Skip to content

Commit 0791d76

Browse files
committed
Draft: support for rp2350
1 parent 456a6f8 commit 0791d76

File tree

4 files changed

+226
-0
lines changed

4 files changed

+226
-0
lines changed

config/examples/rp2350.config

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ARCH?=ARM
2+
TZEN?=0
3+
TARGET?=rp2350
4+
SIGN?=ECC256
5+
HASH?=SHA256
6+
DEBUG?=0
7+
VTOR?=1
8+
CORTEX_M33?=1
9+
NO_ASM?=0
10+
NO_MPU=1
11+
EXT_FLASH?=0
12+
SPI_FLASH?=0
13+
ALLOW_DOWNGRADE?=0
14+
SPMATH?=1
15+
RAM_CODE?=1
16+
WOLFBOOT_PARTITION_SIZE?=0x40000
17+
WOLFBOOT_SECTOR_SIZE?=0x2000
18+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x10040000
19+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=10080000
20+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x100C0000
21+
22+
PICO_SDK_PATH=/home/dan/src/pico-sdk
23+
24+
# Use a larger image header size to enforce alignment requirements for the interrupt vector table
25+
IMAGE_HEADER_SIZE?=1024

hal/rp2350-ns.ld

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
MEMORY
2+
{
3+
FLASH (rx) : ORIGIN = @WOLFBOOT_ORIGIN@, LENGTH = @BOOTLOADER_PARTITION_SIZE@
4+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00082000
5+
}
6+
7+
SECTIONS
8+
{
9+
.text :
10+
{
11+
_start_text = .;
12+
KEEP(*(.isr_vector))
13+
*(.text*)
14+
*(.rodata*)
15+
. = ALIGN(8);
16+
_end_text = .;
17+
} > FLASH
18+
19+
.edidx :
20+
{
21+
. = ALIGN(4);
22+
*(.ARM.exidx*)
23+
} > FLASH
24+
25+
_stored_data = .;
26+
.data : AT (_stored_data)
27+
{
28+
_start_data = .;
29+
KEEP(*(.data*))
30+
. = ALIGN(8);
31+
KEEP(*(.ramcode))
32+
. = ALIGN(8);
33+
_end_data = .;
34+
} > RAM
35+
36+
.bss (NOLOAD) :
37+
{
38+
_start_bss = .;
39+
__bss_start__ = .;
40+
*(.bss*)
41+
*(COMMON)
42+
. = ALIGN(8);
43+
_end_bss = .;
44+
__bss_end__ = .;
45+
_end = .;
46+
} > RAM
47+
. = ALIGN(8);
48+
}
49+
50+
END_STACK = ORIGIN(RAM) + LENGTH(RAM);

hal/rp2350.c

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/* rp2350.c
2+
*
3+
* Stubs for custom HAL implementation. Defines the
4+
* functions used by wolfboot for a specific target.
5+
*
6+
* Copyright (C) 2021 wolfSSL Inc.
7+
*
8+
* This file is part of wolfBoot.
9+
*
10+
* wolfBoot is free software; you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License as published by
12+
* the Free Software Foundation; either version 3 of the License, or
13+
* (at your option) any later version.
14+
*
15+
* wolfBoot is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU General Public License
21+
* along with this program; if not, write to the Free Software
22+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
23+
*/
24+
25+
#include <stdint.h>
26+
#include <target.h>
27+
#include "image.h"
28+
29+
30+
#define SIO_BASE (0xD0000000U)
31+
#define SIO_CPUID (*(volatile uint32_t *)(SIO_BASE + 0x00))
32+
33+
const uint32_t VTOR_ADDR = 0xE000ED08;
34+
const uint32_t BOOTROM_VTABLE_OFFSET = 0x00000000;
35+
36+
void __attribute__((naked)) jmp_to_rom_vector(void)
37+
{
38+
__asm volatile(
39+
"ldr r0, =BOOTROM_VTABLE_OFFSET\n"
40+
"ldr r1, =VTOR_ADDR\n"
41+
"str r0, [r1]\n"
42+
"ldmia r0!, {r1, r2}\n"
43+
"msr msp, r1\n"
44+
"bx r2\n"
45+
);
46+
}
47+
48+
#ifdef __WOLFBOOT
49+
void hal_init(void)
50+
{
51+
/* Keep CPU1 in ROM */
52+
if (SIO_CPUID != 0) {
53+
jmp_to_rom_vector();
54+
}
55+
}
56+
57+
void hal_prepare_boot(void)
58+
{
59+
}
60+
61+
#endif
62+
63+
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
64+
{
65+
return 0; /* on success. */
66+
}
67+
68+
void RAMFUNCTION hal_flash_unlock(void)
69+
{
70+
}
71+
72+
void RAMFUNCTION hal_flash_lock(void)
73+
{
74+
}
75+
76+
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
77+
{
78+
return 0; /* on success. */
79+
}
80+

hal/rp2350.ld

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
MEMORY
2+
{
3+
FLASH (rx) : ORIGIN = @WOLFBOOT_ORIGIN@, LENGTH = @BOOTLOADER_PARTITION_SIZE@ - 0x20000
4+
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00012000
5+
RAM_HEAP (rw): ORIGIN = 0x20012000, LENGTH = 0xc000 /* 49152 B Heap for wolfcrypt/PKCS11 */
6+
RAM_KV (rw): ORIGIN = 0x2001e000, LENGTH = 0x2000
7+
FLASH_KEYVAULT(rw): ORIGIN = @WOLFBOOT_ORIGIN@ + 0x20000, LENGTH = 0x18000
8+
FLASH_NSC(rx): ORIGIN = @WOLFBOOT_ORIGIN@ + 0x38000, LENGTH = 0x8000
9+
}
10+
11+
SECTIONS
12+
{
13+
.text :
14+
{
15+
_start_text = .;
16+
KEEP(*(.isr_vector))
17+
*(.text*)
18+
*(.rodata*)
19+
. = ALIGN(8);
20+
_end_text = .;
21+
} > FLASH
22+
23+
.edidx :
24+
{
25+
. = ALIGN(4);
26+
*(.ARM.exidx*)
27+
} > FLASH
28+
29+
.gnu.sgstubs :
30+
{
31+
. += 0x400;
32+
. = ALIGN(4);
33+
*(.gnu.sgstubs*) /* Secure Gateway stubs */
34+
. = ALIGN(4);
35+
} >FLASH_NSC
36+
37+
_stored_data = .;
38+
.data : AT (_stored_data)
39+
{
40+
_start_data = .;
41+
KEEP(*(.data*))
42+
. = ALIGN(8);
43+
KEEP(*(.ramcode))
44+
. = ALIGN(8);
45+
_end_data = .;
46+
} > RAM
47+
48+
.bss (NOLOAD) :
49+
{
50+
_start_bss = .;
51+
__bss_start__ = .;
52+
*(.bss*)
53+
*(COMMON)
54+
. = ALIGN(8);
55+
_end_bss = .;
56+
__bss_end__ = .;
57+
_end = .;
58+
} > RAM
59+
. = ALIGN(8);
60+
}
61+
62+
END_STACK = ORIGIN(RAM) + LENGTH(RAM);
63+
64+
_keyvault_origin = ORIGIN(RAM_KV);
65+
_keyvault_size = LENGTH(RAM_KV);
66+
67+
_flash_keyvault = ORIGIN(FLASH_KEYVAULT);
68+
_flash_keyvault_size = LENGTH(FLASH_KEYVAULT);
69+
70+
_start_heap = ORIGIN(RAM_HEAP);
71+
_heap_size = LENGTH(RAM_HEAP);

0 commit comments

Comments
 (0)