From ed687308ec4ef726aa60b5b855f6658d9c95d6ec Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 30 Jul 2021 17:27:04 +0700 Subject: [PATCH] clean up, update doc --- README.md | 12 +++--------- changelog.md | 10 ++++++++++ ports/esp32s2/README.md | 9 ++++----- ports/stm32f4/README.md | 10 ++++++++++ ports/stm32f4/board_flash.c | 8 ++++---- .../boards/feather_stm32f405_express/board.mk | 3 --- ports/stm32f4/boards/stm32f401_blackpill/board.mk | 5 +---- .../stm32f4/boards/stm32f411ce_blackpill/README.txt | 3 --- ports/stm32f4/boards/stm32f411ce_blackpill/board.h | 4 ++-- ports/stm32f4/boards/stm32f411ce_blackpill/board.mk | 2 +- ports/stm32f4/boards/stm32f411ve_discovery/board.mk | 7 ++----- 11 files changed, 37 insertions(+), 36 deletions(-) create mode 100644 ports/stm32f4/README.md delete mode 100644 ports/stm32f4/boards/stm32f411ce_blackpill/README.txt diff --git a/README.md b/README.md index 02afc7a4c..ccca0f313 100644 --- a/README.md +++ b/README.md @@ -28,18 +28,10 @@ TODO more docs later ## Build and Flash -### Requirements - -- GCC cross compiler and Make +Following is generic compiling information. Each port may require extra set-up and slight different process e.g esp32s2 require setup IDF. ### Compile -Firstly clone this repo and its submodules with - -``` -$ git clone --recurse-submodules https://github.com/adafruit/tinyuf2 -``` - To build this for a specific board, we need to change current directory to its port folder ``` @@ -52,6 +44,8 @@ Then compile with `make BOARD=[board_name] all`, for example make BOARD=feather_stm32f405_express all ``` +The required mcu driver submodule if any will be clone automatically if needed. + ### Flash `flash` target will use the default on-board debugger (jlink/cmsisdap/stlink/dfu) to flash the binary, please install those support software in advance. Some board use bootloader/DFU via serial which is required to pass to make command diff --git a/changelog.md b/changelog.md index 54eb70c22..b88774f42 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,15 @@ # TinyUF2 Changelog +## 0.5.1 - 2021.07.30 + +### ESP32-S2 + +- Added new board: unexpectedmaker_feathers2_neo + +### STM32F4 + +- fix updating issue with circuipython + ## 0.5.0 - 2021.07.12 - Update self-update as application diff --git a/ports/esp32s2/README.md b/ports/esp32s2/README.md index 49d2951c6..d03863c60 100644 --- a/ports/esp32s2/README.md +++ b/ports/esp32s2/README.md @@ -1,4 +1,4 @@ -# UF2 Bootloader **Application** for ESP32-S2 +# TinyUF2 "Bootloader Application" for ESP32-S2 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. @@ -68,9 +68,10 @@ There are a few ways to enter UF2 mode: To create your own UF2 file, simply use the [Python conversion script](https://github.com/Microsoft/uf2/blob/master/utils/uf2conv.py) on a .bin file, specifying the family as **0xbfdd4eee**. Note you must specify application address of 0x00 with the -b switch, the bootloader will use it as offset to write to ota partition. -To create a UF2 image from a .bin file: +To create a UF2 image from a .bin file using family option `ESP32S2` or its magic number as followss: ``` +uf2conv.py firmware.bin -c -b 0x00 -f ESP32S2 uf2conv.py firmware.bin -c -b 0x00 -f 0xbfdd4eee ``` @@ -94,9 +95,7 @@ NOTE: uf2 bootloader, customized 2nd bootloader and partition table can be overw ## Partition -The following partition isn't final yet, current build without optimization and lots of debug is around 100 KB. Since IDF requires application type must be 64KB aligned, uf2 is best with size of 64KB, we will try to see if we could fit https://github.com/microsoft/uf2/blob/master/hf2.md and https://github.com/microsoft/uf2/blob/master/cf2.md within 64KB. - -UF2 only uses `ota_0` user application can change partition table (e.g increase ota_0 size, re-arrange layout/address) but should not overwrite the uf2 part. If an complete re-design partition is required, `uf2_bootloader.bin` and the `modified 2nd_stage_bootloader.bin` should be included as part of user combined binary for flash command. +Following is typical partition for 4MB flash, check out the `partition-xMB.csv` for details. ``` # Name, Type, SubType, Offset, Size, Flags diff --git a/ports/stm32f4/README.md b/ports/stm32f4/README.md new file mode 100644 index 000000000..d568f23cf --- /dev/null +++ b/ports/stm32f4/README.md @@ -0,0 +1,10 @@ +# TinyUF2 for STM32F4 + +TinyUF2 reserved 64KB for compatible with eixisting application e.g ciruitpython, even though TinyUF2 actual binary size is much smaller (less than 32KB). Therefore application should start at `0x08010000`. + +To create a UF2 image from a .bin file, either use family option `STM32F4` or its magic number as follows: + +``` +uf2conv.py -c -b 0x08010000 -f STM32F4 firmware.bin +uf2conv.py -c -b 0x08010000 -f 0x57755a57 firmware.bin +``` diff --git a/ports/stm32f4/board_flash.c b/ports/stm32f4/board_flash.c index ca67c6690..dcd94b743 100644 --- a/ports/stm32f4/board_flash.c +++ b/ports/stm32f4/board_flash.c @@ -33,9 +33,7 @@ //#define FLASH_CACHE_SIZE 4096 //#define FLASH_CACHE_INVALID_ADDR 0xffffffff - #define FLASH_BASE_ADDR 0x08000000 -#define APP_LOAD_ADDRESS 0x08010000 /* flash parameters that we should not really know */ static const uint32_t sector_size[] = @@ -45,17 +43,19 @@ static const uint32_t sector_size[] = 16 * 1024, 16 * 1024, 16 * 1024, - // Application (APP_LOAD_ADDRESS) + // Application (BOARD_FLASH_APP_START) 64 * 1024, 128 * 1024, 128 * 1024, 128 * 1024, + + // flash sectors only in 1 MB devices 128 * 1024, 128 * 1024, 128 * 1024, 128 * 1024, - // flash sectors only in 2MiB devices + // flash sectors only in 2 MB devices 16 * 1024, 16 * 1024, 16 * 1024, diff --git a/ports/stm32f4/boards/feather_stm32f405_express/board.mk b/ports/stm32f4/boards/feather_stm32f405_express/board.mk index 961748526..79711bc0a 100644 --- a/ports/stm32f4/boards/feather_stm32f405_express/board.mk +++ b/ports/stm32f4/boards/feather_stm32f405_express/board.mk @@ -10,6 +10,3 @@ JLINK_DEVICE = stm32f405rg flash: flash-dfu-util erase: erase-jlink - -#flash: flash-stlink -#erase: erase-stlink diff --git a/ports/stm32f4/boards/stm32f401_blackpill/board.mk b/ports/stm32f4/boards/stm32f401_blackpill/board.mk index 5e0e2486e..03c10da2c 100644 --- a/ports/stm32f4/boards/stm32f401_blackpill/board.mk +++ b/ports/stm32f4/boards/stm32f401_blackpill/board.mk @@ -8,8 +8,5 @@ SRC_S += \ # For flash-jlink target JLINK_DEVICE = stm32f401cc -flash: flash-jlink +flash: flash-dfu-util erase: erase-jlink - -#flash: flash-stlink -#erase: erase-stlink diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/README.txt b/ports/stm32f4/boards/stm32f411ce_blackpill/README.txt deleted file mode 100644 index 5b4abd33c..000000000 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/README.txt +++ /dev/null @@ -1,3 +0,0 @@ -Remember when creating the uf2 file that the family_id and base address are specified as follows: -uf2conv.py -o stm32f411blackpill-app.uf2 -b 0x08010000 -f 0x57755a57 stm32f411blackpill-app.bin -uf2conv.py -o stm32f411blackpill-app.uf2 -b 0x08010000 -f STM32F4 stm32f411blackpill-app.bin diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/board.h b/ports/stm32f4/boards/stm32f411ce_blackpill/board.h index 8e9c36c35..a768deb4e 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/board.h +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/board.h @@ -52,8 +52,8 @@ //--------------------------------------------------------------------+ // Flash size of the board -#define BOARD_FLASH_SIZE (512 * 1024) -#define BOARD_FLASH_SECTORS 8 +#define BOARD_FLASH_SIZE (512 * 1024) +#define BOARD_FLASH_SECTORS 8 //--------------------------------------------------------------------+ // USB UF2 diff --git a/ports/stm32f4/boards/stm32f411ce_blackpill/board.mk b/ports/stm32f4/boards/stm32f411ce_blackpill/board.mk index 946497652..ab6577472 100644 --- a/ports/stm32f4/boards/stm32f411ce_blackpill/board.mk +++ b/ports/stm32f4/boards/stm32f411ce_blackpill/board.mk @@ -8,5 +8,5 @@ SRC_S += \ # For flash-jlink target JLINK_DEVICE = stm32f411ce -flash: flash-jlink +flash: flash-dfu-util erase: erase-jlink diff --git a/ports/stm32f4/boards/stm32f411ve_discovery/board.mk b/ports/stm32f4/boards/stm32f411ve_discovery/board.mk index fe46d8e96..b5b8da21b 100644 --- a/ports/stm32f4/boards/stm32f411ve_discovery/board.mk +++ b/ports/stm32f4/boards/stm32f411ve_discovery/board.mk @@ -8,8 +8,5 @@ SRC_S += \ # For flash-jlink target JLINK_DEVICE = stm32f411ve -flash: flash-jlink -erase: erase-jlink - -#flash: flash-stlink -#erase: erase-stlink +flash: flash-stlink +erase: erase-stlink