]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
FWU: developerbox: read boot index from NOR flash
authorMasahisa Kojima <masahisa.kojima@linaro.org>
Thu, 8 Feb 2024 02:33:44 +0000 (11:33 +0900)
committerTom Rini <trini@konsulko.com>
Sat, 2 Mar 2024 17:26:19 +0000 (12:26 -0500)
The FWU Multi Bank Update feature allows the platform to boot the
firmware images from one of the partitions(banks).
On the Developerbox, SCP-firmware running on the SCB(Cortex-M3)
passes the value of the boot index on the NOR flash.
Add a function to read the boot index value from the NOR flash.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
board/socionext/developerbox/fwu_plat.c
include/configs/synquacer.h

index e724e702bdc71aeac6a495061fd5b77c885a8508..26031795b09d97d6bb9f83c7e573f4e4cf56ad44 100644 (file)
@@ -35,3 +35,34 @@ void set_dfu_alt_info(char *interface, char *devstr)
 
        env_set("dfu_alt_info", buf);
 }
+
+/**
+ * fwu_plat_get_bootidx() - Get the value of the boot index
+ * @boot_idx: Boot index value
+ *
+ * Get the value of the bank(partition) from which the platform
+ * has booted. This value is passed to U-Boot from the earlier
+ * stage bootloader which loads and boots all the relevant
+ * firmware images
+ */
+void fwu_plat_get_bootidx(uint *boot_idx)
+{
+       int ret;
+       u32 buf;
+       size_t readlen;
+       struct mtd_info *mtd;
+
+       *boot_idx = 0;
+
+       mtd_probe_devices();
+       mtd = get_mtd_device_nm("nor1");
+       if (IS_ERR_OR_NULL(mtd))
+               return;
+
+       ret = mtd_read(mtd, SCB_PLAT_METADATA_OFFSET, sizeof(buf),
+                      &readlen, (u_char *)&buf);
+       if (ret < 0)
+               return;
+
+       *boot_idx = buf;
+}
index e36e63e81e4ea48d74ca300be867ddce8e047718..f0867227acc33d007816ef04eb18796e51241a33 100644 (file)
@@ -21,6 +21,7 @@
 /*
  * Boot info
  */
+#define SCB_PLAT_METADATA_OFFSET       (0x510000)
 
 /*
  * Hardware drivers support