forked from wolfSSL/wolfBoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhifive1_write_page.c
More file actions
31 lines (27 loc) · 772 Bytes
/
hifive1_write_page.c
File metadata and controls
31 lines (27 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdint.h>
#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)
{
if (dst == 0x60000)
wolfBoot_erase_partition(0x01);
hal_flash_write(dst, flash_page, PAGESIZE);
}