Skip to content

Commit 3aecb63

Browse files
authored
Merge pull request #12 from AlexLanzano/boards
[boards, tests, examples] Create example boards directory. Move board cfg there
2 parents 66a70b5 + 2c3b26d commit 3aecb63

37 files changed

Lines changed: 436 additions & 1366 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ compile_commands.json
6060

6161
docs/
6262

63-
tests/sim/test_sim
63+
tests/core/test_core

README.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ platforms.
99

1010
| Platform | Board | Drivers |
1111
|----------|-------|---------|
12-
| STM32WB55 | Nucleo | RCC (PLL + MSI), GPIO, UART, LPUART, SPI, Flash, SysTick |
13-
| PIC32CZ | Curiosity Ultra | Clock (dual PLL), GPIO, UART, Supply (SUPC), SysTick |
12+
| STM32WB55 | Nucleo | RCC (PLL + MSI), GPIO, UART, LPUART, SPI, Flash, RNG, SysTick |
13+
| PIC32CZ | Curiosity Ultra | Clock (dual PLL), GPIO, UART, Flash, Supply (SUPC), SysTick |
1414

1515
## Architecture
1616

@@ -48,6 +48,7 @@ whal_Gpio g_whalGpio = {
4848
| Flash | `wolfHAL/flash/flash.h` | Init, Deinit, Lock, Unlock, Read, Write, Erase |
4949
| SPI | `wolfHAL/spi/spi.h` | Init, Deinit, SendRecv, Send, Recv |
5050
| Timer | `wolfHAL/timer/timer.h` | Init, Deinit, Start, Stop, Reset |
51+
| RNG | `wolfHAL/rng/rng.h` | Init, Deinit, Generate |
5152
| Supply | `wolfHAL/supply/supply.h` | Init, Deinit, Enable, Disable |
5253

5354
Utilities: `wolfHAL/regmap.h` (masked register access), `wolfHAL/bitops.h`
@@ -61,13 +62,15 @@ wolfHAL/ Public headers (API surface)
6162
platform/st/ STM32WB55 device macros
6263
platform/microchip/ PIC32CZ device macros
6364
src/ Driver implementations (generic + platform)
65+
boards/
66+
stm32wb55xx_nucleo/ STM32WB55 Nucleo board support
67+
pic32cz_curiosity_ultra/ PIC32CZ Curiosity Ultra board support
6468
examples/
65-
stm32wb/ STM32WB55 Nucleo board bring-up and UART echo
66-
pic32cz/ PIC32CZ Curiosity Ultra board bring-up
69+
blinky/ LED blink + UART echo (multi-board)
6770
tests/
6871
test.h Minimal test framework (no libc dependency)
69-
sim/ Host-compiled tests (bitops, dispatch validation)
70-
hw/stm32wb/ On-target tests (clock, GPIO, flash, timer)
72+
core/ Host-compiled tests (bitops, dispatch validation)
73+
clock/ gpio/ flash/ ... On-target per-module tests
7174
```
7275

7376
## Getting started
@@ -82,7 +85,7 @@ src/reg.c
8285
# Generic dispatch (include all, or just the modules you use)
8386
src/clock/clock.c src/gpio/gpio.c src/uart/uart.c
8487
src/flash/flash.c src/spi/spi.c src/timer/timer.c
85-
src/supply/supply.c
88+
src/supply/supply.c src/rng/rng.c
8689
8790
# Platform drivers (pick your target)
8891
src/clock/stm32wb_rcc.c src/gpio/stm32wb_gpio.c ...
@@ -91,43 +94,50 @@ src/timer/systick.c
9194
```
9295

9396
Create a board config file that instantiates devices with your pin assignments,
94-
clock settings, and peripheral configs. See `examples/stm32wb/stm32wb55xx_nucleo.c`
95-
or `examples/pic32cz/pic32cz_curiosity_ultra.c` for reference.
97+
clock settings, and peripheral configs. See `boards/stm32wb55xx_nucleo/board.c`
98+
or `boards/pic32cz_curiosity_ultra/board.c` for reference.
9699

97100
To write a driver for a new platform, implement the functions in the relevant
98101
`*Driver` vtable and provide device macros in a platform header.
99102

100103
## Building the examples
101104

102-
Both examples use `arm-none-eabi-gcc` and produce a `.bin` suitable for flashing:
105+
Examples use `arm-none-eabi-gcc` and produce a `.bin` suitable for flashing.
106+
Select a board with `BOARD=`:
103107

104108
```sh
105-
cd examples/stm32wb && make # -> boot.bin (Cortex-M4)
106-
cd examples/pic32cz && make # -> boot.bin (Cortex-M33)
109+
cd examples/blinky
110+
make BOARD=stm32wb55xx_nucleo # -> build/stm32wb55xx_nucleo/blinky.bin
111+
make BOARD=pic32cz_curiosity_ultra # -> build/pic32cz_curiosity_ultra/blinky.bin
107112
```
108113

109114
## Tests
110115

111-
**Simulation tests** run on the host and validate the abstraction layer without
112-
any hardware:
116+
**Core tests** run on the host and validate the abstraction layer without any
117+
hardware:
113118

114119
```sh
115-
cd tests/sim && make run
120+
cd tests/core && make run
116121
```
117122

118-
**Hardware tests** cross-compile and run on an STM32WB55 Nucleo. They boot the
119-
board, report results over UART, and signal pass/fail via LED:
123+
**Hardware tests** cross-compile for a target board. They boot the board, report
124+
results over UART, and signal pass/fail via LED:
120125

121126
```sh
122-
cd tests/stm32wb && make # -> test_hw.bin
127+
cd tests
128+
make BOARD=stm32wb55xx_nucleo # -> build/stm32wb55xx_nucleo/test_hw.bin
129+
make BOARD=pic32cz_curiosity_ultra # -> build/pic32cz_curiosity_ultra/test_hw.bin
123130
```
124131

132+
Each board's `Makefile.inc` defines a default `TESTS` list (e.g. `clock gpio
133+
flash timer rng`). Override it on the command line to run a subset.
134+
125135
## CI
126136

127137
GitHub Actions runs on every push and PR to `main`:
128-
- **sim-tests** -- builds and runs the host test suite
138+
- **core-tests** -- builds and runs the host test suite
129139
- **cross-compile** -- verifies all examples and hardware tests compile cleanly
130-
with `arm-none-eabi-gcc`
140+
with `arm-none-eabi-gcc` for every supported board
131141

132142
## Documentation
133143

boards/README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# wolfHAL Example Board Definitions
2+
3+
The board definitions in this directory are **examples** for use with
4+
wolfHAL's tests and sample applications. They are configured for specific
5+
development boards and are not intended for production use. Users should
6+
create their own board support packages tailored to their hardware.
7+
8+
Each subdirectory contains a board support package (BSP) for a specific
9+
development board. A BSP provides everything needed to build wolfHAL for a
10+
given target: startup code, peripheral initialization, linker script, and
11+
build configuration.
12+
13+
## Supported Boards
14+
15+
| Board | Platform | CPU | Directory |
16+
|-------|----------|-----|-----------|
17+
| Microchip PIC32CZ CA Curiosity Ultra | PIC32CZ | Cortex-M7 | `pic32cz_curiosity_ultra/` |
18+
| ST STM32WB55 Nucleo | STM32WB | Cortex-M4 | `stm32wb55xx_nucleo/` |
19+
20+
## Board Directory Contents
21+
22+
Each board directory contains:
23+
24+
- **`Makefile.inc`** - Build configuration: toolchain, CPU flags, platform
25+
drivers, and linker script. Included by application Makefiles via
26+
`include $(BOARD_DIR)/Makefile.inc`.
27+
- **`board.h`** - Board-level declarations: global peripheral instances,
28+
pin definitions, and `Board_Init()`/`Board_Deinit()` prototypes.
29+
- **`board.c`** - Peripheral instantiation and `Board_Init()` implementation
30+
(supply, clock, GPIO, UART, flash, timer).
31+
- **`linker.ld`** - Linker script defining memory regions (flash, RAM).
32+
- Any additional board-specific source files (e.g. interrupt vector table,
33+
architecture-specific startup code).
34+
35+
## Makefile.inc Convention
36+
37+
Board `Makefile.inc` files use a self-referencing pattern so that they can be
38+
included from any directory:
39+
40+
```makefile
41+
_BOARD_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
42+
```
43+
44+
`_BOARD_DIR` points to the board's own directory, while the application
45+
Makefile sets `BOARD_DIR` which may point elsewhere (e.g. a private board
46+
overlay). This enables private repositories to extend a board by including
47+
the base `Makefile.inc` and adding additional sources.
48+
49+
### What `BOARD_SOURCE` includes
50+
51+
Board `Makefile.inc` populates `BOARD_SOURCE` with all of the sources
52+
required to build the wolfHAL tests and sample applications for that board:
53+
54+
- Board files: `board.c` and any additional board-specific source files
55+
- Platform / SoC drivers: e.g. `pic32cz_*.c`, `stm32wb_*.c`
56+
- Architecture support: `systick.c` and any related startup / vector code
57+
- Core wolfHAL modules and common sources: generic drivers such as
58+
`gpio.c`, `clock.c`, `uart.c`, and other files under `src/*.c`
59+
60+
In your own projects you may either reuse these defaults by including the
61+
board `Makefile.inc` as-is, or define your own `BOARD_SOURCE` in your
62+
application Makefile to select a different set of modules.
63+
64+
## Adding a New Board
65+
66+
1. Create a new directory: `boards/<vendor>_<board>/`
67+
2. Add `Makefile.inc` following the `_BOARD_DIR` pattern above
68+
3. Implement `board.h`, `board.c`, and `linker.ld`
69+
4. Set `PLATFORM`, `TESTS`, toolchain variables, `CFLAGS`, and `BOARD_SOURCE`
70+
5. Build with `make BOARD=<your_board>`
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
_BOARD_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
2+
13
PLATFORM = pic32cz
2-
TESTS = clock gpio flash timer
4+
TESTS ?= clock gpio flash timer
35

46
GCC = $(GCC_PATH)arm-none-eabi-gcc
57
LD = $(GCC_PATH)arm-none-eabi-ld
@@ -10,14 +12,19 @@ CFLAGS += -Wall -Werror $(INCLUDE) -g3 \
1012
-DPLATFORM_PIC32CZ -MMD -MP
1113
LDFLAGS = --omagic -static
1214

13-
BOARD_SOURCE = $(BOARD_DIR)/ivt.c
14-
BOARD_SOURCE += $(BOARD_DIR)/board.c
15+
LINKER_SCRIPT ?= $(_BOARD_DIR)/linker.ld
16+
17+
INCLUDE += -I$(_BOARD_DIR)
18+
19+
BOARD_SOURCE = $(_BOARD_DIR)/ivt.c
20+
BOARD_SOURCE += $(_BOARD_DIR)/board.c
1521
BOARD_SOURCE += $(wildcard $(WHAL_DIR)/src/*.c)
1622
BOARD_SOURCE += $(wildcard $(WHAL_DIR)/src/*/gpio.c)
1723
BOARD_SOURCE += $(wildcard $(WHAL_DIR)/src/*/clock.c)
1824
BOARD_SOURCE += $(wildcard $(WHAL_DIR)/src/*/uart.c)
1925
BOARD_SOURCE += $(wildcard $(WHAL_DIR)/src/*/timer.c)
2026
BOARD_SOURCE += $(wildcard $(WHAL_DIR)/src/*/supply.c)
2127
BOARD_SOURCE += $(wildcard $(WHAL_DIR)/src/*/flash.c)
28+
BOARD_SOURCE += $(wildcard $(WHAL_DIR)/src/*/rng.c)
2229
BOARD_SOURCE += $(wildcard $(WHAL_DIR)/src/*/pic32cz_*.c)
2330
BOARD_SOURCE += $(wildcard $(WHAL_DIR)/src/*/systick.c)

0 commit comments

Comments
 (0)