如何把文件系统烧到EMMC并从EMMC加载

描述

之前文章介绍了如何下载并从SD卡加载文件系统,提到过可以从EMMC引导系统,本篇将为您介绍如何把文件系统烧到EMMC,并从EMMC加载。

接之前操作,系统已经从SD卡正常启动(本文方案需要借助SD卡):

Version: 3.0.3 

smarc-rzg2l login: root 

Last login: Sun Sep 20 1003 UTC 2020

root@smarc-rzg2l:~#

已经可以接上网线,并借助网路(如ssh服务)把相关文件拷贝到SD卡,为后边做准备。

需要的文件如下:

root@smarc-rzg2l:~# ls

Image-r9a07g044l2-smarc.dtb Image-smarc-rzg2l.bin core-image-qt-smarc-rzg2l.tar.bz2  

EMMC创建分区:

左右滑动查看完整内容

 

root@smarc-rzg2l:~# fdisk /dev/mmcblk0


Welcome to fdisk (util-linux 2.35.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): o
Created a new DOS disklabel with disk identifier 0xf23e9318.


Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): (Push the enter key)


Using default response p.
Partition number (1-4, default 1): (Push the enter key)
First sector (2048-124321791, default 2048): (Push the enter key)
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-124321791, default 124321791): +500M


Created a new partition 1 of type 'Linux' and of size 500 MiB.


Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): (Push the enter key)


Using default response p.
Partition number (2-4, default 2): (Push the enter key)
First sector (1026048-124321791, default 1026048): (Push the enter key)
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1026048-124321791, default 124321791): (Push the enter key)


Created a new partition 2 of type 'Linux' and of size 58.8 GiB.


Command (m for help): p
Disk /dev/mmcblk0: 59.29 GiB, 63652757504 bytes, 124321792 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf23e9318


Device         Boot   Start       End   Sectors  Size Id Type
/dev/mmcblk0p1         2048   1026047   1024000  500M 83 Linux
/dev/mmcblk0p2      1026048 124321791 123295744 58.8G 83 Linux


Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@smarc-rzg2l:~#

 

格式化EMMC:

左右滑动查看完整内容

 

root@smarc-rzg2l:~# mkfs.ext4 /dev/mmcblk0p1
mke2fs 1.45.7 (28-Jan-2021)
Discarding device blocks: done
Creating filesystem with 512000 1k blocks and 128016 inodes
Filesystem UUID: cd3a51a9-ef38-4399-888e-9773fcc41ecc
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409


Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done


root@smarc-rzg2l:~# mkfs.ext4 /dev/mmcblk0p2
mke2fs 1.45.7 (28-Jan-2021)
Discarding device blocks: done
Creating filesystem with 15411968 4k blocks and 3858432 inodes
Filesystem UUID: 07d98391-d70c-4eed-a3af-4227a7460a32
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424


Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done


root@smarc-rzg2l:~#

 

挂载EMMC,拷贝内核、设备树、文件系统:

左右滑动查看完整内容

 

root@smarc-rzg2l:~# mount /dev/mmcblk0p1 /mnt/
root@smarc-rzg2l:~# cp Image-smarc-rzg2l.bin /mnt/
root@smarc-rzg2l:~# cp Image-r9a07g044l2-smarc.dtb /mnt/
root@smarc-rzg2l:~# umount /dev/mmcblk0p1
root@smarc-rzg2l:~# mount /dev/mmcblk0p2 /mnt/
root@smarc-rzg2l:~# tar xf core-image-qt-smarc-rzg2l.tar.bz2 -C /mnt/
root@smarc-rzg2l:~# umount /dev/mmcblk0p2

 

关机,设置开发板SW11/SW1拨码开关模式:

文件系统文件系统

重启开发板,设置环境变量:

左右滑动查看完整内容

 

NOTICE:  BL2: v2.7(release):203c783-dirty
NOTICE:  BL2: Built : 06:57:02, Nov 10 2022
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x1f840 src=(p:1)0x20000(256) len=0x10(1)
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x1f9a0 src=(p:1)0x20010(256) len=0x28(1)
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x44000000 src=(p:1)0x20090(256) len=0x6069(49)
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x1f840 src=(p:1)0x20000(256) len=0x10(1)
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x1f9a0 src=(p:1)0x20010(256) len=0x28(1)
NOTICE:  BL2: Load dst=0x1f9a0 src=(p:1)0x20038(256) len=0x28(1)
NOTICE:  BL2: eMMC boot from partition 1
NOTICE:  BL2: Load dst=0x50000000 src=(p:1)0x26100(304) len=0xb0238(1410)
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.7(release):203c783-dirty
NOTICE:  BL31: Built : 06:57:02, Nov 10 2022




U-Boot 2021.10 (Mar 15 2023 - 07:34:17 +0000)


CPU:   Renesas Electronics K rev 2.1
Model: smarc-rzg2l
DRAM:  1.9 GiB
WDT:   watchdog@0000000012800800
WDT:   Started with servicing (60s timeout)
MMC:   sd@11c00000: 0, sd@11c10000: 1
Loading Environment from MMC... OK
In:    serial@1004b800
Out:   serial@1004b800
Err:   serial@1004b800
U-boot WDT started!
Net:
Error: ethernet@11c20000 address not set.
No ethernet found.


Hit any key to stop autoboot:  0
Hit any key to stop autoboot:  0
=> env default -a
## Resetting to default environment
=> setenv bootargs 'root=/dev/mmcblk0p2 rootwait'
=> setenv bootcmd 'mmc dev 1; ext4load mmc 0:1 0x48080000 Image-smarc-rzg2l.bin; ext4load mmc 0:1 0x48000000 Image-r9a07g044l2-smarc.dtb; booti 0x48080000 - 0x48000000'
=> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK

 

重启开发板,从emmc成功加载:

 

 

BSP: RZG2L/RZG2L-SMARC-EVK/3.0.3
LSI: RZG2L
Version: 3.0.3
smarc-rzg2l login: root
Last login: Mon Sep 18 02:29:32 UTC 2023
root@smarc-rzg2l:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/root              58G  1.2G   54G   3% /
devtmpfs              740M     0  740M   0% /dev
tmpfs                 933M     0  933M   0% /dev/shm
tmpfs                 933M  9.7M  924M   2% /run
tmpfs                 933M     0  933M   0% /sys/fs/cgroup
tmpfs                 933M     0  933M   0% /tmp
tmpfs                 933M   28K  933M   1% /var/volatile
tmpfs                 187M     0  187M   0% /run/user/0
root@smarc-rzg2l:~#

 

  审核编辑:汤梓红

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分