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

[复制链接]
3453|3
 楼主| 不爱说话 发表于 2018-6-20 14:07 | 显示全部楼层 |阅读模式
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和文件系统。真是太方便了,这在以前是需要我做很多步骤才能完成的事。

下一步烧到板子里试试,看能不能工作。
xyz549040622 发表于 2018-6-20 14:30 来自手机 | 显示全部楼层
赞一个,期待实际运行速度的测试。
caijie001 发表于 2018-6-21 00:44 | 显示全部楼层
期待教程啊哈哈哈
 楼主| 不爱说话 发表于 2018-6-25 21:16 | 显示全部楼层
在我的STM32F429板子上测试,Buildroot生成的文件系统可以使用。之前我构造的文件系统是按照网上搜索的步骤一步一步做出来的,现在简单多了。
鉴于我的板子和STM32F429 Discovery有些区别,需要修改一些源码,所以没有测试buildroot生成的u-boot和kernel,下面就是使用buildroot root filesystem启动linux的log:
  1. ## Booting kernel from Legacy Image at c0007fb4 ...
  2.    Image Name:   linux-4.12_STM32F429
  3.    Image Type:   ARM Linux Kernel Image (uncompressed)
  4.    Data Size:    2994400 Bytes =  2.9 MB
  5.    Load Address: c0008000
  6.    Entry Point:  c0008001
  7.    Verifying Checksum ... OK
  8. ## Loading init Ramdisk from Legacy Image at c0400000 ...
  9.    Image Name:
  10.    Image Type:   ARM Linux RAMDisk Image (uncompressed)
  11.    Data Size:    459264 Bytes = 448.5 kB
  12.    Load Address: 00000000
  13.    Entry Point:  00000000
  14.    Verifying Checksum ... OK
  15. ## Flattened Device Tree blob at c0800000
  16.    Booting using the fdt blob at 0xc0800000
  17.    Loading Kernel Image ... OK
  18. OK
  19.    Loading Ramdisk to c3f8f000, end c3fff200 ... OK
  20.    Loading Device Tree to c3f88000, end c3f8eece ... OK

  21. Starting kernel ...

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

  119. Welcome to Buildroot
  120. buildroot login: root
  121. Jan  1 00:00:17 login[47]: root login on 'console'
  122. ~ # ls
  123. ~ # pwd
  124. /root
  125. ~ # cd ..
  126. / # ls
  127. bin      init     linuxrc  opt      run      tmp
  128. dev      lib      media    proc     sbin     usr
  129. etc      lib32    mnt      root     sys      var
  130. / # ls dev
  131. console             mem                 ram3
  132. cpu_dma_latency     memory_bandwidth    ram4
  133. full                network_latency     ram5
  134. gpiochip0           network_throughput  ram6
  135. gpiochip1           null                ram7
  136. gpiochip10          pts                 ram8
  137. gpiochip2           ram0                ram9
  138. gpiochip3           ram1                random
  139. gpiochip4           ram10               shm
  140. gpiochip5           ram11               tty
  141. gpiochip6           ram12               ttyS0
  142. gpiochip7           ram13               urandom
  143. gpiochip8           ram14               zero
  144. gpiochip9           ram15
  145. kmsg                ram2
  146. / #


您需要登录后才可以回帖 登录 | 注册

本版积分规则

115

主题

886

帖子

34

粉丝
快速回复 在线客服 返回列表 返回顶部