Boot Switch Functionality for Apalis i.MX8QP 2GB WB

Hi,

I am using Apalis i.MX8QP 2GB WB SOM on my customized hardware. We are trying to use boot mode functionality using boot switches. We want to boot the image from different medias like SD card, EMMC, etc as per boot switch combinations.
I did not find any reference to Boot Switches in i.MX8 datasheet.
I also checked section 4.4 of the Apalis i.MX8 datasheet for detailed checking of pin description. But there also I c
apalis_imx8_datasheet.pdf (2.4 MB)
ould not see anything related to boot switches.
I have also attached the datasheet I have referred.
So please provide me the details of the boot pins of the Apalis i.MX8.

Hi @prathamesh.kulkarni,

Please check below article, although this do not talk about exact module in question but similar approach can be applied.

Other option is to make uboot script where one can use any available io pin and change boot order as per pin status. This would be simple and quick to implement as this requires no compiling.

Note: All modules are fused to boot exclusively from their on-module storage eMMC or Nand flash. So at least the boot loader(U-boot) has to present on the eMMC or Nand.

Let me know if you have any queries.
Best Regards
Ritesh kumar

Thanks @ritesh.tx for your inputs.
We are trying to use uboot script option for using GPIO pin. We are using these GPIO pins: GPIO 377 and GPIO 378.
We checked existing script boot.scr. We did not find any use of GPIO pins in the existing script.
Could you please share an example how to use GPIO pins in boot.scr for changing boot order?
This article Using DIP Switches to change the boot process | Toradex Developer Center gives an example of i.MX6. Could you please share similar example for i.MX8?

Regards,
Prathamesh Kulkarni

Hi @prathamesh.kulkarni,

Please note we have not tested this use case and we don’t recommend this for production. That said your script should look something as below:

setenv check_gpio_level ''gpio input GPIO7_9'; setenv gpio_level $?'
setenv custom_boot_order 'run check_gpio_level; if itest 1 -eq $gpio_level; then setenv boot_targets usb0 mmc1 mmc0 dhcp; else setenv boot_targets mmc1 mmc0 usb0 dhcp;fi'
setenv bootcmd 'run custom_boot_order; run distro_bootcmd; usb start ; setenv stdout serial,vidconsole; setenv stdin serial,usbkbd'
saveenv

change gpio as per your requirement.

This article Using DIP Switches to change the boot process | Toradex Developer Center gives an example of i.MX6. Could you please share similar example for i.MX8?
As of now we don’t have article specific to iMX8.

Best Regards
Ritesh Kumar

Hi @ritesh.tx, we tried to change boot order using above commands.
We were able to change boot order by updating ‘boot_targets’ variable from U-boot command prompt.
We tried the to update the same variable as per boot switch combinations through boot script. Below is the script snippet for reference.


env set check_gpio_level ''gpio input GPIO4_26'; setenv boot_sw0 $? ; 'gpio input GPIO4_25'; setenv boot_sw1 $?'

run check_gpio_level

echo "Checking boot switch positions...."
if test "${boot_sw0}" = "0"; then
	if test "${boot_sw1}" = "0"; then
		env set boot_targets "mmc0  usb0 mmc1 mmc2 dhcp"
	else
		env set boot_targets "usb0 mmc0 mmc1 mmc2 dhcp"
	fi
else
	if test "${boot_sw1}" = "0"; then
		env set boot_targets "dhcp mmc0  usb0 mmc1 mmc2"
	else
		env set boot_targets "mmc2 mmc1 mmc0 usb0 dhcp"
	fi
fi

saveenv

For now we are testing only for EMMC and SD card. We are facing below issues during testing.

  1. When I changed boot switches combinations, the variable ‘boot_targets’ updated successfully. But the board was booting with expected media on next reboot.
    e.g. If I set both the boot switches to ON (1). The board is expected to boot from SD card. But I have to reboot the board one more time in order to boot it from SD card.
    Could you please share your input on this?
  2. Suddenly we are getting below error at U-boot and not able to boot with any media irrespective of value of ‘boot_targets’
U-Boot 2020.04-5.6.0-devel+git.7d1febd4af77 (Feb 16 2022 - 09:00:30 +0000)



CPU:   NXP i.MX8QM RevB A53 at 1200 MHz



DRAM:  2 GiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Model: Toradex Apalis iMX8 QuadPlus 2GB Wi-Fi / BT V1.1C, Serial# 07107096



BuildInfo:
  - SCFW 99e479ce, SECO-FW 2f7f6f59, IMX-MKIMAGE 8947fea3, ATF 835a8f6
  - U-Boot 2020.04-5.6.0-devel+git.7d1febd4af77



switch to partitions #0, OK
mmc0(part 0) is current device
flash target is MMC:0
Net:   eth0: ethernet@5b040000
Fastboot: Normal
Normal Boot
Hit any key to stop autoboot:  0
** Bad device specification : 0x9c000000 **
Loading hdp firmware from 0x000000009c000000 offset 0x0000000000002000
Loading hdp firmware Complete
** Bad device specification : 0x8a000000 **
Apalis iMX8

Any idea how we can get out of this and boot with EMMC/SD card?

Regards,
Prathamesh Kulkarni

Hi @ritesh.tx ,

I was able to get my device out of the state mentioned above and boot it successfully.
I tried this Using DIP Switches to change the boot process | Toradex Developer Center to change boot order as per boot switch positions on my device the issue I was getting while using boot script method got resolved.
But I have two queries regarding the boot medias.

  1. While booting from USB I am facing an issue. There are 3 USB ports on my Apalis i.MX8 board. I am able to boot using only one of the USB ports on the device.
    We have defined boot order as follows:
    boot_targets=usb0 mmc0 mmc2 mmc1 dhcp
    Below are the details of the USB port device is booting from.
    oot@apalis-imx8-07107096:~# [ 29.322395] usb 2-1: new SuperSpeed Gen 1 USB device number 3 using cdns-usb3

[   29.348661] usb-storage 2-1:1.0: USB Mass Storage device detected
[   29.355479] scsi host0: usb-storage 2-1:1.0
[   30.367306] scsi 0:0:0:0: Direct-Access      USB      SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
[   30.377733] sd 0:0:0:0: [sda] 60063744 512-byte logical blocks: (30.8 GB/28.6 GiB)
[   30.386299] sd 0:0:0:0: [sda] Write Protect is off
[   30.391423] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[   30.426052]  sda: sda1 sda2
[   30.440565] sd 0:0:0:0: [sda] Attached SCSI removable disk

Device is not booting from below two USB ports.


[  679.810729] usb 3-1.3: new high-speed USB device number 6 using ci_hdrc
[  679.932693] usb-storage 3-1.3:1.0: USB Mass Storage device detected
[  679.939690] scsi host1: usb-storage 3-1.3:1.0
[  680.959500] scsi 1:0:0:0: Direct-Access      USB      SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
[  680.968838] sd 1:0:0:0: [sda] 60063744 512-byte logical blocks: (30.8 GB/28.6 GiB)
[  680.979250] sd 1:0:0:0: [sda] Write Protect is off
[  680.984871] sd 1:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  681.033932]  sda: sda1 sda2
[  681.051871] sd 1:0:0:0: [sda] Attached SCSI removable disk

[  726.398215] usb 3-1.2: new high-speed USB device number 7 using ci_hdrc
[  726.512530] usb-storage 3-1.2:1.0: USB Mass Storage device detected
[  726.519554] scsi host1: usb-storage 3-1.2:1.0
[  727.551506] scsi 1:0:0:0: Direct-Access      USB      SanDisk 3.2Gen1 1.00 PQ: 0 ANSI: 6
[  727.568654] sd 1:0:0:0: [sda] 60063744 512-byte logical blocks: (30.8 GB/28.6 GiB)
[  727.577343] sd 1:0:0:0: [sda] Write Protect is off
[  727.582976] sd 1:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  727.620502]  sda: sda1 sda2
[  727.627474] sd 1:0:0:0: [sda] Attached SCSI removable disk

Could you please share your inputs how I can make device boot using these two USB ports.

  1. I can see 3 MMC devices from mmc list command on U boot command prompt.
Apalis iMX8 # mmc list
FSL_SDHC: 0 (eMMC)
FSL_SDHC: 1
FSL_SDHC: 2
Apalis iMX8 #

MMC0 is emmc and MMC2 is SD card. I am not able to find what is MMC1.
Any idea what could be the MMC1 in this case?

Regards,
Prathamesh Kulkarni

Hi All,
Could you pleas help me with above issues?

Regards,
Prathamesh Kulkarni

Hi @prathamesh.kulkarni ,

In U-boot only USB3 is enumerated and not other USB. Please check below post likely other USB will not be supported.

The i.MX 8 SoC provides three SDIO interfaces; one is used internally for the eMMC Flash, and two are available on the module edge connector Pins.

Best Regards
Ritesh Kumar