ao-stmload: Always round up load amount to 4 byte boundary
authorKeith Packard <keithp@keithp.com>
Wed, 29 Aug 2012 01:02:25 +0000 (18:02 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 29 Aug 2012 06:00:22 +0000 (23:00 -0700)
The flashing code doesn't deal with partial writes.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/ao-stmload/ao-stmload.c

index e689539bb41c5b3e372c3698d2ae601444fdf30c..a471dcc47358b6d54a1dcefaae6769d73b750946 100644 (file)
@@ -112,10 +112,17 @@ struct load {
        uint8_t         buf[0];
 };
 
        uint8_t         buf[0];
 };
 
+uint32_t round4(uint32_t a) {
+       return (a + 3) & ~3;
+}
+
 struct load *
 new_load (uint32_t addr, uint32_t len)
 {
 struct load *
 new_load (uint32_t addr, uint32_t len)
 {
-       struct load *new = calloc (1, sizeof (struct load) + len);
+       struct load *new;
+
+       len = round4(len);
+       new = calloc (1, sizeof (struct load) + len);
        if (!new)
                abort();
 
        if (!new)
                abort();