eMMC启动uboot

eMMC分区介绍


分区     名称     描述
0x0     No access to boot partition(default)     不可访问分区
0x1     R/W boot partition 1     读写引导分区1
0x2     R/W boot partition 2     读写引导分区2
0x3     R/W Replace Protect Memory Block(RPMB)     读写重发保护存储器块
0x4     Access to General Purpose Partition 1     访问通用分区 1
0x5     Access to General Purpose Partition 2     访问通用分区 2
0x6     Access to General Purpose Partition 3     访问通用分区 3
0x7     Access to General Purpose Partition 4     访问通用分区 4

 R/W boot partition 1/2:此分区主要是为了支持从 eMMC 启动系统而设计的。大小为:4MB
 RPMB:在实际应用中,RPMB 分区通常用来保存安全相关的数据,例如指纹数据、安全支付相关的密钥等。大小为:512KB-32MB
 General Purpose Partition 1/2/3/4:此区域则主要用于存储系统或者用户数据。
 User Data Area: 此区域则主要用于存储系统或者用户数据。

emmc的boot分区烧录uboot方式有两种:

一:  Linux下读写boot分区

     boot分区中一般存放的是bootloader或者相关配置参数,这些参数一般是不允许修改的,所以默认情况下是能读boot分区,不能写。

1 使能读写

如果需要些则需要,修改/sys/block/mmcblk0boot0/force_ro。

使能写:

echo 0 > /sys/block/mmcblk0boot0/force_ro

关闭写:

echo 1 > /sys/block/mmcblk0boot1/force_ro

在重启之后,force_ro会恢复为1。

二: emmc boot启动分区选择

boot配置在EXT_CSD寄存器第179个字节定义,可以设置BOOT_PARTITION_ENABLE位的值来选择从Boot Partition或者User Area分区启动。关于第179字节的定义如下:
179字节定义

 

设置Boot Partition大小

可知,Boot Partition大小范围为:128KB ~ 31.875MB
大小


当前包含2个mmc设备

uboot>mmc list
FSL_SDHC: 0 (eMMC)
FSL_SDHC: 1

 

uboot>mmc partconf dev
EXT_CSD[179], PARTITION_CONFIG:
BOOT_ACK: 0x0
BOOT_PARTITION_ENABLE: 0x0
PARTITION_ACCESS: 0x0

1: 从上述结果根据EXT_CSD寄存器第179个字节定义,默认emmc是没有设置boot启动分区,如果要从user area启动BOOT_PARTITION_ENABLE的值设置为0x07

uboot>mmc partconf dev 0 0x07  0

uboot>mmc partconf dev
EXT_CSD[179], PARTITION_CONFIG:
BOOT_ACK: 0x0
BOOT_PARTITION_ENABLE: 0x7
PARTITION_ACCESS: 0x0

然后再将uboot下烧录uboot固件,并且CPU的boot mode改成emmc启动,可以从emmc boot
uboot>tftp 0x82000000 u-boot.bin
uboot>mmc write 0x82000000 0 0x800

2: 如果要从boot partition1启动BOOT_PARTITION_ENABLE的值设置为0x01

uboot>mmc partconf dev 0 0x01  0

3: 如果要从boot partition2启动BOOT_PARTITION_ENABLE的值设置为0x02

uboot>mmc partconf dev 0 0x02 0

 

三:mmc工具的使用

mmc-utils工具是用于在linux下用户层访问mmc设备的工具。其详细用法如下:

Usage:
        mmc extcsd read <device>
                Print extcsd data from <device>.
        mmc writeprotect boot get <device>
                Print the boot partitions write protect status for <device>.
        mmc writeprotect boot set <device>
                Set the boot partitions write protect status for <device>.
                This sets the eMMC boot partitions to be write-protected until
                the next boot.
        mmc writeprotect user set <type><start block><blocks><device>
                Set the write protect configuration for the specified region
                of the user area for <device>.
                <type> must be "none|temp|pwron".
                    "none"  - Clear temporary write protection.
                    "temp"  - Set temporary write protection.
                    "pwron" - Set write protection until the next poweron.
                <start block> specifies the first block of the protected area.
                <blocks> specifies the size of the protected area in blocks.
                NOTE! The area must start and end on Write Protect Group
                boundries, Use the "writeprotect user get" command to get the
                Write Protect Group size.
        mmc writeprotect user get <device>
                Print the user areas write protect configuration for <device>.
        mmc disable 512B emulation <device>
                Set the eMMC data sector size to 4KB by disabling emulation on
                <device>.
        mmc gp create <-y|-n|-c> <length KiB> <partition> <enh_attr> <ext_attr> <device>
                Create general purpose partition for the <device>.
                Dry-run only unless -y or -c is passed.
                Use -c if more partitioning settings are still to come.
                NOTE!  This is a one-time programmable (unreversible) change.
                To set enhanced attribute to general partition being created set
                 <enh_attr> to 1 else set it to 0.
                To set extended attribute to general partition
                 set <ext_attr> to 1,2 else set it to 0
        mmc enh_area set <-y|-n|-c> <start KiB> <length KiB> <device>
                Enable the enhanced user area for the <device>.
                Dry-run only unless -y or -c is passed.
                Use -c if more partitioning settings are still to come.
                NOTE!  This is a one-time programmable (unreversible) change.
        mmc write_reliability set <-y|-n|-c> <partition> <device>
                Enable write reliability per partition for the <device>.
                Dry-run only unless -y or -c is passed.
                Use -c if more partitioning settings are still to come.
                NOTE!  This is a one-time programmable (unreversible) change.
        mmc status get <device>
                Print the response to STATUS_SEND (CMD13).
        mmc bootpart enable <boot_partition> <send_ack> <device>
                Enable the boot partition for the <device>.
                Disable the boot partition for the <device> if <boot_partition> is set to 0.
                To receive acknowledgment of boot from the card set <send_ack>
                to 1, else set it to 0.
        mmc bootbus set <boot_mode> <reset_boot_bus_conditions> <boot_bus_width> <device>
                Set Boot Bus Conditions.
                <boot_mode> must be "single_backward|single_hs|dual"
                <reset_boot_bus_conditions> must be "x1|retain"
                <boot_bus_width> must be "x1|x4|x8"
        mmc bkops enable <device>
                Enable the eMMC BKOPS feature on <device>.
                NOTE!  This is a one-time programmable (unreversible) change.
        mmc hwreset enable <device>
                Permanently enable the eMMC H/W Reset feature on <device>.
                NOTE!  This is a one-time programmable (unreversible) change.
        mmc hwreset disable <device>
                Permanently disable the eMMC H/W Reset feature on <device>.
                NOTE!  This is a one-time programmable (unreversible) change.
        mmc sanitize <device>
                Send Sanitize command to the <device>.
                This will delete the unmapped memory region of the device.
        mmc rpmb write-key <rpmb device> <key file>
                Program authentication key which is 32 bytes length and stored
                in the specified file. Also you can specify '-' instead of
                key file path to read the key from stdin.
                NOTE!  This is a one-time programmable (unreversible) change.
                Example:
                  $ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | \
                    mmc rpmb write-key /dev/mmcblk0rpmb -
        mmc rpmb read-counter <rpmb device>
                Counter value for the <rpmb device> will be read to stdout.
        mmc rpmb read-block <rpmb device> <address> <blocks count> <output file> [key file]
                Blocks of 256 bytes will be read from <rpmb device> to output
                file or stdout if '-' is specified. If key is specified - read
                data will be verified. Instead of regular path you can specify
                '-' to read key from stdin.
                Example:
                  $ echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH | \
                    mmc rpmb read-block /dev/mmcblk0rpmb 0x02 2 /tmp/block -
                or read two blocks without verification
                  $ mmc rpmb read-block /dev/mmcblk0rpmb 0x02 2 /tmp/block
        mmc rpmb write-block <rpmb device> <address> <256 byte data file> <key file>
                Block of 256 bytes will be written from data file to
                <rpmb device>. Also you can specify '-' instead of key
                file path or data file to read the data from stdin.
                Example:
                  $ (awk 'BEGIN {while (c++<256) printf "a"}' | \
                    echo -n AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH) | \
                    mmc rpmb write-block /dev/mmcblk0rpmb 0x02 - -
        mmc cache enable <device>
                Enable the eMMC cache feature on <device>.
                NOTE! The cache is an optional feature on devices >= eMMC4.5.
        mmc cache disable <device>
                Disable the eMMC cache feature on <device>.
                NOTE! The cache is an optional feature on devices >= eMMC4.5.
        mmc csd read <device path>
                Print CSD data from <device path>.
                The device path should specify the csd file directory.
        mmc cid read <device path>
                Print CID data from <device path>.
                The device path should specify the cid file directory.
        mmc scr read <device path>
                Print SCR data from <device path>.
                The device path should specify the scr file directory.
        mmc ffu <image name> <device>
                Run Field Firmware Update with <image name> on <device>.


        mmc help|--help|-h
                Show the help.

        mmc <cmd> --help
                Show detailed help for a command or subset of commands.

0.1

  • 2
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用\[1\]:在ZynqMP平台上,可以通过将文件系统和内核、uboot复制到eMMC分区来实现eMMC启动。首先,在官方板子上使用SD卡启动,然后挂载eMMC分区,将文件系统和内核、uboot复制到eMMC分区。接下来,通过拨码开关启动。需要注意的是,如果要将系统放到8G的eMMC中,需要进行压缩处理。可以在虚拟机中挂载SD卡,查看文件系统分区的实际大小,并进行压缩。压缩后的文件系统可以挂载到eMMC中,并直接解压到eMMC中。实测压缩后的文件系统大小为2.6G。\[1\] 引用\[2\]:如果遇到无法ping通外网的问题,可以参考https://superuser.com/questions/1026291/linux-avahi-daemon-failed-to-find-user-avahi。如果SSH无法登录,即使修改了/etc/ssh/sshd_config中的perimtrootlogin为yes,仍然无法登录,可以参考https://blog.csdn.net/lizheng2017/article/details/123141120。在处理这些问题时,可以观察启动日志,查看哪些服务未启动,并根据提示寻找解决方法。\[2\] 引用\[3\]:如果网络无法启动,eth无法识别,可以在rc.local文件中配置网络IP和网关。需要注意的是,在rc.local文件中启动失败的程序需要屏蔽,并在网络启动服务和设置IP服务之间增加适当的延时(例如sleep 5)。\[3\] 综上所述,要在ZynqMP上实现eMMC启动,可以通过将文件系统和内核、uboot复制到eMMC分区,并进行压缩处理。同时,需要注意处理网络相关的问题,如无法ping通外网、SSH无法登录以及网络无法启动等。可以参考提供的链接和观察启动日志来解决这些问题。 #### 引用[.reference_title] - *1* *2* *3* [在黑金zynqmp 上用emmc 启动的那些坑](https://blog.csdn.net/Nyiragongo/article/details/128470418)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值