Sometimes I need to patch the framework I’m working with (Arduino, Mbed, etc.). For example, I’m using it with my custom board which uses different external oscillator frequency. I thought it would be a good feature to enable file tree overlay for a framework.
I.e. add a new setting to platformio.ini build environment section, for example, framework_overlay_dir = patches.
This is the path to a subdirectory in the project tree. It can contain files and directories, replicating the structure of the used framework. Whenever a file from the framework is built (or a header file included), if similar file is found in patches subdirectory of the project, it will be used instead of the file shipped with the framework.
Pros: makes framework patching easier, the patches will survive framework version update.
Cons: can lead to errors if you forget about file substitution (it is readily detected by seeing additional setting in platformio.ini, though).
I had to patch system_clock.c file of Mbed framework (in target subdirectory for blue pill board) because it sets PLL multiplier to 9 which is fine for 8 MHz external crystal, but my customized board has 12 MHz external crystal.
board_build.f_cpu did not work for me because the frequency is the same (72 MHz), only PLL multiplier is different (72 = 9*8 = 12*6).
No, I’d like to freeze framework version specifically. Or load framework from local folder instead of Internet. Platform version does not prohibit framework version updates, and if framework is updated, all my local patches would be gone.
I think it’s okay if it’s not possible, I’ll have to copy patched files over original ones before each build then.
Or I can simply set the filesystem permissions so that framework is read only. Then it won’t be updated ever.
As @azarubkin suggested, it’s already possible as of PIO v4 to do platforms… i.e. you can specify a git repo like github as the platform source… I think a URL can be specified also for frameworks… but if not, the new platform_packages override will do the job, especially if you just want to tweak a framework package for a standard platform…