Skip to content

Commit

Permalink
add pre-commit hook, codespell dictionary, minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Nov 7, 2023
1 parent ddf7ce6 commit b064ed5
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 29 deletions.
10 changes: 10 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/build_arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- 'sparkfun_stm32_thing_plus'
# stm32l4
- 'swan_r5'

steps:
- name: Setup Python
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_esp32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
[ -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
2 changes: 1 addition & 1 deletion .github/workflows/build_selftest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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/
# )
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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

Expand All @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions ports/espressif/README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ports/espressif/components/bootloader/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ports/espressif/components/bootloader/Makefile.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand All @@ -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<NEOPIXEL_NUMBER; i++) {
// Note: WS2812 color order is GRB
Expand Down Expand Up @@ -428,9 +428,9 @@ void sw_i2c_begin(uint8_t address) {

void sw_i2c_end() {
gpio_ll_set_level(&GPIO, I2C_MASTER_SDA_IO, LOW);
delay_cycle( ns2cycle(I2C_WAIT*1000) ) ;
delay_cycle( ns2cycle(I2C_WAIT*1000) ) ;
gpio_ll_set_level(&GPIO, I2C_MASTER_SCL_IO, HIGH);
delay_cycle( ns2cycle(I2C_WAIT*1000) ) ;
delay_cycle( ns2cycle(I2C_WAIT*1000) ) ;
gpio_ll_set_level(&GPIO, I2C_MASTER_SDA_IO, HIGH);
}

Expand All @@ -449,13 +449,13 @@ void sw_i2c_init() {
gpio_ll_input_disable(&GPIO, I2C_MASTER_SCL_IO);
gpio_ll_output_enable(&GPIO, I2C_MASTER_SCL_IO);
gpio_ll_od_enable(&GPIO, I2C_MASTER_SCL_IO);
gpio_ll_pullup_en(&GPIO, I2C_MASTER_SCL_IO);
gpio_ll_pullup_en(&GPIO, I2C_MASTER_SCL_IO);
gpio_ll_pulldown_dis(&GPIO, I2C_MASTER_SCL_IO);
gpio_ll_intr_disable(&GPIO, I2C_MASTER_SCL_IO);
gpio_ll_intr_disable(&GPIO, I2C_MASTER_SCL_IO);
gpio_ll_set_level(&GPIO, I2C_MASTER_SCL_IO, HIGH);
}

//Turn on Peripheral power.
//Turn on Peripheral power.
void init_tca9554() {
sw_i2c_begin(TCA9554_ADDR << 1);
sw_i2c_write_byte(TCA9554_CONFIGURATION_REG);
Expand All @@ -475,11 +475,11 @@ static void board_led_on(void) {
#ifdef NEOPIXEL_PIN
#ifdef TCA9554_ADDR
sw_i2c_init();
// For some reason this delay is required after the pins are initialized before being used.
// For some reason this delay is required after the pins are initialized before being used.
delay_cycle( ns2cycle(30000*1000) );
init_tca9554();
#endif

#ifdef NEOPIXEL_POWER_PIN
esp_rom_gpio_pad_select_gpio(NEOPIXEL_POWER_PIN);
gpio_ll_input_disable(&GPIO, NEOPIXEL_POWER_PIN);
Expand Down
Empty file.
13 changes: 13 additions & 0 deletions tools/codespell/ignore-words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
synopsys
sie
tre
thre
hsi
fro
dout
mot
te
attch
endianess
pris
busses

0 comments on commit b064ed5

Please sign in to comment.