Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
if (CONFIG_ARDUINO_API)
string(REPLACE "__" "_" NORMALIZED_BOARD_TARGET "${NORMALIZED_BOARD_TARGET}")

if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/variants/${BOARD})
# Find variant directory and check for variant.h
# If board-specific variant.h exists, use it; otherwise fall back to default
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/variants/${BOARD}/variant.h)
set(variant_dir variants/${BOARD})
elseif (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/variants/${NORMALIZED_BOARD_TARGET})
elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/variants/${NORMALIZED_BOARD_TARGET}/variant.h)
set(variant_dir variants/${NORMALIZED_BOARD_TARGET})
else()
message(WARNING
"Variant dir not found: variants/${BOARD}, variants/${NORMALIZED_BOARD_TARGET}\n"
"Your board is currently not supported. To use it you must create a DTS overlay."
)
set(variant_dir variants/default)
endif()

Expand Down
6 changes: 3 additions & 3 deletions documentation/variants.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ target board. To add board support:
needs to be added it needs to be done in the `variants/` folder.
Add a folder inside of the variants folder that matches the name of your board.
2. Add an overlay file file that match the name of the board.
3. Add a `variant.h` file.
3. Add a `variant.h` file. (if required only)

An example of this structure is shown below.

```tree
variants/
├── arduino_nano_33_ble
│   ├── arduino_nano_33_ble.overlay
│   ├── variant.h
│   ├── variant.h (optional)
```

It is possible to apply the overlay outside of the `variants` folder. In that case `cmake` will show a warning and a default empty `variant.h` file will be used. The `zephyr,user` section will still need to be defined somewhere in your project, as described in the [Guide to Writing Overlays section](#guide-to-writing-overlays).
Expand Down Expand Up @@ -187,7 +187,7 @@ One example of a change that you may find useful is mapping additional pins. For
example, the LEDs on the nRF52840 are not connected to any of the Arduino header
pins. To define a built-in LED for this board, a 22nd pin definition was added.

Your pinmap header file must be added to the variant.h file by adding three
Your pinmap header file can optionally be added to the variant.h file by adding three
lines using this format:

```c
Expand Down
5 changes: 0 additions & 5 deletions variants/arduino_mkrzero/variant.h

This file was deleted.

5 changes: 0 additions & 5 deletions variants/nrf52840dk_nrf52840/variant.h

This file was deleted.

7 changes: 0 additions & 7 deletions variants/pocketbeagle_2_am6254_a53/variant.h

This file was deleted.

5 changes: 0 additions & 5 deletions variants/rpi_pico/variant.h

This file was deleted.

Loading