Skip to content

Commit cfa058c

Browse files
committed
app_hifive1: improved debug (app RAM moved ahead to help debugging RAM
code + optional naked version of write_page()
1 parent b5cf09d commit cfa058c

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

test-app/RISCV.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ENTRY( _reset )
55
MEMORY
66
{
77
FLASH(rxai!w) : ORIGIN = 0x20020100, LENGTH = 256K - 0x100
8-
RAM(wxa!ri) : ORIGIN = 0x80000000, LENGTH = 16K
8+
RAM(wxa!ri) : ORIGIN = 0x80001000, LENGTH = 12K
99
}
1010

1111
SECTIONS

test-app/hifive1_write_page.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
#include <stdint.h>
22
#include "hal.h"
3+
#include "target.h"
4+
#include "wolfboot/wolfboot.h"
5+
36
#define PAGESIZE (0x1000) /* Flash sector: 4K */
47
extern uint8_t flash_page[];
58

9+
10+
#ifdef APP_DEBUG_WRITE_PAGE
11+
__attribute__((used,naked,section(".ramcode.user")))
12+
void write_page(uint32_t dst)
13+
{
14+
asm volatile ("addi sp, sp, -4");
15+
asm volatile ("sw ra, 0(sp)");
16+
if (dst == 0x60000)
17+
wolfBoot_erase_partition(0x01);
18+
hal_flash_write(dst, flash_page, PAGESIZE);
19+
asm volatile ("lw a4, 0(sp)");
20+
asm volatile ("addi sp, sp, 4");
21+
asm volatile ("jr a4");
22+
}
23+
#endif
24+
625
__attribute__((used,section(".ramcode.user")))
726
void write_page(uint32_t dst)
827
{
9-
hal_flash_erase(dst, PAGESIZE);
28+
if (dst == 0x60000)
29+
wolfBoot_erase_partition(0x01);
1030
hal_flash_write(dst, flash_page, PAGESIZE);
1131
}

0 commit comments

Comments
 (0)