How to Flash Yocto Images to Raspberry Pi SD Card Using DD: Step-by-Step Guide

If you have already followed steps to build root filesystem and kernel for RaspberryPi using yocto as mentioned at “Building kernel and filesystem using Yocto for Raspberry Pi / Creating Embedded Linux for RPi using Yocto”, it creates sdimg files inside build/tmp/deploy/images/raspberrypi3 which contains both RFS & kernel. We need to flash this image to SD card using dd tool as,

 $ cd build/tmp/deploy/images/raspberrypi3

Clear kernel dmesg from terminal to identify latest messages as,

 $ sudo dmesg -c

Now connect SD card to PC, and type dmesg on terminal, you might see messages like below,

 $ dmesg 
[ 1528.540042] usb 2-2: new high-speed USB device number 3 using ehci-pci
[ 1528.673479] usb 2-2: New USB device found, idVendor=aaaa, idProduct=8816
[ 1528.673492] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1528.673500] usb 2-2: Product: MXT USB Device
[ 1528.673506] usb 2-2: Manufacturer: MXTronics
[ 1528.673512] usb 2-2: SerialNumber: 130818v01
[ 1528.674322] usb-storage 2-2:1.0: USB Mass Storage device detected
[ 1528.676506] scsi host7: usb-storage 2-2:1.0
[ 1529.676941] scsi 7:0:0:0: Direct-Access     MXT-USB  Storage Device   1308 PQ: 0 ANSI: 0 CCS
[ 1529.677949] sd 7:0:0:0: Attached scsi generic sg2 type 0
[ 1529.679771] sd 7:0:0:0: [sdb] 1984000 512-byte logical blocks: (1.02 GB/969 MiB)
[ 1529.681752] sd 7:0:0:0: [sdb] Write Protect is off
[ 1529.681764] sd 7:0:0:0: [sdb] Mode Sense: 03 00 00 00
[ 1529.682390] sd 7:0:0:0: [sdb] No Caching mode page found
[ 1529.682400] sd 7:0:0:0: [sdb] Assuming drive cache: write through
[ 1529.690150]  sdb: sdb1
[ 1529.692905] sd 7:0:0:0: [sdb] Attached SCSI removable disk
[ 1530.717761] FAT-fs (sdb1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

Above messages, shows that our SD card is detected as /dev/sdb with only one partition as, /dev/sdb1. Now to flash the complete yocto image which normaly contains 2 partitions, we have to use root of sd card partition as /dev/sdb and not /dev/sdb1 [ keep note of this ]
Note: There are chances, you might see your SD detected with some other devices nodes like /dev/sdc or /dev/mmblk0 etc, so use correct device node which you see in dmesg after connecting SD card, or you might end up formatting something different like your Hard dist.

Now check name of rpi-sdimg in directory as,

$ ls -alh core-image-minimal-raspberrypi3.rpi-sdimg

lrwxrwxrwx 2 myuser myuser 63 Sep  9 09:57 core-image-minimal-raspberrypi3.rpi-sdimg -> core-image-minimal-raspberrypi3-20170909042633.rootfs.rpi-sdimg

core-image-minimal-raspberrypi3.rpi-sdimg contains minimal image, you can also flash complete UI if you have created sato image core-image-sato-raspberrypi3.rpi-sdimg

 $ sudo dd if=./core-image-minimal-raspberrypi3.rpi-sdimg of=/dev/sdb

Leave a Comment