mbed-os/targets/TARGET_STM
Martin Kojtal 7b5a8d37b5
Merge pull request #12966 from MultiTechSystems/update-df413-onoff
DRAGONFLY_F413RH: Update power on and power off functionality
2020-06-16 13:54:01 +02:00
..
TARGET_STM32F0 STM32F0 baremetal support 2020-05-18 15:27:29 +02:00
TARGET_STM32F1 STM32F1 STM32Cube FW V1.8.0: update for MBED 2020-06-15 13:49:47 +02:00
TARGET_STM32F2 STM32F2 baremetal support 2020-06-09 10:24:36 +02:00
TARGET_STM32F3 STM32F3 baremetal support 2020-05-18 17:26:50 +02:00
TARGET_STM32F4 Merge pull request #12966 from MultiTechSystems/update-df413-onoff 2020-06-16 13:54:01 +02:00
TARGET_STM32F7 STM32 rename TOOLCHAIN_ARM_STD into TOOLCHAIN_ARM 2020-05-15 10:41:28 +02:00
TARGET_STM32G0 STM32 rename TOOLCHAIN_ARM_STD into TOOLCHAIN_ARM 2020-05-15 10:41:28 +02:00
TARGET_STM32G4 Apply linker fix as in #12690 to new NUCLEO_G474RE target 2020-05-20 06:39:17 -04:00
TARGET_STM32H7 Merge pull request #13083 from jeromecoutant/PR_H7_CUBE170 2020-06-16 13:45:42 +02:00
TARGET_STM32L0 STM32L0 baremetal support 2020-05-18 17:27:42 +02:00
TARGET_STM32L1 STM32L1 baremetal support 2020-06-08 11:46:56 +02:00
TARGET_STM32L4 STM32L4 baremetal support 2020-06-08 12:05:54 +02:00
TARGET_STM32L5 STM32 rename TOOLCHAIN_ARM_STD into TOOLCHAIN_ARM 2020-05-15 10:41:28 +02:00
TARGET_STM32WB Merge pull request #13001 from jeromecoutant/PR_BAREMETAL_SUPPORT_STEP2 2020-06-12 14:44:14 +01:00
PeripheralPins.h STM32F7: directory restructuration 2020-04-23 18:02:06 +02:00
PinNamesTypes.h Move GPIO_AF_NONE from PeripheralPins.h to PinNamesTypes.h 2019-11-28 08:32:10 +01:00
PortNames.h STM32: make PortNames.h a common file 2017-01-19 15:27:19 +01:00
README.md Merge pull request #13083 from jeromecoutant/PR_H7_CUBE170 2020-06-16 13:45:42 +02:00
USBPhyHw.h STM32 USB redesign step 1 2019-10-21 17:12:03 +02:00
USBPhy_STM32.cpp STM32F4 V1.19.0 -> V1.25.0 : adaptation 2020-03-30 16:04:02 +02:00
analogin_api.c NUCLEO_H743ZI: add initial SDK 2019-01-04 10:03:36 +01:00
analogout_api.c STM32: analog_out: generalize code for multiple instance handling 2017-06-27 09:27:46 +02:00
can_api.c STM pin_function(), pin_mode(): return immediately when given pin is NC 2020-02-19 11:46:59 +01:00
device.h STM: move us_ticker_defines.h include 2020-06-09 11:04:23 +02:00
gpio_api.c STM32H7: enable dual analogic pad 2020-06-05 16:26:22 +02:00
gpio_irq_api.c STM32L5 : update generic STM files for L5 2020-01-23 17:54:55 +01:00
gpio_object.h TARGET_STM: Remove timeout on HSEM. 2019-11-27 14:25:43 +01:00
hal_tick_overrides.c STM: move us_ticker_defines.h include 2020-06-09 11:04:23 +02:00
i2c_api.c STM32 warning remove 2020-04-24 10:57:45 +02:00
lp_ticker.c STM32L5 : update generic STM files for L5 2020-01-23 17:54:55 +01:00
mbed_crc_api.c Update HAL CRC API 2019-12-02 14:45:37 +02:00
mbed_overrides.c STM32: add weak TargetBSP_Init function 2020-05-27 16:49:54 +02:00
mbed_rtx.h STM32F0: clean main-thread-stack-size setting 2019-12-23 12:29:40 +01:00
nvic_addr.h TARGET_STM astyle 2018-06-27 14:21:07 +02:00
pinmap.c STM pin_function(), pin_mode(): return immediately when given pin is NC 2020-02-19 11:46:59 +01:00
port_api.c STM32: Change Set_GPIO_Clock return type 2017-02-16 18:55:44 +01:00
pwmout_api.c Change explicit pinmap to static pinmap 2019-11-28 08:32:12 +01:00
qspi_api.c STM32 : enable MBED trace for QSPI 2020-02-20 12:20:24 +01:00
reset_reason.c STM32 TARGET_STM astyle corrections 2019-12-10 14:39:47 +01:00
rtc_api.c STM: change rtc irq handler name 2020-02-04 12:29:52 +01:00
rtc_api_hal.h STM32 RTC : Prescaler calculation issue 2018-10-22 15:58:32 +02:00
serial_api.c STM pin_function(), pin_mode(): return immediately when given pin is NC 2020-02-19 11:46:59 +01:00
serial_api_hal.h TARGET_STM astyle 2018-06-27 14:21:07 +02:00
sleep.c Increase MSI clock frequency when exiting deep sleep 2020-01-07 17:59:33 +01:00
stm32_assert.h TARGET_STM astyle 2018-06-27 14:21:07 +02:00
stm_spi_api.c STM32 warning remove 2020-04-24 10:57:45 +02:00
trng_api.c STM32L5 : update generic STM files for L5 2020-01-23 17:54:55 +01:00
us_ticker.c Microlib slow division causes HAL_GetTick API performance issue, so optimized HAL_GetTick API to improve performance. 2020-05-05 16:24:53 +01:00
us_ticker_defines.h STM: Correct macro test in us_ticker_defines.h 2019-07-01 13:34:55 +03:00
watchdog_api.c Added support for WDT (untested). Checked datasheet for maximum LSI frequency 2020-05-20 06:39:17 -04:00

README.md

README for Mbed OS STM32 targets

ST TOOLS

USB drivers

Mandatory: get the latest USB driver in order to make available all the USB interfaces provided by the ST-LINK:

  • ST Debug
  • Virtual COM port
  • ST Bridge interfaces

Default Windows USB drivers will not setup full capabilities.

https://www.st.com/en/development-tools/stsw-link009.html

Mandatory: get the latest ST-Link Firmware:

https://www.st.com/en/development-tools/stsw-link007.html

You could have some issue to connect your board if you didn't install full USB drivers.

Note that with the latest FW version, you are able to check the version number easily with a simple "mbedls":

$ mbedls
| platform_name       | platform_name_unique   | mount_point | serial_port | target_id                | interface_version |
|---------------------|------------------------|-------------|-------------|--------------------------|-------------------|
| DISCO_H747I         | DISCO_H747I[0]         | D:          | COM13       | 081402210D03E72132477E08 | V3J7M2            |
| DISCO_L475VG_IOT01A | DISCO_L475VG_IOT01A[0] | E:          | COM9        | 07640221683B630A577FF553 | V2J37M26          |

STM32 Cube

https://www.st.com/en/embedded-software/stm32cube-mcu-packages.html

There is one STM32Cube package for each individual STM32 MCU family.

It includes:

  • The hardware abstraction layer (HAL) enabling portability between different STM32 devices via standardized API calls
  • Low-layer (LL) APIs, a light-weight, optimized, expert oriented set of APIs designed for both performance and runtime efficiency
  • A collection of middleware components including RTOS, USB library, file system, TCP/IP stack, touch-sensing library or graphics library (depending on the STM32 series)
  • BSP drivers, based on HAL drivers.

Part of STM32Cube files are copied in each targets/TARGET_STM/TARGET_STM32<xx>/STM32Cube_FW directory:

  • CMSIS header files in CMSIS sub-directory
  • HAL and LL files in STM32<XX>xx_HAL_Driver sub-directory

Mbed OS HAL calls ST porting layer, which calls ST HAL and LL API.

Note that all ST HAL and LL files are available:

  • you can then develop some applications with direct ST HAL and LL call, even if feature is not supported in Mbed OS
  • BSP for LCD, AUDIO, SENSORS, etc... are not available in Mbed OS, but you should be able to use it in your local application.

Each STM32Cube package is also available in Github. This table summarizes the STM32Cube versions currently used in Mbed OS master branch :

STM32 Serie Cube version Github source
F0 1.9.0 https://github.com/STMicroelectronics/STM32CubeF0
F1 1.8.0 https://github.com/STMicroelectronics/STM32CubeF1
F2 1.6.0 https://github.com/STMicroelectronics/STM32CubeF2
F3 1.9.0 https://github.com/STMicroelectronics/STM32CubeF3
F4 1.19.0 https://github.com/STMicroelectronics/STM32CubeF4
F7 1.16.0 https://github.com/STMicroelectronics/STM32CubeF7
G0 1.3.0 https://github.com/STMicroelectronics/STM32CubeG0
H7 1.7.0 https://github.com/STMicroelectronics/STM32CubeH7
L0 1.10.0 https://github.com/STMicroelectronics/STM32CubeL0
L1 1.8.1 https://github.com/STMicroelectronics/STM32CubeL1
L4 1.11.0 https://github.com/STMicroelectronics/STM32CubeL4
L5 1.1.0 https://github.com/STMicroelectronics/STM32CubeL5
WB 1.4.0 https://github.com/STMicroelectronics/STM32CubeWB

In Mbed OS repository, we try to minimize the difference between "official" and copied files.

STM32CubeMX

STM32CubeMX is a graphical tool that allows a very easy configuration of all STM32

https://www.st.com/en/development-tools/stm32cubemx.html

Tool is not used in Mbed OS, but it can be useful for you.

STM32CubeProgrammer

It provides an easy-to-use and efficient environment for reading, writing and verifying device memory.

https://www.st.com/en/development-tools/stm32cubeprog.html

Tool is not used in Mbed OS, but it can be useful for you.

STM32 families

STM32WB

STM32WB README

STM32H7

STM32H7 README

Custom boards

It should be "easy" to add your custom board with a STM32 MCU in Mbed OS

STM32 organisation

STM32 root directory is https://github.com/ARMmbed/mbed-os/tree/master/targets/TARGET_STM

This contains:

  • all STM32 families directories: F0, F1, F2, F3, F4, F7, G0, H7, L0, L1, L4, WB
  • Mbed OS porting layer common for all

Each STM32 family contains several "sub-families".

Each STM32 Part Number defines a sub-family: STM32F401 / STM32F407 / STM32F429 / ...

But also each STM32 Part Number with different FLASH size : STM32F401xC / STM32F401xE

Mbed OS porting layer specific for this family are placed here.

Example in TARGET_STM32G0:

  • TARGET_STM32G031xx
  • TARGET_STM32G071xx
  • ...

Each STM32 sub-family contains:

  • toolchains files
  • board specific files

Add a custom board

ST provides the complete support for few NUCLEO and DISCO boards.

Locate one of these boards with the minimum difference with your chosen MCU.

Copy paste, and update!

Board specific files (pinmap)

2 files in Mbed OS:

  • PeripheralPins.c
  • PinNames.h

It is recommended to use a python script to generate those files

https://github.com/ARMmbed/mbed-os/blob/master/tools/targets/STM32_gen_PeripheralPins.py

STM32CubeMX has to be installed first. Path has to be specified in the cube_path.json file.

$ python tools/targets/STM32_gen_PeripheralPins.py -h

Script version 1.9
usage: STM32_gen_PeripheralPins.py [-h] [-l | -b | -m xml | -t HW | -c CUSTOM]

Script will generate PeripheralPins.c thanks to the xml files description available in
STM32CubeMX directory defined in 'cube_path.json':
        C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX

optional arguments:
  -h, --help            show this help message and exit
  -l, --list            list available mcu xml files description in STM32CubeMX
  -b, --boards          list available boards description in STM32CubeMX
  -m xml, --mcu xml     specify the mcu xml file description in STM32CubeMX to use (use double quotes).
                           Parameter can be a filter like L496 if you want to parse all L496 chips (-m STM32 to parse all).
  -t HW, --target HW    specify the board file description in STM32CubeMX to use (use double quotes).
                           Parameter can be a filter like L496 (only the first file found will be parsed).
  -c CUSTOM, --custom CUSTOM
                        specify a custom board .ioc file description to use (use double quotes).

Once generated, you have to check and comment pins that can not be used (specific HW, internal ADC channels, remove PWM using us ticker timer, ...)

How to generate files for a custom boards based on a STM32F427 MCU:

$ python tools/targets/STM32_gen_PeripheralPins.py -l | grep F427
STM32F427A(G-I)Hx.xml
STM32F427I(G-I)Hx.xml
STM32F427I(G-I)Tx.xml
STM32F427V(G-I)Tx.xml
STM32F427Z(G-I)Tx.xml

$ python tools/targets/STM32_gen_PeripheralPins.py -m "STM32F427V(G-I)Tx.xml"

Script version 1.9
CubeMX DB version DB.5.0.60

 * Output directory: C:\github\mbed\STM32F427V(G-I)Tx
 * Generating PeripheralPins.c and PinNames.h with 'STM32F427V(G-I)Tx.xml'
 * GPIO file: C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX\db\mcu\IP\GPIO-STM32F427_gpio_v1_0_Modes.xml
 * I/O pins found: 82 connected: 0

Use of custom_targets.json

https://os.mbed.com/docs/mbed-os/v6.0/porting/porting-a-custom-board.html

Example with a board based on STM32F103C8 (like BluePill):

  • MCU_STM32F103x8 generic configuration is already available in targets.json file
$ python tools/targets/STM32_gen_PeripheralPins.py -m "STM32F103C(8-B)Tx.xml"
// PeripheralPins.c and PinNames.h template files are created in STM32H745ZITx directory

$ mv STM32F103C\(8-B\)Tx/ TARGET_BLUEPILL_F103C8
// Edit PeripheralPins.c and PinNames.h to match your board configuration

// Create a custom_targets.json with:
{
    "BLUEPILL_F103C8": {
        "inherits": [
            "MCU_STM32F103x8"
        ],
        "overrides": {
            "clock_source": "USE_PLL_HSE_XTAL"
        },
        "device_has_remove": [
            "STDIO_MESSAGES"
        ],
        "device_name": "STM32F103C8"
    }
}

Example with a board based on STM32H745ZI

  • this is dual core MCU with CM4 and CM7
  • MCU_STM32H745I_CM4 and MCU_STM32H745I_CM7 generic configuration is already available in targets.json file
$ python tools/targets/STM32_gen_PeripheralPins.py -m "STM32H745ZITx.xml"
// PeripheralPins.c and PinNames.h template files are created in STM32H745ZITx directory

$ mv STM32H745ZITx TARGET_H745ZI_BOARD
// Edit PeripheralPins.c and PinNames.h to match your board configuration

// Create a custom_targets.json with:
{
    "H745ZI_BOARD_CM4": {
        "inherits": [
            "MCU_STM32H745I_CM4"
        ],
        "extra_labels_add": [
            "H745ZI_BOARD"
        ]
    },
    "H745ZI_BOARD_CM7": {
        "inherits": [
            "MCU_STM32H745I_CM7"
        ],
        "extra_labels_add": [
            "H745ZI_BOARD"
        ]
    }
}

ST specific implementation

WiFi configuration

https://github.com/ARMmbed/wifi-ism43362

https://os.mbed.com/teams/ST/wiki/How-to-make-wifi-tests

Ethernet configuration

Depending on your PHY, you will have to customize several configuration values:

  • the number of RX buffers
  • the number of TX buffers
  • thread size
  • PHY address
  • media interface
  • AutoNegotiation mode
  • DuplexMode mode
  • Speed mode
  • PHY register Offset
  • Speed mask information in the PHY status register
  • Duplex mask information in the PHY status register

Check the default values in: https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/emac-drivers/TARGET_STM/mbed_lib.json

Option is also to define your own HAL_ETH_MspInit function, you then have to add USE_USER_DEFINED_HAL_ETH_MSPINIT macro.

Mbed OS Wiki pages

https://os.mbed.com/teams/ST/wiki/

https://os.mbed.com/teams/ST/wiki/How-to-enable-flash-dual-bank

https://os.mbed.com/teams/ST/wiki/Nucleo-144pins-ethernet-spi-conflict