3.6.8.2.5 Step 5 - Flashing the Embedded Linux Image to the Board

A Linux image is tightly related to the SoC hardware design it was compiled for. SmartHLS uses the Microchip Linux image - 2023.02.1 release, which is meant to be used with the Icicle Kit Reference Design - 2023.02 release and may not be the same as the image that the Icicle Kit board has been flashed with from the factory, or any other image currently loaded in your board. If you have your own Linux image and your own Libero SoC project then see the User-defined SmartDesigns section.

To program this Linux image to the board, follow these instructions:

  1. Download the Linux image core-image-minimal-dev-icicle-kit-es-20230328094718.rootfs.wic.gz and its associated core-image-minimal-dev-icicle-kit-es-20230328094718.rootfs.wic.bmap file file. Then verify their checksum.
    $> wget https://github.com/polarfire-soc/meta-polarfire-soc-yocto-bsp/releases/download/v2024.2/core-image-minimal-dev-icicle-kit-es-20230328094718.rootfs.wic.gz
    
    $> wget https://github.com/polarfire-soc/meta-polarfire-soc-yocto-bsp/releases/download/v2024.2/core-image-minimal-dev-icicle-kit-es-20230328094718.rootfs.wic.bmap
    
    $> sha256sum core-image-minimal-dev-icicle-kit-es.wic.*
    
    58fdce37eb4e3f63cb8e6aa0569d5a5a47fcb67352e6548dc659a082e8ad6a76  core-image-minimal-dev-icicle-kit-es-20230328094718.rootfs.wic.bmap
    
    4a1406ba9e764a94026fcea2ee8fbb84f91384e953e7ba6176fcb7dadcbc5522  core-image-minimal-dev-icicle-kit-es-20230328094718.rootfs.wic.gz
         ...
    
  2. In the Host PC with Linux enter the command ls /dev/sd*, and take note of what appears. This will be used in a later step to help determine the device name of the eMMC flash memory.

In our example, we have /dev/sda and /dev/sdc already:

Expose Board’s eMMC Flash Memory to Host PC as USB flash storage

To flash the Embedded Linux image we first need to expose the eMMC flash memory as a USB storage device to the host PC. Make sure the board’s USB OTG connection is made as described in Step 1: Setup Required Board Connections.
  1. Reset the Icicle Kit by pressing push button SW4 (top left push button). In the HSS Serial terminal, when prompted to Press a key to enter CLI, press any key aside from ESC. If you don’t press a key within 1 second then the board will continue to boot Linux and you will have to reset the board again. Double check in the Linux Serial Terminal to verify that you don’t see any output from Linux booting.
    You should now see a prompt for the HSS command-line interface:
  2. In the HSS Serial Terminal, enter the command mmc to select the eMMC flash memory (only needed for newer HSS versions). Then enter the command usbdmsc.
    Important: If you see “FLASH_DRIVE_init() returned false” (below), then you forgot to run the mmc command before running usbdmsc.
  3. If the board is properly connected to your host computer, you should see data being read as shown on the last line of the following image:
  4. On a Linux host PC, you can run again ls /dev/sd* and compare against what we saw inin the earlier step. Note which new device shows up. In our example, /dev/sda and /dev/sdc were present before, but /dev/sdb is new. Therefore, the eMMC flash memory on the board is represented on our host machine as: /dev/sdb. We can now flash the Linux image to the board.
    Alternatively, you can check the exact device using the lshw command and it will show the device for the PolarFireSoC:
    $> sudo lshw -class disk -short
    H/W path                 Device     Class          Description==============================================================
    /0/100/14/0/6/0.0.0      /dev/sdb   disk           7820MB PolarFireSoC_msd
    /0/100/14/0/6/0.0.0/0    /dev/sdb   disk           7820MB
    /0/1/0.0.0               /dev/sda   disk           1TB Samsung SSD 860

    On a Windows host PC, you can use the Windows File Explorer -> This PC to see the Icicle Kit’s eMMC flash memory as a media drive. In this case, shown as “boot (D:)”:

Flash the Embedded Linux Image to the Board

Using Balena Etcher

For either Linux or Windows, you can easily flash the Embedded Linux image (*.wic.gz file) using Balena Etcher software, which can be downloaded here: etcher.balena.io.

Open Balena's Etcher and click on Flash from file. This will open a window to select the file you want to flash. Choose the *.wic.gz file (Embedde Linux Image file) then click on Select target button and choose the board's flash memory drive as described in the previous section. The drive should have been detected by Windows or Linux when you issued the usbdmmc command. Once you have set the target and file, click on theFlash! button and wait for the image file to be flashed to the board.

After the flashing command completes, you should disconnect the mounted drive, by typing Ctrl+C in the HSS Serial Terminal. The embedded Linux image on the board is now updated.

Using command line (Linux-only).

Alternateively, when using Linux you can use the bmap tool. Assuming the board flash storage device is /dev/sdb you can flash the image like this:

$> bmaptool copy <linux image>.wic.gz /dev/sdb

Note that to use bmap you need the *.wic.bmap file that was downloaded earlier.

Yet anoter alternative in Linux is to use the dd command as follows:

$> sudo umount /dev/sdb
$> zcat <linux image>.wic.gz | sudo dd of=/dev/sdb bs=4096iflag=fullblock oflag=direct conv=fsync status=progress
Warning:
dd flashing command should take several minutes to complete. DO NOT power cycle the Icicle board at this point.
After the flashing command completes, you should disconnect the mounted drive, by typing Ctrl+C in the HSS Serial Terminal. The embedded Linux image on the board is now updated.