GD32 + Non volatile Memory : NeVerMind

 

I'm porting the spotwelder control board from stm32duino to lnArduino, so that i can use indifferently a STM32F1/GD32F1/F3/VF3 and to have a smaller and better codebase.

It had a couple of tiny bugs but it is working sort of ok.
Then  i reached the last missing piece : Non volatile memory.

The Stm32duino version is using the eeprom emulation code from STM that can only store couple (id,value) with value on 16 bits. 
It works  but it's a bit awkard to use if you want to store 32 bits stuff or floats.
Additionally, the license is a bit restrictive it seems.


On the other end of the spectrum, you can switch to tinyFS. But this is way overkill to store some basic settings.
I looked on github without finding something suitable.

What do we want ?
  • Sort of robust if interrupted during a write ( ~ atomic)
  • Variable size writes (with a small maximum)
  • Not erasing the flash at every write
Since i couldn't find something suitable,  i wrote a quick & dirty non volatile memory storage : NeVerMind.

Upon testing i realised something : The STM32/GD32 chips dont allow bit sized write
You can only write 16 or 32 bits on top of fully erased 16/32 bits

So no "one bit update" for you

Ok, nevermind updated, basically expanding each bit of the previous implementation to 16 bits.
Light testing was ok, good enough for me.
It is fully integrated with the build system, so the space is automatically allocated in the linker script and the linker script exports the address and size of the NVM area.
No risk of writing stuff at the wrong place.








Comments

Popular posts from this blog

Component tester with STM32 : Part 1 ADC, Resistor

Fixing the INA3221

INA3221, weird wiring