Skip to content

Commit

Permalink
This supports build for the NXP imx8mm-lpddr4-evk reference platform.
Browse files Browse the repository at this point in the history
More work is needed:
- add Balena website details for this board at given links
- "contracts" have not been looked at
- writing to /dev/ttymxc0 seems to reset the board
- need to check support for secure boot / secure filesystem
- need to support image flasher
- testing

Changelog-entry: Add support for NXP imx8mm-lpddr4-evk board
Signed-off-by: Alex J Lennon <ajlennon@dynamicdevices.co.uk>

Remove extraneous patch

Signed-off-by: Alex J Lennon <ajlennon@dynamicdevices.co.uk>

Default to balenaOS image flasher

We have made changes to correctly enable build of the
flasher image which has been tested to run up and flash
the onboard EVK eMMC part correctly. This then boots
and runs up to the BalenaOS prompt

TODO:

- Still need to verify portal HostOS update works
  but will do that when device is supported through
  portal

Changelog-entry: Default imx8mm-lpddr4-evk board to image-flasher
Signed-off-by: Alex J Lennon <ajlennon@dynamicdevices.co.uk>

Use correct Yocto MACHINE name imx8mm-lpddr4-evk

I was overriding this to append -nxp to enable use of
IMX_DEFAULT_BSP="nxp" but am now adding this in layer.conf
instead so we can use the original machine name

Signed-off-by: Alex J Lennon <ajlennon@dynamicdevices.co.uk>

iwlwifi: Add support for Intel iwlwifi devices

We're using an M.2 WiFi module AX210NGW which this change supports

Signed-off-by: Alex J Lennon <ajlennon@dynamicdevices.co.uk>

linux-fslc-imx: Changes for peer review

- inherit kernel-balena not kernel-resin
- tidy up comments
- make settings board specific for disabling kernel versioning
  and kernel patches
- don't disable apparmour as this done elsewhere
- don't optimise for size as we set f/s size for EVK board

Signed-off-by: Alex J Lennon <ajlennon@dynamicdevices.co.uk>
  • Loading branch information
ajlennon committed Oct 20, 2023
1 parent 66db78b commit e9a7195
Show file tree
Hide file tree
Showing 20 changed files with 269 additions and 1 deletion.
51 changes: 51 additions & 0 deletions imx8mm-lpddr4-evk.coffee
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions layers/meta-balena-fsl-arm/conf/layer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Original file line number Diff line number Diff line change
@@ -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" \
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_ENV_SIZE=0x4000
CONFIG_ENV_IS_NOWHERE=y
CONFIG_CMD_SAVEENV=n
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_SYS_MALLOC_F_LEN=0x10000
Original file line number Diff line number Diff line change
@@ -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 \
"
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ unmanaged-devices=interface-name:p2p*
EOF

}

do_deploy:append:imx8mm-lpddr4-evk() {
cat >> ${D}${sysconfdir}/NetworkManager/NetworkManager.conf <<EOF

[keyfile]
unmanaged-devices=interface-name:p2p*
EOF

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ PACKAGE_INSTALL:solidrun-n6g += " \
"

PACKAGE_INSTALL:remove:nitrogen8mm = " initramfs-module-recovery"
PACKAGE_INSTALL:remove:imx8mm-lpddr4-evk = " initramfs-module-recovery"

PACKAGE_INSTALL:remove = "mdraid"
23 changes: 23 additions & 0 deletions layers/meta-balena-fsl-arm/recipes-core/images/balena-image.inc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ BALENA_BOOT_PARTITION_FILES:nitrogen8mm-dwe = " \
imx-boot:/imx-boot \
"

BALENA_BOOT_SIZE:imx8mm-lpddr4-evk = "131072"
IMAGE_ROOTFS_SIZE:imx8mm-lpddr4-evk = "524288"
IMAGE_FSTYPES:append:imx8mm-lpddr4-evk = " balenaos-img"
BALENA_IMAGE_BOOTLOADER:imx8mm-lpddr4-evk = "u-boot-imx"
BALENA_BOOT_PARTITION_FILES:imx8mm-lpddr4-evk = " \
${KERNEL_IMAGETYPE}${KERNEL_INITRAMFS}-${MACHINE}.bin:/${KERNEL_IMAGETYPE} \
imx8mm-evk.dtb:/imx8mm-evk.dtb \
imx-boot:/imx-boot \
"

IMAGE_CMD:balenaos-img:append:imx8mm-lpddr4-evk () {
dd if=${DEPLOY_DIR_IMAGE}/imx-boot of=${BALENA_RAW_IMG} conv=notrunc seek=33 bs=1024
}

# up the rootfs size to be safe for future increases
IMAGE_ROOTFS_SIZE:emgw3="409600"

Expand All @@ -134,7 +148,16 @@ IMAGE_INSTALL:append:emgw3 = " \
udev-rules-bt \
"

IMAGE_INSTALL:append:imx8mm-lpddr4-evk = " \
firmware-imx-8m \
linux-firmware-bdsdmac \
linux-firmware-iwlwifi \
kernel-devicetree \
pciutils \
"

DEPENDS:append:nitrogen8mm += "imx-boot"
DEPENDS:append:imx8mm-lpddr4-evk += "imx-boot"

# the BSP sets this variable so let's unset it since this makes our build fail
unset ROOTFS_SIZE
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
diff -ur kernel-source.org/arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi kernel-source/arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi
--- kernel-source.org/arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi 2023-09-20 14:08:41.822947549 +0100
+++ kernel-source/arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi 2023-09-20 16:08:00.194748554 +0100
@@ -130,6 +130,7 @@
audio-cpu = <&sai1>;
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 = <&reg_audio_board>;
DVDD-supply = <&reg_audio_board>;
+ status = "disabled";
};

ak4458_2: ak4458@12 {
@@ -416,6 +418,7 @@
reg = <0x12>;
AVDD-supply = <&reg_audio_board>;
DVDD-supply = <&reg_audio_board>;
+ status = "disabled";
};

ak5558: ak5558@13 {
@@ -424,6 +427,7 @@
reset-gpios = <&pca6416 3 GPIO_ACTIVE_LOW>;
AVDD-supply = <&reg_audio_board>;
DVDD-supply = <&reg_audio_board>;
+ status = "disabled";
};

ak4497: ak4497@11 {
@@ -433,6 +437,7 @@
AVDD-supply = <&reg_audio_board>;
DVDD-supply = <&reg_audio_board>;
dsd-path = <1>;
+ status = "disabled";
};

ov5640_mipi: ov5640_mipi@3c {
Original file line number Diff line number Diff line change
@@ -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 = <GIC_SPI 114 IRQ_TYPE_LEVEL_HIGH>;
+ status = "disabled";
};
};

Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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 \
"

Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
TTYS:append:nitrogen8mm = " ttymxc1"
TTYS:append:imx8mm-lpddr4-evk = " ttymxc1"
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
"
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
FILESEXTRAPATHS:append := "${THISDIR}/${PN}"
FILESEXTRAPATHS:append:nitrogen8mm := "${THISDIR}/${PN}-nitrogen8mm"
FILESEXTRAPATHS:append:imx8mm-lpddr4-evk := "${THISDIR}/${PN}-imx8mm"
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit e9a7195

Please sign in to comment.