Skip to content

Commit c9ace83

Browse files
committed
wolfHAL design review
1 parent d5c1bc5 commit c9ace83

83 files changed

Lines changed: 10069 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Object files
5+
*.o
6+
*.ko
7+
*.obj
8+
*.elf
9+
10+
# Linker output
11+
*.ilk
12+
*.map
13+
*.exp
14+
15+
# Precompiled Headers
16+
*.gch
17+
*.pch
18+
19+
# Libraries
20+
*.lib
21+
*.a
22+
*.la
23+
*.lo
24+
25+
# Shared objects (inc. Windows DLLs)
26+
*.dll
27+
*.so
28+
*.so.*
29+
*.dylib
30+
31+
# Executables
32+
*.exe
33+
*.out
34+
*.app
35+
*.i*86
36+
*.x86_64
37+
*.hex
38+
*.bin
39+
40+
# Debug files
41+
*.dSYM/
42+
*.su
43+
*.idb
44+
*.pdb
45+
46+
# Kernel Module Compile Results
47+
*.mod*
48+
*.cmd
49+
.tmp_versions/
50+
modules.order
51+
Module.symvers
52+
Mkfile.old
53+
dkms.conf
54+
55+
# debug information files
56+
*.dwo
57+
58+
*.cache
59+
compile_commands.json
60+
61+
tests/core/test_core
62+
63+
*.pdf

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# wolfHAL
2+
3+
wolfHAL is a lightweight, OS-agnostic, compiler-agnostic hardware abstraction
4+
layer for embedded targets written in C. It provides a uniform driver model
5+
based on vtable dispatch.
6+
7+
## Repository layout
8+
9+
```
10+
wolfHAL/ Public headers (API surface)
11+
platform/ Platform-specific device macros and definitions
12+
src/ Driver implementations (generic + platform)
13+
boards/ Example board configurations used for testing and examples
14+
examples/ Example applications
15+
tests/ Test framework and test suites
16+
```
17+
18+
## Further reading
19+
20+
- [Getting Started](docs/getting_started.md) — Integrating wolfHAL into your project
21+
- [Boards](boards/README.md) — Example board configurations
22+
- [Examples](examples/README.md) — Example applications
23+
- [Tests](tests/README.md) — Test framework and test suites
24+
- [Writing a Driver](docs/writing_a_driver.md) — How to implement a driver for a new platform
25+
- [Adding a Board](docs/adding_a_board.md) — How to add a new board configuration
26+
- [Adding a Peripheral](docs/adding_a_peripheral.md) — How to add an external peripheral device
27+
- [Adding an Example](docs/adding_an_example.md) — How to add a new example application
28+
- [Adding a Test](docs/adding_a_test.md) — How to add hardware tests
29+
30+
## License
31+
32+
GPLv3 -- see [LICENSE](LICENSE) for details.

boards/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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 NUCLEO-C031C6 | STM32C0 | Cortex-M0+ | `stm32c031_nucleo/` |
19+
| ST NUCLEO-F091RC | STM32F0 | Cortex-M0 | `stm32f091rc_nucleo/` |
20+
| ST NUCLEO-F302R8 | STM32F3 | Cortex-M4 | `stm32f302r8_nucleo/` |
21+
| WeAct BlackPill STM32F411 | STM32F4 | Cortex-M4 | `stm32f411_blackpill/` |
22+
| ST NUCLEO-H563ZI | STM32H5 | Cortex-M33 | `stm32h563zi_nucleo/` |
23+
| ST NUCLEO-WB55RG | STM32WB | Cortex-M4 | `stm32wb55xx_nucleo/` |
24+
| ST NUCLEO-L152RE | STM32L1 | Cortex-M3 | `stm32l152re_nucleo/` |
25+
| ST NUCLEO-N657X0-Q | STM32N6 | Cortex-M55 | `stm32n657a0_nucleo/` |
26+
| ST NUCLEO-WBA55CG | STM32WBA | Cortex-M33 | `stm32wba55cg_nucleo/` |
27+
28+
## Board Directory Contents
29+
30+
Each board directory contains:
31+
32+
- **`board.mk`** - Build configuration: toolchain, CPU flags, platform
33+
drivers, and linker script. Included by application Makefiles via
34+
`include $(BOARD_DIR)/board.mk`.
35+
- **`board.h`** - Board-level declarations: global peripheral instances,
36+
pin definitions, and `Board_Init()`/`Board_Deinit()` prototypes.
37+
- **`board.c`** - Peripheral instantiation and `Board_Init()` implementation
38+
(power, clock, GPIO, UART, flash, timer).
39+
- **`linker.ld`** - Linker script defining memory regions (flash, RAM).
40+
- Any additional board-specific source files (e.g. interrupt vector table,
41+
architecture-specific startup code).
42+
43+
## board.mk Convention
44+
45+
Board `board.mk` files use a self-referencing pattern so that they can be
46+
included from any directory:
47+
48+
```makefile
49+
_BOARD_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
50+
```
51+
52+
`_BOARD_DIR` points to the board's own directory, while the application
53+
Makefile sets `BOARD_DIR` which may point elsewhere (e.g. a private board
54+
overlay). This enables private repositories to extend a board by including
55+
the base `board.mk` and adding additional sources.
56+
57+
### What `BOARD_SOURCE` includes
58+
59+
Board `board.mk` populates `BOARD_SOURCE` with all of the sources
60+
required to build the wolfHAL tests and sample applications for that board:
61+
62+
- Board files: `board.c` and any additional board-specific source files
63+
- Platform / SoC drivers: e.g. `pic32cz_*.c`, `stm32wb_*.c`
64+
- Architecture support: `systick.c` and any related startup / vector code
65+
- Core wolfHAL modules and common sources: generic drivers such as
66+
`gpio.c`, `clock.c`, `uart.c`, and other files under `src/*.c`
67+
68+
In your own projects you may either reuse these defaults by including the
69+
board `board.mk` as-is, or define your own `BOARD_SOURCE` in your
70+
application Makefile to select a different set of modules.
71+
72+
## Adding a New Board
73+
74+
1. Create a new directory: `boards/<vendor>_<board>/`
75+
2. Add `board.mk` following the `_BOARD_DIR` pattern above
76+
3. Implement `board.h`, `board.c`, and `linker.ld`
77+
4. Set `PLATFORM`, `TESTS`, toolchain variables, `CFLAGS`, and `BOARD_SOURCE`
78+
5. Build with `make BOARD=<your_board>`

0 commit comments

Comments
 (0)