Skip to content

Commit

Permalink
tc3xx: fix wolfBoot-tc3xx project and wbaurixtool.sh to properly gene…
Browse files Browse the repository at this point in the history
…rate macros for non-HSM projects
  • Loading branch information
bigbrett committed Jan 8, 2025
1 parent 57d224b commit a22a9b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions IDE/AURIX/wolfBoot-tc3xx/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@
<listOptionValue builtIn="false" value="PART_BOOT_EXT"/>
<listOptionValue builtIn="false" value="WOLFBOOT_FLASH_MULTI_SECTOR_ERASE"/>
</option>
<option id="com.infineon.aurix.buildsystem.managed.tool.c.compiler.option.misc.other.1524582129" name="Other flags" superClass="com.infineon.aurix.buildsystem.managed.tool.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -mtc162" valueType="string"/>
<option id="com.infineon.aurix.buildsystem.managed.tool.c.compiler.option.misc.other.1524582129" name="Other flags" superClass="com.infineon.aurix.buildsystem.managed.tool.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-mtc162 -c -fmessage-length=0 &quot;@${workspace_loc:/${ProjName}/wolfBoot_macros.txt}&quot;" valueType="string"/>
<inputType id="com.infineon.aurix.buildsystem.managed.tool.c.compiler.inputType.1768062788" superClass="com.infineon.aurix.buildsystem.managed.tool.c.compiler.inputType"/>
</tool>
<tool id="com.infineon.aurix.buildsystem.managed.tool.cpp.compiler.937301277" name="AURIX G++ Compiler" superClass="com.infineon.aurix.buildsystem.managed.tool.cpp.compiler">
Expand Down Expand Up @@ -705,7 +705,7 @@
<listOptionValue builtIn="false" value="PART_SWAP_EXT"/>
<listOptionValue builtIn="false" value="WOLFBOOT_FLASH_MULTI_SECTOR_ERASE"/>
</option>
<option id="com.infineon.aurix.buildsystem.managed.tool.c.compiler.option.misc.other.1290904533" name="Other flags" superClass="com.infineon.aurix.buildsystem.managed.tool.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -mtc162" valueType="string"/>
<option id="com.infineon.aurix.buildsystem.managed.tool.c.compiler.option.misc.other.1290904533" name="Other flags" superClass="com.infineon.aurix.buildsystem.managed.tool.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-mtc162 -c -fmessage-length=0 &quot;@${workspace_loc:/${ProjName}/wolfBoot_macros.txt}&quot;" valueType="string"/>
<inputType id="com.infineon.aurix.buildsystem.managed.tool.c.compiler.inputType.526570406" superClass="com.infineon.aurix.buildsystem.managed.tool.c.compiler.inputType"/>
</tool>
<tool id="com.infineon.aurix.buildsystem.managed.tool.cpp.compiler.1059779057" name="AURIX G++ Compiler" superClass="com.infineon.aurix.buildsystem.managed.tool.cpp.compiler">
Expand Down
14 changes: 9 additions & 5 deletions tools/scripts/tc3xx/wbaurixtool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ WOLFBOOT_DIR="../../../"
PRVKEY_DER="$WOLFBOOT_DIR/priv.der"
PUBKEY_DER="$WOLFBOOT_DIR/priv_pub.der"
TARGET_H="$WOLFBOOT_DIR/include/target.h"
MACROS_IN="$WOLFBOOT_DIR/IDE/AURIX/wolfBoot-tc3xx-wolfHSM/wolfBoot_macros.in"
MACROS_OUT="$WOLFBOOT_DIR/IDE/AURIX/wolfBoot-tc3xx-wolfHSM/wolfBoot_macros.txt"
NVM_CONFIG="$WOLFBOOT_DIR/tools/scripts/tc3xx/wolfBoot-wolfHSM-keys.nvminit"
NVM_BIN="whNvmImage.bin"
NVM_HEX="whNvmImage.hex"
Expand Down Expand Up @@ -238,16 +236,22 @@ do_gen_target() {
# Function to clean generated files
do_clean() {
echo "Cleaning generated files"
local macros_out="$WOLFBOOT_DIR/IDE/AURIX/wolfBoot-tc3xx${HSM:+-wolfHSM}/wolfBoot_macros.txt"

rm -f "$PRVKEY_DER"
rm -f "$PUBKEY_DER"
rm -f "$TARGET_H"
rm -f "$MACROS_OUT"
rm -f "$macros_out"
rm -f "$NVM_BIN"
rm -f "$NVM_HEX"
}

# Function to generate macros
do_gen_macros() {
# Set the macros paths dynamically based on HSM flag
local macros_in="$WOLFBOOT_DIR/IDE/AURIX/wolfBoot-tc3xx${HSM:+-wolfHSM}/wolfBoot_macros.in"
local macros_out="$WOLFBOOT_DIR/IDE/AURIX/wolfBoot-tc3xx${HSM:+-wolfHSM}/wolfBoot_macros.txt"

# Use macros options first, then fall back to sign/keygen options
local sign_algo="${MACROS_OPTS[sign_algo]:-${SIGN_OPTS[sign_algo]:-${KEYGEN_OPTS[sign_algo]:-$DEFAULT_SIGN_ALGO}}}"
local hash_algo="${MACROS_OPTS[hash_algo]:-${SIGN_OPTS[hash_algo]}}"
Expand Down Expand Up @@ -314,10 +318,10 @@ do_gen_macros() {
-e "s/@ML_DSA_IMAGE_SIGNATURE_SIZE@/$ml_dsa_image_signature_size/g" \
-e "s/@WOLFBOOT_HUGE_STACK@/$use_huge_stack/g" \
-e "s/@WOLFBOOT_USE_WOLFHSM_PUBKEY_ID@/$use_wolfhsm_pubkey_id/g" \
"$MACROS_IN" > "$MACROS_OUT"
"$macros_in" > "$macros_out"

# Remove empty lines from the output file, as they cause compiler errors
sed -i '/^$/d' "$MACROS_OUT"
sed -i '/^$/d' "$macros_out"
}

# Function to generate a wolfHSM NVM image
Expand Down

0 comments on commit a22a9b1

Please sign in to comment.