LEC-MTK-1200 Ubuntu Build Guide OverviewThis 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. PrerequisitesHardware 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 Yocto1.1 Configure Yocto Build EnvironmentFollow this build guide for building Yocto for LEC-MTK-1200. 1.2 Modify Yocto ConfigurationAdd the below line to your conf/local.conf file to generate Debian packages. # Added to support Debian packagesPACKAGE_CLASSES = "package_deb" 1.3 Build Yocto ImageExecute 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 FilesEnsure 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 Image2.1 Download MTK Genio Ubuntu ImageDownload the Ubuntu base image from ADLINK server by clicking_here. 2.2 Copy the Downloaded Ubuntu ImageCreate a new directory called UBUNTU_IMAGE, navigate into it, and copy the downloaded Ubuntu image into the directory mkdir UBUNTU_IMAGEcd UBUNTU_IMAGE/cp <path_to_downloaded_Ubuntu_image>/ubuntu.img . 2.3 Integrate Custom FirmwareCopy 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 FileModify 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-envindex 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 ContentsThe resulting directory should contain at minimum: $lsbl2.imgbootassets.vfatfip.binfirmware.vfatlk.binu-boot-initial-envubuntu.imgubuntu.jsonpartition.xml 3. Flashing the Image3.1 Flash to ModuleInstall 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 packagespip3 install --upgrade pipsudo apt-get remove python3-pip python-pip-whlsudo apt update# Install fastbootsudo apt install fastboot# Install the latest genio-toolspip3 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.rulessudo udevadm control --reload-rulessudo udevadm triggersudo 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 ConfigurationAfter 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 ImageOnce the system is ready, use the following credentials to log in for the first time: Username: ubuntu Password: ubuntu Locate Kernel Image in Yocto BuildOn 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 ModuleUse SCP or a USB drive to copy the kernel image to the module: scp Image ubuntu@<module-ip>:/tmp/ Replace Kernel ImageOn the module, Enter the following command: sudo cp /tmp/Image /boot/vmlinuz-5.15.42-lec-mtki1200-23.2 4.2 Update GRUB ConfigurationExecute the following commands on the module to update GRUB bootloader: # Update GRUBsudo update-grubsudo su# Set kernel versionkernelver=5.15.42-lec-mtki1200-23.2# Get menu ID for Ubuntu advanced optionsMID=$(awk '/Advanced options for Ubuntu/{print $(NF-1)}' /boot/grub/grub.cfg | cut -d\' -f2)# Generate kernel-specific IDKID=$(echo "$MID" | sed -r "s/gnulinux/gnulinux-$kernelver/g")# Configure GRUB to save default entrycat > /etc/default/grub.d/95-savedef.cfg <<EOFGRUB_DEFAULT=savedGRUB_SAVEDEFAULT=trueEOF# Set the saved entry to boot custom kernelgrub-editenv /boot/grub/grubenv set saved_entry="${MID}>${KID}" 4.3 Installing Dependency PackagesLocate Deb PackagesOn 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 ModuleCopy all .deb files to the module using SCP or USB drive. Clean Unnecessary PackagesRemove debug and unnecessary kernel packages. rm kernel-vmlinux* kernel-dbg* kernel-devicetree* kernel-image* Install PackagesInstall all remaining Debian packages dpkg -i *.deb 4.4 Finalize InstallationReboot the module to boot with the updated kernel and packages. sudo reboot 5. VerificationAfter successful installation and reboot, verify it using following commands: # Check kernel versionuname -r# Verify loaded kernel matches custom buildcat /proc/version# Check loaded moduleslsmod