Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade idf v5.1 #354

Merged
merged 21 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ddf7ce6
fix bootloader build with idf 5.1, remove idf as submodule
hathach Nov 7, 2023
b064ed5
add pre-commit hook, codespell dictionary, minor changes
hathach Nov 7, 2023
9b4daea
sync bootloader with idf 5.1
hathach Nov 7, 2023
7b89de3
add tinyusb_src as a component, fix app compiling with idf 5.1
hathach Nov 7, 2023
15a89a1
update ci to build with 5.1.1
hathach Nov 7, 2023
26a9feb
add esp32s2 devkitc 1
hathach Nov 7, 2023
b793923
add main component (move from top/src)
hathach Nov 7, 2023
d3f49c1
able to add self_update as subproject, although app is required to bu…
hathach Nov 7, 2023
9497037
try to generate update-tinyuf2.uf2
hathach Nov 7, 2023
2e01b60
move self-update to seperated project since it require app to be buil…
hathach Nov 8, 2023
20de288
update makefile to refelct changes in self-update cmake
hathach Nov 8, 2023
3d2f96c
change all portTICK_RATE_MS to portTICK_PERIOD_MS
hathach Nov 8, 2023
9b09592
fix compilation with lilygo boards
hathach Nov 8, 2023
1895a94
run pre-commit on ci
hathach Nov 8, 2023
0cd557a
update ci precommit
hathach Nov 8, 2023
b1c3e01
skip lib/ in pre-commit check. Fixed mostly trailing spaces and end o…
hathach Nov 8, 2023
b443ef3
revert uncorrect typo check by codespell
hathach Nov 8, 2023
9de5349
Remove forbid submodule
hathach Nov 9, 2023
cb07051
Revert changes to s3 devkit flash size
hathach Nov 9, 2023
0eda9b6
Revert incorrecr change by codespell
hathach Nov 9, 2023
6c7652e
Revert incorrect change by codespell
hathach Nov 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions .github/workflows/build_esp32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
run: echo BIN_PATH=ports/espressif/_bin/${{ matrix.board }} >> $GITHUB_ENV

- name: Build
run: docker run --rm -v $PWD:/project -w /project espressif/idf:v4.4.3 /bin/bash -c "git config --global --add safe.directory /project && make -C ports/espressif/ BOARD=${{ matrix.board }} all self-update copy-artifact"
run: docker run --rm -v $PWD:/project -w /project espressif/idf:v5.1.1 /bin/bash -c "git config --global --add safe.directory /project && make -C ports/espressif/ BOARD=${{ matrix.board }} all self-update copy-artifact"

- uses: actions/upload-artifact@v3
with:
Expand Down 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
25 changes: 25 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: pre-commit

on:
workflow_dispatch:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Checkout code
uses: actions/checkout@v3

- name: Run pre-commit
uses: pre-commit/[email protected]
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/sdkconfig
.settings/
*.o
*.d
*.P
Expand All @@ -9,3 +8,4 @@ _bin/
*.cmake~
sdkconfig~
*.yml~
ports/espressif/apps/self_update/main/bootloader_bin.c
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
[submodule "lib/tinyusb"]
path = lib/tinyusb
url = https://github.com/hathach/tinyusb.git
[submodule "lib/esp-idf"]
path = lib/esp-idf
url = https://github.com/espressif/esp-idf.git
[submodule "lib/uf2"]
path = lib/uf2
url = https://github.com/microsoft/uf2.git
Expand Down
53 changes: 53 additions & 0 deletions .idea/cmake.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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)^(
lib/|
ports/espressif/components/bootloader/subproject/components
)
- id: end-of-file-fixer
exclude: |
(?x)^(
lib/|
.idea/
)

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
args: [-w]
exclude: |
(?x)^(
lib/
)
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
3 changes: 0 additions & 3 deletions apps/self_update/CMakeLists.txt

This file was deleted.

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
1 change: 0 additions & 1 deletion lib/esp-idf
Submodule esp-idf deleted from bbe2a1
5 changes: 5 additions & 0 deletions ports/espressif/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ add_compile_definitions(UF2_VERSION="${GIT_VERSION} - ${GIT_SUBMODULE_VERSIONS}"
cmake_print_variables(GIT_VERSION GIT_SUBMODULE_VERSIONS)

project(tinyuf2)

# Post build: generate bootloader_bin.c for self-update and combined.bin
add_custom_command(TARGET app POST_BUILD
COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} --carray -o ${CMAKE_SOURCE_DIR}/apps/self_update/main/bootloader_bin.c ${CMAKE_BINARY_DIR}/tinyuf2.bin
)
14 changes: 6 additions & 8 deletions ports/espressif/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ combined-flash: $(BUILD)/combined.bin
esptool.py --chip $(IDF_TARGET) write_flash 0x0 $<

#-------------- Self Update --------------
SELF_BUILD = apps/self_update/$(BUILD)
SELF_APP = apps/self_update
SELF_BUILD = ${SELF_APP}/${BUILD}

$(SELF_BUILD)/update-tinyuf2.bin: app
$(PYTHON3) $(TOP)/lib/uf2/utils/uf2conv.py --carray $(BUILD)/tinyuf2.bin -o $(TOP)/apps/self_update/bootloader_bin.c
idf.py -C apps/self_update/ -B$(SELF_BUILD) -DBOARD=$(BOARD) app
@rm $(TOP)/apps/self_update/bootloader_bin.c

$(SELF_BUILD)/update-tinyuf2.uf2: $(SELF_BUILD)/update-tinyuf2.bin
$(PYTHON3) $(TOP)/lib/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID_$(IDF_TARGET)) -b 0x0000 -c -o $@ $^
# cmake post build of tinyuf2's app will generate bootloader_bin.c
# cmake post build of self-update's app will generate update-tinyuf2.uf2
$(SELF_BUILD)/update-tinyuf2.uf2: app
idf.py -C ${SELF_APP} -B${SELF_BUILD} -DBOARD=${BOARD} app

self-update: $(SELF_BUILD)/update-tinyuf2.uf2

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.1. Should you have a problem please try to change your IDF version.

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
51 changes: 21 additions & 30 deletions ports/espressif/apps/self_update/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

# Check for -DBOARD=
if(NOT (DEFINED BOARD AND EXISTS "${CMAKE_SOURCE_DIR}/../../boards/${BOARD}/board.h") )
file(GLOB BOARD_LIST RELATIVE ${CMAKE_SOURCE_DIR}/../../boards "boards/*/board.h")

message("Please specify `-DBOARD=` with one of supported boards")
foreach(board IN LISTS BOARD_LIST)
string(REPLACE "/board.h" "" board ${board})
message("- ${board}")
endforeach()

message(FATAL_ERROR "Invalid BOARD specified")
endif()

include(${CMAKE_SOURCE_DIR}/../../boards/${BOARD}/board.cmake)

# TOP is absolute path to root directory
set(TOP "../../../..")
get_filename_component(TOP "${TOP}" REALPATH)

set(EXTRA_COMPONENT_DIRS "${TOP}/apps/self_update" "../../boards" "../../components")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

add_compile_definitions(TINYUF2_SELF_UPDATE)

project(update-tinyuf2)
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.17)

include(${CMAKE_CURRENT_LIST_DIR}/../../../family_support.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../../boards/${BOARD}/board.cmake)

# Must be set before including IDF project.cmake
set(EXTRA_COMPONENT_DIRS "../../boards" "../../components")

set(SELFUPDATE_BUILD 1)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

add_compile_definitions(TINYUF2_SELF_UPDATE)

project(update-tinyuf2)

add_custom_command(TARGET app POST_BUILD
COMMAND ${Python_EXECUTABLE} ${UF2CONV_PY} -f ${UF2_FAMILY_ID_${IDF_TARGET}} -b 0x0 -c -o ${CMAKE_BINARY_DIR}/update-tinyuf2.uf2 ${CMAKE_BINARY_DIR}/update-tinyuf2.bin
VERBATIM
)
4 changes: 4 additions & 0 deletions ports/espressif/apps/self_update/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Note: bootloader_bin.c is generated by tinyuf2 app target
idf_component_register(SRCS ${TOP}/apps/self_update/self_update.c bootloader_bin.c
INCLUDE_DIRS ${TOP}/src
REQUIRES boards)
32 changes: 16 additions & 16 deletions ports/espressif/apps/self_update/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
CONFIG_IDF_CMAKE=y
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
# Compiler options
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
# Newlib
CONFIG_NEWLIB_NANO_FORMAT=y
# Virtual file system
CONFIG_VFS_SUPPORT_IO=n
# Compatibility options
CONFIG_FLASHMODE_QIO=y
CONFIG_IDF_CMAKE=y
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y

# Compiler options
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y

# Newlib
CONFIG_NEWLIB_NANO_FORMAT=y

# Virtual file system
CONFIG_VFS_SUPPORT_IO=n

# Compatibility options
CONFIG_FLASHMODE_QIO=y
Loading