Arm Mbed OS support forum

Custom board with STM32L476ZG - first steps?

Hi everyone,

I am rather new to Mbed and STM32 programming in general. I am looking for a way to create a target for a custom board with an STM32L476ZG. Is there an “easy” way to do this? As far as I see, there currently is no board available with an STM32L476ZG, which I could use and remap, right?

Thanks in advance!

Hello,

I have no persotal experince with this, but on the page 15 of Datasheet - STM32L476xx you can found some differentions between STM32L476ZG and STM32L476RG what is used on NUCLEO-L476RG | Mbed.
Maybe that can be used as a start point.

README for Mbed OS STM32 targets - custom-boards

BR, Jan

Hi,

As far as I see, there currently is no board available with an STM32L476ZG, which I could use and remap, right?

Correct. There is no STM32L476ZG support, but STM32L476xG is available, so you can re-use the code.

Build step

  • Clone mbed-os-example-blinky project
  • Copy one of target board related folder to the root. e.g.
  • And rename it for you custom board. e.g. TARGET_MY_L476ZG
  • Create custom_targets.json and add your board config below:
{
    "MY_L476ZG": {
        "inherits": [
            "MCU_STM32L476xG"
        ]
    }
}
  • Modify linker script files and pinmap files in the folder

Also, you can refer my custom board project here:

I hope this helps.

Thanks a lot for your responses! I tried to add a custom target with the following steps:

  1. Created the blinky example: mbed import mbed-os-example-blinky
  2. Created a custom_targets.json with the following content:
{
    "WOMOLIN_V2": {
        "inherits": [
            "MCU_STM32L476xG"
        ]
    }
}
  1. Generated the pin mapping files following the link to the README posted by @JohnnyK :
    Inside mbed-os-example-blinky
cd mbed-os
python targets/TARGET_STM/tools/STM32_gen_PeripheralPins.py -m "STM32L476Z(E-G)Tx.xml"
  1. Copied PeripheralPins.c and PinNames.h from mbed-os/targets_custom/TARGET_STM/TARGET_STM32L4/TARGET_STM32L476xG/TARGET_STM32L476ZGT to a new folder TARGET_WOMOLIN_V2 inside mbed-os-example-blinky
  2. Changed the content of PinNames.h to match my configuration (see here)
  3. Compiled the code with mbed compile -m WOMOLIN_V2 -t GCC_ARM

Am I on the right track so far?

I noticed a warning when compiling:

Configuration error: Bootloader not supported on this target. ROM start not found in targets.json.
Configuration error: Bootloader not supported on this target. RAM start not found in targets.json.

As far as I understand, the ROM and RAM start should be defined in the target.json, which I am extending with my custom_targets.json. I would expect the inherits to take the values for the RAM and ROM start from the already defined parent definition MCU_STM32L476xG. Any ideas what is happening here? How can I fix that?

I set the STM32 into bootloader mode by pressing the boot button on the board and connecting it to USB. lsusb lists it as Bus 001 Device 018: ID 0483:3748 STMicroelectronics ST-LINK/V2. When executing mbed compile -m WOMOLIN_V2 -t GCC_ARM -f to flash the code, I get

[1614191038.26][mbedls.lstools_linux]Could not get serial devices by id. This could be because your Linux distribution does not use udev, or does not create /dev/serial/by-id symlinks. Please submit an issue to github.com/armmbed/mbed-ls.

I think this may be my setup of mbed (installed via aur on Arch Linux).

I also tried flashing the firmware using Mbed Studio. When connecting the board in bootloader mode, it does show up as STM32 BOOTLOADER. I added the configuration as you can see in the screenshot here:
Bildschirmfoto von 2021-02-24 19-53-08
When clicking “Run program”, Mbed seems to be stuck. Checking running processes, I noticed pyocd flash running in the background, but it won’t finish. Clicking “Debug program” quits with a timeout: “Timeout waiting for gdb server”
Is it possible to get Mbed Studio to flash my program or should I stick with flashing via my STLinkV2?

Thank you very much for your answers!

Hi,

The build tool refers target ROM and RAM start address from CMSIS package file which is in mbed-os/tools/arm_package_manager/index.json.
Your target device is configured as STM32L476ZGTx in the file, so you can modify your custom_targets.json as below.

{
    "WOMOLIN_V2": {
        "inherits": [
            "MCU_STM32L476xG"
        ],
        "device_name": "STM32L476ZGTx"
    }
}

Thanks,
Toyo

Thanks! The error is gone :slight_smile:

1 Like