igor-krechetov / hsmcpp

C++ based Hierarchical / Finite State Machine library oriented for embedded and RTOS systems.
https://hsmcpp.readthedocs.io
MIT License
71 stars 11 forks source link

Unable to build FreeRTOS posix example #7

Closed sriharsha88 closed 10 months ago

sriharsha88 commented 1 year ago

Hi @igor-krechetov,

I am trying to build hsmcpp library for Renesas Cortex M33 MCU. As a start I tried building the freertos posix port example/08_freertos. The build fails at linking stage. Its failing to link following libraries.

Where can i find these libraries? They are not available in the FreeRTOS souce directory as well. I have attached the build log. Please have a look. build-log.txt

Regards, Harsha

sriharsha88 commented 1 year ago

Hi @igor-krechetov,

I was able to port the FreeRTOS example to Renesas Cortex M33 MCU architecture. I am sharing my debugging experience here for anyone porting this library to various FreeRTOS based hardware platforms.

Following FreeRTOS configurations are must for the example/08_freertos switch example to be executed on Renesas MCU.

sriharsha88 commented 1 year ago

Hi @igor-krechetov,

Also found the following explicit type casting of timer interval parameter necessary for registerStateAction() to succeed.

(void)registerStateAction(SwitchHsmStates::Paused, hsmcpp::StateActionTrigger::ON_STATE_ENTRY, hsmcpp::StateAction::START_TIMER, static_cast(SwitchHsmTimers::RESUME), static_cast(2000), true);

Without explicit type casting, registerStateAction() would fail with 'invalid arguments' error. The 'newAction.actionArgs[1].isNumeric()' condition evaluated to false in function HierarchicalStateMachine::Impl::registerStateAction() without type casting.

igor-krechetov commented 1 year ago

Hi @sriharsha88 .

Glad this worked out for you and also thank you for sharing solution here. Though I'm curious about the FreeRTOS configuration that you mentioned. All these flags were already defined in FreeRTOSConfig.h in the 08_freertos example. And also available in the reference config in include/hsmcpp/os/freertos/FreeRTOSConfig.h . Have your tried them? I only tested the library with the POSIX simulation of the FreeRTOS so it's always helpfull to know which configurations should be used for specific MCUs.

Hi @igor-krechetov,

I was able to port the FreeRTOS example to Renesas Cortex M33 MCU architecture. I am sharing my debugging experience here for anyone porting this library to various FreeRTOS based hardware platforms.

Following FreeRTOS configurations are must for the example/08_freertos switch example to be executed on Renesas MCU.

  • INCLUDE_xTaskGetCurrentTaskHandle = 1
  • configUSE_TASK_NOTIFICATIONS = 1
  • configUSE_TIMERS = 1
  • configUSE_MUTEXES = 1
  • configSUPPORT_DYNAMIC_ALLOCATION = 1
  • configMINIMAL_STACK_SIZE = 512

As for type casting issue, this looks like a problem with code generator. I remember fixing something similar before for FreeRTOS build. I'll double check and push a fix.

igor-krechetov commented 10 months ago

Hi @sriharsha88 .

Just an update on the raised issues with FreeRTOS build before closing the ticket: