binman: fit: skip empty data property for externally-provided images
cover binman: fit: skip empty data property for externally-provided images
When generating a FIT image with binman and storing its data externally to the FIT, an empty data property is still present in the FIT header, alongside the data-position and data-size properties.
This patch prevents the data property from being added when the image data is stored externally to the FIT.
The current implementation produces the following FIT structure with an empty data property:
/ {
timestamp = <0x6b00252a>;
description = "Kernel FIT";
label = "kernel";
phandle = <0x00000001>;
images {
kernel-1 {
data-size = <0x0096f890>;
data-position = <0x00001000>;
description = "Linux kernel";
type = "kernel";
os = "linux";
arch = "arm64";
data;
compression = "lzo";
load = <0x02f00000>;
entry = <0x02f00000>;
hash {
value = <0x8a206366 0xe4a74eb6 0xe0e65630 0x31543640 0xc999a554 0x0b446c28 0xbc23a525 0xb7459f15>;
algo = "sha256";
};
};
...Paul HENRYS (1):
binman: fit: skip empty data property for externally-provided images
tools/binman/etype/fit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
PATCH 1/1 binman: fit: skip empty data property for externally-provided images
When a FIT images node has its data provided via /incbin/ in the DTS rather than through a binman sub-entry, entry.GetData() returns empty bytes. Writing fsw.property('data', b'') in that case emits an empty 'data;' property into the intermediate ITB. When mkimage subsequently converts the FIT to external-data format (-E), it adds data-position and data-size but leaves the now-empty 'data;' property in place, producing an ambiguous node that carries both inline and external data attributes.
Skip the fsw.property() call when data is empty so that only nodes with actual binman-managed content get an inline data property, and nodes relying on /incbin/ sources end up with clean external-only attributes after mkimage processing.
--- tools/binman/etype/fit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/binman/etype/fit.py +2 -1
@@ -1047,7 +1047,8 @@ class Entry_fit(Entry_section): image_name = rel_path[len('/images/'):] entry = self._priv_entries[image_name] data = entry.GetData() - fsw.property('data', bytes(data)) + if data or 'data' not in node.props: + fsw.property('data', bytes(data)) for subnode in node.subnodes: if has_images and not self.IsSpecialSubnode(subnode):
Signature · 1 line
2.43.0
Hi Paul,
Quoted 25 lines · Paul HENRYS
When a FIT images node has its data provided via /incbin/ in the DTS rather than through a binman sub-entry,
entry.GetData()returns empty bytes. Writingfsw.property('data', b'')in that case emits an empty 'data;' property into the intermediate ITB. When mkimage subsequently converts the FIT to external-data format (-E), it adds data-position and data-size but leaves the now-empty 'data;' property in place, producing an ambiguous node that carries both inline and external data attributes.Skip the
fsw.property()call when data is empty so that only nodes with actual binman-managed content get an inline data property, and nodes relying on /incbin/ sources end up with clean external-only attributes after mkimage processing.Assisted-by Claude Sonnet 4.6Signed-off-by Paul HENRYS <[email protected]>--- tools/binman/etype/fit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tools/binman/etype/fit.py +0
-0
tools/binman/etype/fit.py class Entry_fit(Entry_section): · line 1050
Quoted 5 lines
tools/binman/etype/fit.py +1
-1@@ -1047,7 +1047,8 @@ class Entry_fit(Entry_section): image_name = rel_path[len('/images/'):] entry = self._priv_entries[image_name] data = entry.GetData() - fsw.property('data', bytes(data)) + if data or 'data' not in node.props:
question: why suddenly the check on 'data' property?
This seems like a different kind of fix, where we don't overwrite a data property already present in the FIT. I'm not even sure that's correct as binman has support for replacing entries in an image, and I'm assuming it should change the content of the data property as well.
issue: missing tests
We definitely need new tests in tools/binman/ftest.py to cover this bug fix to show that's an expected behavior.
Cheers,
Quentin
Hi Quentin,
Quoted 39 lines · Quentin Schulz
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 25 lines · Paul HENRYS
When a FIT images node has its data provided via /incbin/ in the DTS rather than through a binman sub-entry,
entry.GetData()returns empty bytes. Writingfsw.property('data', b'')in that case emits an empty 'data;' property into the intermediate ITB. When mkimage subsequently converts the FIT to external-data format (-E), it adds data-position and data-size but leaves the now-empty 'data;' property in place, producing an ambiguous node that carries both inline and external data attributes.Skip the
fsw.property()call when data is empty so that only nodes with actual binman-managed content get an inline data property, and nodes relying on /incbin/ sources end up with clean external-only attributes after mkimage processing.Assisted-by Claude Sonnet 4.6Signed-off-by Paul HENRYS <[email protected]>---
tools/binman/etype/fit.py| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)tools/binman/etype/fit.py +0
-0@@ -1047,7 +1047,8 @@ class Entry_fit(Entry_section):Quoted 5 lines
image_name= rel_path[len('/images/'):] entry = self._priv_entries[image_name] data =entry.GetData()
-fsw.property('data', bytes(data))+ if data or 'data' not in node.props:question: why suddenly the check on 'data' property?
Quoted 4 lines
This seems like a different kind of fix, where we don't overwrite a data property already present in the FIT. I'm not even sure that's correct as binman has support for replacing entries in an image, and I'm assuming it should change the content of the data property as well.
I was looking at something else and noticed an empty 'data' property was added to the final FIT image generated by binman when using the property data with "/incbin/" in the dts file passed to binman:
/dts-v1/;
/ {
binman {
fit {
fit,external-offset = <0x1000>;
images {
my-image {
data = /incbin/("myfile.bin"); };
};
};
};
};
When generating a FIT with such a config file passed to binman, trying to decompile the intermediate DTB with dtc generate the following error:
$ dtc -I dtb -O dts build/fit.itb <stdout>: ERROR (duplicate_property_names): /images/fdt:data: Duplicate property name ERROR: Input tree has errors, aborting (use -f to force output)
This being said, it might be that /incbin/ together with the data property should not be used to generate FIT images with binman. When using blob entry, the FIT image does not have the empty data property when storing the data externally. Nonetheless, I am also not sure blob entry should be used directly as mentioned in tools/binman/etype/blob.py.
Quoted 8 lines
issue: missing tests
We definitely need new tests in
tools/binman/ftest.pyto cover this bug fix to show that's an expected behavior.Cheers,
Quentin