This is not a question; merely an observation. I have a font table in progmem:
static const uint8_t PROGMEM font[] = {
0x00, 0x00, 0x00, 0x00, 0x00,
…
0x00, 0x00, 0x5F, 0x00, 0x00,
0x00, 0x03, 0x00, 0x03, 0x00,
… many bytes ...
};
and read it using pgm_read_byte()
uint16_t line_idx = font + char_idx + col;
uint8_t line = pgm_read_byte(line_idx);
except that it doesn't work. It doesn't work unless I give the compiler a nudge. If I add one line like this:
void setup() {
…
if (millis() > 100000L) Serial.println((uint16_t) font, HEX);
…
}
then things work. Note the Serial.println never gets called, but the compiler doesn't know that.
When disassembling, the code that works contains the font table in .text, where you'd expect it:
Disassembly of section .text:
00000000 <__vectors>:
…
00000068 <__trampolines_end>:
…
0000020b <_ZL4font>:
...
2af: 00 00 00 5f 00 00 00 03 00 03 00 14 7f 14 7f 14 ..._............
When I disassemble the code that doesn't work the bytes are there, but they're marked as executeable code, not as data.
Disassembly of section .text:
00000000 <__vectors>:
…
00000068 <__trampolines_end>:
…
10c: 00 00 nop
10e: 00 5f subi r16, 0xF0 ; 240
110: 00 00 nop
112: 00 03 mulsu r16, r16
114: 00 03 mulsu r16, r16
116: 00 14 cp r0, r0
118: 7f 14 cp r7, r15
11a: 7f 14 cp r7, r15
Rest of the sketch is on github . Arduino 1.8.9, avr-gcc 5.4.0. Hope this helps someone.