summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Krummenacher <max.krummenacher@toradex.com>2023-02-18 12:28:56 +0100
committerMax Krummenacher <max.krummenacher@toradex.com>2023-02-22 12:15:07 +0100
commit6d147efd19e42b03b812392c4bf8eee4e96b2d2d (patch)
tree8ce7f3151a69afae7641899a7ad6133f199e2f36
parent9ae53d1bb4b192041770877c253da255b2b463a2 (diff)
board: verdin-am62: allow dfu update
Detect if U-Boot proper was booted from DFU, if so start DFU for flashing U-boot to eMMC boot area followed by UMS for flashing eMMC user area. Upstream-Status: Pending Initial U-Boot to be used for bring-up and validation of the V1.0 design, we'll decide on the step forward to mainline this once the bring-up and validation will be done. Refactoring ideas: - `Detect DFU boot` moved into arch K3 specific code. - `Detect DFU boot` by DFUing to a 'DFU' address a magic pattern and test that address. - Have a special U-Boot configuration for DFU boots,. - With TEZI available for Verdin AM62 this commit can be dropped. - The TEZI U-Boot could then have in its boot flow: ... if (! dfu_boot()) load_the_TEZI_fitimage_from_eMMC(); boot_from_fitimage(); ... Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
-rw-r--r--board/toradex/verdin-am62/verdin-am62.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/board/toradex/verdin-am62/verdin-am62.c b/board/toradex/verdin-am62/verdin-am62.c
index 7116bd82bc..f1c0614e07 100644
--- a/board/toradex/verdin-am62/verdin-am62.c
+++ b/board/toradex/verdin-am62/verdin-am62.c
@@ -22,6 +22,15 @@
DECLARE_GLOBAL_DATA_PTR;
+/* from 5.8 Boot Memory Maps */
+#define BOOT_PARAMETER_TABLE 0x43c3f298
+/* from 5.6.1 Common Header */
+#define BOOT_PARAMETER_PRIMARY_PERIPHERAL (*(u16 *)(BOOT_PARAMETER_TABLE + 0x04))
+#define BOOT_PARAMETER_SECONDARY_PERIPHERAL (*(u16 *)(BOOT_PARAMETER_TABLE + 0x204))
+#define BOOT_PARAMETER_EMMC 101
+#define BOOT_PARAMETER_SD 100
+#define BOOT_PARAMETER_USB_DFU 70
+
#define PMIC_I2C_BUS 0x0
#define PMIC_I2C_ADDRESS 0x30
#define PMIC_BUCK1_VSET_850 0xa
@@ -126,6 +135,42 @@ int ft_board_setup(void *blob, struct bd_info *bd)
}
#endif
+#if !defined(CONFIG_SPL_BUILD)
+/* Should check if we were booted over dfu, and if so go to DFU / UMS for download */
+void decide_on_dfu(void)
+{
+ /*
+ * SD boot with sdcard, 7000f290: 00000000
+ * SD boot without sdcard, dfu, 7000f290: 00000001
+ * eMMC Boot, eMMC flashed 7000f290: 00000000
+ * eMMC Boot, eMMC zeroed 7000f290: 00000001
+ * DFU Boot 7000f290: 00000000
+ *
+ * If this Memory location will stay untouched in future versions is
+ * unknown, so the code might break.
+ * Compare with arch/arm/mach-k3/am625_init.c which however is SPL only
+ */
+ u32 bootindex = *(u32 *)(CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX);
+ u32 bootmode = bootindex & 1 ? BOOT_PARAMETER_SECONDARY_PERIPHERAL :
+ BOOT_PARAMETER_PRIMARY_PERIPHERAL;
+
+ if (bootmode == BOOT_PARAMETER_USB_DFU) {
+ printf("DFU boot mode detected, going to DFU again for further downloads\n");
+ env_set("bootcmd", "setenv dfu_alt_info $dfu_alt_info_emmc;"
+ "dfu 0 mmc 0; ums 0 mmc 0");
+ }
+
+ debug("Booting from %s boot device\n", bootindex & 1 ? "Secondary" :
+ "Primary");
+ debug("Primary boot device as read from boot parameters %hd\n",
+ BOOT_PARAMETER_PRIMARY_PERIPHERAL);
+ debug("Secondary boot device as read from boot parameters %hd\n",
+ BOOT_PARAMETER_SECONDARY_PERIPHERAL);
+}
+#else
+void decide_on_dfu(void) {}
+#endif /* CONFIG_SPL_BUILD */
+
static void select_dt_from_module_version(void)
{
char variant[32];
@@ -155,6 +200,9 @@ int board_late_init(void)
{
select_dt_from_module_version();
+ /* set bootcmd to start DFU and then UMS mode if booted from DFU */
+ decide_on_dfu();
+
return 0;
}