Skip to content

Commit 759f896

Browse files
authored
Merge branch 'master' into renovate/lib-tinyusb-digest
2 parents 2bb3721 + 9855791 commit 759f896

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
OTAFIX 2.1–2.3 are Meshtastic's fork; everything from 0.6.2 down predates
44
it and is upstream Adafruit history, kept for provenance.
55

6+
## OTAFIX 2.3-BP1.6
7+
8+
- `CURRENT.UF2` is now sized from the application start instead of counting every UF2 block written since the start of flash. Previously, a dump taken after a serial or BLE OTA update was silently truncated by the SoftDevice span, and restoring such a dump only worked while the missing tail happened to still be in flash — re-take any backups made with BP1.5 or older after a DFU update. Verified on RAK4631 both directions (dump size correct after serial DFU; restore boots, next dump byte-identical).
9+
- `lib/tinyusb` digest bump (0.21.0-241-g7800876). Exercised on hardware via UF2 mass-storage flashing, USB CDC, and serial DFU on RAK4631.
10+
611
## OTAFIX 2.3
712

813
- New boards: Heltec T096, Heltec T1, RAK 3401 (merged from oltaco's upstream, which calls this same board-support work "OTAFIX 2.3" too).

src/usb/msc_uf2.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,15 @@ void tud_msc_write10_complete_cb(uint8_t lun)
223223
// update App
224224
update_status.status_code = DFU_UPDATE_APP_COMPLETE;
225225

226-
// Record the real written size so bootloader_settings.bank_0_size
226+
// Record the real app span so bootloader_settings.bank_0_size
227227
// reflects the actual app, not 0 -- ghostfat.c's CURRENT.UF2 uses
228-
// this to size its dump to the real app instead of the max region.
229-
// 256 mirrors ghostfat.c's UF2_FIRMWARE_BYTES_PER_SECTOR (the UF2
230-
// format's fixed payload-per-block size, not board-specific).
231-
update_status.app_size = _wr_state.numWritten * 256;
228+
// this to size its dump. Measured from DFU_BANK_0_REGION_START like
229+
// serial/OTA DFU do, so a CURRENT.UF2 restore (which also carries
230+
// the SoftDevice blocks) does not overcount.
231+
if ( _wr_state.appEnd > DFU_BANK_0_REGION_START )
232+
{
233+
update_status.app_size = _wr_state.appEnd - DFU_BANK_0_REGION_START;
234+
}
232235

233236
PRINTF("Application update complete\r\n");
234237
}

src/usb/uf2/ghostfat.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,14 @@ static uint32_t current_flash_size(void)
199199
bootloader_settings_t const * boot_setting;
200200
bootloader_util_settings_get(&boot_setting);
201201

202+
// bank_0_size counts from DFU_BANK_0_REGION_START (the CRC check and
203+
// serial/OTA DFU both define it that way); the dump starts at
204+
// USER_FLASH_START, so add the SoftDevice span in between.
202205
flash_sz = boot_setting->bank_0_size;
206+
if ( flash_sz && (flash_sz != 0xFFFFFFFFUL) )
207+
{
208+
flash_sz += DFU_BANK_0_REGION_START - USER_FLASH_START;
209+
}
203210

204211
// Round up to a whole UF2 payload chunk, else the last real chunk of
205212
// the app would get truncated out of CURRENT.UF2.
@@ -484,6 +491,7 @@ int write_block (uint32_t block_no, uint8_t *data, WriteState *state)
484491
{
485492
PRINTF("Write addr = 0x%08lX, block = %ld (%ld of %ld)\r\n", bl->targetAddr, bl->blockNo, state->numWritten, bl->numBlocks);
486493
flash_nrf5x_write(bl->targetAddr, bl->data, bl->payloadSize, true);
494+
if ( bl->targetAddr + bl->payloadSize > state->appEnd ) state->appEnd = bl->targetAddr + bl->payloadSize;
487495
}else if ( bl->targetAddr < USER_FLASH_START )
488496
{
489497
// do nothing if writing to MBR, occurs when SD hex is included

src/usb/uf2/uf2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ SOFTWARE.
5252
typedef struct {
5353
uint32_t numBlocks;
5454
uint32_t numWritten;
55+
uint32_t appEnd; // highest end address written in app space (0 if none)
5556

5657
bool aborted; // aborting update and reset
5758
bool update_bootloader; // if updating bootloader (else app)

0 commit comments

Comments
 (0)