fitImage align 8-byte for ARM64

Hi!
I have had trouble booting a fitImage packed kernel for dragonboard410c, which is an ARM64 platform. After days and days of debugging, I found that the fdt is 4-byte aligned. But within the linux kernel, Documentation/arm64/booting.txt says, fdt must be 8 byte aligned.
If I change the alignment by means of fdt_high, the Kernel boots, otherwise, it hangs.
Is there an option to align the fitImage to 8-byte boundaries, and if not, is it feasible to submit a patch or will this never have a chance to get merged?!
Thanks and Regards,
Matthias Schöpfer

On Mon, Jan 06, 2020 at 01:47:25PM +0100, Matthias Schoepfer wrote:
Hi!
I have had trouble booting a fitImage packed kernel for dragonboard410c, which is an ARM64 platform. After days and days of debugging, I found that the fdt is 4-byte aligned. But within the linux kernel, Documentation/arm64/booting.txt says, fdt must be 8 byte aligned.
If I change the alignment by means of fdt_high, the Kernel boots, otherwise, it hangs.
Is there an option to align the fitImage to 8-byte boundaries, and if not, is it feasible to submit a patch or will this never have a chance to get merged?!
That's interesting. It sounds like you need to look at boot_relocate_fdt() perhaps? Thanks!

Hi Tom,
thanks for your reply. As far as I can understand this code, only if fdt_high is set to 0xffffffffffffffff (which is the very case for dragonboard410c) a not aligned mapping of the fdt can happen. In this case, the address is images->ft_addr, which I *think* comes from the fitImage creation?!
I wonder, whether just removing fdt_high is a valid solution...
Regards,
Matthias
On 1/6/20 3:20 PM, Tom Rini wrote:
On Mon, Jan 06, 2020 at 01:47:25PM +0100, Matthias Schoepfer wrote:
Hi!
I have had trouble booting a fitImage packed kernel for dragonboard410c, which is an ARM64 platform. After days and days of debugging, I found that the fdt is 4-byte aligned. But within the linux kernel, Documentation/arm64/booting.txt says, fdt must be 8 byte aligned.
If I change the alignment by means of fdt_high, the Kernel boots, otherwise, it hangs.
Is there an option to align the fitImage to 8-byte boundaries, and if not, is it feasible to submit a patch or will this never have a chance to get merged?!
That's interesting. It sounds like you need to look at boot_relocate_fdt() perhaps? Thanks!

On Mon, Jan 06, 2020 at 04:22:02PM +0100, Matthias Schoepfer wrote:
Hi Tom,
thanks for your reply. As far as I can understand this code, only if fdt_high is set to 0xffffffffffffffff (which is the very case for dragonboard410c) a not aligned mapping of the fdt can happen. In this case, the address is images->ft_addr, which I *think* comes from the fitImage creation?!
I wonder, whether just removing fdt_high is a valid solution...
Ah. Yes, generally speaking fdt_high shouldn't be set as it stops us from relocating things to ensure alignment. Making use of bootm_size instead (to ensure that everything is within a certain area of memory) is better for the general case. So please, update the default environment and CC the board maintainer, thanks!

Hi Tom, Simon,
On 2020/1/6 下午10:20, Tom Rini wrote:
On Mon, Jan 06, 2020 at 01:47:25PM +0100, Matthias Schoepfer wrote:
Hi!
I have had trouble booting a fitImage packed kernel for dragonboard410c, which is an ARM64 platform. After days and days of debugging, I found that the fdt is 4-byte aligned. But within the linux kernel, Documentation/arm64/booting.txt says, fdt must be 8 byte aligned.
If I change the alignment by means of fdt_high, the Kernel boots, otherwise, it hangs.
Is there an option to align the fitImage to 8-byte boundaries, and if not, is it feasible to submit a patch or will this never have a chance to get merged?!
That's interesting. It sounds like you need to look at boot_relocate_fdt() perhaps? Thanks!
When I use the FIT image, I met another issue:
- The emmc/sd read is by block which is 512byte;
- The FIT image header is always not 512byte align, and the entry of
image in FIT is always not aligned to block;
- The image read from block device always need memory coppy which
make it slow.
I can truncate the image in FIT align to 512 byte, but not able to make the
header which is dtb 512byte align, any idea to implement this?
Thanks,
- Kever

On Tue, Jan 07, 2020 at 09:25:53AM +0800, Kever Yang wrote:
Hi Tom, Simon,
On 2020/1/6 下午10:20, Tom Rini wrote:
On Mon, Jan 06, 2020 at 01:47:25PM +0100, Matthias Schoepfer wrote:
Hi!
I have had trouble booting a fitImage packed kernel for dragonboard410c, which is an ARM64 platform. After days and days of debugging, I found that the fdt is 4-byte aligned. But within the linux kernel, Documentation/arm64/booting.txt says, fdt must be 8 byte aligned.
If I change the alignment by means of fdt_high, the Kernel boots, otherwise, it hangs.
Is there an option to align the fitImage to 8-byte boundaries, and if not, is it feasible to submit a patch or will this never have a chance to get merged?!
That's interesting. It sounds like you need to look at boot_relocate_fdt() perhaps? Thanks!
When I use the FIT image, I met another issue:
The emmc/sd read is by block which is 512byte;
The FIT image header is always not 512byte align, and the entry of
image in FIT is always not aligned to block;
- The image read from block device always need memory coppy which
make it slow.
I can truncate the image in FIT align to 512 byte, but not able to make the
header which is dtb 512byte align, any idea to implement this?
I don't quite follow, sorry. Don't you control where the image will be written to in eMMC?

Hi Kever,
On Tue, 7 Jan 2020 at 13:27, Tom Rini trini@konsulko.com wrote:
On Tue, Jan 07, 2020 at 09:25:53AM +0800, Kever Yang wrote:
Hi Tom, Simon,
On 2020/1/6 下午10:20, Tom Rini wrote:
On Mon, Jan 06, 2020 at 01:47:25PM +0100, Matthias Schoepfer wrote:
Hi!
I have had trouble booting a fitImage packed kernel for dragonboard410c, which is an ARM64 platform. After days and days of debugging, I found that the fdt is 4-byte aligned. But within the linux kernel, Documentation/arm64/booting.txt says, fdt must be 8 byte aligned.
If I change the alignment by means of fdt_high, the Kernel boots, otherwise, it hangs.
Is there an option to align the fitImage to 8-byte boundaries, and if not, is it feasible to submit a patch or will this never have a chance to get merged?!
That's interesting. It sounds like you need to look at boot_relocate_fdt() perhaps? Thanks!
When I use the FIT image, I met another issue:
The emmc/sd read is by block which is 512byte;
The FIT image header is always not 512byte align, and the entry of
image in FIT is always not aligned to block;
The image read from block device always need memory coppy which
make it slow.
I can truncate the image in FIT align to 512 byte, but not able to make the
header which is dtb 512byte align, any idea to implement this?
I don't quite follow, sorry. Don't you control where the image will be written to in eMMC?
In the SPL FIT implementation, it reads the blocks from MMC in such a way that the first byte of the image is at the required load address, and the FIT metadata is before that. See spl_load_simple_fit().
Regards, Simon
participants (4)
-
Kever Yang
-
Matthias Schoepfer
-
Simon Glass
-
Tom Rini