Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for IOT-DIN-IMX8PLUS #26

Open
mgisch opened this issue Mar 10, 2025 · 9 comments
Open

Support for IOT-DIN-IMX8PLUS #26

mgisch opened this issue Mar 10, 2025 · 9 comments

Comments

@mgisch
Copy link

mgisch commented Mar 10, 2025

Hello,

Can anyone provide hints for what would need changing to support a similar compulab model - the IOT-DIN-IMX8PLUS?.

Out of the box the images produced from bookworm branch do not boot on this device; failing here:

U-Boot 2023.04-IOTDIN-IMX8P-1.0 (May 20 2024 - 11:23:34 +0300)

CPU:   i.MX8MP[8] rev1.1 1800 MHz (running at 1200 MHz)
CPU:   Commercial temperature grade (0C to 95C) at 42C
Reset cause: POR
Model: CompuLab IOTDIN-IMX8P
DRAM:  2 GiB
Core:  238 devices, 30 uclasses, devicetree: separate
MMC:   FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
SEC0:  RNG instantiated
switch to partitions #0, OK
mmc2(part 0) is current device
flash target is MMC:2
Net:   eth0: ethernet@30be0000 [PRIME], eth1: ethernet@30bf0000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  2 ^H^H^H 1 ^H^H^H 0 
Running BSP bootcmd ...
Running usb_ul ...
starting USB...
Bus usb@38100000: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
Bus usb@38200000: Register 2000140 NbrPorts 2
Starting the controller
USB XHCI 1.10
scanning bus usb@38100000 for devices... 2 USB Device(s) found
scanning bus usb@38200000 for devices... 3 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
2115 bytes read in 4 ms (515.6 KiB/s)
Running bootscript from usb 0:1 ...
## Executing script at 43500000
536 bytes read in 9 ms (57.6 KiB/s)
Successfully loaded secondary boot script.
## Executing script at 40400000
30073344 bytes read in 866 ms (33.1 MiB/s)
Failed to load '/usr/lib/linux-image-5.15.32-iot-gate-imx8m-3.2.1+/compulab/'
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree
loading Image
Failed to load 'Image'

The same usb stick boots fine on an iot-gate-imx8.

Thank you,
-M.

@lueschem
Copy link
Owner

Hi @mgisch
Without having the device on my desk it is difficult to give some proper advice.
Based on the documentation I believe you need a newer kernel. Depending on the kernel related changes also the first stage boot script might need to get modified. Also we might need to provide a new second stage boot script similar to this one. Please note that this file can be provided directly using the edi-cl setup instead of baking it into the edi-boot-shim Debian package.
Best regards
Matthias

@mgisch
Copy link
Author

mgisch commented Mar 15, 2025

Hi @lueschem - thank you for the quick response.
I've tried various kernel builds but cannot get the device to boot any of them; consistently failing with "Did not find a cmdline Flattened Device Tree".

I do have a working debian image provided by CL themselves (https://mediawiki.compulab.com/w/index.php?title=IOT-DIN-IMX8PLUS:_Debian_Linux:_Preparing_Live_Media). Is it possible to somehow use that as part of the edi image build and still end up with the dual partition / mender enabled setup?

These are the files in the first partition of the CL image:

-rw-r--r-- 1 root root  2105776 Jun  3  2024 flash.bin.d1d8
-rw-r--r-- 1 root root  2105776 Jun  3  2024 flash.bin.d2d4
lrwxrwxrwx 1 root root       16 Jun  3  2024 Image -> Image-6.1.55-1.0
-rw-r--r-- 1 root root 33004032 Jun  3  2024 Image-6.1.55-1.0
-rw-r--r-- 1 root root    86305 Dec  4 23:07 iotdin-imx8p.dtb
-rw-r--r-- 1 root root    88106 Dec  4 23:07 iotdin-imx8p-rpmsg.dtb
drwx------ 2 root root    12288 Feb  8  2024 lost+found

Thank you.

@lueschem
Copy link
Owner

lueschem commented Mar 16, 2025

Hi @mgisch

It is for sure a good idea to look at the Compulab provided image. I would not directly rip out the files from that image as then the setup gets somewhat unreproducible.

Here is what I figured out about the file list you provided:

  • flash.bin.d1d8, flash.bin.d2d4: Those are two U-Boot bootloaders. They are not strictly required on the image as one of them is probably already flashed to one of the boot partitions of the eMMC or some other location.
  • Image: A symlink to the actual kernel image.
  • Image-6.1.55-1.0: The actual kernel image.
  • iotdin-imx8p.dtb, iotdin-imx8p-rpmsg.dtb: The device tree binaries for the iot-din-imx8plus device.

The kernel documentation I pointed out seems to be outdated. This documentation seems to be the most recent one. I did a GitHub actions workflow for it and got this kernel (for Debian bookworm - let me know if you need one for trixie).

The kernel Debian package contains the required kernel image (vmlinux-xyz in /boot/) as well as the matching device tree binaries (see /usr/lib/linux-image-6.6.23-g96ad4675347d/compulab/). As the next steps we might need to include this new kernel and adjust the U-Boot bootloader setup.

Could you do the following commands on your Compulab device running the Compulab provided image and provide the output?

sudo fw_printenv
cat /proc/cmdline

This should help us to stick the remaining pieces together.

@mgisch
Copy link
Author

mgisch commented Mar 17, 2025

Thank you for looking at this in more detail @lueschem .

If I use your kernel package in the edi build the resulting usb image now says it finds a device tree but fails with this error instead:

       scanning usb for storage devices... 1 Storage Device(s) found
2115 bytes read in 5 ms (413.1 KiB/s)
Running bootscript from usb 0:1 ...
## Executing script at 43500000
518 bytes read in 8 ms (62.5 KiB/s)
Successfully loaded secondary boot script.
## Executing script at 40400000
35013120 bytes read in 1011 ms (33 MiB/s)
Failed to load '/usr/lib/linux-image-6.6.23-g96ad4675347d/compulab/'
## Flattened Device Tree blob at 43000000
   Booting using the fdt blob at 0x43000000
Working FDT set to 43000000
clk usb_phy_root_clk already disabled
clk usb_phy_root_clk already disabled
   Using Device Tree in place at 0000000043000000, end 0000000043018fff
Working FDT set to 43000000
fdt_find_or_add_subnode: chosen: FDT_ERR_BADSTRUCTURE
ERROR: /chosen node create failed
 - must RESET the board to recover.

FDT creation failed!
resetting ...

Here is the output of those 2 commands from a running system:

root@0001c03b2c23:~# fw_printenv
arch=arm
autoload=off
baudrate=115200
board=iotdin-imx8p
board_name=iotdin-imx8p
board_rev=iMX8MP
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootaa64.efi; if fdt addr -q ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_efi_bootmgr=if fdt addr -q ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr;fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_fdt=try
boot_fit=no
boot_net_usb_start=usb start
boot_opt=net.ifnames=0
boot_part=1
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=usb0 mmc1 mmc2 
bootargs=console=ttymxc1,115200 console=tty1 root=/dev/mmcblk2p2 rootwait rw net.ifnames=0
bootcmd=run bsp_bootcmd
bootcmd_mfg=run mfgtool_args;if iminfo ${initrd_addr}; then if test ${tee} = yes; then bootm ${tee_addr} ${initrd_addr} ${fdt_addr}; else booti ${loadaddr} ${initrd_addr} ${fdt_addr}; fi; else echo "Run fastboot ..."; fastboot 0; fi;
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_mmc2=devnum=2; run mmc_boot
bootcmd_usb0=devnum=0; run usb_boot
bootcount=0
bootdelay=2
bootlimit=1
bootlist=usb_ul sd_ul emmc_ul
bootm_size=0x10000000
bootscript=echo Running bootscript from mmc ...; source
bsp_bootcmd=echo Running BSP bootcmd ...; for src in ${bootlist}; do echo Running ${src} ...; run ${src}; env exist boot_opt && env exists bootargs && setenv bootargs ${bootargs} ${boot_opt}; if run ulbootscript; then run ulrunbootscript; fi; if run ulimage; then if run ulfdt; then booti ${loadaddr} - ${fdt_addr_r}; else if test ${boot_fdt} != yes; then booti ${loadaddr}; fi; fi; fi; done; 
bsp_script=boot.scr
console=ttymxc1,115200 console=tty1
cpu=armv8
dev=2
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
dram_subset=d2d4
edi_first_boot_done=true
efi_dtb_prefixes=/ /dtb/ /dtb/current/
emmc_dev=2
emmc_root=/dev/mmcblk2p2
emmc_ul=setenv iface mmc; setenv dev ${emmc_dev}; setenv part ${boot_part};setenv bootargs console=${console} root=${emmc_root} ${root_opt};
eth1addr=00:01:c0:3b:2c:32
ethact=ethernet@30be0000
ethaddr=00:01:c0:3b:2c:23
ethprime=eth0
fastboot_dev=mmc2
fdt_addr=0x43000000
fdt_addr_r=0x43000000
fdt_high=0xffffffffffffffff
fdtcontroladdr=bdbf2510
fdtfile=iotdin-imx8p.dtb
fdto_addr_r=0x43800000
fileaddr=43500000
filesize=843
iface=mmc
image=Image
initrd_addr=0x43800000
initrd_high=0xffffffffffffffff
kboot=booti 
kernel_addr_r=0x40400000
kernel_comp_addr_r=0x42000000
kernel_comp_size=0x2000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x40400000
loadbootscript=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bsp_script};
loadfdt=load mmc ${mmcdev}:${mmcpart} ${fdt_addr_r} ${fdtfile}
loadimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
mender_boot_part=3
mender_boot_part_A=3
mender_boot_part_B=4
mender_boot_part_hex=3
mender_boot_part_hex_A=3
mender_boot_part_hex_B=4
mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc clk_ignore_unused 
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
mmcargs=setenv bootargs console=${console} root=${mmcroot}
mmcautodetect=yes
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fit} = yes || test ${boot_fit} = try; then bootm ${loadaddr}; else if run loadfdt; then booti ${loadaddr} - ${fdt_addr_r}; else echo WARN: Cannot load the DT; fi; fi;
mmcdev=2
mmcpart=1
mmcroot=/dev/mmcblk2p2 rootwait rw
nandfit_part=yes
netargs=setenv bootargs console=${console} root=/dev/nfs ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp
netboot=echo Booting from net ...; run netargs;  if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${loadaddr} ${image}; if test ${boot_fit} = yes || test ${boot_fit} = try; then bootm ${loadaddr}; else if ${get_cmd} ${fdt_addr_r} ${fdtfile}; then booti ${loadaddr} - ${fdt_addr_r}; else echo WARN: Cannot load the DT; fi; fi;
part=1
root_opt=rootwait rw
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then part uuid ${devtype} ${devnum}:${distro_bootpart} distro_bootpart_uuid ; run scan_dev_for_boot; fi; done; setenv devplist
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_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo EXTLINUX FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0x43500000
sd_dev=1
sd_root=/dev/mmcblk1p2
sd_ul=setenv iface mmc; setenv dev ${sd_dev}; setenv part ${boot_part};setenv bootargs console=${console} root=${sd_root} ${root_opt};
serial#=1726b8003429c8d2
soc=imx8m
soc_type=imx8mp
splashimage=0x50000000
stderr=serial,vidconsole
stdin=serial,usbkbd
stdout=serial,vidconsole
ulbootscript=load ${iface} ${dev}:${part} ${scriptaddr} ${bsp_script};
ulfdt=if test ${boot_fdt} = yes || test ${boot_fdt} = try; then echo loading ${fdtfile}; load ${iface} ${dev}:${part} ${fdt_addr_r} ${fdtfile}; if env exists fdtofile;then run ulfdto; else true; fi; fi;
ulfdto=setenv fdto1file; for fdto1file in ${fdtofile}; do echo loading ${fdto1file}; load ${iface} ${dev}:${part} ${fdto_addr_r} ${fdto1file} && fdt addr ${fdt_addr_r} && fdt resize 0x8000 && fdt apply ${fdto_addr_r};done; true;
ulimage=echo loading ${image}; load ${iface} ${dev}:${part} ${loadaddr} ${image}
ulrunbootscript=echo Running bootscript from ${iface} ${dev}:${part} ...; source ${scriptaddr}
upgrade_available=0
usb_boot=usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
usb_dev=0
usb_root=/dev/sda2
usb_ul=usb start; setenv iface usb; setenv dev ${usb_dev}; setenv part ${boot_part};setenv bootargs console=${console} root=${usb_root} ${root_opt};
vendor=compulab
video_link=1
root@0001c03b2c23:~# 
root@0001c03b2c23:~# 
root@0001c03b2c23:~# cat /proc/cmdline
console=ttymxc1,115200 console=tty1 root=/dev/mmcblk2p2 rootwait rw net.ifnames=0
root@0001c03b2c23:~# 

The only variables I added were the 2 kernel_comp; the rest is as it came from CL.

@lueschem
Copy link
Owner

Can you give this branch a try?

The build command is:

edi -v project make iot-din-imx8plus.yml

It will build a Debian trixie image using buildah and friends.

This commit pulls in the 6.6 kernel, sets an appropriate mender device type and chooses the correct edi-boot-shim template.

The edi-boot-shim template is implemented here.

@mgisch
Copy link
Author

mgisch commented Mar 18, 2025

This looks very promising!

  • The image builds
  • The device is able to boot off the usb
  • After writing it to mmc, the device is able to boot off mmc

I've run into a couple of issues. It's possible they are more related to me being new to the "v2" workflow.

The root file system never gets resized (resize2fs binary is not present in the image)

Mar 18 02:34:47 iot-gate-imx8-0001c03b2c23 edi-resize-rootfs[305]: /usr/bin/edi-resize-rootfs: line 146: resize2fs: command not found
Mar 18 02:34:47 iot-gate-imx8-0001c03b2c23 edi-resize-rootfs[161]: error: failed to resize rootfs due to abnormal script termination

Customizing the default user password appears to have no effect.
Changing the default user name/group to something other than compulab always fails with 'Gid 2000 already exists' type error.

Any ideas what might be going wrong there?
Thank you very much for getting it running to this point.

@lueschem
Copy link
Owner

I am glad to hear that the device boots!

About the missing resize2fs: Recently the "Priority" of e2fsprogs went from "required" to "important". Therefore resize2fs is missing on the image. I will fix that asap!

About the default user password and group ID: I will try to reproduce that issue. My first guess is that you need to clear intermediate artifacts before doing that change:

edi -v project make --recursive-clean 2 iot-din-imx8plus.yml
< edit user name and password >
edi -v project make iot-din-imx8plus.yml

Background: If there is already a group with gid 2000 in the buildah container, then Ansible will refuse to create another group with the same gid.

@lueschem
Copy link
Owner

lueschem commented Mar 18, 2025

I believe I can reproduce the group ID issue:

lueschem@NanoPi-R6C:~/edi-workspace/edi-cl$ edi -v project make iot-gate-imx8.yml
...
TASK [get_edi_io.debian_setup.default_user : Add a group for the default user.] ********************************
fatal: [edi-2ebded6f-60b1b4eb]: FAILED! => {"changed": false, "msg": "groupadd: GID '2000' already exists\n", "name": "mygroup"}

PLAY RECAP *****************************************************************************************************
edi-2ebded6f-60b1b4eb      : ok=9    changed=1    unreachable=0    failed=1    skipped=6    rescued=0    ignored=0   

Error: Command '['ansible-playbook', '--connection', 'buildah', '--inventory', '/home/lueschem/edi-workspace/edi-cl/tmpmrhj0beq/inventory', '--extra-vars', '@/home/lueschem/edi-workspace/edi-cl/tmpmrhj0beq/extra_vars_100_os_setup', '/home/lueschem/edi-workspace/edi-cl/plugins/playbooks/os_setup/main.yml']' returned non-zero exit status 2.
For more information increase the log level.

However, after a edi -v project make --recursive-clean 2 iot-gate-imx8.yml the build passes and the new default user is working with the new password (tested in buildah container edi-2ebded6f-60b1b4eb, I modified default_user_name, default_user_group and default_user_password in configuration/base/common.yml):

lueschem@NanoPi-R6C:~/edi-workspace/edi-cl$ buildah run edi-2ebded6f-60b1b4eb bash
root@f44c3122f82c:/# login myuser
Password: 
Linux f44c3122f82c 6.1.99 #32 SMP Mon Jan 20 15:50:32 CST 2025 aarch64
...
myuser@f44c3122f82c:~$ groups
mygroup adm sudo

Let me know if I am missing something!

@mgisch
Copy link
Author

mgisch commented Mar 20, 2025

Confirmed - after the recursive clean I was able to set custom user & password.
Also fixed the resizefs issue by adding e2fsprogs to the packages in resize_rootfs task list.

So far the only other delta I've noticed is that it's very noisy on console; mostly with systemd logging.
Still more testing to do...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants