Skip to content

feat(nucleo-f401re): implement comprehensive ThreadX RTOS monitor and primitives showcase#40

Open
AmmarOkla12772 wants to merge 11 commits into
eclipse-threadx:devfrom
AmmarOkla12772:main
Open

feat(nucleo-f401re): implement comprehensive ThreadX RTOS monitor and primitives showcase#40
AmmarOkla12772 wants to merge 11 commits into
eclipse-threadx:devfrom
AmmarOkla12772:main

Conversation

@AmmarOkla12772

Copy link
Copy Markdown
Contributor

Overview

This PR extends the validation demo for the STMicroelectronics NUCLEO-F401RE board under STMicroelectronics/NUCLEO_F401RE/.

The goal is to provide a comprehensive ThreadX RTOS demonstration showcasing dynamic memory management, runtime diagnostics, thread monitoring, and synchronization primitives using public ThreadX APIs.

Changes

  • Replaced static thread stack allocation with a central TX_BYTE_POOL
  • Added runtime memory diagnostics reporting total, allocated, and free byte pool capacity
  • Added TX_BLOCK_POOL for fixed-size deterministic memory allocation
  • Added message passing between sender and receiver threads using TX_QUEUE
  • Added pointer-based queue transfers backed by block pool allocations
  • Added TX_MUTEX synchronization with two competing worker threads sharing a simulated SPI resource
  • Added TX_EVENT_FLAGS_GROUP synchronization between the LED heartbeat thread and an event-processing thread
  • Added TX_SEMAPHORE synchronization with a dedicated consumer thread awakened by LED activity
  • Added TX_TIMER periodic callback executing once per second from the ThreadX system timer thread
  • Expanded the demo from 3 threads to 9 threads to exercise core ThreadX scheduling and synchronization features
  • Added registry-based thread diagnostics using tx_thread_info_get()
  • Added stack high-water mark monitoring by scanning the ThreadX stack fill pattern (0xEFEFEFEF)
  • Added per-thread stack usage and utilization reporting
  • Added formatted runtime telemetry output over USART2 including thread states, priorities, run counts, memory statistics, and synchronization activity counters

Validation

Tested on physical NUCLEO-F401RE board:

  • System runs continuously without crashes or scheduler instability
  • UART output remains stable at 115200 baud
  • Free memory remains constant at 79028 bytes during operation, indicating no byte pool or block pool leaks
  • Thread diagnostics correctly report state transitions, run counts, priorities, and stack watermarks
  • Stack utilization remains within safe limits for all threads
  • System uptime tracks wall-clock time accurately
  • ThreadX synchronization primitives operate as expected under active scheduling
  • No build warnings with Arm GNU Toolchain 15.2.Rel1

Toolchain

  • Arm GNU Toolchain 15.2.Rel1
  • CMake + Ninja build system

Notes

All runtime diagnostics are implemented using documented ThreadX public APIs. No private kernel structures or undocumented internal ThreadX data are accessed, maintaining portability across ThreadX targets.

	new file:   STMicroelectronics/NUCLEO_F401RE/README.md
	new file:   STMicroelectronics/NUCLEO_F401RE/app/CMakeLists.txt
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/board_init.c
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/board_init.h
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/console.c
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/sntp_client.c
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/startup/NUCLEO_F401RE.ld
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/startup/startup_stm32f401xe.s
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/startup/tx_initialize_low_level.S
	new file:   STMicroelectronics/NUCLEO_F401RE/app/common/stm32cubef4/stm32f4xx_hal_msp.c
	new file:   STMicroelectronics/NUCLEO_F401RE/app/starter/cloud_config.h
	new file:   STMicroelectronics/NUCLEO_F401RE/app/starter/main.c
	new file:   STMicroelectronics/NUCLEO_F401RE/cmake/FindCMSIS.cmake
	new file:   STMicroelectronics/NUCLEO_F401RE/cmake/FindSTM32HAL.cmake
	new file:   STMicroelectronics/NUCLEO_F401RE/cmake/arm-gcc-cortex-m4.cmake
	new file:   STMicroelectronics/NUCLEO_F401RE/cmake/arm-gcc-cortex-toolchain.cmake
	new file:   STMicroelectronics/NUCLEO_F401RE/cmake/utilities.cmake
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/CMakeLists.txt
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/nucleo_bsp/CMakeLists.txt
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/nucleo_bsp/nucleo_bsp.c
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/nucleo_bsp/nucleo_bsp.h
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/stm32cubef4/CMakeLists.txt
	new file:   STMicroelectronics/NUCLEO_F401RE/lib/stm32cubef4/config/stm32f4xx_hal_conf.h
Booted ThreadX on NUCLEO-F401RE
Validated scheduler operation
Validated UART console output
Validated LED thread
Validated flashing and hardware execution
…and event flags. Modified demo README file to reflect changes.
…aphore functionality and 1 hz applicaion timer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants