Skip to contentSkip to conversation

toradex: imx: add update_uboot wrapper

PATCH Superseded Igor Opaniuk 2 participants 8 messages Dec 4, 2019 – Dec 5, 2019 Arm i.MX and Layerscape

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover toradex: imx: add update_uboot wrapper

This patch series introduces universtal update_uboot wrapper that helps to update U-Boot image on internal storage.

Example of usage:

Quoted 4 lines

tftpboot ${loadaddr} ${board_name}/u-boot.img
run update_uboot
tftpboot ${loadaddr} ${board_name}/SPL
run update_spl

Igor Opaniuk (5):
colibri_imx7: add update_uboot wrapper
apalis_imx6: add update_uboot wrapper
colibri_imx6: add update_uboot wrapper
colibri-imx6ull: add update_uboot wrapper
colibri_vf: add update_uboot wrapper

 include/configs/apalis_imx6.h     | 12 ++++++++++++
 include/configs/colibri-imx6ull.h |  8 ++++++++
 include/configs/colibri_imx6.h    | 12 ++++++++++++
 include/configs/colibri_imx7.h    | 18 ++++++++++++++++++
 include/configs/colibri_vf.h      |  6 ++++++
 5 files changed, 56 insertions(+)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/5 colibri_imx7: add update_uboot wrapper

From: Igor Opaniuk <[email protected]>

Add universal update_uboot wrapper that helps to update U-Boot image on internal storage.

Usage example:

Quoted 2 lines

tftpboot ${loadaddr} ${board_name}/u-boot-dtb.imx
run update_uboot

---

 include/configs/colibri_imx7.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/configs/colibri_imx7.h +18 -0
index d92db7192e..2e212bf8ec 100644
@@ -43,6 +43,23 @@
 #define CONFIG_NETMASK			255.255.255.0
 #define CONFIG_SERVERIP			192.168.10.1
 
+#if defined(CONFIG_TARGET_COLIBRI_IMX7_EMMC)
+#define UBOOT_UPDATE \
+	"uboot_hwpart=1\0" \
+	"uboot_blk=2\0" \
+	"set_blkcnt=setexpr blkcnt ${filesize} + 0x1ff && " \
+		"setexpr blkcnt ${blkcnt} / 0x200\0" \
+	"update_uboot=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && " \
+		"mmc write ${loadaddr} ${uboot_blk} ${blkcnt}\0"
+#elif defined(CONFIG_TARGET_COLIBRI_IMX7_NAND)
+#define UBOOT_UPDATE \
+	"uboot_hwpart=1\0" \
+	"update_uboot=nand erase.part u-boot1 && " \
+		"nand write ${loadaddr} u-boot1 ${filesize} && " \
+		"nand erase.part u-boot2 && " \
+		"nand write ${loadaddr} u-boot2 ${filesize}\0"
+#endif
+
 #ifndef PARTS_DEFAULT
 /* Define the default GPT table for eMMC */
 #define PARTS_DEFAULT \
@@ -163,6 +180,7 @@
 	MEM_LAYOUT_ENV_SETTINGS \
 	NFS_BOOTCMD \
 	MODULE_EXTRA_ENV_SETTINGS \
+	UBOOT_UPDATE \
 	"boot_file=zImage\0" \
 	"console=ttymxc0\0" \
 	"defargs=\0" \
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/5 apalis_imx6: add update_uboot wrapper

In reply to Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Add universal update_uboot wrapper that helps to update U-Boot image on internal storage.

Usage example:

Quoted 4 lines

tftpboot ${loadaddr} ${board_name}/u-boot.img
run update_uboot
tftpboot ${loadaddr} ${board_name}/SPL
run update_spl

---

 include/configs/apalis_imx6.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/configs/apalis_imx6.h +12 -0
index 50a4391cd4..800f27ccbb 100644
@@ -121,6 +121,17 @@
 	"imx6q-apalis-eval.dtb fat 0 1;" \
 	"imx6q-apalis-cam-eval.dtb fat 0 1"
 
+#define UBOOT_UPDATE \
+	"uboot_hwpart=1\0" \
+	"uboot_blk=8a\0" \
+	"uboot_spl_blk=2\0" \
+	"set_blkcnt=setexpr blkcnt ${filesize} + 0x1ff && " \
+		"setexpr blkcnt ${blkcnt} / 0x200\0" \
+	"update_uboot=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && " \
+		"mmc write ${loadaddr} ${uboot_blk} ${blkcnt}\0" \
+	"update_spl=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && " \
+		"mmc write ${loadaddr} ${uboot_spl_blk} ${blkcnt}\0"
+
 #define EMMC_BOOTCMD \
 	"set_emmcargs=setenv emmcargs ip=off root=PARTUUID=${uuid} " \
 		"ro,noatime rootfstype=ext4 rootwait\0" \
@@ -178,6 +189,7 @@
 	"fdt_fixup=;\0" \
 	MEM_LAYOUT_ENV_SETTINGS \
 	NFS_BOOTCMD \
+	UBOOT_UPDATE \
 	"setethupdate=if env exists ethaddr; then; else setenv ethaddr " \
 		"00:14:2d:00:00:00; fi; tftpboot ${loadaddr} " \
 		"flash_eth.img && source ${loadaddr}\0" \
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/5 colibri_imx6: add update_uboot wrapper

In reply to Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Add universal update_uboot wrapper that helps to update U-Boot image on internal storage.

Quoted 4 lines

tftpboot ${loadaddr} ${board_name}/u-boot.img
run update_uboot
tftpboot ${loadaddr} ${board_name}/SPL
run update_spl

---

 include/configs/colibri_imx6.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
include/configs/colibri_imx6.h +12 -0
index 95b5a14b59..750463ef47 100644
@@ -110,6 +110,17 @@
 	"imx6dl-colibri-eval-v3.dtb fat 0 1;" \
 	"imx6dl-colibri-cam-eval-v3.dtb fat 0 1"
 
+#define UBOOT_UPDATE \
+	"uboot_hwpart=1\0" \
+	"uboot_blk=8a\0" \
+	"uboot_spl_blk=2\0" \
+	"set_blkcnt=setexpr blkcnt ${filesize} + 0x1ff && " \
+		"setexpr blkcnt ${blkcnt} / 0x200\0" \
+	"update_uboot=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && " \
+		"mmc write ${loadaddr} ${uboot_blk} ${blkcnt}\0" \
+	"update_spl=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && " \
+		"mmc write ${loadaddr} ${uboot_spl_blk} ${blkcnt}\0"
+
 #define EMMC_BOOTCMD \
 	"set_emmcargs=setenv emmcargs ip=off root=PARTUUID=${uuid} "\
 		"rw,noatime rootfstype=ext4 " \
@@ -163,6 +174,7 @@
 	"fdt_fixup=;\0" \
 	MEM_LAYOUT_ENV_SETTINGS \
 	NFS_BOOTCMD \
+	UBOOT_UPDATE \
 	"setethupdate=if env exists ethaddr; then; else setenv ethaddr " \
 		"00:14:2d:00:00:00; fi; tftpboot ${loadaddr} " \
 		"flash_eth.img && source ${loadaddr}\0" \
Signature · 1 line
2.17.1
#4 lore raw

PATCH 3/5 colibri_imx6: add update_uboot wrapper

Hi Igor,

Quoted 27 lines

From: Igor Opaniuk <[email protected]>

Add universal update_uboot wrapper that helps to update U-Boot image on internal storage.

Quoted 4 lines

tftpboot ${loadaddr} ${board_name}/u-boot.img
run update_uboot
tftpboot ${loadaddr} ${board_name}/SPL
run update_spl

---

 include/configs/colibri_imx6.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
(quoted diff) +0 -0

b/include/configs/colibri_imx6.h index 95b5a14b59..750463ef47 100644

include/configs/colibri_imx6.h +3 -0
@@ -110,6 +110,17 @@
 	"imx6dl-colibri-eval-v3.dtb fat 0 1;" \
 	"imx6dl-colibri-cam-eval-v3.dtb fat 0 1"
 
+#define UBOOT_UPDATE \
+	"uboot_hwpart=1\0" \
+	"uboot_blk=8a\0" \

include/configs/colibri_imx6.h line 125

Quoted 10 lines
include/configs/colibri_imx6.h +8 -0
+	"uboot_spl_blk=2\0" \
+	"set_blkcnt=setexpr blkcnt ${filesize} + 0x1ff && " \
+		"setexpr blkcnt ${blkcnt} / 0x200\0" \
+	"update_uboot=run set_blkcnt && mmc dev 0 ${uboot_hwpart} &&
 " \
+		"mmc write ${loadaddr} ${uboot_blk} ${blkcnt}\0" \
+	"update_spl=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && "
 \
+		"mmc write ${loadaddr} ${uboot_spl_blk} ${blkcnt}\0"
+

Do you see any chance to make this code common and being re-usable by other imx6 devices?

include/configs/colibri_imx6.h line 180

Quoted 11 lines
include/configs/colibri_imx6.h +0 -0
 #define EMMC_BOOTCMD \
include/configs/colibri_imx6.h +1 -0
 	"set_emmcargs=setenv emmcargs ip=off root=PARTUUID=${uuid} "\
 		"rw,noatime rootfstype=ext4 " \
@@ -163,6 +174,7 @@
 	"fdt_fixup=;\0" \
 	MEM_LAYOUT_ENV_SETTINGS \
 	NFS_BOOTCMD \
+	UBOOT_UPDATE \
 	"setethupdate=if env exists ethaddr; then; else setenv
 ethaddr " \ "00:14:2d:00:00:00; fi; tftpboot ${loadaddr} " \
 		"flash_eth.img && source ${loadaddr}\0" \

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191204/7cd9cffc/attachment.sig>

#5 lore raw

PATCH 3/5 colibri_imx6: add update_uboot wrapper

Hi Lukasz,

Quoted 27 lines · Lukasz Majewski

Hi Igor,

Quoted 24 lines

From: Igor Opaniuk <[email protected]>

Add universal update_uboot wrapper that helps to update U-Boot image on internal storage.

Quoted 4 lines

tftpboot ${loadaddr} ${board_name}/u-boot.img
run update_uboot
tftpboot ${loadaddr} ${board_name}/SPL
run update_spl

---

 include/configs/colibri_imx6.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
(quoted diff) +0 -0

b/include/configs/colibri_imx6.h index 95b5a14b59..750463ef47 100644

include/configs/colibri_imx6.h +0 -0
@@ -110,6 +110,17 @@
      "imx6dl-colibri-eval-v3.dtb fat 0 1;" \
      "imx6dl-colibri-cam-eval-v3.dtb fat 0 1"
 
Quoted 16 lines

include/configs/colibri_imx6.h line 123

Quoted 13 lines
include/configs/colibri_imx6.h +11 -0
+#define UBOOT_UPDATE \
+     "uboot_hwpart=1\0" \
+     "uboot_blk=8a\0" \
+     "uboot_spl_blk=2\0" \
+     "set_blkcnt=setexpr blkcnt ${filesize} + 0x1ff && " \
+             "setexpr blkcnt ${blkcnt} / 0x200\0" \
+     "update_uboot=run set_blkcnt && mmc dev 0 ${uboot_hwpart} &&
 " \
+             "mmc write ${loadaddr} ${uboot_blk} ${blkcnt}\0" \
+     "update_spl=run set_blkcnt && mmc dev 0 ${uboot_hwpart} && "
 \
+             "mmc write ${loadaddr} ${uboot_spl_blk} ${blkcnt}\0"
+

Do you see any chance to make this code common and being re-usable by other imx6 devices?

Not sure, because:
1. Some platforms use "user" hw partition instead of boot0 for storing SPL/U-boot proper (AFAIK this is actual for i.MX6Q Sabre) IMHO, for this case it's much more convenient to use DFU/UMS/Fastboot (which is not possible for boot0/boot1) for flashing instead of some wrapper like this.
2. I don't have any mx6-based boards other than from Toradex, so at least I won't be
able to test it.

If you insist, I can add "update_uboot" to the common include, but to be honest I really doubt that someone will use it :)

Quoted 18 lines

include/configs/colibri_imx6.h line 180

Quoted 12 lines
include/configs/colibri_imx6.h +0 -0
 #define EMMC_BOOTCMD \
      "set_emmcargs=setenv emmcargs ip=off root=PARTUUID=${uuid} "\
              "rw,noatime rootfstype=ext4 " \
include/configs/colibri_imx6.h +1 -0
@@ -163,6 +174,7 @@
      "fdt_fixup=;\0" \
      MEM_LAYOUT_ENV_SETTINGS \
      NFS_BOOTCMD \
+     UBOOT_UPDATE \
      "setethupdate=if env exists ethaddr; then; else setenv
 ethaddr " \ "00:14:2d:00:00:00; fi; tftpboot ${loadaddr} " \
              "flash_eth.img && source ${loadaddr}\0" \

Best regards,

Quoted 7 lines

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de

Thanks
--
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk

#6 lore raw

PATCH 4/5 colibri-imx6ull: add update_uboot wrapper

In reply to Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Add universal update_uboot wrapper that helps to update U-Boot image on internal storage.

Usage example:

Quoted 2 lines

tftpboot ${loadaddr} ${board_name}/u-boot-nand.imx run update_uboot

---

 include/configs/colibri-imx6ull.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/configs/colibri-imx6ull.h +8 -0
index 0c36a57a0e..ac65ffdfd2 100644
@@ -47,6 +47,13 @@
 	"ramdisk_addr_r=0x82200000\0" \
 	"scriptaddr=0x87000000\0"
 
+#define UBOOT_UPDATE \
+	"uboot_hwpart=1\0" \
+	"update_uboot=nand erase.part u-boot1 && " \
+		"nand write ${loadaddr} u-boot1 ${filesize} && " \
+		"nand erase.part u-boot2 && " \
+		"nand write ${loadaddr} u-boot2 ${filesize}\0"
+
 #define NFS_BOOTCMD \
 	"nfsargs=ip=:::::eth0: root=/dev/nfs\0" \
 	"nfsboot=run setup; " \
@@ -83,6 +90,7 @@
 	MEM_LAYOUT_ENV_SETTINGS \
 	NFS_BOOTCMD \
 	UBI_BOOTCMD \
+	UBOOT_UPDATE \
 	"console=ttymxc0\0" \
 	"defargs=user_debug=30\0" \
 	"dfu_alt_info=" DFU_ALT_NAND_INFO "\0" \
Signature · 1 line
2.17.1
#7 lore raw

PATCH 5/5 colibri_vf: add update_uboot wrapper

In reply to Igor Opaniuk

From: Igor Opaniuk <[email protected]>

Add universal update_uboot wrapper that helps to update U-Boot image on internal storage.

Usage example:

Quoted 2 lines

tftpboot ${loadaddr} ${board_name}/u-boot-nand.imx run update_uboot

---

 include/configs/colibri_vf.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/configs/colibri_vf.h +6 -0
index 40c050a27e..53e4ae2702 100644
@@ -58,6 +58,11 @@
 	"ramdisk_addr_r=0x82100000\0" \
 	"scriptaddr=0x87000000\0"
 
+#define UBOOT_UPDATE \
+	"uboot_hwpart=1\0" \
+	"update_uboot=nand erase.part u-boot && " \
+		"nand write ${loadaddr} u-boot ${filesize}\0" \
+
 #define NFS_BOOTCMD \
 	"nfsargs=ip=:::::eth0: root=/dev/nfs\0"	\
 	"nfsboot=run setup; " \
@@ -112,6 +117,7 @@
 	NFS_BOOTCMD \
 	SD_BOOTCMD \
 	UBI_BOOTCMD \
+	UBOOT_UPDATE \
 	"console=ttyLP0\0" \
 	"defargs=user_debug=30\0" \
 	"dfu_alt_info=" DFU_ALT_NAND_INFO "\0" \
Signature · 1 line
2.17.1