debian下为stm32f429i-discovery编译uboot、linux内核和根文件系统

交叉编译器:arm-uclinuxeabi-2010q1

交叉编译器下载下来后解压,然后将其中bin文件夹路径加入到PATH变量中.

根据《debian下烧写stm32f429I discovery裸机程序》安装openocd.

安装genromfs,使用下面命令:

sudo apt-get install genromfs

已经有人提供好脚本,只要执行几条命令即可。使用git下载文件并进行编译:

git clone https://github.com/jserv/stm32f429-linux-builder.git
make

会自动从github仓库中将uboot和内核源码以及busybox下载下来,并且制作成u-boot.bin,xipImage.bin,以及romfs.bin

如果已经连接好开发板和pc,可以用make install将文件加载到开发板中(因为现在手头没有开发板,所以没有测试这一步)。

需要注意是,这个版本的uboot中使用uart3来作为串口连接端,如果使用ft232与开发板相连,那么连接方式如下:

GND和VCC连线方式不变,但PC10连接TXD,PC11连接RXD。

之前我试过直接编译这个uboot,然后采用uart3来进行连接,用minicom可以看到到uboot的输出信息。

其他内容我还没有测试。

补注:几天后我找到了开发板,然后执行make install,但是失败了。因为make install 其实相当于调用了下面的命令(请查看文件mk/flash.mak):

 openocd \
-f interface/stlink-v2.cfg \
-f target/stm32f4x_stlink.cfg \
-c "init" \
-c "reset init" \
-c "flash probe 0" \
-c "flash info 0" \
-c "flash write_image erase $(uboot_target) 0x08000000" \
-c "flash write_image erase $(kernel_target) 0x08020000" \
-c "flash write_image erase $(rootfs_target) 0x08120000" \
-c "reset run" -c shutdown

这是因为我使用了普通账户来执行命令,而openocd需要用root账户才能执行成功。我在openocd 前添加了sudo,然后再执行make install,烧写成功。

然后使用uart3连接串口,并重启开发板,使用minicom打开串口,得到下面的信息:

U-Boot 2010.03--g934021a (Jun   - ::)

CPU  : STM32F4 (Cortex-M4)
Freqs: SYSCLK=180MHz,HCLK=180MHz,PCLK1=45MHz,PCLK2=90MHz
Board: STM32F429I-DISCOVERY board,Rev 1.0
DRAM: MB
Using default environment Hit any key to stop autoboot:
## Booting kernel from Legacy Image at ...
Image Name: Linux-2.6.-arm1
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: Bytes = kB
Load Address:
Entry Point:
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK Starting kernel ... Linux version 2.6.-arm1 (host@debian) (gcc version 4.4. (Sourcery G++ Lite 2010q1-) ) # Mon Jun :: CST
CPU: ARMv7-M Processor [410fc241] revision (ARMv7M)
CPU: NO data cache, NO instruction cache
Machine: STMicro STM32
Ignoring unrecognised tag 0x54410008
Built zonelists in Zone order, mobility grouping off. Total pages:
Kernel command line: stm32_platform=stm32429-disco mem=7M console=ttyS2,115200n8 consoleblank= root=/dev/mtdblock0 rdinit=/sbin/init video=vfb:enable,fbmem:0x907000000
PID hash table entries: (order: -, bytes)
Dentry cache hash table entries: (order: , bytes)
Inode-cache hash table entries: (order: , bytes)
Memory: 7MB = 7MB total
Memory: 6976k/6976k available, 192k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0x00000000 - 0x00001000 ( kB)
fixmap : 0xfff00000 - 0xfffe0000 ( kB)
vmalloc : 0x00000000 - 0xffffffff ( MB)
lowmem : 0x90000000 - 0x90700000 ( MB)
modules : 0x90000000 - 0x90800000 ( MB)
.init : 0x9000a000 - 0x9000e000 ( kB)
.text : 0x08028000 - 0x080c4000 ( kB)
.data : 0x90008000 - 0x90018460 ( kB)
Hierarchical RCU implementation.
NR_IRQS:
Console: colour dummy device 80x30
Calibrating delay loop... 168.34 BogoMIPS (lpj=)
Mount-cache hash table entries:
bio: create slab <bio-> at
Switching to clocksource cm3-systick
ROMFS MTD (C) Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered (default)
Console: switching to colour frame buffer device 60x53
fb0: Virtual frame buffer device, using 1024K of video memory
Serial: STM32 USART driver
stm32serial.: ttyS2 at MMIO 0x40004800 (irq = ) is a STM32 USART Port
console [ttyS2] enabled
brd: module loaded
uclinux[mtd]: ROM probe address=0x8120000 size=0x59000
Creating MTD partitions on "ROM":
0x000000000000-0x000000059000 : "ROMfs"
ARMv7-M VFP Extension supported
VFS: Mounted root (romfs filesystem) readonly on device :.
Freeing init memory: 16K
starting pid , tty '/dev/ttyS2': '/bin/login -f root'
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || | | | | |_| |/ \
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_| For further information check:
http://www.uclinux.org/ Jan :: login[]: root login on 'ttyS2'
~ # ls
bin etc proc root sys usr
dev lib ramfs.img sbin tmp var

同时在开发板屏幕上还显示了一个企鹅的图标。

基本上测试就完成了,整个脚本都是完全可以使用的。如果需要在开发板上添加额外的模块。可以直接在现在的源代码下添加功能,相信会节约不少时间。

上一篇:51单片机小项目电路TwoLed电路图


下一篇:java反射快速入门