linux用dd命令制作整个emmc的bin文件用于产线烧录(PC端)

本文档介绍了一种在PC端使用dd命令创建整个EMMC bin文件(包括partition、boot和rootfs)的方法,避免了在板子上运行后生成bin文件的步骤。首先,通过dd创建一个4G的bin文件,接着使用gdisk创建GPT分区并命名,然后将boot.img和rootfs.img分别添加到bin文件中,从而得到原始的bin文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景

        以前制作工厂烧录的bin文件一直是先烧录板子,然后在板子上dd一个bin文件出来用于产线烧录,这种方式dd出来的bin文件是被在板子上运行过的,不是原始状态。

        那么工作上遇到一些需求就是不想用这种方式,想要PC端原始生成一个bin文件,那么如下这种办法提供了一种方法,可以在PC端用dd命令生成一整个emmc的bin文件(partition+boot+rootfs)。

思路

通过dd制作partition后不要执行最后一步,即不执行dd if=disk.img of=partition.img bs=1k count=32,此时partition已经在了,然后再通过dd命令将其余的img加进去即可。

方法(example)

1)dd一个4G的bin文件

dd if=/dev/zero of=emmc.bin bs=1M count=4096

2)创建partition

hui@hui:~/work/tools/partition$ gdisk emmc.bin

GPT fdisk (gdisk) version 1.0.3

Partition table scan:

MBR: not present

BSD: not present

APM: not present

GPT: not present

Creating new GPT entries.

Command (? for help): n

Partition number (1-128, default 1):

First sector (34-8388574, default = 2048) or {+-}size{KMGTP}:

Last sector (2048-8388574, default = 8388574) or {+-}size{KMGTP}: +256M

Current type is 'Linux filesystem'

Hex code or GUID (L to show codes, Enter = 8300):

Changed type of partition to 'Linux filesystem'

Command (? for help): n

Partition number (2-128, default 2):

First sector (34-8388574, default = 526336) or {+-}size{KMGTP}:

Last sector (526336-8388574, default = 8388574) or {+-}size{KMGTP}: +3G

Current type is 'Linux filesystem'

Hex code or GUID (L to show codes, Enter = 8300):

Changed type of partition to 'Linux filesystem'

Command (? for help): p

Disk emmc.bin: 8388608 sectors, 4.0 GiB

Sector size (logical): 512 bytes

Disk identifier (GUID): A985885F-8435-49F1-AA58-5C82B863B981

Partition table holds up to 128 entries

Main partition table begins at sector 2 and ends at sector 33

First usable sector is 34, last usable sector is 8388574

Partitions will be aligned on 2048-sector boundaries

Total free space is 1572797 sectors (768.0 MiB)

Number Start (sector) End (sector) Size Code Name

1 2048 526335 256.0 MiB 8300 Linux filesystem

2 526336 6817791 3.0 GiB 8300 Linux filesystem

Command (? for help): c

Partition number (1-2): 1

Enter name: boot

Command (? for help): c

Partition number (1-2): 2

Enter name: rootfs

Command (? for help): p

Disk emmc.bin: 8388608 sectors, 4.0 GiB

Sector size (logical): 512 bytes

Disk identifier (GUID): A985885F-8435-49F1-AA58-5C82B863B981

Partition table holds up to 128 entries

Main partition table begins at sector 2 and ends at sector 33

First usable sector is 34, last usable sector is 8388574

Partitions will be aligned on 2048-sector boundaries

Total free space is 1572797 sectors (768.0 MiB)

Number Start (sector) End (sector) Size Code Name

1 2048 526335 256.0 MiB 8300 boot

2 526336 6817791 3.0 GiB 8300 rootfs

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING

PARTITIONS!!

Do you want to proceed? (Y/N): y

OK; writing new GUID partition table (GPT) to emmc.bin.

Warning: The kernel is still using the old partition table.

The new table will be used at the next reboot or after you

run partprobe(8) or kpartx(8)

The operation has completed successfully.

3)将boot.img加到emmc.bin

simg2img boot.img boot.ext4

dd if=boot.ext4 of=emmc.bin bs=1K seek=1024 conv=notrunc

4)将rootfs.img添加到emmc.bin

simg2img rootfs.img rootfs.ext4

dd if=rootfs.ext4 of=emmc.bin bs=1M seek=257 conv=notrunc

完结!

如果对您有帮助,请动动手指点个赞哦 !

声明:自己总结,请结合自己情况使用!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值