|
| 1 | +# Flashing Zarhus OS |
| 2 | + |
| 3 | +There are many ways an OS can be flashed and booted on embedded platform, but |
| 4 | +the most common one is using an SD card. This guide will describe SD card |
| 5 | +flashing only, because all other ways to flash the image are highly |
| 6 | +target-specific and are described [per-target](../supported-targets/targets.md). |
| 7 | + |
| 8 | +## Flashing SD card |
| 9 | + |
| 10 | +This section demonstrates how to flash a Zarhus OS image on the SD card. |
| 11 | + |
| 12 | +### Prerequisites |
| 13 | + |
| 14 | +* Linux PC (tested on `Fedora 40`); |
| 15 | +* [bmaptool](https://docs.yoctoproject.org/dev-manual/bmaptool.html) |
| 16 | + installed: |
| 17 | + |
| 18 | + ```bash |
| 19 | + sudo apt install bmap-tools |
| 20 | + ``` |
| 21 | + |
| 22 | +* Zarhus OS image built according to [build guide](./building.md). |
| 23 | + |
| 24 | +!!! note |
| 25 | + |
| 26 | + You can also use `bmaptool` [from |
| 27 | + GitHub](https://github.com/yoctoproject/bmaptool) if it is not available in |
| 28 | + your distro. |
| 29 | + |
| 30 | +### Flashing |
| 31 | + |
| 32 | +Find out your device name: |
| 33 | + |
| 34 | +```shell |
| 35 | +$ lsblk |
| 36 | +(...) |
| 37 | +sdx 8:16 1 14.8G 0 disk |
| 38 | +├─sdx1 8:17 1 3.5M 0 part |
| 39 | +├─sdx2 8:18 1 256K 0 part |
| 40 | +├─sdx3 8:19 1 192K 0 part |
| 41 | +(...) |
| 42 | +``` |
| 43 | + |
| 44 | +!!! warning |
| 45 | + |
| 46 | + In this case the device name is `/dev/sdx` **but be aware, in next steps |
| 47 | + replace `/dev/sdx` with the right device name on your platform or else you |
| 48 | + can damage your system!** |
| 49 | + |
| 50 | +From the directory you ran your image build, run command: |
| 51 | + |
| 52 | +```shell |
| 53 | +$ cd build/tmp/deploy/images/MACHINE_NAME |
| 54 | +$ sudo umount /dev/sdx* |
| 55 | +$ sudo bmaptool copy IMAGE_NAME-IMAGE_TYPE-MACHINE_NAME.rootfs.wic.gz /dev/sdx |
| 56 | +``` |
| 57 | + |
| 58 | +!!! note |
| 59 | + |
| 60 | + Replace `MACHINE_NAME` with the name of the machine you have built the image |
| 61 | + for, `IMAGE_TYPE` with `debug` or `prod` and `IMAGE_NAME` with the name of |
| 62 | + the image you have built. |
| 63 | + |
| 64 | +You should see output similar to this: |
| 65 | + |
| 66 | +```shell |
| 67 | +bmaptool: info: block map format version 2.0 |
| 68 | +bmaptool: info: 85971 blocks of size 4096 (335.8 MiB), mapped 42910 blocks (167.6 MiB or 49.9%) |
| 69 | +bmaptool: info: copying image 'zarhus-base-image-debug-zarhus-machine-cm3.rootfs.wic.gz' to block device '/dev/sdx' using bmap file 'zarhus-base-image-debug-zarhus-machine-cm3.rootfs.wic.bmap' |
| 70 | +bmaptool: info: 100% copied |
| 71 | +bmaptool: info: synchronizing '/dev/sdx' |
| 72 | +bmaptool: info: copying time: 11.1s, copying speed 15.1 MiB/sec |
| 73 | +``` |
| 74 | + |
| 75 | +## Verification |
| 76 | + |
| 77 | +After the SD card has been flashed with your image, the partitions (at least |
| 78 | +`rootfs` partition) should be mountable. So, you can mount a partition and |
| 79 | +explore the Zarhus OS without even booting it! Here is example block storage |
| 80 | +layout after flashing [Zarhus Rockchip OS |
| 81 | +image](https://github.com/zarhus/meta-zarhus-bsp-rockchip/blob/main/wic/sdimage-rockchip.wks): |
| 82 | + |
| 83 | +```bash |
| 84 | +$ lsblk |
| 85 | +(...) |
| 86 | +sdx 8:16 1 14.8G 0 disk |
| 87 | +├─sdx1 8:17 1 3.5M 0 part |
| 88 | +├─sdx2 8:18 1 256K 0 part |
| 89 | +├─sdx3 8:19 1 192K 0 part |
| 90 | +├─sdx4 8:20 1 32K 0 part |
| 91 | +├─sdx5 8:21 1 32K 0 part |
| 92 | +├─sdx6 8:22 1 4M 0 part |
| 93 | +├─sdx7 8:23 1 4M 0 part |
| 94 | +├─sdx8 8:24 1 4M 0 part |
| 95 | +└─sdx9 8:25 1 320.7M 0 part |
| 96 | +(...) |
| 97 | +``` |
| 98 | + |
| 99 | +!!! note |
| 100 | + |
| 101 | + Your SD card may get another file name in your system, here `sdx` is shown |
| 102 | + as an example. |
| 103 | + |
| 104 | +Mounting `rootfs`: |
| 105 | + |
| 106 | +```bash |
| 107 | +$ sudo mount /dev/sdx9 /mnt |
| 108 | +$ ls /mnt |
| 109 | +bin boot dev etc home lib lost+found media mnt proc root run sbin srv sys tmp usr var |
| 110 | +$ lsblk |
| 111 | +(...) |
| 112 | +sdx 8:16 1 14.8G 0 disk |
| 113 | +├─sdx1 8:17 1 3.5M 0 part |
| 114 | +├─sdx2 8:18 1 256K 0 part |
| 115 | +├─sdx3 8:19 1 192K 0 part |
| 116 | +├─sdx4 8:20 1 32K 0 part |
| 117 | +├─sdx5 8:21 1 32K 0 part |
| 118 | +├─sdx6 8:22 1 4M 0 part |
| 119 | +├─sdx7 8:23 1 4M 0 part |
| 120 | +├─sdx8 8:24 1 4M 0 part |
| 121 | +└─sdx9 8:25 1 320.7M 0 part /mnt |
| 122 | +(...) |
| 123 | +``` |
| 124 | + |
| 125 | +For further image verification checkout [verification guide](./verification.md). |
0 commit comments