Custom STM32F405RG target throwing errors

Have been creating an mbed os 6 target for the STM32F405RG and have run into the following error log upon compilation:

Traceback (most recent call last):

File “c:\Users\Admin\mbed-os-imaginary-port\mbed-os\tools\targets_init_.py”, line 157, in target
resolution_order = get_resolution_order(json_data, name, [])
File “c:\Users\Admin\mbed-os-imaginary-port\mbed-os\tools\targets_init_.py”, line 145, in get_resolution_order
order = get_resolution_order(json_data, par, order, level + 1)
File “c:\Users\Admin\mbed-os-imaginary-port\mbed-os\tools\targets_init_.py”, line 143, in get_resolution_order
parents = json_data[target_name].get(“inherits”, [])
KeyError: ‘FAMILY_STM32’
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “c:\Users\Admin\mbed-os-imaginary-port/mbed-os/tools/make.py”, line 412, in
main()
File “c:\Users\Admin\mbed-os-imaginary-port/mbed-os/tools/make.py”, line 309, in main
mcu = extract_mcus(parser, options)[0]
File “c:\Users\Admin\mbed-os-imaginary-port\mbed-os\tools\options.py”, line 146, in extract_mcus
update_target_data()
File “c:\Users\Admin\mbed-os-imaginary-port\mbed-os\tools\targets_init_.py”, line 816, in update_target_data
in Target.get_json_target_data().items()
File “c:\Users\Admin\mbed-os-imaginary-port\mbed-os\tools\targets_init_.py”, line 817, in
if obj.get(“public”, True)]
File “c:\Users\Admin\mbed-os-imaginary-port\mbed-os\tools\targets_init_.py”, line 113, in wrapper
CACHES[(func.name, args)] = func(*args, **kwargs)
File “c:\Users\Admin\mbed-os-imaginary-port\mbed-os\tools\targets_init_.py”, line 368, in get_target
return target(target_name, Target.get_json_target_data())
File “c:\Users\Admin\mbed-os-imaginary-port\mbed-os\tools\targets_init_.py”, line 161, in target
), exc)
File “c:\Users\Admin\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\future\utils_init_.py”, line 398, in raise_from
exec(execstr, myglobals, mylocals)
File “”, line 1, in
tools.utils.NotSupportedException: target MTS_MDOT_F405RGT6 has an incomplete target definition

I’m guessing this has something to do with the custom_targets.json but am not sure. Can someone please provide some help/insight to this issue?

The files and code I am using is in the following repo: GitHub - DheerN/Imaginary-Board

Because your custom target repo and mbed-os (6.7) do not have TARGET_MTS_MDOT_F405RGT6 directory.

You can re-use the code from 5.15 branch below for your custom target.

Hello @MACRUM

Thanks for the reply, really appreciate it. I changed the program to an Mbed OS 5.15 program and it doesn’t even recognize the new build target anymore. I’m assuming that given the files in the repo you linked in your reply, Mbed Studio should be able to recognize the target. Please let me know if I am doing something wrong and I would appreciate if you could find a solution to my problem.

Here is the new repo: GitHub - DheerN/405_Target

Hi,

I don’t think Mbed OS 5.15.x support custom target build. You need to use Mbed OS 6.x.
I quickly modified your repo and build the target MTS_MDOT_F405RG as below.

mbed import https://github.com/DheerN/405_Target
cd 405_Target
cp -r mbed-os/targets/TARGET_STM/TARGET_STM32F4/TARGET_MTS_MDOT_F405RG .
cd mbed-os
mbed update latest
cd ..
mv custom_target.json custom_targets.json
# change ["STM_FAMILY"] to ["MCU_STM32"] in the custom_targets.json
mbed compile -m mts_mdot_f405rg -t gcc_arm

I hope this helps.

Hi @MACRUM – that was indeed very helpful.

When I compile using mbed compile -m mts_mdot_f405rg -t gcc_arm
The compilation fails:

Compile [ 46.7%]: ws_mpx_header.c
Compile [ 46.8%]: ws_neighbor_class.c
Compile [ 46.9%]: ws_pae_key_storage.c
[Error] ws_pae_key_storage.c@411,42: expected ')' before 'PRIi64'
[Warning] ws_pae_key_storage.c@411,18: spurious trailing '%' in format [-Wformat=]
[Error] ws_pae_key_storage.c@647,26: expected ')' before 'PRIi64'
[Warning] ws_pae_key_storage.c@647,13: format '%s' expects a matching 'char *' argument [-Wformat=]
[Warning] ws_pae_key_storage.c@647,13: format '%s' expects a matching 'char *' argument [-Wformat=]
[Warning] ws_pae_key_storage.c@647,13: spurious trailing '%' in format [-Wformat=]
[Error] ws_pae_key_storage.c@698,42: expected ')' before 'PRIx64'
[Warning] ws_pae_key_storage.c@698,13: spurious trailing '%' in format [-Wformat=]
[Error] ws_pae_key_storage.c@772,38: expected ')' before 'PRIx64'
[Warning] ws_pae_key_storage.c@772,13: spurious trailing '%' in format [-Wformat=]
[Error] ws_pae_key_storage.c@835,51: expected ')' before 'PRIi64'
[Warning] ws_pae_key_storage.c@835,22: spurious trailing '%' in format [-Wformat=]
[Error] ws_pae_key_storage.c@864,40: expected ')' before 'PRIx64'
[Warning] ws_pae_key_storage.c@864,13: spurious trailing '%' in format [-Wformat=]
[Error] ws_pae_key_storage.c@937,59: expected ')' before 'PRIi64'
[Warning] ws_pae_key_storage.c@937,21: spurious trailing '%' in format [-Wformat=]
[Error] ws_pae_key_storage.c@953,59: expected ')' before 'PRIi64'
[Warning] ws_pae_key_storage.c@953,21: spurious trailing '%' in format [-Wformat=]
[Error] ws_pae_key_storage.c@973,46: expected ')' before 'PRIi64'
[Warning] ws_pae_key_storage.c@973,18: spurious trailing '%' in format [-Wformat=]
[ERROR] In file included from ./mbed-os/connectivity/libraries/nanostack-libservice/mbed-client-libservice/ns_trace.h:32,
                 from ./mbed-os/connectivity/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_key_storage.c:22:
./mbed-os/connectivity/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_key_storage.c: In function 'ws_pae_key_storage_supp_write':
./mbed-os/connectivity/nanostack/sal-stack-nanostack/source/6LoWPAN/ws/ws_pae_key_storage.c:411:42: error: expected ')' before 'PRIi64'
  411 |         tr_error("KeyS write time err: %"PRIi64", ref: %"PRIi64", diff: %"PRIi32, ws_pae_current_time_get(), key_storage_array->storage_array_handle->reference_time, time_difference);
      |                                          ^~~~~~

I’m using:

arm-none-eabi-gcc (15:9-2019-q4-0ubuntu1) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

When I use Mbed Studio it uses the ARMC6 toolchain. It finishes compiling but produces a linker error:

Compile [ 99.9%]: us_ticker.c
Compile [100.0%]: stm_spi_api.c
Link: 405_Target
[Warning] @0,0: L3912W: Option 'legacyalign' is deprecated.
[Error] @0,0: L6218E: Undefined symbol PinMap_UART_CTS (referred from BUILD/MTS_MDOT_F405RG/ARMC6/mbed-os/targets/TARGET_STM/TARGET_STM32F4/serial_device.o).
[Error] @0,0: L6218E: Undefined symbol PinMap_UART_RTS (referred from BUILD/MTS_MDOT_F405RG/ARMC6/mbed-os/targets/TARGET_STM/TARGET_STM32F4/serial_device.o).
Warning: L3912W: Option 'legacyalign' is deprecated.
Error: L6218E: Undefined symbol PinMap_UART_CTS (referred from BUILD/MTS_MDOT_F405RG/ARMC6/mbed-os/targets/TARGET_STM/TARGET_STM32F4/serial_device.o).
Error: L6218E: Undefined symbol PinMap_UART_RTS (referred from BUILD/MTS_MDOT_F405RG/ARMC6/mbed-os/targets/TARGET_STM/TARGET_STM32F4/serial_device.o).
Finished: 0 information, 1 warning and 2 error messages.
[ERROR] Warning: L3912W: Option 'legacyalign' is deprecated.
Error: L6218E: Undefined symbol PinMap_UART_CTS (referred from BUILD/MTS_MDOT_F405RG/ARMC6/mbed-os/targets/TARGET_STM/TARGET_STM32F4/serial_device.o).
Error: L6218E: Undefined symbol PinMap_UART_RTS (referred from BUILD/MTS_MDOT_F405RG/ARMC6/mbed-os/targets/TARGET_STM/TARGET_STM32F4/serial_device.o).
Finished: 0 information, 1 warning and 2 error messages.

Which version of gcc_arm did you use @MACRUM ?

My build environment is below:

gcc_arm

arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

python
Python 3.8.1

mbed-cli
1.10.5

For Mbed Studio build (ARMC6), I got same error. To avoid this error, you can add below config in your custom_targets.json.

"device_has_remove": ["SERIAL_FC"],

Or, you have to add proper pinmap config in the PeripheralPins.c for your target, for example: