介绍两种移植方法
第一种:AFboot + Linux4.13.12 + Stm32_mini_rootfs.cpio.bz2
第二种:u-boot-2016.03 + Linux4.13.12 + Stm32_mini_rootfs.cpio.bz2
硬件:stm32f429-discovery
软件平台:ubuntu-12.04
1. 交叉连接器
下载地址:https ://launchpad.net/gcc-arm-embedded/+download
我下载的是gcc-arm-none-eabi-5_4-2016q3 -20160926-linux.tar.bz2
安装交叉编译器。
2.下载linux4.13.12源码
下载地址:https :
//mirrors.edge.kernel.org/pub/linux/kernel/下载Linux-4.13.12.tar. xz
3.下载uboot
下载地址:http://ftp.denx.de/pub/u-boot/
下载u-boot-2016.03.tar.bz2
4.下载afboot
下载地址:https://github.com/mcoquelin -stm32/afboot-stm32.git
下载afboot-stm32-master.zip
5.下载的rootfs
下载地址:https://elinux.org/File:Stm32_mini_rootfs.cpio.bz2
下载Stm32_mini_rootfs.cpio.bz2
AFboot + Linux4.13.12 + Stm32_mini_rootfs.cpio.bz2
打开afboot的Makefile,可以看到kernel和dtb在FLASH中的位置
KERNEL_ADDR?=0x08008000
DTB_ADDR?=0x08004000
编译afboot:make stm32f429i-
discostm32f429i-disco.bin。
系统文件使用initramfs,2s_cp_2_cpio,
先解压stmfs解压成cpio文件:bzip2 -d Stm32_mini_rootfs.cpio.bz2
创建文件夹rootfs:mkdir rootfs
将文件解压到rootfs文件夹中:cpio -idmv 《 。./Stm32_mini_rootfs.cpiodev
中是否有null,tty0,console节点,没有在开发者文件夹中创建这三个节点。
sudo mknod console c 5 1sudo mknod null c 1 3sudo mknod tty0 c 204 64 在rootfs文件夹下面添加init文件,文件中添加下面的内容
#!/bin/sh# devtmpfs不会自动挂载为initramfs/bin/mount - t devtmpfs devtmpfs /devexec 0《/dev/consoleexec 1》/dev/consoleexec 2》/dev/consoleexec /***in/init $
配置Linux4.9内核:make stm32_defconfig
在menuconfig中添加rootfs文件的文件的路径
Initial RAM filesystem and RAM disk (initramfs/initrd) support (/work/system/my-linux/rootfs) Initramfs source file(s) 编译内核:make
生成的内核的路径:arch/arm/boot/xipImage
生成的设备树路径:arch/arm/boot/dts/stm32f429-disco.dtb
直接给xipImage和stm32f429-disco.dtb添加后缀名.bin,这样才可以通过j-flash或者st-link烧写到flash中。
烧写系统
stm32f429i-disco.bin烧写到0x08000000
stm32f429-disco.dtb.bin烧写到0x08004000
xipImage.bin烧写到0x08008000
u-boot-2016.03+ Linux4.13.12+ Stm32_mini_rootfs.cpio.bz2
配置uboot:make stm32f429-discovery_defconfig
编译uboot:make
生成uboot.bin
rootfs在按照前面讲的移植。
编译linux
有几个地方需要修改一下:
arch/arm/configs/stm32_defconfig中的CONFIG_DRAM_BASE改为0xD0000000.
arch/arm/boot/dts/stm32f429-disco.dts中的 reg = 《0x90000000 0x800000》改为
reg = 《0xD0000000 0x800000》。
还有一个地方,我在这卡了好久,一直都卡在start kernel。。。,后来使用emcraft提供的内核,发现可以正常运行,对比发现我移植的内核entey point和load address相同,而emcraft提供的内核entry point比load address大1,我按照emcraft的修改内核,发现linux13.12可以正常使用。具体的修改:scripts/Makefile.lib中修改UIMAGE_ENTRYADDR,如下所示
UIMAGE_LOADADDR ?= arch_must_set_thisUIMAGE_ENTRYADDR =$(shell echo $(UIMAGE_LOADADDR) | sed -e “s/。.$$/01/”)UIMAGE_NAME ?= ‘Linux-$(KERNELRELEASE)’ 编译内核:make uImage LOADADDR=0xD0008000,生成uImage文件
编译设备树:make dtbs,生成stm32f429-disco.dtb
烧写系统
将uboot烧写到起始地址为0x08000000的flash中,使用uboot的命令loadb,将uImage传输到SDRAM中,地址为0xD0100000,将stm32f429-disco.dtb传输到0xD0300000位置。
bootm D0100000 - D0300000 启动Linux系统
我还试了linux4.9和linux4,17,其中linux4.9可以正常使用,linux4.17还有点问题。移植的问题搞定了,下可以漫长的驱动搬砖了。
介绍两种移植方法
第一种:AFboot + Linux4.13.12 + Stm32_mini_rootfs.cpio.bz2
第二种:u-boot-2016.03 + Linux4.13.12 + Stm32_mini_rootfs.cpio.bz2
硬件:stm32f429-discovery
软件平台:ubuntu-12.04
1. 交叉连接器
下载地址:https ://launchpad.net/gcc-arm-embedded/+download
我下载的是gcc-arm-none-eabi-5_4-2016q3 -20160926-linux.tar.bz2
安装交叉编译器。
2.下载linux4.13.12源码
下载地址:https :
//mirrors.edge.kernel.org/pub/linux/kernel/下载Linux-4.13.12.tar. xz
3.下载uboot
下载地址:http://ftp.denx.de/pub/u-boot/
下载u-boot-2016.03.tar.bz2
4.下载afboot
下载地址:https://github.com/mcoquelin -stm32/afboot-stm32.git
下载afboot-stm32-master.zip
5.下载的rootfs
下载地址:https://elinux.org/File:Stm32_mini_rootfs.cpio.bz2
下载Stm32_mini_rootfs.cpio.bz2
AFboot + Linux4.13.12 + Stm32_mini_rootfs.cpio.bz2
打开afboot的Makefile,可以看到kernel和dtb在FLASH中的位置
KERNEL_ADDR?=0x08008000
DTB_ADDR?=0x08004000
编译afboot:make stm32f429i-
discostm32f429i-disco.bin。
系统文件使用initramfs,2s_cp_2_cpio,
先解压stmfs解压成cpio文件:bzip2 -d Stm32_mini_rootfs.cpio.bz2
创建文件夹rootfs:mkdir rootfs
将文件解压到rootfs文件夹中:cpio -idmv 《 。./Stm32_mini_rootfs.cpiodev
中是否有null,tty0,console节点,没有在开发者文件夹中创建这三个节点。
sudo mknod console c 5 1sudo mknod null c 1 3sudo mknod tty0 c 204 64 在rootfs文件夹下面添加init文件,文件中添加下面的内容
#!/bin/sh# devtmpfs不会自动挂载为initramfs/bin/mount - t devtmpfs devtmpfs /devexec 0《/dev/consoleexec 1》/dev/consoleexec 2》/dev/consoleexec /***in/init $
配置Linux4.9内核:make stm32_defconfig
在menuconfig中添加rootfs文件的文件的路径
Initial RAM filesystem and RAM disk (initramfs/initrd) support (/work/system/my-linux/rootfs) Initramfs source file(s) 编译内核:make
生成的内核的路径:arch/arm/boot/xipImage
生成的设备树路径:arch/arm/boot/dts/stm32f429-disco.dtb
直接给xipImage和stm32f429-disco.dtb添加后缀名.bin,这样才可以通过j-flash或者st-link烧写到flash中。
烧写系统
stm32f429i-disco.bin烧写到0x08000000
stm32f429-disco.dtb.bin烧写到0x08004000
xipImage.bin烧写到0x08008000
u-boot-2016.03+ Linux4.13.12+ Stm32_mini_rootfs.cpio.bz2
配置uboot:make stm32f429-discovery_defconfig
编译uboot:make
生成uboot.bin
rootfs在按照前面讲的移植。
编译linux
有几个地方需要修改一下:
arch/arm/configs/stm32_defconfig中的CONFIG_DRAM_BASE改为0xD0000000.
arch/arm/boot/dts/stm32f429-disco.dts中的 reg = 《0x90000000 0x800000》改为
reg = 《0xD0000000 0x800000》。
还有一个地方,我在这卡了好久,一直都卡在start kernel。。。,后来使用emcraft提供的内核,发现可以正常运行,对比发现我移植的内核entey point和load address相同,而emcraft提供的内核entry point比load address大1,我按照emcraft的修改内核,发现linux13.12可以正常使用。具体的修改:scripts/Makefile.lib中修改UIMAGE_ENTRYADDR,如下所示
UIMAGE_LOADADDR ?= arch_must_set_thisUIMAGE_ENTRYADDR =$(shell echo $(UIMAGE_LOADADDR) | sed -e “s/。.$$/01/”)UIMAGE_NAME ?= ‘Linux-$(KERNELRELEASE)’ 编译内核:make uImage LOADADDR=0xD0008000,生成uImage文件
编译设备树:make dtbs,生成stm32f429-disco.dtb
烧写系统
将uboot烧写到起始地址为0x08000000的flash中,使用uboot的命令loadb,将uImage传输到SDRAM中,地址为0xD0100000,将stm32f429-disco.dtb传输到0xD0300000位置。
bootm D0100000 - D0300000 启动Linux系统
我还试了linux4.9和linux4,17,其中linux4.9可以正常使用,linux4.17还有点问题。移植的问题搞定了,下可以漫长的驱动搬砖了。
举报