GNU/Linux - wic文件的使用

Yocto/OpenEmbedded使用的磁盘镜像格式是 wic。为嵌入式系统提供 bootable images。

The disk image format used in the Yocto Project is wic.

.wic 文件显然只是一个带有分区表和分区的磁盘镜像,就像下载 Linux 发行版时获得的所有 .img 文件一样。这就是为什么你可以使用 dd 命令烧写 .wic 文件,就像使用 .img 文件一样。

A .wic file is apparently just a disk image with a partition table and partitions, just like all the .img files you get when downloading e.g Linux distros. That's why you can flash a .wic file using dd just like you would with a .img file.

之所以使用 .wic 文件扩展名,是因为它是由 wic 工具创建的,该工具读取 .wks 文件中描述的分区布局,并生成带有相应分区的映像。有关 wic 工具的更多信息,请参阅: 19 Creating Partitioned Images Using Wic — The Yocto Project ® 5.0.1 documentation

The reason for the .wic file extension is simply that it's created by the wic tool, which reads a partition layout described in a .wks file and generates an image with the corresponding partitions. For more info on the wic tool, see:  19 Creating Partitioned Images Using Wic — The Yocto Project ® 5.0.1 documentation 

如何读取wic文件中的内容呢?

1,Mount the .wic File

将wic文件加载为loop device。

Automatically find an available loop device and associate it with a file.

$ sudo losetup -Pf --show my-image.wic

/dev/loop17

$ losetup --help

-a, --all                     list all used devices

-P, --partscan                create a partitioned loop device

-f, --find                    find first unused device

--show                    print device name after setup (with -f)

-d, --detach <loopdev>...     detach one or more devices

-D, --detach-all              detach all used devices

$ losetup -a

上面结果显示加载为/dev/loop17设备。

将设备名赋值给变量:

LOOP_DEVICE=$(sudo losetup -Pf --show my-image.wic)

2, List Partitions

使用fdisk命令,查看加载设备的分区信息

$ sudo fdisk -l /dev/loop17

Disk /dev/loop17: 7.11 GiB, 7638816768 bytes, 14919564 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: 0x076c4a2a

Device        Boot  Start      End  Sectors  Size Id Type

/dev/loop17p1 *     16384   186775   170392 83.2M  c W95 FAT32 (LBA)

/dev/loop17p2      196608 14919563 14722956    7G 83 Linux

3,Mount Partitions

sudo mount  /dev/loop17p1 mnt

4,Access Files

cd mnt

ls

5, Cleaning up

Unmount partitions:

sudo umount mnt

6, Detach the loop device

sudo losetup -d /dev/loop17


使用kpartx命令操作:

$ kpartx --help

-a add partition devmappings

-d del partition devmappings

-v verbose

-l list partitions devmappings that would be added by -a

$ sudo kpartx -av my-image.wic

[sudo] password for dev:

add map loop17p1 (252:0): 0 170392 linear 7:17 16384

add map loop17p2 (252:1): 0 14722956 linear 7:17 196608

$ sudo kpartx -l my-image.wic

loop17p1 : 0 170392 /dev/loop17 16384

loop17p2 : 0 14722956 /dev/loop17 196608

$ sudo kpartx -l /dev/loop17

loop17p1 : 0 170392 /dev/loop17 16384

loop17p2 : 0 14722956 /dev/loop17 196608

$ sudo fdisk -l /dev/loop17

Disk /dev/loop17: 7.11 GiB, 7638816768 bytes, 14919564 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: 0x076c4a2a

Device        Boot  Start      End  Sectors  Size Id Type

/dev/loop17p1 *     16384   186775   170392 83.2M  c W95 FAT32 (LBA)

/dev/loop17p2      196608 14919563 14722956    7G 83 Linux

$ ls /dev/mapper/

control  loop17p1  loop17p2

$ sudo mount /dev/mapper/loop17p2 mnt

$ sudo umount mnt

$ sudo kpartx -dv my-image.wic

del devmap : loop17p1

del devmap : loop17p2

loop deleted : /dev/loop17

$ sudo kpartx -dv /dev/loop17

del devmap : loop17p1

del devmap : loop17p2

参考:

linux - Difference between wic and hddimg format in yocto - Stack Overflow

### LoongArch GNU 工具链配置详情及 GCC 版本信息 #### 配置细节 LoongArch GNU 工具链的目标架构为 `loongarch64-linux-gnu`,其对应的 GCC 编译器版本为 8.3.0。此工具链支持龙芯自主指令集体系结构(LoongArch),并针对该架构进行了优化[^1]。 在构建过程中,GCC 的配置选项通常会指定目标平台以及所需的特性支持。对于 LoongArch 架构而言,常见的配置命令可能如下所示: ```bash ./configure --target=loongarch64-linux-gnu \ --prefix=/opt/loongson/toolchain \ --enable-languages=c,c++ \ --disable-multilib \ --with-system-zlib \ --with-gmp=/usr/local/gmp \ --with-mpfr=/usr/local/mpfr \ --with-mpc=/usr/local/mpc \ --with-isl=/usr/local/isl ``` 上述配置说明了以下几点: - 使用 `--target=loongarch64-linux-gnu` 来定义目标平台。 - 设置安装路径为 `/opt/loongson/toolchain`。 - 启用了 C 和 C++ 支持。 - 关闭多库模式以减少复杂度。 - 指定了依赖项的位置,例如 GMP、MPFR、MPC 和 ISL 库。 #### GCC 版本信息 所使用的 GCC 版本为 8.3.0,这是由官方预先编译好的二进制文件提供[^4]。通过解压预编译的工具链包即可获得完整的开发环境。例如,在 Linux 下可以通过以下命令完成解压操作: ```bash tar -xvf loongson-gnu-toolchain-8.3-src-loongarch64-linux-gnu-rc1.2.tar ``` 这一步骤将提取出所有必要的组件,包括编译器、汇编器和链接器等工具。 此外,动态链接库的信息也表明系统中存在兼容的 libc 实现。例如,标准 C 库的共享对象文件位于 `/lib/x86_64-linux-gnu/libc.so.6` 中[^3]。尽管此处提到的是 x86_64 平台上的实现,但在 LoongArch 上也会有类似的对应版本。 --- ### 总结 综上所述,LoongArch GNU 工具链基于 GCC 8.3.0 开发,并专门适配于 `loongarch64-linux-gnu` 目标平台。它不仅提供了高效的编译能力,还包含了经过验证的标准库支持。用户可以按照既定流程下载并部署这一工具链至本地环境中,从而开展面向 LoongArch 架构的应用程序开发工作。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值