Skip to content

Commit 1a0011d

Browse files
Put serial_offset into PROGMEM
This saves a bit of RAM, at the cost of a bit of extra flash (more code to load the values) in place. However, since this is the last variable in the .data section, this avoids the overhead gcc generated for loading data into the .data section, effectively saving 16 bytes of flash.
1 parent d383971 commit 1a0011d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

bootloader.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <string.h>
1919
#include <avr/io.h>
2020
#include <avr/boot.h>
21+
#include <avr/pgmspace.h>
2122
#include <util/delay.h>
2223
#include <stdio.h>
2324

@@ -183,7 +184,7 @@ cmd_result processCommand(uint8_t cmd, uint8_t *datain, uint8_t len, uint8_t *da
183184
// These are offsets into the device signature imprint table, which
184185
// store the parts of the serial number (lot number, wafer number, x/y
185186
// coordinates).
186-
static const uint8_t serial_offset[] = {0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x15, 0x16, 0x17};
187+
static const uint8_t PROGMEM serial_offset[] = {0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x15, 0x16, 0x17};
187188

188189
if (len != 0)
189190
return cmd_result(Status::INVALID_ARGUMENTS);
@@ -192,7 +193,7 @@ cmd_result processCommand(uint8_t cmd, uint8_t *datain, uint8_t len, uint8_t *da
192193
return cmd_result(Status::NO_REPLY);
193194

194195
for (uint8_t i = 0; i < sizeof(serial_offset); ++i)
195-
dataout[i] = boot_signature_byte_get(serial_offset[i]);
196+
dataout[i] = boot_signature_byte_get(pgm_read_byte(&serial_offset[i]));
196197
return cmd_ok(sizeof(serial_offset));
197198
}
198199
case Commands::START_APPLICATION:

0 commit comments

Comments
 (0)