htjgdw 发表于 2018-6-20 13:48:57

使用Buildroot编译STM32F429 linux内核,文件系统成功

Buildroot是一组Makefile和Patch文件,用来简化和自动化为嵌入式系统建造一个完整和可引导的Linux环境的过程,特别是在使用交叉编译来允许在单一的基于Linux的开发系统上为多个目标平台进行建造的时候。以上内容摘自wiki百科:)



最近我发现了Buildroot这个工具(其实早就知道,只是没了解过)出现了stm32的配置文件,于是拿来尝试。下载了最新的版本buildroot-2018.02.2.tar.gz
解压到一个目录:tar xzvf buildroot-2018.02.2.tar.gz
进入目录:cd buildroot-2018.02.2   
配置STM32F429:make ARCH=arm stm32f429_disco_defconfig
编译:make ARCH=arm

剩下的就是等待,Buildroot会自动编译目标系统需要的bootloader,linux kernel,file system。在此过程中它会自动下载需要的软件包,编译器。。。
由于我选择了使用buildroot自动编译,因此这货下载了gcc源码并编译gcc,这花了大约2个小时,后面真正编译的时间并不长也就20分钟不到,最后编译成功,在output/images目录会得到编译好的bootloader,kernel和文件系统。真是太方便了,这在以前是需要我做很多步骤才能完成的事。

下一步烧到板子里试试,看能不能工作。

郭震2009 发表于 2018-6-20 23:07:06

{:handshake:}{:handshake:}{:handshake:}

郭震2009 发表于 2018-6-20 23:07:22

{:handshake:}{:handshake:}

fengxin32 发表于 2018-6-20 23:08:07

能运行么?惊得目瞪口呆。
有这个东西,我还辛辛苦苦的研究如何移植U-boot,如何编译Linux,如果编译根文件干嘛

郭震2009 发表于 2018-6-20 23:08:16

马上实践

浮华一生 发表于 2018-6-20 23:10:22

fengxin32 发表于 2018-6-20 23:08
能运行么?惊得目瞪口呆。
有这个东西,我还辛辛苦苦的研究如何移植U-boot,如何编译Linux,如果编译根文件 ...

定制化的时候, 还是要研究。。。 {:titter:}

honami520 发表于 2018-6-20 23:45:54

buildroot是挺好用的。我用了好几年了。搞全志的都知道这玩意

pinocchio 发表于 2018-6-21 00:22:44

应用在什么场景?

licheng0620 发表于 2018-6-21 01:33:04

使用Buildroot是不是要翻墙才能成功?

ysoni 发表于 2018-6-21 01:57:08

下载留档一份。

htjgdw 发表于 2018-6-21 09:08:05

licheng0620 发表于 2018-6-21 01:33
使用Buildroot是不是要翻墙才能成功?

不至于吧。不过我之前是在可以访问外网的环境下编译的。等回来在家里再试试。

WM_CH 发表于 2018-6-21 16:38:59

厉害哦               

longjunyi 发表于 2018-6-22 08:34:19

期待结果,不知道需要多大空间?

soos 发表于 2018-6-22 08:41:07

顶一把楼主,期侍继续分享

liudan 发表于 2018-6-22 14:09:23

楼主,烧到板子里,可以工作吗?

dhbighead 发表于 2018-6-22 18:56:17

fengxin32 发表于 2018-6-20 23:08
能运行么?惊得目瞪口呆。
有这个东西,我还辛辛苦苦的研究如何移植U-boot,如何编译Linux,如果编译根文件 ...

buildroot在构造根文件目录

dukelec 发表于 2018-6-24 01:47:56

本帖最后由 dukelec 于 2018-6-24 01:51 编辑

之前看内核代码,无意看到有 STM32, 还以为 STM32 高端版本支持 MMU 了呢,原来是反过来,Linux 支持 No-MMU 了。。。

htjgdw 发表于 2018-6-25 12:31:36

dukelec 发表于 2018-6-24 01:47
之前看内核代码,无意看到有 STM32, 还以为 STM32 高端版本支持 MMU 了呢,原来是反过来,Linux 支持 No-MM ...

这个世界在变化{:smile:}

menglongfc 发表于 2018-6-25 14:30:43

fengxin32 发表于 2018-6-20 23:08
能运行么?惊得目瞪口呆。
有这个东西,我还辛辛苦苦的研究如何移植U-boot,如何编译Linux,如果编译根文件 ...

buildroot并不能解决所有问题

htjgdw 发表于 2018-6-25 21:14:07

在我的STM32F429板子上测试,Buildroot生成的文件系统可以使用。之前我构造的文件系统是按照网上搜索的步骤一步一步做出来的,现在简单多了。
鉴于我的板子和STM32F429 Discovery有些区别,需要修改一些源码,所以没有测试buildroot生成的u-boot和kernel,下面就是使用buildroot root filesystem启动linux的log:

## Booting kernel from Legacy Image at c0007fb4 ...
   Image Name:   linux-4.12_STM32F429
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2994400 Bytes =2.9 MB
   Load Address: c0008000
   Entry Point:c0008001
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at c0400000 ...
   Image Name:
   Image Type:   ARM Linux RAMDisk Image (uncompressed)
   Data Size:    459264 Bytes = 448.5 kB
   Load Address: 00000000
   Entry Point:00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at c0800000
   Booting using the fdt blob at 0xc0800000
   Loading Kernel Image ... OK
OK
   Loading Ramdisk to c3f8f000, end c3fff200 ... OK
   Loading Device Tree to c3f88000, end c3f8eece ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.14.0-rc4 (hw@localhost.localdomain) (gcc ver
sion 5.4.1 20160609 (release) (GNU
Tools for ARM Embedded Processors)) #3 PREEMPT Tue Oct 17 14:53:53 CST 2017
[    0.000000] CPU: ARMv7-M revision 1 (ARMv7M), cr=00000000
[    0.000000] CPU: unknown data cache, unknown instruction cache
[    0.000000] OF: fdt: Machine model: STMicroelectronics STM32F429i-DISCO
board
[    0.000000] Built 1 zonelists, mobility grouping on.Total pages: 16256
[    0.000000] Kernel command line: stm32_platform=stm-disco console=ttyS0,
115200 panic=10
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes
)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Memory: 61364K/65536K available (1176K kernel code, 132K rwd
ata, 380K rodata, 1160K init, 114K bss, 4172K reserved, 0K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]   vector: 0x00000000 - 0x00001000   (   4 kB)
[    0.000000]   fixmap: 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]   vmalloc : 0x00000000 - 0xffffffff   (4095 MB)
[    0.000000]   lowmem: 0xc0000000 - 0xc4000000   (64 MB)
[    0.000000]       .text : 0xc0008000 - 0xc012e378   (1177 kB)
[    0.000000]       .init : 0xc01a0000 - 0xc02c2000   (1160 kB)
[    0.000000]       .data : 0xc02c2000 - 0xc02e30e0   ( 133 kB)
[    0.000000]      .bss : 0xc02e30e0 - 0xc02ffab4   ( 115 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]Tasks RCU enabled.
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] /soc/interrupt-controller@40013c00: 23 External IRQs detecte
d
[    0.000000] clocksource: arm_system_timer: mask: 0xffffff max_cycles: 0x
ffffff, max_idle_ns: 355517175 ns
[    0.000000] ARM System timer initialized as clocksource
[    0.000000] /soc/timer@40000c00: STM32 clockevent driver initialized (32
bits)
[    0.000000] sched_clock: 32 bits at 100 Hz, resolution 10000000ns, wraps
every 21474836475000000ns
[    0.010000] Calibrating delay loop... 13.33 BogoMIPS (lpj=66688)
[    0.140000] pid_max: default: 4096 minimum: 301
[    0.140000] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.140000] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 by
tes)
[    0.160000] Hierarchical SRCU implementation.
[    0.180000] devtmpfs: initialized
[    0.320000] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xfffffff
f, max_idle_ns: 19112604462750000 ns
[    0.330000] pinctrl core: initialized pinctrl subsystem
[    0.450000] stm32f429-pinctrl soc:pin-controller: GPIOA bank added
[    0.460000] stm32f429-pinctrl soc:pin-controller: GPIOB bank added
[    0.460000] stm32f429-pinctrl soc:pin-controller: GPIOC bank added
[    0.470000] stm32f429-pinctrl soc:pin-controller: GPIOD bank added
[    0.470000] stm32f429-pinctrl soc:pin-controller: GPIOE bank added
[    0.480000] stm32f429-pinctrl soc:pin-controller: GPIOF bank added
[    0.480000] stm32f429-pinctrl soc:pin-controller: GPIOG bank added
[    0.490000] stm32f429-pinctrl soc:pin-controller: GPIOH bank added
[    0.490000] stm32f429-pinctrl soc:pin-controller: GPIOI bank added
[    0.500000] stm32f429-pinctrl soc:pin-controller: GPIOJ bank added
[    0.500000] stm32f429-pinctrl soc:pin-controller: GPIOK bank added
[    0.500000] stm32f429-pinctrl soc:pin-controller: Pinctrl STM32 initiali
zed
[    0.610000] stm32-dma 40026000.dma-controller: STM32 DMA driver register
ed
[    0.630000] stm32-dma 40026400.dma-controller: STM32 DMA driver register
ed
[    0.640000] random: fast init done
[    0.650000] clocksource: Switched to clocksource arm_system_timer
[    5.610000] Trying to unpack rootfs image as initramfs...
[    6.040000] Freeing initrd memory: 452K
[    6.060000] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    6.270000] io scheduler noop registered (default)
[    6.270000] io scheduler mq-deadline registered
[    6.270000] io scheduler kyber registered
[    6.280000] STM32 USART driver initialized
[    6.290000] 40011000.serial: ttyS0 at MMIO 0x40011000 (irq = 32, base_ba
ud = 5250000) is a stm32-usart
[    6.640000] console enabled
[    6.860000] brd: module loaded
[    6.970000] stm32_rtc 40002800.rtc: Can't enter in init mode. Prescaler
config failed.
[    6.980000] stm32_rtc: probe of 40002800.rtc failed with error -110
[    6.980000] i2c /dev entries driver
[    6.990000] IR NEC protocol handler initialized
[    7.000000] IR RC5(x/sz) protocol handler initialized
[    7.000000] IR RC6 protocol handler initialized
[    7.010000] IR JVC protocol handler initialized
[    7.010000] IR Sony protocol handler initialized
[    7.020000] IR SANYO protocol handler initialized
[    7.020000] IR Sharp protocol handler initialized
[    7.030000] IR MCE Keyboard/mouse protocol handler initialized
[    7.030000] IR XMP protocol handler initialized
[    7.080000] input: gpio_keys as /devices/platform/gpio_keys/input/input0
[    7.090000] hctosys: unable to open rtc device (rtc0)
[    7.220000] Freeing unused kernel memory: 1160K
[    7.230000] This architecture does not have kernel memory protection.
Initializing random number generator... done.

Welcome to Buildroot
buildroot login: root
Jan1 00:00:17 login: root login on 'console'
~ # ls
~ # pwd
/root
~ # cd ..
/ # ls
bin      init   linuxrcopt      run      tmp
dev      lib      media    proc   sbin   usr
etc      lib32    mnt      root   sys      var
/ # ls dev
console             mem               ram3
cpu_dma_latency   memory_bandwidth    ram4
full                network_latency   ram5
gpiochip0         network_throughputram6
gpiochip1         null                ram7
gpiochip10          pts               ram8
gpiochip2         ram0                ram9
gpiochip3         ram1                random
gpiochip4         ram10               shm
gpiochip5         ram11               tty
gpiochip6         ram12               ttyS0
gpiochip7         ram13               urandom
gpiochip8         ram14               zero
gpiochip9         ram15
kmsg                ram2
/ #

fengxin32 发表于 2018-6-25 22:21:58

htjgdw 发表于 2018-6-25 21:14
在我的STM32F429板子上测试,Buildroot生成的文件系统可以使用。之前我构造的文件系统是按照网上搜索的步骤 ...

非常感谢。我也去试试。
先去查查编译环境能指定现成的不,编译GCC太慢了,尤其是那个编译三次的选项

htjgdw 发表于 2018-6-26 13:58:57

ayuanshop 发表于 2018-6-25 22:16
我手上只有cmsis-dap,用的虚拟机编译的br,请问要怎么烧些xipimage呢

把bootloader烧进去,后面就不需要cmsis-dap了。用bootloader网络下载烧写image到板子上。
话说,如果用串口烧写bootloader,那么连cmsis-dap也可以没有。

7nian 发表于 2018-6-26 17:33:24

强烈关注,希望玩起来的大神能出个教程,带带我们

1066950103 发表于 2018-6-26 18:42:27

honami520 发表于 2018-6-20 23:45
buildroot是挺好用的。我用了好几年了。搞全志的都知道这玩意

你是全志linux哈 硬解码 有库么?gpu能用么?

honami520 发表于 2018-6-26 19:38:40

1066950103 发表于 2018-6-26 18:42
你是全志linux哈 硬解码 有库么?gpu能用么?

gpu当然不能用啊。linux无法使用。只能软解

htjgdw 发表于 2018-6-27 09:29:12

ayuanshop 发表于 2018-6-26 16:01
额。。。。我找不到bootloader在哪里,或者怎么做

buildroot可以编译u-boot,你在menuconfig里找,把u-boot选上。然后退出,make,buildroot就会自动编译u-boot了,最后会在output/images目录生成u-boot.bin

armstrong 发表于 2018-7-2 13:57:46

honami520 发表于 2018-6-26 19:38
gpu当然不能用啊。linux无法使用。只能软解

原来用linux也有不能克服的无奈啊,我还以为厂家的linux-bsp都很好用呢。
页: [1]
查看完整版本: 使用Buildroot编译STM32F429 linux内核,文件系统成功