Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


Convert to C++ project - some hints

Hey folks,

first of all: nice project and I hope that it will go on in this way :-)

Here are some annotations and problems I had while generating a C++ project.

  • I am running the plugin on 1.7.0 under Windows with Eclipse Mars as System Workbench for STM32
  • I tested CubeMX generated projects and Eclipse generated projects


To convert a project to C++, check all of the points:

  • if someone does not find the convert to C++ project: Window –> Show View –> Project Explorer (do NOT use the context menu New --> convert to C/C++ stuff!!!)
  • after conversion, check the settings of the G++ compiler under: -> Properties -> C/C++ Build -> Settings -> MCU G++ (“you must at least check that the C++ compile build settings (in project >> Properties >> C/C++ Build >> Settings) are coherent with those from the C Compiler (mainly symbol definitions, include files and libraries)” - http://www.openstm32.org/tiki-view_forum_thread.php?comments_parentId=1231&display=printQuestion )
    • for an Eclipse generated project this did not work at all
    • for a CubeMX project it seemed to work
    • so I took the information from a CubeMX project and copied it to an Eclipse generated project (before doing this, close the Workbench/Eclipse) - but do this carefully otherwise your Eclipse might get troubles :-D (1) (2) (3)
  • to get rid of the _sbrk error: “but you also must add linker flags -specs=nosys.specs -specs=nano.specs in C/C++ Build >> Settings >> MCU G++ Linker >> Miscellaneous” ( source: http://www.openstm32.org/tiki-view_forum_thread.php?comments_parentId=1231&display=printQuestion )
  • modify the linker script (for a CubeMX project I could use (but this also depends on the target): ${workspace_loc:/${ProjName}/STM32F407IGHx_FLASH.ld} ) - for details refer again: http://www.openstm32.org/tiki-view_forum_thread.php?comments_parentId=1231&display=printQuestion
  • for me it still did not work. Reason: Reading the Build Console carefully, the main.cpp files still was compiled with ‘Invoking: MCU GCC Compiler’ instead of ‘Invoking: MCU G++ Compiler’. Solution: rename main.c to main.cpp in Eclipse
    • Caveat at a CubeMX project: I renamed the main.c to main.cpp inside Eclipse but the path still pointed to a main.c file. So do following:
    • open file explorer, open the folder /Src/ and rename main.c to main.cpp
    • open the folder /SW4STM32// and open .project
    • search for main.c and modify this path to: PARENT-2-PROJECT_LOC/Src/main.cpp


THEN it finally should work :-)
For the developers of the Workbench/plugin: maybe you could fix the mentioned problems in the future.

annotations:
(1) doing this inside Eclipse might be totally crap. I did following: I diffed the .cproject files and copied the stuff line by line. If someone might have trouble because of missing new lines, one can use notepad++ together with the XML tools plugin to reformat.

(2) For the Eclipse generated project: under properties -> C/C++ Build -> Settings -> MCU G++ Builder -> All options for me it looks like in the end:

  • -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Dweak=”attributeweak” -Dpacked=”attributepacked” -DUSE_HAL_DRIVER -DSTM32F407xx -I”C:\workspace\stm3240g-eval_hal_lib” -I”C:\workspace\/inc” -I”C:\workspace\stm3240g-eval_hal_lib\CMSIS\core” -I”C:\workspace\stm3240g-eval_hal_lib\CMSIS\device” -I”C:\workspace\stm3240g-eval_hal_lib\HAL_Driver\Inc\Legacy” -I”C:\workspace\stm3240g-eval_hal_lib\HAL_Driver\Inc” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\ampire480272” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\ampire640480” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\Common” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\cs43l22” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\exc7200” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\ili9325” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\ili9341” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\l3gd20” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\lis302dl” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\lis3dsh” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\lsm303dlhc” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\mfxstm32l152” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\n25q256a” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\ov2640” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\s5k5cag” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\st7735” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\stmpe1600” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\stmpe811” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\ts3510” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Components\wm8994” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Fonts” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\Log” -I”C:\workspace\stm3240g-eval_hal_lib\Utilities\STM324xG_EVAL” -O0 -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fno-exceptions -fno-rtti


(3) For the CubeMX generated project: under properties -> C/C++ Build -> Settings -> MCU G++ Builder -> All options for me it looks like in the end:

  • -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Dweak=”attributeweak” -Dpacked=”attributepacked” -DUSE_HAL_DRIVER -DSTM32F407xx -I../../../Inc -I../../../Drivers/STM32F4xx_HAL_Driver/Inc -I../../../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I../../../Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I../../../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc -I../../../Drivers/CMSIS/Include -I../../../Drivers/CMSIS/Device/ST/STM32F4xx/Include -O0 -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fno-exceptions -fno-rtti


(sorry, the bold printed stuff should be underscores. I do not find the verbatim environment :-/ )

hmm for me it’s saying :
Src/stm32f1xx_hal_msp.o: In function `HAL_SPI_MspInit’:
... Debug/../Src/stm32f1xx_hal_msp.c:125: undefined reference to `Error_Handler’

The error handler is a function created by cubemx and is located in my main.cpp

void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler */
/* User can add his own implementation to report the HAL error return state */
while(1)
{
}
/* USER CODE END Error_Handler */
}

Hi DW. How did you fix the undefined reference to `Error_Handler’?
Turned out there was a fault in my code but I can’t remember where. sorry

Hi, to use Error_Handler() function go to main.h file and change section to this:

/* USER CODE BEGIN Private defines */
#ifdef __cplusplus
extern "C" {
#endif

void _Error_Handler(char *, int);

#ifdef __cplusplus
}
#endif
/* USER CODE END Private defines */

#define Error_Handler() _Error_Handler(__FILE__, __LINE__)

it does not solve the problem

there are other options?


 

Newest Forum Posts

  1. Монтаж камина с грилем в Москве - установка и барбекю by KpddomErorb, 2025-05-10 18:28
  2. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs