UPDATE I have posted a new article to simplify this process.
This week I have got the ClearFog SOM with a eMMC flash on it. The serial number of this eMMC is KLM8G1GEND B031 which indicate that it comes from SAMSUNG and has 8G capacity. In this post, I will show you how to format and flash the file system in this eMMC flash. How to flash a new U-boot is alread covered in link.
Preparation
- ARMADA SoM with eMMC flash (link);
- ARMADA SBC. Here I have only ClearFog Pro;
- Plug in Ethernet cabel in slot J11;
- Plug in USB cabel in Debug port and open your serial terminal;
- Power adapter;
- OpenWRT trunk source tree from my ClearFog repo
Info about eMMC flash
After installation of this SOM in the ClearFog Pro carrier board and power on, I got infomation output from BootRom and Marvell U-boot as:
BootROM - 1.73 Booting from MMC General initialization - Version: 1.0.0 Detected Device ID 6828 High speed PHY - Version: 2.0 Init Customer board board SerDes lanes topology details: | Lane # | Speed| Type | ------------------------------| | 0 | 3 | SATA0 | | 1 | 0 | SGMII1 | | 2 | 5 | PCIe1 | | 3 | 5 | USB3 HOST1 | | 4 | 5 | PCIe2 | | 5 | 0 | SGMII2 | ------------------------------- PCIe, Idx 1: detected no link :** Link is Gen1, check the EP capability PCIe, Idx 2: remains Gen1 High speed PHY - Ended Successfully DDR3 Training Sequence - Ver TIP-1.39.0 DDR3 Training Sequence - Switching XBAR Window to FastPath Window DDR3 Training Sequence - Ended Successfully BootROM: Image checksum verification PASSED __ __ _ _ | \/ | __ _ _ ____ _____| | | | |\/| |/ _` | '__\ \ / / _ \ | | | | | | (_| | | \ V / __/ | ||_|\__,_|_| \_/ \___|_|_| _ _ ____ _ | | | | | __ ) ___ ___ | |_ | | | |___| _ \ / _ \ / _ \| __| |
|___| |_) | (_) | (_) | |_ \___/ |____/ \___/ \___/ \__| ** LOADER ** U-Boot 2013.01-g6109ead-dirty (Aug 08 2016 - 11:06:58) Marvell version: 2015_T11 Board: A38x-Customer-Board-1 SoC: MV88F6828 Rev A0 running 2 CPUs CPU: ARM Cortex A9 MPCore (Rev 1) LE CPU 0 CPU @ 1332 [MHz] L2 @ 666 [MHz] TClock @ 250 [MHz] DDR3 @ 666 [MHz] DDR3 32 Bit Width,FastPath Memory Access, DLB Enabled, ECC Disabled DRAM: 1 GiB MMC: mv_sdh: 0 sdhci_transfer_data: Error detected in status(0x408000)! PCI-e 0: Detected No Link. PCI-e 2 (IF 1 - bus 0) Root Complex Interface, Detected Link X1, GEN 1.1 USB2.0 0: Host Mode USB3.0 0: Host Mode USB3.0 1: Host Mode Map: Code: 0x3fed3000:0x3ff97d88 BSS: 0x3ffef9cc Stack: 0x3f9c2f20 Heap: 0x3f9c3000:0x3fed3000 U-Boot Environment: 0x000f0000:0x00100000 (MMC) Board configuration detected: Net: | port | Interface | PHY address | |--------|-----------|--------------| | egiga0 | RGMII | 0x00 | | egiga1 | SGMII | In-Band | | egiga2 | SGMII | In-Band | egiga0 [PRIME], egiga1, egiga2 Hit any key to stop autoboot: 0 Marvell>>
It is noted that there is a error message about sdhci_transfer_data:
sdhci_transfer_data: Error detected in status(0x408000)!
The Marvell U-Boot has support of MMC operations with
mmc - MMC sub system Usage: mmc read addr blk# cnt mmc write addr blk# cnt mmc erase blk# cnt mmc rescan mmc part - lists available partition on current mmc device mmc dev [dev] [part] - show or set current mmc device [partition] mmc list - lists available devicesmmc setdsr - set DSR register value
where the mmc rescan has the same error message above. It seems that this command can not work properly.
mmc part has no output indicating that there are no partitions in this eMMC flash.
mmc list shows
mv_sdh: 0
that there is noly one SD highspeed device existing. It also confirms that either eMMC flash or SD card can connect with ARMADA388 in this SOM.
Experiment via U-Boot
Then I started to search a way to format the eMMC flash via U-Boot. The solution is the command gpt, but this command seems not working in this U-Boot.
Experiment via OpenWRT initramfs
The final solution comming into my mind is loading an initramfs with all the necessary applications like dd, mkfs and tftp. And then formatting the eMMC flash and loading Linux kernel, device tree and file system via this Linux system in RAM.
I have made an initramfs from OpenWRT trunk for ClearFog and it is very easy to boot using following U-Boot command:
Marvell>> tftpboot openwrt-mvebu-armada-388-clearfog-initramfs Marvell>> bootm
The tftpboot and bootm will automatically download and boot the image from the default RAM address 0x0200000.
In the Linux boot message, you may find some predefined partition label:
[ 1.611557] mmc0: SDHCI controller on f10d8000.sdhci [f10d8000.sdhci] using ADMA [ 1.619094] sdhci-pltfm: SDHCI platform and OF driver helper [ 1.628439] marvell-cesa f1090000.crypto: CESA device successfully registered [ 1.636290] NET: Registered protocol family 10 [ 1.641373] NET: Registered protocol family 17 [ 1.645885] bridge: automatic filtering via arp/ip/ip6tables has been deprecated. Update your scripts to load br_netfil. [ 1.658684] Distributed Switch Architecture driver version 0.1 [ 1.664828] mdio_bus f1072004.mdio-mi: unknown revision 1, using base switch 0x1760 [ 1.672532] mvneta f1030000.ethernet eth0: [0]: detected a Marvell 88E6176 switch [ 1.714060] mmc0: MAN_BKOPS_EN bit is not set [ 1.719790] mmc0: new high speed MMC card at address 0001 [ 1.725487] mmcblk0: mmc0:0001 8GND3R 7.28 GiB [ 1.730113] mmcblk0boot0: mmc0:0001 8GND3R partition 1 4.00 MiB [ 1.736144] mmcblk0boot1: mmc0:0001 8GND3R partition 2 4.00 MiB [ 1.742167] mmcblk0rpmb: mmc0:0001 8GND3R partition 3 512 KiB
Here mmcblk0boot0, mmcblk0boot1 and mmcblk0rpmb are shown. Until now I only know the first two parts are for boot image partition. I have no idea for what is mmcblk0rpmb.
Further information is showed via fdisk -l
root@OpenWrt:/# fdisk -l Disk /dev/mmcblk0: 7.3 GiB, 7818182656 bytes, 15269888 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xca639272 Device Boot Start End Sectors Size Id Type Disk /dev/mmcblk0boot1: 4 MiB, 4194304 bytes, 8192 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mmcblk0boot0: 4 MiB, 4194304 bytes, 8192 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
This time more usefull information about mmcblk0boot0 and mmcblk0boot1 are given. After some small fdisk format tests, I found these partitions are not real partitions but only labels. They are predefined in the beginning of the eMMC flash. It is better to reserve these space for them because the U-Boot must stay at the beginning of the eMMC flash and Linux kernel may also stay in these partions in furture.
Prepare the eMMC partion
Based on the info above, the reset is simply.
(echo n; echo p; echo 1; echo 16385; echo +1000M; echo w) | fdisk /dev/mmcblk0
This command makes a 1G partition in the eMMC flash. It starts from 16385 sector following /dev/mmcblk0boot1. Then the format of this partition is done by
mkfs.ext4 /dev/mmcblk0p1
Copy the root filesystem
rsync -arl {openwrt}/{build_dir}/{target_xxx}/mvbeu-root/ -e ssh root@:/ Enjoy.