palm-client: shared tables must not be const (prc-tools puts const in code)

The transcript wrapped after a few characters on the Visor: gSmallFontWidths
was const, so prc-tools placed it in .text, but text.c reached it through an
extern declaration A5-relative (lea %a5@(0)) as if it were data, and read
garbage widths. The same applied to gPresets. Both generators now emit
non-const tables, with a note why. Host tests can't see this.
This commit is contained in:
rich committed 2026-11-01 15:34:13 -05:00
1 parent c04bebeb81
commit 40412223a4
7 files changed
+22 -9

No files matched your search

+1
View File
@@ -70,3 +70,4 @@
- Node Settings verified from the Visor: radio now 919.500 MHz / BW 500 / SF10 / CR5, 2-byte path hash (confirmed independently over the XIAO's USB). Seen in the bridge log: the Visor's USB link dropped while the Settings form was open and re-attached on the next send; it worked, but commands only try once, so this needs a closer look.
- Reception was dead until the XIAO rebooted: SET_RADIO_PARAMS saves and reports the new settings, but the receiver only retunes on a restart. Settings now offers to reboot the radio (CMD_REBOOT) after a radio change and reconnects. The radio then heard the user's contact.
- MeshTerm-style UI built: generated 4x6 font (PilRC's FONT compiler writes a corrupt NFNT, so gen_font.py writes it), rowlist, text layout (host-tested), message store and sync, Home/Conversation/Contacts/Node screens. Font verified readable on the Neo.
- Transcript wrapped after ~4 characters on the Visor: prc-tools puts `const` data in the code section, but another file reaching an `extern const` table addresses it A5-relative as data, so it read garbage widths. Shared tables (font widths, presets) are now non-const, set in their generators. Host tests can't catch this. Rule: never share an `extern const` table across files in palm-client.
+5 -2
View File
@@ -6,7 +6,10 @@
*/
#include "presets.h"
const VmPreset gPresets[] = {
/* Not const: prc-tools puts const data in the code section, but other files reach an
* extern table A5-relative as if it were data, so a const table reads as garbage on the Visor. */
VmPreset gPresets[] = {
{ "PhillyMesh", 919500UL, 500000UL, 10, 5, 2 },
{ "Australia", 915800UL, 250000UL, 10, 5, 0 },
{ "Australia (Narrow)", 916575UL, 62500UL, 7, 7, 0 },
@@ -37,4 +40,4 @@ const VmPreset gPresets[] = {
{ "Vietnam (Deprecated)", 920250UL, 250000UL, 11, 5, 0 },
};
const UInt16 gPresetCount = sizeof(gPresets) / sizeof(gPresets[0]);
UInt16 gPresetCount = sizeof(gPresets) / sizeof(gPresets[0]);
+3 -2
View File
@@ -12,7 +12,8 @@ typedef struct {
UInt8 pathHashSize; /* bytes; 0 = preset doesn't specify one */
} VmPreset;
extern const VmPreset gPresets[];
extern const UInt16 gPresetCount;
/* Not const: see the note in presets.c (prc-tools puts const data in code). */
extern VmPreset gPresets[];
extern UInt16 gPresetCount;
#endif
+3 -1
View File
@@ -1,7 +1,9 @@
/* GENERATED by tools/gen_font.py: small-font character widths in pixels. */
#include "fontmetrics.h"
const UInt8 gSmallFontWidths[256] = {
/* Not const: prc-tools puts const data in the code section, but other files reach an
* extern table A5-relative as if it were data, so a const table reads as garbage on the Visor. */
UInt8 gSmallFontWidths[256] = {
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+2 -1
View File
@@ -4,6 +4,7 @@
#include "../protocol.h" /* integer types on both Palm and host */
/* Small-font character widths in pixels, indexed by (UInt8) character. */
extern const UInt8 gSmallFontWidths[256];
/* Not const: see the note in fontmetrics.c (prc-tools puts const data in code). */
extern UInt8 gSmallFontWidths[256];
#endif
+3 -1
View File
@@ -198,7 +198,9 @@ def main():
widths = [len(font[c][0]) if c in font else len(missing[0]) for c in range(256)]
with open(OUT_METRICS, 'w') as f:
f.write('/* GENERATED by tools/gen_font.py: small-font character widths in pixels. */\n')
f.write('#include "fontmetrics.h"\n\nconst UInt8 gSmallFontWidths[256] = {\n')
f.write('#include "fontmetrics.h"\n\n')
f.write('/* Not const: prc-tools puts const data in the code section, but other files reach an\n * extern table A5-relative as if it were data, so a const table reads as garbage on the Visor. */\n')
f.write('UInt8 gSmallFontWidths[256] = {\n')
for r in range(0, 256, 16):
f.write('\t' + ', '.join(str(w) for w in widths[r:r + 16]) + ',\n')
f.write('};\n')
+5 -2
View File
@@ -60,11 +60,14 @@ def main():
*/
#include "presets.h"
const VmPreset gPresets[] = {{
/* Not const: prc-tools puts const data in the code section, but other files reach an
* extern table A5-relative as if it were data, so a const table reads as garbage on the Visor. */
VmPreset gPresets[] = {{
''' + '\n'.join(rows) + f'''
}};
const UInt16 gPresetCount = sizeof(gPresets) / sizeof(gPresets[0]);
UInt16 gPresetCount = sizeof(gPresets) / sizeof(gPresets[0]);
''')
print(f'{len(rows)} presets -> {os.path.relpath(OUT)}')