Skip to content

Commit

Permalink
clean up, update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Jul 30, 2021
1 parent de2e89f commit ed68730
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 36 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 4 additions & 5 deletions ports/esp32s2/README.md
Original file line number Diff line number Diff line change
@@ -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.

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

Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions ports/stm32f4/README.md
Original file line number Diff line number Diff line change
@@ -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
```
8 changes: 4 additions & 4 deletions ports/stm32f4/board_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] =
Expand All @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions ports/stm32f4/boards/feather_stm32f405_express/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ JLINK_DEVICE = stm32f405rg

flash: flash-dfu-util
erase: erase-jlink

#flash: flash-stlink
#erase: erase-stlink
5 changes: 1 addition & 4 deletions ports/stm32f4/boards/stm32f401_blackpill/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions ports/stm32f4/boards/stm32f411ce_blackpill/README.txt

This file was deleted.

4 changes: 2 additions & 2 deletions ports/stm32f4/boards/stm32f411ce_blackpill/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ports/stm32f4/boards/stm32f411ce_blackpill/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ SRC_S += \
# For flash-jlink target
JLINK_DEVICE = stm32f411ce

flash: flash-jlink
flash: flash-dfu-util
erase: erase-jlink
7 changes: 2 additions & 5 deletions ports/stm32f4/boards/stm32f411ve_discovery/board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ed68730

Please sign in to comment.