openSUSE:ARM 技术研讨会 2014/STM32F429
作为 ARM 平台和 在 ARM 上 开发 openSUSE 13.2 开发工具的演示, 演示了来自 SUSE Hackweek Interstellar 项目:在 STM32F4 微控制器上运行的 Linux。
硬件
由 Rutronik 慷慨提供 STM32F4 Discovery kit for STM32F429。
- STM32F429ZIT6 微控制器
- 180 MHz 的 ARM Cortex-M4F
- 2 MB 内部 Flash
- 256 KB 内部 SRAM
- 8 MB 板载 SDRAM
ARM 技术研讨会的新内容
在 ARM Tech Symposium Europe 演示中新增的内容是 内核。它最初基于 v3.18-rc5,后来重新基于 v3.18-rc6,并使用新的设备树概念来描述硬件。
实现了以下最少数量的内核驱动程序
- USART3 earlyprintk 支持
- SysTick 时钟源
- RCC 时钟控制器
- TIM2 时钟事件
- USART3 串口控制台
- LTDC 帧缓冲区
未实现的是,其中包括
- GPIO 控制器(依赖于引导加载程序)
- RCC 复位控制器(使用临时复位代码代替)
- 用于串口的 DMA
- DMA2D 帧缓冲区加速
- LTDC 初始化(依赖于引导加载程序)
- RTC
- USB
U-Boot 引导加载程序来自 此处,并且仅修改为从不同的 Flash 地址加载内核,并将设备树 Flash 地址传递给内核。
更新
来自 home:a_faerber:arm 的 genromfs 包已被删除,因为它已在 Base:System 中可用。
最新的内核工作重新基于 v3.19-rc1 位于 此处
- RCC 的复位驱动程序(正在进行中)
初始 U-Boot 引导加载程序工作位于 此处,尚未完全构建。另请参阅 U-Boot 邮件列表上的“[U-Boot] [PATCH v2] arm: build arch memset/memcpy in Thumb2 mode”。
作为替代方案,已经提供了一个非交互式的 自定义引导加载程序。它使用的 Flash 空间小于 2 KB,从而释放更多空间用于内核和设备树。
详细信息
Flash 布局
| 开始 | 结束 | 大小 | 已用 | 目录 |
|---|---|---|---|---|
| 0x08000000 | 0x0801FFFF | 128 KB | 75048 B | U-Boot 引导加载程序 |
| 0x08020000 | 0x08020FFF | 4096 B | 3017 B | 扁平设备树 |
| 0x08021000 | 0x0811FFFF | 1 MB 减去 4096 B | 1025908 B | Linux 内核 (XIP) |
| 0x08120000 | 0x081FFFFF | 1 MB 减去 128 KB | 293888 B | 带有 busybox 的 ROMFS 文件系统 |
注意:由于 Flash 擦除大小限制,内核和设备树需要一起刷新。
命令
openocd -f board/stm32f429discovery.cfg \
-c "init" \
-c "reset init" \
-c "flash probe 0" \
-c "flash info 0" \
-c "flash write_image erase dtb+uImage.bin 0x08020000" \
-c "reset run" \
-c "shutdown"
工具
内核编译器:gcc 4.8-6.1 / gcc48 4.8.3+r212056-5.1 来自 openSUSE Factory
$ gcc --version gcc (SUSE Linux) 4.8.3 20140627 [gcc-4_8-branch revision 212064] Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
内核汇编器:binutils 2.24-5.1 来自 openSUSE Factory
$ as --version GNU assembler (GNU Binutils; openSUSE Factory) 2.24.0.20140403-5 Copyright 2013 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or later. This program has absolutely no warranty. This assembler was configured for a target of `armv7hl-suse-linux-gnueabi'.
刷新器和片上调试器:openocd 0.8.0-4.1 来自 openSUSE Factory
$ openocd --version Open On-Chip Debugger 0.8.0 (2014-10-11-17:40) Licensed under GNU GPL v2 For bug reports, read http://openocd.sourceforge.net/doc/doxygen/bugs.html
调试器:gdb 7.8-4.1 来自 openSUSE Factory
$ gdb --version GNU gdb (GDB; openSUSE Factory) 7.8 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "armv7hl-suse-linux". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://bugs.opensuse.org/>. Find the GDB manual and other documentation resources online at: <https://gnu.ac.cn/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word".
文件系统创建:genromfs 0.5.2-95.1.2 来自 openSUSE 13.2 (在 x86_64 上)
$ genromfs -h genromfs 0.5.2 Usage: genromfs [OPTIONS] -f IMAGE Create a romfs filesystem image from a directory -f IMAGE Output the image into this file -d DIRECTORY Use this directory as source -v (Too) verbose operation -V VOLUME Use the specified volume name -a ALIGN Align regular file data to ALIGN bytes -A ALIGN,PATTERN Align all objects matching pattern to at least ALIGN bytes -x PATTERN Exclude all objects matching pattern -h Show this help
输出
U-Boot 2010.03-00003-g934021a-dirty (Nov 29 2014 - 02:04:13)
CPU : STM32F4 (Cortex-M4)
Freqs: SYSCLK=180MHz,HCLK=180MHz,PCLK1=45MHz,PCLK2=90MHz
Board: STM32F429I-DISCOVERY board,Rev 1.0
DRAM: 8 MB
Using default environment
Hit any key to stop autoboot: 0
## Booting kernel from Legacy Image at 08021000 ...
Image Name: Linux-3.18
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1025844 Bytes = 1001.8 kB
Load Address: 08021040
Entry Point: 08021041
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Booting Linux on physical CPU 0x0
Linux version 3.18.0-rc6-00016-g4c00142-dirty (andreas@droide) (gcc version 4.8.3 20140627 [gcc-4_8-branch revision 212064] (SUSE Linux) ) #165 Mon Dec 1 04:27:08 CET 2014
CPU: ARMv7-M [410fc241] revision 1 (ARMv7M), cr=00000000
CPU: unknown data cache, unknown instruction cache
Machine model: ST STM32F4 Discovery kit for STM32F429
bootconsole [earlycon0] enabled
debug: ignoring loglevel setting.
On node 0 totalpages: 2048
free_area_init_node: node 0, pgdat 9001fb60, node_mem_map 906f0000
Normal zone: 16 pages used for memmap
Normal zone: 0 pages reserved
Normal zone: 2048 pages, LIFO batch:0
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping off. Total pages: 2032
Kernel command line: console=ttystm3,115200n8 earlyprintk ignore_loglevel debug clk_ignore_unused ihash_entries=64 dhash_entries=64 uclinux.physaddr=0x08120000 root=/dev/mtdblock0 rdinit=/sbin/init
PID hash table entries: 32 (order: -5, 128 bytes)
Dentry cache hash table entries: 64 (order: -4, 256 bytes)
Inode-cache hash table entries: 64 (order: -4, 256 bytes)
Memory: 6904K/8192K available (758K kernel code, 76K rwdata, 104K rodata, 60K init, 55K bss, 1288K reserved)
Virtual kernel memory layout:
vector : 0x00000000 - 0x00001000 ( 4 kB)
fixmap : 0xffc00000 - 0xffe00000 (2048 kB)
vmalloc : 0x00000000 - 0xffffffff (4095 MB)
lowmem : 0x90000000 - 0x90800000 ( 8 MB)
.text : 0x08021040 - 0x080f8928 ( 863 kB)
.init : 0x9000a000 - 0x9000f000 ( 20 kB)
.data : 0x90008000 - 0x90020200 ( 97 kB)
.bss : 0x90020200 - 0x9002debc ( 56 kB)
NR_IRQS:16 nr_irqs:16 16
rcc @ 0x40023800
clk HSI @ 16000000
clk HSE @ 8000000
clk PLLSRC @ 8000000
clk PLL @ 360000000
clk PLLCLK @ 180000000
clk PLL48CK @ 51428572
clk SYSCLK @ 180000000
clk AHB @ 180000000
clk APB1 @ 45000000
clk TIM2 @ 45000000
clk TIM3 @ 45000000
clk TIM4 @ 45000000
clk TIM5 @ 45000000
clk USART3 @ 45000000
clk APB2 @ 90000000
timer @ 0x40000000 (90000000)
before TIMx CR1 (40000000)
before TIMx CR1 (40000000)
systick @ 0xe000e010 (22500000)
sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps every 21474836480000000ns
Console: colour dummy device 80x30
Calibrating delay loop... 118.68 BogoMIPS (lpj=593408)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
devtmpfs: initialized
Switched to clocksource cortex-m3-systick
futex hash table entries: 256 (order: -1, 3072 bytes)
romfs: ROMFS MTD (C) 2007 Red Hat, Inc.
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered (default)
Console: switching to colour frame buffer device 30x40
stm32_usart 40004800.uart: ttystm3 at MMIO 0x40004800 (irq = 17, base_baud = 0) is a stm32_usart
console [ttystm3] enabled
bootconsole [earlycon0] disabled
brd: module loaded
uclinux[mtd]: probe address=0x8120000 size=0x48000
Creating 1 MTD partitions on "rom":
0x000000000000-0x000000048000 : "ROMfs"
clk: Not disabling unused clocks
VFS: Mounted root (romfs filesystem) readonly on device 31:0.
devtmpfs: mounted
Freeing unused kernel memory: 20K (9000a000 - 9000f000)
starting pid 23, tty '/dev/ttystm3': '/bin/login -f root'
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || | | | | |_| |/ \
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_|
For further information check:
http://www.uclinux.org/
Jan 1 00:00:00 login[23]: root login on 'ttystm3'
~ #
~ # cat /proc/cpuinfo processor : 0 model name : ARMv7-M rev 1 (v7ml) Features : half thumb fastmult idivt CPU implementer : 0x41 CPU architecture: 7M CPU variant : 0x0 CPU part : 0xc24 CPU revision : 1 Hardware : STM32 (Device Tree Support) Revision : 0000 Serial : 0000000000000000
~ # cat /proc/meminfo MemTotal: 6924 kB MemFree: 3752 kB MemAvailable: 3664 kB Buffers: 264 kB Cached: 296 kB SwapCached: 0 kB Active: 508 kB Inactive: 32 kB Active(anon): 0 kB Inactive(anon): 0 kB Active(file): 508 kB Inactive(file): 32 kB Unevictable: 0 kB Mlocked: 0 kB MmapCopy: 824 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 0 kB Writeback: 0 kB AnonPages: 0 kB Mapped: 0 kB Shmem: 0 kB Slab: 612 kB SReclaimable: 100 kB SUnreclaim: 512 kB KernelStack: 136 kB PageTables: 0 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 3460 kB Committed_AS: 0 kB VmallocTotal: 0 kB VmallocUsed: 0 kB VmallocChunk: 0 kB
~ # cat /proc/iomem 90000000-907fffff : System RAM 90008000-9002debb : Kernel data
~ # busybox
BusyBox v1.22.1 (2014-11-29 03:23:08 CET) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2012.
Licensed under GPLv2. See source distribution for detailed
copyright notices.
Usage: busybox [function [arguments]...]
or: busybox --list
or: function [arguments]...
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as.
Currently defined functions:
bash, cat, chgrp, chmod, chown, chroot, clear, cp, date, dd, df, dmesg,
du, fbset, free, freeramdisk, fuser, getty, halt, hd, head, hexdump,
hush, init, insmod, iostat, kill, killall, killall5, less, ln, login,
ls, lsmod, md5sum, mkdir, mkdosfs, mke2fs, mkfs.ext2, mkfs.vfat, mknod,
modinfo, more, mount, mv, passwd, pgrep, pidof, pkill, poweroff, ps,
pstree, pwd, reboot, renice, reset, rm, rmdir, rmmod, sh, sleep, stat,
sync, sysctl, tail, time, top, umount, uname, uptime, vi, watch