Skip to contentSkip to conversation

tools: binman: etype: Allow to replace 'NAME' in node names

PATCH Superseded Paul HENRYS 2 participants 6 messages Nov 20, 2024 – Feb 17, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: binman: etype: Allow to replace 'NAME' in node names

This change allows to replace both 'SEQ' and 'NAME' keywords by respectively a sequence number and the name of the FDT to provide more flexibility in the node name for the device trees included in the FIT.

---
 tools/binman/etype/fit.py | 1 +
 1 file changed, 1 insertion(+)
tools/binman/etype/fit.py +1 -0
index e0c1ac08d8..b9ebc3afd0 100644
@@ -732,6 +732,7 @@ class Entry_fit(Entry_section):
                 # Generate nodes for each FDT
                 for seq, fdt_fname in enumerate(self._fdts):
                     node_name = node.name[1:].replace('SEQ', str(seq + 1))
+                    node_name = node_name.replace('NAME', fdt_fname)
                     if self._fdt_dir:
                         fname = os.path.join(self._fdt_dir, fdt_fname + '.dtb')
                     else:
Signature · 1 line
2.43.0
#1 lore raw

Hi Paul,

Quoted 4 lines · Paul HENRYS

This change allows to replace both 'SEQ' and 'NAME' keywords by respectively a sequence number and the name of the FDT to provide more flexibility in the node name for the device trees included in the FIT.

This seems OK to me, but it would help to understand the motivation better. Can you expand this a bit?

Quoted 19 lines
---
 tools/binman/etype/fit.py | 1 +
 1 file changed, 1 insertion(+)
tools/binman/etype/fit.py +1 -1
index e0c1ac08d8..b9ebc3afd0 100644
@@ -732,6 +732,7 @@ class Entry_fit(Entry_section):
                 # Generate nodes for each FDT
                 for seq, fdt_fname in enumerate(self._fdts):
                     node_name = node.name[1:].replace('SEQ', str(seq + 1))
+                    node_name = node_name.replace('NAME', fdt_fname)
                     if self._fdt_dir:
                         fname = os.path.join(self._fdt_dir, fdt_fname + '.dtb')
                     else:
--
Quoted 1 line

2.43.0

Please update the documentation (near the top of this file) and regenerate entries.rst

It also needs a test so that coverage passes (binman test -T)...

[..]

Regards,
Simon

#2 lore raw

Hi Simon,

Quoted 11 lines · Simon Glass

This Mail comes from Outside of SoftAtHome: Do not answer, click links or open attachments unless you recognize the sender and know the content is safe.

Hi Paul,

Quoted 3 lines · Paul HENRYS

This change allows to replace both 'SEQ' and 'NAME' keywords by respectively a sequence number and the name of the FDT to provide more flexibility in the node name for the device trees included in the FIT.

This seems OK to me, but it would help to understand the motivation better. Can you expand this a bit?

The rational behind this change is because some projects uses some kind of board data to look for the right config in a FIT image in U-Boot. The default sequence number (config-1, config-2...) does not make it easy to retrieve the right config in such a case. For instance, OpenWrt uses the script "scripts/mkits.sh" to create an ITS passed to mkimage, where the config node names can be customized when supporting multiple configs and typically uses the device tree name appended to "config-". The idea is thus to provide the flexibility in binman to use the traditional scheme with the sequence numbers (config-1, config-2...) or use NAME instead (e.g. config-myboard1, config-myboard2...) or a combination of both.

Quoted 23 lines
Quoted 19 lines
---
  tools/binman/etype/fit.py | 1 +
  1 file changed, 1 insertion(+)
tools/binman/etype/fit.py +1 -1
index e0c1ac08d8..b9ebc3afd0 100644
@@ -732,6 +732,7 @@ class Entry_fit(Entry_section):
                  # Generate nodes for each FDT
                  for seq, fdt_fname in enumerate(self._fdts):
                      node_name = node.name[1:].replace('SEQ', str(seq + 1))
+                    node_name = node_name.replace('NAME', fdt_fname)
                      if self._fdt_dir:
                          fname = os.path.join(self._fdt_dir, fdt_fname + '.dtb')
                      else:
--
Quoted 1 line

2.43.0

Please update the documentation (near the top of this file) and regenerate entries.rst

Quoted 1 line

It also needs a test so that coverage passes (binman test -T)...

Ok. I am going to update the documentation and add a test.

Quoted 5 lines

[..]

Regards,
Simon

Regards,
Paul

#3 lore raw

Hi Paul,

Quoted 15 lines · Paul HENRYS

Hi Simon,

Quoted 11 lines · Simon Glass

This Mail comes from Outside of SoftAtHome: Do not answer, click links or open attachments unless you recognize the sender and know the content is safe.

Hi Paul,

Quoted 3 lines · Paul HENRYS

This change allows to replace both 'SEQ' and 'NAME' keywords by respectively a sequence number and the name of the FDT to provide more flexibility in the node name for the device trees included in the FIT.

This seems OK to me, but it would help to understand the motivation better. Can you expand this a bit?

Quoted 11 lines

The rational behind this change is because some projects uses some kind of board data to look for the right config in a FIT image in U-Boot. The default sequence number (config-1, config-2...) does not make it easy to retrieve the right config in such a case. For instance, OpenWrt uses the script "scripts/mkits.sh" to create an ITS passed to mkimage, where the config node names can be customized when supporting multiple configs and typically uses the device tree name appended to "config-". The idea is thus to provide the flexibility in binman to use the traditional scheme with the sequence numbers (config-1, config-2...) or use NAME instead (e.g. config-myboard1, config-myboard2...) or a combination of both.

Sorry, I dropped this for ages.

You should use the compatible string, not the node name. What kind of board is this?

Quoted 24 lines
Quoted 23 lines
Quoted 19 lines
---
  tools/binman/etype/fit.py | 1 +
  1 file changed, 1 insertion(+)
tools/binman/etype/fit.py +1 -1
index e0c1ac08d8..b9ebc3afd0 100644
@@ -732,6 +732,7 @@ class Entry_fit(Entry_section):
                  # Generate nodes for each FDT
                  for seq, fdt_fname in enumerate(self._fdts):
                      node_name = node.name[1:].replace('SEQ', str(seq + 1))
+                    node_name = node_name.replace('NAME', fdt_fname)
                      if self._fdt_dir:
                          fname = os.path.join(self._fdt_dir, fdt_fname + '.dtb')
                      else:
--
Quoted 1 line

2.43.0

Please update the documentation (near the top of this file) and regenerate entries.rst

Quoted 1 line

It also needs a test so that coverage passes (binman test -T)...

Quoted 8 lines

Ok. I am going to update the documentation and add a test.

Quoted 5 lines

[..]

Regards,
Simon

Regards,
Paul

Regards,
Simon

#4 lore raw

Hi Simon,

Quoted 29 lines · Simon Glass

Hi Paul,

Quoted 14 lines · Paul HENRYS

Hi Simon,

Quoted 11 lines · Simon Glass

This Mail comes from Outside of SoftAtHome: Do not answer, click links or open attachments unless you recognize the sender and know the content is safe.

Hi Paul,

Quoted 3 lines · Paul HENRYS

This change allows to replace both 'SEQ' and 'NAME' keywords by respectively a sequence number and the name of the FDT to provide more flexibility in the node name for the device trees included in the FIT.

This seems OK to me, but it would help to understand the motivation better. Can you expand this a bit?

Quoted 11 lines

The rational behind this change is because some projects uses some kind of board data to look for the right config in a FIT image in U-Boot. The default sequence number (config-1, config-2...) does not make it easy to retrieve the right config in such a case. For instance, OpenWrt uses the script "scripts/mkits.sh" to create an ITS passed to mkimage, where the config node names can be customized when supporting multiple configs and typically uses the device tree name appended to "config-". The idea is thus to provide the flexibility in binman to use the traditional scheme with the sequence numbers (config-1, config-2...) or use NAME instead (e.g. config-myboard1, config-myboard2...) or a combination of both.

Quoted 4 lines

Sorry, I dropped this for ages.

You should use the compatible string, not the node name. What kind of board is this?

No worries but you actually reviewed this change and it was integrated in the master branch in the commit a4345b193479.

I agree that the compatibility property can be used and that might be a better practice but U-Boot current implementation also uses the configuration node names to select the configuration. Hereafter is my understanding of the implementation.

The configuration name (spec) in the FIT image can be passed to the bootm command, typically with such a command: bootm 0x1000000#config-1.

do_bootm() -> bootm_run_states() -> bootm_find_os() -> boot_get_kernel() -> genimg_get_kernel_addr_fit() -> fit_parse_conf()

The above sequence retrieves the configuration name passed through the bootm arguments and stored in fit_uname_config.

Later on, fit_image_load() is called in boot_get_kernel() and the previously configuration name stored in fit_uname_config can be used to retrieve the images to load. There are actually different solutions to retrieve the configuration and the images to be loaded:
  * Using the compatibility information if provided and when CONFIG_FIT_BEST_MATCH is enabled. This happens when calling fit_conf_find_compat() if fit_uname_config is NULL
  * Using the configuration node name when calling fit_conf_get_node() if no configuration could be previously found

So basically, U-Boot current implementation allows to use both compatibility property and the config node name from the FIT but so far only a sequence number could be set (config-1, config-2...). The proposed changes allow to also set a name based on the device tree names.

Quoted 25 lines
Quoted 25 lines
Quoted 23 lines
Quoted 19 lines
---
   tools/binman/etype/fit.py | 1 +
   1 file changed, 1 insertion(+)
tools/binman/etype/fit.py +1 -1
index e0c1ac08d8..b9ebc3afd0 100644
@@ -732,6 +732,7 @@ class Entry_fit(Entry_section):
                   # Generate nodes for each FDT
                   for seq, fdt_fname in enumerate(self._fdts):
                       node_name = node.name[1:].replace('SEQ', str(seq + 1))
+                    node_name = node_name.replace('NAME', fdt_fname)
                       if self._fdt_dir:
                           fname = os.path.join(self._fdt_dir, fdt_fname + '.dtb')
                       else:
--
Quoted 1 line

2.43.0

Please update the documentation (near the top of this file) and regenerate entries.rst

Quoted 1 line

It also needs a test so that coverage passes (binman test -T)...

Ok. I am going to update the documentation and add a test.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

[..]

Regards,
Simon

Regards,
Paul

Regards,
Simon

Regards,
Paul

#5 lore raw

Hi Paul,

Quoted 65 lines · Paul HENRYS

Hi Simon,

Quoted 29 lines · Simon Glass

Hi Paul,

Quoted 14 lines · Paul HENRYS

Hi Simon,

Quoted 11 lines · Simon Glass

This Mail comes from Outside of SoftAtHome: Do not answer, click links or open attachments unless you recognize the sender and know the content is safe.

Hi Paul,

Quoted 3 lines · Paul HENRYS

This change allows to replace both 'SEQ' and 'NAME' keywords by respectively a sequence number and the name of the FDT to provide more flexibility in the node name for the device trees included in the FIT.

This seems OK to me, but it would help to understand the motivation better. Can you expand this a bit?

Quoted 11 lines

The rational behind this change is because some projects uses some kind of board data to look for the right config in a FIT image in U-Boot. The default sequence number (config-1, config-2...) does not make it easy to retrieve the right config in such a case. For instance, OpenWrt uses the script "scripts/mkits.sh" to create an ITS passed to mkimage, where the config node names can be customized when supporting multiple configs and typically uses the device tree name appended to "config-". The idea is thus to provide the flexibility in binman to use the traditional scheme with the sequence numbers (config-1, config-2...) or use NAME instead (e.g. config-myboard1, config-myboard2...) or a combination of both.

Quoted 4 lines

Sorry, I dropped this for ages.

You should use the compatible string, not the node name. What kind of board is this?

No worries but you actually reviewed this change and it was integrated in the master branch in the commit a4345b193479.

I agree that the compatibility property can be used and that might be a better practice but U-Boot current implementation also uses the configuration node names to select the configuration. Hereafter is my understanding of the implementation.

The configuration name (spec) in the FIT image can be passed to the bootm command, typically with such a command: bootm 0x1000000#config-1.

do_bootm() -> bootm_run_states() -> bootm_find_os() -> boot_get_kernel() -> genimg_get_kernel_addr_fit() -> fit_parse_conf()

The above sequence retrieves the configuration name passed through the bootm arguments and stored in fit_uname_config.

Later on, fit_image_load() is called in boot_get_kernel() and the previously configuration name stored in fit_uname_config can be used to retrieve the images to load. There are actually different solutions to retrieve the configuration and the images to be loaded:
* Using the compatibility information if provided and when
CONFIG_FIT_BEST_MATCH is enabled. This happens when calling fit_conf_find_compat() if fit_uname_config is NULL
* Using the configuration node name when calling fit_conf_get_node()
if no configuration could be previously found

Quoted 4 lines

So basically, U-Boot current implementation allows to use both compatibility property and the config node name from the FIT but so far only a sequence number could be set (config-1, config-2...). The proposed changes allow to also set a name based on the device tree names.

As I think you have said here, the idea with 'bootm' is that it can automatically select the right configuration, if CONFIG_FIT_BEST_MATCH is enabled.

Thanks for the details above, it is a helpful summary.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 20 lines
---
   tools/binman/etype/fit.py | 1 +
   1 file changed, 1 insertion(+)
tools/binman/etype/fit.py +1 -1
index e0c1ac08d8..b9ebc3afd0 100644
@@ -732,6 +732,7 @@ class Entry_fit(Entry_section):
                   # Generate nodes for each FDT
                   for seq, fdt_fname in enumerate(self._fdts):
                       node_name = node.name[1:].replace('SEQ', str(seq + 1))
+                    node_name = node_name.replace('NAME', fdt_fname)
                       if self._fdt_dir:
                           fname = os.path.join(self._fdt_dir, fdt_fname + '.dtb')
                       else:
--
Quoted 1 line

2.43.0

Please update the documentation (near the top of this file) and regenerate entries.rst

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

It also needs a test so that coverage passes (binman test -T)...

Ok. I am going to update the documentation and add a test.

Quoted 2 lines

[..]

Regards,
Simon