The persisted configuration size is limited to 4096 bytes. You can try changing PERSISTED_CONFIG_SIZE in CMakeLists.txt, but I haven’t tried it. Probably needs to be a multiple of 4096.
@jfedor Thanks, see below, I’ll try your suggestion if I hit the same problem again as I add functionality to my project.
I have got it working (without rebuilding) as follows:
I’ve shrunk the output of my macros, there were a lot of unnecessary keys. In the snippet I’ve shown, there’s a ‘nothing’ ([]) entry between two disimilar outputs - not necessary. There were 71 of those.
I also realised that 4 keys were not needed, only three. that alone is 160 less commands, so with the above I’ve removed 231 commands.
I am able to upload my huge macros while my hid remapper is connected. And the program is able to execute every macro. But when I replug the hid-remapper into my PC, the device disappears and the web console configuration tool can’t find it. Then I need to flash a ‘nuke_universal.uf2’ from rpi’s website and reflash my recompiled hid-remapper again. But replugging causes the same issue again, so I need to reflash ‘nuke_universal.uf2’ everytime.
If you want to erase the external flash memory, you can copy a special UF2 file to the Raspberry Pi Pico device while it’s in BOOTSEL mode.
Is there something we need to delay for the config to load fully? I think 16 KB is enough since pico has 2 MB of flash. Also, I noticed if I upload a smaller config via web tool, then replugging works, so this seems to be tied to a large json config. But to get past the “Configuration too big to persist” when uploading my big json file, increasing PERSISTED_CONFIG_SIZE=16384 was required.
I don’t know, maybe it’s hitting some other limit or running out of memory, though in theory it shouldn’t if the macros work after loading the configuration before you unplug. Share the JSON file if there’s no sensitive data inside.
Open a notepad and scroll. It will cycle through 3 big strings.
The right button will reset back to macro 1 on next scroll.
Long pressing right button will send an ‘Enter’ key.
When done testing, replug from PC side, and see if hid remapper is not detected.
I’ve noticed this happens when the macro is too big. If we distribute the big string among more macros, then it may work. But I want each macro to have big strings.
Macros are actually limited to 255 entries in the configuration saved to flash (there’s one byte for macro length). However there is no such limit in memory and this is not enforced correctly when persisting the config to flash. As a result at some point when loading config from flash it starts reading garbage and tries to allocate too much memory and crashes.
(Your macros have like 900+ entries from what I can see.)