Merge pull request #544 from miyazakh/fix_raspi3

Revert simple start-up for Raspi3b
pull/545/head
David Garske 2025-03-20 16:16:56 -07:00 committed by GitHub
commit 2d4d897acb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 90 additions and 6 deletions

View File

@ -4,12 +4,13 @@ SIGN?=RSA4096
HASH?=SHA3 HASH?=SHA3
DEBUG?=1 DEBUG?=1
VTOR?=1 VTOR?=1
NO_XIP?=1
SPMATH?=1 SPMATH?=1
IMAGE_HEADER_SIZE?=1024 IMAGE_HEADER_SIZE?=1024
PKA?=1 PKA?=1
WOLFTPM?=0 WOLFTPM?=0
DEBUG_UART?=0 DEBUG_UART?=0
NO_XIP?=1
NO_QNX?=1
WOLFBOOT_SECTOR_SIZE=0x400 WOLFBOOT_SECTOR_SIZE=0x400
WOLFBOOT_NO_PARTITIONS=1 WOLFBOOT_NO_PARTITIONS=1
WOLFBOOT_LOAD_ADDRESS?=0x3080000 WOLFBOOT_LOAD_ADDRESS?=0x3080000

View File

@ -102,6 +102,7 @@ static inline void delay(int32_t count)
asm volatile("nop"); asm volatile("nop");
} }
} }
#if defined(DEBUG_UART)
/** /**
* write message to mailbox * write message to mailbox
*/ */
@ -213,7 +214,7 @@ void uart_init()
/* enable UART0 transfer & receive*/ /* enable UART0 transfer & receive*/
*UART0_CR = (1 << 0) | (1 << 8) | (1 << 9); *UART0_CR = (1 << 0) | (1 << 8) | (1 << 9);
} }
#endif
void* hal_get_primary_address(void) void* hal_get_primary_address(void)
{ {
return (void*)&kernel_addr; return (void*)&kernel_addr;
@ -300,7 +301,7 @@ void hal_init(void)
"0123456789abcdef"; "0123456789abcdef";
wolfBoot_set_encrypt_key((uint8_t *)enc_key,(uint8_t *)(enc_key + 32)); wolfBoot_set_encrypt_key((uint8_t *)enc_key,(uint8_t *)(enc_key + 32));
#endif #endif
#if defined(DEBUG_UART)
uart_init(); uart_init();
/* length of the message */ /* length of the message */
@ -341,7 +342,7 @@ void hal_init(void)
wolfBoot_printf("\n M2MC clock : %d Hz", getclocks(13)); wolfBoot_printf("\n M2MC clock : %d Hz", getclocks(13));
wolfBoot_printf("\n PIXEL_BVB clock : %d Hz\n", getclocks(14)); wolfBoot_printf("\n PIXEL_BVB clock : %d Hz\n", getclocks(14));
#endif #endif
#endif
} }
void hal_prepare_boot(void) void hal_prepare_boot(void)

28
hal/raspi3.h 100644
View File

@ -0,0 +1,28 @@
/* raspi3.h
*
* Copyright (C) 2025 wolfSSL Inc.
*
* This file is part of wolfBoot.
*
* wolfBoot is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfBoot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef _RASPI3_H_
#define _RASPI3_H_
#define USE_BUILTIN_STARTUP
#define USE_SIMPLE_STARTUP
#endif /* _RASPI3_H_ */

View File

@ -563,7 +563,9 @@ endif
ifeq ($(NO_XIP),1) ifeq ($(NO_XIP),1)
CFLAGS+=-D"NO_XIP" CFLAGS+=-D"NO_XIP"
endif endif
ifeq ($(NO_QNX),1)
CFLAGS+=-D"NO_QNX"
endif
ifeq ($(ALLOW_DOWNGRADE),1) ifeq ($(ALLOW_DOWNGRADE),1)
CFLAGS+= -D"ALLOW_DOWNGRADE" CFLAGS+= -D"ALLOW_DOWNGRADE"

View File

@ -1,6 +1,6 @@
/* boot_aarch64.c /* boot_aarch64.c
* *
* Copyright (C) 2024 wolfSSL Inc. * Copyright (C) 2025 wolfSSL Inc.
* *
* This file is part of wolfBoot. * This file is part of wolfBoot.
* *

View File

@ -30,6 +30,10 @@
#include "hal/nxp_ls1028a.h" #include "hal/nxp_ls1028a.h"
#endif #endif
#ifdef TARGET_raspi3
#include "hal/raspi3.h"
#endif
/* GICv2 Register Offsets */ /* GICv2 Register Offsets */
#ifndef GICD_BASE #ifndef GICD_BASE
#define GICD_BASE 0xF9010000 #define GICD_BASE 0xF9010000
@ -1028,7 +1032,55 @@ FPUStatus:
.skip 1 .skip 1
.align 8 .align 8
#elif defined(USE_SIMPLE_STARTUP)
.section ".boot"
.global _vector_table
_vector_table:
mov x21, x0 // read ATAG/FDT address
4: ldr x1, =_vector_table // get start of .text in x1
// Read current EL
mrs x0, CurrentEL
and x0, x0, #0x0C
// EL == 3?
cmp x0, #12
bne 2f
3: mrs x2, scr_el3
orr x2, x2, 0x0F // scr_el3 |= NS|IRQ|FIQ|EA
msr scr_el3, x2
msr cptr_el3, xzr // enable FP/SIMD
// EL == 1?
2: cmp x0, #4
beq 1f
// EL == 2?
mov x2, #3 << 20
msr cptr_el2, x2 /* Enable FP/SIMD */
b 0f
1: mov x0, #3 << 20
msr cpacr_el1, x0 // Enable FP/SIMD for EL1
msr sp_el1, x1
/* Suspend slave CPUs */
0: mrs x3, mpidr_el1 // read MPIDR_EL1
and x3, x3, #3 // CPUID = MPIDR_EL1 & 0x03
cbz x3, 8f // if 0, branch forward
7: wfi // infinite sleep
b 7b
8: mov sp, x1 // set stack pointer
bl boot_entry_C // boot_entry_C never returns
b 7b // go to sleep anyhow in case.
#if 0
.section ".boot"
.global _vector_table
_vector_table:
bl boot_entry_C // boot_entry_C never returns
#endif
#endif /* !USE_BUILTIN_STARTUP */ #endif /* !USE_BUILTIN_STARTUP */