STM32F0 - run user program from SPI flash memory
STM32F0 - run user program from SPI flash memory
I'm building an application based on the STM32F030F4P6 microcontroller. During the development of the firmware, I realized that the flash memory of the microcontroller is too small.
Can I run my firmware from SPI flash memory? If yes, how could I do it?
While sold as a 16K part, the STM32F030F4P6 typically in practice actually has 32K of flash. It's not something you can necessarily count on, and it may not have been tested, but if you change your linker script and try, you'll probably find it is there and usable for prototypes. In production you may be able to shrink space by removing output messages, etc - or find an officially larger chip such as the one suggested.
– Chris Stratton
Aug 23 at 4:25
The whole point with having all these countless MCU families is that you should be able to upgrade within the same family without changing code or pin-out. Did you check if there is a compatible STM32F with more flash?
– Lundin
Aug 23 at 8:16
That's true in general but the options for the TSSOP-20 packages are substantially more limited than the others. Still there do appear to be some that officially have 32K.
– Chris Stratton
Aug 23 at 21:53
2 Answers
2
The bad news is no, you can't execute directly from SPI flash. You could store some of your program on the external flash, and copy it to RAM a bit at a time for execution, it would work, but it's a terrible idea overall. It's probably easier to change to a more suitable microcontroller.
The stm32f070f6p6 is a similar part with 32k instead of 16k of flash, it may even be pin compatible.
In my answer of increase memory of an atmega32 there are a lot of generic possibilities to reduce flash size.
However, the most simple way (as Colin mentioned) is to use a microcontroller with more flash.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
While STM32F0 cannot do this, for example STM32F7 can execute code from SPI flash. It has some integrated cache so that it can work fast even though external flash is slower than internal one.
– jpa
Aug 22 at 19:17