2025-11-25 5:50 AM - last edited on 2025-11-25 6:29 AM by Andrew Neil
Good morning.
I'm still trying to develop in STM code.
I have an open-source code developed for the STM32L476.
Questions:
If I generate a compiled HEX for the STM32L476, will it run on the 411?
Are they compatible?
Is it possible to migrate to an STMF303 or an STM32F411?
These are the ones I have to continue developing my studies.
I still don't have enough knowledge.
I've been trying to adapt it to the various available STM controllers.
Thank you.
Valter Matos
2025-11-25 6:06 AM
> If I generate a compiled HEX for the STM32L476, will it run on the 411?
> Are they compatible?
Short answer - no.
Flash and RAM sizes are different, peripherals (number, address, features) are different, "special" RAM regions are different. Even sub-variants of many MCUs are not directly compatible (e.g. F303xB/C/D/E vs. F303x6/8).
> Is it possible to migrate to an STMF303 or an STM32F411?
Yes, of course.
I have migrated projects between F0, C0, F3 and F4 devices successfully, although it takes some effort.
The behavior of many peripherals is slightly different in many variants.
Unless, of course, you use a (HAL) abstraction layer like MicroPython, Arduino, or a RTOS with appropriate drivers. Which is not what you mean, I suppose.
2025-11-25 6:19 AM - edited 2025-11-25 6:31 AM
See AN3364, Migration and compatibility guidelines for STM32 microcontroller applications.
Specifically for STM32, using HAL should help: your will use a different HAL version for the different targets, but they should present a (largely) common interface to your software.
General principle for making any software portable is to isolate hardware dependencies into as few places as possible - so that only those few places will need changing to change target.
Here's how I have common code running on different targets in CubeIDE:
2025-11-25 6:37 AM
Thank you.
Before abandoning the STM series.
I will try to migrate using the knowledge I have in STM.
I will use CUBE MX to generate the code and try to migrate the source code. I don't have the knowledge to start from scratch.
I have knowledge of the Arduino IDE, which is not the case now.
One of the difficulties I find with STM products is the large diversity of families and the lack of compatibility between them.
Thank you again.
Valter Matos
2025-11-25 6:59 AM
@ValterMatos wrote:I will use CUBE MX to generate the code
CubeMX just generates the configuration stuff specific to the particular target chip.
The "business logic" of your application should be separate from this.
If it is not well separated, I strongly suggest that you start by making it so on the original L476 version.
This will make it much easier to then port to your other target(s).
I suggest that you keep all of your "own" code out of the files generated by CubeMX
@ValterMatos wrote:One of the difficulties I find with STM products is ... the lack of compatibility between them.
Not sure what you mean by that?
There is a great deal of compatibility between them - when a feature is present on two different chips, it generally works the same on both.
Again, using HAL helps with this.
2025-11-25 8:00 AM
I will try to keep the resources independent of the chip.
One of the difficulties now is the use of SPI1 and 2. It seems to me that the pins are different between the L476 and the 411, and I have 303 and 411 boards for my studies.
The only direct pin compatibility I know of so far is between the 103 and the 303.
It is possible to replace the chips.
I don't know how to use HAL very well.
I will try.
Thank you.
2025-11-25 8:19 AM
@ValterMatos wrote:It seems to me that the pins are different between the L476 and the 411, and I have 303 and 411 boards for my studies..
Indeed, that will always be an issue - certainly not specific to STM32.
So that is one of the key things that you need to isolate from your application.
@ValterMatos wrote:I have an open-source code developed for the STM32L476.
As it's open-source, why not share it?
Then perhaps people could make suggestions...
(probably in a separate thread)