Misc cleanup

master
Thomas Cook 2026-09-28 12:18:32 -04:00 committed by Daniele Lacamera
parent d4c65ef7a5
commit 13d11a85bc
17 changed files with 400 additions and 190 deletions

View File

@ -413,7 +413,7 @@ if(NOT DEFINED ARM_TARGETS)
stm32u5
stm32wb
ti
ti_am64x
ti_am64x_r5
zynqmp
)
set(ARM_TARGETS

View File

@ -588,7 +588,7 @@ wolfboot.efi: wolfboot.elf
$(Q)$(SIZE) wolfboot.efi
@echo
ifeq ($(TARGET),ti_am64x)
ifeq ($(TARGET),ti_am64x_r5)
$(GENERATED_SRCS):
@echo "\t[TI SYSCONFIG] generated/hal/"
$(Q)$(TI_SYSCONFIG)/nodejs/node \
@ -596,11 +596,11 @@ $(GENERATED_SRCS):
--product $(TI_MCU_PLUS_SDK)/.metadata/product.json \
--context r5fss0-0 --part Default --package ALV \
--output generated/hal/ \
config/examples/ti-am64x/ti-am64x-r5_hal.syscfg
config/examples/ti-am64x-r5/ti-am64x-r5_hal.syscfg
endif
wolfboot.bin: wolfboot.elf
ifeq ($(TARGET),ti_am64x)
ifeq ($(TARGET),ti_am64x_r5)
@echo "\t[BIN] wolfboot.tmp"
$(Q)$(OBJCOPY) $(OBJCOPY_FLAGS) -O binary $^ wolfboot.tmp
@echo "\t[TI BIN] ROM-bootable image: wolfboot.bin"
@ -783,7 +783,7 @@ endif
test-app/image.elf: wolfboot.elf
$(Q)$(MAKE) -C test-app WOLFBOOT_ROOT="$(WOLFBOOT_ROOT)" ELF_FLASH_SCATTER="$(ELF_FLASH_SCATTER)" LIBERO_FPGA_CONFIG_DIR="$(LIBERO_FPGA_CONFIG_DIR)" WOLFHSM_MICROCHIP_PIC32CZ="$(WOLFHSM_MICROCHIP_PIC32CZ)" image.elf
ifeq ($(ELF_FLASH_SCATTER),1)
ifneq (,$(ELF_FLASH_SCATTER)$(filter ti_am64x_r5,$(TARGET)))
$(Q)$(SIZE) test-app/image-orig.elf
else
$(Q)$(SIZE) test-app/image.elf

13
arch.mk
View File

@ -2152,7 +2152,7 @@ ifeq ($(TARGET),ti_hercules)
OPTIMIZATION_LEVEL=2
endif
ifeq ($(TARGET),ti_am64x)
ifeq ($(TARGET),ti_am64x_r5)
TI_MCU_PLUS_SDK=$(abspath $(wildcard $(PWD)/../TI/mcu_plus_sdk_am64x_*))
ifeq ($(TI_MCU_PLUS_SDK),)
$(error "No sdk found at $(PWD)/../TI/mcu_plus_sdk_am64x_*")
@ -2216,12 +2216,20 @@ ifeq ($(TARGET),ti_am64x)
GENERATED_SRCS+=generated/hal/ti_pinmux_config.c
GENERATED_SRCS+=generated/hal/ti_power_clock_config.c
UPDATE_OBJS:=src/update_ram.o
CFLAGS+=-DWOLFBOOT_DUALBOOT -DWOLFBOOT_NO_RAMBOOT
OBJS+=$(patsubst %.c,%.o,$(GENERATED_SRCS))
OBJS+=\
$(TI_MCU_PLUS_SDK)/source/board/flash/flash.o \
$(TI_MCU_PLUS_SDK)/source/board/flash/ospi/flash_nor_ospi.o \
$(TI_MCU_PLUS_SDK)/source/drivers/bootloader/soc/am64x_am243x/bootloader_soc.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/ospi_phy_dqs.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/ospi_v0.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/lld/dma/udma/ospi_udma_lld.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/lld/ospi_phy_dqs_lld.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/lld/ospi_v0_lld.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/lld/ospi_tuning/ospi_tuning_algo/algo_v1/ospi_phy_tuning.o \
$(TI_MCU_PLUS_SDK)/source/drivers/sciclient/sciclient_boardcfg.o \
$(TI_MCU_PLUS_SDK)/source/drivers/sciclient/sciclient_firewall.o \
$(TI_MCU_PLUS_SDK)/source/drivers/sciclient/sciclient_procboot.o \
@ -2264,8 +2272,7 @@ ifeq ($(TARGET),ti_am64x)
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/printf.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/SemaphoreP_nortos.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/TaskP_nortos.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/TimerP_rti_nortos.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/TimerP_rti_priv.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/TimerP.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/r5/boot_armv7r.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/r5/boot_armv7r_asm.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/r5/CacheP_armv7r.o \

View File

@ -1,5 +1,5 @@
ARCH?=ARM
TARGET?=ti_am64x
TARGET?=ti_am64x_r5
SIGN?=ECC256
HASH?=SHA256
CORTEX_R5?=1
@ -11,7 +11,7 @@ VTOR?=1
NO_ASM?=1
NO_ARM_ASM=1
NO_MPU=1
EXT_FLASH?=1
EXT_FLASH?=0
SPI_FLASH?=0
NO_XIP?=1
ALLOW_DOWNGRADE?=0
@ -21,19 +21,20 @@ V?=0
SPMATH?=1
RAM_CODE?=0
DUALBANK_SWAP?=0
FLASH_MULTI_SECTOR_ERASE?=1
ELF=1
ELF_FLASH_SCATTER=1
FLASH_MULTI_SECTOR_ERASE?=0
ELF?=1
PKA?=0
WOLFBOOT_SECTOR_SIZE?=0x200
WOLFBOOT_SECTOR_SIZE?=0x40000
# Default configuration
WOLFBOOT_PARTITION_SIZE?=0x40000
WOLFBOOT_PARTITION_SIZE?=0x100000
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x60080000
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x600c0000
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x600e0000
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x60180000
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x60280000
WOLFBOOT_LOAD_ADDRESS?=0x70080000
WOLFCRYPT_TEST?=1
WOLFCRYPT_BENCHMARK?=1

View File

@ -23,8 +23,12 @@ scripting.excludeFromBuild("linker_defines.h");
/**
* Import the modules used in this configuration.
*/
const flash = scripting.addModule("/board/flash/flash", {}, false);
const flash1 = flash.addInstance();
const firewall = scripting.addModule("/drivers/firewall/firewall", {}, false);
const firewall1 = firewall.addInstance();
const qos = scripting.addModule("/drivers/qos/qos", {}, false);
const qos1 = qos.addInstance();
const debug_log = scripting.addModule("/kernel/dpl/debug_log");
const dpl_cfg = scripting.addModule("/kernel/dpl/dpl_cfg");
const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false);
@ -33,7 +37,6 @@ const mpu_armv72 = mpu_armv7.addInstance();
const mpu_armv73 = mpu_armv7.addInstance();
const mpu_armv74 = mpu_armv7.addInstance();
const mpu_armv75 = mpu_armv7.addInstance();
const mpu_armv76 = mpu_armv7.addInstance();
const default_linker = scripting.addModule("/memory_configurator/default_linker", {}, false);
const default_linker1 = default_linker.addInstance();
const general = scripting.addModule("/memory_configurator/general", {}, false);
@ -58,6 +61,14 @@ const crypto1 = crypto.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
flash1.$name = "CONFIG_FLASH0";
flash1.peripheralDriver.$name = "CONFIG_OSPI0";
flash1.peripheralDriver.phyEnable = true;
flash1.peripheralDriver.advanced = true;
flash1.peripheralDriver.inputClkFreq = 166666666;
flash1.peripheralDriver.dmaEnable = true;
flash1.peripheralDriver.child.$name = "drivers_ospi_v0_ospi_v0_template0";
firewall1.$name = "CONFIG_FIREWALL0";
firewall1.regCfg.create(1);
firewall1.regCfg[0].$name = "FWL_REG_CFG0";
@ -67,6 +78,13 @@ firewall1.regCfg[0].interName = "MMRA";
firewall1.regCfg[0].fwlCache = true;
firewall1.regCfg[0].fwlPriv1 = "MAIN_0_R5_0_SECURE";
qos1.$name = "CONFIG_QOS0";
const udma = scripting.addModule("/drivers/udma/udma", {}, false);
const udma1 = udma.addInstance({}, false);
udma1.$name = "CONFIG_UDMA0";
flash1.peripheralDriver.udmaDriver = udma1;
debug_log.enableUartLog = true;
debug_log.uartLog.$name = "CONFIG_UART_CONSOLE";
debug_log.uartLog.UART.$assign = "USART0";
@ -96,14 +114,9 @@ mpu_armv74.baseAddr = 0x70000000;
mpu_armv74.size = 21;
mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD";
mpu_armv75.$name = "CONFIG_MPU_REGION4";
mpu_armv75.baseAddr = 0x60000000;
mpu_armv75.size = 28;
mpu_armv75.accessPermissions = "Supervisor RD, User RD";
mpu_armv76.$name = "CONFIG_MPU_REGION5";
mpu_armv76.baseAddr = 0x80000000;
mpu_armv76.size = 31;
mpu_armv75.baseAddr = 0x80000000;
mpu_armv75.size = 31;
mpu_armv75.$name = "CONFIG_MPU_REGION4";
default_linker1.$name = "memory_configurator_default_linker0";
@ -275,15 +288,26 @@ section11.output_section[0].alignment = 0;
crypto1.$name = "CONFIG_CRYPTO0";
crypto1.sa2ul.$name = "CONFIG_SA2UL0";
const udma = scripting.addModule("/drivers/udma/udma", {}, false);
const udma1 = udma.addInstance({}, false);
udma1.$name = "CONFIG_UDMA0";
crypto1.sa2ul.udmaPKTDMA = udma1;
const udma2 = udma.addInstance({}, false);
udma2.$name = "CONFIG_UDMA1";
crypto1.sa2ul.udmaPKTDMA = udma2;
/**
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
* re-solve from scratch.
*/
debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD";
debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD";
flash1.peripheralDriver.OSPI.$suggestSolution = "OSPI0";
flash1.peripheralDriver.OSPI.CLK.$suggestSolution = "OSPI0_CLK";
flash1.peripheralDriver.OSPI.CSn0.$suggestSolution = "OSPI0_CSn0";
flash1.peripheralDriver.OSPI.DQS.$suggestSolution = "OSPI0_DQS";
flash1.peripheralDriver.OSPI.D7.$suggestSolution = "OSPI0_D7";
flash1.peripheralDriver.OSPI.D6.$suggestSolution = "OSPI0_D6";
flash1.peripheralDriver.OSPI.D5.$suggestSolution = "OSPI0_D5";
flash1.peripheralDriver.OSPI.D4.$suggestSolution = "OSPI0_D4";
flash1.peripheralDriver.OSPI.D3.$suggestSolution = "OSPI0_D3";
flash1.peripheralDriver.OSPI.D2.$suggestSolution = "OSPI0_D2";
flash1.peripheralDriver.OSPI.D1.$suggestSolution = "OSPI0_D1";
flash1.peripheralDriver.OSPI.D0.$suggestSolution = "OSPI0_D0";
debug_log.uartLog.UART.RXD.$suggestSolution = "UART0_RXD";
debug_log.uartLog.UART.TXD.$suggestSolution = "UART0_TXD";

View File

@ -73,6 +73,7 @@ This README describes configuration of supported targets.
* [STM32L5](#stm32l5)
* [STM32U5](#stm32u5)
* [STM32WB55](#stm32wb55)
* [TI AM6442](#ti-am6442)
* [TI C2000 C28x (LAUNCHXL-F28P55X)](#ti-c2000-c28x-launchxl-f28p55x)
* [TI Hercules TMS570LC435](#ti-hercules-tms570lc435)
* [Vorago VA416x0](#vorago-va416x0)
@ -7317,8 +7318,6 @@ cmd>
See [/config/examples/ti-tms570lc435.config](/config/examples/ti-tms570lc435.config) for example configuration.
## Nordic nRF52840
We have full Nordic nRF5280 examples for Contiki and RIOT-OS in our [wolfBoot-examples repo](https://github.com/wolfSSL/wolfboot-examples)
@ -10379,6 +10378,171 @@ Stage 1 is built by `make -C stage1` and takes its own options, separately from
The two bring-up options exist to get a new board talking; neither belongs in a shipped configuration, and the build refuses to combine either with authentication rather than letting a boot continue past a refusal.
## TI AM6442
The TI AM6442 is a multi-core SoC, with one dual-core Cortex-A53, two dual-core Cortex-R5F,
a Cortex-M4F, and a dedicated security core based on a Cortex-M3. This support has been
tested on the TMDS64EVM board (rev 101D).
### AM64x: Setup Software Tools
Software builds require the TI MCU Plus SDK and the TI Arm Clang toolchain, plus
a couple other TI tools.
Download the SDK:
[MCU Plus SDK for AM64x v11.02](https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-SfkcjYAjGS/11.02.00.24/mcu_plus_sdk_am64x_11_02_00_24-linux-x64-installer.run)
To set up the TI SDK and toolchain:
```
# from the wolfBoot directory...
mkdir ../TI
cd ../TI
# Install SDK
/path/to/mcu_plus_sdk_am64x_11_02_00_24-linux-x64-installer.run --mode unattended --prefix .
# Clone the setup repo
git clone --branch REL.MCUSDK.K3.11.02.00.24 https://github.com/TexasInstruments/mcupsdk-setup.git
# Run the download_components.sh script
chmod +x mcupsdk-setup/releases/11_00_00/am64x/download_components.sh
mcupsdk-setup/am64x/download_components.sh --install_dir=./tools --skip_nodejs=true --skip_doxygen=true --skip_ccs=true
```
### AM64x: Hardware Acceleration
wolfBoot / wolfCrypt provide support for the TI AM64x hardware acceleration
blocks via the device's SA2UL peripheral. By default, this
support is turned off in the config files, and all crypto is software based.
To turn on hardware acceleration, set PKA=1 in the config file.
Basic hardware acceleration supported:
- AES-CBC (128, 256 key sizes)
- AES-ECB (128, 256 key sizes)
- AES-GCM (128, 256 key sizes)
- SHA-256, SHA-512
See [Test and Benchmark](#am64x-test-and-benchmark) for a comparison with and without hardware acceleration.
### AM64x: Configuring and compiling
Copy the example configuration file and build with make:
```sh
cp config/examples/lpc55s69.config .config
make
```
We also provide a TrustZone configuration at `config/examples/lpc55s69-tz.config`
and a benchmarking configuration at `config/examples/lpc55s69-benchmark.config`.
### AM64x: Loading the firmware
Download and install the LinkServer tool:
[@NXP: LinkServer for microcontrollers](https://www.nxp.com/design/design-center/software/development-software/mcuxpresso-software-and-tools-/linkserver-for-microcontrollers:LINKERSERVER#downloads)
NOTE: The LPCXpresso55S69's on-board LINK2 debugger comes loaded with CMSIS-DAP protocol, but it can be
optionally updated to use JLink protocol instead. See the EVK user manual for how to do this, if desired.
The below examples were tested with the default CMSIS-DAP protocol. CMSIS-DAP is supported by default in
the MCUXpresso IDE for debugging purposes.
Connect a USB cable from your development PC to P6 on the dev board.
Open a terminal to the virtual COM port with putty or similar app, settings 115200-N-8-1.
### AM64x: Testing firmware factory.bin
1) Erase the entire flash:
```sh
LinkServer flash LPC55S69 erase
```
2) Program the factory.bin, which contains both wolfBoot and the test-app version 1:
```sh
LinkServer flash LPC55S69 load factory.bin:0
```
NOTE: See [tools/scripts/lpc55s69/lpc55s69_flash_factory_bin.cmm](/tools/scripts/lpc55s69/lpc55s69_flash_factory_bin.cmm) for the lauterbach equivalent of 1 and 2 combined.
3) The LED will light up blue to indicate version 1 of the firmware is running. You should also see output
like this in the terminal window:
```sh
lpc55s69 init
Boot partition: 0xD000 (sz 22460, ver 0x1, type 0x601)
Partition 1 header magic 0xFFFFFFFF invalid at 0x18000
Boot partition: 0xD000 (sz 22460, ver 0x1, type 0x601)
Booting version: 0x1
==================================
LPC55S69 wolfBoot demo Application
Copyright 2026 wolfSSL Inc
==================================
boot: ver=0x1 state=0xFF
update: ver=0x0 state=0xFF
Calling wolfBoot_success()
boot: ver=0x1 state=0x00
update: ver=0x0 state=0xFF
```
### AM64x: Debugging
Debugging with GDB:
Note: We include a `.gdbinit` in the wolfBoot root that loads the wolfboot and test-app elf files.
In one terminal: `LinkServer gdbserver LPC55S69`
In another terminal use `gdb`:
```
b main
mon reset
c
```
NOTE: See [tools/scripts/lpc55s69/lpc55s69_debug.cmm](/tools/scripts/lpc55s69/lpc55s69_debug.cmm) for the lauterbach equivalent.
### AM64x Test and Benchmark
Here is an example of how to run wolfCrypt test and benchmarking on actual hardware.
1. Start with [lpc55s69-benchmark.config](/config/examples/lpc55s69-benchmark.config)
- By default, the config file has PKA?=0, which means hardware acceleration of crypto is off. Let's try that first.
```sh
cp config/examples/lpc55s69-benchmark.config .config
make clean
make
```
2. Flash the factory.bin and reboot...
```sh
```
2. Now try changing to PKA?=1 in the config file, rebuild, and reflash...
```sh
```
## TI C2000 C28x (LAUNCHXL-F28P55X)
wolfBoot runs on the Texas Instruments C2000 C28x DSP (TMS320F28P550SJ, 150 MHz) as a secure execute-in-place (XIP) bootloader. The C28x is word-addressed with `CHAR_BIT == 16` (no 8-bit type -- each octet occupies one 16-bit cell), built with the TI `cl2000` toolchain against wolfSSL's wide-byte (`CHAR_BIT != 8`) support.

View File

@ -1,4 +1,4 @@
/* ti_am64x.c
/* ti_am64x_r5.c
*
* Copyright (C) 2026 wolfSSL Inc.
*
@ -27,29 +27,10 @@
#include <wolfssl/wolfcrypt/types.h>
// static flash_config_t pflash;
// static const uint32_t pflash_page_size = 512U;
// uint32_t SystemCoreClock; /* set in clock_config.c */
// static void hal_flash_fix_ecc(void)
// {
// uint8_t page_buf[512];
// uint32_t addr;
// uint32_t start = WOLFBOOT_PARTITION_BOOT_ADDRESS;
// uint32_t end = WOLFBOOT_PARTITION_SWAP_ADDRESS + WOLFBOOT_SECTOR_SIZE;
// memset(page_buf, 0xFF, sizeof(page_buf));
// for (addr = start; addr < end; addr += pflash_page_size) {
// if (FLASH_VerifyErase(&pflash, addr, pflash_page_size)
// == kStatus_FLASH_Success) {
// FLASH_Program(&pflash, addr, page_buf, pflash_page_size);
// }
// }
// }
#include "DebugP.h"
#include "board/flash.h"
#include "drivers/sciclient.h"
#include "drivers/ospi.h"
#include "drivers/bootloader/soc/am64x_am243x/bootloader_soc.h"
#include "kernel/dpl/ClockP.h"
#include "security/security_common/drivers/crypto/rng/rng.h"
@ -57,9 +38,9 @@
void System_init(void);
void Drivers_open(void);
void Drivers_udmaOpen(void);
void Drivers_uartOpen(void);
extern ClockP_Config gClockConfig;
int32_t Board_driversOpen(void);
extern OSPI_Handle gOspiHandle[1];
extern Flash_Handle gFlashHandle[1];
#ifndef __WOLFBOOT
#include <stdio.h>
@ -75,6 +56,32 @@ void putchar__(char character)
}
#endif
static void flashFixUpOspiBoot(OSPI_Handle oHandle)
{
int32_t status = SystemP_FAILURE;
OSPI_setProtocol(oHandle, OSPI_NOR_PROTOCOL(8,8,8,1));
OSPI_enableDDR(oHandle);
OSPI_setDualOpCodeMode(oHandle);
/* Do a soft reset of the OSPI flash */
OSPI_WriteCmdParams wrParams;
OSPI_WriteCmdParams_init(&wrParams);
wrParams.cmd = 0x66;
status = OSPI_writeCmd(oHandle, &wrParams);
if(status == SystemP_SUCCESS)
{
wrParams.cmd = 0x99;
status = OSPI_writeCmd(oHandle, &wrParams);
}
/* Wait for the flash to reset */
ClockP_usleep(100);
OSPI_enableSDR(oHandle);
OSPI_clearDualOpCodeMode(oHandle);
OSPI_setProtocol(oHandle, OSPI_NOR_PROTOCOL(1,1,1,0));
}
void hal_init(void)
{
#ifdef __WOLFBOOT
@ -86,12 +93,6 @@ void hal_init(void)
Sciclient_waitForBootNotification();
/* Warm Reset Workaround to prevent CPSW register lockup */
if (!Bootloader_socIsMCUResetIsoEnabled())
{
Bootloader_socResetWorkaround();
}
if (!Bootloader_socIsMCUResetIsoEnabled())
{
/* Update devGrp to ALL to initialize MCU domain when reset isolation is
@ -116,41 +117,28 @@ void hal_init(void)
(void)Sciclient_boardCfgRm(&boardCfgPrms_rm);
/* Enable MCU PLL. MCU PLL will not be enabled by DMSC when devGrp is set
to Main in boardCfg */
Bootloader_enableMCUPLL();
}
System_init();
Bootloader_socOpenFirewalls();
Bootloader_socNotifyFirewallOpen();
Drivers_udmaOpen();
Drivers_uartOpen();
Drivers_open();
uart_write("ti_am64x_r5 init\n", 14);
Sciclient_getVersionCheck(1);
#else
gClockConfig.timerBaseAddr = 0x0e080000UL; /* fixes sdk syscfg bug */
// asm(
// "_debug_loop_start:\n"
// " b _debug_loop_start\n"
// );
System_init();
Drivers_open();
#endif /* __WOLFBOOT */
#ifdef __WOLFBOOT
# ifdef DEBUG_UART
uart_init();
uart_write("ti_am64x init\n", 14);
# endif
#endif /* __WOLFBOOT */
#if defined(__WOLFBOOT)
// memset(&pflash, 0, sizeof(pflash));
// FLASH_Init(&pflash);
// hal_flash_fix_ecc();
#endif
flashFixUpOspiBoot(gOspiHandle[0]);
Board_driversOpen();
OSPI_enableDacMode(gOspiHandle[0]);
}
#ifdef __WOLFBOOT
@ -171,10 +159,36 @@ void hal_prepare_boot(void)
}
#endif
#define PAGE_SIZE 256
int RAMFUNCTION hal_flash_write(uint32_t address, const uint8_t *data, int len)
{
int status = 0;
uint32_t page_addr;
uint32_t offset;
uint32_t chunk;
uint8_t page_buf[PAGE_SIZE];
return 0;
while (len > 0) {
page_addr = address & ~(PAGE_SIZE - 1);
offset = address - page_addr;
chunk = PAGE_SIZE - offset;
if ((uint32_t)len < chunk)
chunk = (uint32_t)len;
memcpy(page_buf, (void *)page_addr, PAGE_SIZE);
memcpy(page_buf + offset, data, chunk);
OSPI_disableDacMode(gOspiHandle[0]);
status |= Flash_write(gFlashHandle[0], page_addr - ARCH_FLASH_OFFSET, page_buf, PAGE_SIZE);
OSPI_enableDacMode(gOspiHandle[0]);
address += chunk;
data += chunk;
len -= (int)chunk;
}
return status;
}
void RAMFUNCTION hal_flash_unlock(void)
@ -187,9 +201,18 @@ void RAMFUNCTION hal_flash_lock(void)
int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
{
uint32_t offset = address - ARCH_FLASH_OFFSET;
uint32_t blk, page;
int status;
OSPI_disableDacMode(gOspiHandle[0]);
status = Flash_offsetToBlkPage(gFlashHandle[0], offset, &blk, &page);
if (status == 0) {
status = Flash_eraseBlk(gFlashHandle[0], blk);
}
OSPI_enableDacMode(gOspiHandle[0]);
return 0;
return status;
}
#ifdef WOLFCRYPT_SECURE_MODE
@ -278,34 +301,6 @@ void uart_write(const char *buf, unsigned int sz)
}
#endif
#ifdef EXT_FLASH
int ext_flash_read(uintptr_t address, uint8_t *data, int len)
{
XMEMCPY(data, (void *)address, len);
return len;
}
int ext_flash_erase(uintptr_t address, int len)
{
XMEMSET((void *)address, 0xFF, len);
return len;
}
int ext_flash_write(uintptr_t address, const uint8_t *data, int len)
{
XMEMCPY((void *)address, data, len);
return len;
}
void ext_flash_lock(void)
{
}
void ext_flash_unlock(void)
{
}
#endif /* EXT_FLASH */
#include <kernel/dpl/HwiP.h>
#include <kernel/dpl/CacheP.h>
@ -316,5 +311,8 @@ void do_boot(const uint32_t *app_offset)
HwiP_disable();
CacheP_wbInvAll(CacheP_TYPE_ALL);
Bootloader_socCpuResetReleaseSelf();
while (1) {
asm("nop");
}
}
#endif /* __WOLFBOOT */

View File

@ -11,8 +11,8 @@ __UNDEFINED_STACK_SIZE = 256;
MEMORY
{
MSRAM_VECS : ORIGIN = 0x70000000 , LENGTH = 0x100
MSRAM_0 : ORIGIN = 0x70000100 , LENGTH = 0x6FF00
MSRAM_1 : ORIGIN = 0x70070000 , LENGTH = 0x10000
MSRAM_0 : ORIGIN = 0x70000100 , LENGTH = 0x1FF00
MSRAM_01 : ORIGIN = 0x70020000 , LENGTH = 0x60000
}
SECTIONS
@ -40,13 +40,13 @@ SECTIONS
. = ALIGN(4);
_end_bss = .;
_end = .;
} > MSRAM_1 , palign(8)
} > MSRAM_01 , palign(8)
RUN_START(__BSS_START)
RUN_END(__BSS_END)
.stack :
{
} > MSRAM_1 , palign(8)
} > MSRAM_01 , palign(8)
GROUP : {
.irqstack : {
@ -74,5 +74,5 @@ SECTIONS
} align(8)
RUN_START(__UNDEFINED_STACK_START)
RUN_END(__UNDEFINED_STACK_END)
} > MSRAM_1
} > MSRAM_01
}

View File

@ -745,8 +745,8 @@ extern int tolower(int c);
#define WOLFSSL_SHA256
#define WOLFSSL_SHA384
#define WOLFSSL_SHA512
#elif defined(TARGET_ti_am64x)
#ifndef WOLFSSL_TI_AM64X
#elif defined(TARGET_ti_am64x_r5)
#ifndef WOLFSSL_TI_AM64X_R5
#define WC_NO_RNG
#endif
#define HAVE_AES_ECB
@ -755,11 +755,8 @@ extern int tolower(int c);
#define WOLFSSL_AES_DIRECT
#define WOLFSSL_CMAC
#define WOLFSSL_SHA512
#define WOLFMEM_DIST 49,10,6,14,5,6,9,1,2
#define WOLFSSL_STATIC_MEMORY_TEST_SZ (50 * 1024)
#define WOLFSSL_BENCHMARK_FIXED_UNITS_MB
#define GENERATE_MACHINE_PARSEABLE_REPORT
#define WOLFSSL_BENCHMARK_FIXED_CSV
#else
/* Use custom RNG for tests/benchmarks (saves ~7KB vs HASHDRBG).
* WARNING: my_rng_seed_gen is NOT cryptographically secure.

View File

@ -1333,7 +1333,7 @@ ifeq ($(DEBUG_SYMBOLS),1)
ifeq ($(USE_GCC),1)
CFLAGS+=-ggdb3
else ifneq ($(ARCH),AURIX)
ifneq ($(TARGET),ti_am64x)
ifneq ($(TARGET),ti_am64x_r5)
ifneq ($(USE_CLANG),1)
# -gstabs was removed in GCC 12; -gdwarf-4 works on old and new GCC
CFLAGS+=-gdwarf-4

View File

@ -2392,7 +2392,7 @@ static int read_flash_fwimage(struct wolfBoot_image* img, uint32_t offset,
*/
static int read_flash_addr(void* src, void* buffer, uint32_t size, int src_ext)
{
if (buffer == NULL) {
if (src == NULL || buffer == NULL) {
return -1;
}

View File

@ -1,4 +1,4 @@
--stack_size=16384
--stack_size=32768
--heap_size=1024
__IRQ_STACK_SIZE = 4096;
__FIQ_STACK_SIZE = 256;
@ -11,7 +11,7 @@ __UNDEFINED_STACK_SIZE = 256;
MEMORY
{
R5F_VECS : ORIGIN = 0x0 , LENGTH = 0x40
MSRAM : ORIGIN = 0x70080000 , LENGTH = 0x80000
MSRAM_45 : ORIGIN = 0x70100000 , LENGTH = 0xC0000
}
SECTIONS
@ -24,18 +24,18 @@ SECTIONS
*(.text*)
*(.rodata*)
*(.data*)
} > MSRAM , palign(8)
} > MSRAM_45 , palign(8)
.bss :
{
*(.bss*)
} > MSRAM , palign(8)
} > MSRAM_45 , palign(8)
RUN_START(__BSS_START)
RUN_END(__BSS_END)
.stack :
{
} > MSRAM , palign(8)
} > MSRAM_45 , palign(8)
GROUP : {
.irqstack : {
@ -63,7 +63,7 @@ SECTIONS
} align(8)
RUN_START(__UNDEFINED_STACK_START)
RUN_END(__UNDEFINED_STACK_END)
} > MSRAM
} > MSRAM_45
}
_wolfboot_partition_boot_address = @WOLFBOOT_PARTITION_BOOT_ADDRESS@;

View File

@ -103,7 +103,7 @@ else
CFLAGS+=-Wall -ffreestanding -Wno-unused -ffunction-sections -fdata-sections
# Stack usage computation not supported on TriCore
ifneq ($(ARCH),AURIX)
ifneq ($(TARGET),ti_am64x)
ifneq ($(TARGET),ti_am64x_r5)
ifneq ($(USE_CLANG),1)
CFLAGS+=-Wstack-usage=$(STACK_USAGE_LIMIT)
endif
@ -114,7 +114,7 @@ else
ifeq ($(USE_GCC),1)
CFLAGS+=-ggdb3
else ifneq ($(ARCH),AURIX)
ifneq ($(TARGET),ti_am64x)
ifneq ($(TARGET),ti_am64x_r5)
ifneq ($(USE_CLANG),1)
# -gstabs was removed in GCC 12; -gdwarf-4 works on old and new GCC
CFLAGS+=-gdwarf-4
@ -187,8 +187,8 @@ endif
# Setup default linker flags (gcc-driver form). Renesas RX links with ld
# directly (USE_GCC=0) and gets its -T/-gc-sections/oformat from arch.mk, so
# these gcc-driver flags (-Wl,/-nostartfiles and a duplicate -T) are skipped.
ifeq ($(TARGET),ti_am64x)
LDFLAGS+=-Wl,$(LSCRIPT) -Wl,-m=image.map -Wl,--symbol_map=putchar_=putchar__
ifeq ($(TARGET),ti_am64x_r5)
LDFLAGS+=-Wl,$(LSCRIPT) -Wl,-m=image.map -Wl,--symbol_map=putchar_=putchar__ -Wl,--honor_cmdfile_order
else ifneq ($(ARCH),RENESAS_RX)
LDFLAGS+=-T $(LSCRIPT) -Wl,-gc-sections -Wl,-Map=image.map -nostartfiles
endif
@ -288,7 +288,7 @@ endif
ifeq ($(WOLFCRYPT_SUPPORT),1)
# Add support infrastructure
APP_OBJS+=wolfcrypt_support.o
ifneq ($(TARGET),ti_am64x)
ifneq ($(TARGET),ti_am64x_r5)
APP_OBJS+=syscalls.o
endif
@ -912,8 +912,8 @@ ifeq ($(TARGET),ti_hercules)
OBJCOPY_FLAGS=
endif
ifeq ($(TARGET),ti_am64x)
LSCRIPT_TEMPLATE=ARM-ti_am64x.ld
ifeq ($(TARGET),ti_am64x_r5)
LSCRIPT_TEMPLATE=ARM-ti_am64x_r5.ld
endif
ifeq ($(TARGET),va416x0)
@ -1198,7 +1198,7 @@ ifeq ($(TARGET),rw612)
endif
endif
ifeq ($(TARGET),ti_am64x)
ifeq ($(TARGET),ti_am64x_r5)
GENERATED_APP_SRCS=
GENERATED_APP_SRCS+=../generated/test-app/ti_board_config.c
GENERATED_APP_SRCS+=../generated/test-app/ti_board_open_close.c
@ -1210,13 +1210,22 @@ ifeq ($(TARGET),ti_am64x)
ORIGINAL_SA2UL_C=$(TI_MCU_PLUS_SDK)/source/security/security_common/drivers/crypto/sa2ul/sa2ul.c
PATCHED_SA2UL_C=$(abspath ../generated/common/sa2ul.c)
PATCHFILE_SA2UL_C=$(abspath ../config/examples/ti-am64x/mcuplussdk_11.02.00_sa2ul.c.patch)
PATCHFILE_SA2UL_C=$(abspath ../config/examples/ti-am64x-r5/mcuplussdk_11.02.00_sa2ul.c.patch)
APP_OBJS+=$(patsubst %.c,%.o,$(GENERATED_APP_SRCS))
APP_OBJS+=$(patsubst %.c,%.o,$(PATCHED_SA2UL_C))
APP_OBJS+=\
$(TI_MCU_PLUS_SDK)/source/board/flash/flash.o \
$(TI_MCU_PLUS_SDK)/source/board/flash/ospi/flash_nor_ospi.o \
$(TI_MCU_PLUS_SDK)/source/drivers/firewall/v0/firewall.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/ospi_phy_dqs.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/ospi_v0.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/lld/dma/udma/ospi_udma_lld.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/lld/ospi_phy_dqs_lld.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/lld/ospi_v0_lld.o \
$(TI_MCU_PLUS_SDK)/source/drivers/ospi/v0/lld/ospi_tuning/ospi_tuning_algo/algo_v1/ospi_phy_tuning.o \
$(TI_MCU_PLUS_SDK)/source/drivers/pinmux/am64x_am243x/pinmux.o \
$(TI_MCU_PLUS_SDK)/source/drivers/qos/v0/qos.o \
$(TI_MCU_PLUS_SDK)/source/drivers/sciclient/csl_sec_proxy.o \
$(TI_MCU_PLUS_SDK)/source/drivers/sciclient/sciclient.o \
$(TI_MCU_PLUS_SDK)/source/drivers/sciclient/sciclient_pm.o \
@ -1253,8 +1262,7 @@ ifeq ($(TARGET),ti_am64x)
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/printf.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/SemaphoreP_nortos.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/TaskP_nortos.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/TimerP_rti_nortos.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/TimerP_rti_priv.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/common/TimerP.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/r5/boot_armv7r.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/r5/boot_armv7r_asm.o \
$(TI_MCU_PLUS_SDK)/source/kernel/nortos/dpl/r5/CacheP_armv7r.o \
@ -1273,11 +1281,11 @@ ifeq ($(TARGET),ti_am64x)
$(TI_MCU_PLUS_SDK)/source/security/security_common/drivers/crypto/rng/rng.o
ifeq ($(PKA),1)
CFLAGS+=-DWOLFSSL_TI_AM64X
CFLAGS+=-DWOLFSSL_TI_AM64X_R5
CFLAGS+=-DWOLFSSL_TI_AM64X_RNG_CTR_DRBG
APP_OBJS+=\
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/cryptocb.o \
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/ti/ti-sa2ul_port.o
$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/ti/ti-sa2ul_r5_port.o
endif
endif
@ -1769,7 +1777,7 @@ ifeq ($(WOLFHSM_SERVER),1)
APP_OBJS += $(sort $(patsubst $(WOLFBOOT_LIB_WOLFSSL)/%, $(WOLFBOOT_LIB_WOLFSSL)/%, $(WOLFCRYPT_OBJS)))
endif
ifeq ($(TARGET),ti_am64x)
ifeq ($(TARGET),ti_am64x_r5)
$(GENERATED_APP_SRCS):
@echo "\t[TI SYSCONFIG] ../generated/test-app/"
$(Q)$(TI_SYSCONFIG)/nodejs/node \
@ -1777,7 +1785,7 @@ $(GENERATED_APP_SRCS):
--product $(TI_MCU_PLUS_SDK)/.metadata/product.json \
--context r5fss0-0 --part Default --package ALV \
--output ../generated/test-app/ \
../config/examples/ti-am64x/ti-am64x-r5_test-app.syscfg
../config/examples/ti-am64x-r5/ti-am64x-r5_test-app.syscfg
$(PATCHED_SA2UL_C): $(ORIGINAL_SA2UL_C) $(PATCHFILE_SA2UL_C)
@echo "\t[PATCH] $(PATCHED_SA2UL_C)"
@ -1815,8 +1823,8 @@ APP_OBJS := $(patsubst $(WOLFBOOT_LIB_WOLFSSL)/%, \
APP_OBJS := $(patsubst $(WOLFBOOT_LIB_WOLFIP)/%, \
$(WOLFIP_LOCAL_OBJDIR)/%, $(APP_OBJS))
ifeq ($(ELF_FLASH_SCATTER),1)
# When ELF_FLASH_SCATTER=1, preprocess the ELF file with the squashelf tool
# squashelf if either ELF_FLASH_SCATTER==1 or TARGET==ti_am64x_r5
ifneq (,$(ELF_FLASH_SCATTER)$(filter ti_am64x_r5,$(TARGET)))
SQUASHELF_TOOL = ../tools/squashelf/squashelf
OBJCOPY_SRC_ELF=image-orig.elf
image-orig.elf: $(APP_OBJS) $(LSCRIPT)
@ -1827,7 +1835,7 @@ image.elf: image-orig.elf
@echo "\t[SQUASHELF] $@"
$(Q)$(SQUASHELF_TOOL) -v --nosht $< $@
else
# Default behavior when ELF_FLASH_SCATTER is not set
# Default behavior
image.elf: $(APP_OBJS) $(LSCRIPT)
@echo "\t[LD] $@"
$(Q)$(LD) $(LDFLAGS) $(APP_OBJS) $(LIBS) $(OUTPUT_FLAG) $@

View File

@ -1,4 +1,4 @@
/* app_ti_am64x.c
/* app_ti_am64x_r5.c
*
* Copyright (C) 2026 wolfSSL Inc.
*
@ -77,37 +77,37 @@ void main(void)
wolfBoot_printf("Copyright 2026 wolfSSL Inc\n");
wolfBoot_printf("==================================\n");
// check_parts(&boot_ver, &update_ver, &boot_state, &update_state);
check_parts(&boot_ver, &update_ver, &boot_state, &update_state);
// if (
// boot_ver != 0 &&
// (boot_state == IMG_STATE_TESTING || boot_state == IMG_STATE_NEW)
// )
// {
// #ifdef WOLFCRYPT_SECURE_MODE
// wolfBoot_printf("Calling wolfBoot_nsc_success()\n");
// wolfBoot_nsc_success();
// #else
// wolfBoot_printf("Calling wolfBoot_success()\n");
// wolfBoot_success();
// #endif
// check_parts(&boot_ver, &update_ver, &boot_state, &update_state);
// }
if (
boot_ver != 0 &&
(boot_state == IMG_STATE_TESTING || boot_state == IMG_STATE_NEW)
)
{
#ifdef WOLFCRYPT_SECURE_MODE
wolfBoot_printf("Calling wolfBoot_nsc_success()\n");
wolfBoot_nsc_success();
#else
wolfBoot_printf("Calling wolfBoot_success()\n");
wolfBoot_success();
#endif
check_parts(&boot_ver, &update_ver, &boot_state, &update_state);
}
// if (boot_ver == 1)
// {
// if (update_ver != 0) {
// wolfBoot_printf("Update detected, version: 0x%lx\n", update_ver);
// wolfBoot_printf("Triggering update...\n");
// #ifdef WOLFCRYPT_SECURE_MODE
// wolfBoot_nsc_update_trigger();
// #else
// wolfBoot_update_trigger();
// #endif
// check_parts(&boot_ver, &update_ver, &boot_state, &update_state);
// wolfBoot_printf("...done. Reboot to apply.\n");
// }
// }
if (boot_ver == 1)
{
if (update_ver != 0) {
wolfBoot_printf("Update detected, version: 0x%lx\n", update_ver);
wolfBoot_printf("Triggering update...\n");
#ifdef WOLFCRYPT_SECURE_MODE
wolfBoot_nsc_update_trigger();
#else
wolfBoot_update_trigger();
#endif
check_parts(&boot_ver, &update_ver, &boot_state, &update_state);
wolfBoot_printf("...done. Reboot to apply.\n");
}
}
#if defined(WOLFCRYPT_TEST) || defined(WOLFCRYPT_BENCHMARK)
wolfCrypt_Init();
@ -120,7 +120,18 @@ void main(void)
# ifdef WOLFCRYPT_BENCHMARK
wolfBoot_printf("\nRunning wolfCrypt benchmarks...\n");
#if 1
benchmark_test(NULL);
#else
{
word32 bs;
for (bs = BENCH_SIZE_EMBEDDED; bs >= 16; bs >>= 1) {
wolfBoot_printf("\n");
benchmark_configure(bs);
benchmark_test(NULL);
}
}
#endif
wolfBoot_printf("Benchmarks complete.\n\n");
# endif

View File

@ -192,8 +192,8 @@
return (uint64_t)csr_read(time);
#endif
}
#elif defined(TARGET_ti_am64x)
#define RTI_RTIFRC0 0x0e080010ul /* free running counter at 1000 Hz */
#elif defined(TARGET_ti_am64x_r5)
extern uint64_t ClockP_getTimeUsec(void);
#else
/* Simple tick counter fallback */
static volatile unsigned int tick_counter = 0;
@ -246,8 +246,8 @@ unsigned long my_time(unsigned long* timer)
}
#elif defined(TARGET_mpfs250)
unsigned long t = (unsigned long)(mpfs_get_ticks() / RISCV_SMODE_TIMER_FREQ);
#elif defined(TARGET_ti_am64x)
unsigned long t = (unsigned long)(*((volatile uint32_t *)RTI_RTIFRC0) / 1000);
#elif defined(TARGET_ti_am64x_r5)
unsigned long t = (unsigned long)(ClockP_getTimeUsec() / 1000000);
if (timer) *timer = t;
return t;
#else
@ -302,9 +302,9 @@ double current_time(int reset)
if (reset)
mpfs_start_ticks = mpfs_get_ticks();
return (double)(mpfs_get_ticks() - mpfs_start_ticks) / (double)RISCV_SMODE_TIMER_FREQ;
#elif defined(TARGET_ti_am64x)
#elif defined(TARGET_ti_am64x_r5)
(void)reset;
return (double)*((volatile uint32_t *)RTI_RTIFRC0) / 1000.0;
return (double)(ClockP_getTimeUsec()) / 1000000.0;
#else
/* Simple counter-based timing */
if (reset)