Add wolfBoot support for STM32G4#777
Open
dgarske wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds wolfBoot target support for STM32G4 (verified on NUCLEO-G491RE), including a new HAL, linker script, test application integration, and documentation updates.
Changes:
- Introduces STM32G4 HAL (clock bring-up, flash IAP, optional debug UART) and linker script.
- Adds STM32G4 test app support (LED + UART/printf) and build system wiring.
- Documents STM32G4 configuration, memory layout, flashing, and debugging steps; adds CI build coverage for the new example config.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test-app/led.c | Adds STM32G4-specific boot LED on/off implementation for NUCLEO-G491RE. |
| test-app/app_stm32g4.c | New bare-metal STM32G4 test app (LED blink + update confirmation + printf). |
| test-app/Makefile | Adds STM32G4 build flags and ensures syscalls/printf linkage. |
| hal/stm32g4.ld | New STM32G4 linker script (FLASH/RAM layout and sections). |
| hal/stm32g4.h | New STM32G4 register/bit definitions and UART/board pin constants. |
| hal/stm32g4.c | New STM32G4 HAL implementation (clock, flash write/erase, UART). |
| docs/Targets.md | Adds STM32G4 target documentation (config, layout, flashing/debugging). |
| config/examples/stm32g4.config | Adds a reference STM32G4 configuration and partition layout. |
| arch.mk | Adds STM32G4 ARCH_FLASH_OFFSET configuration. |
| .github/workflows/test-configs.yml | Adds CI build job for stm32g4 example config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+66
to
+75
| int off = (address + i) - (((address + i) >> 3) << 3); | ||
| uint32_t base_addr = address & (~0x07); /* aligned to 64 bit */ | ||
| int u32_idx = (i >> 2); | ||
| dst = (uint32_t *)(base_addr); | ||
| val[0] = dst[u32_idx]; | ||
| val[1] = dst[u32_idx + 1]; | ||
| while ((off < 8) && (i < len)) | ||
| vbytes[off++] = data[i++]; | ||
| dst[u32_idx] = val[0]; | ||
| dst[u32_idx + 1] = val[1]; |
Comment on lines
+116
to
+127
| end_address = address + len - 1; | ||
| for (p = address; p < end_address; p += FLASH_PAGE_SIZE) { | ||
| flash_wait_complete(); | ||
| flash_clear_errors(); | ||
| page_number = (p >> 11) & FLASH_CR_PNB_MASK; | ||
| reg = FLASH_CR & ~(FLASH_CR_PNB_MASK << FLASH_CR_PNB_SHIFT); | ||
| FLASH_CR = reg | (page_number << FLASH_CR_PNB_SHIFT) | FLASH_CR_PER; | ||
| DMB(); | ||
| FLASH_CR |= FLASH_CR_STRT; | ||
| flash_wait_complete(); | ||
| FLASH_CR &= ~FLASH_CR_PER; | ||
| } |
Comment on lines
+34
to
+36
| #define DMB() __asm__ volatile ("dmb") | ||
| #define ISB() __asm__ volatile ("isb") | ||
| #define DSB() __asm__ volatile ("dsb") |
Comment on lines
+37
to
+43
| static void RAMFUNCTION flash_clear_errors(void) | ||
| { | ||
| FLASH_SR |= (FLASH_SR_OPERR | FLASH_SR_PROGERR | FLASH_SR_WRPERR | | ||
| FLASH_SR_PGAERR | FLASH_SR_SIZERR | FLASH_SR_PGSERR | | ||
| FLASH_SR_MISERR | FLASH_SR_FASTERR | FLASH_SR_RDERR | | ||
| FLASH_SR_OPTVERR); | ||
| } |
| for (i = 0; i < len; i++) { | ||
| while ((LPUART1_ISR & USART_ISR_TXE) == 0) | ||
| ; | ||
| LPUART1_TDR = (uint32_t)buf[i]; |
Comment on lines
+19
to
+23
| .edidx : | ||
| { | ||
| . = ALIGN(4); | ||
| *(.ARM.exidx*) | ||
| } > FLASH |
| reg = GPIOA_MODER & ~(0x03 << (pin * 2)); | ||
| GPIOA_MODER = reg | (1 << (pin * 2)); | ||
| reg = GPIOA_PUPDR & ~(0x03 << (pin * 2)); | ||
| GPIOA_PUPDR = reg | (1 << (pin * 2)); |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
hal/stm32g4.hso the wolfBoot HAL and the test-app share one definition.printfviatest-app/syscalls.c(routes_write->uart_write), so v1/v2 boot logs andwolfBoot_success()confirmation print over the ST-LINK VCP.DEBUG_UART=1enables wolfBoot's own boot logs on LPUART1 PA2/PA3 AF12 (NUCLEO ST-LINK VCP) at 115200..github/workflows/test-configs.yml.