From 9b032cb3a212670936c190c5e5c7a807f944ab3b Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Thu, 23 Jun 2022 16:34:21 +0100 Subject: [PATCH] Badger2040: Move to more generic fixups hack. --- .github/workflows/micropython-badger2040.yml | 10 +- .../badger2040/PIMORONI_BADGER2040/board.json | 17 +++ .../PIMORONI_BADGER2040/mpconfigboard.cmake | 1 + .../PIMORONI_BADGER2040/mpconfigboard.h} | 0 .../_board/badger2040/pimoroni_badger2040.h | 116 ++++++++++++++++++ micropython/_board/board-fixup.sh | 4 +- 6 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 micropython/_board/badger2040/PIMORONI_BADGER2040/board.json create mode 100644 micropython/_board/badger2040/PIMORONI_BADGER2040/mpconfigboard.cmake rename micropython/{badger2040-mpconfigboard.h => _board/badger2040/PIMORONI_BADGER2040/mpconfigboard.h} (100%) create mode 100644 micropython/_board/badger2040/pimoroni_badger2040.h diff --git a/.github/workflows/micropython-badger2040.yml b/.github/workflows/micropython-badger2040.yml index da266933..d0e0b4b8 100644 --- a/.github/workflows/micropython-badger2040.yml +++ b/.github/workflows/micropython-badger2040.yml @@ -8,7 +8,7 @@ on: env: MICROPYTHON_VERSION: v1.19 - BOARD_TYPE: PICO + BOARD_TYPE: PIMORONI_BADGER2040 # MicroPython version will be contained in github.event.release.tag_name for releases RELEASE_FILE: pimoroni-badger2040-${{github.event.release.tag_name || github.sha}}-micropython.uf2 @@ -82,11 +82,11 @@ jobs: submodules: true path: pimoroni-pico-${{ github.sha }} - # Copy Python module files - - name: HACK - Copy board config fixup - if: env.BOARD_TYPE == 'PICO' + - name: "HACK: MicroPython Board Fixups" + shell: bash + working-directory: micropython/ports/rp2 run: | - cp pimoroni-pico-${GITHUB_SHA}/micropython/badger2040-mpconfigboard.h micropython/ports/rp2/boards/PICO/mpconfigboard.h + ../../../pimoroni-pico-${GITHUB_SHA}/micropython/_board/board-fixup.sh badger2040 ${{env.BOARD_TYPE}} ../../../pimoroni-pico-${GITHUB_SHA}/micropython/_board # Linux deps - name: Install Compiler & CCache diff --git a/micropython/_board/badger2040/PIMORONI_BADGER2040/board.json b/micropython/_board/badger2040/PIMORONI_BADGER2040/board.json new file mode 100644 index 00000000..0acf4b6b --- /dev/null +++ b/micropython/_board/badger2040/PIMORONI_BADGER2040/board.json @@ -0,0 +1,17 @@ +{ + "deploy": [ + "../deploy.md" + ], + "docs": "", + "features": [ + "296*128 e-Ink", + "Buttons" + ], + "images": [ + ], + "mcu": "rp2040", + "product": "Badger2040 (2MiB)", + "thumbnail": "", + "url": "https://shop.pimoroni.com/products/badger-2040", + "vendor": "Pimoroni" +} diff --git a/micropython/_board/badger2040/PIMORONI_BADGER2040/mpconfigboard.cmake b/micropython/_board/badger2040/PIMORONI_BADGER2040/mpconfigboard.cmake new file mode 100644 index 00000000..f9699b9f --- /dev/null +++ b/micropython/_board/badger2040/PIMORONI_BADGER2040/mpconfigboard.cmake @@ -0,0 +1 @@ +# cmake file for Pimoroni Badger 2040 diff --git a/micropython/badger2040-mpconfigboard.h b/micropython/_board/badger2040/PIMORONI_BADGER2040/mpconfigboard.h similarity index 100% rename from micropython/badger2040-mpconfigboard.h rename to micropython/_board/badger2040/PIMORONI_BADGER2040/mpconfigboard.h diff --git a/micropython/_board/badger2040/pimoroni_badger2040.h b/micropython/_board/badger2040/pimoroni_badger2040.h new file mode 100644 index 00000000..27a62655 --- /dev/null +++ b/micropython/_board/badger2040/pimoroni_badger2040.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +// ----------------------------------------------------- +// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO +// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES +// ----------------------------------------------------- + +#ifndef _BOARDS_PIMORONI_BADGER2040_H +#define _BOARDS_PIMORONI_BADGER2040_H + +// For board detection +#define PIMORONI_BADGER2040 + +// --- BOARD SPECIFIC --- +#define BADGER2040_UART 0 +#define BADGER2040_TX_PIN 0 +#define BADGER2040_RX_PIN 1 + +#define BADGER2040_I2C 0 +#define BADGER2040_INT_PIN 3 +#define BADGER2040_SDA_PIN 4 +#define BADGER2040_SCL_PIN 5 + +#define BADGER2040_3V3_EN_PIN 10 + +#define BADGER2040_SW_DOWN_PIN 11 +#define BADGER2040_SW_A_PIN 12 +#define BADGER2040_SW_B_PIN 13 +#define BADGER2040_SW_C_PIN 14 +#define BADGER2040_SW_UP_PIN 15 + +#define BADGER2040_INKY_SPI 0 +#define BADGER2040_INKY_MISO_PIN 16 +#define BADGER2040_INKY_CSN_PIN 17 +#define BADGER2040_INKY_SCK_PIN 18 +#define BADGER2040_INKY_MOSI_PIN 19 +#define BADGER2040_INKY_DC_PIN 20 +#define BADGER2040_INKY_RESET_PIN 21 +#define BADGER2040_INKY_BUSY_PIN 26 + +#define BADGER2040_USER_SW_PIN 23 +#define BADGER2040_USER_LED_PIN 25 + +#define BADGER2040_VBUS_DETECT_PIN 24 +#define BADGER2040_VREF_POWER_PIN 27 +#define BADGER2040_1V2_REF_PIN 28 +#define BADGER2040_BAT_SENSE_PIN 29 + +// --- UART --- +#ifndef PICO_DEFAULT_UART +#define PICO_DEFAULT_UART BADGER2040_UART +#endif + +#ifndef PICO_DEFAULT_UART_TX_PIN +#define PICO_DEFAULT_UART_TX_PIN BADGER2040_TX_PIN +#endif + +#ifndef PICO_DEFAULT_UART_RX_PIN +#define PICO_DEFAULT_UART_RX_PIN BADGER2040_RX_PIN +#endif + +// --- LED --- +#ifndef PICO_DEFAULT_LED_PIN +#define PICO_DEFAULT_LED_PIN BADGER2040_USER_LED_PIN +#endif +// no PICO_DEFAULT_WS2812_PIN + +// --- I2C --- +#ifndef PICO_DEFAULT_I2C +#define PICO_DEFAULT_I2C BADGER2040_I2C +#endif +#ifndef PICO_DEFAULT_I2C_SDA_PIN +#define PICO_DEFAULT_I2C_SDA_PIN BADGER2040_SDA_PIN +#endif +#ifndef PICO_DEFAULT_I2C_SCL_PIN +#define PICO_DEFAULT_I2C_SCL_PIN BADGER2040_SCL_PIN +#endif + +// --- SPI --- +#ifndef PICO_DEFAULT_SPI +#define PICO_DEFAULT_SPI BADGER2040_INKY_SPI +#endif +#ifndef PICO_DEFAULT_SPI_SCK_PIN +#define PICO_DEFAULT_SPI_SCK_PIN BADGER2040_INKY_SCK_PIN +#endif +#ifndef PICO_DEFAULT_SPI_TX_PIN +#define PICO_DEFAULT_SPI_TX_PIN BADGER2040_INKY_MOSI_PIN +#endif +#ifndef PICO_DEFAULT_SPI_RX_PIN +#define PICO_DEFAULT_SPI_RX_PIN BADGER2040_INKY_MISO_PIN +#endif +#ifndef PICO_DEFAULT_SPI_CSN_PIN +#define PICO_DEFAULT_SPI_CSN_PIN BADGER2040_INKY_CSN_PIN +#endif + +// --- FLASH --- +#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 + +#ifndef PICO_FLASH_SPI_CLKDIV +#define PICO_FLASH_SPI_CLKDIV 2 +#endif + +#ifndef PICO_FLASH_SIZE_BYTES +#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024) +#endif + +// All boards have B1 RP2040 +#ifndef PICO_RP2040_B0_SUPPORTED +#define PICO_RP2040_B0_SUPPORTED 0 +#endif + +#endif \ No newline at end of file diff --git a/micropython/_board/board-fixup.sh b/micropython/_board/board-fixup.sh index ecc4fd60..7335535f 100755 --- a/micropython/_board/board-fixup.sh +++ b/micropython/_board/board-fixup.sh @@ -5,12 +5,12 @@ MPY_DIR=`pwd` echo "Fixup: $NAME $BOARD $MPY_DIR" -if [[ ! -f "$MPY_DIR/../../lib/pico-sdk/src/boards/include/boards/pimoroni_$NAME.h" ]]; then +if [[ ! -f "$MPY_DIR/../../lib/pico-sdk/src/boards/include/boards/pimoroni_$NAME.h" ]] && [[ -f "$FIXUP_DIR/$NAME/pimoroni_$NAME.h" ]]; then echo "Missing Pico SDK board .h. Copying: $FIXUP_DIR/$NAME/pimoroni_$NAME.h to $MPY_DIR/../../lib/pico-sdk/src/boards/include/boards/pimoroni_$NAME.h" cp "$FIXUP_DIR/$NAME/pimoroni_$NAME.h" "$MPY_DIR/../../lib/pico-sdk/src/boards/include/boards/pimoroni_$NAME.h" fi -if [[ ! -d "$MPY_DIR/boards/$BOARD" ]]; then +if [[ ! -d "$MPY_DIR/boards/$BOARD" ]] && [[ -d "$FIXUP_DIR/$NAME/$BOARD/" ]]; then echo "Missing board dir. Copying: $FIXUP_DIR/$NAME/$BOARD/ to $MPY_DIR/boards/" cp -r "$FIXUP_DIR/$NAME/$BOARD/" "$MPY_DIR/boards/" fi \ No newline at end of file