您好,登錄后才能下訂單哦!
本篇文章為大家展示了STM32F746-DISCO如何運行Linux4.19,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
主線linux已經提供對無MMU的處理器的支持,configs中已經存在stm32_defconfig,DTS中包含:stm32f746-disco;因此只需要編譯即可。
下載主線源碼:http://cdn.kernel.org/pub/linux/kernel/v4.x
安裝交叉編譯鏈,可以使用之前編譯uboot的arm-none-eabi-gcc,但是這個是編譯鏈線程模式是single,而不是posix,也就是說雖然這個編譯鏈可以編譯內核和根文件系統,但是不能編譯linux應用程序。如果需要支持編譯linux應用程序(一般要支持,不然移植linux干嘛--!),則需要自己去構建交叉編譯鏈,網上講解的比較詳細,不過我推薦使用Buildroot來構建支持stm32的交叉編譯鏈,簡單快捷,當然也可以用Buildroot來構建內核和根文件系統。
根文件系統可以使用busybox構建,也可以使用buildroot構建。
elinux.org提供了一個使用busybox編譯好的Ramdisk最小系統,File:Stm32 mini rootfs.cpio.bz2, 但需要做如下改動:
使用initramfs,將下載的Stm32_mini_rootfs.cpio.bz2解壓,先解壓成cpio文件:
bzip2 -d Stm32_mini_rootfs.cpio.bz2
創建文件夾rootfs:
mkdir rootfs
將文件解壓到rootfs文件夾中:
cpio -idmv <../Stm32_mini_rootfs.cpio
看看dev中是否有null,tty0,console節點,沒有的話需要在dev文件夾中創建這三個節點。
sudo mknod console c 5 1 sudo mknod null c 1 3 sudo mknod tty0 c 204 64
再rootfs文件夾下新建init文件,內容如下
#!/bin/sh # devtmpfs does not get automounted for initramfs /bin/mount -t devtmpfs devtmpfs /dev exec 0/dev/console exec 2>/dev/console exec /sbin/init $
配置內核使用initramfs
make ARCH=arm CROSS_COMPILE=arm-none-eabi- menuconfig
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support (/work/system/my-linux/rootfs) Initramfs source file(s)
上述步驟主要參考了這位老哥的實現,https://blog.csdn.net/u011371090/article/details/81587170
如果需要使用其他類型的根文件系統,比如ext4等,需要修改bootcmd,具體再研究。
make ARCH=arm CROSS_COMPILE=arm-none-eabi- stm32_defconfig make mkimage -n 'linux' -A arm -O linux -T kernel -C none -a 0xc0300000 -e 0xc0300000 -d ./arch/arm/boot/zImage uImage
setenv ipaddr 192.168.66.69 setenv serverip 192.168.66.66 tftp c0300000 uImage tftp c0500000 stm32f746-disco.dtb setenv bootargs "root=/dev/ram console=ttySTM0,115200" bootm c0300000 - c0500000
sf probe sf erase 0 1000000 sf write c0300000 0 200000 sf write c0500000 200000 4000
可以更改源碼將bootcmd寫入源碼中,不然每次都要手動改。
setenv bootcmd "setenv bootargs "root=/dev/ram console=ttySTM0,115200"; sf probe; sf read c0300000 0 200000;sf read c0500000 200000 4000;bootm c0300000 - c0500000;"
U-Boot > env set bootargs "root=/dev/ram console=ttySTM0,115200" U-Boot > bootm c0300000 - c0500000 ## Booting kernel from Legacy Image at c0300000 ... Image Name: linux Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 1519384 Bytes = 1.4 MiB Load Address: c0300000 Entry Point: c0300000 Verifying Checksum ... OK ## Flattened Device Tree blob at c0500000 Booting using the fdt blob at 0xc0500000 Loading Kernel Image ... OK Using Device Tree in place at c0500000, end c0506a09 Starting kernel ... [ 0.000000] Booting Linux on physical CPU 0x0 [ 0.000000] Linux version 4.19.69 (yhang@localhost.localdomain) (gcc version 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907] (GNU Tools for Arm Embedded Processors 7-2018-q2-update)) #1 PREEMPT Thu Sep 5 09:03:24 CST 2019 [ 0.000000] CPU: ARMv7-M [410fc271] revision 1 (ARMv7M), cr=00000000 [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache [ 0.000000] OF: fdt: Machine model: STMicroelectronics STM32F746-DISCO board [ 0.000000] random: get_random_bytes called from start_kernel+0x55/0x2c8 with crng_init=0 [ 0.000000] Built 1 zonelists, mobility grouping off. Total pages: 2032 [ 0.000000] Kernel command line: root=/dev/ram console=ttySTM0,115200 [ 0.000000] Dentry cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.000000] Inode-cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.000000] Memory: 5508K/8192K available (1479K kernel code, 142K rwdata, 472K rodata, 216K init, 115K bss, 2684K 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 - 0xc0800000 ( 8 MB) [ 0.000000] .text : 0x(ptrval) - 0x(ptrval) (1480 kB) [ 0.000000] .init : 0x(ptrval) - 0x(ptrval) ( 216 kB) [ 0.000000] .data : 0x(ptrval) - 0x(ptrval) ( 143 kB) [ 0.000000] .bss : 0x(ptrval) - 0x(ptrval) ( 116 kB) [ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [ 0.000000] rcu: Preemptible hierarchical RCU implementation. [ 0.000000] Tasks RCU enabled. [ 0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16 [ 0.000000] interrupt-controller@40013c00: bank0, External IRQs available:0xffffff [ 0.000000] clocksource: arm_system_timer: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 298634427 ns [ 0.000000] ARM System timer initialized as clocksource [ 0.000067] sched_clock: 32 bits at 100MHz, resolution 10ns, wraps every 21474836475ns [ 0.000154] timer@40000c00: STM32 sched_clock registered [ 0.000250] Switching to timer-based delay loop, resolution 10ns [ 0.000322] timer@40000c00: STM32 delay timer registered [ 0.000434] clocksource: timer@40000c00: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604467 ns [ 0.000592] /soc/timer@40000c00: STM32 clockevent driver initialized (32 bits) [ 0.001473] Calibrating delay loop (skipped), value calculated using timer frequency.. 200.00 BogoMIPS (lpj=1000000) [ 0.001635] pid_max: default: 4096 minimum: 301 [ 0.002945] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.003100] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes) [ 0.012600] rcu: Hierarchical SRCU implementation. [ 0.017399] devtmpfs: initialized [ 0.069578] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.069719] pinctrl core: initialized pinctrl subsystem [ 0.108491] stm32f746-pinctrl soc:pin-controller: GPIOA bank added [ 0.110059] stm32f746-pinctrl soc:pin-controller: GPIOB bank added [ 0.111741] stm32f746-pinctrl soc:pin-controller: GPIOC bank added [ 0.113419] stm32f746-pinctrl soc:pin-controller: GPIOD bank added [ 0.114960] stm32f746-pinctrl soc:pin-controller: GPIOE bank added [ 0.116526] stm32f746-pinctrl soc:pin-controller: GPIOF bank added [ 0.118141] stm32f746-pinctrl soc:pin-controller: GPIOG bank added [ 0.119682] stm32f746-pinctrl soc:pin-controller: GPIOH bank added [ 0.121218] stm32f746-pinctrl soc:pin-controller: GPIOI bank added [ 0.123182] stm32f746-pinctrl soc:pin-controller: GPIOJ bank added [ 0.124780] stm32f746-pinctrl soc:pin-controller: GPIOK bank added [ 0.124952] stm32f746-pinctrl soc:pin-controller: Pinctrl STM32 initialized [ 0.167396] clocksource: Switched to clocksource timer@40000c00 [ 0.286124] workingset: timestamp_bits=30 max_order=11 bucket_order=0 [ 0.355551] io scheduler noop registered (default) [ 0.355664] io scheduler mq-deadline registered [ 0.355753] io scheduler kyber registered [ 0.359175] STM32 USART driver initialized [ 0.360584] 40011000.serial: ttySTM0 at MMIO 0x40011000 (irq = 33, base_baud = 6250000) is a stm32-usart [ 0.757352] console [ttySTM0] enabled [ 0.763214] stm32-usart 40011000.serial: rx dma alloc failed [ 0.769230] stm32-usart 40011000.serial: interrupt mode used for rx (no dma) [ 0.776229] stm32-usart 40011000.serial: tx dma alloc failed [ 0.782067] stm32-usart 40011000.serial: interrupt mode used for tx (no dma) [ 0.792438] i2c /dev entries driver [ 0.843743] stm32f7-i2c 40005400.i2c: can't use DMA [ 0.851160] stm32f7-i2c 40005400.i2c: STM32F7 I2C-0 bus adapter [ 0.862408] mmci-pl18x 40012c00.sdio1: Got CD GPIO [ 0.868031] mmci-pl18x 40012c00.sdio1: Linked as a consumer to regulator.2 [ 0.875138] mmci-pl18x 40012c00.sdio1: mmc0: PL180 manf 80 rev8 at 0x40012c00 irq 34,0 (pio) [ 0.883767] mmci-pl18x 40012c00.sdio1: DMA channels RX none, TX none [ 0.928369] hctosys: unable to open rtc device (rtc0) [ 0.935401] mmc_vcard: disabling [ 0.941700] Freeing unused kernel memory: 216K [ 0.946045] This architecture does not have kernel memory protection. [ 0.952691] Run /init as init process
上述內容就是STM32F746-DISCO如何運行Linux4.19,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。