-
Notifications
You must be signed in to change notification settings - Fork 4
[docs, README] Update READMEs. Add some docs. #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
Merged
Merged
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 |
|---|---|---|
|
|
@@ -58,6 +58,4 @@ dkms.conf | |
| *.cache | ||
| compile_commands.json | ||
|
|
||
| docs/ | ||
|
|
||
| tests/core/test_core | ||
This file was deleted.
Oops, something went wrong.
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
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,133 @@ | ||
| # Adding a New Board | ||
|
|
||
| This guide covers adding a new board configuration to wolfHAL. | ||
|
|
||
| ## Overview | ||
|
|
||
| A board ties a platform to concrete hardware by defining peripheral instances, | ||
| pin assignments, clock settings, and startup code. Each board lives in its own | ||
| directory under `boards/` named `<platform>_<board_name>/`. | ||
|
|
||
| ## Required Files | ||
|
|
||
| ### board.h | ||
|
|
||
| Exports global peripheral instances and board-specific constants: | ||
|
|
||
| ```c | ||
| #pragma once | ||
|
|
||
| #include <wolfHAL/wolfHAL.h> | ||
|
|
||
| extern whal_Clock g_whalClock; | ||
| extern whal_Gpio g_whalGpio; | ||
| extern whal_Uart g_whalUart; | ||
| extern whal_Timer g_whalTimer; | ||
| extern whal_Flash g_whalFlash; | ||
|
|
||
| #define BOARD_LED_PIN 0 | ||
|
|
||
| whal_Error Board_Init(void); | ||
| whal_Error Board_Deinit(void); | ||
| void Board_WaitMs(size_t ms); | ||
| ``` | ||
|
|
||
| ### board.c | ||
|
|
||
| Defines global device instances with their configurations and implements | ||
| `Board_Init()` and `Board_Deinit()`. | ||
|
|
||
| `Board_Init()` is responsible for initializing all peripherals in dependency | ||
| order. For example, the clock controller must be initialized before peripherals | ||
| that depend on it, and a power supply controller (if present) may need to come | ||
| before the clock. It should return `WHAL_SUCCESS` on success or an error code | ||
| on failure. | ||
|
|
||
| `Board_Deinit()` tears down peripherals in reverse order. | ||
|
|
||
| ```c | ||
| #include "board.h" | ||
| #include <wolfHAL/platform/vendor/device.h> | ||
|
|
||
| static whal_MyplatformGpio_PinCfg pinCfg[] = { /* ... */ }; | ||
|
|
||
| static whal_MyplatformGpio_Cfg gpioConfig = { | ||
| .clkCtrl = &g_whalClock, | ||
| .pinCfg = pinCfg, | ||
| .pinCount = sizeof(pinCfg) / sizeof(pinCfg[0]), | ||
| }; | ||
|
|
||
| whal_Gpio g_whalGpio = { | ||
| WHAL_MYPLATFORM_GPIO_DEVICE, | ||
| .cfg = &gpioConfig, | ||
| }; | ||
|
|
||
| whal_Error Board_Init(void) | ||
| { | ||
| whal_Error err; | ||
|
|
||
| err = whal_Clock_Init(&g_whalClock); | ||
| if (err != WHAL_SUCCESS) return err; | ||
|
|
||
| err = whal_Gpio_Init(&g_whalGpio); | ||
| if (err != WHAL_SUCCESS) return err; | ||
|
|
||
| err = whal_Uart_Init(&g_whalUart); | ||
| if (err != WHAL_SUCCESS) return err; | ||
|
|
||
| err = whal_Timer_Init(&g_whalTimer); | ||
| if (err != WHAL_SUCCESS) return err; | ||
|
|
||
| err = whal_Timer_Start(&g_whalTimer); | ||
| if (err != WHAL_SUCCESS) return err; | ||
|
|
||
| return WHAL_SUCCESS; | ||
| } | ||
|
|
||
| whal_Error Board_Deinit(void) | ||
| { | ||
| whal_Timer_Stop(&g_whalTimer); | ||
| whal_Timer_Deinit(&g_whalTimer); | ||
| whal_Uart_Deinit(&g_whalUart); | ||
| whal_Gpio_Deinit(&g_whalGpio); | ||
| whal_Clock_Deinit(&g_whalClock); | ||
| return WHAL_SUCCESS; | ||
| } | ||
| ``` | ||
|
|
||
| ### Makefile.inc | ||
|
|
||
| Defines the toolchain, compiler flags, and source file list: | ||
|
|
||
| ```makefile | ||
| _BOARD_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) | ||
|
|
||
| PLATFORM = myplatform | ||
| TESTS = gpio clock uart flash timer | ||
|
|
||
| GCC = arm-none-eabi-gcc | ||
| LD = arm-none-eabi-gcc | ||
| OBJCOPY = arm-none-eabi-objcopy | ||
|
|
||
| CFLAGS = -mcpu=cortex-m4 -mthumb -Os -Wall -MMD $(INCLUDE) -I$(_BOARD_DIR) | ||
| LDFLAGS = -mcpu=cortex-m4 -mthumb -nostdlib -lgcc | ||
|
|
||
| LINKER_SCRIPT = $(_BOARD_DIR)/linker.ld | ||
|
|
||
| BOARD_SOURCE = $(_BOARD_DIR)/board.c | ||
| BOARD_SOURCE += $(_BOARD_DIR)/ivt.c | ||
| BOARD_SOURCE += $(wildcard $(WHAL_DIR)/src/*/myplatform_*.c) | ||
| BOARD_SOURCE += $(WHAL_DIR)/src/timer/systick.c | ||
| ``` | ||
|
|
||
| ### linker.ld | ||
|
|
||
| Linker script defining the memory layout for your board's MCU. Must define | ||
| FLASH and RAM regions, place `.isr_vector` at the start of FLASH, and set up | ||
| `.text`, `.data`, and `.bss` sections. | ||
|
|
||
| ### ivt.c (ARM targets) | ||
|
|
||
| Interrupt vector table and `Reset_Handler`. The reset handler copies `.data` | ||
| from FLASH to RAM, zeroes `.bss`, and calls `main()`. This file is specific to | ||
| ARM Cortex-M targets. Other architectures will need their own startup code. |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.