spl: Align device tree blob address at 8-byte boundary
PATCH 1/1 spl: Align device tree blob address at 8-byte boundary
Since libfdt v1.6.1, a new requirement on the device tree address via:
commit 5e735860c478 ("libfdt: Check for 8-byte address alignment in fdt_ro_probe_()")
must be met that the device tree must be loaded in to memory at an 8-byte aligned address.
---
common/spl/spl_fit.c | 6 ++++++ 1 file changed, 6 insertions(+)
common/spl/spl_fit.c +6 -0
@@ -374,6 +374,12 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,*/ image_info.load_addr = spl_image->load_addr + spl_image->size; +/* +* Since libfdt v1.6.1, the device tree must be loaded in to memory +* at an 8-byte aligned address. +*/ + image_info.load_addr =roundup (image_info.load_addr,8 ); +/* Figure out which device tree the board wants to use */ node =spl_fit_get_image_node (ctx,FIT_FDT_PROP , index++);if (node <0 ) {
Signature · 1 line
2.25.1
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Quoted 42 lines
-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Monday, 12 July 2021 3:53 pm
To: Tom Rini <[email protected]>; Simon Glass <[email protected]>; u- [email protected]
Cc: Bin Meng <[email protected]>
Subject: [PATCH] spl: Align device tree blob address at 8-byte boundarySince libfdt v1.6.1, a new requirement on the device tree address via:
commit
5e735860c478("libfdt: Check for 8-byte address alignment infdt_ro_probe_()")must be met that the device tree must be loaded in to memory at an 8-byte aligned address.
Signed-off-by Bin Meng <[email protected]>---
common/spl/spl_fit.c | 6 ++++++ 1 file changed, 6 insertions(+)common/spl/spl_fit.c index renamed from common/spl/spl_fit.c +0
-0
f41abca0cc..9baf6aca9f100644common/spl/spl_fit.c +6
-0@@ -374,6 +374,12 @@ static int spl_fit_append_fdt(struct spl_image_info*spl_image, */ image_info.load_addr = spl_image->load_addr + spl_image->size; +/* +* Since libfdt v1.6.1, the device tree must be loaded in to memory +* at an 8-byte aligned address. +*/ + image_info.load_addr =roundup (image_info.load_addr,8 ); +/* Figure out which device tree the board wants to use */ node =spl_fit_get_image_node (ctx,FIT_FDT_PROP , index++);if (node < 0) {
--
2.25.1
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
Note, as I indicated in this patch, now with libfdt 1.6.1, the alignment to 8 byte is a must-have. So we have to do such alignment anyway.
@Tom may fill in why libfdt commit commit 5e735860c478 ("libfdt: Check for 8-byte address alignment in fdt_ro_probe_()") was made to have the 8-byte alignment requirement.
Quoted 32 lines
-----Original Message-----
Quoted 30 lines
From: U-Boot <[email protected]> On Behalf Of Bin Meng
Sent: Monday, 12 July 2021 3:53 pm
To: Tom Rini <[email protected]>; Simon Glass <[email protected]>; u- [email protected]
Cc: Bin Meng <[email protected]>
Subject: [PATCH] spl: Align device tree blob address at 8-byte boundarySince libfdt v1.6.1, a new requirement on the device tree address via:
commit
5e735860c478("libfdt: Check for 8-byte address alignment infdt_ro_probe_()")must be met that the device tree must be loaded in to memory at an 8-byte aligned address.
Signed-off-by Bin Meng <[email protected]>---
common/spl/spl_fit.c | 6 ++++++ 1 file changed, 6 insertions(+)common/spl/spl_fit.c index renamed from common/spl/spl_fit.c +0
-0
f41abca0cc..9baf6aca9f100644common/spl/spl_fit.c +0
-0@@ -374,6 +374,12 @@ static int spl_fit_append_fdt(struct spl_image_info*spl_image, */ image_info.load_addr = spl_image->load_addr + spl_image->size;
Quoted 10 lines
Quoted 10 lines
common/spl/spl_fit.c +6
-0+/* +* Since libfdt v1.6.1, the device tree must be loaded in to memory +* at an 8-byte aligned address. +*/ +image_info.load_addr =roundup (image_info.load_addr,8 ); +/* Figure out which device tree the board wants to use */ node =spl_fit_get_image_node (ctx,FIT_FDT_PROP , index++);if (node < 0) {
--
Regards,
Bin
Quoted 12 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
Quoted 8 lines
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
Quoted 7 lines
Note, as I indicated in this patch, now with libfdt 1.6.1, the alignment to 8 byte is a must-have. So we have to do such alignment anyway.
@Tom may fill in why libfdt commit commit
5e735860c478("libfdt: Check for 8-byte address alignment infdt_ro_probe_()") was made to have the 8-byte alignment requirement.
Note that it's not so much since libfdt 1.6.1 but that since always the device tree has required 8 byte alignment. It's just that on 32bit platforms 4-but-not-8 byte alignment tends to not be fatal but on 64bit platforms it is.
Signature · 1 line
Tom
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."
Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
If I recall this correctly, DT node alignment is 4 byte and that is what DTC emits. If you have fitImage with embedded data, you basically end up with
/ {
prop1 = "string1";
prop2 = "string2";
};
where the "string2" is aligned to 4 bytes. And that is what U-Boot expects when it tries to access those data in-place in SPL.
The problem with the reverted patch was that it made U-Boot assume the alignment is 8 bytes, and that actually works only if you use fitImage with external data (mkimage -E), but with embedded data (mkimage default) not so much. That caused off-by-4 error in some cases and that made the SPL hang.
Quoted 10 lines
Quoted 7 lines
Note, as I indicated in this patch, now with libfdt 1.6.1, the alignment to 8 byte is a must-have. So we have to do such alignment anyway.
@Tom may fill in why libfdt commit commit
5e735860c478("libfdt: Check for 8-byte address alignment infdt_ro_probe_()") was made to have the 8-byte alignment requirement.Note that it's not so much since libfdt 1.6.1 but that since always the device tree has required 8 byte alignment.
DT alignment was always 4 byte , no ?
Quoted 3 lines
It's just that on 32bit
platforms 4-but-not-8 byte alignment tends to not be fatal but on 64bit platforms it is.
[...]
Quoted 47 lines · Marek Vasut
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
If I recall this correctly, DT node alignment is 4 byte and that is what DTC emits. If you have fitImage with embedded data, you basically end up with
/ {
prop1 = "string1";
prop2 = "string2";
};where the "string2" is aligned to 4 bytes. And that is what U-Boot expects when it tries to access those data in-place in SPL.
The problem with the reverted patch was that it made U-Boot assume the alignment is 8 bytes, and that actually works only if you use fitImage with external data (mkimage -E), but with embedded data (mkimage default) not so much. That caused off-by-4 error in some cases and that made the SPL hang.
Quoted 4 lines
Quoted 4 lines
Note, as I indicated in this patch, now with libfdt 1.6.1, the alignment to 8 byte is a must-have. So we have to do such alignment anyway.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
@Tom may fill in why libfdt commit commit
5e735860c478("libfdt: Check for 8-byte address alignment infdt_ro_probe_()") was made to have the 8-byte alignment requirement.Note that it's not so much since libfdt 1.6.1 but that since always the device tree has required 8 byte alignment.
DT alignment was always 4 byte , no ?
I'm pretty sure, no, 8 byte base alignment is a pretty much always thing. I don't have a reference handy but I also know I couldn't have convinced dgibson to add the check otherwise.
Signature · 1 line
Tom
Quoted 52 lines · Tom Rini
Quoted 51 lines · Marek Vasut
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
If I recall this correctly, DT node alignment is 4 byte and that is what DTC emits. If you have fitImage with embedded data, you basically end up with
/ {
prop1 = "string1";
prop2 = "string2";
};where the "string2" is aligned to 4 bytes. And that is what U-Boot expects when it tries to access those data in-place in SPL.
The problem with the reverted patch was that it made U-Boot assume the alignment is 8 bytes, and that actually works only if you use fitImage with external data (mkimage -E), but with embedded data (mkimage default) not so much. That caused off-by-4 error in some cases and that made the SPL hang.
Quoted 8 lines
Quoted 7 lines
Note, as I indicated in this patch, now with libfdt 1.6.1, the alignment to 8 byte is a must-have. So we have to do such alignment anyway.
@Tom may fill in why libfdt commit commit
5e735860c478("libfdt: Check for 8-byte address alignment infdt_ro_probe_()") was made to have the 8-byte alignment requirement.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Note that it's not so much since libfdt 1.6.1 but that since always the device tree has required 8 byte alignment.
DT alignment was always 4 byte , no ?
I'm pretty sure, no, 8 byte base alignment is a pretty much always thing. I don't have a reference handy but I also know I couldn't have convinced dgibson to add the check otherwise.
DTSpec rev 0.3 says the following and I think you got confused by section 5.6 which talks about alignment of the entire tree, not its nodes:
5.4 Structure Block
"
Each token in the structure block, and thus the structure block itself, shall be located at a 4-byte aligned offset from the beginning of the devicetree blob (see 5.6).
"
5.4.2 Tree structure
"
For each property of the node:
...
– FDT_PROP token
...
* [zeroed padding bytes to align to a 4-byte boundary] "
5.5 Strings Block
"
The strings block contains strings representing all the property names used in the tree. These null terminated strings are simply concatenated together in this section, and referred to from the structure block by an offset into the strings block. The strings block has no alignment constraints and may appear at any offset from the beginning of the devicetree blob. "
5.6 Alignment
"
As described in the previous sections, the structure and strings blocks shall have aligned offsets from the beginning of the devicetree blob. To ensure the in-memory alignment of the blocks, it is sufficient to ensure that the devicetree as a whole is loaded at an address aligned to the largest alignment of any of the subblocks, that is, to an 8-byte boundary. "
Quoted 91 lines · Marek Vasut
Quoted 52 lines · Tom Rini
Quoted 51 lines · Marek Vasut
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
If I recall this correctly, DT node alignment is 4 byte and that is what DTC emits. If you have fitImage with embedded data, you basically end up with
/ {
prop1 = "string1";
prop2 = "string2";
};where the "string2" is aligned to 4 bytes. And that is what U-Boot expects when it tries to access those data in-place in SPL.
The problem with the reverted patch was that it made U-Boot assume the alignment is 8 bytes, and that actually works only if you use fitImage with external data (mkimage -E), but with embedded data (mkimage default) not so much. That caused off-by-4 error in some cases and that made the SPL hang.
Quoted 8 lines
Quoted 7 lines
Note, as I indicated in this patch, now with libfdt 1.6.1, the alignment to 8 byte is a must-have. So we have to do such alignment anyway.
@Tom may fill in why libfdt commit commit
5e735860c478("libfdt: Check for 8-byte address alignment infdt_ro_probe_()") was made to have the 8-byte alignment requirement.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Note that it's not so much since libfdt 1.6.1 but that since always the device tree has required 8 byte alignment.
DT alignment was always 4 byte , no ?
I'm pretty sure, no, 8 byte base alignment is a pretty much always thing. I don't have a reference handy but I also know I couldn't have convinced dgibson to add the check otherwise.
DTSpec rev 0.3 says the following and I think you got confused by section 5.6 which talks about alignment of the entire tree, not its nodes:
5.4 Structure Block
"
Each token in the structure block, and thus the structure block itself, shall be located at a 4-byte aligned offset from the beginning of the devicetree blob (see 5.6).
"5.4.2 Tree structure
"
For each property of the node:
...
–FDT_PROPtoken
...
* [zeroed padding bytes to align to a 4-byte boundary] "5.5 Strings Block
"
The strings block contains strings representing all the property names used in the tree. These null terminated strings are
simply concatenated together in this section, and referred to from the structure block by an offset into the strings block.
The strings block has no alignment constraints and may appear at any offset from the beginning of the devicetree blob.
"
Quoted 8 lines
5.6 Alignment
"
As described in the previous sections, the structure and strings blocks shall have aligned offsets from the beginning of
the devicetree blob. To ensure the in-memory alignment of the blocks, it is sufficient to ensure that the devicetree as a
whole is loaded at an address aligned to the largest alignment of any of the subblocks, that is, to an 8-byte boundary.
Right. A device tree must start at an 8-byte boundary and U-Boot was violating this both with:
- All of the boards that use fdt_high=0xffffffff to disable relocation, and then then place things at arbitrary spots in memory that may or may not violate these requirements.
- Perhaps some of the FIT internals where we have a device tree inside a device tree? And we need to fixup whatever we're doing there that's wrong.
Signature · 1 line
Tom
Quoted 101 lines · Tom Rini
Quoted 91 lines · Marek Vasut
Quoted 52 lines · Tom Rini
Quoted 51 lines · Marek Vasut
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
If I recall this correctly, DT node alignment is 4 byte and that is what DTC emits. If you have fitImage with embedded data, you basically end up with
/ { prop1 = "string1"; prop2 = "string2"; };where the "string2" is aligned to 4 bytes. And that is what U-Boot expects when it tries to access those data in-place in SPL.
The problem with the reverted patch was that it made U-Boot assume the alignment is 8 bytes, and that actually works only if you use fitImage with external data (mkimage -E), but with embedded data (mkimage default) not so much. That caused off-by-4 error in some cases and that made the SPL hang.
Quoted 8 lines
Quoted 7 lines
Note, as I indicated in this patch, now with libfdt 1.6.1, the alignment to 8 byte is a must-have. So we have to do such alignment anyway.
@Tom may fill in why libfdt commit commit
5e735860c478("libfdt: Check for 8-byte address alignment infdt_ro_probe_()") was made to have the 8-byte alignment requirement.Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Note that it's not so much since libfdt 1.6.1 but that since always the device tree has required 8 byte alignment.
DT alignment was always 4 byte , no ?
I'm pretty sure, no, 8 byte base alignment is a pretty much always thing. I don't have a reference handy but I also know I couldn't have convinced dgibson to add the check otherwise.
DTSpec rev 0.3 says the following and I think you got confused by section 5.6 which talks about alignment of the entire tree, not its nodes:
5.4 Structure Block
"
Each token in the structure block, and thus the structure block itself, shall be located at a 4-byte aligned offset from the beginning of the devicetree blob (see 5.6).
"5.4.2 Tree structure
"
For each property of the node:
...
–FDT_PROPtoken
...
* [zeroed padding bytes to align to a 4-byte boundary] "5.5 Strings Block
"
The strings block contains strings representing all the property names used in the tree. These null terminated strings are
simply concatenated together in this section, and referred to from the structure block by an offset into the strings block.
The strings block has no alignment constraints and may appear at any offset from the beginning of the devicetree blob.
"Quoted 8 lines
5.6 Alignment
"
As described in the previous sections, the structure and strings blocks shall have aligned offsets from the beginning of
the devicetree blob. To ensure the in-memory alignment of the blocks, it is sufficient to ensure that the devicetree as a
whole is loaded at an address aligned to the largest alignment of any of the subblocks, that is, to an 8-byte boundary.
Quoted 1 line
Right. A device tree must start at an 8-byte boundary
Start, yes ; string alignment, no.
Quoted 3 lines
and U-Boot was
violating this both with:
- All of the boards that use fdt_high=0xffffffff to disable relocation,
Not applicable to SPL case.
Quoted 5 lines
and then then place things at arbitrary spots in memory that may or may not violate these requirements.
- Perhaps some of the FIT internals where we have a device tree inside a device tree? And we need to fixup whatever we're doing there that's wrong.
And that too. On arm32 and legacy setups this is fine, on arm64 and all new setups, use mkimage -E to avoid running into this.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."
Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDT
In case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt = ALIGN_4(u_boot + u_boot_size) u-boot: fdt = ALIGN_4(u_boot + u_boot_size)
In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin u-boot: fdt = ALIGN_4(u_boot + u_boot_size)
We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Alex
Hi Alex,
Quoted 46 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt =ALIGN_4(u_boot + u_boot_size)
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)
Quoted 6 lines
We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Just on that specific point, we should use the SPL handoff info in a bloblist.
Regards,
Simon
Quoted 28 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
Quoted 7 lines
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDT
Is this CONFIG_OF_EMBED?
Quoted 4 lines
In case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt =ALIGN_4(u_boot + u_boot_size)
I don't see there is even a ALIGN_4 in current SPL logic, but it happens to be 4 in all cases I think.
Quoted 7 lines
u-boot: fdt = ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)
Quoted 6 lines
We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Regards,
Bin
Quoted 45 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt = ALIGN_4(u_boot + u_boot_size) u-boot: fdt = ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin u-boot: fdt = ALIGN_4(u_boot + u_boot_size)
Quoted 6 lines
We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Signature · 1 line
Tom
Quoted 50 lines · Tom Rini
Quoted 49 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt = ALIGN_4(u_boot + u_boot_size) u-boot: fdt = ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin u-boot: fdt = ALIGN_4(u_boot + u_boot_size)We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
Quoted 7 lines
Quoted 2 lines
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Tom Rini
Quoted 51 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt = ALIGN_4(u_boot + u_boot_size) u-boot: fdt = ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin u-boot: fdt = ALIGN_4(u_boot + u_boot_size)We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Quoted 7 lines
Quoted 4 lines
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
I don't follow you, sorry. But since you seem to have the best understanding of where all of the cases something could go wrong here, can you perhaps post an RFC patch? That is likely to be clearer than another long thread here.
Signature · 1 line
Tom
Quoted 60 lines · Tom Rini
Quoted 59 lines · Marek Vasut
Quoted 57 lines · Tom Rini
Quoted 45 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt = ALIGN_4(u_boot + u_boot_size) u-boot: fdt = ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin u-boot: fdt = ALIGN_4(u_boot + u_boot_size)Quoted 6 lines
We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Quoted 7 lines
Quoted 2 lines
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
I don't follow you, sorry. But since you seem to have the best understanding of where all of the cases something could go wrong here, can you perhaps post an RFC patch? That is likely to be clearer than another long thread here.
I don't follow you, sorry. I believe the revert did the right thing and new systems should use mkimage -E when generating fitImages, to avoid the string alignment problem. That is all.
Hi Marek,
Quoted 65 lines · Marek Vasut
Quoted 63 lines · Tom Rini
Quoted 61 lines · Marek Vasut
Quoted 50 lines · Tom Rini
Quoted 49 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt =ALIGN_4(u_boot + u_boot_size)
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
Quoted 7 lines
Quoted 2 lines
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
Quoted 8 lines
Quoted 4 lines
I don't follow you, sorry. But since you seem to have the best understanding of where all of the cases something could go wrong here, can you perhaps post an RFC patch? That is likely to be clearer than another long thread here.
I don't follow you, sorry. I believe the revert did the right thing and new systems should use mkimage -E when generating fitImages, to avoid the string alignment problem. That is all.
Using -E should be optional and things really should work without it.
Regards,
Simon
Quoted 73 lines · Simon Glass
Hi Marek,
Quoted 70 lines · Marek Vasut
Quoted 67 lines · Tom Rini
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Tom Rini
Quoted 51 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt =ALIGN_4(u_boot + u_boot_size)
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Quoted 7 lines
Quoted 4 lines
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
I don't follow you, sorry. But since you seem to have the best understanding of where all of the cases something could go wrong here, can you perhaps post an RFC patch? That is likely to be clearer than another long thread here.
Quoted 5 lines
Quoted 3 lines
I don't follow you, sorry. I believe the revert did the right thing and new systems should use mkimage -E when generating fitImages, to avoid the string alignment problem. That is all.
Using -E should be optional and things really should work without it.
See the DTSpec, I don't think that is possible unless you relocate fitImage components, and if you want fast boot time esp. in SPL, that is not good.
Quoted 74 lines · Marek Vasut
Quoted 73 lines · Simon Glass
Hi Marek,
Quoted 70 lines · Marek Vasut
Quoted 67 lines · Tom Rini
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Tom Rini
Quoted 51 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt =ALIGN_4(u_boot + u_boot_size)
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Quoted 7 lines
Quoted 4 lines
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
I don't follow you, sorry. But since you seem to have the best understanding of where all of the cases something could go wrong here, can you perhaps post an RFC patch? That is likely to be clearer than another long thread here.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I don't follow you, sorry. I believe the revert did the right thing and new systems should use mkimage -E when generating fitImages, to avoid the string alignment problem. That is all.
Using -E should be optional and things really should work without it.
See the DTSpec, I don't think that is possible unless you relocate fitImage components, and if you want fast boot time esp. in SPL, that is not good.
This is why I've asked you to make up some patch to perhaps highlight the problem. Ensuring that the device tree, which is small, is also 8-byte aligned, shouldn't be a big problem nor performance hit. I'm not sure where the problem case is that isn't "user put things they control in a bad spot, fail and tell them why" but I could just be missing a case.
Signature · 1 line
Tom
Quoted 84 lines · Tom Rini
Quoted 74 lines · Marek Vasut
Quoted 73 lines · Simon Glass
Hi Marek,
Quoted 70 lines · Marek Vasut
Quoted 67 lines · Tom Rini
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Tom Rini
Quoted 51 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt =ALIGN_4(u_boot + u_boot_size)
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Quoted 7 lines
Quoted 4 lines
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
I don't follow you, sorry. But since you seem to have the best understanding of where all of the cases something could go wrong here, can you perhaps post an RFC patch? That is likely to be clearer than another long thread here.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I don't follow you, sorry. I believe the revert did the right thing and new systems should use mkimage -E when generating fitImages, to avoid the string alignment problem. That is all.
Using -E should be optional and things really should work without it.
See the DTSpec, I don't think that is possible unless you relocate fitImage components, and if you want fast boot time esp. in SPL, that is not good.
Quoted 6 lines
This is why I've asked you to make up some patch to perhaps highlight the problem. Ensuring that the device tree, which is small, is also 8-byte aligned, shouldn't be a big problem nor performance hit. I'm not sure where the problem case is that isn't "user put things they control in a bad spot, fail and tell them why" but I could just be missing a case.
The fail case is this:
- you update SPL with this 8 byte alignment change
- you have older kernel fitImage with embedded DT for falcon mode
- system no longer boots because there is off-by-4 error in the DT address passed to the kernel
I hope this is clear now.
Quoted 93 lines · Marek Vasut
Quoted 85 lines · Tom Rini
Quoted 75 lines · Marek Vasut
Quoted 74 lines · Simon Glass
Hi Marek,
Quoted 71 lines · Marek Vasut
Quoted 68 lines · Tom Rini
Quoted 55 lines · Marek Vasut
Quoted 54 lines · Tom Rini
Quoted 52 lines · Alex G.
Quoted 20 lines · Tom Rini
Quoted 19 lines · Bin Meng
Quoted 7 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."
Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt =ALIGN_4(u_boot + u_boot_size)
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Quoted 7 lines
Quoted 4 lines
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
I don't follow you, sorry. But since you seem to have the best understanding of where all of the cases something could go wrong here, can you perhaps post an RFC patch? That is likely to be clearer than another long thread here.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I don't follow you, sorry. I believe the revert did the right thing and new systems should use mkimage -E when generating fitImages, to avoid the string alignment problem. That is all.
Using -E should be optional and things really should work without it.
See the DTSpec, I don't think that is possible unless you relocate fitImage components, and if you want fast boot time esp. in SPL, that is not good.
Quoted 6 lines
This is why I've asked you to make up some patch to perhaps highlight the problem. Ensuring that the device tree, which is small, is also 8-byte aligned, shouldn't be a big problem nor performance hit. I'm not sure where the problem case is that isn't "user put things they control in a bad spot, fail and tell them why" but I could just be missing a case.
Quoted 5 lines
The fail case is this:
- you update SPL with this 8 byte alignment change
- you have older kernel fitImage with embedded DT for falcon mode
- system no longer boots because there is off-by-4 error in the DT address passed to the kernel
I'm not sure how falcon mode would break the kernel. It passes to the kernel the load address of the fdt. The concern here is loading u-boot.
Quoted 1 line
I hope this is clear now.
Quoted 92 lines · Marek Vasut
Quoted 84 lines · Tom Rini
Quoted 74 lines · Marek Vasut
Quoted 73 lines · Simon Glass
Hi Marek,
Quoted 70 lines · Marek Vasut
Quoted 67 lines · Tom Rini
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Tom Rini
Quoted 51 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt =ALIGN_4(u_boot + u_boot_size)
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Quoted 7 lines
Quoted 4 lines
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
I don't follow you, sorry. But since you seem to have the best understanding of where all of the cases something could go wrong here, can you perhaps post an RFC patch? That is likely to be clearer than another long thread here.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I don't follow you, sorry. I believe the revert did the right thing and new systems should use mkimage -E when generating fitImages, to avoid the string alignment problem. That is all.
Using -E should be optional and things really should work without it.
See the DTSpec, I don't think that is possible unless you relocate fitImage components, and if you want fast boot time esp. in SPL, that is not good.
Quoted 6 lines
This is why I've asked you to make up some patch to perhaps highlight the problem. Ensuring that the device tree, which is small, is also 8-byte aligned, shouldn't be a big problem nor performance hit. I'm not sure where the problem case is that isn't "user put things they control in a bad spot, fail and tell them why" but I could just be missing a case.
Quoted 5 lines
The fail case is this:
- you update SPL with this 8 byte alignment change
- you have older kernel fitImage with embedded DT for falcon mode
- system no longer boots because there is off-by-4 error in the DT address passed to the kernel
OK. Then I think the answer is what I said recently in another part of this thread, we need to split "find the fdt" from "align the fdt". The fdt can come to us with any alignment it happens to have, but we can't use that fdt in-place unless it's correctly aligned. In the case of falcon mode, it needs to end up at CONFIG_SYS_SPL_ARGS_ADDR. The case of passing it on to U-Boot proper is where we have at best a hack right now (as noted by fdt_hack in common/spl/spl.c). That would be a place to, as has been also suggested in this thread, pass along more correctly where the device tree in memory is.
Signature · 1 line
Tom
Quoted 100 lines · Tom Rini
Quoted 92 lines · Marek Vasut
Quoted 84 lines · Tom Rini
Quoted 74 lines · Marek Vasut
Quoted 73 lines · Simon Glass
Hi Marek,
Quoted 70 lines · Marek Vasut
Quoted 67 lines · Tom Rini
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Tom Rini
Quoted 51 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt =ALIGN_4(u_boot + u_boot_size)
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Quoted 7 lines
Quoted 4 lines
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
I don't follow you, sorry. But since you seem to have the best understanding of where all of the cases something could go wrong here, can you perhaps post an RFC patch? That is likely to be clearer than another long thread here.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I don't follow you, sorry. I believe the revert did the right thing and new systems should use mkimage -E when generating fitImages, to avoid the string alignment problem. That is all.
Using -E should be optional and things really should work without it.
See the DTSpec, I don't think that is possible unless you relocate fitImage components, and if you want fast boot time esp. in SPL, that is not good.
Quoted 6 lines
This is why I've asked you to make up some patch to perhaps highlight the problem. Ensuring that the device tree, which is small, is also 8-byte aligned, shouldn't be a big problem nor performance hit. I'm not sure where the problem case is that isn't "user put things they control in a bad spot, fail and tell them why" but I could just be missing a case.
Quoted 5 lines
The fail case is this:
- you update SPL with this 8 byte alignment change
- you have older kernel fitImage with embedded DT for falcon mode
- system no longer boots because there is off-by-4 error in the DT address passed to the kernel
Quoted 9 lines
OK. Then I think the answer is what I said recently in another part of this thread, we need to split "find the fdt" from "align the fdt". The fdt can come to us with any alignment it happens to have, but we can't use that fdt in-place unless it's correctly aligned. In the case of falcon mode, it needs to end up at
CONFIG_SYS_SPL_ARGS_ADDR. The case of passing it on to U-Boot proper is where we have at best a hack right now (as noted byfdt_hackincommon/spl/spl.c). That would be a place to, as has been also suggested in this thread, pass along more correctly where the device tree in memory is.
Where are we on this issue?
Regards,
Bin
Quoted 111 lines · Bin Meng
Quoted 100 lines · Tom Rini
Quoted 92 lines · Marek Vasut
Quoted 84 lines · Tom Rini
Quoted 74 lines · Marek Vasut
Quoted 73 lines · Simon Glass
Hi Marek,
Quoted 70 lines · Marek Vasut
Quoted 67 lines · Tom Rini
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Tom Rini
Quoted 51 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
On Mon, Jul 12, 2021 at 1:21 PM Reuben Dowle <[email protected]> wrote:
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content
can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already
aligned to 4, so how did this commit make the system hang on arm32?I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt =ALIGN_4(u_boot + u_boot_size)
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Quoted 7 lines
Quoted 4 lines
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
I don't follow you, sorry. But since you seem to have the best understanding of where all of the cases something could go wrong here, can you perhaps post an RFC patch? That is likely to be clearer than another long thread here.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I don't follow you, sorry. I believe the revert did the right thing and new systems should use mkimage -E when generating fitImages, to avoid the string alignment problem. That is all.
Using -E should be optional and things really should work without it.
See the DTSpec, I don't think that is possible unless you relocate fitImage components, and if you want fast boot time esp. in SPL, that is not good.
Quoted 6 lines
This is why I've asked you to make up some patch to perhaps highlight the problem. Ensuring that the device tree, which is small, is also 8-byte aligned, shouldn't be a big problem nor performance hit. I'm not sure where the problem case is that isn't "user put things they control in a bad spot, fail and tell them why" but I could just be missing a case.
Quoted 5 lines
The fail case is this:
- you update SPL with this 8 byte alignment change
- you have older kernel fitImage with embedded DT for falcon mode
- system no longer boots because there is off-by-4 error in the DT address passed to the kernelQuoted 9 lines
OK. Then I think the answer is what I said recently in another part of this thread, we need to split "find the fdt" from "align the fdt". The fdt can come to us with any alignment it happens to have, but we can't use that fdt in-place unless it's correctly aligned. In the case of falcon mode, it needs to end up at
CONFIG_SYS_SPL_ARGS_ADDR. The case of passing it on to U-Boot proper is where we have at best a hack right now (as noted byfdt_hackincommon/spl/spl.c). That would be a place to, as has been also suggested in this thread, pass along more correctly where the device tree in memory is.
Quoted 1 line
Where are we on this issue?
Waiting for someone to do what I suggested I think. I've not yet had time to take a look.
Signature · 1 line
Tom
Quoted 84 lines · Tom Rini
Quoted 74 lines · Marek Vasut
Quoted 73 lines · Simon Glass
Hi Marek,
Quoted 70 lines · Marek Vasut
Quoted 67 lines · Tom Rini
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Tom Rini
Quoted 51 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt =ALIGN_4(u_boot + u_boot_size)
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin
u-boot: fdt =ALIGN_4(u_boot + u_boot_size)We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Quoted 7 lines
Quoted 4 lines
I'm not sure that we need to worry too much about mix-and-match SPL/U-Boot, but documenting what to go change if you must do it somewhere under doc/ would be good. I think we can just switch to ALIGN(8) not ALIGN(4) and be done with it?
Remember, there is also falcon boot. And we definitely have to be able to have old u-boot (SPL) boot new fitImage and vice versa.
I don't follow you, sorry. But since you seem to have the best understanding of where all of the cases something could go wrong here, can you perhaps post an RFC patch? That is likely to be clearer than another long thread here.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I don't follow you, sorry. I believe the revert did the right thing and new systems should use mkimage -E when generating fitImages, to avoid the string alignment problem. That is all.
Using -E should be optional and things really should work without it.
See the DTSpec, I don't think that is possible unless you relocate fitImage components, and if you want fast boot time esp. in SPL, that is not good.
Quoted 7 lines
This is why I've asked you to make up some patch to perhaps highlight the problem. Ensuring that the device tree, which is small, is also 8-byte aligned, shouldn't be a big problem nor performance hit. I'm not sure where the problem case is that isn't "user put things they control in a bad spot, fail and tell them why" but I could just be missing a case.
As far as highlighting the problem, here's an excerpt from the previous discussion [1].
## SPL:
image_info.load_addr = ALIGN(spl_image->load_addr + spl_image->size, 8);
(gdb) print/x (spl_image->load_addr + spl_image->size) $19 = 0xc01cf85c (gdb) print/x image_info->load_addr $20 = 0xc01cf860
FDT is installed at 0xc01cf860
## u-boot:
__weak void *board_fdt_blob_setup(void)
{
/* FDT is at end of image */
fdt_blob = (ulong *)&_end;
(gdb) print &_end
$22 = (char (*)[]) 0xc01cf85cFDT is expected at 0xc01cf85c
Alex
[1] https://lists.denx.de/pipermail/u-boot/2020-October/430066.html
Quoted 45 lines · Alex G.
Quoted 19 lines · Tom Rini
Quoted 18 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."Quoted 6 lines
Quoted 2 lines
I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
It's true that the flat devicetree spec requires an 8-byte alignment, even on 32-bit. The issues here are specific to u-boot.
SPL and u-boot have to agree where u-boot's FDT is located. We'll look at two cases:
1) u-boot as a FIT (binary and FDT separately loaded)
2) u-boot with embedded FDTIn case (1) SPL must place the FDT at a location where u-boot will find it. The current logic is
SPL: fdt = ALIGN_4(u_boot + u_boot_size) u-boot: fdt = ALIGN_4(u_boot + u_boot_size)In case (2), SPL's view of the FDT is not relevant, but instead the build system must place the FDT correctly:
build: fdt >> u-boot.bin u-boot: fdt = ALIGN_4(u_boot + u_boot_size)
Quoted 6 lines
We have 3 places that must agree. A correct and complete patch could change all three, but one has to consider compatibility issues when crossing u-boot and SPL versions.
I had proposed in the revert discussion that SPL use r2 or similar mechanism to pass the location of the FDT to u-boot.
Looking at this again, and trying to figure out what we can do here most easily, I think we need to have spl_fit_append_fdt() perhaps be split in to "find the fdt" and then either a new function, or more logic within the function for "ensure fdt is aligned properly". We had made the assumption that we can use the fdt in place in memory but that's not always true.
Signature · 1 line
Tom
Quoted 31 lines · Tom Rini
Quoted 12 lines · Bin Meng
Quoted 6 lines · Reuben Dowle
I submitted an almost identical patch. See https://github.com/u-boot/u-boot/commit/eb39d8ba5f0d1468b01b89a2a464d18612d3ea76
This patch eventually had to be reverted (https://github.com/u-boot/u-boot/commit/5675ed7cb645f5ec13958726992daeeed16fd114), because it was causing issues on some platforms that had FIT on 32 bit boundary. However I continue to use it in production code, as without it the boot on my platform aborts.
I don't have time to investigate why this was happening, but you need to check this code won't just cause exactly the same faults.
Thanks for your information.
+Marek who did the revert
Quoted 8 lines
The revert commit message says:
"The commit breaks booting of fitImage by SPL, the system simply
hangs. This is because on arm32, the fitImage and all of its content can be aligned to 4 bytes and U-Boot expects just that."I don't understand this. If an address is aligned to 8, it is already aligned to 4, so how did this commit make the system hang on arm32?
I think this had something to do with embedding contents somewhere in the image? There is a thread on the ML from then but I don't know how informative it will end up being.
Quoted 4 lines
Note, as I indicated in this patch, now with libfdt 1.6.1, the alignment to 8 byte is a must-have. So we have to do such alignment anyway.
Quoted 8 lines
Quoted 3 lines
@Tom may fill in why libfdt commit commit
5e735860c478("libfdt: Check for 8-byte address alignment infdt_ro_probe_()") was made to have the 8-byte alignment requirement.Note that it's not so much since libfdt 1.6.1 but that since always the device tree has required 8 byte alignment. It's just that on 32bit platforms 4-but-not-8 byte alignment tends to not be fatal but on 64bit platforms it is.
But with libfdt v1.6.1 commit 5e735860c478 ("libfdt: Check for 8-byte address alignment in fdt_ro_probe_()"), now this is fatal error if DT address is not 8-bytes aligned, as that commit adds a check in fdt_ro_probe_().
Regards,
Bin