-
Notifications
You must be signed in to change notification settings - Fork 207
Add TI LAUNCHXL-F28P55X (C2000 C28x) bare-metal wolfCrypt example #576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dgarske
wants to merge
2
commits into
wolfSSL:master
Choose a base branch
from
dgarske:ti_c25
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| out/ | ||
| *.obj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /* 28p55x_wolf_flash_lnk.cmd | ||
| * | ||
| * Linker command file for the wolfCrypt test/benchmark on the | ||
| * TI LAUNCHXL-F28P55X (TMS320F28P550SJ), running from flash. EABI only | ||
| * (build driverlib and this project with --abi=eabi). | ||
| * | ||
| * Differs from the stock C2000Ware generic flash linker in three ways that | ||
| * the ML-DSA-87 verify path requires: | ||
| * - A large STACK in low RAM. The C28x stack pointer is 16-bit, so the | ||
| * stack must live below 0x10000. RAMLS0-7 (0x8000..0xBFFF, 16 KW) is the | ||
| * largest contiguous low block; the verify key struct (~7 KW pinned by | ||
| * WOLFSSL_MLDSA_VERIFY_NO_MALLOC) plus Keccak frames live here. | ||
| * - A real heap (.sysmem) in low RAMGS0-1 for the test/benchmark malloc | ||
| * temporaries (ML-DSA verify itself allocates nothing). | ||
| * - .bss/.data placed in the high RAMGS2-3 + RAMLS8-9 blocks so they do not | ||
| * compete with the stack for low RAM. | ||
| * | ||
| * Copyright (C) 2006-2026 wolfSSL Inc. GPLv3 - see project headers. | ||
| */ | ||
|
|
||
| -stack 0x4000 /* 16 KW C28x stack (full RAMLS0-7); wolfcrypt_test's deep call | ||
| * chain + SHAKE/large-hash locals (~1.6 KW) need the headroom */ | ||
| -heap 0x2000 /* 8 KW heap (RAMGS1); RAMGS0 now hosts RAM-resident hot code. | ||
| * ML-DSA verify uses no heap; test/benchmark temporaries fit. */ | ||
|
|
||
| MEMORY | ||
| { | ||
| BEGIN : origin = 0x080000, length = 0x000002 | ||
|
|
||
| BOOT_RSVD : origin = 0x000002, length = 0x000126 /* M0, used by boot ROM stack */ | ||
| RAMM0 : origin = 0x000128, length = 0x0002D8 | ||
| RAMM1 : origin = 0x000400, length = 0x000400 | ||
|
|
||
| /* Low RAM (< 0x10000): usable for the 16-bit-SP stack and the heap. */ | ||
| RAMLS_STACK : origin = 0x008000, length = 0x004000 /* RAMLS0-7, 16 KW */ | ||
| /* RAMGS0 hosts RAM-resident hot code (.TI.ramfunc), RAMGS1 the heap. At | ||
| * 150 MHz the flash has wait states; running the Keccak permutation and the | ||
| * ML-DSA NTTs from RAM removes the instruction-fetch stalls. */ | ||
| RAMGS_RAMCODE : origin = 0x00C000, length = 0x002000 /* RAMGS0, 8 KW */ | ||
| RAMGS_HEAP : origin = 0x00E000, length = 0x002000 /* RAMGS1, 8 KW */ | ||
|
|
||
| /* High RAM (>= 0x10000): data only (no stack). */ | ||
| RAMGS_HI : origin = 0x010000, length = 0x004000 /* RAMGS2-3, 16 KW */ | ||
| RAMLS_HI : origin = 0x014000, length = 0x004000 /* RAMLS8-9, 16 KW */ | ||
|
|
||
| /* Flash banks (ML-DSA verify code + const test vectors are large). */ | ||
| FLASH_BANK0 : origin = 0x080002, length = 0x01FFFE | ||
| FLASH_BANK1 : origin = 0x0A0000, length = 0x020000 | ||
| FLASH_BANK2 : origin = 0x0C0000, length = 0x020000 | ||
| FLASH_BANK3 : origin = 0x0E0000, length = 0x020000 | ||
| FLASH_BANK4 : origin = 0x100000, length = 0x008000 | ||
|
|
||
| RESET : origin = 0x3FFFC0, length = 0x000002 | ||
| } | ||
|
|
||
| SECTIONS | ||
| { | ||
| codestart : > BEGIN | ||
| /* Hot crypto relocated to RAM (loaded from flash, copied by Device_init's | ||
| * Ramfuncs memcpy). Listed before .text so these subsections are claimed | ||
| * here, not by the generic .text below. --gen_func_subsections=on makes | ||
| * each function its own .text:<name> input section. */ | ||
| .TI.ramfunc : { sha3.obj(.text:BlockSha3) | ||
| wc_mldsa.obj(.text:mldsa_ntt_c) | ||
| wc_mldsa.obj(.text:mldsa_invntt_c) | ||
| wc_mldsa.obj(.text:mldsa_ntt_small_c) } | ||
| LOAD = FLASH_BANK0, | ||
| RUN = RAMGS_RAMCODE, | ||
| LOAD_START(RamfuncsLoadStart), | ||
| LOAD_SIZE(RamfuncsLoadSize), | ||
| LOAD_END(RamfuncsLoadEnd), | ||
| RUN_START(RamfuncsRunStart), | ||
| RUN_SIZE(RamfuncsRunSize), | ||
| RUN_END(RamfuncsRunEnd), | ||
| ALIGN(8) | ||
| .text : >> FLASH_BANK0 | FLASH_BANK1 | FLASH_BANK2 | FLASH_BANK3 | FLASH_BANK4, ALIGN(8) | ||
| .cinit : > FLASH_BANK0 | FLASH_BANK1 | FLASH_BANK2 | FLASH_BANK3 | FLASH_BANK4, ALIGN(8) | ||
| .switch : > FLASH_BANK0 | FLASH_BANK1 | FLASH_BANK2 | FLASH_BANK3 | FLASH_BANK4, ALIGN(8) | ||
| .reset : > RESET, TYPE = DSECT /* unused */ | ||
|
|
||
| .stack : > RAMLS_STACK | ||
|
|
||
| .bss : >> RAMGS_HI | RAMLS_HI | ||
| .bss:output : > RAMGS_HI | ||
| .init_array : > FLASH_BANK0 | FLASH_BANK1 | FLASH_BANK2 | FLASH_BANK3 | FLASH_BANK4, ALIGN(8) | ||
| .const : >> FLASH_BANK0 | FLASH_BANK1 | FLASH_BANK2 | FLASH_BANK3 | FLASH_BANK4, ALIGN(8) | ||
| .data : >> RAMGS_HI | RAMLS_HI | ||
| .sysmem : > RAMGS_HEAP | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* 28p55x_wolf_sign_lnk.cmd | ||
| * | ||
| * Linker command file for the FULL ML-DSA-87 (keygen + sign + verify) build of | ||
| * the wolfCrypt example on the TI LAUNCHXL-F28P55X (TMS320F28P550SJ), running | ||
| * from flash. EABI only. Selected by `make SIGN=1`. | ||
| * | ||
| * ML-DSA-87 keygen/sign/verify need a much larger heap than the verify-only | ||
| * build. Even with every small-memory path enabled the peak is ~30 KW in a | ||
| * single allocation, so this script dedicates the whole contiguous RAMGS0-3 | ||
| * block (32 KW) to the heap (.sysmem). The stack stays in low RAMLS0-7 (the | ||
| * 16-bit SP needs RAM < 0x10000) and .bss/.data live in RAMLS8-9. The full | ||
| * wolfcrypt test/benchmark are NOT built in this mode (they would not fit | ||
| * alongside the 32 KW heap), so .bss is small. | ||
| * | ||
| * Copyright (C) 2006-2026 wolfSSL Inc. GPLv3 - see project headers. | ||
| */ | ||
|
|
||
| -stack 0x3000 /* 12 KW C28x stack (< 0x10000); big arrays go to heap via | ||
| * WOLFSSL_SMALL_STACK */ | ||
| -heap 0x7E00 /* ~31.5 KW heap - ML-DSA-87 keygen/sign peak ~30.5 KW */ | ||
|
|
||
| MEMORY | ||
| { | ||
| BEGIN : origin = 0x080000, length = 0x000002 | ||
|
|
||
| BOOT_RSVD : origin = 0x000002, length = 0x000126 /* M0, used by boot ROM stack */ | ||
| RAMM0 : origin = 0x000128, length = 0x0002D8 | ||
| RAMM1 : origin = 0x000400, length = 0x000400 | ||
|
|
||
| /* Low RAM (< 0x10000): the 16-bit-SP stack (12 KW), plus 4 KW of RAM- | ||
| * resident hot code carved from the top of RAMLS0-7. The stack only uses | ||
| * 0x3000, so 0xB000..0xBFFF is free for the Keccak permutation. */ | ||
| RAMLS_STACK : origin = 0x008000, length = 0x003000 /* RAMLS0-5, 12 KW */ | ||
| RAMLS_RAMCODE : origin = 0x00B000, length = 0x001000 /* RAMLS6-7, 4 KW */ | ||
|
|
||
| /* RAMGS0-3 is one contiguous 32 KW block (0xC000..0x13FFF): the heap. */ | ||
| RAMGS_BIG : origin = 0x00C000, length = 0x008000 /* RAMGS0-3, 32 KW */ | ||
|
|
||
| /* High RAM: .bss/.data (no stack here). */ | ||
| RAMLS_HI : origin = 0x014000, length = 0x004000 /* RAMLS8-9, 16 KW */ | ||
|
|
||
| /* Flash banks (ML-DSA sign code is large). */ | ||
| FLASH_BANK0 : origin = 0x080002, length = 0x01FFFE | ||
| FLASH_BANK1 : origin = 0x0A0000, length = 0x020000 | ||
| FLASH_BANK2 : origin = 0x0C0000, length = 0x020000 | ||
| FLASH_BANK3 : origin = 0x0E0000, length = 0x020000 | ||
| FLASH_BANK4 : origin = 0x100000, length = 0x008000 | ||
|
|
||
| RESET : origin = 0x3FFFC0, length = 0x000002 | ||
| } | ||
|
|
||
| SECTIONS | ||
| { | ||
| codestart : > BEGIN | ||
| .text : >> FLASH_BANK0 | FLASH_BANK1 | FLASH_BANK2 | FLASH_BANK3, ALIGN(8) | ||
| .cinit : > FLASH_BANK0, ALIGN(8) | ||
| .switch : > FLASH_BANK0, ALIGN(8) | ||
| .reset : > RESET, TYPE = DSECT /* unused */ | ||
|
|
||
| .stack : > RAMLS_STACK | ||
|
|
||
| .bss : > RAMLS_HI | ||
| .bss:output : > RAMLS_HI | ||
| .init_array : > FLASH_BANK0, ALIGN(8) | ||
| .const : >> FLASH_BANK0 | FLASH_BANK1, ALIGN(8) | ||
| .data : > RAMLS_HI | ||
| .sysmem : > RAMGS_BIG | ||
|
|
||
| .TI.ramfunc : { sha3.obj(.text:BlockSha3) } | ||
| LOAD = FLASH_BANK0, | ||
| RUN = RAMLS_RAMCODE, | ||
| LOAD_START(RamfuncsLoadStart), | ||
| LOAD_SIZE(RamfuncsLoadSize), | ||
| LOAD_END(RamfuncsLoadEnd), | ||
| RUN_START(RamfuncsRunStart), | ||
| RUN_SIZE(RamfuncsRunSize), | ||
| RUN_END(RamfuncsRunEnd), | ||
| ALIGN(8) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* ecc_p256_kat.h - deterministic ECDSA P-256 (SECP256R1) known-answer vector. | ||
| * | ||
| * Source: RFC 6979 Appendix A.2.5 (P-256), message "sample", hash SHA-256. | ||
| * Used for an RNG-free verify KAT on the TI C2000 C28x bring-up. | ||
| * | ||
| * Brace-init byte arrays (NOT "\x.." string literals): on cl2000 a char[]/byte[] | ||
| * initialized from a "\x.." string sign-extends bytes >= 0x80 into the 16-bit | ||
| * cell; a brace-init list stores clean octets. | ||
| */ | ||
| #ifndef ECC_P256_KAT_H | ||
| #define ECC_P256_KAT_H | ||
|
|
||
| /* Public key Q = (Ux, Uy), 32 bytes each, big-endian. */ | ||
| static const unsigned char kat_p256_qx[32] = { | ||
| 0x60,0xFE,0xD4,0xBA,0x25,0x5A,0x9D,0x31,0xC9,0x61,0xEB,0x74,0xC6,0x35,0x6D,0x68, | ||
| 0xC0,0x49,0xB8,0x92,0x3B,0x61,0xFA,0x6C,0xE6,0x69,0x62,0x2E,0x60,0xF2,0x9F,0xB6 | ||
| }; | ||
| static const unsigned char kat_p256_qy[32] = { | ||
| 0x79,0x03,0xFE,0x10,0x08,0xB8,0xBC,0x99,0xA4,0x1A,0xE9,0xE9,0x56,0x28,0xBC,0x64, | ||
| 0xF2,0xF1,0xB2,0x0C,0x2D,0x7E,0x9F,0x51,0x77,0xA3,0xC2,0x94,0xD4,0x46,0x22,0x99 | ||
| }; | ||
|
|
||
| /* SHA-256("sample") - the message digest that was signed. */ | ||
| static const unsigned char kat_p256_hash[32] = { | ||
| 0xAF,0x2B,0xDB,0xE1,0xAA,0x9B,0x6E,0xC1,0xE2,0xAD,0xE1,0xD6,0x94,0xF4,0x1F,0xC7, | ||
| 0x1A,0x83,0x1D,0x02,0x68,0xE9,0x89,0x15,0x62,0x11,0x3D,0x8A,0x62,0xAD,0xD1,0xBF | ||
| }; | ||
|
|
||
| /* Signature (r, s), 32 bytes each, big-endian. */ | ||
| static const unsigned char kat_p256_r[32] = { | ||
| 0xEF,0xD4,0x8B,0x2A,0xAC,0xB6,0xA8,0xFD,0x11,0x40,0xDD,0x9C,0xD4,0x5E,0x81,0xD6, | ||
| 0x9D,0x2C,0x87,0x7B,0x56,0xAA,0xF9,0x91,0xC3,0x4D,0x0E,0xA8,0x4E,0xAF,0x37,0x16 | ||
| }; | ||
| static const unsigned char kat_p256_s[32] = { | ||
| 0xF7,0xCB,0x1C,0x94,0x2D,0x65,0x7C,0x41,0xD4,0x36,0xC7,0xA1,0xB6,0xE2,0x9F,0x65, | ||
| 0xF3,0xE9,0x00,0xDB,0xB9,0xAF,0xF4,0x06,0x4D,0xC4,0xAB,0x2F,0x84,0x3A,0xCD,0xA8 | ||
| }; | ||
|
|
||
| #endif /* ECC_P256_KAT_H */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.