From ad923ea232ca60c999b9cc94faccc3b14c2fe3e0 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Tue, 26 Dec 2023 10:28:15 +0800
Subject: [PATCH] Update meta-igkboard to add igkboard-imx6ull support

---
 yocto/meta-igkboard/recipes-bsp/u-boot/uenv_1.0.bb                            |   29 +++++
 yocto/meta-igkboard/tools/igkboard-setup.sh                                   |    4 
 yocto/meta-igkboard/recipes-qt/packagegroups/packagegroup-qt6-addons.bbappend |   12 ++
 yocto/meta-igkboard/conf/machine/igkboard-imx8mp.conf                         |   43 ++++----
 yocto/meta-igkboard/recipes-bsp/u-boot/files/uboot-logo-igkboard-imx8mp.bmp   |    0 
 yocto/meta-igkboard/conf/igkboard-imx8mp_local.conf                           |    0 
 yocto/meta-igkboard/recipes-bsp/u-boot/u-boot-imx_%.bbappend                  |   22 ---
 yocto/meta-igkboard/recipes-bsp/u-boot/files/uboot-logo-igkboard-imx6ull.bmp  |    0 
 yocto/meta-igkboard/recipes-kernel/linux/linux-imx_%.bbappend                 |   32 ++++++
 yocto/meta-igkboard/recipes-bsp/u-boot/files/config-igkboard-imx6ull.txt      |   29 +++++
 yocto/meta-igkboard/conf/machine/igkboard-imx6ull.conf                        |   58 +++++++++++
 yocto/meta-igkboard/conf/igkboard-imx6ull_local.conf                          |   24 ++++
 yocto/meta-igkboard/recipes-bsp/u-boot/files/config-igkboard-imx8mp.txt       |   29 +++++
 13 files changed, 239 insertions(+), 43 deletions(-)

diff --git a/yocto/meta-igkboard/conf/igkboard-imx6ull_local.conf b/yocto/meta-igkboard/conf/igkboard-imx6ull_local.conf
new file mode 100644
index 0000000..2a1cc00
--- /dev/null
+++ b/yocto/meta-igkboard/conf/igkboard-imx6ull_local.conf
@@ -0,0 +1,24 @@
+MACHINE ??= 'igkboard-imx6ull'
+DISTRO ?= 'fsl-imx-wayland'
+PACKAGE_CLASSES ?= 'package_deb'
+EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
+USER_CLASSES ?= "buildstats"
+PATCHRESOLVE = "noop"
+BB_DISKMON_DIRS ??= "\
+    STOPTASKS,${TMPDIR},1G,100K \
+    STOPTASKS,${DL_DIR},1G,100K \
+    STOPTASKS,${SSTATE_DIR},1G,100K \
+    STOPTASKS,/tmp,100M,100K \
+    ABORT,${TMPDIR},100M,1K \
+    ABORT,${DL_DIR},100M,1K \
+    ABORT,${SSTATE_DIR},100M,1K \
+    ABORT,/tmp,10M,1K"
+PACKAGECONFIG:append_pn-qemu-system-native = " sdl"
+CONF_VERSION = "2"
+
+#DL_DIR ?= "${HOME}/oe-sources-yocto/"
+ACCEPT_FSL_EULA = "1"
+
+# Switch to Debian packaging and include package-management in the image
+PACKAGE_CLASSES = "package_deb"
+EXTRA_IMAGE_FEATURES += "package-management"
diff --git a/yocto/meta-igkboard/conf/local.conf b/yocto/meta-igkboard/conf/igkboard-imx8mp_local.conf
similarity index 100%
rename from yocto/meta-igkboard/conf/local.conf
rename to yocto/meta-igkboard/conf/igkboard-imx8mp_local.conf
diff --git a/yocto/meta-igkboard/conf/machine/igkboard-imx6ull.conf b/yocto/meta-igkboard/conf/machine/igkboard-imx6ull.conf
new file mode 100644
index 0000000..1dc54d3
--- /dev/null
+++ b/yocto/meta-igkboard/conf/machine/igkboard-imx6ull.conf
@@ -0,0 +1,58 @@
+#@TYPE       : Machine
+#@NAME       : LingYun IoT Gatway Kits Boards based on i.MX6ULL
+#@SOC        : i.MX6ULL
+#@DESCRIPTION: Machine configuration for LingYun IGKBoard-IMX6ULL
+#@MAINTAINER : Wenxue Guo <guowenxue@gmail.com>
+#@REFERENCE  : meta-imx/meta-bsp/conf/machine/imx6ull9x9evk.conf
+
+# Add new machine igkboard-imx6ull
+MACHINEOVERRIDES =. "mx6:mx6ul:mx6ull:igkboardbase:igkboard-imx6ull"
+
+include conf/machine/include/imx-base.inc
+include conf/machine/include/arm/armv7a/tune-cortexa7.inc
+
+# Device tree file generated during kernel compilation
+KERNEL_DEVICETREE = "${MACHINE}.dtb"
+
+# Device tree overlay files generated during kernel compilation
+KERNEL_DTOVERLAY = " \
+    ${MACHINE}/adc.dtbo \
+    ${MACHINE}/cam.dtbo \
+    ${MACHINE}/can1.dtbo \
+    ${MACHINE}/can2.dtbo \
+    ${MACHINE}/i2c1.dtbo \
+    ${MACHINE}/lcd.dtbo \
+    ${MACHINE}/nbiot-4g.dtbo \
+    ${MACHINE}/pwm7.dtbo \
+    ${MACHINE}/pwm8.dtbo \
+    ${MACHINE}/spi1.dtbo \
+    ${MACHINE}/uart2.dtbo \
+    ${MACHINE}/uart3.dtbo \
+    ${MACHINE}/uart4.dtbo \
+    ${MACHINE}/uart7.dtbo \
+    ${MACHINE}/w1.dtbo \
+"
+
+# Uboot configuration
+UBOOT_CONFIG ??= "sd"
+UBOOT_CONFIG[sd] = "${MACHINE}_defconfig,sdcard"
+
+# Add wic image in deploy folder
+SOC_DEFAULT_IMAGE_FSTYPES:append = " wic"
+
+# Define the kernel boot file
+WKS_FILE_DEPENDS:append = " uenv"
+IMAGE_BOOT_FILES = " \
+    ${KERNEL_IMAGETYPE} \
+    ${KERNEL_DEVICETREE} \
+    overlays/*;overlays/ \
+    config.txt \
+"
+# Remove unused optee bcm4339 bcm43455
+MACHINE_FEATURES += "wifi bluetooth"
+
+# Refer to linux-imx/drivers/tty/serial/imx.c
+SERIAL_CONSOLES = "115200;ttymxc0"
+
+# /etc/hostname (uname -a)
+hostname:pn-base-files = "igkboard"
diff --git a/yocto/meta-igkboard/conf/machine/igkboard-imx8mp.conf b/yocto/meta-igkboard/conf/machine/igkboard-imx8mp.conf
index fec84b0..c581a46 100644
--- a/yocto/meta-igkboard/conf/machine/igkboard-imx8mp.conf
+++ b/yocto/meta-igkboard/conf/machine/igkboard-imx8mp.conf
@@ -1,18 +1,32 @@
-#@TYPE: Machine
-#@NAME: IoT Gatway Kits Boards based on i.MX8M Plus
-#@SOC: i.MX8M Plus
+#@TYPE       : Machine
+#@NAME       : LingYun IoT Gatway Kits Boards based on i.MX8M Plus
+#@SOC        : i.MX8M Plus
 #@DESCRIPTION: Machine configuration for LingYun IGKBoard-IMX8MP 2GB LPDDR4, 8GB eMMC
-#@MAINTAINER: Wenxue Guo <guowenxue@gmail.com>
-#@REFERENCE: meta-freescale/conf/machine/imx8mp-lpddr4-evk.conf
+#@MAINTAINER : Wenxue Guo <guowenxue@gmail.com>
+#@REFERENCE  : meta-freescale/conf/machine/imx8mp-lpddr4-evk.conf
 
-MACHINEOVERRIDES =. "mx8:mx8m:mx8mp:"
-MACHINEOVERRIDES =. "igkboardbase:igkboard-imx8mp:"
+# Add new machine igkboard-imx8mp
+MACHINEOVERRIDES =. "mx8:mx8m:mx8mp:igkboardbase:igkboard-imx8mp:"
 
 require conf/machine/include/imx-base.inc
 require conf/machine/include/arm/armv8a/tune-cortexa53.inc
 
 MACHINE_FEATURES:append = " wifi bluetooth ppp "
 MACHINE_FEATURES:remove = " nxp8801-sdio nxp8987-sdio nxp8997-pcie nxp8997-sdio nxp9098-pcie nxp9098-sdio nxpiw416-sdio nxpiw612-sdio qemu-usermode "
+
+# linux kernel images
+KERNEL_DEVICETREE = "freescale/${MACHINE}.dtb"
+KERNEL_IMAGETYPE = "Image"
+
+# Uboot configuration
+UBOOT_DTB_NAME = "${MACHINE}.dtb"
+LOADADDR = ""
+UBOOT_SUFFIX = "bin"
+UBOOT_MAKE_TARGET = ""
+SPL_BINARY = "spl/u-boot-spl.bin"
+UBOOT_CONFIG ??= "sd"
+UBOOT_CONFIG[sd] = "${MACHINE}_defconfig,sdcard"
+SERIAL_CONSOLES = "115200;ttymxc1"
 
 # Set DDR FIRMWARE, Refer to:
 # meta-imx/meta-bsp/recipes-bsp/imx-mkimage/imx-boot_*.bb
@@ -25,20 +39,6 @@
     lpddr4_pmu_train_2d_imem_${DDR_FIRMWARE_VERSION}.bin \
 "
 
-# Set linux DTB
-KERNEL_DEVICETREE = "freescale/igkboard-imx8mp.dtb"
-KERNEL_IMAGETYPE = "Image"
-
-# Set u-boot DTB
-UBOOT_DTB_NAME = "igkboard-imx8mp.dtb"
-LOADADDR = ""
-UBOOT_SUFFIX = "bin"
-UBOOT_MAKE_TARGET = ""
-SPL_BINARY = "spl/u-boot-spl.bin"
-UBOOT_CONFIG ??= "sd"
-UBOOT_CONFIG[sd] = "igkboard-imx8mp_defconfig,sdcard"
-SERIAL_CONSOLES = "115200;ttymxc1"
-
 # Set ATF platform name
 ATF_PLATFORM = "imx8mp"
 
@@ -48,6 +48,7 @@
 IMX_BOOT_SEEK = "32"
 OPTEE_BIN_EXT = "8mp"
 
+# Add wic image in deploy folder
 SOC_DEFAULT_IMAGE_FSTYPES:append = " wic"
 
 # Boot partition size [in KiB] for kernel and other data
diff --git a/yocto/meta-igkboard/recipes-bsp/u-boot/files/config-igkboard-imx6ull.txt b/yocto/meta-igkboard/recipes-bsp/u-boot/files/config-igkboard-imx6ull.txt
new file mode 100644
index 0000000..d23b6fd
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-bsp/u-boot/files/config-igkboard-imx6ull.txt
@@ -0,0 +1,29 @@
+# Enable LCD overlay
+#dtoverlay_lcd=yes
+
+# Enable Camera overlay
+#dtoverlay_cam=yes
+
+# Eanble 1-Wire overlay
+#dtoverlay_w1=yes
+
+# Enable ADC overlay
+#dtoverlay_adc=yes
+
+# Enable I2C overlay
+#dtoverlay_i2c=1
+
+# Enable SPI overlay, SPI1 conflict with UART8(NB-IoT/4G module)
+#dtoverlay_spi=1
+
+# Enable UART overlays
+#dtoverlay_uart=2 3 4 7
+
+# Enable CAN overlays
+#dtoverlay_can=1 2
+
+# Enable PWM overlays, PWM8 conflict with UART8(NB-IoT/4G module)
+#dtoverlay_pwm=7
+
+# Enable extra overlays
+#dtoverlay_extra=nbiot-4g
diff --git a/yocto/meta-igkboard/recipes-bsp/u-boot/files/config-igkboard-imx8mp.txt b/yocto/meta-igkboard/recipes-bsp/u-boot/files/config-igkboard-imx8mp.txt
new file mode 100644
index 0000000..d23b6fd
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-bsp/u-boot/files/config-igkboard-imx8mp.txt
@@ -0,0 +1,29 @@
+# Enable LCD overlay
+#dtoverlay_lcd=yes
+
+# Enable Camera overlay
+#dtoverlay_cam=yes
+
+# Eanble 1-Wire overlay
+#dtoverlay_w1=yes
+
+# Enable ADC overlay
+#dtoverlay_adc=yes
+
+# Enable I2C overlay
+#dtoverlay_i2c=1
+
+# Enable SPI overlay, SPI1 conflict with UART8(NB-IoT/4G module)
+#dtoverlay_spi=1
+
+# Enable UART overlays
+#dtoverlay_uart=2 3 4 7
+
+# Enable CAN overlays
+#dtoverlay_can=1 2
+
+# Enable PWM overlays, PWM8 conflict with UART8(NB-IoT/4G module)
+#dtoverlay_pwm=7
+
+# Enable extra overlays
+#dtoverlay_extra=nbiot-4g
diff --git a/yocto/meta-igkboard/recipes-bsp/u-boot/files/uboot-logo-igkboard-imx6ull.bmp b/yocto/meta-igkboard/recipes-bsp/u-boot/files/uboot-logo-igkboard-imx6ull.bmp
new file mode 100644
index 0000000..ef087b6
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-bsp/u-boot/files/uboot-logo-igkboard-imx6ull.bmp
Binary files differ
diff --git a/yocto/meta-igkboard/recipes-bsp/u-boot/files/uboot-logo-igkboard-imx8mp.bmp b/yocto/meta-igkboard/recipes-bsp/u-boot/files/uboot-logo-igkboard-imx8mp.bmp
new file mode 100644
index 0000000..ef087b6
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-bsp/u-boot/files/uboot-logo-igkboard-imx8mp.bmp
Binary files differ
diff --git a/yocto/meta-igkboard/recipes-bsp/u-boot/u-boot-imx_%.bbappend b/yocto/meta-igkboard/recipes-bsp/u-boot/u-boot-imx_%.bbappend
index 344a567..9675d97 100644
--- a/yocto/meta-igkboard/recipes-bsp/u-boot/u-boot-imx_%.bbappend
+++ b/yocto/meta-igkboard/recipes-bsp/u-boot/u-boot-imx_%.bbappend
@@ -1,23 +1,7 @@
 FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
 SRC_URI:append = " file://uboot-imx-lf-6.1.36-2.1.0.patch "
 
-do_deploy:append:igkboardbase() {
-    # Deploy u-boot-nodtb.bin and fsl-imx8m*-XX.dtb for mkimage to generate boot binary
-    if [ -n "${UBOOT_CONFIG}" ]
-    then
-        for config in ${UBOOT_MACHINE}; do
-            i=$(expr $i + 1);
-            for type in ${UBOOT_CONFIG}; do
-                j=$(expr $j + 1);
-                if [ $j -eq $i ]
-                then
-                    install -d ${DEPLOYDIR}/${BOOT_TOOLS}
-                    install -m 0777 ${B}/${config}/arch/arm/dts/${UBOOT_DTB_NAME}  ${DEPLOYDIR}/${BOOT_TOOLS}
-                    install -m 0777 ${B}/${config}/u-boot-nodtb.bin  ${DEPLOYDIR}/${BOOT_TOOLS}/u-boot-nodtb.bin-${MACHINE}-${type}
-                fi
-            done
-            unset  j
-        done
-        unset  i
-    fi
+addtask copy_logo after do_unpack before do_configure
+do_copy_logo(){
+    cp ${BSPDIR}/sources/meta-igkboard/recipes-bsp/u-boot/files/uboot-logo-${MACHINE}.bmp ${S}/tools/logos/lingyun.bmp
 }
diff --git a/yocto/meta-igkboard/recipes-bsp/u-boot/uenv_1.0.bb b/yocto/meta-igkboard/recipes-bsp/u-boot/uenv_1.0.bb
new file mode 100644
index 0000000..b632d6c
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-bsp/u-boot/uenv_1.0.bb
@@ -0,0 +1,29 @@
+DESCRIPTION = "U-boot Env from config.txt"
+SECTION = "app"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
+
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+FILES:${PN} = "/boot"
+
+S = "${WORKDIR}"
+
+SRC_URI = " " 
+SRC_URI = " \ 
+    file://config-${MACHINE}.txt \
+"
+
+do_install() {
+    install -d ${D}/boot
+    install -m 0644 ${S}/config-${MACHINE}.txt ${D}/boot/config.txt
+}
+
+inherit deploy
+addtask deploy after do_install
+
+do_deploy () {
+    install -m 0644 ${D}/boot/config.txt ${DEPLOYDIR}
+}
+
+COMPATIBLE_MACHINE = "(igkboardbase)"
+PACKAGE_ARCH = "${MACHINE_ARCH}"
diff --git a/yocto/meta-igkboard/recipes-kernel/linux/linux-imx_%.bbappend b/yocto/meta-igkboard/recipes-kernel/linux/linux-imx_%.bbappend
index baa4abe..df6ddf9 100644
--- a/yocto/meta-igkboard/recipes-kernel/linux/linux-imx_%.bbappend
+++ b/yocto/meta-igkboard/recipes-kernel/linux/linux-imx_%.bbappend
@@ -5,8 +5,36 @@
 PATCHTOOL = "patch"
 
 KERNEL_DANGLING_FEATURES_WARN_ONLY="1"
+KERNEL_DTC_FLAGS = "-@"
+KERNEL_DTOVERLAY ?= ""
 
 do_copy_defconfig:append() {
-    cp ${S}/arch/arm64/configs/${MACHINE}_defconfig ${WORKDIR}/defconfig
-    cp ${S}/arch/arm64/configs/${MACHINE}_defconfig ${B}/.config
+	if [ ${DO_CONFIG_V7_COPY} = "yes" ]; then
+        cp ${S}/arch/arm/configs/${MACHINE}_defconfig ${WORKDIR}/defconfig
+        cp ${S}/arch/arm/configs/${MACHINE}_defconfig ${B}/.config
+    else
+        cp ${S}/arch/arm64/configs/${MACHINE}_defconfig ${WORKDIR}/defconfig
+        cp ${S}/arch/arm64/configs/${MACHINE}_defconfig ${B}/.config
+    fi
+}
+
+do_compile:append() {
+    if [ -n "${KERNEL_DTC_FLAGS}" ]; then
+        export DTC_FLAGS="${KERNEL_DTC_FLAGS}"
+    fi
+
+    for dtbf in ${KERNEL_DTOVERLAY}; do
+        dtb=`normalize_dtb "$dtbf"`
+        oe_runmake $dtb CC="${KERNEL_CC} $cc_extra " LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS}
+    done
+}
+
+do_deploy:append(){
+    install -d ${DEPLOYDIR}/overlays
+
+	if [ ${DO_CONFIG_V7_COPY} = "yes" ]; then
+        cp ${B}/arch/arm/boot/dts/${MACHINE}/*.dtbo ${DEPLOYDIR}/overlays
+#    else
+#        cp ${B}/arch/arm64/boot/dts/${MACHINE}/*.dtbo ${DEPLOYDIR}/overlays
+    fi
 }
diff --git a/yocto/meta-igkboard/recipes-qt/packagegroups/packagegroup-qt6-addons.bbappend b/yocto/meta-igkboard/recipes-qt/packagegroups/packagegroup-qt6-addons.bbappend
new file mode 100644
index 0000000..ecaaba8
--- /dev/null
+++ b/yocto/meta-igkboard/recipes-qt/packagegroups/packagegroup-qt6-addons.bbappend
@@ -0,0 +1,12 @@
+RDEPENDS:${PN}:remove = " \
+    qt3d \
+    qtdatavis3d \
+    qtquick3d \
+    qtquick3dphysics \
+    qtopcua \
+    qthttpserver \
+    qtlocation \
+    qtlottie \
+    qtpositioning \
+    qtspeech \
+"
diff --git a/yocto/meta-igkboard/tools/igkboard-setup.sh b/yocto/meta-igkboard/tools/igkboard-setup.sh
index dca643b..9482970 100755
--- a/yocto/meta-igkboard/tools/igkboard-setup.sh
+++ b/yocto/meta-igkboard/tools/igkboard-setup.sh
@@ -12,10 +12,12 @@
     echo "Options:"
     echo "  <machine>    machine name"
     echo "               - igkboard-imx8mp"
+    echo "               - igkboard-imx6ull"
     echo "  * [-b build-dir]: Build directory, if unspecified script uses 'build' as output directory"
     echo "  * [-h]: help"
     echo "Examples: "
     echo "$ MACHINE=igkboard-imx8mp source sources/meta-igkboard/tools/igkboard-setup.sh -b igkboard-imx8mp"
+    echo "$ MACHINE=igkboard-imx6ull source sources/meta-igkboard/tools/igkboard-setup.sh -b igkboard-imx6ull"
     echo
 }
 
@@ -89,7 +91,7 @@
 
 function igkboard_conf_set(){
     local build_dir=$1
-    cp $CWD/sources/meta-igkboard/conf/local.conf $CWD/${build_dir}/conf/local.conf
+    cp $CWD/sources/meta-igkboard/conf/${MACHINE}_local.conf $CWD/${build_dir}/conf/local.conf
     cp $CWD/sources/meta-igkboard/conf/bblayers.conf $CWD/${build_dir}/conf/bblayers.conf
 }
 

--
Gitblit v1.9.1