Skip to content

MAX32666 bare-metal SHA accelerator#10431

Merged
dgarske merged 9 commits into
wolfSSL:masterfrom
mattia-moffa:20260330-max32666-sha-bare-metal
Jun 5, 2026
Merged

MAX32666 bare-metal SHA accelerator#10431
dgarske merged 9 commits into
wolfSSL:masterfrom
mattia-moffa:20260330-max32666-sha-bare-metal

Conversation

@mattia-moffa

@mattia-moffa mattia-moffa commented May 8, 2026

Copy link
Copy Markdown
Member

Description

Implements the SHA accelerator for MAX32666 as bare-metal, replacing the previous SDK-based one, which only supported one-shot hashing. This is needed to hash big firmwares in wolfBoot without taking up too much RAM.

Also has a fix for F#3076

Testing

Temporary test firmware: https://moffa.xyz/tmp/test_max32666.tar.gz

@mattia-moffa mattia-moffa self-assigned this May 8, 2026
Copilot AI review requested due to automatic review settings May 8, 2026 02:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the previous MAX32666 SHA (TPU) integration that relied on SDK one-shot hashing with a bare-metal, incremental (Update/Final) SHA accelerator implementation, enabling hashing of large inputs without buffering the entire message in RAM (e.g., wolfBoot firmware images).

Changes:

  • Reworked MAX3266x SHA support to use bare-metal register-level feeding of blocks and saved intermediate state, supporting incremental hashing.
  • Simplified crypto callback SHA copy/free handling and removed the prior HASH_KEEP-based message accumulation approach.
  • Updated Maxim port README to remove the previous “large hash” limitation note.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
wolfssl/wolfcrypt/port/maxim/max3266x.h Removes HASH_KEEP/empty-digest helpers and adds bare-metal TPU SHA helper APIs/state sizing constants.
wolfcrypt/src/port/maxim/README.md Removes outdated note about SDK one-shot SHA limiting large hashes.
wolfcrypt/src/port/maxim/max3266x.c Implements incremental bare-metal TPU SHA (setup/feed/save/read) and rewires SHA callbacks + per-algorithm wc_Sha* APIs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wolfcrypt/src/port/maxim/max3266x.c
Comment thread wolfcrypt/src/port/maxim/max3266x.c
Comment thread wolfcrypt/src/port/maxim/max3266x.c Outdated
Comment thread wolfcrypt/src/port/maxim/max3266x.c Outdated
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

gcc-arm-cortex-m4

  • FLASH: .rodata.pkcs8KeyASN +4 B, .rodata.wolfSSL_ERR_reason_error_string.str1.1 -3 B, .text +448 B (+0.2%, 197,934 B / 262,144 B, total: 76% used)
  • RAM: .bss +8 B (+1.0%, 836 B / 65,536 B, total: 1% used)

gcc-arm-cortex-m4-baremetal

  • FLASH: .rodata.pkcs8KeyASN +4 B, .text +832 B (+1.3%, 65,739 B / 262,144 B, total: 25% used)
  • RAM: .bss +36 B (+5.6%, 680 B / 65,536 B, total: 1% used)

gcc-arm-cortex-m4-min-ecc

  • FLASH: .rodata.pkcs8KeyASN +4 B, .text +384 B (+0.5%, 60,717 B / 262,144 B, total: 23% used)
  • RAM: .bss +8 B (+1.2%, 676 B / 65,536 B, total: 1% used)

gcc-arm-cortex-m4-tls12

@mattia-moffa

Copy link
Copy Markdown
Member Author

Jenkins retest this please

3 similar comments
@mattia-moffa

Copy link
Copy Markdown
Member Author

Jenkins retest this please

@mattia-moffa

Copy link
Copy Markdown
Member Author

Jenkins retest this please

@mattia-moffa

Copy link
Copy Markdown
Member Author

Jenkins retest this please

@mattia-moffa mattia-moffa force-pushed the 20260330-max32666-sha-bare-metal branch from 2e30019 to c9a534a Compare May 19, 2026 22:26
@mattia-moffa

Copy link
Copy Markdown
Member Author

Jenkins retest this please

@mattia-moffa

Copy link
Copy Markdown
Member Author

Jenkins retest this please

night1rider
night1rider previously approved these changes May 26, 2026

@night1rider night1rider left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally on hardware, no issues

@night1rider night1rider left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does seem there is a performance regression.

  • older code gave:
SHA                          6 MiB took 1.000 seconds,    6.247 MiB/s
SHA-224                      2 MiB took 0.319 seconds,    6.656 MiB/s
SHA-256                      7 MiB took 1.004 seconds,    6.663 MiB/s
SHA-384                      7 MiB took 1.004 seconds,    6.663 MiB/s
SHA-512                      7 MiB took 1.004 seconds,    6.663 MiB/s
  • Newer Code Gives:
SHA                          5 MiB took 1.005 seconds,    4.543 MiB/s
SHA-224                      5 MiB took 1.005 seconds,    4.543 MiB/s
SHA-256                      5 MiB took 0.994 seconds,    4.543 MiB/s
SHA-384                      5 MiB took 1.005 seconds,    4.543 MiB/s
SHA-512                      5 MiB took 1.005 seconds,    4.543 MiB/s

I understand the older code buffered the entire message into memory, and then preformed the digest on the entire message.

Not sure it makes sense to have a option to return that older behavior as this refactor is more efficient overall than an accumulate and one shot.

@dgarske dgarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a build option to support the old caching option (off by default).

@mattia-moffa

Copy link
Copy Markdown
Member Author

Jenkins retest this please

@mattia-moffa

Copy link
Copy Markdown
Member Author

Jenkins retest this please

@mattia-moffa mattia-moffa requested a review from dgarske June 5, 2026 00:38
@mattia-moffa mattia-moffa removed their assignment Jun 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread wolfcrypt/src/port/maxim/max3266x.c
@night1rider night1rider self-assigned this Jun 5, 2026
@douzzer douzzer added the Staged Staged for merge pending final test results and review label Jun 5, 2026

@night1rider night1rider left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works and new define returns older performance

@night1rider night1rider removed their assignment Jun 5, 2026
@dgarske dgarske merged commit f9817cf into wolfSSL:master Jun 5, 2026
478 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Staged Staged for merge pending final test results and review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants