嵌入式Linux从TF卡启动,arm-linux嵌入式 系统直接从SD卡启动运行

这种一般是在工厂测试,为了提高效率 使用的

之前有写过一个,把SD卡制作好,然后通过另外分区, 加载到SD卡也能启动系统,但是这个有一个缺点,就是文件系统不能使用镜像直接烧了,要使用Linux拷贝文件到exit4中,

这样比较麻烦,今天记录一下在之前的基础上 实现 镜像的统一

参照这里把除了文件系统以外的uboot  zImage相关的文件制作好,文件系统镜像留着

完成以上的步骤,得到

zImag  MLO  **.dtb  u-boot.img

这里主要是修改bootargs启动参数

接下来就是分区合并了

命令操作如下:

sudo dd if=/dev/zero of=my.img bs=1M count=200

sudo losetup -f --show my.img

通过 fdisk 命令对磁盘文件进行分区,就跟普通磁盘文件一样。

sudo    fdisk    /dev/loop0

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building anew DOS disklabel with disk identifier 0x2e7df78e.

Changes will remaininmemory only, until you decide to write them.

After that, of course, the previous content won‘t be recoverable.

Warning: invalid flag0x0000 of partition table 4will be corrected by w(rite)

Command (mforhelp): n # 新建一个分区

Partition type:

p primary (0 primary, 0 extended, 4 free)

e extended

Select (defaultp): p # 主分区

Partition number (1-4, default 1): 1# 分区号

First sector (2048-409599, default 2048): # 默认2048

Usingdefault value 2048Last sector,+sectors or +size{K,M,G} (2048-409599, default 409599): +30M

# 给30M空间第一个分区

Command (mforhelp): n # 新建一个分区

Partition type:

p primary (1 primary, 0 extended, 3 free)

e extended

Select (defaultp): p # 主分区

Partition number (1-4, default 2): # 使用默认的2

Usingdefault value 2First sector (63488-409599, default 63488): # 使用默认值

Usingdefault value 63488Last sector,+sectors or +size{K,M,G} (63488-409599, default 409599): # 直接到结束

Usingdefault value 409599Command (mforhelp): t # 改变分区

Partition number (1-4): 1# 改变第几个分区

Hex code (type L to list codes): e # 改为FAT16分区

Changed system type of partition1to e (W95 FAT16 (LBA))

Command (mforhelp): a # 增加boot 属性

Partition number (1-4): 1# 指定第一个分区增加boot 属性

ommand (mforhelp): w # 保存相关信息

The partition table has been altered!Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.

The kernel still uses the old table. Thenewtable will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

WARNING: If you have created or modified any DOS6.x

partitions, please see the fdisk manual pageforadditional

information.

Syncing disks.

sudo kpartx -av /dev/loop0

sudo mkfs.vfat -n "boot" -F 16 /dev/mapper/loop0p1

sudo mkfs.ext3 -L "rootfs" /dev/mapper/loop0p2

接着挂载在p1  p2 上,首先新建两个文件夹 p1  p2

sudo mount /dev/mapper/loop0p1 p1

sudo mount /dev/mapper/loop0p2 p2

sync

就是复制你的镜像文件到对应的分区,把除了文件系统的文件,复制到p1  ,文件系统下的文件 复制到p2

然后解除挂载

sudo umount   p1   p2

sudo kpartx -d /dev/loop0

sudo losetup -d /dev/loop0

就可以把第一步制作的my.img 拷贝出去,正常烧录

原文:https://www.cnblogs.com/ChenChangXiong/p/12613760.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值