Added IDE/pico-sdk dir to build wolfboot+blink app

pull/524/head
Daniele Lacamera 2024-12-05 13:23:17 +01:00
parent 628fbe5524
commit 359c59fa47
17 changed files with 149 additions and 80 deletions

4
.gitignore vendored
View File

@ -231,6 +231,10 @@ IDE/Renesas/e2studio/RX72N/app_RenesasRX01/src/smc_gen
IDE/Renesas/e2studio/RX72N/wolfBoot/HardwareDebug
IDE/Renesas/e2studio/RX72N/wolfBoot/src/smc_gen
# IDE pico-sdk build directories
IDE/pico-sdk/rp23550/wolfboot/build
IDE/pico-sdk/rp23550/test-app/build
# Renesas Libraries
lib/r_bsp
lib/r_config

View File

@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.13)
set(WOLFBOOT_PATH ../../../../)
set(CMAKE_CXX_COMPILER arm-none-eabi-gcc)
include(${PICO_SDK_PATH}/pico_sdk_init.cmake)
set(PICOTOOL_FETCH_FROM_GIT_PATH ../wolfboot/build/picotool)
set(BOOT_STAGE2_FILE ${CMAKE_CURRENT_LIST_DIR}/boot2_empty.S)
project(blink)
# initialize the Raspberry Pi Pico SDK
pico_sdk_init()
add_executable(blink
blink.c
)
target_link_libraries(blink pico_stdlib)
# create map/bin/hex/uf2 file etc.
pico_add_extra_outputs(blink)

View File

@ -0,0 +1,53 @@
/**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "pico/stdlib.h"
// Pico W devices use a GPIO on the WIFI chip for the LED,
// so when building for Pico W, CYW43_WL_GPIO_LED_PIN will be defined
#ifdef CYW43_WL_GPIO_LED_PIN
#include "pico/cyw43_arch.h"
#endif
#ifndef LED_DELAY_MS
#define LED_DELAY_MS 250
#endif
// Perform initialisation
int pico_led_init(void) {
#if defined(PICO_DEFAULT_LED_PIN)
// A device like Pico that uses a GPIO for the LED will define PICO_DEFAULT_LED_PIN
// so we can use normal GPIO functionality to turn the led on and off
gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
return PICO_OK;
#elif defined(CYW43_WL_GPIO_LED_PIN)
// For Pico W devices we need to initialise the driver etc
return cyw43_arch_init();
#endif
}
// Turn the led on or off
void pico_set_led(bool led_on) {
#if defined(PICO_DEFAULT_LED_PIN)
// Just set the GPIO on or off
gpio_put(PICO_DEFAULT_LED_PIN, led_on);
#elif defined(CYW43_WL_GPIO_LED_PIN)
// Ask the wifi "driver" to set the GPIO on or off
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, led_on);
#endif
}
int main() {
int rc = pico_led_init();
hard_assert(rc == PICO_OK);
while (true) {
pico_set_led(true);
sleep_ms(LED_DELAY_MS);
pico_set_led(false);
sleep_ms(LED_DELAY_MS);
}
}

View File

@ -0,0 +1,14 @@
#!/bin/bash
mkdir -p build
cd build
cmake .. -DPICO_SDK_PATH=$PICO_SDK_PATH -DPICO_PLATFORM=rp2350
cat pico_flash_region.ld | sed -e "s/0x10000000/0x10040400/g" >pico_flash_region_wolfboot.ld
cp pico_flash_region_wolfboot.ld pico_flash_region.ld
make clean && make
../../../../../tools/keytools/sign --sha256 --ecc256 blink.bin \
../../../../../wolfboot_signing_private_key.der 1
cd ..
JLinkExe -Device RP2350_M33_0 -If swd -Speed 4000 -CommanderScript flash_app.jlink

View File

@ -0,0 +1,6 @@
connect
r
loadfile build/blink_v1_signed.bin 0x10040000
r
g
exit

View File

@ -4,7 +4,7 @@ set(CMAKE_CXX_COMPILER arm-none-eabi-gcc)
include(${PICO_SDK_PATH}/pico_sdk_init.cmake)
set(PICOTOOL_FETCH_FROM_GIT_PATH 1)
set(PICOTOOL_FETCH_FROM_GIT_PATH build/picotool)
project(wolfboot)

View File

@ -0,0 +1,10 @@
#!/bin/bash
#cd ../../../.. && make keytools && make src/keystore.c && cd -
cd ../../../.. && make include/target.h && cd -
mkdir -p build
cd build
cmake .. -DPICO_SDK_PATH=$PICO_SDK_PATH -DPICO_PLATFORM=rp2350
make clean && make
cd ..
JLinkExe -Device RP2350_M33_0 -If swd -Speed 4000 -CommanderScript erase.jlink
JLinkExe -Device RP2350_M33_0 -If swd -Speed 4000 -CommanderScript flash_wolfboot.jlink

View File

@ -0,0 +1,2 @@
#!/bin/bash
JLinkGDBServer -Device RP2350_M33_0 -If swd -Speed 4000 -port 3333

View File

@ -0,0 +1,6 @@
connect
r
erase
r
h
exit

View File

@ -0,0 +1,6 @@
connect
r
loadfile build/wolfboot.bin 0x10000000
r
g
exit

View File

@ -148,6 +148,10 @@ ifeq ($(TARGET),sama5d3)
MAIN_TARGET:=wolfboot.bin test-app/image_v1_signed.bin
endif
ifeq ($(TARGET),rp2350)
MAIN_TARGET:=include/target.h keytools wolfboot_signing_private_key.der pico-sdk-info
endif
ifeq ($(FLASH_OTP_KEYSTORE),1)
MAIN_TARGET+=tools/keytools/otp/otp-keystore-primer.bin
@ -451,6 +455,9 @@ secondary: $(SECONDARY_PRIVATE_KEY)
src/x86/fsp_s.o: $(FSP_S_BIN)
$(OBJCOPY) -I binary -O elf64-x86-64 -B i386 --rename-section .data=.fsp_s $^ $@
pico-sdk-info: FORCE
@echo "To complete the build, check IDE/pico-sdk/rp2350"
FORCE:
.PHONY: FORCE clean keytool_check

View File

@ -233,6 +233,7 @@ ifeq ($(ARCH),ARM)
endif
SPI_TARGET=raspberrypi_pico
CFLAGS+=-DPICO_SDK_PATH=$(PICO_SDK_PATH)
CFLAGS+=-I$(PICO_SDK_PATH)/src/common/pico_stdlib_headers/include
endif
ifeq ($(TARGET),sama5d3)

View File

@ -13,11 +13,11 @@ SPI_FLASH?=0
ALLOW_DOWNGRADE?=0
SPMATH?=1
RAM_CODE?=1
WOLFBOOT_PARTITION_SIZE?=0x40000
WOLFBOOT_PARTITION_SIZE?=0xC0000
WOLFBOOT_SECTOR_SIZE?=0x2000
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x10040000
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=10080000
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x100C0000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x10040000
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x10100000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x101C0000
PICO_SDK_PATH=/home/dan/src/pico-sdk

View File

@ -23,6 +23,7 @@ This README describes configuration of supported targets.
* [NXP T1024 PPC](#nxp-qoriq-t1024-ppc)
* [NXP T2080 PPC](#nxp-qoriq-t2080-ppc)
* [Qemu x86-64 UEFI](#qemu-x86-64-uefi)
* [Raspberry Pi pico 2 (rp2350)](#raspberry-pi-pico-rp2350)
* [Renesas RA6M4](#renesas-ra6m4)
* [Renesas RX65N](#renesas-rx65n)
* [Renesas RX72N](#renesas-rx72n)
@ -2511,6 +2512,10 @@ make test-sim-internal-flash-with-update
Note: This also works on Mac OS, but `objcopy` does not exist. Install with `brew install binutils` and make using `OBJCOPY=/usr/local/Cellar//binutils/2.41/bin/objcopy make`.
## Raspberry Pi Pico rp2350
See instructions in [IDE/pico-sdk/rp2350/README.md](/IDE/pico-sdk/rp2350/README.md)
## Renesas RX65N
Tested on the:

View File

@ -1,50 +0,0 @@
MEMORY
{
FLASH (rx) : ORIGIN = @WOLFBOOT_ORIGIN@, LENGTH = @BOOTLOADER_PARTITION_SIZE@
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00082000
}
SECTIONS
{
.text :
{
_start_text = .;
KEEP(*(.isr_vector))
*(.text*)
*(.rodata*)
. = ALIGN(8);
_end_text = .;
} > FLASH
.edidx :
{
. = ALIGN(4);
*(.ARM.exidx*)
} > FLASH
_stored_data = .;
.data : AT (_stored_data)
{
_start_data = .;
KEEP(*(.data*))
. = ALIGN(8);
KEEP(*(.ramcode))
. = ALIGN(8);
_end_data = .;
} > RAM
.bss (NOLOAD) :
{
_start_bss = .;
__bss_start__ = .;
*(.bss*)
*(COMMON)
. = ALIGN(8);
_end_bss = .;
__bss_end__ = .;
_end = .;
} > RAM
. = ALIGN(8);
}
END_STACK = ORIGIN(RAM) + LENGTH(RAM);

View File

@ -25,33 +25,14 @@
#include <stdint.h>
#include <target.h>
#include "image.h"
#define SIO_BASE (0xD0000000U)
#define SIO_CPUID (*(volatile uint32_t *)(SIO_BASE + 0x00))
const uint32_t VTOR_ADDR = 0xE000ED08;
const uint32_t BOOTROM_VTABLE_OFFSET = 0x00000000;
void __attribute__((naked)) jmp_to_rom_vector(void)
{
__asm volatile(
"ldr r0, =BOOTROM_VTABLE_OFFSET\n"
"ldr r1, =VTOR_ADDR\n"
"str r0, [r1]\n"
"ldmia r0!, {r1, r2}\n"
"msr msp, r1\n"
"bx r2\n"
);
}
#include "printf.h"
#ifdef __WOLFBOOT
void hal_init(void)
{
/* Keep CPU1 in ROM */
if (SIO_CPUID != 0) {
jmp_to_rom_vector();
}
#ifdef PRINTF_ENABLED
stdio_init_all();
#endif
}
void hal_prepare_boot(void)

View File

@ -397,7 +397,7 @@ void isr_empty(void)
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) && defined(TZEN)
# define isr_securefault isr_fault
#else
# define isr_securefault 0
@ -446,7 +446,7 @@ void RAMFUNCTION do_boot(const uint32_t *app_offset)
/* Update IV */
VTOR = ((uint32_t)app_offset);
asm volatile("msr msplim, %0" ::"r"(0));
# if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
# if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) && defined(TZEN)
asm volatile("msr msp_ns, %0" ::"r"(app_end_stack));
/* Jump to non secure app_entry */
asm volatile("mov r7, %0" ::"r"(app_entry));