diff --git a/.github/workflows/build-zoog.yml b/.github/workflows/build-zoog.yml new file mode 100644 index 0000000000000..80b894ec02a0d --- /dev/null +++ b/.github/workflows/build-zoog.yml @@ -0,0 +1,181 @@ +name: Build Zoog + +on: + push: + pull_request: + release: + types: [published] + check_suite: + types: [rerequested] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-20.04 + outputs: + boards-arm: ${{ steps.set-matrix.outputs.boards-arm }} + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - uses: actions/checkout@v2.2.0 + with: + submodules: false + fetch-depth: 1 + - name: Set up Python 3 + uses: actions/setup-python@v2 + with: + python-version: "3.x" + - name: Get CP deps + run: python tools/ci_fetch_deps.py test ${{ github.sha }} + - name: CircuitPython version + run: | + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y eatmydata + sudo eatmydata apt-get install -y gettext gcc-aarch64-linux-gnu mingw-w64 + pip install -r requirements-ci.txt -r requirements-dev.txt + - name: Versions + run: | + gcc --version + python3 --version + # - name: Duplicate USB VID/PID Check + # run: python3 -u -m tools.ci_check_duplicate_usb_vid_pid + - name: Build mpy-cross + run: make -C mpy-cross -j2 + - name: Build unix port + run: | + make -C ports/unix VARIANT=coverage -j2 + - name: Test all + run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 + working-directory: tests + - name: Print failure info + run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --print-failures + if: failure() + working-directory: tests + - name: Native Tests + run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --emit native + working-directory: tests + - name: mpy Tests + run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --via-mpy -d basics float micropython + working-directory: tests + - name: Native mpy Tests + run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --via-mpy --emit native -d basics float micropython + working-directory: tests + - name: Build native modules + run: | + make -C examples/natmod/features1 + make -C examples/natmod/features2 + make -C examples/natmod/btree + make -C examples/natmod/framebuf + make -C examples/natmod/uheapq + make -C examples/natmod/urandom + make -C examples/natmod/ure + make -C examples/natmod/uzlib + - name: Test native modules + run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-natmodtests.py extmod/{btree*,framebuf*,uheapq*,ure*,uzlib*}.py + working-directory: tests + - name: Build mpy-cross.static-aarch64 + run: make -C mpy-cross -j2 -f Makefile.static-aarch64 + - uses: actions/upload-artifact@v2 + with: + name: mpy-cross.static-aarch64 + path: mpy-cross/mpy-cross.static-aarch64 + - name: Build mpy-cross.static-raspbian + run: make -C mpy-cross -j2 -f Makefile.static-raspbian + - uses: actions/upload-artifact@v2 + with: + name: mpy-cross.static-raspbian + path: mpy-cross/mpy-cross.static-raspbian + - name: Build mpy-cross.static + run: make -C mpy-cross -j2 -f Makefile.static + - uses: actions/upload-artifact@v2 + with: + name: mpy-cross.static-amd64-linux + path: mpy-cross/mpy-cross.static + - name: Build mpy-cross.static-mingw + run: make -C mpy-cross -j2 -f Makefile.static-mingw + - uses: actions/upload-artifact@v2 + with: + name: mpy-cross.static-x64-windows + path: mpy-cross/mpy-cross.static.exe + - name: "Get changes" + if: github.event_name == 'pull_request' + uses: dorny/paths-filter@v2 + id: filter + with: + list-files: json + filters: | + changed: + - '**' + - name: "Set matrix" + id: set-matrix + working-directory: tools + env: + CHANGED_FILES: '["ports/nrf/boards/zoog/mpconfig.mk"]' + run: python3 -u ci_set_matrix.py + + build-arm: + runs-on: ubuntu-20.04 + needs: test + strategy: + fail-fast: false + matrix: + board: ${{ fromJSON(needs.test.outputs.boards-arm) }} + if: ${{ needs.test.outputs.boards-arm != '[]' }} + steps: + - name: Set up Python 3 + uses: actions/setup-python@v2 + with: + python-version: "3.x" + - uses: actions/checkout@v2.2.0 + with: + submodules: false + fetch-depth: 1 + - name: Get CP deps + env: + SSH_KEY: ${{ secrets.PRIVATE_SUBMODULE_SSH_KEY }} + run: | + mkdir $HOME/.ssh && echo "${{ env.SSH_KEY }}" > $HOME/.ssh/id_rsa && chmod 600 $HOME/.ssh/id_rsa + python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }} + - name: Install dependencies + run: | + sudo apt-get install -y gettext + pip install -r requirements-ci.txt -r requirements-dev.txt + wget --no-verbose https://adafruit-circuit-python.s3.amazonaws.com/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 + sudo tar -C /usr --strip-components=1 -xaf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 + - name: Versions + run: | + gcc --version + arm-none-eabi-gcc --version + python3 --version + - name: mpy-cross + run: make -C mpy-cross -j2 + - name: Setup build failure matcher + run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/workflows/match-build-fail.json" + - name: build + run: python3 -u build_release_files.py + working-directory: tools + env: + REPO_TOKEN: ${{ secrets.REPO_TOKEN }} + BOARDS: ${{ matrix.board }} + - uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.board }} + path: bin/${{ matrix.board }} + - name: Upload Release Asset + uses: softprops/action-gh-release@v1 + if: ${{ github.event_name == 'release' }} + env: + RELEASE_WRITE_TOKEN: ${{ secrets.RELEASE_WRITE_TOKEN }} + with: + files: | + bin/${{ matrix.board }}/**/* + token: ${{ env.RELEASE_WRITE_TOKEN }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 52e64396f45b4..eba14a6fc7603 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -138,7 +138,7 @@ jobs: id: set-matrix working-directory: tools env: - CHANGED_FILES: '["ports/nrf/boards/zoog/mpconfig.mk"]' + CHANGED_FILES: ${{ steps.filter.outputs.changed_files }} run: python3 -u ci_set_matrix.py @@ -284,11 +284,7 @@ jobs: submodules: false fetch-depth: 1 - name: Get CP deps - env: - SSH_KEY: ${{ secrets.PRIVATE_SUBMODULE_SSH_KEY }} - run: | - mkdir $HOME/.ssh && echo "${{ env.SSH_KEY }}" > $HOME/.ssh/id_rsa && chmod 600 $HOME/.ssh/id_rsa - python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }} + run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }} - name: Install dependencies run: | sudo apt-get install -y gettext @@ -308,25 +304,19 @@ jobs: run: python3 -u build_release_files.py working-directory: tools env: - REPO_TOKEN: ${{ secrets.REPO_TOKEN }} BOARDS: ${{ matrix.board }} - uses: actions/upload-artifact@v2 with: name: ${{ matrix.board }} path: bin/${{ matrix.board }} - # - name: Upload to S3 - # run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1" - # env: - # AWS_PAGER: '' - # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - # if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')) - - name: Upload Release Asset - uses: softprops/action-gh-release@v1 - if: ${{ github.event_name == 'release' }} - with: - files: | - bin/${{ matrix.board }}/**/* + - name: Upload to S3 + run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1" + env: + AWS_PAGER: '' + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')) + build-riscv: runs-on: ubuntu-20.04 diff --git a/frozen/abc/abc/__init__.py b/frozen/abc/abc/__init__.py new file mode 100644 index 0000000000000..86e91308e06d1 --- /dev/null +++ b/frozen/abc/abc/__init__.py @@ -0,0 +1,10 @@ +class ABC: + pass + + +def abstractmethod(f): + return f + + +def abstractproperty(f): + return f diff --git a/frozen/enum/enum/__init__.py b/frozen/enum/enum/__init__.py new file mode 100644 index 0000000000000..d3529cf58e81f --- /dev/null +++ b/frozen/enum/enum/__init__.py @@ -0,0 +1,2 @@ +class IntEnum: + pass diff --git a/frozen/typing_extensions/typing_extensions/__init__.py b/frozen/typing_extensions/typing_extensions/__init__.py new file mode 100644 index 0000000000000..3dc9473195972 --- /dev/null +++ b/frozen/typing_extensions/typing_extensions/__init__.py @@ -0,0 +1,2 @@ +class TypedDict: + pass diff --git a/frozen/zoog-firmware b/frozen/zoog-firmware index 7b50c0e36ac2d..7993cd1c1daa2 160000 --- a/frozen/zoog-firmware +++ b/frozen/zoog-firmware @@ -1 +1 @@ -Subproject commit 7b50c0e36ac2dbdb2d9131238b2411fab2930934 +Subproject commit 7993cd1c1daa2eb23682531754d9daf67d1d0dd2 diff --git a/ports/nrf/boards/zoog/mpconfigboard.mk b/ports/nrf/boards/zoog/mpconfigboard.mk index 0ce4896e3afd2..686eb6459318d 100644 --- a/ports/nrf/boards/zoog/mpconfigboard.mk +++ b/ports/nrf/boards/zoog/mpconfigboard.mk @@ -10,13 +10,19 @@ MCU_CHIP = nrf52840 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "GD25Q16E" +CIRCUITPY_BLE_FILE_SERVICE = 0 +CIRCUITPY_COUNTIO = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_KEYPAD = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_SDCARDIO = 0 +CIRCUITPY_SERIAL_BLE = 0 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BLE FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_hashlib +FROZEN_MPY_DIRS += $(TOP)/frozen/abc +FROZEN_MPY_DIRS += $(TOP)/frozen/enum +FROZEN_MPY_DIRS += $(TOP)/frozen/typing_extensions FROZEN_MPY_DIRS += $(TOP)/frozen/zoog-firmware diff --git a/ports/nrf/boards/zoog_cpb/board.c b/ports/nrf/boards/zoog_cpb/board.c new file mode 100644 index 0000000000000..938d92aff116d --- /dev/null +++ b/ports/nrf/boards/zoog_cpb/board.c @@ -0,0 +1,63 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "py/obj.h" +#include "peripherals/nrf/pins.h" +#include "supervisor/shared/board.h" + +#include "nrf_gpio.h" + +void board_init(void) { + // Turn on power to sensors and neopixels. + nrf_gpio_cfg(POWER_SWITCH_PIN->number, + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_NOPULL, + NRF_GPIO_PIN_S0S1, + NRF_GPIO_PIN_NOSENSE); + nrf_gpio_pin_write(POWER_SWITCH_PIN->number, false); +} + +void board_deinit(void) { + // Turn off power to sensors and neopixels. + nrf_gpio_cfg(POWER_SWITCH_PIN->number, + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_NOPULL, + NRF_GPIO_PIN_S0S1, + NRF_GPIO_PIN_NOSENSE); + nrf_gpio_pin_write(POWER_SWITCH_PIN->number, true); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + board_reset_user_neopixels(&pin_P0_13, 10); +} diff --git a/ports/nrf/boards/zoog_cpb/mpconfigboard.h b/ports/nrf/boards/zoog_cpb/mpconfigboard.h new file mode 100644 index 0000000000000..69bff087612e7 --- /dev/null +++ b/ports/nrf/boards/zoog_cpb/mpconfigboard.h @@ -0,0 +1,70 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "Adafruit Circuit Playground Bluefruit" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#define MICROPY_HW_LED_STATUS (&pin_P1_14) + +#define MICROPY_HW_NEOPIXEL (&pin_P0_13) +#define MICROPY_HW_NEOPIXEL_COUNT (10) + +// Board does not have a 32kHz crystal. It does have a 32MHz crystal. +#define BOARD_HAS_32KHZ_XTAL (0) + +#if QSPI_FLASH_FILESYSTEM +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 21) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 23) +#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(1, 00) +#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 22) +#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19) +#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 15) +#endif + +#if SPI_FLASH_FILESYSTEM +#define SPI_FLASH_MOSI_PIN &pin_P0_21 +#define SPI_FLASH_MISO_PIN &pin_P0_23 +#define SPI_FLASH_SCK_PIN &pin_P0_19 +#define SPI_FLASH_CS_PIN &pin_P0_15 +#endif + +// Disables onboard peripherals and neopixels to save power. +#define POWER_SWITCH_PIN (&pin_P0_06) + +#define DEFAULT_I2C_BUS_SCL (&pin_P0_04) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_05) + +#define DEFAULT_SPI_BUS_SCK (&pin_P0_02) +#define DEFAULT_SPI_BUS_MOSI (&pin_P0_03) +#define DEFAULT_SPI_BUS_MISO (&pin_P0_29) + +#define DEFAULT_UART_BUS_RX (&pin_P0_30) +#define DEFAULT_UART_BUS_TX (&pin_P0_14) + +#define SPEAKER_ENABLE_PIN (&pin_P1_04) diff --git a/ports/nrf/boards/zoog_cpb/mpconfigboard.mk b/ports/nrf/boards/zoog_cpb/mpconfigboard.mk new file mode 100644 index 0000000000000..656e1a57b44e6 --- /dev/null +++ b/ports/nrf/boards/zoog_cpb/mpconfigboard.mk @@ -0,0 +1,25 @@ +USB_VID = 0x239A +USB_PID = 0x8046 +USB_PRODUCT = "Circuit Playground Bluefruit" +USB_MANUFACTURER = "Adafruit Industries LLC" + +MCU_CHIP = nrf52840 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICES = "GD25Q16C" + +CIRCUITPY_BLE_FILE_SERVICE = 0 +CIRCUITPY_COUNTIO = 0 +CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_FRAMEBUFFERIO = 0 +CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_KEYPAD = 0 +CIRCUITPY_RGBMATRIX = 0 +CIRCUITPY_SDCARDIO = 0 +CIRCUITPY_SERIAL_BLE = 0 + +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BLE +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_hashlib +FROZEN_MPY_DIRS += $(TOP)/frozen/abc +FROZEN_MPY_DIRS += $(TOP)/frozen/enum +FROZEN_MPY_DIRS += $(TOP)/frozen/typing_extensions diff --git a/ports/nrf/boards/zoog_cpb/pins.c b/ports/nrf/boards/zoog_cpb/pins.c new file mode 100644 index 0000000000000..9c0b815a5bab7 --- /dev/null +++ b/ports/nrf/boards/zoog_cpb/pins.c @@ -0,0 +1,78 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_AUDIO), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_P0_26) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_02) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_29) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_03) }, + + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_04) }, + + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_05) }, + + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_30) }, + + // This cannot be A7, as it is on CPX. We don't have enough analog inputs. + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_14) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_14) }, + + { MP_ROM_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_P0_28) }, + + { MP_ROM_QSTR(MP_QSTR_TEMPERATURE), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_P0_31) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON_A), MP_ROM_PTR(&pin_P1_02) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P1_02) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON_B), MP_ROM_PTR(&pin_P1_15) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P1_15) }, + + { MP_ROM_QSTR(MP_QSTR_SLIDE_SWITCH), MP_ROM_PTR(&pin_P1_06) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P1_06) }, + + // If high, turns off NeoPixels, LIS3DH, sound sensor, light sensor, temp sensor. + { MP_ROM_QSTR(MP_QSTR_POWER_SWITCH), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_P0_06) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_P1_14) }, + { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_14) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_14) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_13) }, + + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_CLOCK), MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_MICROPHONE_DATA), MP_ROM_PTR(&pin_P0_16) }, + + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_P1_13) }, + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SDA), MP_ROM_PTR(&pin_P1_10) }, + { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_SCL), MP_ROM_PTR(&pin_P1_12) }, + + { MP_ROM_QSTR(MP_QSTR_SPEAKER_ENABLE), MP_ROM_PTR(&pin_P1_04) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index b478e0b4d770d..b4f11af93c3a3 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -109,12 +109,51 @@ static void make_sample_code_file(FATFS *fatfs) { "button.direction = digitalio.Direction.INPUT\n" "button.pull = digitalio.Pull.DOWN\n" "\n" + "if (not button.value):\n" + " storage.disable_usb_drive()\n" + "\n" "# If button up, CircuitPython can write to the drive\n" "storage.remount(\"/\", button.value)\n"; // Create or modify existing boot.py file f_open(fatfs, &fs, "/boot.py", FA_WRITE | FA_CREATE_ALWAYS); - f_write(&fs, buffer, sizeof(boot_buffer) - 1, &char_written); + f_write(&fs, boot_buffer, sizeof(boot_buffer) - 1, &char_written); + f_close(&fs); + + char_written = 0; + + const byte init_asset_buffer[] = { + 0xFF, 0xFB, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00 + }; + // Create or modify init_asset file + f_open(fatfs, &fs, "/init_asset", FA_WRITE | FA_CREATE_ALWAYS); + f_write(&fs, init_asset_buffer, sizeof(init_asset_buffer) - 1, &char_written); f_close(&fs); #else make_empty_file(fatfs, "/main.py");