access sd card in uboot

1.show all command of sd card

ZynqMP> mmc --help                                                              
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  

2.show the table of sdcard

ZynqMP> mmc part                                                                
                                                                                
Partition Map for MMC device 0  --   Partition Type: DOS                        
                                                                                
Part    Start Sector    Num Sectors     UUID            Type                    
  1     2048            1048576         1383d36e-01     0c                      
  2     1050624         14473216        1383d36e-02     83  

3.use fatls command to list file of sdcard

ZynqMP> fatls mmc 0:1                                                           
   153400   bl31.elf                                                            
 27658520   BOOT.BIN                                                            
            .Trash-1000/                                                        
 79314128   image.ub                                                            
            .Trash-0/                                                           
   154072   pmufw.elf                                                           
 26510901   system.bit                                                          
    41288   system.dtb                                                          
      415   uEnv.txt~                                                           
   903216   u-boot.elf                                                          
   141848   zynqmp_fsbl.elf                                                     
                                                                                
9 file(s), 2 dir(s)  

4.load file to ram

ZynqMP> fatload mmc 0:1 0x22000000 image.ub                                     
79314128 bytes read in 5183 ms (14.6 MiB/s)

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 将U-Boot保存到SD卡的步骤如下: 1. 准备工作: - 确保你有一个装有U-Boot二进制文件的计算机。 - 将SD卡插入计算机的SD卡读卡器。 2. 格式化SD卡: - 使用计算机上的磁盘管理工具(如DiskPart)或第三方工具将SD卡格式化为FAT32文件系统。 - 确保为SD卡分配一个可用的驱动器号(例如,E:\)。 3. 复制U-Boot二进制文件: - 在计算机上找到U-Boot二进制文件(通常命名为u-boot.bin)。 - 将u-boot.bin复制到SD卡的根目录中。 4. 卸载SD卡: - 在操作系统中右键单击SD卡驱动器号(例如,E:\)。 - 选择“弹出&rdquo;或“安全删除硬件&rdquo;选项,确保SD卡安全地从计算机中卸载。 5. 连接SD卡到目标设备: - 将SD卡插入目标设备的SD卡插槽。 6. 运行U-Boot: - 启动目标设备并进入U-Boot引导菜单(通常通过按下特定的键组合)。 - 在U-Boot命令行中键入以下命令: `mmc rescan`(用于识别SD卡)。 - 确认SD卡已成功识别后,键入以下命令: `fatload mmc [设备号] [加载地址] u-boot.bin`。 - 将[设备号]替换为目标设备中SD卡的设备号(例如,mmc 0)。 - 将[加载地址]替换为U-Boot加载到的地址(例如,0x80000000)。 - 最后,键入以下命令来运行U-Boot: `go [加载地址]`。 7. 完成: - 现在,U-Boot已成功加载并在目标设备上运行。可以在U-Boot命令行中执行额外的操作,如配置引导选项、更新固件等。 请注意,这只是一种基本的操作方法。实际操作可能因不同的设备和U-Boot版本而有所不同。在进行任何修改操作之前,请确保详细阅读相关设备和U-Boot的文档,并按照官方建议执行操作。 ### 回答2: 要将U-Boot修改后的版本保存到SD卡,可以按照以下步骤进行操作: 1. 首先确认SD卡已插入计算机中,并且可以被识别。可以通过`lsblk`等命令来查看SD卡的设备名,比如`/dev/sdb`。 2. 连接计算机和SD卡的读卡器或者通过其他方式挂载SD卡。 3. 下载U-Boot的源代码,并进行修改或者配置。将修改后的源代码编译成可执行文件,如`u-boot.img`。 4. 打开终端,使用root权限运行以下命令:`dd if=u-boot.img of=/dev/sdX bs=512 seek=2`。 - 其中`u-boot.img`是你修改后的U-Boot文件的路径和文件名。 - `/dev/sdX`是SD卡的设备名,如`/dev/sdb`。 - `bs=512`表示每次读写数据的块大小为512字节。 - `seek=2`表示在SD卡的第二个扇区位置写入U-Boot。 5. 等待命令执行完毕,将U-Boot文件成功写入SD卡。 6. 锁定和卸载SD卡,可以通过执行以下命令完成:`sudo fsck /dev/sdX`(检查和修复文件系统),然后执行`sudo umount /dev/sdX`(卸载SD卡)。 修改U-Boot并将其保存到SD卡上仅适用于一些特定的嵌入式系统或开发板。在实际操作过程中,请根据具体设备的要求和指南进行操作,以确保正确性和安全性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值