Skip to contentSkip to conversation

config: Add 'update_bootimg' command to update flash.bin on Phytec's imx8mm

PATCH Superseded Lukasz Majewski 4 participants 7 messages Aug 6, 2024 – Aug 9, 2024 Arm i.MX and Layerscape

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 config: Add 'update_bootimg' command to update flash.bin on Phytec's imx8mm

This command allows easy update on SD card or eMMC of the flash.bin generated (with binman) during u-boot build.

---
Changes for v2:
- Remove 'update_mmc_part' variable
- Change path for hostname
- Use full version of dhcp command (${loadaddr} added)

Changes for v3:
- Remove +1 when calculating the size of binary to be written

---
 include/configs/phycore_imx8mm.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
include/configs/phycore_imx8mm.h +10 -0
index ce6dc87c69..361e665676 100644
@@ -29,6 +29,16 @@
 	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
 	"mmcpart=1\0" \
 	"mmcroot=2\0" \
+	"update_offset=0x42\0" \
+	"update_filename=flash.bin\0" \
+	"hostname=/srv/tftp/\0" \
+	"update_bootimg="						\
+		"mmc dev ${mmcdev} ; "		\
+		"if dhcp ${loadaddr} ${hostname}/${update_filename} ; then "	\
+		"setexpr fw_sz ${filesize} / 0x200 ; "	/* SD block size */ \
+		"setexpr fw_sz ${fw_sz} ; "				\
+		"mmc write ${loadaddr} ${update_offset} ${fw_sz} ; "	\
+		"fi\0" \
 	"mmcautodetect=yes\0" \
 	"mmcargs=setenv bootargs console=${console} " \
 		"root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait rw\0" \
Signature · 1 line
2.39.2
reviewer
#1 lore raw

Hi Lukasz,

Quoted 5 lines · Lukasz Majewski

This command allows easy update on SD card or eMMC of the flash.bin generated (with binman) during u-boot build.

Quoted 8 lines

---
Changes for v2:
- Remove 'update_mmc_part' variable
- Change path for hostname
- Use full version of dhcp command (${loadaddr} added)

Changes for v3:
- Remove +1 when calculating the size of binary to be written

It looks good to me now.

Teresa/Benjamin/Cem,

Are you happy with this version?

Thanks

#2 lore raw
In reply to Lukasz Majewski

Hi Lukasz,

Quoted 21 lines · Lukasz Majewski

This command allows easy update on SD card or eMMC of the flash.bin generated (with binman) during u-boot build.

---
Changes for v2:
- Remove 'update_mmc_part' variable
- Change path for hostname
- Use full version of dhcp command (${loadaddr} added)

Changes for v3:
- Remove +1 when calculating the size of binary to be written

---
  include/configs/phycore_imx8mm.h | 10 ++++++++++
  1 file changed, 10 insertions(+)
include/configs/phycore_imx8mm.h +0 -0
index ce6dc87c69..361e665676 100644

include/configs/phycore_imx8mm.h line 37

Quoted 9 lines
include/configs/phycore_imx8mm.h +6 -0
@@ -29,6 +29,16 @@
  	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
  	"mmcpart=1\0" \
  	"mmcroot=2\0" \
+	"update_offset=0x42\0" \
+	"update_filename=flash.bin\0" \
+	"hostname=/srv/tftp/\0" \
+	"update_bootimg="						\
+		"mmc dev ${mmcdev} ; "		\
+		"if dhcp ${loadaddr} ${hostname}/${update_filename} ; then "	\

The dhcp and tftp command should take the filepath from the tftp directory and get the tftp directory automatically not the absolute path. So this will try to get the file from /path_to_tftp_folder/srv/tftp/flash.bin and will fail because it can't find it. So you can drop the ${hostname}.
Also drop the initialization of ${hostname} above since it is no longer needed.

Should be like this:

dhcp ${loadaddr} ${update_filename}

include/configs/phycore_imx8mm.h line 39

Quoted 2 lines
include/configs/phycore_imx8mm.h +2 -0
+		"setexpr fw_sz ${filesize} / 0x200 ; "	/* SD block size */ \
+		"setexpr fw_sz ${fw_sz} ; "

I think you can drop this line since it does not do anything.

Benjamin

Quoted 6 lines
include/configs/phycore_imx8mm.h +2 -0
 				\
+		"mmc write ${loadaddr} ${update_offset} ${fw_sz} ; "	\
+		"fi\0" \
  	"mmcautodetect=yes\0" \
  	"mmcargs=setenv bootargs console=${console} " \
  		"root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait rw\0" \
#3 lore raw

Hi Benjamin,

Quoted 32 lines

Hi Lukasz,

Quoted 29 lines · Lukasz Majewski

This command allows easy update on SD card or eMMC of the flash.bin generated (with binman) during u-boot build.

---
Changes for v2:
- Remove 'update_mmc_part' variable
- Change path for hostname
- Use full version of dhcp command (${loadaddr} added)

Changes for v3:
- Remove +1 when calculating the size of binary to be written

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

b/include/configs/phycore_imx8mm.h index ce6dc87c69..361e665676 100644 --- a/include/configs/phycore_imx8mm.h
+++ b/include/configs/phycore_imx8mm.h

include/configs/phycore_imx8mm.h +4 -0
@@ -29,6 +29,16 @@
  	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
  	"mmcpart=1\0" \
  	"mmcroot=2\0" \
+	"update_offset=0x42\0" \
+	"update_filename=flash.bin\0" \
+	"hostname=/srv/tftp/\0" \
+	"update_bootimg="
 	\
Quoted 8 lines

Review line 39

Quoted 3 lines
(quoted diff) +2 -0
+		"mmc dev ${mmcdev} ; "		\
+		"if dhcp ${loadaddr}
 ${hostname}/${update_filename} ; then "	\  

The dhcp and tftp command should take the filepath from the tftp directory and get the tftp directory automatically not the absolute path. So this will try to get the file from /path_to_tftp_folder/srv/tftp/flash.bin and will fail

And that is why you do have the ${hostname}/${update_filename}, so when you have several exported directories - you can specify which one without the need to modify the 'update_bootimg' command.

Quoted 2 lines

because it
can't find it. So you can drop the ${hostname}.

I would prefer to keep the ${hostname}/${update_filename} part.

Quoted 7 lines

Also drop the initialization of ${hostname} above since it is no longer needed.

Should be like this:

dhcp ${loadaddr} ${update_filename}

IMHO the line shall be:

dhcp ${loadaddr} ${hostname}/${update_filename}

Quoted 5 lines

Review line 42

Quoted 3 lines
(quoted diff) +2 -0
+		"setexpr fw_sz ${filesize} / 0x200 ; "	/*
 SD block size */ \
+		"setexpr fw_sz ${fw_sz} ; "  

I think you can drop this line since it does not do anything.

Ok.

Quoted 11 lines

Benjamin

Quoted 8 lines
				\
(quoted diff) +1 -0
+		"mmc write ${loadaddr} ${update_offset} ${fw_sz} ;

" \

include/configs/phycore_imx8mm.h +1 -0
+		"fi\0" \
  	"mmcautodetect=yes\0" \
  	"mmcargs=setenv bootargs console=${console} " \
  		"root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait

rw\0" \

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [email protected]

#4 lore raw

Hello Lukasz,

Am Mittwoch, dem 07.08.2024 um 13:04 +0200 schrieb Lukasz Majewski:

Quoted 44 lines

Hi Benjamin,

Quoted 33 lines

Hi Lukasz,

Quoted 30 lines · Lukasz Majewski

This command allows easy update on SD card or eMMC of the flash.bin
generated (with binman) during u-boot build.

---
Changes for v2:
- Remove 'update_mmc_part' variable
- Change path for hostname
- Use full version of dhcp command (${loadaddr} added)

Changes for v3:
- Remove +1 when calculating the size of binary to be written
---
  include/configs/phycore_imx8mm.h | 10 ++++++++++

  1 file changed, 10 insertions(+)
(quoted diff) +0 -0

b/include/configs/phycore_imx8mm.h index ce6dc87c69..361e665676 100644 --- a/include/configs/phycore_imx8mm.h
+++ b/include/configs/phycore_imx8mm.h

include/configs/phycore_imx8mm.h +4 -0
@@ -29,6 +29,16 @@
         "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
         "mmcpart=1\0" \
         "mmcroot=2\0" \
+       "update_offset=0x42\0" \
+       "update_filename=flash.bin\0" \
+       "hostname=/srv/tftp/\0" \
+       "update_bootimg="
         \
Quoted 8 lines

Review line 39

Quoted 3 lines
(quoted diff) +2 -0
+               "mmc dev ${mmcdev} ; "          \
+               "if dhcp ${loadaddr}
 ${hostname}/${update_filename} ; then " \  

The dhcp and tftp command should take the filepath from the tftp directory and get the tftp directory automatically not the absolute path. So this will try to get the file from /path_to_tftp_folder/srv/tftp/flash.bin and will fail

Quoted 4 lines

And that is why you do have the ${hostname}/${update_filename}, so when
you have several exported directories - you can specify which one without the need to modify the 'update_bootimg' command.

do I understand it correct that you just want to be able to define sub dirs with a variable? This does make sense but you should not pre- define them here.

And I think the variable name $hostname is kind of miss leading. Maybe you can find some different name for it?

Regards,
Teresa

Quoted 52 lines
Quoted 3 lines

because it
can't find it. So you can drop the ${hostname}.

I would prefer to keep the ${hostname}/${update_filename} part.

Quoted 7 lines

Also drop the initialization of ${hostname} above since it is no longer needed.

Should be like this:

dhcp ${loadaddr} ${update_filename}

IMHO the line shall be:

dhcp ${loadaddr} ${hostname}/${update_filename}

Quoted 5 lines

Review line 42

Quoted 3 lines
(quoted diff) +2 -0
+               "setexpr fw_sz ${filesize} / 0x200 ; "  /*
 SD block size */ \
+               "setexpr fw_sz ${fw_sz} ; "  

I think you can drop this line since it does not do anything.

Ok.

Quoted 12 lines

Benjamin

Quoted 9 lines

                                \
+               "mmc write ${loadaddr} ${update_offset} ${fw_sz} ;
"       \
+               "fi\0" \
        "mmcautodetect=yes\0" \
        "mmcargs=setenv bootargs console=${console} " \
                "root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait rw\0" \

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
[email protected]

Signature · 5 lines
PHYTEC Messtechnik GmbH | Barcelona-Allee 1 | 55129 Mainz, Germany

Geschäftsführer: Dipl.-Ing. Michael Mitezki, Dipl.-Ing. Bodo Huber,
Dipl.-Ing. (FH) Markus Lickes | Handelsregister Mainz HRB 4656 |
Finanzamt Mainz | St.Nr. 266500608, DE 149059855
#5 lore raw

Hi Teresa,

Quoted 47 lines

Hello Lukasz,

Am Mittwoch, dem 07.08.2024 um 13:04 +0200 schrieb Lukasz Majewski:

Quoted 44 lines

Hi Benjamin,

Quoted 41 lines

Hi Lukasz,

Quoted 23 lines · Lukasz Majewski

This command allows easy update on SD card or eMMC of the flash.bin
generated (with binman) during u-boot build.

---
Changes for v2:
- Remove 'update_mmc_part' variable
- Change path for hostname
- Use full version of dhcp command (${loadaddr} added)

Changes for v3:
- Remove +1 when calculating the size of binary to be written
---
  include/configs/phycore_imx8mm.h | 10 ++++++++++

  1 file changed, 10 insertions(+)
(quoted diff) +0 -0

b/include/configs/phycore_imx8mm.h index ce6dc87c69..361e665676 100644 --- a/include/configs/phycore_imx8mm.h
+++ b/include/configs/phycore_imx8mm.h

include/configs/phycore_imx8mm.h +0 -0
@@ -29,6 +29,16 @@
         "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \

include/configs/phycore_imx8mm.h line 39

Quoted 10 lines
include/configs/phycore_imx8mm.h +6 -0
         "mmcpart=1\0" \
         "mmcroot=2\0" \
+       "update_offset=0x42\0" \
+       "update_filename=flash.bin\0" \
+       "hostname=/srv/tftp/\0" \
+       "update_bootimg="
         \
+               "mmc dev ${mmcdev} ; "          \
+               "if dhcp ${loadaddr}
 ${hostname}/${update_filename} ; then " \    

The dhcp and tftp command should take the filepath from the tftp directory and get the tftp directory automatically not the absolute path. So this will try to get the file from /path_to_tftp_folder/srv/tftp/flash.bin and will fail

Quoted 7 lines
Quoted 4 lines

And that is why you do have the ${hostname}/${update_filename}, so when
you have several exported directories - you can specify which one without the need to modify the 'update_bootimg' command.

do I understand it correct that you just want to be able to define sub dirs with a variable?

Yes, correct.

Quoted 2 lines

This does make sense but you should not pre-
define them here.

Ok. I will remove the "hostname=/srv/tftp" environment variable.

Quoted 3 lines

And I think the variable name $hostname is kind of miss leading. Maybe you can find some different name for it?

The ${hostname} is used in a few places already in that way. Maybe you have better idea for this variable's name?

Quoted 57 lines

Regards,
Teresa

Quoted 52 lines
Quoted 3 lines

because it
can't find it. So you can drop the ${hostname}.

I would prefer to keep the ${hostname}/${update_filename} part.

Quoted 7 lines

Also drop the initialization of ${hostname} above since it is no longer needed.

Should be like this:

dhcp ${loadaddr} ${update_filename}

IMHO the line shall be:

dhcp ${loadaddr} ${hostname}/${update_filename}

Quoted 5 lines

Review line 42

Quoted 3 lines
(quoted diff) +2 -0
+               "setexpr fw_sz ${filesize} / 0x200 ; "  /*
 SD block size */ \
+               "setexpr fw_sz ${fw_sz} ; "    

I think you can drop this line since it does not do anything.

Ok.

Quoted 12 lines

Benjamin

Quoted 9 lines

                                \
+               "mmc write ${loadaddr} ${update_offset} ${fw_sz} ;
"       \
+               "fi\0" \
        "mmcautodetect=yes\0" \
        "mmcargs=setenv bootargs console=${console} " \
                "root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait rw\0" \

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
[email protected]

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [email protected]

#6 lore raw

Hello Lukasz

Am Donnerstag, dem 08.08.2024 um 12:25 +0200 schrieb Lukasz Majewski:

Quoted 69 lines

Hi Teresa,

Quoted 55 lines

Hello Lukasz,

Am Mittwoch, dem 07.08.2024 um 13:04 +0200 schrieb Lukasz Majewski:

Quoted 46 lines

Hi Benjamin,

Quoted 35 lines

Hi Lukasz,

Quoted 32 lines · Lukasz Majewski

This command allows easy update on SD card or eMMC of the flash.bin
generated (with binman) during u-boot build.

---
Changes for v2:
- Remove 'update_mmc_part' variable
- Change path for hostname
- Use full version of dhcp command (${loadaddr} added)

Changes for v3:
- Remove +1 when calculating the size of binary to be written
---
  include/configs/phycore_imx8mm.h | 10 ++++++++++

  1 file changed, 10 insertions(+)
(quoted diff) +0 -0

b/include/configs/phycore_imx8mm.h index
ce6dc87c69..361e665676
100644 --- a/include/configs/phycore_imx8mm.h
+++ b/include/configs/phycore_imx8mm.h

include/configs/phycore_imx8mm.h +5 -0
@@ -29,6 +29,16 @@
         "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
         "mmcpart=1\0" \
         "mmcroot=2\0" \
+       "update_offset=0x42\0" \
+       "update_filename=flash.bin\0" \
+       "hostname=/srv/tftp/\0" \
+       "update_bootimg="
         \
+               "mmc dev ${mmcdev} ; "          \
Quoted 8 lines

Review line 39

Quoted 2 lines
(quoted diff) +1 -0
+               "if dhcp ${loadaddr}
 ${hostname}/${update_filename} ; then " \    

The dhcp and tftp command should take the filepath from the tftp
directory and get the tftp directory automatically not the absolute path. So this will try to get the file from /path_to_tftp_folder/srv/tftp/flash.bin and will fail

Quoted 5 lines

And that is why you do have the ${hostname}/${update_filename}, so
when
you have several exported directories - you can specify which one without the need to modify the 'update_bootimg' command.

Quoted 3 lines

do I understand it correct that you just want to be able to define sub
dirs with a variable?

Yes, correct.

Quoted 2 lines

This does make sense but you should not pre-
define them here.

Ok. I will remove the "hostname=/srv/tftp" environment variable.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

And I think the variable name $hostname is kind of miss leading. Maybe
you can find some different name for it?

The ${hostname} is used in a few places already in that way. Maybe you
have better idea for this variable's name?

As it is ${update_filename} maybe ${update_filepath}?

Teresa

Quoted 77 lines
Quoted 63 lines

Regards,
Teresa

Quoted 57 lines

Quoted 2 lines

because it
can't find it. So you can drop the ${hostname}.

I would prefer to keep the ${hostname}/${update_filename} part.

Quoted 8 lines

Also drop the initialization of ${hostname} above since it is no
longer needed.

Should be like this:

dhcp ${loadaddr} ${update_filename}

IMHO the line shall be:

dhcp ${loadaddr} ${hostname}/${update_filename}

Quoted 5 lines

Review line 42

Quoted 3 lines
(quoted diff) +2 -0
+               "setexpr fw_sz ${filesize} / 0x200 ; "  /*
 SD block size */ \
+               "setexpr fw_sz ${fw_sz} ; "    

I think you can drop this line since it does not do anything.

Ok.

Quoted 13 lines

Benjamin

Quoted 11 lines

                                \
+               "mmc write ${loadaddr} ${update_offset} ${fw_sz}
;
"       \
+               "fi\0" \
        "mmcautodetect=yes\0" \
        "mmcargs=setenv bootargs console=${console} " \
                "root=/dev/mmcblk${mmcdev}p${mmcroot} rootwait
rw\0" \

Quoted 1 line

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
[email protected]

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
[email protected]

Signature · 5 lines
PHYTEC Messtechnik GmbH | Barcelona-Allee 1 | 55129 Mainz, Germany

Geschäftsführer: Dipl.-Ing. Michael Mitezki, Dipl.-Ing. Bodo Huber,
Dipl.-Ing. (FH) Markus Lickes | Handelsregister Mainz HRB 4656 |
Finanzamt Mainz | St.Nr. 266500608, DE 149059855