diff --git a/test-app/RISCV.ld b/test-app/RISCV.ld index ed9167a7..84f024c4 100644 --- a/test-app/RISCV.ld +++ b/test-app/RISCV.ld @@ -5,7 +5,7 @@ ENTRY( _reset ) MEMORY { FLASH(rxai!w) : ORIGIN = 0x20020100, LENGTH = 256K - 0x100 - RAM(wxa!ri) : ORIGIN = 0x80000000, LENGTH = 16K + RAM(wxa!ri) : ORIGIN = 0x80001000, LENGTH = 12K } SECTIONS diff --git a/test-app/hifive1_write_page.c b/test-app/hifive1_write_page.c index 236e1187..22f542ea 100644 --- a/test-app/hifive1_write_page.c +++ b/test-app/hifive1_write_page.c @@ -1,11 +1,31 @@ #include #include "hal.h" +#include "target.h" +#include "wolfboot/wolfboot.h" + #define PAGESIZE (0x1000) /* Flash sector: 4K */ extern uint8_t flash_page[]; + +#ifdef APP_DEBUG_WRITE_PAGE +__attribute__((used,naked,section(".ramcode.user"))) +void write_page(uint32_t dst) +{ + asm volatile ("addi sp, sp, -4"); + asm volatile ("sw ra, 0(sp)"); + if (dst == 0x60000) + wolfBoot_erase_partition(0x01); + hal_flash_write(dst, flash_page, PAGESIZE); + asm volatile ("lw a4, 0(sp)"); + asm volatile ("addi sp, sp, 4"); + asm volatile ("jr a4"); +} +#endif + __attribute__((used,section(".ramcode.user"))) void write_page(uint32_t dst) { - hal_flash_erase(dst, PAGESIZE); + if (dst == 0x60000) + wolfBoot_erase_partition(0x01); hal_flash_write(dst, flash_page, PAGESIZE); }