Flashing Images to SDCard - cu-ecen-aeld/buildroot-assignments-base GitHub Wiki
For this step you will need an sdcard reader, either a USB version or one built into your computer.
You'll also need physical access to the image on the same machine which includes the SDCard reader.
- If you are using the same machine to build your image you can directly use the instructions below to place the image on your machine.
- If you are using a build machine in a virtual machine you can typically pass your SDCard into the VM instance.
- If you are using a cloud hosted build runner, this means you'll need to scp the image from the cloud machine to your host machine. See scp instructions below
See the instructions for use of scp in assignment 4 content or scp man page but the basic format is scp <user>@<source machine name or IP>:location <target machine path>
to copy from the source machine to your target.
- When using a Windows host you can install OpenSSH via powershell.
If you have a USB card reader or are using a physical linux machine with sdcard slot, you can write your image directly to the card using dd like this:
sudo dd if=buildroot/output/images/sdcard.img of=/dev/sdX conv=fdatasync bs=1M
where /dev/sdX is replaced with the [a-z] value of the device listed in your system log when you insert your sdcard. Be very careful with this command, if you choose the wrong device you could corrupt your root filesystem partition.
- Be sure to use the the /dev/sd[a-z] without the partition reference like /dev/sd[a-z]1. The 1 references the first partition. Boot won't work if you dd to the partition since you need to write the boot sector on the first block of the card.
The
conv=fdatasync
argument ensures the command will wait for all data to be written to the SDCard. You could also use thesync
command from the command prompt after the dd completes.
- Motivation:
To program an SD card withfoo.wic.bz2
format BMAP tool is helpful.
foo -> core-image-base-raspberrypi3
BMAP tool takes less arguments and easy to interpret. - Command format:
Be sure to select, proper sd[x] (x is the relevant partition) partition before running following command. Usually, sd[a] would be your windows partition when running the command from a virtual box.
sudo bmaptool copy path/to/image.wic.bz2 /dev/sd[b-z]
- Command usage example:
In the root of your build repo execute the following command:
sudo bmaptool copy build/tmp/deploy/images/raspberrypi3/core-image-base-raspberrypi3.wic.bz2 /dev/sdb
You can use Rufus on Windows to transfer the sdcard.img file to your sdcard.
If you see an error from rufus when attempting to write to your sdcard, you may need to remove any partitions on the sdcard using diskpart from the command line.
- Find the device in disk management, start diskpart.exe in an adminstrator command prompt, then use commands:
select disk X
clean
exit
where X is the disk number of the disk as shown in disk management. Here's an example of how disk management should look when a 30 GB flash drive Disk1 has partition information removed:
- Next select the sdcard.img file you build with buildroot and click "Start" to start the partition step
- Click OK at the warning steps about delting the partition after double checking that you've selected the correct device.