From b064ed5ae1f99dcdecd66f7e286f4d2b411bf42c Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 7 Nov 2023 11:18:09 +0700 Subject: [PATCH] add pre-commit hook, codespell dictionary, minor changes --- .codespellrc | 10 ++++++ .github/workflows/build_arm.yml | 2 +- .github/workflows/build_esp32.yml | 2 +- .github/workflows/build_selftest.yml | 2 +- .pre-commit-config.yaml | 32 +++++++++++++++++++ README.md | 14 ++++---- changelog.md | 6 ++-- ports/espressif/README.md | 6 ++-- .../components/bootloader/Kconfig.projbuild | 4 +-- .../components/bootloader/Makefile.projbuild | 2 +- .../subproject/main/bootloader_hooks.h | 2 +- .../subproject/main/bootloader_start.c | 20 ++++++------ tools/codespell/exclude-file.txt | 0 tools/codespell/ignore-words.txt | 13 ++++++++ 14 files changed, 86 insertions(+), 29 deletions(-) create mode 100644 .codespellrc create mode 100644 .pre-commit-config.yaml create mode 100644 tools/codespell/exclude-file.txt create mode 100644 tools/codespell/ignore-words.txt diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 000000000..1e707155e --- /dev/null +++ b/.codespellrc @@ -0,0 +1,10 @@ +# See: https://github.com/codespell-project/codespell#using-a-config-file +[codespell] +# In the event of a false positive, add the problematic word, in all lowercase, to 'ignore-words.txt' (one word per line). +# Or copy & paste the whole problematic line to 'exclude-file.txt' +ignore-words = tools/codespell/ignore-words.txt +exclude-file = tools/codespell/exclude-file.txt +check-filenames = +check-hidden = +count = +skip = .git,./lib diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml index 083b0fa52..23f71232a 100644 --- a/.github/workflows/build_arm.yml +++ b/.github/workflows/build_arm.yml @@ -46,7 +46,7 @@ jobs: - 'sparkfun_stm32_thing_plus' # stm32l4 - 'swan_r5' - + steps: - name: Setup Python uses: actions/setup-python@v4 diff --git a/.github/workflows/build_esp32.yml b/.github/workflows/build_esp32.yml index 04f4907a9..6aa59e3f1 100644 --- a/.github/workflows/build_esp32.yml +++ b/.github/workflows/build_esp32.yml @@ -149,4 +149,4 @@ jobs: if: ${{ github.event_name == 'release' }} run: | [ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.zip s3://adafruit-circuit-python/bootloaders/esp32/tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.zip --no-progress --region us-east-1 - [ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp update-tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.uf2 s3://adafruit-circuit-python/bootloaders/esp32/update-tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.uf2 --no-progress --region us-east-1 \ No newline at end of file + [ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp update-tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.uf2 s3://adafruit-circuit-python/bootloaders/esp32/update-tinyuf2-${{ matrix.board }}-${{ github.event.release.tag_name }}.uf2 --no-progress --region us-east-1 diff --git a/.github/workflows/build_selftest.yml b/.github/workflows/build_selftest.yml index aa7e31dd0..e57acdcfa 100644 --- a/.github/workflows/build_selftest.yml +++ b/.github/workflows/build_selftest.yml @@ -75,7 +75,7 @@ jobs: gzip --keep ghostfat_${{ matrix.board }}.img gzip --keep --force --best ghostfat_${{ matrix.board }}.img.gz popd - + - name: Save newly generated self-test images as CI artifacts if: always() uses: actions/upload-artifact@v3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..f40c2e7f4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,32 @@ +# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò +# +# SPDX-License-Identifier: Unlicense + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: trailing-whitespace +# exclude: | +# (?x)^( +# hw/bsp/mcx/sdk/ +# ) + - id: end-of-file-fixer +# exclude: | +# (?x)^( +# .idea/| +# hw/bsp/mcx/sdk/ +# ) + - id: forbid-submodules + +- repo: https://github.com/codespell-project/codespell + rev: v2.2.4 + hooks: + - id: codespell + args: [-w] +# exclude: | +# (?x)^( +# lib/| +# hw/bsp/mcx/sdk/ +# ) diff --git a/README.md b/README.md index b9aedac04..f4f919f34 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ This repo is cross-platform UF2 Bootloader projects for MCUs based on [TinyUSB]( ├── apps # Useful applications such as self-update, erase firmware ├── lib # Sources from 3rd party such as tinyusb, mcu drivers ... ├── ports # Port/family specific sources -│   ├── espressif -│   │   └── boards/ # Board specific sources -│   │   └── Makefile # Makefile for this port -│   └── mimxrt10xx +│ ├── espressif +│ │ └── boards/ # Board specific sources +│ │ └── Makefile # Makefile for this port +│ └── mimxrt10xx ├── src # Cross-platform bootloader sources files ``` @@ -49,7 +49,7 @@ To build this for a specific board, we need to change current directory to its p $ cd ports/stm32f4 ``` -Firstly we need to get all of submodule dependecy for our board e.g mcu driver with `get-deps` target. You only need to do this once for each mcu family +Firstly we need to get all of submodule dependency for our board e.g mcu driver with `get-deps` target. You only need to do this once for each mcu family ``` make BOARD=feather_stm32f405_express get-deps @@ -81,7 +81,7 @@ $ make BOARD=feather_stm32f405_express DEBUG=1 all #### Log -Should you have an issue running example and/or submitting an bug report. You could enable TinyUSB built-in debug logging with optional `LOG=`. +Should you have an issue running example and/or submitting an bug report. You could enable TinyUSB built-in debug logging with optional `LOG=`. - **LOG=1** will print message from bootloader and error if any from TinyUSB stack. - **LOG=2** and **LOG=3** will print more information with TinyUSB stack events @@ -91,7 +91,7 @@ $ make BOARD=feather_stm32f405_express LOG=1 all #### Logger -By default log message is printed via on-board UART which is slow and take lots of CPU time comparing to USB speed. If your board support on-board/external debugger, it would be more efficient to use it for logging. There are 2 protocols: +By default log message is printed via on-board UART which is slow and take lots of CPU time comparing to USB speed. If your board support on-board/external debugger, it would be more efficient to use it for logging. There are 2 protocols: - `LOGGER=rtt`: use [Segger RTT protocol](https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/) - Cons: requires jlink as the debugger. diff --git a/changelog.md b/changelog.md index 1666cb743..62f3ba1c8 100644 --- a/changelog.md +++ b/changelog.md @@ -50,7 +50,7 @@ Added new boards: MorphESP-240 ESP32S2, Lolin S2 Mini, Espressif HMI devkit ## 0.4.0 - Add support for multiple sectors per cluster in GhostFAT to enable larger flash sizes - - Add native test for ghostfat with varous checks + - Add native test for ghostfat with various checks - Add new board API: - board_reset() - board_flash_erase_app() @@ -59,7 +59,7 @@ Added new boards: MorphESP-240 ESP32S2, Lolin S2 Mini, Espressif HMI devkit - Add `erase_firmware` application target (only implemented for iMXRT for now). - TinyUF2 will erase whole flash if `MAGIC_ERASE_APP` is written by application. - `erase_firmware.uf2` is also uploaded as part of build/release asset if available -- No major chagnes to LPC55, STM32 F3 F4 +- No major changes to LPC55, STM32 F3 F4 ### ESP32-S2 @@ -71,7 +71,7 @@ Added new boards: MorphESP-240 ESP32S2, Lolin S2 Mini, Espressif HMI devkit ### iMXRT -- Always write tinyuf2 image to flash if loaded in Serial Donwload mode (Boot Mode = 01) +- Always write tinyuf2 image to flash if loaded in Serial Download mode (Boot Mode = 01) - Add `erase_firmware.uf2` to erase the whole flash except bootloader - Add sdphost binary for arm 32bit e.g raspberry pi 4 - Add `esp32programmer.uf2` app for selected board. diff --git a/ports/espressif/README.md b/ports/espressif/README.md index bf8651fd3..e1c5f3d5d 100644 --- a/ports/espressif/README.md +++ b/ports/espressif/README.md @@ -1,6 +1,8 @@ # TinyUF2 "Bootloader Application" for ESP32-S2 and ESP32-S3 -The project is composed of customizing the 2nd stage bootloader from IDF and UF2 factory application as 3rd stage bootloader. **Note**: since IDF is actively developed and change very often, it is included as submodule at `lib/esp-idf`, please run export script there to have your environment setup correctly. +The project is composed of customizing the 2nd stage bootloader from IDF and UF2 factory application as 3rd stage bootloader. + +**Note**: IDF is actively developed and change very often, TinyUF2 is developed and tested with IDF v5.1. Should you have a problem please try to change your IDF version to v5.1. Following boards are supported: @@ -33,7 +35,7 @@ Following boards are supported: ### Build -You will need to download and [set up ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/get-started/) or [set up ESP-IDF for ESP32-S3](https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/get-started/). The IDF version is developed and tested by TinyUF2 is at `lib/esp-idf` +Once installed and setup ESP-IDF, you can build with all target ``` make BOARD=adafruit_feather_esp32s2 all diff --git a/ports/espressif/components/bootloader/Kconfig.projbuild b/ports/espressif/components/bootloader/Kconfig.projbuild index 7c145f603..5a61b1210 100644 --- a/ports/espressif/components/bootloader/Kconfig.projbuild +++ b/ports/espressif/components/bootloader/Kconfig.projbuild @@ -314,7 +314,7 @@ menu "Bootloader config" select EFUSE_VIRTUAL_KEEP_IN_FLASH help This option allows to emulate read/write operations with all eFuses and efuse secure version. - It allows to test anti-rollback implemention without permanent write eFuse bits. + It allows to test anti-rollback implementation without permanent write eFuse bits. There should be an entry in partition table with following details: `emul_efuse, data, efuse, , 0x2000`. This option enables: EFUSE_VIRTUAL and EFUSE_VIRTUAL_KEEP_IN_FLASH. @@ -402,7 +402,7 @@ menu "Bootloader config" this area remains valid when rebooted, except for power loss. This memory is located at a fixed address and is available for both the bootloader and the application. - (The application and bootoloader must be compiled with the same option). + (The application and bootloader must be compiled with the same option). The RTC FAST memory has access only through PRO_CPU. config BOOTLOADER_CUSTOM_RESERVE_RTC_SIZE diff --git a/ports/espressif/components/bootloader/Makefile.projbuild b/ports/espressif/components/bootloader/Makefile.projbuild index 565d197fd..74a270a31 100644 --- a/ports/espressif/components/bootloader/Makefile.projbuild +++ b/ports/espressif/components/bootloader/Makefile.projbuild @@ -25,7 +25,7 @@ BOOTLOADER_OFFSET := 0x1000 # Custom recursive make for bootloader sub-project # # NB: Some variables are cleared in the environment, not -# overriden, because they need to be re-defined in the child +# overridden, because they need to be re-defined in the child # project. # # Pass PROJECT_PATH variable, it will let the subproject look diff --git a/ports/espressif/components/bootloader/subproject/main/bootloader_hooks.h b/ports/espressif/components/bootloader/subproject/main/bootloader_hooks.h index eeaa1b96d..504534f03 100644 --- a/ports/espressif/components/bootloader/subproject/main/bootloader_hooks.h +++ b/ports/espressif/components/bootloader/subproject/main/bootloader_hooks.h @@ -16,7 +16,7 @@ #define BOOTLOADER_HOOKS_H /** - * @file The 2nd stage bootloader can be overriden or completed by an application. + * @file The 2nd stage bootloader can be overridden or completed by an application. * The functions declared here are weak, and thus, are meant to be defined by a user * project, if required. * Please check `custom_bootloader` ESP-IDF examples for more details about this feature. diff --git a/ports/espressif/components/bootloader/subproject/main/bootloader_start.c b/ports/espressif/components/bootloader/subproject/main/bootloader_start.c index 813b80d3a..0673d9fbd 100644 --- a/ports/espressif/components/bootloader/subproject/main/bootloader_start.c +++ b/ports/espressif/components/bootloader/subproject/main/bootloader_start.c @@ -226,7 +226,7 @@ static int selected_boot_partition(const bootloader_state_t *bs) { esp_rom_gpio_pad_select_gpio(PIN_BUTTON_UF2); PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[PIN_BUTTON_UF2]); esp_rom_gpio_pad_pullup_only(PIN_BUTTON_UF2); - + // run the GPIO detection at least once even if UF2_DETECTION_DELAY_MS is set to zero uint32_t tm_start = esp_log_early_timestamp(); do { @@ -292,7 +292,7 @@ static inline uint32_t delay_cycle(uint32_t cycle) { #define HIGH 0x01 #define ACK 0x00 #define NACK 0x01 -#define CLOCK_STRETCH_TIMEOUT 1000 +#define CLOCK_STRETCH_TIMEOUT 1000 #endif @@ -307,7 +307,7 @@ static void board_neopixel_set(uint32_t num_pin, uint8_t const rgb[]) { uint32_t const time0 = ns2cycle(400); uint32_t const time1 = ns2cycle(800); uint32_t const period = ns2cycle(1250); - + uint8_t pixels[3*NEOPIXEL_NUMBER]; for(uint32_t i=0; i