Skip to content

Commit

Permalink
- support for wolfHSM ML-DSA on simulator and AURIX (DMA only)
Browse files Browse the repository at this point in the history
- consolidate AURIX scripts into wbaurixtool.sh
  • Loading branch information
bigbrett committed Dec 3, 2024
1 parent 6d1adc2 commit 8c130a2
Show file tree
Hide file tree
Showing 30 changed files with 3,349 additions and 111 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ IDE/AURIX/Configurations/*
!IDE/AURIX/Configurations/placeholder.txt
IDE/AURIX/wolfHSM-infineon-tc3xx/*
!IDE/AURIX/wolfHSM-infineon-tc3xx/placeholder.txt
IDE/AURIX/wolfBoot-tc3xx/wolfBoot_macros.txt
IDE/AURIX/wolfBoot-tc3xx-wolfHSM/wolfBoot_macros.txt
IDE/AURIX/test-app/Lcf_Gnuc_Tricore_Tc.lsl
IDE/AURIX/test-app-wolfHSM/Lcf_Gnuc_Tricore_Tc.lsl

tpm_seal_key.key

Expand Down
68 changes: 54 additions & 14 deletions IDE/AURIX/README.md

Large diffs are not rendered by default.

611 changes: 611 additions & 0 deletions IDE/AURIX/test-app-wolfHSM/.cproject

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions IDE/AURIX/test-app-wolfHSM/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>test-app-wolfHSM</name>
<comment></comment>
<projects>
<project>wolfBoot-tc3xx-wolfHSM</project>
</projects>
<buildSpec>
<buildCommand>
<name>com.infineon.aurix.buildsystem.builders.booster</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.infineon.aurix.buildsystem.builders.autodiscovery</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>com.infineon.aurix.buildsystem.aurixnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
<linkedResources>
<link>
<name>Configurations</name>
<type>2</type>
<locationURI>SDK_CONFIGURATION_DIR</locationURI>
</link>
<link>
<name>Libraries</name>
<type>2</type>
<locationURI>SDK_DIR</locationURI>
</link>
</linkedResources>
<variableList>
<variable>
<name>SDK_CONFIGURATION_DIR</name>
<value>$%7BPARENT-1-PROJECT_LOC%7D/Configurations</value>
</variable>
<variable>
<name>SDK_DIR</name>
<value>$%7BPARENT-1-PROJECT_LOC%7D/SDK</value>
</variable>
</variableList>
</projectDescription>
83 changes: 83 additions & 0 deletions IDE/AURIX/test-app-wolfHSM/Cpu0_Main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* Cpu0_Main.c
*
* Copyright (C) 2014-2024 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 wolfBoot. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Bsp.h"
#include "IfxCpu.h"
#include "IfxPort.h"
#include "IfxScuWdt.h"
#include "Ifx_Types.h"
#include "wolfboot/wolfboot.h"

IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;


#define LED &MODULE_P00, 5 /* LED: Port, Pin definition */
#define BLINK_TIME_BASE 500 /* Wait time constant in milliseconds */
#define BLINK_TIME_UPDATE 100 /* Wait time constant in milliseconds */

#define BASE_FW_VERSION 1

/* This function initializes the port pin which drives the LED */
static void initLED(void)
{
/* Initialization of the LED used in this example */
IfxPort_setPinModeOutput(LED,
IfxPort_OutputMode_pushPull,
IfxPort_OutputIdx_general);

/* Switch OFF the LED (low-level active) */
IfxPort_setPinLow(LED);
}

void core0_main(void)
{
size_t blinkTime;

IfxCpu_enableInterrupts();

/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
* Enable the watchdogs and service them periodically if it is required
*/
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());

/* Wait for CPU sync event */
IfxCpu_emitEvent(&g_cpuSyncEvent);
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);

initLED();

if (wolfBoot_current_firmware_version() <= BASE_FW_VERSION) {
/* We are booting into the base firmware, so stage the update and set
* the LED to blink slow */
wolfBoot_update_trigger();
blinkTime = BLINK_TIME_BASE;
}
else {
/* we are booting into the updated firmware so acknowledge the update
* (to prevent rollback) and set the LED to blink fast */
wolfBoot_success();
blinkTime = BLINK_TIME_UPDATE;
}

while (1) {
IfxPort_togglePin(LED);
waitTime(IfxStm_getTicksFromMilliseconds(BSP_DEFAULT_TIMER, blinkTime));
}
}
42 changes: 42 additions & 0 deletions IDE/AURIX/test-app-wolfHSM/Cpu1_Main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Cpu1_Main.c
*
* Copyright (C) 2014-2024 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 wolfBoot. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"

extern IfxCpu_syncEvent g_cpuSyncEvent;

void core1_main(void)
{
IfxCpu_enableInterrupts();

/* !!WATCHDOG1 IS DISABLED HERE!!
* Enable the watchdog and service it periodically if it is required
*/
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());

/* Wait for CPU sync event */
IfxCpu_emitEvent(&g_cpuSyncEvent);
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);

while(1)
{
}
}
42 changes: 42 additions & 0 deletions IDE/AURIX/test-app-wolfHSM/Cpu2_Main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Cpu2_Main.c
*
* Copyright (C) 2014-2024 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 wolfBoot. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"

extern IfxCpu_syncEvent g_cpuSyncEvent;

void core2_main(void)
{
IfxCpu_enableInterrupts();

/* !!WATCHDOG2 IS DISABLED HERE!!
* Enable the watchdog and service it periodically if it is required
*/
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());

/* Wait for CPU sync event */
IfxCpu_emitEvent(&g_cpuSyncEvent);
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);

while(1)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ LCF_HEAP2_OFFSET = (LCF_USTACK2_OFFSET - LCF_HEAP_SIZE);


LCF_WOLFBOOT_BOOT_PART_BASEADDR = 0xA0300000;
LCF_WOLFBOOT_HEADER_OFFSET = 0x100;

/* size of wolfBoot header, configured by aurixtool.sh based on --sign-algo */
LCF_WOLFBOOT_HEADER_OFFSET = @LCF_WOLFBOOT_HEADER_OFFSET@;

LCF_CODE_BASE_ADDR = LCF_WOLFBOOT_BOOT_PART_BASEADDR + LCF_WOLFBOOT_HEADER_OFFSET;

Expand Down Expand Up @@ -116,10 +118,10 @@ MEMORY
pfls0 (rx!p): org = 0xA0000000, len = 3M

/* placeholder for wolfBoot image header */
pfls1_hdr (rx!p): org = 0xA0300000, len = 256
pfls1_hdr (rx!p): org = LCF_WOLFBOOT_BOOT_PART_BASEADDR, len = LCF_WOLFBOOT_HEADER_OFFSET

/* pfls1 is the remainder of the wolfBoot BOOT partition. Everything goes here */
pfls1 (rx!p): org = 0xA0300100, len = 0x17DF00 /* 0x17E000 - 256B */
pfls1 (rx!p): org = LCF_CODE_BASE_ADDR, len = (0x17E000 - LCF_WOLFBOOT_HEADER_OFFSET)

/* reserved for wolfBoot UPDATE partition */
pfls1_update (rwx!p): org = 0xA047E000, len = 0x17E000 /* ~1.5MiB */
Expand Down
Loading

0 comments on commit 8c130a2

Please sign in to comment.