ZYNQFLASH+EMMC手动移植LINUX启动

更新时间:2023-07-18 20:26:10 阅读: 评论:0

ZYNQFLASH+EMMC⼿动移植LINUX启动
前⾔
虽可使⽤Petalinux进⾏移植,简单⽅便,但为了更清楚明⽩的了解整个流程,还是尝试了⼀波⼿动移植。
参考资料
流程
对于⼿动移植,所需的⽂件为:
BOOT.bin(FSBL+fpga_bit⽂件+u_boot.elf)、uImage、devicetree.dtb、、⽂件系统
⽂件放置位置说明:
FLASH:BOOT.bin(FSBL+fpga_bit⽂件+u_boot.elf)
EMMC:
第⼀个分区放置:uImage、devicetree.dtb、
第⼆个分区放置:⽂件系统
启动流程为:板⼦设置为QSPI启动模式,FSBL执⾏调u-boot执⾏,u-boot根据调EMMC分区1中的内核执⾏,内核最后跳到分区⼆中的⽂件系统。
FSBL、bit⽂件、uImage、⽂件系统都可复⽤SD卡移植模式下的内容:参考参考资料第⼀个链接。
本⽂章主要讲述的重点在于:u-boot、设备树、的更改部分
板⼦主要信息说明:板⼦芯⽚:ZYNQ7035,板⼦的调试打印串⼝为PS0,板⼦上有SD卡(SD0)、EMMC(SD1),板⼦上有FLASH。其他外设不赘述。
u-boot移植说明:
NOTE:u-boot xilinx-v2018.3版本的zynq-common.h跟xilinx-v2018.1版本的不⼀样,这⾥检出v2018.1版本使⽤。
主要是CONFIG_EXTRA_ENV_SETTINGS环境变量不⼀致。
默认的如下所⽰:
/
* Default environment */
#ifndef CONFIG_EXTRA_ENV_SETTINGS
#define CONFIG_EXTRA_ENV_SETTINGS \
"ethaddr=00:0a:35:00:01:22\0" \
"kernel_image=uImage\0" \
"kernel_load_address=0x2080000\0" \
"ramdisk_image=\0" \
"ramdisk_load_address=0x4000000\0" \
"devicetree_image=devicetree.dtb\0" \
"devicetree_load_address=0x2000000\0" \
神犬巴迪"bitstream_image=system.bit.bin\0" \
"boot_image=BOOT.bin\0" \
"loadbit_addr=0x100000\0" \
"loadbootenv_addr=0x2000000\0" \
"kernel_size=0x500000\0" \
"devicetree_size=0x20000\0" \
"ramdisk_size=0x5E0000\0" \
"boot_size=0xF00000\0" \
"fdt_high=0x20000000\0" \
"initrd_high=0x20000000\0" \
"\0" \
"loadbootenv=load mmc 0 ${loadbootenv_addr} ${bootenv}\0" \
"importbootenv=echo Importing environment from SD ...; " \
"env import -t ${loadbootenv_addr} $filesize\0" \
"sd_uEnvtxt_existence_test=test -e mmc 0 /\0" \
"preboot=if test $modeboot = sdboot && env run sd_uEnvtxt_existence_test; " \
"then if env run loadbootenv; " \
"then env run importbootenv; " \
"fi; " \
"fi; \0" \
"mmc_loadbit=echo Loading bitstream from SD/MMC/eMMC to RAM.. && " \
"mmcinfo && " \
"load mmc 0 ${loadbit_addr} ${bitstream_image} && " \
"fpga load 0 ${loadbit_addr} ${filesize}\0" \
"norboot=echo Copying Linux from NOR flash && " \
"cp.b 0xE2100000 ${kernel_load_address} ${kernel_size} && " \
"cp.b 0xE2600000 ${devicetree_load_address} ${devicetree_size} && " \
"echo && " \
"cp.b 0xE2620000 ${ramdisk_load_address} ${ramdisk_size} && " \
"bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}\0" \
"qspiboot=echo Copying Linux from QSPI flash && " \
"sf probe 0 0 0 && " \
"sf read ${kernel_load_address} 0x100000 ${kernel_size} && " \
"sf read ${devicetree_load_address} 0x600000 ${devicetree_size} && " \
"echo && " \
"sf read ${ramdisk_load_address} 0x620000 ${ramdisk_size} && " \
"bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}\0" \
"uenvboot=" \
"if run loadbootenv; then " \
"echo Loaded environment from ${bootenv}; " \
"run importbootenv; " \
"fi; " \
"if test -n $uenvcmd; then " \
炒腊肠的做法"echo Running uenvcmd ...; " \
"run uenvcmd; " \
"fi\0" \
"sdboot=if mmcinfo; then " \
"run uenvboot; " \
"echo Copying Linux from SD && " \
"load mmc 0 ${kernel_load_address} ${kernel_image} && " \
"load mmc 0 ${devicetree_load_address} ${devicetree_image} && " \
"load mmc 0 ${ramdisk_load_address} ${ramdisk_image} && " \
"bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}; " \
"fi\0" \
"usbboot=if usb start; then " \
南宁科技馆
"run uenvboot; " \
"echo Copying Linux from USB && " \
"load usb 0 ${kernel_load_address} ${kernel_image} && " \
"load usb 0 ${devicetree_load_address} ${devicetree_image} && " \
"load usb 0 ${ramdisk_load_address} ${ramdisk_image} && " \
"bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}; " \
"fi\0" \
"nandboot=echo Copying Linux from NAND flash && " \
"nand read ${kernel_load_address} 0x100000 ${kernel_size} && " \
"nand read ${devicetree_load_address} 0x600000 ${devicetree_size} && " \
"echo && " \
"nand read ${ramdisk_load_address} 0x620000 ${ramdisk_size} && " \
"bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}\0" \
"jtagboot=echo TFTPing Linux && " \
"tftpboot ${kernel_load_address} ${kernel_image} && " \
"tftpboot ${devicetree_load_address} ${devicetree_image} && " \
"tftpboot ${ramdisk_load_address} ${ramdisk_image} && " \
"bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}\0" \
"rsa_norboot=echo Copying Image from NOR flash && " \
"cp.b 0xE2100000 0x100000 ${boot_size} && " \
"zynqrsa 0x100000 && " \
"bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}\0" \
"rsa_nandboot=echo Copying Image from NAND flash && " \
"nand read 0x100000 0x0 ${boot_size} && " \
"zynqrsa 0x100000 && " \
"bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}\0" \
"rsa_qspiboot=echo Copying Image from QSPI flash && " \
"sf probe 0 0 0 && " \
"sf read 0x100000 0x0 ${boot_size} && " \
"zynqrsa 0x100000 && " \
"bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}\0" \
"rsa_sdboot=echo Copying Image from SD && " \
"load mmc 0 0x100000 ${boot_image} && " \
"zynqrsa 0x100000 && " \
"bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}\0" \
"rsa_jtagboot=echo TFTPing Image && " \
"tftpboot 0x100000 ${boot_image} && " \
"zynqrsa 0x100000 && " \
"bootm ${kernel_load_address} ${ramdisk_load_address} ${devicetree_load_address}\0" \
DFU_ALT_INFO \
BOOTENV
#endif
可以看到其上定义了⼀堆的东西及不同的启动指令。
不同的启动指令由#define CONFIG_BOOTCOMMAND指定。
这⾥想FLASH+EMMC启动,则可以选择sdboot,同时因为EMMC是SD1,所以上述的⽂件需要进⾏
更改:更改的存储位置为mmc 1;去掉sdboot中的ramdisk,及存储kernel、设备树位置为mmc 1;修改bootm参数。
黄永玉的画"loadbootenv=load mmc 1 ${loadbootenv_addr} ${bootenv}\0" \
"importbootenv=echo Importing environment from SD ...; " \
"env import -t ${loadbootenv_addr} $filesize\0" \
"sd_uEnvtxt_existence_test=test -e mmc 1 /\0" \
"sdboot=if mmcinfo; then " \
"run uenvboot; " \
"echo Copying Linux from hahahah SD && " \
"load mmc 1 ${kernel_load_address} ${kernel_image} && " \
"load mmc 1 ${devicetree_load_address} ${devicetree_image} && " \
"bootm ${kernel_load_address} - ${devicetree_load_address}; " \
"fi\0" \
上述命令的执⾏逻辑为:u-boot启动后,执⾏sdboot指令:
(1)装载⽂件并运⾏;
(2)装载内核、设备树;
(3)运⾏;
2.由于是⾃⼰做的板⼦,则可以基于类似的板⼦defconfig进⾏修改适配u-boot:这⾥使⽤zynq_zed_defconfig⽂件:
(1)增加传统镜像⽂件⽀持:CONFIG_IMAGE_FORMAT_LEGACY=y
(2)因为已经知道是从EMMC启动相关⽂件,则可直接指定:CONFIG_BOOTCOMMAND="mmc dev 1;run sdboot"
mmc dev 1是为了避免u-boot死锁bug(移植petalinux中u-boot存在,为官⽅bug,这⾥加上,不知道有没有⽤);sdboot会直接调⽤执⾏zynq-common.h中的对应选项。
(3)因为板⼦上串⼝使⽤的是PS0,修改:CONFIG_DEBUG_UART_BASE=0xe0000000(地址可在设备树中查看)
⽂件参考:
CONFIG_ARM=y
CONFIG_ARCH_ZYNQ=y
CONFIG_SYS_TEXT_BASE=0x4000000硕鼠硕鼠无食我黍
CONFIG_SPL_STACK_R_ADDR=0x200000
CONFIG_DEFAULT_DEVICE_TREE="zynq-zed"
CONFIG_DEBUG_UART=y
CONFIG_DISTRO_DEFAULTS=y
CONFIG_IMAGE_FORMAT_LEGACY=y
CONFIG_FIT=y
CONFIG_FIT_SIGNATURE=y
CONFIG_FIT_VERBOSE=y
CONFIG_BOOTCOMMAND="mmc dev 1;run sdboot"
# CONFIG_DISPLAY_CPUINFO is not t
CONFIG_SPL=y
CONFIG_SPL_STACK_R=y
CONFIG_SPL_OS_BOOT=y
CONFIG_SYS_PROMPT="Zynq> "
无线鼠标不灵敏
CONFIG_CMD_THOR_DOWNLOAD=y
CONFIG_CMD_DFU=y
# CONFIG_CMD_FLASH is not t
CONFIG_CMD_FPGA_LOADBP=y
CONFIG_CMD_FPGA_LOADFS=y
CONFIG_CMD_FPGA_LOADMK=y
CONFIG_CMD_FPGA_LOADP=y
CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_SF=y
CONFIG_CMD_USB=y
# CONFIG_CMD_SETEXPR is not t
CONFIG_CMD_TFTPPUT=y
CONFIG_CMD_CACHE=y
CONFIG_CMD_EXT4_WRITE=y
CONFIG_OF_EMBED=y
CONFIG_ENV_IS_IN_SPI_FLASH=y
CONFIG_NET_RANDOM_ETHADDR=y
CONFIG_SPL_DM_SEQ_ALIAS=y
CONFIG_DFU_MMC=y
CONFIG_DFU_RAM=y
CONFIG_FPGA_XILINX=y
CONFIG_DM_GPIO=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_ZYNQ=y
CONFIG_SPI_FLASH=y
忧心忡忡CONFIG_SPI_FLASH_BAR=y
CONFIG_SF_DUAL_FLASH=y
CONFIG_SPI_FLASH_SPANSION=y
CONFIG_SPI_FLASH_STMICRO=y
CONFIG_SPI_FLASH_WINBOND=y
CONFIG_PHY_MARVELL=y
CONFIG_PHY_REALTEK=y
CONFIG_PHY_XILINX=y
CONFIG_ZYNQ_GEM=y
CONFIG_DEBUG_UART_ZYNQ=y
CONFIG_DEBUG_UART_BASE=0xe0000000
CONFIG_DEBUG_UART_CLOCK=50000000
CONFIG_ZYNQ_SERIAL=y
CONFIG_ZYNQ_QSPI=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_ULPI_VIEWPORT=y
CONFIG_USB_ULPI=y
CONFIG_USB_STORAGE=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_MANUFACTURER="Xilinx"
CONFIG_USB_GADGET_VENDOR_NUM=0x03fd
CONFIG_USB_GADGET_PRODUCT_NUM=0x0300
CONFIG_CI_UDC=y
CONFIG_USB_GADGET_DOWNLOAD=y
3.修改u-boot的设备树:实际上u-boot也带了设备树,这⾥需要进⾏修改:(1)修改uart为uart0;
(2)修改SD为mmc1;
(3)去除QSPI中的分区表;
⽂件参考:
/*
* Xilinx ZED board DTS
*
*  Copyright (C) 2011 - 2015 Xilinx
*  Copyright (C) 2012 National Instruments Corp.
*
* SPDX-Licen-Identifier: GPL-2.0+
*/
/dts-v1/;
#include "zynq-7000.dtsi"
/ {
model = "Zynq Zed Development Board";
compatible = "xlnx,zynq-zed", "xlnx,zynq-7000";
alias {
ethernet0 = &gem0;
rial0 = &uart0;
spi0 = &qspi;
mmc1 = &sdhci1;
};
memory@0 {
device_type = "memory";
reg = <0x0 0x20000000>;
};
chon {
bootargs = "";
stdout-path = "rial0:115200n8";
};
usb_phy0: phy0@e0002000 {
compatible = "ulpi-phy";
#phy-cells = <0>;
reg = <0xe0002000 0x1000>;
view-port = <0x0170>;
drv-vbus;
};
};
&clkc {
ps-clk-frequency = <33333333>;
};
钳工&gem0 {
status = "okay";
phy-mode = "rgmii-id";
phy-handle = <ðernet_phy>;
ethernet_phy: ethernet-phy@0 {
reg = <0>;
device_type = "ethernet-phy";
};
};
&qspi {
u-boot,dm-pre-reloc;
status = "okay";
is-dual = <0>;
num-cs = <1>;
flash@0 {
compatible = "n25q128a11";
reg = <0x0>;
spi-tx-bus-width = <1>;
spi-rx-bus-width = <4>;
spi-max-frequency = <50000000>;
#address-cells = <1>;
#size-cells = <1>;
};
};
&sdhci1 {
u-boot,dm-pre-reloc;
status = "okay";
};
&uart0 {
u-boot,dm-pre-reloc;
status = "okay";
};
&usb0 {
status = "okay";
dr_mode = "host";
usb-phy = <&usb_phy0>;
};
4. 编译u-boot:
清除中间编译:
make distclean
使⽤配置⽂件:
make CROSS_COMPILE=arm-linux-gnueabihf- zynq_zed_defconfig
通过下述指令可在界⾯中uboot进⾏进⼀步修改配置:改defconfig⽂件也可以,暂时默认即可
make CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
⼯具编译:
make CROSS_COMPILE=arm-linux-gnueabihf- tools
编译u-boot:
make CROSS_COMPILE=arm-linux-gnueabihf-
5. 修改总设备树的boottags:console=ttyPS0,115200n8 root=/dev/mmcblk1p2 rw noinitrd rootfstype=ext4 rootwait
6. 修改为:mmc 0修改为mmc 1;root=/dev/mmcblk1p2
bootargs=console=ttyPS0,115200 root=/dev/mmcblk1p2 rw earlyprintk rootfstype=ext4 rootwait
load_image=fatload mmc 1 ${kernel_load_address} ${kernel_image} && fatload mmc 1 ${devicetree_load_address} ${devicetree_image}
uenvcmd=echo Copying Linux from SD && mmcinfo &&  run load_image && bootm ${kernel_load_address} - ${devicetree_load_address}
7. 组装BOOT.bin,不赘述。
8. 烧录BOOT.bin到FLASH,对EMMC进⾏分区,EMMC分区⼀中放置uImage、devicetree.dtb、,EMMC分区⼆中放置⽂件系统
即可。
9. 启动。
U-Boot 2018.01-dirty (Jul 26 2021 - 20:05:00 +0800)
Model: Zynq Zed Development Board
Board: Xilinx Zynq
Silicon: v3.1
DRAM:  ECC disabled 512 MiB
MMC:  sdhci_transfer_data: Error detected in status(0x208000)!
sdhci@e0101000: 1 (eMMC)
SF: Detected s25fl128s_64k with page size 256 Bytes, era size 64 KiB, total 16 MiB
*** Warning - bad CRC, using default environment
In:    rial@e0000000
Out:  rial@e0000000
Err:  rial@e0000000

本文发布于:2023-07-18 20:26:10,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1086786.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:启动   修改   移植   放置   设备   分区
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图