I have an STM32L4S7ZIT. The MCU is not found on a nucleo board. So I bought a Nucleo L4a6zg board and replaced the MCU with mine. I developed a simple code with the CubeIDE to try my modified nucleo board. The simple code works without any problem.
Now I want to develop a simple code for my modified nucleo using mbed-os. However, STM32L4S7ZIT is not among the supported MCUs in v6.16. I folowed below steps to add the MCU/custom board as a new target:
- Generated
PinNames.h
,PeripheralPins.c
andCMakeLists.txt
, folowing the instructions in the readme file in TARGET_STM folder. I generated these from the working*.ioc
file - Created
TARGET_STM32L4S7xI
folder. In this folder createdNUCLEO_L4Custom
andTOOLCHAIN_[ARM/GCC_ARM/IAR]
folders. I downloaded the corresponding .S files from this repository. Copied the linker files formTARGET_STM32L4S5xI
. I am compiling with GCC_ARM. - Copied the generated files at the first step to my NUCLEO_L4Custom folder.
- From
TARGET_STM32L4S5xI
, copiedCMakeLists.txt
,cmsis_nvic.h
andsystem_clock.c
to my TARGET_STM32L4S7xI folder. - Modified a bit the CMakeLists.txt in order to set the correct .S and .ld file paths.
- Added
MCU_STM32L4S7xI
andNUCLEO_L4Custom
to targets.json. It simply it looks like this:
"MCU_STM32L4S7xI": {
"inherits": [
"MCU_STM32L4"
],
"public": false,
"components_add": [
"FLASHIAP"
],
"extra_labels_add": [
"STM32L4S7xI"
],
"macros_add": [
"STM32L4S7xx",
"MBEDTLS_CONFIG_HW_SUPPORT"
]
},
"NUCLEO_L4Custom": {
"inherits": [
"MCU_STM32L4S7xI"
],
"supported_form_factors": [
"ARDUINO_UNO"
],
"device_name": "STM32L4S7ZITx",
"detect_code": [
"0776"
],
"device_has_add": [
"USBDEVICE"
]
},
The code compiles but it does not run. I also added DISCO_F407VG as another target. When I compile for that board it works without any problem. However, TARGET_STM32F407xG is already available in the official release. I just had to add the discovery board as a new target.
I believe copying the files from TARGET_STM32L4S5xI (step 4) is correct because S5, 7, 9 MCUs are explained in the same datasheet and their core hw architecture is the same. I also compared those files with L4R5 and noticed they are identical except the .S and .ld file paths in cmake_lists.txt. So, using the same linker, system_clock.c, cmsis_nvic.h should be okay. I did no modifications in arm_pack_manager json files. I found this but it is quite old and not valid for the latest os version. Where is my mistake? Do I miss any steps or do I do a mistake while adding the new mcu? There is not a comprehensive documentation about how to add a new STM32 target and the above steps are what I understand by reading all the documentations I found and going through the file structure.