Help Compiling in CLI

I am trying to compile a project that I have exported from mbed online IDE (OS 6) so that I can create an ELF file for debugging with gdb. I followed the prompts in the documentation for compiling in mbed CLI and every time I try to issue a command within my project directory it gives me: “[mbed] ERROR: The mbed tools were not found in .
You can run “mbed deploy” to install dependencies and tools.”
I indeed ran “mbed deploy” and got the same error about the mbed tools directory.

I have been endlessly searching for an answer to this to no avail. I am using an ST Nucleo F429ZI and want to compile my program into an ELF file so I can debug with openocd/gdb. The following is what I have done so far:

  • Export from mbed online for GCC-ARM
  • Within exported project directory, set my target to STM32F429ZI and my toolchain to GCC_ARM
  • Ran “mbed compiile --profile debug”
  • Cannot proceed further after receiving error message described above.

I have also tried importing my program from mbed online with the CLI in order to export from CLI instead, hoping the missing tools would be found, but the import command gets stuck every time I try (literally left it overnight and nothing happened). I have run out of solutions to try and can’t find any new information to help me. Any guidance would be greatly appreciated.

Hello Lauren,

You can try the following:

  • Delete the mbed-os folder from the exported project directory.
  • Open https://github.com/ARMmbed/mbed-os and download the zipped mbed-os archive file (click on Code and Download ZIP).
  • Unzip the archive file to the exported project directory.
  • Open a command prompt in the exported project directory and run
mbed compile -m NUCLEO_F429ZI --profile debug

Best regards, Zoltan

Hi Zoltan,

Thanks for the help. That seemed to fix the tool directory issue I was having. Whenever I now enter the compile command above, I get this:

C:\Users\Lauren\Documents\Work\Embedded Fuzzing Design\Debugging\NucleoFuzzTest>mbed compile -m NUCLEO_F4Preformatted text29ZI --profile debug
[mbed] Working path “C:\Users\Lauren\Documents\Work\Embedded Fuzzing Design\Debugging\NucleoFuzzTest” (program)
WARNING: MBED_GCC_ARM_PATH set as environment variable but doesn’t exist
[Warning] @,: Compiler version mismatch: Have 6.3.1; expected version >= 9.0.0 and < 10.0.0
Building project NucleoFuzzTest (NUCLEO_F429ZI, GCC_ARM)
Scan: NucleoFuzzTest
WARNING: MBED_GCC_ARM_PATH set as environment variable but doesn’t exist
WARNING: MBED_GCC_ARM_PATH set as environment variable but doesn’t exist
WARNING: MBED_GCC_ARM_PATH set as environment variable but doesn’t exist
WARNING: MBED_GCC_ARM_PATH set as environment variable but doesn’t exist
WARNING: MBED_GCC_ARM_PATH set as environment variable but doesn’t exist
WARNING: MBED_GCC_ARM_PATH set as environment variable but doesn’t exist
WARNING: MBED_GCC_ARM_PATH set as environment variable but doesn’t exist
WARNING: MBED_GCC_ARM_PATH set as environment variable but doesn’t exist
Compile [ 0.1%]: mbed_tz_context.c
Compile [ 0.2%]: AT_CellularInformation.cpp
[Warning] stm32f4xx_ll_tim.h@2797,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
[Warning] stm32f4xx_ll_tim.h@2814,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
[Warning] stm32f4xx_ll_tim.h@2834,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
Compile [ 0.3%]: AT_CellularSMS.cpp
Compile [ 0.4%]: AT_CellularDevice.cpp
[Warning] stm32f4xx_ll_tim.h@2797,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
[Warning] stm32f4xx_ll_tim.h@2814,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
[Warning] stm32f4xx_ll_tim.h@2834,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
Compile [ 0.5%]: AT_CellularNetwork.cpp
[Warning] stm32f4xx_ll_tim.h@2797,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
[Warning] stm32f4xx_ll_tim.h@2814,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
[Warning] stm32f4xx_ll_tim.h@2834,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
Compile [ 0.6%]: AT_CellularContext.cpp
[Warning] stm32f4xx_ll_tim.h@2797,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
[Warning] stm32f4xx_ll_tim.h@2814,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
[Warning] stm32f4xx_ll_tim.h@2834,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
Compile [ 0.8%]: CellularLog.cpp
Compile [ 0.9%]: APN_db.cpp
Compile [ 1.0%]: MFRC522.cpp
[Warning] stm32f4xx_ll_tim.h@2797,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
[Warning] stm32f4xx_ll_tim.h@2814,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
[Warning] stm32f4xx_ll_tim.h@2834,10: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
[Error] MFRC522.cpp@251,13: ‘wait_ms’ was not declared in this scope
[Error] MFRC522.cpp@282,13: ‘wait_ms’ was not declared in this scope
[ERROR] In file included from ./mbed-os/targets/TARGET_STM/TARGET_STM32F4/common_objects.h:38:0,
from ./mbed-os/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F429xI/objects.h:61,
from ./mbed-os/targets/TARGET_STM/device.h:38,
from ./mbed-os/hal/ticker_api.h:25,
from ./mbed-os/connectivity/netsocket/include/netsocket/SocketStats.h:24,
from ./mbed-os/connectivity/netsocket/include/netsocket/InternetSocket.h:30,
from ./mbed-os/connectivity/netsocket/include/netsocket/UDPSocket.h:23,
from ./mbed-os/connectivity/netsocket/include/netsocket/nsapi.h:40,
from ./mbed-os/mbed.h:26,
from .\MFRC522\MFRC522.h:77,
from .\MFRC522\MFRC522.cpp:7:
./mbed-os/targets/TARGET_STM/TARGET_STM32F4/STM32Cube_FW/STM32F4xx_HAL_Driver/stm32f4xx_ll_tim.h: In function ‘void LL_TIM_EnableBRK(TIM_TypeDef*)’:
./mbed-os/targets/TARGET_STM/TARGET_STM32F4/STM32Cube_FW/STM32F4xx_HAL_Driver/stm32f4xx_ll_tim.h:2797:10: warning: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
(void)(tmpreg);
~^~~~~~~
./mbed-os/targets/TARGET_STM/TARGET_STM32F4/STM32Cube_FW/STM32F4xx_HAL_Driver/stm32f4xx_ll_tim.h: In function ‘void LL_TIM_DisableBRK(TIM_TypeDef*)’:
./mbed-os/targets/TARGET_STM/TARGET_STM32F4/STM32Cube_FW/STM32F4xx_HAL_Driver/stm32f4xx_ll_tim.h:2814:10: warning: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
(void)(tmpreg);
~^~~~~~~
./mbed-os/targets/TARGET_STM/TARGET_STM32F4/STM32Cube_FW/STM32F4xx_HAL_Driver/stm32f4xx_ll_tim.h: In function ‘void LL_TIM_ConfigBRK(TIM_TypeDef*, uint32_t)’:
./mbed-os/targets/TARGET_STM/TARGET_STM32F4/STM32Cube_FW/STM32F4xx_HAL_Driver/stm32f4xx_ll_tim.h:2834:10: warning: conversion to void will not access object of type ‘volatile uint32_t {aka volatile long unsigned int}’
(void)(tmpreg);
~^~~~~~~
.\MFRC522\MFRC522.cpp: In member function ‘void MFRC522::PCD_Init()’:
.\MFRC522\MFRC522.cpp:251:13: error: ‘wait_ms’ was not declared in this scope
wait_ms(10);
^
.\MFRC522\MFRC522.cpp: In member function ‘void MFRC522::PCD_Reset()’:
.\MFRC522\MFRC522.cpp:282:13: error: ‘wait_ms’ was not declared in this scope
wait_ms(50);
^

[mbed] ERROR: “c:\users\lauren\appdata\local\programs\python\python38\python.exe” returned error.
Code: 1
Path: “C:\Users\Lauren\Documents\Work\Embedded Fuzzing Design\Debugging\NucleoFuzzTest”
Command: “c:\users\lauren\appdata\local\programs\python\python38\python.exe -u C:\Users\Lauren\Documents\Work\Embedded Fuzzing Design\Debugging\NucleoFuzzTest\mbed-os\tools\make.py -t GCC_ARM -m NUCLEO_F429ZI --profile debug --source . --build .\BUILD\NUCLEO_F429ZI\GCC_ARM-DEBUG”
Tip: You could retry the last command with “-v” flag for verbose output

I am not sure how to proceed from here. I think I see basically two types of errors : errors from the MFRC522 library and the python error at the bottom. The MRFC522 library was imported into my mbed online project, which compiled fine in mbed online. I am not sure how to fix these errors in order to get compilation, appreciate any further guidance.

  • Delete the MFRC522 folder from the exported project directory.
  • In the online compiler click on the MFRC522 folder. Then click on the URL link (top-right corner). Once the MRFC522 library page is open copy the library’s URL (e.g. https://os.mbed.com/users/AtomX/code/MFRC522/) to the clipboard.
  • Open a command prompt in the exported project directory and type
mbed import `paste here the library's URL`
  • Hit ENTER. This should import the MRFC522 into your offline project.

  • Recompile the project.

Okay, I deleted the folder in my exported project directory, opened a new command prompt and entered “mbed import https://os.mbed.com/users/AtomX/code/MFRC522/” and got the following:
[mbed] ERROR: Cannot import program in the specified location “” because it’s already part of a program “”.
Please change your working directory to a different location or use “mbed add” to import the URL as a library.

Do I need to use ‘add’ instead or is there some other issue?

Use add instead of import as suggested.

So, I added the libraries as suggested above and still got errors. I also tried compiling an example program (blinky) which was successful (as expected), then added the libraries I use in my other program to the example program just to see what happens, and I got the same errors as I did before with both the MFRC522 and TextLCD libraries. The only thing I changed was adding these libraries one at a time and both of them caused the compilation to quit with errors. Example: “.\TextLCD\TextLCD.cpp:94:19: error: ‘wait’ was not declared in this scope
wait(0.000040f);”

Is there a way to fix this or understand why these libraries will compile in the online IDE but not in this way?

The error message:

 .\TextLCD\TextLCD.cpp:94:19: error: ‘wait’ was not declared in this scope
wait(0.000040f);”

indicates that the used library is not compatible with Mbed OS 6. Check the revision of Mbed OS used by the online compiler: Right-click on mbed-os in the online project and select Revisions...

You can fix such error when building with Mbed OS 6 by replacing the wait function with suitable Mbed OS 6 function.
For example:
wait(0.000040f); can be replaced with wait_us(40);
wait_ms(50); can be replaced with ThisThread::sleep_for(50ms);

At the moment the MbedStudio IDE supports debugging only on a few target boards. So if you would like to debug with OpenOCD (and pyOCD) and don’t mind to use Linux then you can try Building and debugging offline on Linux with QtCreator IDE.