ARMADA 388 ClearFog: Install LEDE into eMMC in an easy way

UPDATE:
02/11/2018 – Update dropbox link.

Last time I have talked about the install of system into eMMC flash. This process is rather complicated and time consuming. After that I have a further research of the current LEDE project, Solid-Run forum and Armbian forum. And I will try to figure out another easy way to prepare the LEDE system into the eMMC flash in this post.

Note: Following method is only tested in ClearFog Pro board.

1. Preparation

  1. ARMADA SoM with eMMC flash
  2. ARMADA carrier board. Here I have only ClearFog Pro;
  3. Ehternet cable;
  4. Plug in USB cable in Debug port and open your serial terminal;
  5. 12V power adapter;
  6. Ready-to-use images or compile your own from scratch U-Boot, LEDE;

2. U-Boot: Compile

As this wiki said, following the instructions below to build U-Boot for ClearFog board

git clone https://github.com/SolidRun/u-boot-armada38x.git
cd u-boot-armada38x
export CROSS_COMPILE=<Set toolchain prefix to your toolchain>
make armada_38x_clearfog_config
make u-boot.mmc

You will get u-boot.mmc and u-boot-uart.mmc. The first one is for SD/eMMC boot mode and the second one is for UART boot mode.

2. U-Boot: Download UART Bootloader

When the board is not power on, changing SW1 to UART boot mode. The u-boot-mmc.mmc version that is build in the last step is ready to use. At first we need a program to transfer this image to ClearFog board. Here we have two choice, the first one is download-serial.sh which you can find in the u-boot source tree. The other one is kwboot which you can compile from uboot-kirkwood package in both OpenWRT and LEDE system. Here is a instruction of this program:

Usage: kwboot [-d | -a | -q <req-delay> | -s <resp-timeo> | -b <image> | -D <image> ] [ -t ] [-B <baud> ] <TTY>

  -b <image>: boot <image> with preamble (Kirkwood, Armada 370/XP)
  -p: patch <image> to type 0x69 (uart boot)
  -D <image>: boot <image> without preamble (Dove)
  -d: enter debug mode
  -a: use timings for Armada XP
  -q <req-delay>:  use specific request-delay
  -s <resp-timeo>: use specific response-timeout

  -t: mini terminal

  -B <baud>: set baud rate

Following instruction is used to prepare the transfer of u-boot-uart.mmc into RAM of ARMADA388 chip from PC side.

kwboot -b u-boot-uart.mmc -t /dev/ttyUSB0 -B 115200n8

Then power on your board and you will have following output:

Sending boot message. Please reboot the target...|
Sending boot image...
  0 % [......................................................................]
  0 % [......................................................................]
  1 % [......................................................................]
............
 96 % [......................................................................]
 97 % [......................................................................
 98 % [......................................................................]
 99 % [............................................................]

kwboot will start a terminal after the transfer is finished. You will see U-Boot information and should press Enter to stop the automatic boot progress and come to the next step.

3. U-Boot: Flash eMMC Bootloader

Now the U-Boot is running and the hardwares such as Ethernet are initialised. Plugin the Ethernet cable and setup the IP addresses:

Marvell>> setenv serverip <server ip>
Marvell>> setenv ipaddr <board ip>
Marvell>> saveenv
Saving Environment to MMC...
Writing to MMC(0)... done
Marvell>> 

You could use ping command to check the connection

Marvell>> ping $serverip
host 192.168.112.17 is alive

Now you could download another bootloader:

Marvell>> tftp u-boot.mmc
Using egiga0 device
TFTP from server 192.168.112.17; our IP address is 192.168.112.18
Filename 'u-boot.mmc'.
Load address: 0x1000000
Loading: #################################################################
     6 MiB/s
done
Bytes transferred = 952620 (e892c hex)
Marvell>>

There are two import information which should be noted: Load address: 0x1000000 and Bytes transferred = 952620 (e892c hex). The first one is the start address of image in RAM from where we should copy into the eMMC flash. The second one indicates 952620 / 512 ~ 1861 (0x745) ~ 0x800 blocks we should copy.

As this wiki said:

The main different between booting u-boot on eMMC and MicroSD is that in MicroSD u-boot resides in second sector of the SD card, where in eMMC it must reside in first block in either the main eMMC storage or it’s first or second boot partitions.

So if the main physical partition of eMMC is used then it will override the partition table. So it’s recommended to use the boot partitions for that purpose.

Therefore:

Marvell>> mmc dev 0 1
switch to partions #1, OK
mmc0(part 1) is current device
Marvell>> mmc write 0x1000000 0 0x800

MMC write: dev # 0, block # 0, count 2048 ... 2048 blocks write: OK

Now the normal eMMC bootloader is ready. It’s time to download the filesystem.

4. LEDE: Download

Recently LEDE system has rather good support for ClearFog Pro board. It has a special SD card image generation script to make a All-in-One image for SD card. After some tests I made, I found this image is also working in eMMC flash.

Note: The size of the SD image mainly depends on CONFIG_TARGET_ROOTFS_PARTSIZE which you can find in Target Images –> Root filesystem partition size (in MB).

You can find lede-mvebu-armada-388-clearfog-sdcard.img.gz in /bin/targets/mvebu/generic. Unzip with

gunzip lede-mvebu-armada-388-clearfog-sdcard.img.gz

On your U-Boot side, type

Marvell>> tftp lede-mvebu-armada-388-clearfog-sdcard.img
TFTP from server 192.168.112.17; our IP address is 192.168.112.65
Filename 'lede-mvebu-armada-388-clearfog-sdcard.img'.
Load address: 0x1000000
Loading: #################################################################

....

     #################################################################
     ######
     8.3 MiB/s
done
Bytes transferred = 52559872 (3220000 hex)

Note the two import numbers: Load address: 0x1000000 and Bytes transferred = 52559872. The second one indicates 52559872 / 512 = 102656 (0x19100) blocks we should copy.

5. LEDE: Flash

Type mmcinfo to get info about eMMC flash:

Marvell>> mmcinfo
Device: mv_sdh
Manufacturer ID: 15
OEM: 100
Name: 8GND3 
Tran Speed: 52000000
Rd Block Len: 512
MMC version 4.0
High Capacity: Yes
Capacity: 7.3 GiB
Bus Width: 4-bit

Switch back to the main physical partition and start flash:

Marvell>> mmc dev 0 0
Marvell>> mmc write 0x01000000 0 0x19100

This process is very fast.You can use mmc command to list all the partitions found in main physical partition of eMMC:

Marvell>> mmc part

Partition Map for MMC device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors UUID        Type
  1 4096        33280       00000083-01 83 Boot
  2 40960       131584      00000083-02 83
Marvell>> 

Finally power off your board and switch back to SD/eMMC boot mode.

Enjoy 🙂