LEC-MTK-1200 Ubuntu Build Guide


Overview

This guide provides step-by-step instructions for deploying Ubuntu Desktop on LEC-MTK-1200. Since MediaTek provides Ubuntu images only for their official EVK (Evaluation Kit) through their partnership with Canonical, ADLINK LEC-MTK-1200 requires a hybrid approach: booting with the EVK Ubuntu image and then replacing firmware components with custom-built binaries from Yocto.

Prerequisites

Hardware Requirements

  • I-Pi SMARC 1200 development kit(Carrier, Module and etc.)
  • Host PC running Ubuntu OS
  • Stable internet connection for downloading images and flashing tools

Software Requirements

  • Yocto build environment configured for LECM-MTK-1200.

1. Building Custom Firmware with Yocto

1.1 Configure Yocto Build Environment

Follow this build guide for building Yocto for LEC-MTK-1200.

1.2 Modify Yocto Configuration

Add the below line to your conf/local.conf file to generate Debian packages.

# Added to support Debian packages
PACKAGE_CLASSES = "package_deb"

1.3 Build Yocto Image

Execute the Yocto build process. Once the build is completed, locate the build output directory

build-directory/tmp/deploy/images/<MACHINE\>/

For reference purposes, we'll call this directory {BOOT_FIRMWARE}.

1.4 Verify Required Firmware Files

Ensure the following binary files are present in the build output:

  • bl2.img

  • bootassets.vfat

  • fip.bin

  • lk.bin

  • u-boot-initial-env

  • firmware.vfat

  • partition.xml

2. Preparing the Ubuntu Base Image

2.1 Download MTK Genio Ubuntu Image

Download the Ubuntu base image from ADLINK server by clicking_here.

2.2 Copy the Downloaded Ubuntu Image

Create a new directory called UBUNTU_IMAGE, navigate into it, and copy the downloaded Ubuntu image into the directory

mkdir UBUNTU_IMAGE
cd UBUNTU_IMAGE/
cp <path_to_downloaded_Ubuntu_image>/ubuntu.img .

2.3 Integrate Custom Firmware

Copy the previously Yocto built firmware files into the Ubuntu image directory:

cp {BOOT_FIRMWARE}/bl2.img {BOOT_FIRMWARE}/bootassets.vfat {BOOT_FIRMWARE}/fip.bin {BOOT_FIRMWARE}/lk.bin {BOOT_FIRMWARE}/u-boot-initial-env {BOOT_FIRMWARE}/firmware.vfat {BOOT_FIRMWARE}/partition.xml {UBUNTU_IMAGE}/

2.4 Modify Environment and JSON File

Modify the environment configuration file (u-boot-initial-env) by updating specific boot parameters and command.

diff --git a/u-boot-initial-env b/u-boot-initial-env
index 126607f..8849782 100644
--- a/u-boot-initial-env
+++ b/u-boot-initial-env
-boot_net_usb_start=usb start
-boot_targets=embedded
+boot_targets=scsi2
-bootcmd_embedded=bootembedded
-bootcmd_usb0=devnum=0; run usb_boot
-distro_bootcmd=scsi_need_init=; for target in ${boot_targets}; do run bootcmd_${target}; done
-efi_dtb_prefixes=/ /dtb/ /dtb/current/
+distro_bootcmd=scsi_need_init=; for target in ${boot_targets}; do if test "${target}" != "embedded"; then dtbprobe ${storage} ${storage_dev} /FIRMWARE/mediatek/lec-mtk-i1200-ufs/; fi; run bootcmd_${target}; done
+
+fdt_resize=10240
-load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
+load_efi_dtb=load ${devtype} ${devnum}:3 ${fdt_addr_r} /FIRMWARE/mediatek/lec-mtk-i1200-ufs/${fdtfile}
-scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;run boot_efi_bootmgr;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootaa64.efi; then echo Found EFI removable media binary efi/boot/bootaa64.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
+scan_dev_for_efi=setenv efi_fdtfile ${fdtfile};run load_efi_dtb;run boot_efi_bootmgr;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootaa64.efi; then echo Found EFI removable media binary efi/boot/bootaa64.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
-dtb_path=/FIRMWARE/mediatek/lec-mtk-i1200-ufs/
-efi_dtb_prefixes=${dtb_path} / /dtb/ /dtb/current/
-boot_targets=embedded
-distro_bootcmd=for target in ${boot_targets}; do if test "${target}" != "embedded"; then dtbprobe ${storage} ${storage_dev} ${dtb_path}; fi; run bootcmd_${target}; done
-scan_dev_for_efi=run boot_efi_bootmgr;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootaa64.efi; then echo Found EFI removable media binary efi/boot/bootaa64.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi

You will also need to configure the ubuntu.json file to handle partitioning, environment variables, and bootloader settings.

  • In the working directory, create a new file named ubuntu.json

    touch {UBUNTU_IMAGE}/ubuntu.json
  • Open the ubuntu.json file and add the following JSON configuration:

    {
    "ubuntu-env": {
    "edition": "Ubuntu classic/core images",
    "codename": "jammy",
    "version": "22.04"
    },
    "uboot-env": {
    "env-redund-support": false
    },
    "genio-tools": {
    "min-version": "1.3.dev2"
    },
    "partitions": {
    "mmc0": "ubuntu.img",
    "mmc0boot0": "bl2.img",
    "mmc0boot1": "u-boot-env.bin",
    "bootloaders": "fip.bin",
    "bootloaders_b": "fip.bin",
    "firmware": "firmware.vfat",
    "firmware_b": "firmware.vfat",
    "dramk": null,
    "misc": null,
    "capsule": "capsule.vfat",
    "bootassets": "bootassets.vfat"
    },
    "groups": {
    "all": {
    "erase": [
    "mmc0",
    "mmc0boot0",
    "mmc0boot1",
    "bootloaders",
    "bootloaders_b",
    "firmware",
    "firmware_b",
    "bootassets"
    ],
    "flash": [
    "mmc0",
    "mmc0boot0",
    "mmc0boot1",
    "bootloaders",
    "bootloaders_b",
    "firmware",
    "firmware_b",
    "bootassets"
    ]
    },
    "bootloaders": {
    "flash": ["bootloaders"]
    },
    "erase-emmc": {
    "erase": ["mmc0", "mmc0boot0", "mmc0boot1"]
    },
    "board-assets": {
    "flash": [
    "mmc0boot0",
    "mmc0boot1",
    "bootloaders",
    "bootloaders_b",
    "firmware",
    "firmware_b",
    "bootassets"
    ]
    }
    }
    }

2.5 Verify Image Directory Contents

The resulting directory should contain at minimum:

$ls
bl2.img
bootassets.vfat
fip.bin
firmware.vfat
lk.bin
u-boot-initial-env
ubuntu.img
ubuntu.json
partition.xml

3. Flashing the Image

3.1 Flash to Module

Install genio-tool and Dependencies.

Install genio-tool and its dependencies. This is used to flash Ubuntu images to the LEC-MTK-1200.

# pip3 >= 20.3 is required for genio-tools, but the latest version in focal-update is 20.0.2
# Upgrade pip by pip command and remove pip deb packages

pip3 install --upgrade pip
sudo apt-get remove python3-pip python-pip-whl
sudo apt update

# Install fastboot
sudo apt install fastboot

# Install the latest genio-tools
pip3 install -U genio-tools

Configure udev Rules and User Permissions.

Add a new udev rule and add your user account to the plugdev group:

echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="0e8d", ATTR{idProduct}=="201c", MODE="0660", GROUP="plugdev"' | sudo tee -a /etc/udev/rules.d/96-genio-board.rules

sudo udevadm control --reload-rules
sudo udevadm trigger
sudo usermod -a -G plugdev $USER

Note: The usermod command requires you to logout and login again with your account to make it effective. You only have to do this once.

Depending on your Ubuntu version you may also need to run the following command:

sudo usermod -a -G dialout \$USER

Navigate to the image directory and flash the Image

cd {UBUNTU_IMAGE}/

Power on the target device and connect the micro USB port on the target to the USB port on the host device using a USB cable. Then, execute the following command to flash the image onto the UFS:

genio-flash

Now, the host device is ready to find the target device as a fastboot device. Press the reset key on the target device to make it a fastboot device. Once the target device is detected as a fastboot device, it will automatically start to flash the Ubuntu image.


4. Post-Boot Configuration

After successfully booting the module with the flashed Ubuntu image, additional configuration is required to install our Yocto built kernel and dependencies.

4.1 Installing Kernel Image

Once the system is ready, use the following credentials to log in for the first time:

  • Username: ubuntu

  • Password: ubuntu

Locate Kernel Image in Yocto Build

On your host PC, the kernel image is located at:

build-directory/tmp/work/<MACHINE>-poky-linux/linux-mtk/<kernel_version>/linux-<machine>-standard-build/arch/arm64/boot/Image

Transfer Kernel to Module

Use SCP or a USB drive to copy the kernel image to the module:

scp Image ubuntu@<module-ip>:/tmp/

Replace Kernel Image

On the module, Enter the following command:

sudo cp /tmp/Image /boot/vmlinuz-5.15.42-lec-mtki1200-23.2

4.2 Update GRUB Configuration

Execute the following commands on the module to update GRUB bootloader:

# Update GRUB
sudo update-grub

sudo su

# Set kernel version
kernelver=5.15.42-lec-mtki1200-23.2

# Get menu ID for Ubuntu advanced options
MID=$(awk '/Advanced options for Ubuntu/{print $(NF-1)}' /boot/grub/grub.cfg | cut -d\' -f2)

# Generate kernel-specific ID
KID=$(echo "$MID" | sed -r "s/gnulinux/gnulinux-$kernelver/g")

# Configure GRUB to save default entry
cat > /etc/default/grub.d/95-savedef.cfg <<EOF
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
EOF

# Set the saved entry to boot custom kernel
grub-editenv /boot/grub/grubenv set saved_entry="${MID}>${KID}"

4.3 Installing Dependency Packages

Locate Deb Packages

On your host PC, find the generated kernel Deb packages (kernel-* & linux-mkt-src*).

build-directory/tmp/work/<machine>-poky-linux/rity-demo-image/1.0/oe-rootfs-repo/<machine>/

Transfer Packages to Module

Copy all .deb files to the module using SCP or USB drive.

Clean Unnecessary Packages

Remove debug and unnecessary kernel packages.

rm kernel-vmlinux* kernel-dbg* kernel-devicetree* kernel-image*

Install Packages

Install all remaining Debian packages

dpkg -i *.deb

4.4 Finalize Installation

Reboot the module to boot with the updated kernel and packages.

sudo reboot

5. Verification

After successful installation and reboot, verify it using following commands:

# Check kernel version
uname -r

# Verify loaded kernel matches custom build
cat /proc/version

# Check loaded modules
lsmod