STM32F746-DISCO如何运行Linux4.19
本篇文章为大家展示了STM32F746-DISCO如何运行Linux4.19,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
创新互联建站成都企业网站建设服务,提供成都网站设计、成都做网站、外贸网站建设网站开发,网站定制,建网站,网站搭建,网站设计,成都响应式网站建设,网页设计师打造企业风格网站,提供周到的售前咨询和贴心的售后服务。欢迎咨询做网站需要多少钱:18980820575
STM32F746-DISCO运行Linux4.19
Linux Kernel
主线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 $
配置内核使用initramfsmake 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
UBOOT命令行手动下载,引导
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
UBOOT手动下载kernel至spi flash中
sf probe sf erase 0 1000000 sf write c0300000 0 200000 sf write c0500000 200000 4000
UBOOT设置自动从spi flash中引导
可以更改源码将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,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。
分享文章:STM32F746-DISCO如何运行Linux4.19
转载来于:http://pwwzsj.com/article/gdhssp.html