5

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?

Peter Mortensen
  • 1,676
  • 3
  • 17
  • 23
jhon tonini
  • 91
  • 1
  • 7
  • 1
    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 '18 at 19:17
  • 2
    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 '18 at 04: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 '18 at 08: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 '18 at 21:53

2 Answers2

9

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.

Colin
  • 4,499
  • 2
  • 19
  • 33
2

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.

Michel Keijzers
  • 13,867
  • 18
  • 69
  • 139