diff --git a/imx8mm-lpddr4-evk.coffee b/imx8mm-lpddr4-evk.coffee new file mode 100644 index 00000000..bb63ebf8 --- /dev/null +++ b/imx8mm-lpddr4-evk.coffee @@ -0,0 +1,51 @@ +deviceTypesCommon = require '@resin.io/device-types/common' +{ networkOptions, commonImg, instructions } = deviceTypesCommon + +BOARD_POWEROFF = 'Remove and re-connect power to the board.' +BOARD_SHUTDOWN = 'Monitor the device in Balena dashboard to see when it entered the post-provisioning state. Leave the state settle for around 10 seconds.' + +postProvisioningInstructions = [ + BOARD_SHUTDOWN + instructions.REMOVE_INSTALL_MEDIA + instructions.BOARD_REPOWER +] + +module.exports = + version: 1 + slug: 'imx8mm-lpddr4-evk' + name: 'NXP i.MX8M Mini LPDDR4 EVK' + arch: 'aarch64' + state: 'development' + + stateInstructions: + postProvisioning: postProvisioningInstructions + + instructions: [ + instructions.ETCHER_SD + instructions.EJECT_SD + instructions.FLASHER_WARNING + BOARD_POWEROFF + ].concat(postProvisioningInstructions) + + gettingStartedLink: + windows: 'https://docs.resin.io/imx8mm-lpddr4-evk/nodejs/getting-started/#adding-your-first-device' + osx: 'https://docs.resin.io/imx8mm-lpddr4-evk/nodejs/getting-started/#adding-your-first-device' + linux: 'https://docs.resin.io/imx8mm-lpddr4-evk/nodejs/getting-started/#adding-your-first-device' + + yocto: + machine: 'imx8mm-lpddr4-evk' + image: 'balena-image-flasher' + fstype: 'balenaos-img' + version: 'yocto-honister' + deployArtifact: 'balena-image-flasher-imx8mm-lpddr4-evk.balenaos-img' + compressed: true + + options: [ networkOptions.group ] + + configuration: + config: + partition: + primary: 1 + path: '/config.json' + + initialization: commonImg.initialization diff --git a/layers/meta-balena-fsl-arm/conf/layer.conf b/layers/meta-balena-fsl-arm/conf/layer.conf index 547be9d1..4e9dc384 100644 --- a/layers/meta-balena-fsl-arm/conf/layer.conf +++ b/layers/meta-balena-fsl-arm/conf/layer.conf @@ -18,6 +18,9 @@ PREFERRED_PROVIDER_virtual/bootloader:nitrogen6x = "u-boot-boundary" PREFERRED_PROVIDER_u-boot:nitrogen8mm = "u-boot-boundary" PREFERRED_PROVIDER_virtual/bootloader:nitrogen8mm = "u-boot-boundary" +PREFERRED_PROVIDER_u-boot:imx8mm-lpddr4-evk = "u-boot-imx" +PREFERRED_PROVIDER_virtual/bootloader:imx8mm-lpddr4-evk = "u-boot-imx" + BBMASK += "meta-boundary/recipes-boundary/images" BBMASK += "meta-solidrun-arm-imx6/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.12.%.bbappend" BBMASK += "meta-boundary/recipes-graphics/wayland/weston_4.0.0.imx.bbappend" @@ -33,7 +36,12 @@ KERNEL_DEVICETREE:append:nitrogen8mm = " \ freescale/imx8mm-nitrogen8mm_rev2-m4.dtb \ " +IMX_DEFAULT_BSP:imx8mm-lpddr4-evk = "nxp" + +SERIAL_CONSOLES:imx8mm-lpddr4-evk = "115200;ttymxc1" + FIRMWARE_COMPRESSION:nitrogen8mm ?= "1" +FIRMWARE_COMPRESSION:imx8mm-lpddr4-evk ?= "1" # Temporarily removed until the solidrun upstream repo adds honister support: https://github.com/SolidRun/meta-solidrun-solidsense/issues/2 BBMASK += "meta-balena-fsl-arm/recipes-bsp/u-boot/u-boot-solidsense-imx6_%.bbappend" diff --git a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0002-fixup-imx8mm-evk-fdt-addr.patch b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0002-fixup-imx8mm-evk-fdt-addr.patch new file mode 100644 index 00000000..28a230db --- /dev/null +++ b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/0002-fixup-imx8mm-evk-fdt-addr.patch @@ -0,0 +1,14 @@ +diff -ur git.org/include/configs/imx8mm_evk.h git/include/configs/imx8mm_evk.h +--- git.org/include/configs/imx8mm_evk.h 2023-09-19 17:04:45.921296582 +0100 ++++ git/include/configs/imx8mm_evk.h 2023-09-19 17:06:34.504395138 +0100 +@@ -138,8 +138,8 @@ + "image=Image\0" \ + "splashimage=0x50000000\0" \ + "console=ttymxc1,115200\0" \ +- "fdt_addr_r=0x43000000\0" \ +- "fdt_addr=0x43000000\0" \ ++ "fdt_addr_r=0x44000000\0" \ ++ "fdt_addr=0x44000000\0" \ + "fdt_high=0xffffffffffffffff\0" \ + "boot_fit=no\0" \ + "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \ diff --git a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/balenaos_tweaks-imx.cfg b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/balenaos_tweaks-imx.cfg new file mode 100644 index 00000000..98664b73 --- /dev/null +++ b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/balenaos_tweaks-imx.cfg @@ -0,0 +1,3 @@ +CONFIG_ENV_SIZE=0x4000 +CONFIG_ENV_IS_NOWHERE=y +CONFIG_CMD_SAVEENV=n diff --git a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/increase-early-malloc.cfg b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/increase-early-malloc.cfg new file mode 100644 index 00000000..6d08a1f6 --- /dev/null +++ b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/files/increase-early-malloc.cfg @@ -0,0 +1 @@ +CONFIG_SYS_MALLOC_F_LEN=0x10000 diff --git a/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/u-boot-imx_%.bbappend b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/u-boot-imx_%.bbappend new file mode 100644 index 00000000..772ba56d --- /dev/null +++ b/layers/meta-balena-fsl-arm/recipes-bsp/u-boot/u-boot-imx_%.bbappend @@ -0,0 +1,12 @@ +UBOOT_KCONFIG_SUPPORT="1" +BALENA_UBOOT_DEVICE_TYPES="mmc" +inherit resin-u-boot + +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" + +SRC_URI:append:imx8mm-lpddr4-evk = " \ + file://0001-nitrogen8mm_env-common-Force-using-default-environment.patch \ + file://0002-fixup-imx8mm-evk-fdt-addr.patch \ + file://balenaos_tweaks-imx.cfg \ + file://increase-early-malloc.cfg \ +" diff --git a/layers/meta-balena-fsl-arm/recipes-connectivity/networkmanager/networkmanager_%.bbappend b/layers/meta-balena-fsl-arm/recipes-connectivity/networkmanager/networkmanager_%.bbappend index 2cadb6ef..ca093b27 100644 --- a/layers/meta-balena-fsl-arm/recipes-connectivity/networkmanager/networkmanager_%.bbappend +++ b/layers/meta-balena-fsl-arm/recipes-connectivity/networkmanager/networkmanager_%.bbappend @@ -6,3 +6,12 @@ unmanaged-devices=interface-name:p2p* EOF } + +do_deploy:append:imx8mm-lpddr4-evk() { + cat >> ${D}${sysconfdir}/NetworkManager/NetworkManager.conf <; + audio-codec = <&ak4458_1>, <&ak4458_2>; + reset-gpios = <&pca6416 4 GPIO_ACTIVE_LOW>; ++ status = "disabled"; + }; + + sound-ak5558 { +@@ -409,6 +410,7 @@ + reg = <0x10>; + AVDD-supply = <®_audio_board>; + DVDD-supply = <®_audio_board>; ++ status = "disabled"; + }; + + ak4458_2: ak4458@12 { +@@ -416,6 +418,7 @@ + reg = <0x12>; + AVDD-supply = <®_audio_board>; + DVDD-supply = <®_audio_board>; ++ status = "disabled"; + }; + + ak5558: ak5558@13 { +@@ -424,6 +427,7 @@ + reset-gpios = <&pca6416 3 GPIO_ACTIVE_LOW>; + AVDD-supply = <®_audio_board>; + DVDD-supply = <®_audio_board>; ++ status = "disabled"; + }; + + ak4497: ak4497@11 { +@@ -433,6 +437,7 @@ + AVDD-supply = <®_audio_board>; + DVDD-supply = <®_audio_board>; + dsd-path = <1>; ++ status = "disabled"; + }; + + ov5640_mipi: ov5640_mipi@3c { diff --git a/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx/0002-disable-caam-jr2.patch b/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx/0002-disable-caam-jr2.patch new file mode 100644 index 00000000..52b84201 --- /dev/null +++ b/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx/0002-disable-caam-jr2.patch @@ -0,0 +1,11 @@ +diff -ur kernel-source.org/arch/arm64/boot/dts/freescale/imx8mm.dtsi kernel-source/arch/arm64/boot/dts/freescale/imx8mm.dtsi +--- kernel-source.org/arch/arm64/boot/dts/freescale/imx8mm.dtsi 2023-09-20 18:56:03.116395438 +0100 ++++ kernel-source/arch/arm64/boot/dts/freescale/imx8mm.dtsi 2023-09-20 19:00:09.565594489 +0100 +@@ -941,6 +941,7 @@ + compatible = "fsl,sec-v4.0-job-ring"; + reg = <0x3000 0x1000>; + interrupts = ; ++ status = "disabled"; + }; + }; + diff --git a/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx/enable-iwlwifi.cfg b/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx/enable-iwlwifi.cfg new file mode 100644 index 00000000..c8c1657f --- /dev/null +++ b/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx/enable-iwlwifi.cfg @@ -0,0 +1,13 @@ +CONFIG_IWLWIFI=y +CONFIG_IWLWIFI_LEDS=y +CONFIG_IWLDVM=y +CONFIG_IWLMVM=y +# CONFIG_IWLWIFI_BCAST_FILTERING is not set + +# +# Debugging Options +# +# CONFIG_IWLWIFI_DEBUG is not set +# end of Debugging Options + +# CONFIG_MXC_GPU_VIV is not set diff --git a/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx/extra-kernel.cfg b/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx/extra-kernel.cfg new file mode 100644 index 00000000..d1412b2a --- /dev/null +++ b/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx/extra-kernel.cfg @@ -0,0 +1 @@ +CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m diff --git a/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx_%.bbappend b/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx_%.bbappend new file mode 100644 index 00000000..d4297f6f --- /dev/null +++ b/layers/meta-balena-fsl-arm/recipes-kernel/linux/linux-fslc-imx_%.bbappend @@ -0,0 +1,14 @@ +FILESEXTRAPATHS:append := ":${THISDIR}/${PN}" + +inherit kernel-balena + +# Disable commit SHA in kernel version string +SCMVERSION:imx8mm-lpddr4-evk ="n" + +SRC_URI:append:imx8mm-lpddr4-evk = " \ + file://0001-disable-audio-codecs.patch \ + file://0002-disable-caam-jr2.patch \ + file://enable-iwlwifi.cfg \ + file://extra-kernel.cfg \ +" + diff --git a/layers/meta-balena-fsl-arm/recipes-support/balena-info/balena-info.bbappend b/layers/meta-balena-fsl-arm/recipes-support/balena-info/balena-info.bbappend index 5f5ffd4a..56019722 100644 --- a/layers/meta-balena-fsl-arm/recipes-support/balena-info/balena-info.bbappend +++ b/layers/meta-balena-fsl-arm/recipes-support/balena-info/balena-info.bbappend @@ -1 +1,2 @@ TTYS:append:nitrogen8mm = " ttymxc1" +TTYS:append:imx8mm-lpddr4-evk = " ttymxc1" diff --git a/layers/meta-balena-fsl-arm/recipes-support/hostapp-update-hooks/files/99-flash-bootloader-imx8mm-lpddr4-evk b/layers/meta-balena-fsl-arm/recipes-support/hostapp-update-hooks/files/99-flash-bootloader-imx8mm-lpddr4-evk new file mode 100644 index 00000000..9c80390e --- /dev/null +++ b/layers/meta-balena-fsl-arm/recipes-support/hostapp-update-hooks/files/99-flash-bootloader-imx8mm-lpddr4-evk @@ -0,0 +1,38 @@ +#!/bin/sh + +# +# Script used by hostapps updater to flash bootloader onto internal media +# + +set -o errexit + +# machine specific data +uboot_file="imx-boot" +uboot_block_size=1024 +uboot_seek_blocks=33 +device="/dev/mmcblk2boot0" + +update_files="uboot" + +for i in $update_files; do + current_update_file=$(eval echo \$${i}_file) + block_size=$(eval echo \$${i}_block_size) + seek_blocks=$(eval echo \$${i}_seek_blocks) + + # calculate size and md5sum of the binary to update from the update bundle + update_size=$(ls -al /resin-boot/$current_update_file | awk '{print $5}') + update_md5sum=$(md5sum /resin-boot/$current_update_file | awk '{print $1'}) + + let skip_bytes=$block_size*$seek_blocks + + # calculate md5sum of the data already written to $device, using $update_size bytes and skipping $skip_bytes from $device + existing_md5sum=$(dd if=$device bs=1 skip=$skip_bytes count=$update_size status=none | md5sum | awk '{print $1}') + + # This hw partition should NOT be erased on imx8mm-lpddr4-evk, as it might contain an u-boot eMMC environment + if [ ! "$existing_md5sum" = "$update_md5sum" ]; then + echo "Will update u-boot on /dev/mmcblk2boot0" + echo 0 > /sys/block/mmcblk2boot0/force_ro + dd if=/resin-boot/$current_update_file of=$device conv=fdatasync seek=$seek_blocks bs=$block_size + echo 1 > /sys/block/mmcblk2boot0/force_ro + fi +done diff --git a/layers/meta-balena-fsl-arm/recipes-support/hostapp-update-hooks/hostapp-update-hooks.bbappend b/layers/meta-balena-fsl-arm/recipes-support/hostapp-update-hooks/hostapp-update-hooks.bbappend index 67977df7..eb9d34e6 100644 --- a/layers/meta-balena-fsl-arm/recipes-support/hostapp-update-hooks/hostapp-update-hooks.bbappend +++ b/layers/meta-balena-fsl-arm/recipes-support/hostapp-update-hooks/hostapp-update-hooks.bbappend @@ -19,3 +19,8 @@ HOSTAPP_HOOKS:append:nitrogen8mm = " \ 99-resin-uboot \ 99-flash-bootloader-nitrogen8mm \ " + +HOSTAPP_HOOKS:append:imx8mm-lpddr4-evk = " \ + 99-resin-uboot \ + 99-flash-bootloader-imx8mm-lpddr4-evk \ +" diff --git a/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher-board-imx8mm/resin-init-flasher-board b/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher-board-imx8mm/resin-init-flasher-board new file mode 100644 index 00000000..8cd772e4 --- /dev/null +++ b/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher-board-imx8mm/resin-init-flasher-board @@ -0,0 +1,19 @@ +#!/bin/sh + +# +# Initial flashing of u-boot +# + +set -o errexit + +# machine specific data +uboot_file="imx-boot" +uboot_block_size=1024 +uboot_seek_blocks=33 +uboot_device="/dev/mmcblk2boot0" + +# This hw partition should never be erased on the iMX8MM +# as it might contain an eMMC u-boot environment +echo 0 > /sys/block/mmcblk2boot0/force_ro +dd if=/mnt/boot/$uboot_file of=$uboot_device conv=fdatasync seek=$uboot_seek_blocks bs=$uboot_block_size +echo 1 > /sys/block/mmcblk2boot0/force_ro diff --git a/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher-board/resin-init-flasher-board b/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher-board-nitrogen8mm/resin-init-flasher-board similarity index 100% rename from layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher-board/resin-init-flasher-board rename to layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher-board-nitrogen8mm/resin-init-flasher-board diff --git a/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher-board.bbappend b/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher-board.bbappend index 258f034f..0fcb9ba3 100644 --- a/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher-board.bbappend +++ b/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher-board.bbappend @@ -1 +1,2 @@ -FILESEXTRAPATHS:append := "${THISDIR}/${PN}" +FILESEXTRAPATHS:append:nitrogen8mm := "${THISDIR}/${PN}-nitrogen8mm" +FILESEXTRAPATHS:append:imx8mm-lpddr4-evk := "${THISDIR}/${PN}-imx8mm" diff --git a/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher.bbappend b/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher.bbappend index d60025e6..46306a70 100644 --- a/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher.bbappend +++ b/layers/meta-balena-fsl-arm/recipes-support/resin-init/resin-init-flasher.bbappend @@ -1,3 +1,4 @@ # Flash to internal eMMC - kernel always enumerates emmc as mmcblk2 INTERNAL_DEVICE_KERNEL:solidrun-imx6 = "mmcblk2" INTERNAL_DEVICE_KERNEL:nitrogen8mm = "mmcblk0" +INTERNAL_DEVICE_KERNEL:imx8mm-lpddr4-evk = "mmcblk2"