Skip to content

Commit

Permalink
Fix IHEX firmware generation/loading
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David Woodhouse <[email protected]>
  • Loading branch information
mzyngier authored and David Woodhouse committed Aug 2, 2008
1 parent f1136d0 commit 85ebd00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions firmware/ihex2fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,19 +250,19 @@ static void file_record(struct ihex_binrec *record)

static int output_records(int outfd)
{
unsigned char zeroes[5] = {0, 0, 0, 0, 0};
unsigned char zeroes[6] = {0, 0, 0, 0, 0, 0};
struct ihex_binrec *p = records;

while (p) {
uint16_t writelen = (p->len + 9) & ~3;

p->addr = htonl(p->addr);
p->len = htonl(p->len);
p->len = htons(p->len);
write(outfd, &p->addr, writelen);
p = p->next;
}
/* EOF record is zero length, since we don't bother to represent
the type field in the binary version */
write(outfd, zeroes, 5);
write(outfd, zeroes, 6);
return 0;
}
2 changes: 1 addition & 1 deletion include/linux/ihex.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct ihex_binrec {
__be32 addr;
__be16 len;
uint8_t data[0];
} __attribute__((aligned(4)));
} __attribute__((packed));

/* Find the next record, taking into account the 4-byte alignment */
static inline const struct ihex_binrec *
Expand Down

0 comments on commit 85ebd00

Please sign in to comment.