Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Fix IHEX firmware generation/loading

Fix both the IHEX firmware generation (len field always null, and EOF
marker a byte too short) and loading (struct ihex_binrec needs to be
packed to reflect the on-disk structure).

Signed-off-by: Marc Zyngier <maz@misterjones.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Marc Zyngier and committed by
David Woodhouse
85ebd003 f1136d02

+4 -4
+3 -3
firmware/ihex2fw.c
··· 250 250 251 251 static int output_records(int outfd) 252 252 { 253 - unsigned char zeroes[5] = {0, 0, 0, 0, 0}; 253 + unsigned char zeroes[6] = {0, 0, 0, 0, 0, 0}; 254 254 struct ihex_binrec *p = records; 255 255 256 256 while (p) { 257 257 uint16_t writelen = (p->len + 9) & ~3; 258 258 259 259 p->addr = htonl(p->addr); 260 - p->len = htonl(p->len); 260 + p->len = htons(p->len); 261 261 write(outfd, &p->addr, writelen); 262 262 p = p->next; 263 263 } 264 264 /* EOF record is zero length, since we don't bother to represent 265 265 the type field in the binary version */ 266 - write(outfd, zeroes, 5); 266 + write(outfd, zeroes, 6); 267 267 return 0; 268 268 }
+1 -1
include/linux/ihex.h
··· 18 18 __be32 addr; 19 19 __be16 len; 20 20 uint8_t data[0]; 21 - } __attribute__((aligned(4))); 21 + } __attribute__((packed)); 22 22 23 23 /* Find the next record, taking into account the 4-byte alignment */ 24 24 static inline const struct ihex_binrec *