mirror of
https://github.com/oltaco/Adafruit_nRF52_Bootloader_OTAFIX.git
synced 2026-10-23 06:33:03 +00:00
more with uf2
This commit is contained in:
1 parent
795fd2ee17
commit
fe1a7ea4f2
4 files changed
+18
-20
No files matched your search
@@ -118,7 +118,6 @@ bool is_ota(void);
|
||||
#define PRINTF printf
|
||||
#define PRINT_LOCATION() printf("%s: %d:\n", __PRETTY_FUNCTION__, __LINE__)
|
||||
#define PRINT_MESS(x) printf("%s: %d: %s \n" , __FUNCTION__, __LINE__, (char*)(x))
|
||||
#define PRTNT_HEAP() if (CFG_DEBUG == 3) printf("\n%s: %d: Heap free: %d\n", __FUNCTION__, __LINE__, util_heap_get_free_size())
|
||||
#define PRINT_STR(x) printf("%s: %d: " #x " = %s\n" , __FUNCTION__, __LINE__, (char*)(x) )
|
||||
#define PRINT_INT(x) printf("%s: %d: " #x " = %ld\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
|
||||
#define PRINT_HEX(x) printf("%s: %d: " #x " = 0x%X\n" , __FUNCTION__, __LINE__, (uint32_t) (x) )
|
||||
@@ -143,7 +142,6 @@ bool is_ota(void);
|
||||
#define PRINTF(...)
|
||||
#define PRINT_LOCATION()
|
||||
#define PRINT_MESS(x)
|
||||
#define PRTNT_HEAP()
|
||||
#define PRINT_STR(x)
|
||||
#define PRINT_INT(x)
|
||||
#define PRINT_HEX(x)
|
||||
|
||||
+9
-12
@@ -5,7 +5,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "boards.h"
|
||||
#include "tusb.h"
|
||||
|
||||
#include "bootloader_settings.h"
|
||||
#include "bootloader.h"
|
||||
@@ -99,8 +98,8 @@ static struct TextFile const info[] = {
|
||||
STATIC_ASSERT(ARRAY_SIZE(indexFile) < 512);
|
||||
|
||||
|
||||
#define NUM_FILES (ARRAY_SIZE(info))
|
||||
#define NUM_DIRENTRIES (NUM_FILES + 1) // Code adds volume label as first root directory entry
|
||||
#define NUM_FILES (ARRAY_SIZE(info))
|
||||
#define NUM_DIRENTRIES (NUM_FILES + 1) // Code adds volume label as first root directory entry
|
||||
|
||||
#define UF2_SIZE (uf2current_flash_sz * 2)
|
||||
#define UF2_SECTORS (UF2_SIZE / 512)
|
||||
@@ -202,7 +201,7 @@ void padded_memcpy (char *dst, char const *src, int len)
|
||||
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Read
|
||||
/* Read CURRENT.UF2
|
||||
*------------------------------------------------------------------*/
|
||||
void read_block(uint32_t block_no, uint8_t *data) {
|
||||
memset(data, 0, 512);
|
||||
@@ -311,19 +310,17 @@ int write_block(uint32_t block_no, uint8_t *data, WriteState *state) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// PRINTF("Addr = 0x%08X, Family = 0x%08X\n", bl->targetAddr, bl->familyID);
|
||||
|
||||
// only accept block with same family id
|
||||
if ( !((bl->flags & UF2_FLAG_FAMILYID) && (bl->familyID == CFG_UF2_FAMILY_ID)) ) {
|
||||
if ( !((bl->familyID == CFG_UF2_FAMILY_ID)) ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((bl->flags & UF2_FLAG_NOFLASH) || bl->payloadSize > 256 || (bl->targetAddr & 0xff) ||
|
||||
(bl->targetAddr < USER_FLASH_START) || (bl->targetAddr + bl->payloadSize > USER_FLASH_END) ) {
|
||||
if ( (bl->targetAddr < USER_FLASH_START) || (bl->targetAddr + bl->payloadSize > USER_FLASH_END) ) {
|
||||
|
||||
//NRF_LOG_WARNING("Skip block at %x", bl->targetAddr);
|
||||
// this happens when we're trying to re-flash CURRENT.UF2 file previously
|
||||
// copied from a device; we still want to count these blocks to reset properly
|
||||
} else {
|
||||
//NRF_LOG_DEBUG("Write block at %x", bl->targetAddr);
|
||||
//PRINTF("Write block at %x", bl->targetAddr);
|
||||
|
||||
static bool first_write = true;
|
||||
if ( first_write ) {
|
||||
@@ -354,7 +351,7 @@ int write_block(uint32_t block_no, uint8_t *data, WriteState *state) {
|
||||
flash_nrf5x_flush(true);
|
||||
}
|
||||
}
|
||||
//NRF_LOG_DEBUG("wr %d=%d (of %d)", state->numWritten, bl->blockNo, bl->numBlocks);
|
||||
//PRINTF("wr %d=%d (of %d)", state->numWritten, bl->blockNo, bl->numBlocks);
|
||||
}
|
||||
|
||||
return 512;
|
||||
|
||||
+3
-1
@@ -78,7 +78,9 @@ typedef struct {
|
||||
|
||||
static inline bool is_uf2_block(UF2_Block const *bl) {
|
||||
return (bl->magicStart0 == UF2_MAGIC_START0) && (bl->magicStart1 == UF2_MAGIC_START1) &&
|
||||
(bl->magicEnd == UF2_MAGIC_END);
|
||||
(bl->magicEnd == UF2_MAGIC_END) &&
|
||||
(bl->flags & UF2_FLAG_FAMILYID) && !(bl->flags & UF2_FLAG_NOFLASH) &&
|
||||
(bl->payloadSize == 256) && !(bl->targetAddr & 0xff);
|
||||
}
|
||||
|
||||
static inline bool in_uf2_bootloader_space(const void *addr) {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "boards.h"
|
||||
|
||||
#define UF2_NUM_BLOCKS 8000 // at least 4,1 MB for FAT16
|
||||
#define FLASH_SIZE (USER_FLASH_END-USER_FLASH_START) // Max flash size
|
||||
#define UF2_NUM_BLOCKS 8000 // at least 4,1 MB for FAT16
|
||||
#define FLASH_SIZE (USER_FLASH_END-USER_FLASH_START) // Max flash size
|
||||
|
||||
// Only allow to write application TODO dynamic depending on SD size
|
||||
#define USER_FLASH_START (SD_FLASH_SIZE + MBR_SIZE)
|
||||
#define USER_FLASH_END 0xAD000 // Fat Fs start here
|
||||
#define USER_FLASH_START (SD_FLASH_SIZE + MBR_SIZE)
|
||||
#define USER_FLASH_END 0xAD000 // Fat Fs start here
|
||||
|
||||
#define CFG_UF2_FAMILY_ID 0xADA52840
|
||||
#define CFG_UF2_FAMILY_ID 0xADA52840
|
||||
#define CFG_UF2_BOOTLOADER_ID ((USB_DESC_VID << 16) | USB_DESC_UF2_PID)
|
||||
Reference in new issue
Block a user