commit
58c19dd389
|
@ -93,9 +93,14 @@ int flash_area_read(const struct flash_area *area, uint32_t off, void *dst,
|
|||
int flash_area_write(const struct flash_area *area, uint32_t off, const void *src,
|
||||
uint32_t len)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
SYS_LOG_DBG("%s: area=%d, off=%x, len=%x", __func__,
|
||||
area->fa_id, off, len);
|
||||
return flash_write(boot_flash_device, area->fa_off + off, src, len);
|
||||
flash_write_protection_set(boot_flash_device, false);
|
||||
rc = flash_write(boot_flash_device, area->fa_off + off, src, len);
|
||||
flash_write_protection_set(boot_flash_device, true);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int flash_area_erase(const struct flash_area *area, uint32_t off, uint32_t len)
|
||||
|
@ -128,6 +133,8 @@ int flash_area_id_from_image_slot(int slot)
|
|||
int flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret)
|
||||
{
|
||||
uint32_t off;
|
||||
uint32_t len;
|
||||
uint32_t max_cnt = *cnt;
|
||||
|
||||
SYS_LOG_DBG("%s: lookup area %d", __func__, idx);
|
||||
/*
|
||||
|
@ -140,13 +147,34 @@ int flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret)
|
|||
if (*cnt < 1)
|
||||
return -1;
|
||||
|
||||
off = (idx - FLASH_AREA_IMAGE_0 + 1) * FLASH_AREA_IMAGE_0_OFFSET;
|
||||
switch (idx) {
|
||||
case FLASH_AREA_IMAGE_0:
|
||||
off = FLASH_AREA_IMAGE_0_OFFSET;
|
||||
len = FLASH_AREA_IMAGE_0_SIZE;
|
||||
break;
|
||||
case FLASH_AREA_IMAGE_1:
|
||||
off = FLASH_AREA_IMAGE_1_OFFSET;
|
||||
len = FLASH_AREA_IMAGE_1_SIZE;
|
||||
break;
|
||||
case FLASH_AREA_IMAGE_SCRATCH:
|
||||
off = FLASH_AREA_IMAGE_SCRATCH_OFFSET;
|
||||
len = FLASH_AREA_IMAGE_SCRATCH_SIZE;
|
||||
break;
|
||||
default:
|
||||
SYS_LOG_ERR("%s: unknown flash area %d", __func__, idx);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret->fa_id = idx;
|
||||
ret->fa_device_id = 0;
|
||||
ret->pad16 = 0;
|
||||
ret->fa_off = off;
|
||||
ret->fa_size = FLASH_AREA_IMAGE_0_SIZE;
|
||||
*cnt = 0;
|
||||
while (len > 0 && *cnt < max_cnt) {
|
||||
ret[*cnt].fa_id = idx;
|
||||
ret[*cnt].fa_device_id = 0;
|
||||
ret[*cnt].pad16 = 0;
|
||||
ret[*cnt].fa_off = off + (FLASH_AREA_IMAGE_SCRATCH_SIZE * (*cnt));
|
||||
ret[*cnt].fa_size = FLASH_AREA_IMAGE_SCRATCH_SIZE;
|
||||
*cnt = *cnt + 1;
|
||||
len -= FLASH_AREA_IMAGE_SCRATCH_SIZE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -70,11 +70,6 @@ void main(void)
|
|||
irq_lock();
|
||||
_MspSet(vt->msp);
|
||||
|
||||
SYS_LOG_INF("Setting vector table to %p", vt);
|
||||
|
||||
/* Not all targets set the VTOR, so just set it. */
|
||||
_scs_relocate_vector_table((void *) vt);
|
||||
|
||||
SYS_LOG_INF("Jumping to the first image slot");
|
||||
((void (*)(void))vt->reset)();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
#define FLASH_DRIVER_NAME "NRF5_FLASH"
|
||||
#define FLASH_ALIGN 1
|
||||
#define FLASH_ALIGN 4
|
||||
#define FLASH_AREA_IMAGE_0_OFFSET 0x08000
|
||||
#define FLASH_AREA_IMAGE_0_SIZE 0x3A000
|
||||
#define FLASH_AREA_IMAGE_1_OFFSET 0x42000
|
||||
|
|
Loading…
Reference in New Issue