Build system requirements
Before building the source code, you should setup your build environment. Our recommended host platform is Ubuntu v18.04.4 (64 bits), and you can launch the below commands to install related packages.
sudo apt-get update sudo apt-get install make binutils build-essential gcc g++ \ bash patch gzip bzip2 perl tar cpio python zlib1g-dev \ gawk ccache gettext libssl-dev libncurses5 minicom git \ bison flex device-tree-compiler gcc-arm-linux-gnueabi |
Download the latest source code
You can get the latest MOCHAbin source code from our GitHub. You can download the source code manually.
- checkout Marvell firmware
git clone https://github.com/globalscaletechnologies/binaries-marvell.git -b binaries-marvell-armada-18.12 |
- checkout atf-marvell
git clone https://github.com/globalscaletechnologies/atf-marvell.git -b atf-v1.5-armada-18.12-gti |
- checkout mv-ddr-marvell
git clone https://github.com/globalscaletechnologies/mv-ddr-marvell.git -b mv_ddr-armada-18.12-gti |
- checkout u-boot-marvell
git clone https://github.com/globalscaletechnologies/u-boot-marvell.git -b u-boot-2018.03-armada-18.12-gti |
- checkout linux-v5.4.163
git clone https://github.com/globalscaletechnologies/linux.git -b linux-5.4.163-gti |
Get the cross-compiler
For MOCHAbin, we use linaro-7.3.1 (aarch64) toolchain, you can download the toolchain from linaro website.
mkdir toolchain tar -xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C toolchain/ rm gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz |
Build the bootloader
After install all related software packages, we can start to build the source code, you can follow below steps to build the bootloader image.
setup environment variables
# Set the cross compiler export CROSS_COMPILE=/path/to/toolchain/aarch64-linux-gnu- # Set path for MV_DDR component export MV_DDR_PATH=path/to/mv_ddr_marvell # Set U-Boot image path export BL33=path/to/u-boot.bin # Set Firmware (binaries-marvell) path export SCP_BL2=path/to/binaries-marvell/mrvl_scp_bl2.img |
build u-boot
The u-boot image need to build first before you start build the ATF image, so let us to build it first.
For MOCHAbin platform, the setting file as below
Device Tree : /arch/arm/dts/armada-7040-mochabin
Defconfig : /configs/gti_mochabin-88f7040_defconfig
make -C gti_mochabin-88f7040_defconfig make -C DEVICE_TREE=armada-7040-mochabin |
build ATF
The ATF has many parameter need to configure, below are major parameters
- DEBUG : debug information enable or not.
- DDR_TOPOLOGY : for MOCHAbin board, we have some different DDR size models,
0: 1cs-4g / 1: 2cs-8g / 2: 1cs-2g - PLAT: platform name
For MOCHAbin platform, the default build command as below
# build for 4GB DDR make -C DEBUG=0 USE_COHERENT_MEM=0 LOG_LEVEL=10 SECURE=0 PLAT=a70x0_mochabin DDR_TOPOLOGY=0 all fip # build for 8GB DDR make -C DEBUG=0 USE_COHERENT_MEM=0 LOG_LEVEL=10 SECURE=0 PLAT=a70x0_mochabin DDR_TOPOLOGY=1 all fip # build for 2GB DDR make -C DEBUG=0 USE_COHERENT_MEM=0 LOG_LEVEL=10 SECURE=0 PLAT=a70x0_mochabin DDR_TOPOLOGY=2 all fip |
The final image is output to
- For non-debug build
/build/a70x0_mochabin/release/flash-image.bin - For debug enabled build
/build/a70x0_mochabin/debug/flash-image.bin
Build the kernel
The current MOCHAbin kernel is based on Linux longterm support version (v5.4).
For MOCHAbin platform, the setting file as below
Device Tree : /arch/arm64/boot/dts/marvell/armada-7040-mochabin.dts
Defconfig : /arch/arm64/configs/gti_generic_mvebu_defconfig
The default build command as below
# build kernel and modules image make -C gti_generic_mvebu_defconfig make -C -j4 # install modules to target path make -C modules_install INSTALL_MOD_PATH= |
Build image with gti build script file
We also provided a build script to build MOCHAbin image. When you use ‘repo sync’ to batch download source code, it also checkout a build script “env-mochabin.sh”.
If you download the source manually, not using ‘repo sync’, you also can flow below steps to download the build script.
git clone https://github.com/globalscaletechnologies/build.git -b mochabin ln -s build/mochabin/env-setup.sh env-mochabin.sh |
Now you can execute the below commands to build the bootloader and kernel image.
source env-mochabin.sh # build bootloader image gtibuild bootloader # build linux kernel and modules image gtibuild kernel # build bootloader & kernel gtibuild all |
The final output image is output to ./out/build-/
Update bootloader image
You can follow the below steps to update the MOCHAbin bootloader image.
- Copy /build/a70x0_mochabin/release/flash-image.bin to USB disk and insert USB disk to MOCHAbin. If you use gti build script to build bootloader image, you can find the bootloader image under ./out/build-/a70x0_mochabin-bootloader-*-dbg.bin.
- Power on the device and press any key on UART debug console during booting
- execute “bubt flash-image.bin spi usb” to update u-boot image
- reset the device to load new bootloader image
Update Ubuntu rootfs image
We provided a prebuilt Ubuntu 18.04 rootfs for MOCHAbin, you can download the prebuilt image from our official website. In our official image included a ramdisk with an updated script, the user can boot into the ramdisk and use this script (mkemmc.sh) to partition / format / install the rootfs to the eMMC disk.
You can follow the below steps to update your device.
- download our prebuilt image from our official website
- prepare a USB disk and format it to FAT/FAT32 filesystem.
- copy all files under the recovery folder to USB disk.
- copy all files under the bootloader and rootfs to USB disk.
- insert USB disk to MOCHAbin board and then power on the device.
- press any key on UART debug console during booting to enter the u-boot console.
- run the below command on the u-boot console to update the bootloader, the image must fit your device hardware model and memory size. If you don’t want to update the bootloader, you can ignore this step.
bubt a70x0_mochabin-bootloader-ddr4-8g--rel.bin spi usb |
- run below command to load ramdisk image and boot it
usb reset; fatload usb 0 $loadaddr recovery.bin; source $loadaddr |
- when device boot into the system, run below commands to install MOCHAbin rootfs image to eMMC.
mount /dev/sda1 /media /root/mkemmc.sh /media/mochabin-rootfs-ubuntu1804-.tar.gz |
- after update completed, reboot the system and enter u-boot console again.
- run below command to setup the device boot from eMMC.
env default -a setenv image_name boot/Image setenv fdt_name boot/armada-7040-mochabin.dtb setenv bootcmd 'mmc dev 0; ext4load mmc 0:1 $kernel_addr_r $image_name;ext4load mmc 0:1 $fdt_addr_r $fdt_name;setenv bootargs $console root=PARTUUID=89708921-01 rw rootwait net.ifnames=0 biosdevname=0; booti $kernel_addr_r - $fdt_addr_r' saveenv boot |