Skip to content

Commit b9e33f6

Browse files
committed
firmware: Allocate space for quantizer table in flash
It is important to ensure that the addresses and lengths of the existing NVM sections (settings and lut) are not changed by this patch. I have manually verified this as follows: * Build the firmware before applying this commit * Run: $ objdump -t build/gemini-firmware.elf | grep _nvm * Then apply the commit and rebuild * Run objdump again * Compare the two sets of outputs. The relevant columns are the first (symbol value) and last (symbol name)
1 parent e9df253 commit b9e33f6

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

firmware/scripts/samd21g18a.ld

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ BOOTLOADER_SIZE = 0x2000; /* 8kB, 8,192 bytes */
5555
NVM_SIZE = 0x400; /* 1kB, 1,024 bytes */
5656
SRAM_SIZE = 0x8000; /* 32kB, 32,768 bytes */
5757

58+
/*
59+
We reserve a chunk at the end of the flash for "non-volatile memory" (NVM) -
60+
which is used by the application to store per-device information.
61+
This is divided into three sections:
62+
63+
* User-selected quantizer table
64+
* User settings
65+
* DAC calibration lookup table (LUT)
66+
*/
67+
QUANTIZER_SIZE = 0x1000; /* 4kB, 4,096 bytes - TODO reduce once format is settled */
68+
SETTINGS_SIZE = 0x200; /* 0.5kB, 512 bytes */
69+
LUT_SIZE = 0x200; /* 0.5kB, 512 bytes */
70+
NVM_SIZE = QUANTIZER_SIZE + SETTINGS_SIZE + LUT_SIZE;
71+
5872
/*
5973
ARM Cortex-M processors use a descending stack and generally
6074
require stack space to be set aside in RAM.
@@ -530,27 +544,38 @@ SECTIONS
530544
to use.
531545
*/
532546

547+
/*
548+
Symbols for the quantizer section in the NVM memory block.
549+
550+
Gemini uses this section to store the user's custom quantization
551+
table (if any).
552+
553+
References:
554+
* ../src/gem_quantizer.c
555+
TODO: Add a marker to the packed config, and hook up to this symbol
556+
*/
557+
_nvm_quantizer_base_address = ORIGIN(nvm);
558+
_nvm_quantizer_length = QUANTIZER_SIZE;
559+
533560
/*
534561
Symbols for the settings section in the NVM memory block.
535562

536-
Gemini uses the first half of the NVM block for user settings.
537-
This symbol is used by the settings module to know where to
538-
load and save settings.
563+
Gemini uses this section to load and save user settings.
539564

540565
References:
541566
* ../src/gem_settings_load_save.c
542567
*/
543-
_nvm_settings_base_address = ORIGIN(nvm);
544-
_nvm_settings_length = LENGTH(nvm) / 2;
568+
_nvm_settings_base_address = ORIGIN(nvm) + QUANTIZER_SIZE;
569+
_nvm_settings_length = SETTINGS_SIZE;
545570

546571
/*
547572
Symbols for the calibration/look-up table in the NVM memory block.
548573

549-
Gemini uses the other half of the NVM block to store the factory-
550-
calibrated look-up table for translating ADC -> frequency/DAC codes.
574+
Gemini uses this section to store the factory-calibrated look-up table
575+
for translating ADC -> frequency/DAC codes.
551576

552577
References:
553578
* ../src/gem_ramp_table_load_save.c
554579
*/
555-
_nvm_lut_base_address = ORIGIN(nvm) + LENGTH(nvm) / 2;
556-
_nvm_lut_length = LENGTH(nvm) / 2;
580+
_nvm_lut_base_address = ORIGIN(nvm) + QUANTIZER_SIZE + SETTINGS_SIZE;
581+
_nvm_lut_length = LUT_SIZE;

0 commit comments

Comments
 (0)