Skip to content

Commit 6dcedf9

Browse files
committed
build need -DBOARD= instead of IDF_TARGET to allow flexible pinout for variant
1 parent 74f8e1f commit 6dcedf9

File tree

4 files changed

+41
-26
lines changed

4 files changed

+41
-26
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ jobs:
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
esp_target:
25+
board:
2626
- 'esp32'
27-
- 'esp32c6'
27+
- 'fruitjam_c6'
2828
build_type:
2929
- 'Release'
3030
- 'Debug'
@@ -40,8 +40,7 @@ jobs:
4040

4141
- name: Build
4242
run: |
43-
docker run --rm -v $PWD:/project -w /project espressif/idf:$IDF_VERSION cmake -B build -G Ninja -DIDF_TARGET=${{ matrix.esp_target }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
44-
docker run --rm -v $PWD:/project -w /project espressif/idf:$IDF_VERSION cmake --build build
43+
docker run --rm -v $PWD:/project -w /project espressif/idf:$IDF_VERSION /bin/bash -c "git config --global --add safe.directory /project && idf.py -DBOARD=${{ matrix.board }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
4544
python combine.py
4645
if [ "${{ matrix.build_type }}" == "Debug" ]; then
4746
# add debug suffix to the bin file
@@ -51,14 +50,14 @@ jobs:
5150
- name: Upload Artifacts
5251
uses: actions/upload-artifact@v4
5352
with:
54-
#name: nina-fw-${{ matrix.esp_target }}${{ matrix.build_type == 'Debug' && format('-{0}', matrix.build_type) || '' }}
55-
name: NINA_ADAFRUIT-${{ matrix.esp_target }}-${{ matrix.build_type }}
53+
#name: nina-fw-${{ matrix.board }}${{ matrix.build_type == 'Debug' && format('-{0}', matrix.build_type) || '' }}
54+
name: NINA_ADAFRUIT-${{ matrix.board }}-${{ matrix.build_type }}
5655
path: |
5756
NINA_ADAFRUIT*.bin
5857
5958
# - name: Prepare Release Asset
60-
# if: github.event_name == 'release'
61-
# run: cp build/nina-fw.bin nina-fw-${{ matrix.esp_target }}-${{ github.event.release.tag_name }}-${{ matrix.build_type }}.bin
59+
# if: github.event_name == 'release' && matrix.build_type == 'Release'
60+
# run: cp build/nina-fw.bin nina-fw-${{ matrix.board }}-${{ github.event.release.tag_name }}-${{ matrix.build_type }}.bin
6261

6362
- name: Upload Release Asset
6463
uses: softprops/action-gh-release@v1

CMakeLists.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,24 @@
22
# CMakeLists in this exact order for cmake to work correctly
33
cmake_minimum_required(VERSION 3.16)
44

5+
if (BOARD STREQUAL "fruitjam_c6")
6+
set(IDF_TARGET esp32c6 CACHE STRING "Target ESP-IDF board")
7+
elseif (BOARD STREQUAL "esp32")
8+
set(IDF_TARGET esp32 CACHE STRING "Target ESP-IDF board")
9+
else ()
10+
message(FATAL_ERROR "Unsupported BOARD: ${BOARD}. Supported boards are: fruitjam_c6, esp32")
11+
endif ()
12+
513
# SDKCONFIG & SDKCONFIG_DEFAULTS for each target
614
set(SDKCONFIG ${CMAKE_SOURCE_DIR}/sdkconfig.${IDF_TARGET})
715

8-
set(SDKCONFIG_DEFAULTS sdkconfig.defaults sdkconfig.defaults.${IDF_TARGET})
16+
# caused by esp-idf/components/bt/controller/esp32c6/bt.c:253:11: In function 'esp_bt_controller_log_init':
17+
# error: 'task_create' may be used uninitialized [-Werror=maybe-uninitialized]
18+
if (IDF_TARGET STREQUAL "esp32c6")
19+
add_compile_options(-Wno-maybe-uninitialized)
20+
endif ()
21+
22+
set(SDKCONFIG_DEFAULTS sdkconfig.defaults sdkconfig.defaults.${BOARD})
923
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
1024
list(APPEND SDKCONFIG_DEFAULTS sdkconfig.debug)
1125
endif ()
@@ -16,10 +30,9 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
1630
add_compile_definitions(CMAKE_BUILD_TYPE_DEBUG)
1731
endif ()
1832

19-
# caused by esp-idf/components/bt/controller/esp32c6/bt.c:253:11: In function 'esp_bt_controller_log_init':
20-
# error: 'task_create' may be used uninitialized [-Werror=maybe-uninitialized]
21-
if (IDF_TARGET STREQUAL "esp32c6")
22-
add_compile_options(-Wno-maybe-uninitialized)
23-
endif ()
33+
STRING(TOUPPER ${BOARD} BOARD_UPPER)
34+
add_compile_definitions(
35+
BOARD_${BOARD_UPPER}
36+
)
2437

2538
project(nina-fw)

main/sketch.ino.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,30 +78,33 @@ SPISClass SPIS(VSPI_HOST, 1, AIRLIFT_MOSI, AIRLIFT_MISO, AIRLIFT_SCK, AIRLIFT_CS
7878
#endif
7979

8080
#if defined(CONFIG_IDF_TARGET_ESP32C6)
81-
// SPIS for WiFi
82-
#define AIRLIFT_MOSI 21
83-
#define AIRLIFT_MISO 6
84-
#define AIRLIFT_SCK 22
85-
#define AIRLIFT_CS 7
86-
#define AIRLIFT_BUSY 18 // ready
8781

8882
// UART for BLE HCI
89-
// CONFIG_BT_LE_HCI_UART_RTS_PIN and CONFIG_BT_LE_HCI_UART_CTS_PIN are defined in sdkconfig.defaults.esp32c6
83+
// CONFIG_BT_LE_HCI_UART_RTS_PIN and CONFIG_BT_LE_HCI_UART_CTS_PIN are defined in sdkconfig.defaults.BOARD
9084
// and used by hci_driver_uart_config() in hci_driver_uart.c. It should matches with BUSY and BOOT pins.
9185
#ifndef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
9286
#error "Please Enable Uart for HCI"
9387
#endif
9488

95-
#if CONFIG_BT_LE_HCI_UART_RTS_PIN != AIRLIFT_BUSY
96-
#error "RTS pin must be the same as ready pin"
97-
#endif
98-
9989
#if CONFIG_BT_LE_HCI_UART_CTS_PIN != 9
10090
#error "CTS pin must be the same as BOOT pin"
10191
#endif
10292

93+
// SPIS for WiFi
94+
#define AIRLIFT_BUSY CONFIG_BT_LE_HCI_UART_RTS_PIN // ready
95+
96+
#if defined(BOARD_FRUITJAM_C6)
97+
#define AIRLIFT_MOSI 21
98+
#define AIRLIFT_MISO 6
99+
#define AIRLIFT_SCK 22
100+
#define AIRLIFT_CS 7
101+
#else
102+
#error "Board is not supported, please add -DBOARD=<board_name> to the build command"
103+
#endif
104+
103105
// dev, dma, mosi, miso, sclk, cs, ready
104-
SPISClass SPIS(SPI2_HOST, SPI_DMA_CH_AUTO, AIRLIFT_MOSI, AIRLIFT_MISO, AIRLIFT_SCK, AIRLIFT_CS, AIRLIFT_BUSY);
106+
SPISClass SPIS(SPI2_HOST, SPI_DMA_CH_AUTO,
107+
AIRLIFT_MOSI, AIRLIFT_MISO, AIRLIFT_SCK, AIRLIFT_CS, AIRLIFT_BUSY);
105108
#endif
106109

107110
// prevent initArduino() to release BT memory

0 commit comments

Comments
 (0)