Skip to content

Commit 5e04123

Browse files
microbit-carlosmathias-arm
authored andcommitted
nrf52: Add new flash algo for nRF52833 that improves flashing time.
More info about the flash algo improvements in: - pyocd/FlashAlgo#68 As the improvement was achieved from a feature not present in all members of the nRF52 family, the original nRF52832 flash algo stays and this version for nRF52833 has been added along side it. Could potentially be used for nRF52840 targets as well.
1 parent 71c0378 commit 5e04123

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

source/family/nordic/nrf52/flash_blob.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "flash_blob.h"
2323

24+
// This flash algo should work with all members of the nRF52 family
2425
static const uint32_t nRF52832AA_FLM[] = {
2526
0xE00ABE00, 0x062D780D, 0x24084068, 0xD3000040, 0x1E644058, 0x1C49D1FA, 0x2A001E52, 0x4770D1F2,
2627
0x47702000, 0x47702000, 0x4c2bb570, 0x60202002, 0x20014929, 0x60083108, 0x68284d28, 0xd00207c0,
@@ -32,6 +33,21 @@ static const uint32_t nRF52832AA_FLM[] = {
3233
0x40010404, 0x40010504, 0x6e524635, 0x00000000,
3334
};
3435

36+
// Compiled from a fork of the pyocd/FlashAlgo repository (details in README):
37+
// https://github.com/microbit-foundation/FlashAlgo/commit/03f07e6d635903e7272860cea72c84c078088a1a
38+
// Compared to the nRF52832 version, this is about 25% faster using a new NVMC
39+
// register (READYNEXT) only present in nRF52820, nRF52833, and nRF52840.
40+
static const uint32_t nRF52833_flash_algo[] = {
41+
0xE00ABE00,
42+
0xf8d24a09, 0xf0133404, 0xd00b03ff, 0x2504f8d2, 0x4a06b142, 0x07d84906, 0x6011bf48, 0xf102085b,
43+
0xd1f80204, 0xbf004770, 0x40010000, 0x40010600, 0x6e524635, 0x47702000, 0x47702000, 0x4c09b510,
44+
0xf8c42302, 0x23013504, 0x350cf8c4, 0x3400f8d4, 0xd40207db, 0xffd4f7ff, 0x2000e7f8, 0x0504f8c4,
45+
0xbf00bd10, 0x4001e000, 0x4c0bb510, 0xf1b02302, 0xf8c42f10, 0xbf263504, 0xf8c42301, 0xf8c43514,
46+
0xf7ff0508, 0xf8d4ffbd, 0x07db3400, 0x2000d5f9, 0x0504f8c4, 0xbf00bd10, 0x4001e000, 0x4e0fb5f8,
47+
0x088d2301, 0x3504f8c6, 0x1a874614, 0x682219e3, 0x3404601a, 0x3408f8d6, 0xd40207da, 0xffa0f7ff,
48+
0x3d01e7f8, 0xf8d6d1f2, 0x07db3400, 0xf7ffd402, 0xe7f8ff97, 0xf8c62000, 0xbdf80504, 0x4001e000
49+
};
50+
3551
/**
3652
* List of start and size for each size of flash sector
3753
* The size will apply to all sectors between the listed address and the next address
@@ -61,3 +77,22 @@ static const program_target_t flash_nrf52 = {
6177
.algo_blob = nRF52832AA_FLM,
6278
.program_buffer_size = 512 // should be USBD_MSC_BlockSize
6379
};
80+
81+
static const program_target_t flash_nrf52833 = {
82+
.init = 0x20000039,
83+
.uninit = 0x2000003d,
84+
.erase_chip = 0x20000041,
85+
.erase_sector = 0x2000006d,
86+
.program_page = 0x200000a1,
87+
.verify = 0x0,
88+
{
89+
.breakpoint = 0x20000001,
90+
.static_base = 0x200000e4,
91+
.stack_pointer = 0x20000300
92+
},
93+
.program_buffer = 0x20000000 + 0x00000A00,
94+
.algo_start = 0x20000000,
95+
sizeof(nRF52833_flash_algo),
96+
.algo_blob = nRF52833_flash_algo,
97+
.program_buffer_size = 512 // should be USBD_MSC_BlockSize
98+
};

source/family/nordic/nrf52/target.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ target_cfg_t target_device_nrf52833 = {
6464
.flash_regions[0].start = 0,
6565
.flash_regions[0].end = KB(512),
6666
.flash_regions[0].flags = kRegionIsDefault,
67-
.flash_regions[0].flash_algo = (program_target_t *) &flash_nrf52,
67+
.flash_regions[0].flash_algo = (program_target_t *) &flash_nrf52833,
6868
.ram_regions[0].start = 0x20000000,
6969
.ram_regions[0].end = 0x20020000,
7070
.erase_reset = 1,

0 commit comments

Comments
 (0)