From mboxrd@z Thu Jan 1 00:00:00 1970 From: Albert ARIBAUD Date: Wed, 15 Jul 2015 09:37:10 +0200 Subject: [U-Boot] [PATCH 4/5] tools: mkimage: fix imximage header size In-Reply-To: <874a6782a666faec3520e1e9a58f7092@agner.ch> References: <1434716311-26189-1-git-send-email-albert.aribaud@3adev.fr> <1434716311-26189-2-git-send-email-albert.aribaud@3adev.fr> <1434716311-26189-3-git-send-email-albert.aribaud@3adev.fr> <1434716311-26189-4-git-send-email-albert.aribaud@3adev.fr> <1434716311-26189-5-git-send-email-albert.aribaud@3adev.fr> <559F7EC8.6020605@denx.de> <874a6782a666faec3520e1e9a58f7092@agner.ch> Message-ID: <20150715093710.119815ec@lilith> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Stefan, On Tue, 14 Jul 2015 12:29:52 +0200, Stefan Agner wrote: > Hi Stefano, > > On 2015-07-10 10:14, Stefano Babic wrote: > > On 19/06/2015 14:18, Albert ARIBAUD (3ADEV) wrote: > >> imximage header size is 4-byte, not 8-byte aligned. > >> This produces .imx images that a Vybrid cannot boot > >> on. > >> > >> Fix by adding a "padding" field in header. > >> > >> Signed-off-by: Albert ARIBAUD (3ADEV) > >> --- > >> > >> tools/imximage.h | 1 + > >> 1 file changed, 1 insertion(+) > >> > >> diff --git a/tools/imximage.h b/tools/imximage.h > >> index 36fe095..a913329 100644 > >> --- a/tools/imximage.h > >> +++ b/tools/imximage.h > >> @@ -129,6 +129,7 @@ typedef struct { > >> ivt_header_t header; > >> write_dcd_command_t write_dcd_command; > >> dcd_addr_data_t addr_data[MAX_HW_CFG_SIZE_V2]; > >> + uint32_t padding[1]; /* end up on an 8-byte boundary */ > >> } dcd_v2_t; > >> > >> typedef struct { > >> > > > > Applied to u-boot-imx, thanks ! > > Sorry, just stumbled over this message now. > > We discussed exactly this issue already more than a year ago, see: > http://lists.denx.de/pipermail/u-boot/2014-April/177580.html > > Back then you asked whether I asked Freescale about it. Earlier this > year I tried to get hold of that issue and asked Freescale on Community, > see: > https://community.freescale.com/thread/355161 > > However, no official confirmation or explanation so far. > > I think my patch back then solves the issue nicer. The struct dcd_v2_t > is not the reason the whole header is not aligned by 8-byte, it is a > problem of the boot_data_t header which is 12 bytes long. So inserting > the padding just after struct boot_data_t (or inside of struct > boot_data_t) seems to be more appropriate. After reading the U-Boot and Freescale discussions, IIUC you have come to the conclusion that the missing 4 bytes were in boot_data_t because it was the only structure in the header which was not 8-bytes-aligned. However, the available documentation does not specify this constraint, and from a more experimental vewpoint, my patch adds 4 bytes at the end of the overall header, thus leaving boot data at 12 bytes (therefore leaving the dcd_table not 8-byte-aligned) and yet Vybrid can boot. To me, this proves that the size alignment problem is not with boot_data_t but with the overall header. Aside: My own hypothesis on the reason for the non-written 8-byte-alignment requirement is that the ROM code initially loads the NAND sector containing the header at some fixed address then calls some function to copy the header just below the image destination address, and that function is 'optimized' to use 8-byte chunks (probably because it only had two free regs for ldm/stm) and thus assumes an 8 bytes header size, and nobody cared to document (or possibly even realized the existence of) that assumption. > -- > Stefan Amicalement, -- Albert.