-
Notifications
You must be signed in to change notification settings - Fork 4
feat(bsp): add STM32F767ZI-Nucleo board enablement verified by ThreadX demo #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alieissa-commits
wants to merge
2
commits into
eclipse-threadx:dev
Choose a base branch
from
alieissa-commits:feature/stm32f767-board-enablement
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| # Copyright (c) 2026-present Eclipse ThreadX contributors | ||
| # | ||
| # This program and the accompanying materials are made available | ||
| # under the terms of the MIT license which is available at | ||
| # https://opensource.org/license/mit. | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # Contributors: | ||
| # Ali Eissa - 2026 version. | ||
|
|
||
| cmake_minimum_required(VERSION 3.5 FATAL_ERROR) | ||
| set(CMAKE_C_STANDARD 99) | ||
|
|
||
| # Set the toolchain if not defined | ||
| if(NOT CMAKE_TOOLCHAIN_FILE) | ||
| set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/cmake/arm-gcc-cortex-m7.cmake") | ||
| endif() | ||
|
|
||
| list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) | ||
|
|
||
| include(utilities) | ||
|
|
||
| # Define the Project | ||
| project(stm32f767_threadx C CXX ASM) | ||
|
|
||
| # Define ThreadX User Configurations | ||
| set(TX_USER_FILE "${CMAKE_CURRENT_LIST_DIR}/lib/threadx/tx_user.h" CACHE STRING "Enable TX user configuration") | ||
| set(TX_USER_FILE_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/threadx") | ||
|
|
||
| # Set up standard paths for find modules | ||
| set(STM32_FAMILY "F7") | ||
| set(STM32Cube_DIR "${CMAKE_CURRENT_LIST_DIR}/lib/stm32cubef7") | ||
|
|
||
| # Find CMSIS and HAL driver packages | ||
| find_package(CMSIS REQUIRED) | ||
| find_package(STM32HAL REQUIRED COMPONENTS cortex pwr rcc gpio uart dma eth) | ||
|
|
||
| # Compile the STM32F7xx HAL Driver Library as an Object Library | ||
| set(HAL_TARGET stm32cubef7) | ||
| add_library(${HAL_TARGET} OBJECT ${STM32HAL_SOURCES}) | ||
|
|
||
| target_compile_definitions(${HAL_TARGET} | ||
| PUBLIC | ||
| STM32F767xx | ||
| USE_HAL_DRIVER | ||
| STM32F7 | ||
| ) | ||
|
|
||
| target_include_directories(${HAL_TARGET} | ||
| PUBLIC | ||
| ${CMSIS_INCLUDE_DIRS} | ||
| ${STM32HAL_INCLUDE_DIR} | ||
| ${CMAKE_CURRENT_LIST_DIR}/app | ||
| ) | ||
|
|
||
| # Compile ThreadX Kernel from root shared libs submodule | ||
| set(THREADX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../libs/threadx") | ||
| add_subdirectory(${THREADX_DIR} threadx) | ||
|
|
||
| # Create the Main Executable | ||
| set(EXE_TARGET stm32f767_threadx) | ||
|
|
||
| add_executable(${EXE_TARGET} | ||
| app/startup/startup_stm32f767zitx.s | ||
| app/startup/system_stm32f7xx.c | ||
| app/startup/tx_initialize_low_level.S | ||
| app/board_init.c | ||
| app/console.c | ||
| app/ethernet_phy.c | ||
| app/main.c | ||
| app/stm32f7xx_hal_msp.c | ||
| app/sysmem.c | ||
| app/syscalls.c | ||
| ) | ||
|
|
||
| # Set compile definitions for our executable | ||
| target_compile_definitions(${EXE_TARGET} | ||
| PRIVATE | ||
| STM32F767xx | ||
| USE_HAL_DRIVER | ||
| STM32F7 | ||
| ) | ||
|
|
||
| # Include paths | ||
| target_include_directories(${EXE_TARGET} | ||
| PRIVATE | ||
| ${CMAKE_CURRENT_LIST_DIR}/app | ||
| ${CMSIS_INCLUDE_DIRS} | ||
| ${STM32HAL_INCLUDE_DIR} | ||
| ${TX_USER_FILE_DIR} | ||
| ) | ||
|
|
||
| # Link libraries (includes ThreadX kernel and HAL object libraries) | ||
| target_link_libraries(${EXE_TARGET} | ||
| PRIVATE | ||
| threadx | ||
| stm32cubef7 | ||
| ) | ||
|
|
||
| # Apply GCC linker script and print memory usage (utilities.cmake function) | ||
| set_target_linker(${EXE_TARGET} "${CMAKE_CURRENT_LIST_DIR}/app/startup/STM32F767ZITx_FLASH.ld") | ||
|
|
||
| # Post-build commands to generate raw .bin and .hex files | ||
| post_build(${EXE_TARGET}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,204 @@ | ||
| /* | ||
| * Copyright (c) 2026-present Eclipse ThreadX contributors | ||
| * | ||
| * This program and the accompanying materials are made available | ||
| * under the terms of the MIT license which is available at | ||
| * https://opensource.org/license/mit. | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| * | ||
| * Contributors: | ||
| * Ali Eissa - 2026 version. | ||
| */ | ||
|
|
||
| #include "board_init.h" | ||
| #include <string.h> | ||
|
|
||
| /* Global UART handler */ | ||
| UART_HandleTypeDef huart3; | ||
|
|
||
| void SystemClock_Config(void); | ||
| void MPU_Config(void); | ||
| void MX_GPIO_Init(void); | ||
| void MX_USART3_UART_Init(void); | ||
|
|
||
| /** | ||
| * @brief Initializes the board clocks, MPU, GPIOs, and serial console. | ||
| * Direct copy of the STM32CubeMX initialization sequence. | ||
| * @retval None | ||
| */ | ||
| void board_init(void) | ||
| { | ||
| /* Configure the Memory Protection Unit */ | ||
| MPU_Config(); | ||
|
|
||
| /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ | ||
| HAL_Init(); | ||
|
|
||
| /* Configure the system clock to 216 MHz */ | ||
| SystemClock_Config(); | ||
|
|
||
| /* Initialize base GPIO pins */ | ||
| MX_GPIO_Init(); | ||
|
|
||
| /* Initialize USART3 console */ | ||
| MX_USART3_UART_Init(); | ||
| } | ||
|
|
||
| /** | ||
| * @brief System Clock Configuration (216 MHz using ST-LINK 8 MHz HSE bypass) | ||
| * Un-modified copy of STM32CubeMX generated Clock Configuration. | ||
| * @retval None | ||
| */ | ||
| void SystemClock_Config(void) | ||
| { | ||
| RCC_OscInitTypeDef RCC_OscInitStruct = {0}; | ||
| RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; | ||
|
|
||
| /** Configure LSE Drive Capability | ||
| */ | ||
| HAL_PWR_EnableBkUpAccess(); | ||
|
|
||
| /** Configure the main internal regulator output voltage | ||
| */ | ||
| __HAL_RCC_PWR_CLK_ENABLE(); | ||
| __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); | ||
|
|
||
| /** Initializes the RCC Oscillators according to the specified parameters | ||
| * in the RCC_OscInitTypeDef structure. | ||
| */ | ||
| RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; | ||
| RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; | ||
| RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; | ||
| RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; | ||
| RCC_OscInitStruct.PLL.PLLM = 4; | ||
| RCC_OscInitStruct.PLL.PLLN = 216; | ||
| RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; | ||
| RCC_OscInitStruct.PLL.PLLQ = 9; | ||
| RCC_OscInitStruct.PLL.PLLR = 2; | ||
| if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) | ||
| { | ||
| Error_Handler(); | ||
| } | ||
|
|
||
| /** Activate the Over-Drive mode | ||
| */ | ||
| if (HAL_PWREx_EnableOverDrive() != HAL_OK) | ||
| { | ||
| Error_Handler(); | ||
| } | ||
|
|
||
| /** Initializes the CPU, AHB and APB buses clocks | ||
| */ | ||
| RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK | ||
| |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; | ||
| RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; | ||
| RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; | ||
| RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; | ||
| RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; | ||
|
|
||
| if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_7) != HAL_OK) | ||
| { | ||
| Error_Handler(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief USART3 Initialization Function | ||
| * | ||
| * @retval None | ||
| */ | ||
| void MX_USART3_UART_Init(void) | ||
| { | ||
| huart3.Instance = USART3; | ||
| huart3.Init.BaudRate = 115200; | ||
| huart3.Init.WordLength = UART_WORDLENGTH_8B; | ||
| huart3.Init.StopBits = UART_STOPBITS_1; | ||
| huart3.Init.Parity = UART_PARITY_NONE; | ||
| huart3.Init.Mode = UART_MODE_TX_RX; | ||
| huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE; | ||
| huart3.Init.OverSampling = UART_OVERSAMPLING_16; | ||
| huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; | ||
| huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; | ||
| if (HAL_UART_Init(&huart3) != HAL_OK) | ||
| { | ||
| Error_Handler(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief GPIO Initialization Function | ||
| * | ||
| * @retval None | ||
| */ | ||
| void MX_GPIO_Init(void) | ||
| { | ||
| GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||
|
|
||
| /* GPIO Ports Clock Enable */ | ||
| __HAL_RCC_GPIOC_CLK_ENABLE(); | ||
| __HAL_RCC_GPIOH_CLK_ENABLE(); | ||
| __HAL_RCC_GPIOA_CLK_ENABLE(); | ||
| __HAL_RCC_GPIOB_CLK_ENABLE(); | ||
| __HAL_RCC_GPIOD_CLK_ENABLE(); | ||
| __HAL_RCC_GPIOG_CLK_ENABLE(); | ||
|
|
||
| /*Configure GPIO pin Output Level */ | ||
| HAL_GPIO_WritePin(GPIOB, LD1_Pin|LD3_Pin|LD2_Pin, GPIO_PIN_RESET); | ||
|
|
||
| /*Configure GPIO pin : USER_Btn_Pin */ | ||
| GPIO_InitStruct.Pin = USER_Btn_Pin; | ||
| GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; | ||
| GPIO_InitStruct.Pull = GPIO_NOPULL; | ||
| HAL_GPIO_Init(USER_Btn_GPIO_Port, &GPIO_InitStruct); | ||
|
|
||
| /*Configure GPIO pins : LD1_Pin LD3_Pin LD2_Pin */ | ||
| GPIO_InitStruct.Pin = LD1_Pin|LD3_Pin|LD2_Pin; | ||
| GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | ||
| GPIO_InitStruct.Pull = GPIO_NOPULL; | ||
| GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; | ||
| HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||
| } | ||
|
|
||
| /** | ||
| * @brief MPU Configuration | ||
| * | ||
| * @retval None | ||
| */ | ||
| void MPU_Config(void) | ||
| { | ||
| MPU_Region_InitTypeDef MPU_InitStruct = {0}; | ||
|
|
||
| /* Disables the MPU */ | ||
| HAL_MPU_Disable(); | ||
|
|
||
| /** Initializes and configures the Region and the memory to be protected | ||
| */ | ||
| MPU_InitStruct.Enable = MPU_REGION_ENABLE; | ||
| MPU_InitStruct.Number = MPU_REGION_NUMBER0; | ||
| MPU_InitStruct.BaseAddress = 0x0; | ||
| MPU_InitStruct.Size = MPU_REGION_SIZE_4GB; | ||
| MPU_InitStruct.SubRegionDisable = 0x87; | ||
| MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; | ||
| MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS; | ||
| MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE; | ||
| MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; | ||
| MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; | ||
| MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; | ||
|
|
||
| HAL_MPU_ConfigRegion(&MPU_InitStruct); | ||
| /* Enables the MPU */ | ||
| HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); | ||
| } | ||
|
|
||
| /** | ||
| * @brief This function is executed in case of error occurrence. | ||
| * @retval None | ||
| */ | ||
| void Error_Handler(void) | ||
| { | ||
| __disable_irq(); | ||
| while (1) | ||
| { | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Copyright (c) 2026-present Eclipse ThreadX contributors | ||
| * | ||
| * This program and the accompanying materials are made available | ||
| * under the terms of the MIT license which is available at | ||
| * https://opensource.org/license/mit. | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| * | ||
| * Contributors: | ||
| * Ali Eissa - 2026 version. | ||
| */ | ||
|
|
||
| #ifndef _BOARD_INIT_H | ||
| #define _BOARD_INIT_H | ||
|
|
||
| /* Official STM32CubeMX generated header containing hardware pin defines */ | ||
| #include "main.h" | ||
|
|
||
| /* Nucleo-144 User Button (active high) */ | ||
| #define BUTTON_PIN USER_Btn_Pin | ||
| #define BUTTON_IS_PRESSED ((USER_Btn_GPIO_Port->IDR & USER_Btn_Pin) != 0) | ||
|
|
||
| /* Nucleo-144 User LEDs: PB0 (Green), PB7 (Blue), PB14 (Red) mapped via STM32CubeMX defines */ | ||
| #define LED1_ON() LD1_GPIO_Port->BSRR = LD1_Pin | ||
| #define LED1_OFF() LD1_GPIO_Port->BSRR = (uint32_t)LD1_Pin << 16 | ||
|
|
||
| #define LED2_ON() LD2_GPIO_Port->BSRR = LD2_Pin | ||
| #define LED2_OFF() LD2_GPIO_Port->BSRR = (uint32_t)LD2_Pin << 16 | ||
|
|
||
| #define LED3_ON() LD3_GPIO_Port->BSRR = LD3_Pin | ||
| #define LED3_OFF() LD3_GPIO_Port->BSRR = (uint32_t)LD3_Pin << 16 | ||
|
|
||
| /* Redirect UartHandle directly to STM32CubeMX global huart3 */ | ||
| extern UART_HandleTypeDef huart3; | ||
| #define UartHandle huart3 | ||
|
|
||
| /* Define prototypes. */ | ||
| void board_init(void); | ||
|
|
||
| #endif // _BOARD_INIT_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the upcoming Q2 release, I must correct all copyright statements that add "-present" to the current year. This is a mistake I made in the Q1 release.
Please perform a search and replace and ensure that the statement in all the files you produced is:
Of course, if files have been generated by vendor tooling, you should respect the existing notices and add our own only if you modified the file.