专栏首页hank【分享】MPSoC UBoot下SD/eMMC卡的验证

【分享】MPSoC UBoot下SD/eMMC卡的验证

介绍

使用eMMC启动时,可以参考Xilinx的AR 67157烧写,也可以直接使用Vitis烧写。Vitis 2020.2 可以直接烧写eMMC设备。 烧写完成后,最好通过JTAG启动到U-Boot,在U-Boot里验证SD/eMMC的分区表、文件系统、启动文件正常。

测试命令

检查SD/eMMC设备

命令mmcinfo可以打印SD/eMMC设备的设备信息,比如大小等。

ZynqMP> mmcinfo
Device: mmc@ff170000
Manufacturer ID: 3
OEM: 5344
Name: SD08G
Bus Speed: 25000000
Mode: SD Legacy
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.4 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes

检查SD/eMMC分区

命令mmc part可以打印SD/eMMC设备的分区表。

ZynqMP> mmc part

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     2048            4096000         01bdb37b-01     0c
  2     4098048         11425792        01bdb37b-02     06

检查SD/eMMC的文件系统

命令fatinfo mmc可以打印SD/eMMC设备的文件系统信息。

ZynqMP> fatinfo mmc 0
Interface:  MMC
  Device 0: Vendor: Man 000003 Snr cb70de00 Rev: 1.14 Prod: SD08G▒
            Type: Removable Hard Disk
            Capacity: 7580.0 MB = 7.4 GB (15523840 x 512)
Filesystem: FAT32 "NO NAME    "

检查SD/eMMC的启动文件

命令fatls可以列出SD/eMMC设备中的文件系统的文件信息。 命令fatload可以将SD/eMMC设备中的文件系统的文件的内容,读入到内存。

ZynqMP> fatls mmc 0
            System Volume Information/
    59919   system.dtb.dts
     1718   boot.scr
            vcu/
            config/
    68916   system.dtb
      455   autostart.sh
    40048   xyavta
 20621764   BOOT.BIN
 123220436   image.ub

23 file(s), 4 dir(s)

ZynqMP>  fatload mmc 0 0x800000 BOOT.BIN 0x100000
1048576 bytes read in 115 ms (8.7 MiB/s)
ZynqMP> md.b 0x800000
00800000: 00 00 00 14 00 00 00 14 00 00 00 14 00 00 00 14    ................
00800010: 00 00 00 14 00 00 00 14 00 00 00 14 00 00 00 14    ................
00800020: 66 55 99 aa 58 4e 4c 58 00 00 00 00 00 00 fc ff    fU..XNLX........
00800030: 00 28 00 00 e0 fa 01 00 e0 fa 01 00 10 02 02 00    .(..............

eMMC Card Initialize

eMMC的初始化流程请参考 UG1085的Table 26‐23: eMMC Card Initialize。简要描述如下:

  1. Send CMD0 to card with no response expected (see Table 26-17).
  2. Send CMD1 while card is still busy with power up (perform the following two steps).
  3. Send command (CMD1) with options to host high-capacity support and high-voltage window (see Table 26-17).
  4. Read response 0.
  5. Send CMD2 for CARD ID (see Table 26-17).
  6. Send CMD3. Save relative card address in response 0.
  7. Read card specific data in response.
  8. Read card specific data in response.
  9. Read card specific data in response.
  10. Read card specific data in response.
  11. Send CMD9 with relative card address saved in CMD3 response.
  12. Read card specific data in response.
  13. Read card specific data in response.
  14. Read card specific data in response.

检查SD/eMMC的文件读写

命令fatmkdir可以在SD/eMMC设备中的文件系统的中创建文件夹。 命令fatwrite可以将内存内容写入SD/eMMC设备中的文件系统的文件。

ZynqMP> fatmkdir  mmc 0 ubootdir
ZynqMP> fatls mmc 0
            System Volume Information/
    59919   system.dtb.dts
     1718   boot.scr
            vcu/
            config/
    68916   system.dtb
      455   autostart.sh
    40048   xyavta
 20621764   BOOT.BIN
 123220436   image.ub
            ubootdir/

23 file(s), 5 dir(s)

ZynqMP>  fatwrite mmc 0 0x100000 uboot-mem.bin 0x100000
1048576 bytes written
ZynqMP>  fatload mmc 0 0x800000 uboot-mem.bin 0x100000
1048576 bytes read in 115 ms (8.7 MiB/s)
ZynqMP> cmp.b 0x100000 0x800000 0x100000
Total of 1048576 byte(s) were the same

完整记录

下面是完整记录,有删减。

Xilinx Zynq MP First Stage Boot Loader
Release 2020.1   Dec 15 2020  -  09:29:14
NOTICE:  ATF running on XCZU7EV/silicon v4/RTL5.1 at 0xfffea000
NOTICE:  BL31: v2.2(release):v1.1-5588-g5918e656e
NOTICE:  BL31: Built : 09:27:00, Dec 15 2020


U-Boot 2020.01 (Dec 15 2020 - 09:27:30 +0000)

Model: ZynqMP ZCU106 RevA
Board: Xilinx ZynqMP
DRAM:  4 GiB
PMUFW:  v1.1
EL Level:       EL2
Chip ID:        zu7ev
NAND:  0 MiB
MMC:   mmc@ff170000: 0
In:    serial@ff000000
Out:   serial@ff000000
Err:   serial@ff000000
Bootmode: LVL_SHFT_SD_MODE1
Reset reason:   EXTERNAL
Net:
ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr 12, interface rgmii-id

Warning: ethernet@ff0e0000 using MAC address from ROM
eth0: ethernet@ff0e0000
Hit any key to stop autoboot:  0
ZynqMP> help
?         - alias for 'help'
base      - print or set address offset
bdinfo    - print Board Info structure
bind      - Bind a device to a driver
blkcache  - block cache diagnostics and control
boot      - boot default, i.e., run 'bootcmd'
bootd     - boot default, i.e., run 'bootcmd'
bootefi   - Boots an EFI payload from memory
bootelf   - Boot from an ELF image in memory
booti     - boot Linux kernel 'Image' format from memory
bootm     - boot application image from memory
bootmenu  - ANSI terminal bootmenu
bootp     - boot image via network using BOOTP/TFTP protocol
bootvx    - Boot vxWorks from an ELF image
clk       - CLK sub-system
cmp       - memory compare
coninfo   - print console devices and information
cp        - memory copy
cpu       - Multiprocessor CPU boot manipulation and release
crc32     - checksum calculation
dfu       - Device Firmware Upgrade
dhcp      - boot image via network using DHCP/TFTP protocol
dm        - Driver model low level access
echo      - echo args to console
editenv   - edit environment variable
env       - environment handling commands
erase     - erase FLASH memory
exit      - exit script
ext2load  - load binary file from a Ext2 filesystem
ext2ls    - list files in a directory (default /)
ext4load  - load binary file from a Ext4 filesystem
ext4ls    - list files in a directory (default /)
ext4size  - determine a file's size
ext4write - create a file in the root directory
false     - do nothing, unsuccessfully
fastboot  - run as a fastboot usb or udp device
fatinfo   - print information about filesystem
fatload   - load binary file from a dos filesystem
fatls     - list files in a directory (default /)
fatmkdir  - create a directory
fatrm     - delete a file
fatsize   - determine a file's size
fatwrite  - write file into a dos filesystem
fdt       - flattened device tree utility commands
flinfo    - print FLASH memory information
fpga      - loadable FPGA image support
fstype    - Look up a filesystem type
go        - start application at address 'addr'
gpio      - query and control gpio pins
gpt       - GUID Partition Table
gzwrite   - unzip and write memory to block device
help      - print command description/usage
i2c       - I2C sub-system
iminfo    - print header information for application image
imxtract  - extract a part of a multi-image
itest     - return true/false on integer compare
led       - manage LEDs
ln        - Create a symbolic link
load      - load binary file from a filesystem
loadb     - load binary file over serial line (kermit mode)
loads     - load S-Record file over serial line
loadx     - load binary file over serial line (xmodem mode)
loady     - load binary file over serial line (ymodem mode)
loop      - infinite loop on address range
ls        - list files in a directory (default /)
lzmadec   - lzma uncompress a memory region
md        - memory display
mdio      - MDIO utility commands
mii       - MII utility commands
mm        - memory modify (auto-incrementing address)
mmc       - MMC sub system
mmcinfo   - display MMC info
mtest     - simple RAM read/write test
mw        - memory write (fill)
nand      - NAND sub-system
nboot     - boot from NAND device
nfs       - boot image via network using NFS protocol
nm        - memory modify (constant address)
part      - disk partition related commands
ping      - send ICMP ECHO_REQUEST to network host
poweroff  - Perform POWEROFF of the device
printenv  - print environment variables
protect   - enable or disable FLASH write protection
pxe       - commands to get and boot from pxe files
random    - fill memory with random pattern
reset     - Perform RESET of the CPU
run       - run commands in an environment variable
save      - save file to a filesystem
scsi      - SCSI sub-system
scsiboot  - boot from SCSI device
setenv    - set environment variables
setexpr   - set environment variable as the result of eval expression
sf        - SPI flash sub-system
showvar   - print local hushshell variables
size      - determine a file's size
sleep     - delay execution for some time
source    - run script from memory
sspi      - SPI utility command
sysboot   - command to get and boot from syslinux files
test      - minimal test like /bin/sh
tftpboot  - boot image via network using TFTP protocol
tftpput   - TFTP put command, for uploading files to a server
thordown  - TIZEN "THOR" downloader
time      - run commands and summarize execution time
timer     - access the system timer
true      - do nothing, successfully
ums       - Use the UMS [USB Mass Storage]
unbind    - Unbind a device from a driver
unzip     - unzip a memory region
usb       - USB sub-system
usbboot   - boot from USB device
version   - print monitor, compiler and linker version
zynqmp    - ZynqMP sub-system
ZynqMP> mmcinfo
Device: mmc@ff170000
Manufacturer ID: 3
OEM: 5344
Name: SD08G
Bus Speed: 25000000
Mode: SD Legacy
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.4 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
ZynqMP> help mmc
mmc - MMC sub system

Usage:
mmc info - display info of the current MMC device
mmc read addr blk# cnt
mmc write addr blk# cnt
mmc erase blk# cnt
mmc rescan
mmc part - lists available partition on current mmc device
mmc dev [dev] [part] - show or set current mmc device [partition]
mmc list - lists available devices
mmc hwpartition [args...] - does hardware partitioning
  arguments (sizes in 512-byte blocks):
    [user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes
    [gp1|gp2|gp3|gp4 cnt [enh] [wrrel {on|off}]] - general purpose partition
    [check|set|complete] - mode, complete set partitioning completed
  WARNING: Partitioning is a write-once setting once it is set to complete.
  Power cycling is required to initialize partitions after set to complete.
mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode
 - Set the BOOT_BUS_WIDTH field of the specified device
mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>
 - Change sizes of boot and RPMB partitions of specified device
mmc partconf dev [boot_ack boot_partition partition_access]
 - Show or change the bits of the PARTITION_CONFIG field of the specified device
mmc rst-function dev value
 - Change the RST_n_FUNCTION field of the specified device
   WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.
mmc setdsr <value> - set DSR register value

ZynqMP> mmc part

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     2048            4096000         01bdb37b-01     0c
  2     4098048         11425792        01bdb37b-02     06
  
ZynqMP> fatinfo mmc 0
Interface:  MMC
  Device 0: Vendor: Man 000003 Snr cb70de00 Rev: 1.14 Prod: SD08G▒
            Type: Removable Hard Disk
            Capacity: 7580.0 MB = 7.4 GB (15523840 x 512)
Filesystem: FAT32 "NO NAME    "

ZynqMP> fatls mmc 0
            System Volume Information/
    59919   system.dtb.dts
     1718   boot.scr
            vcu/
            config/
    68916   system.dtb
      455   autostart.sh
    40048   xyavta
 20621764   BOOT.BIN
 123220436   image.ub

23 file(s), 4 dir(s)

ZynqMP> fatmkdir  mmc 0 ubootdir
ZynqMP> fatls mmc 0
            System Volume Information/
    59919   system.dtb.dts
     1718   boot.scr
            vcu/
            config/
    68916   system.dtb
      455   autostart.sh
    40048   xyavta
 20621764   BOOT.BIN
 123220436   image.ub
            ubootdir/

23 file(s), 5 dir(s)

ZynqMP>  fatload mmc 0 0x800000 BOOT.BIN 0x100000
1048576 bytes read in 115 ms (8.7 MiB/s)
ZynqMP> md.l 0x800000
00800000: 14000000 14000000 14000000 14000000    ................
00800010: 14000000 14000000 14000000 14000000    ................
00800020: aa995566 584c4e58 00000000 fffc0000    fU..XNLX........
00800030: 00002800 0001fae0 0001fae0 00020210    .(..............
00800040: 00020210 00000800 fd163261 00000000    ........a2......
00800050: 00000000 00000000 00000000 00000000    ................
00800060: 00000000 00000000 00000000 01000020    ............ ...
00800070: 00000000 00000000 00000000 00000000    ................
00800080: 00000000 00000000 00000000 00000000    ................
00800090: 00000000 00000000 000008c0 00001100    ................
008000a0: 00000000 00000000 00000000 00000000    ................
008000b0: 00000000 00000000 ffffffff 00000000    ................
008000c0: ffffffff 00000000 ffffffff 00000000    ................
008000d0: ffffffff 00000000 ffffffff 00000000    ................
008000e0: ffffffff 00000000 ffffffff 00000000    ................
008000f0: ffffffff 00000000 ffffffff 00000000    ................

ZynqMP> md.b 0x800000
00800000: 00 00 00 14 00 00 00 14 00 00 00 14 00 00 00 14    ................
00800010: 00 00 00 14 00 00 00 14 00 00 00 14 00 00 00 14    ................
00800020: 66 55 99 aa 58 4e 4c 58 00 00 00 00 00 00 fc ff    fU..XNLX........
00800030: 00 28 00 00 e0 fa 01 00 e0 fa 01 00 10 02 02 00    .(..............

ZynqMP>  fatwrite mmc 0 0x100000 uboot-mem.bin 0x100000
1048576 bytes written

ZynqMP> help fatload
fatload - load binary file from a dos filesystem

Usage:
fatload <interface> [<dev[:part]> [<addr> [<filename> [bytes [pos]]]]]
    - Load binary file 'filename' from 'dev' on 'interface'
      to address 'addr' from dos filesystem.
      'pos' gives the file position to start loading from.
      If 'pos' is omitted, 0 is used. 'pos' requires 'bytes'.
      'bytes' gives the size to load. If 'bytes' is 0 or omitted,
      the load stops on end of file.
      If either 'pos' or 'bytes' are not aligned to
      ARCH_DMA_MINALIGN then a misaligned buffer warning will
      be printed and performance will suffer for the load.
ZynqMP>  fatload mmc 0 0x800000 uboot-mem.bin 0x100000
1048576 bytes read in 115 ms (8.7 MiB/s)
ZynqMP> cmp.b 0x100000 0x800000 0x100000
Total of 1048576 byte(s) were the same

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • ZCU102 休眠到内存(suspend-to-ram)对DDR复位信号的设计

    Xilinx的开发板ZCU102支持休眠到内存(suspend-to-ram)。休眠到内存时,DDR进入自刷新,MPSoC被关电,完全不耗电。唤醒时,MPSoC...

    hankfu
  • 【分享】在MPSoC上运行基于eglfs_kms的QT应用程序

    Xilinx为MPSoC支持4种libMali的backend: X11, Wayland/GBM, Fbdev, Headless-EGL.

    hankfu
  • 【分享】MPSoC R5引导4个A53和两个R5的应用程序的例子

    有工程师反馈R5引导A53和R5的应用程序后,A53和R5的应用程序没有正确执行。因此做了一个MPSoC R5引导4个A53和两个R5的应用程序的例子。

    hankfu
  • SimpleDateFormat线程不安全示例及其解决方法

    我们可以用java.text.SimpleDateFormat类完成日期的转换和格式化操作,如:

    孟君
  • PHP时间函数使用详解

    PHP开发中,关于时间函数的使用基本上可以说是无处不在,而PHP中操作时间的方法也很多,比如PHP时间戳、日期与时间戳之间的转换、获取当前日期、当前时间之前或之...

    砸漏
  • PostgreSQL数据类型

    博客地址:https://ask.hellobi.com/blog/zhiji 欢迎大家来交流学习。

    Python攻城狮
  • 黑客撩妹新招get!如何利用MouseJack入侵女神的鼠标

    0x00 前言 近期安全公司Bastille Networks(巴士底狱)安全研究员发现大多数无线鼠标和接收器之间的通信信号是不加密的。黑客可对一两百米范围内存...

    FB客服
  • PHP5.0 TIDY_PARSE_FILE缓冲区溢出漏洞的解决方案

    不得不再次吐槽一下exploit-db对exp审核的质量,这个exp仍然不能触发漏洞,修改第一个参数则可以触发,我给出的poc是一个可以触发php漏洞的,问题出...

    砸漏
  • Hasbro公司推AR智能玩具,自家后院变成射击战场的感觉如何?

    前段时间,美国玩具公司Hasbro推出了《Nerf Laser Ops Pro》应用,以及一款与之搭配的Nerf枪。借助这款应用以及Nerf枪,用户可将自家的后...

    VRPinea
  • [PHP] 静态工厂模式-创建型设计模式

    和抽象工厂类似,静态工厂模式用来创建一系列互相关联或依赖的对象 和抽象工厂模式不同的是静态工厂模式只用一个静态方法就解决了所有类型的对象创建

    陶士涵

扫码关注云+社区

领取腾讯云代金券