Skip to content

add apalis-imx8 boot firmware update support and fixup for imx8qm-mek erase in mfgtool#454

Merged
mike-scott merged 15 commits intofoundriesio:masterfrom
mike-scott:master-apalis-imx8-boot-firmare-update-support
Nov 16, 2021
Merged

add apalis-imx8 boot firmware update support and fixup for imx8qm-mek erase in mfgtool#454
mike-scott merged 15 commits intofoundriesio:masterfrom
mike-scott:master-apalis-imx8-boot-firmare-update-support

Conversation

@mike-scott
Copy link
Copy Markdown
Contributor

No description provided.

@mike-scott mike-scott self-assigned this Nov 3, 2021
@mike-scott mike-scott changed the title add apalis-imx8 boot firmware update support and fixup for imx8qm-mek erase in mfgtool [WIP] add apalis-imx8 boot firmware update support and fixup for imx8qm-mek erase in mfgtool Nov 3, 2021
@mike-scott
Copy link
Copy Markdown
Contributor Author

Testing these changes

@mike-scott mike-scott force-pushed the master-apalis-imx8-boot-firmare-update-support branch from c0fb19a to cff180d Compare November 3, 2021 22:42
@mike-scott
Copy link
Copy Markdown
Contributor Author

This needs an env size patch to avoid overflow error.

@mike-scott mike-scott marked this pull request as draft November 5, 2021 02:09
@mike-scott mike-scott changed the title [WIP] add apalis-imx8 boot firmware update support and fixup for imx8qm-mek erase in mfgtool add apalis-imx8 boot firmware update support and fixup for imx8qm-mek erase in mfgtool Nov 8, 2021
@mike-scott mike-scott marked this pull request as ready for review November 8, 2021 22:03
Copy link
Copy Markdown
Contributor

@Tim-Anderson Tim-Anderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mike-scott mike-scott force-pushed the master-apalis-imx8-boot-firmare-update-support branch from 4d38d3b to 7cb5278 Compare November 8, 2021 22:37
Comment thread meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp-base.cfg
Comment thread meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp.cfg
Comment thread meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp-base.cfg Outdated
Comment thread meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp.cfg
Comment thread meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/apalis-imx8/boot.cmd Outdated
Comment thread meta-lmp-bsp/recipes-bsp/u-boot/u-boot-base-scr/apalis-imx8/boot.cmd Outdated
Comment thread meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/apalis-imx8/boot.cmd Outdated
@mike-scott mike-scott force-pushed the master-apalis-imx8-boot-firmare-update-support branch from 2c259ce to c902f64 Compare November 10, 2021 04:06
@mike-scott
Copy link
Copy Markdown
Contributor Author

Updated with comments from @igoropaniuk

Diff from previous version:

diff --git a/meta-lmp-bsp/conf/machine/include/lmp-machine-custom.inc b/meta-lmp-bsp/conf/machine/include/lmp-machine-custom.inc
index b63cf4c4..1f9c03a0 100644
--- a/meta-lmp-bsp/conf/machine/include/lmp-machine-custom.inc
+++ b/meta-lmp-bsp/conf/machine/include/lmp-machine-custom.inc
@@ -261,7 +261,7 @@ SOTA_EXTRA_CLIENT_FEATURES_append_sota_apalis-imx6-sec = " fiovb"
 # iMX8QM
 SOTA_CLIENT_FEATURES_append_mx8qm = " ubootenv"
 IMAGE_BOOT_FILES_mx8qm = "imx-boot u-boot.itb hdmitxfw.bin ${KERNEL_IMAGETYPE} ${@make_dtb_boot_files(d)} boot.scr uEnv.txt"
-IMAGE_BOOT_FILES_sota_mx8qm = "imx-boot u-boot.itb boot.itb"
+IMAGE_BOOT_FILES_sota_mx8qm = "imx-boot u-boot.itb"
 LMP_BOOT_FIRMWARE_FILES_mx8qm = "imx-boot u-boot.itb"
 BOOTSCR_LOAD_ADDR_mx8qm = "0x83100000"
 KERNEL_IMAGETYPE_sota_mx8qm = "fitImage"
diff --git a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-base-scr/apalis-imx8/boot.cmd b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-base-scr/apalis-imx8/boot.cmd
index 40fb22c8..5a2abb23 100644
--- a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-base-scr/apalis-imx8/boot.cmd
+++ b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-base-scr/apalis-imx8/boot.cmd
@@ -1,14 +1,3 @@
-setenv fdt_file ${fdtfile}
-echo "Using freescale_${fdt_file}"
-
-# Default boot type and device
-setenv devtype mmc
-setenv devnum 0
-setenv boot_file Image
-setenv bootfile ${boot_file}
-setenv kernel_addr_r 0x80280000
-setenv mmcroot /dev/mmcblk0p2
-
 fatload ${devtype} ${devnum}:1 ${loadaddr} /uEnv.txt
 env import -t ${loadaddr} ${filesize}
 run bootcmd
diff --git a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp-base.cfg b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp-base.cfg
index 84ce9b16..2211f818 100644
--- a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp-base.cfg
+++ b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp-base.cfg
@@ -29,7 +29,5 @@ CONFIG_HUSH_PARSER=y
 CONFIG_ENV_IS_IN_FAT=y
 CONFIG_ENV_FAT_INTERFACE="mmc"
 CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
-CONFIG_USE_BOOTCOMMAND=y
-CONFIG_BOOTCOMMAND="fatload mmc 0:1 ${scriptaddr} /boot.scr; source ${scriptaddr}"
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x400
diff --git a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/apalis-imx8/boot.cmd b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/apalis-imx8/boot.cmd
index 98f2e539..57e30bac 100644
--- a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/apalis-imx8/boot.cmd
+++ b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/apalis-imx8/boot.cmd
@@ -11,9 +11,6 @@ setenv rootpart 2
 setenv hdmi_image hdmitxfw.bin
 setenv m4_0_image core0_m4_image.bin
 setenv m4_1_image core1_m4_image.bin
-setenv ramdisk_addr_r 0x8a000000
-# enable relocation of ramdisk
-setenv initrd_high

 # Boot image files
 setenv fit_addr ${ramdisk_addr_r}
@@ -40,8 +37,8 @@ setenv bootloader2_s_image ${bootloader2_image}
 setenv update_image_boot0 'echo "${fio_msg} writing ${image_path} ..."; run set_blkcnt && mmc dev ${devnum} 1 && mmc write ${loadaddr} ${start_blk} ${blkcnt}'
 setenv update_image_boot1 'echo "${fio_msg} writing ${image_path} ..."; run set_blkcnt && mmc dev ${devnum} 2 && mmc write ${loadaddr} ${start_blk} ${blkcnt}'

-setenv backup_boot0 'echo "${fio_msg} backing up primary boot image set ..."; run set_blkcnt && mmc dev ${devnum} 1 && mmc read ${loadaddr} 0x0 0x3FFE && mmc dev ${devnu>
-setenv restore_boot0 'echo "${fio_msg} restore primary boot image set ..."; run set_blkcnt && mmc dev ${devnum} 2 && mmc read ${loadaddr} 0x0 0x3FFE && mmc dev ${devnum}>
+setenv backup_boot0 'echo "${fio_msg} backing up primary boot image set ..."; run set_blkcnt && mmc dev ${devnum} 1 && mmc read ${loadaddr} 0x0 0x3FFE && mmc dev ${devnum} 2 && mmc write ${loadaddr} 0x0 0x3FFE'
+setenv restore_boot0 'echo "${fio_msg} restore primary boot image set ..."; run set_blkcnt && mmc dev ${devnum} 2 && mmc read ${loadaddr} 0x0 0x3FFE && mmc dev ${devnum} 1 && mmc write ${loadaddr} 0x0 0x3FFE'

 setenv update_primary_image "run update_image_boot0"
 setenv update_primary_image2 "run update_image_boot0"

Copy link
Copy Markdown
Member

@ricardosalveti ricardosalveti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, will let @igoropaniuk do a final review.

Copy link
Copy Markdown
Contributor

@igoropaniuk igoropaniuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only one minor comment

@igoropaniuk
Copy link
Copy Markdown
Contributor

@mike-scott we should also drop these two config options:

CONFIG_BOOTCOUNT_LIMIT=y
CONFIG_BOOTCOUNT_ENV=y

as it's handled now in boot.cmd instead (and to avoid collisions in logic)

did that already for imx8qm-mek https://github.com/foundriesio/meta-lmp/pull/459/files

@mike-scott mike-scott force-pushed the master-apalis-imx8-boot-firmare-update-support branch 3 times, most recently from cd42199 to 2da2cd5 Compare November 15, 2021 23:15
@mike-scott
Copy link
Copy Markdown
Contributor Author

@mike-scott we should also drop these two config options:

CONFIG_BOOTCOUNT_LIMIT=y
CONFIG_BOOTCOUNT_ENV=y

as it's handled now in boot.cmd instead (and to avoid collisions in logic)

did that already for imx8qm-mek https://github.com/foundriesio/meta-lmp/pull/459/files

Done.

@mike-scott
Copy link
Copy Markdown
Contributor Author

Pertninent diff from last version:

diff --git a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp.cfg b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp.cfg
index d898633d..91322d40 100644
--- a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp.cfg
+++ b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-fio/apalis-imx8/lmp.cfg
@@ -8,6 +8,7 @@ CONFIG_SPL_FIT_SIGNATURE=y
 CONFIG_SPL_FIT_SIGNATURE_STRICT=y
 CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
+CONFIG_PSCI_BOARD_REBOOT=y
 # CONFIG_SPL_FIT_IMAGE_TINY is not set
 # CONFIG_SPL_SATA_SUPPORT is not set
 # CONFIG_SPL_LOAD_IMX_CONTAINER is not set
@@ -27,8 +28,6 @@ CONFIG_ENV_SIZE=0x4000
 CONFIG_CMD_IMPORTENV=y
 CONFIG_CMD_EDITENV=y
 CONFIG_CMD_SAVEENV=y
-CONFIG_BOOTCOUNT_LIMIT=y
-CONFIG_BOOTCOUNT_ENV=y
 # CONFIG_DISTRO_DEFAULTS is not set
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_FAT=y
diff --git a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/apalis-imx8/boot.cmd b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/apalis-imx8/boot.cmd
index 57e30bac..951dd269 100644
--- a/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/apalis-imx8/boot.cmd
+++ b/meta-lmp-bsp/recipes-bsp/u-boot/u-boot-ostree-scr-fit/apalis-imx8/boot.cmd
@@ -43,5 +43,7 @@ setenv restore_boot0 'echo "${fio_msg} restore primary boot image set ..."; run
 setenv update_primary_image "run update_image_boot0"
 setenv update_primary_image2 "run update_image_boot0"

+setenv do_reboot "reboot"
+
 @@INCLUDE_COMMON_IMX@@
 @@INCLUDE_COMMON_ALTERNATIVE@@

u-boot-fio config shows:
CONFIG_ENV_SIZE=0x4000

Let's update 0x2000 value in fw_env.config to match that.

Signed-off-by: Michael Scott <[email protected]>
The erase group for boot partitions on imx8qm is 0x400.  This means
using the current settings we are erasing the whole boot partition
and clearing the Toradex Config Block.

Let's account for the 0x400 erase block by erasing to block 0x3C00.

Fixes: 58fba18 ("bsp: mfgtool-files: common: adjust boot0 erase cmds")

Signed-off-by: Michael Scott <[email protected]>
Support secondary boot on the apalis-imx8 HW.
(Similar to patch for imx8qm-mek)

Signed-off-by: Michael Scott <[email protected]>
Support secondary boot for apalis-imx8
(Similar to patch for imx8qm-mek)

Signed-off-by: Michael Scott <[email protected]>
Add support for boot firmware updates
(Similar to patch for imx8qm-mek)

Signed-off-by: Michael Scott <[email protected]>
Flash secondary boot images on apalis-imx8.
(Similar to patch for iMX8QM-MEK)

Signed-off-by: Michael Scott <[email protected]>
The boot script now lives in u-boot fit-image, and it's extracted by SPL.

Let's use it.

Signed-off-by: Michael Scott <[email protected]>
Some settings are in a different order and some settings may
not be needed due to slight differences between the defconfigs.

However, let's sync up the LmP settings for u-boot-fio so that
future updates are easier to follow.

Signed-off-by: Michael Scott <[email protected]>
…loadaddr

This keeps the lmp-base boot script in better sync with the imx8qm-mek.

Signed-off-by: Michael Scott <[email protected]>
This fixes an issue during boot software upgrade where the env
is extended past the original 0x2000 limit.

Signed-off-by: Michael Scott <[email protected]>
Relevant changes:
- bfbf318ff1 [FIO toup] apalis-imx8: allow dropping CONFIG_CMD_USB requirement

Signed-off-by: Michael Scott <[email protected]>
Boot script is now integrated into u-boot fit-image for all supported
hardware.

Signed-off-by: Michael Scott <[email protected]>
@mike-scott mike-scott force-pushed the master-apalis-imx8-boot-firmare-update-support branch from 2da2cd5 to e399962 Compare November 15, 2021 23:20
@mike-scott
Copy link
Copy Markdown
Contributor Author

  • Dropped erase block change for imx8qm-mek

@MrCry0 MrCry0 self-requested a review November 15, 2021 23:28
Copy link
Copy Markdown
Contributor

@MrCry0 MrCry0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Drop CONFIG_BOOTCOUNT_LIMIT, as this is now handled in boot.cmd instead.

(Similar to imx8qm-mek change by Igor Opaniuk <[email protected]>)

Signed-off-by: Michael Scott <[email protected]>
Enable CONFIG_PSCI_BOARD_REBOOT, which enables reboot cmd for triggering
board reset (SC_PM_RESET_TYPE_BOARD).

Default reset cmd is doing SC_PM_RESET_TYPE_COLD, which doesn't force
BootROM to reload imx-boot firmware.

(Similar to commit for imx8qm-mek by Igor Opaniuk <[email protected]>)

Signed-off-by: Michael Scott <[email protected]>
Define custom do_reboot cmd in order to perform a cold reset to force
BootROM to reload the imx-boot firmware.

(Similar to commit for imx8qm-mek by Igor Opaniuk <[email protected]>)

Signed-off-by: Michael Scott <[email protected]>
@mike-scott mike-scott force-pushed the master-apalis-imx8-boot-firmare-update-support branch from e399962 to 2f02b59 Compare November 16, 2021 01:37
@mike-scott
Copy link
Copy Markdown
Contributor Author

Fixed the disable of bootcount handling in u-boot:

-CONFIG_BOOTCOUNT_LIMIT=y
-CONFIG_BOOTCOUNT_ENV=y
+# CONFIG_BOOTCOUNT_LIMIT is not set

@igoropaniuk igoropaniuk self-requested a review November 16, 2021 19:38
Copy link
Copy Markdown
Contributor

@igoropaniuk igoropaniuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mike-scott mike-scott merged commit 8fc4475 into foundriesio:master Nov 16, 2021
@mike-scott mike-scott deleted the master-apalis-imx8-boot-firmare-update-support branch November 16, 2021 19:39
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

Successfully merging this pull request may close these issues.

5 participants