Close

NVS aka EEPROM problems & chip shortage

A project log for CoreXY pen plotter

Created using FreeCAD and Zephyr RTOS. Inspired by AxiDraw.

lukasziwaszkiewiczlukasz.iwaszkiewicz 09/14/2021 at 17:050 Comments

GRBL (running on AVR) uses EEPROM for storing some of its state, but STM32-s doesn't have this type of memory due to its high cost. By the way brand new NXP i MX RT MCUs (at least the fastest ones I think) doesn't even contain the flash memory. I could probably live without the eeprom.c ported because the plotter as it is now seems to draw pretty fine, but I wanted to make my project complete. Default settings are stored in the defaults.h, and although I can change them from the UGS, they are not persisted in the machine.

I tried to get the Zephyr's non volatile storage (NVS) to work, but I quickly ran into problems with my MCU flash layout. STM32F446RE has 512kB. Sectors 0-3 are 16kB, 4 is 64, and lastly sectors 5, 6 and 7 are 128kB long. And now the porblems : 

After compiling the MCUBoot, to my surprise I discovered that the smallest binary I could get is ~36kB in size (only for the bootloader), so there is no way it would fit into sectors 0 and 1. To make things even worse, my main program is ~140kB big (and it's not even finished) while the two partitions for storing it are 128kB. In other words there are strict requirements as to how the flash has to be organized and I can't satisfy them with the current chip.

Alternatives : external EEPROM (takes PCB space, increases complexity), using a SD card (but what if user removes it?), using a MCU with bigger flash (overkill, GRBL stores everything in mere 1kB), using a MCU with smaller flash pages / sectors.

I hit the local distributor website (naive me) to discover that, indeed, the situation hasn't changed, and there's almost no STM32F4xxx available, and only one or two types STM32G4.

So I started to look around my office and found old scrapped boards we did for a client once, and to my delight they all have STM32F405-s with 1M flash. Flash layout is basically the same, and I think I'll finally manage to get it done.

Discussions