Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3

Introduction

CN913x based devices use ATF (ARM Trusted Firmware) for the first stage of booting, wrapping a secondary image such as a U-Boot.

Currently mv-ddr-marvell and atf are taken from the mainline, however, u-boot and mrvl_scp_bl2.img are still not public and must be taken from marvell SDK10, or get the binaries from SolidRun GitHub at https://github.com/SolidRun/cn913x_build.git .

Build Instructions

Fetch sources

  • Clone the ATF source tree from GitHub

git clone https://github.com/ARM-software/arm-trusted-firmware.git arm-trusted-firmware
cd arm-trusted-firmware
git checkout 00ad74c7afe67b2ffaf08300710f18d3dafebb45
  • Clone the mv-ddr-marvell source tree from GitHub

git clone https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git mv-ddr-marvell
cd mv-ddr-marvell
git checkout mv-ddr-devel
  • Clone the u-boot source tree from GitHub and applying u-boot git patches from SDK10

git clone git://git.denx.de/u-boot.git u-boot
cd u-boot
git checkout v2019.10 -b marvell
git am -3 <path-to>/git-u-boot-<version>-<release>/*.patch

It is also possible to download u-boot.bin from SolidRun GitHub, currently available for the CN913x COM Express Type 7.

Patches to support CN913x CEx7 are available on SolidRun GitHub

Compile

A cross toolchain targeting arm64 is required. Linaro provides prebuilt toolchains here; Generally though any toolchain will do. On Debian Stretch and later, the arm64 toolchain is provided by the crossbuild-essential-arm64 package.

  • Toolchain - the toolchain can be either taken from Marvell SDK10 or downloaded. Below, an example for gcc-linaro:

wget http://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/aarch64-linux-gnu/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz
tar -xvf gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu.tar.xz

export CROSS_COMPILE=[path-to-your-toolchain/]/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
  • Compile U-Boot and ATF

# 1. U-Boot
cd u-boot
# run make menuconfig to customize (optional)
make sr_cn913x_cex7_defconfig
make DEVICE_TREE=cn9132-cex7-A
# 2. ATF
cd atf-marvell
export BL33=<patch to u-boot directory>/u-boot/u-boot.bin
export SCP_BL2=<path to image>/mrvl_scp_bl2.img

cd arm-trusted-firmware/

make DEBUG=1 USE_COHERENT_MEM=0 LOG_LEVEL=20 PLAT=t9130 MV_DDR_PATH=/home/alon/work/cn913x/mv-ddr-marvell/mv_ddr-SDK-10.3.3.0-PR8/ CP_NUM=3 all fip
make -j${PARALLEL} USE_COHERENT_MEM=0 LOG_LEVEL=20 PLAT=t9130 MV_DDR_PATH=../build/mv-ddr-marvell CP_NUM=3 all fip

If everything went well there should now be a new file at arm-trusted-firmware/build/t9130/release/flash-image.bin ready for deployment.

Configure

The above flash-image.bin can be used to boot from Micro-SD, SPI and eMMC.
Please note however that the environment will always be saved on SPI flash unless it was explicitly configured differently through these configuration items:

# SPI Flash
CONFIG_ENV_IS_IN_MMC=n
CONFIG_ENV_IS_IN_SPI_FLASH=y

# eMMC boot 0
CONFIG_MVEBU_MMC_BOOT=y
CONFIG_ENV_IS_IN_MMC=y
CONFIG_ENV_IS_IN_SPI_FLASH=n
CONFIG_SYS_MMC_ENV_DEV=1
CONFIG_SYS_MMC_ENV_PART=1
  

#eMMc boot 1
CONFIG_MVEBU_MMC_BOOT=y
CONFIG_ENV_IS_IN_MMC=y
CONFIG_ENV_IS_IN_SPI_FLASH=n
CONFIG_SYS_MMC_ENV_DEV=1
CONFIG_SYS_MMC_ENV_PART=2

# microSD
CONFIG_MVEBU_MMC_BOOT=y
CONFIG_ENV_IS_IN_MMC=y
CONFIG_ENV_IS_IN_SPI_FLASH=n
CONFIG_SYS_MMC_ENV_DEV=1
CONFIG_SYS_MMC_ENV_PART=0

#Remove any other CONFIG_ENV_IS_IN_* occurrences in defconfig file

Note: Since not all of the options are exposed by menuconfig, appending them to configs/sr_cn913x_cex7_defconfig before running make sr_cn913x_cex7_defconfig is the easiest.

Deploy

From Linux

  • To microSD

First insert the target microSD into any computer running Linux and identify its canonical name in /dev, e.g. by reading through dmesg. Errors in this step will result in data loss!

The Boot ROM expects to find a bootable image at 512 bytes, 4096 times into the block device. Use dd for writing the previously compiled flash-image.bin to the designated location. In this example sdX is used as placeholder for the actual device name of your microSD on your system:

dd if=flash-image.bin of=/dev/sdX bs=512 seek=4096 conv=sync

This process will also work on the device itself, if it has already booted into Linux.

  • To eMMC data partition

Since the eMMC is soldered to the board, this procedure has to be done on the device itself after booting into a Linux system first. The process is identical to microSD except for the important detail that the Boot ROM expects to find the bootable image at the first block. This will conflict with any partition table or filesystem on this partition. Therefore using one of the dedicated boot partitions is recommended.

dd if=flash-image.bin of=/dev/sdX conv=sync
  • To eMMC boot

Since the eMMC is soldered to the board, this procedure has to be done on the device itself after booting into a Linux system first. Please note that as with the eMMC data partition, the Boot ROM expects to find the bootable image at the start of the partition without any offset.

To avoid accidents, the boot partitions are write protected by default. This protection is easy enough to turn off:

# for boot0:
echo 0 | sudo tee /sys/block/mmcblk0boot0/force_ro

# for boot1:
echo 0 | sudo tee /sys/block/mmcblk0boot1/force_ro

Now the bootable image can be written to either boot partition with dd:

# for boot0
sudo dd if=flash-image.bin of=/dev/mmcblk0boot0 conv=fsync

# for boot1
sudo dd if=flash-image.bin of=/dev/mmcblk0boot1 conv=fsync

As a last step, the eMMC has to be configured for selecting the intended boot partition. This can be done on the U-Boot console with the mmc partconfcommand, or from Linux with the mmcapplication from mmc-utils:

# from Linux:
# use boot0
mmc bootpart enable 1 0 /dev/mmcblk0
# use boot1
mmc bootpart enable 2 0 /dev/mmcblk0

# from U-Boot
# use boot0
mmc partconf 0 0 1 0
# use boot1
mmc partconf 0 0 2 0

From U-Boot

  • To SPI Flash

This step requires U-Boot running on the target device first, e.g. loaded from microSD or UART. The flash-image.bin can then be loaded from either microSD, eMMC, USB or network, and finally written to the SPI flash.
This sample covers the easiest case where flash-image.bin is available on a fat formatted partition on a USB drive:

# start USB stack
usb start
# scanning usb for storage devices... 1 Storage Device(s) found <-- indicates success

# load flash-image.bin to ram
load usb 0:1 $kernel_addr_r flash-image.bin
# u-boot will indicate how many btes were read. Make sure to verify the number!

# initialize spi flash
sf probe

# optionally erase
sf erase 0 0x800000

# finally write loaded file
sf write $kernel_addr_r 0 0x$filesize

https://github.com/SolidRun/u-boot-armada38x/blob/u-boot-2013.01-15t1-clearfog/download-serial.sh

An example is as follows -

./download-serial.sh /dev/ttyUSB0 flash-image.bin

Embedded in download-serial.sh a small C program that gets built every time the script runs and requires curses libraries.

  • No labels