From 5357b8909615c7b3b2d77ed53eaf5545dc27d286 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Sat, 13 Apr 2024 23:49:32 -0500 Subject: [PATCH] add a post-build command to patch board config into .bin/.uf2 this starts the replacement of BoardConfig.h + migration code with shipped protobuf configs. this should help cleanup some code, and one day will hopefully replace the need for per-board builds entirely, greatly speeding up the GitHub build/creation of board binaries --- CMakeLists.txt | 3 ++ compile_proto.cmake | 1 + configs/BentoBox/board-config.json | 3 ++ configs/FightboardV3/board-config.json | 3 ++ .../FightboardV3Mirrored/board-config.json | 3 ++ configs/FlatboxRev4/board-config.json | 3 ++ configs/FlatboxRev5/board-config.json | 3 ++ configs/FlatboxRev5RGB/board-config.json | 3 ++ configs/FlatboxRev5Southpaw/board-config.json | 3 ++ configs/Granola/board-config.json | 3 ++ configs/Haute42COSMOX/board-config.json | 3 ++ configs/KB2040/board-config.json | 3 ++ configs/KeyboardConverter/board-config.json | 3 ++ configs/Liatris/board-config.json | 3 ++ configs/Mavercade/board-config.json | 3 ++ configs/OpenCore0/board-config.json | 3 ++ configs/OpenCore0WASD/board-config.json | 3 ++ configs/Pico/board-config.json | 3 ++ configs/PicoAnn/board-config.json | 3 ++ configs/PicoFightingBoard/board-config.json | 3 ++ configs/PicoW/board-config.json | 3 ++ .../board-config.json | 3 ++ .../board-config.json | 3 ++ .../RP2040MiniBreakoutBoard/board-config.json | 3 ++ configs/RanaTadpole/board-config.json | 3 ++ configs/ReflexCtrlSNES/board-config.json | 3 ++ configs/ReflexEncodeV1.2/board-config.json | 3 ++ configs/ReflexEncodeV2.0/board-config.json | 3 ++ configs/SGFBridget/board-config.json | 3 ++ configs/SGFFaust/board-config.json | 3 ++ configs/SparkFunProMicro/board-config.json | 3 ++ configs/Stress/board-config.json | 3 ++ configs/WaveshareZero/board-config.json | 3 ++ patch_board_config.cmake | 29 +++++++++++++++++++ 34 files changed, 126 insertions(+) create mode 100644 configs/BentoBox/board-config.json create mode 100644 configs/FightboardV3/board-config.json create mode 100644 configs/FightboardV3Mirrored/board-config.json create mode 100644 configs/FlatboxRev4/board-config.json create mode 100644 configs/FlatboxRev5/board-config.json create mode 100644 configs/FlatboxRev5RGB/board-config.json create mode 100644 configs/FlatboxRev5Southpaw/board-config.json create mode 100644 configs/Granola/board-config.json create mode 100644 configs/Haute42COSMOX/board-config.json create mode 100644 configs/KB2040/board-config.json create mode 100644 configs/KeyboardConverter/board-config.json create mode 100644 configs/Liatris/board-config.json create mode 100644 configs/Mavercade/board-config.json create mode 100644 configs/OpenCore0/board-config.json create mode 100644 configs/OpenCore0WASD/board-config.json create mode 100644 configs/Pico/board-config.json create mode 100644 configs/PicoAnn/board-config.json create mode 100644 configs/PicoFightingBoard/board-config.json create mode 100644 configs/PicoW/board-config.json create mode 100644 configs/RP2040AdvancedBreakoutBoard/board-config.json create mode 100644 configs/RP2040AdvancedBreakoutBoardUSBPassthrough/board-config.json create mode 100644 configs/RP2040MiniBreakoutBoard/board-config.json create mode 100644 configs/RanaTadpole/board-config.json create mode 100644 configs/ReflexCtrlSNES/board-config.json create mode 100644 configs/ReflexEncodeV1.2/board-config.json create mode 100644 configs/ReflexEncodeV2.0/board-config.json create mode 100644 configs/SGFBridget/board-config.json create mode 100644 configs/SGFFaust/board-config.json create mode 100644 configs/SparkFunProMicro/board-config.json create mode 100644 configs/Stress/board-config.json create mode 100644 configs/WaveshareZero/board-config.json create mode 100644 patch_board_config.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index df9c32faf6..bbc8d0ee1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,6 +116,9 @@ add_compile_options(-Wall include(compile_proto.cmake) compile_proto() +include(patch_board_config.cmake) +patch_board_config() + #pull in tinyUSB set(PICO_TINYUSB_PATH "${CMAKE_CURRENT_LIST_DIR}/lib/tinyusb") diff --git a/compile_proto.cmake b/compile_proto.cmake index 89966923ff..2a35563e63 100644 --- a/compile_proto.cmake +++ b/compile_proto.cmake @@ -13,6 +13,7 @@ function (compile_proto) DEPENDS ${CMAKE_SOURCE_DIR}/lib/nanopb/extra/requirements.txt COMMAND ${Python3_EXECUTABLE} -m venv ${VENV} COMMAND ${VENV_BIN_DIR}/pip --disable-pip-version-check install -r ${CMAKE_SOURCE_DIR}/lib/nanopb/extra/requirements.txt + COMMAND ${VENV_BIN_DIR}/pip --disable-pip-version-check install gp2040ce-binary-tools COMMAND ${VENV_BIN_DIR}/pip freeze > ${VENV_FILE} OUTPUT ${VENV_FILE} COMMENT "Setting up Python Virtual Environment" diff --git a/configs/BentoBox/board-config.json b/configs/BentoBox/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/BentoBox/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/FightboardV3/board-config.json b/configs/FightboardV3/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/FightboardV3/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/FightboardV3Mirrored/board-config.json b/configs/FightboardV3Mirrored/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/FightboardV3Mirrored/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/FlatboxRev4/board-config.json b/configs/FlatboxRev4/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/FlatboxRev4/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/FlatboxRev5/board-config.json b/configs/FlatboxRev5/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/FlatboxRev5/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/FlatboxRev5RGB/board-config.json b/configs/FlatboxRev5RGB/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/FlatboxRev5RGB/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/FlatboxRev5Southpaw/board-config.json b/configs/FlatboxRev5Southpaw/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/FlatboxRev5Southpaw/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/Granola/board-config.json b/configs/Granola/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/Granola/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/Haute42COSMOX/board-config.json b/configs/Haute42COSMOX/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/Haute42COSMOX/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/KB2040/board-config.json b/configs/KB2040/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/KB2040/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/KeyboardConverter/board-config.json b/configs/KeyboardConverter/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/KeyboardConverter/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/Liatris/board-config.json b/configs/Liatris/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/Liatris/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/Mavercade/board-config.json b/configs/Mavercade/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/Mavercade/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/OpenCore0/board-config.json b/configs/OpenCore0/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/OpenCore0/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/OpenCore0WASD/board-config.json b/configs/OpenCore0WASD/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/OpenCore0WASD/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/Pico/board-config.json b/configs/Pico/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/Pico/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/PicoAnn/board-config.json b/configs/PicoAnn/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/PicoAnn/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/PicoFightingBoard/board-config.json b/configs/PicoFightingBoard/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/PicoFightingBoard/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/PicoW/board-config.json b/configs/PicoW/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/PicoW/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/RP2040AdvancedBreakoutBoard/board-config.json b/configs/RP2040AdvancedBreakoutBoard/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/RP2040AdvancedBreakoutBoard/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/RP2040AdvancedBreakoutBoardUSBPassthrough/board-config.json b/configs/RP2040AdvancedBreakoutBoardUSBPassthrough/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/RP2040AdvancedBreakoutBoardUSBPassthrough/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/RP2040MiniBreakoutBoard/board-config.json b/configs/RP2040MiniBreakoutBoard/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/RP2040MiniBreakoutBoard/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/RanaTadpole/board-config.json b/configs/RanaTadpole/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/RanaTadpole/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/ReflexCtrlSNES/board-config.json b/configs/ReflexCtrlSNES/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/ReflexCtrlSNES/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/ReflexEncodeV1.2/board-config.json b/configs/ReflexEncodeV1.2/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/ReflexEncodeV1.2/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/ReflexEncodeV2.0/board-config.json b/configs/ReflexEncodeV2.0/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/ReflexEncodeV2.0/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/SGFBridget/board-config.json b/configs/SGFBridget/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/SGFBridget/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/SGFFaust/board-config.json b/configs/SGFFaust/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/SGFFaust/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/SparkFunProMicro/board-config.json b/configs/SparkFunProMicro/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/SparkFunProMicro/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/Stress/board-config.json b/configs/Stress/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/Stress/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/configs/WaveshareZero/board-config.json b/configs/WaveshareZero/board-config.json new file mode 100644 index 0000000000..00bf892c9b --- /dev/null +++ b/configs/WaveshareZero/board-config.json @@ -0,0 +1,3 @@ +{ + "boardVersion": "v0.7.8" +} diff --git a/patch_board_config.cmake b/patch_board_config.cmake new file mode 100644 index 0000000000..d8bd68e57d --- /dev/null +++ b/patch_board_config.cmake @@ -0,0 +1,29 @@ +function (patch_board_config) + find_package(Python3 REQUIRED COMPONENTS Interpreter) + + set(VENV ${CMAKE_CURRENT_BINARY_DIR}/venv) + if(CMAKE_HOST_WIN32) + set(VENV_BIN_DIR ${VENV}/Scripts) + else() + set(VENV_BIN_DIR ${VENV}/bin) + endif() + + add_custom_target( + PatchBoardConfig ALL + DEPENDS ${PROJECT_NAME} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${VENV_BIN_DIR}/concatenate + -P ./proto + -P ./lib/nanopb/generator/proto + ./build/${PROJECT_NAME}_${CMAKE_PROJECT_VERSION}_${GP2040_BOARDCONFIG}.bin + --json-board-config-filename ./configs/${GP2040_BOARDCONFIG}/board-config.json + --new-filename ./build/${PROJECT_NAME}_${CMAKE_PROJECT_VERSION}_${GP2040_BOARDCONFIG}.uf2 + COMMAND ${VENV_BIN_DIR}/concatenate + -P ./proto + -P ./lib/nanopb/generator/proto + ./build/${PROJECT_NAME}_${CMAKE_PROJECT_VERSION}_${GP2040_BOARDCONFIG}.bin + --json-board-config-filename ./configs/${GP2040_BOARDCONFIG}/board-config.json + --new-filename ./build/${PROJECT_NAME}_${CMAKE_PROJECT_VERSION}_${GP2040_BOARDCONFIG}.bin + COMMENT "Patching binary with board config" + ) +endfunction()