Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 178 additions & 3 deletions .github/membrowse-targets.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions .github/scripts/zephyr-4.x/zephyr-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ LOG_DIR="${SCRIPT_DIR}/logs"
mkdir -p "${LOG_DIR}"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
LOG_FILE="${LOG_DIR}/${BOARD_SLUG}_${TIMESTAMP}.log"
ARTIFACTS_DIR="${SCRIPT_DIR}/artifacts/${BOARD_SLUG}-${SAMPLE_NAME}"
mkdir -p "${ARTIFACTS_DIR}"
chmod 0755 "${ARTIFACTS_DIR}"

echo "==> wolfSSL repo: ${WOLFSSL_REPO}"
echo "==> wolfSSL branch: ${WOLFSSL_BRANCH}"
Expand Down Expand Up @@ -256,6 +259,23 @@ else
echo ""
echo "==> [container] Build succeeded!"

# Stage Membrowse-relevant artifacts on the host-mounted volume.
# /artifacts is bind-mounted by the host wrapper; if it isn't writable
# (e.g. interactive runs without the mount), skip silently.
if [[ -d /artifacts && -w /artifacts ]]; then
BUILD_OUT="${WORKDIR}/zephyrproject/build/zephyr"
if [[ -f "${BUILD_OUT}/zephyr.elf" ]]; then
cp "${BUILD_OUT}/zephyr.elf" /artifacts/zephyr.elf
fi
if [[ -f "${BUILD_OUT}/linker.cmd" ]]; then
cp "${BUILD_OUT}/linker.cmd" /artifacts/linker.cmd
fi
# Map file enables Membrowse library/object attribution
if [[ -f "${BUILD_OUT}/zephyr.map" ]]; then
cp "${BUILD_OUT}/zephyr.map" /artifacts/zephyr.map
fi
fi

# Run the app for emulator targets and watch for completion
case "${BOARD_TARGET}" in
native_sim*|qemu_*)
Expand Down Expand Up @@ -342,6 +362,7 @@ docker rm -f "${CONTAINER_NAME}" 2>/dev/null || true
DOCKER_ARGS=(
--name "${CONTAINER_NAME}"
--rm
-v "${ARTIFACTS_DIR}:/artifacts"
)

if [[ "$INTERACTIVE" == "1" ]]; then
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/membrowse-onboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
needs: load-targets
if: github.repository_owner == 'wolfssl'
runs-on: ubuntu-24.04
timeout-minutes: 10
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
Expand All @@ -47,6 +47,7 @@ jobs:
uses: ./.github/actions/install-apt-deps
with:
packages: ${{ matrix.apt_packages }}
cache: ${{ matrix.apt_cache || 'true' }}

- name: Run Membrowse Onboard Action
uses: membrowse/membrowse-action/onboard-action@v1
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/membrowse-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
needs: [load-targets, check-changes]
if: github.repository_owner == 'wolfssl' && (github.event_name != 'pull_request' || needs.check-changes.outputs.needs_build == 'true')
runs-on: ubuntu-24.04
timeout-minutes: 10
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
Expand All @@ -86,6 +86,7 @@ jobs:
uses: ./.github/actions/install-apt-deps
with:
packages: ${{ matrix.apt_packages }}
cache: ${{ matrix.apt_cache || 'true' }}

- name: Build firmware
if: needs.check-changes.outputs.needs_build == 'true'
Expand Down
115 changes: 115 additions & 0 deletions .github/workflows/membrowse-zephyr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Membrowse Zephyr Report

# Triggered after the heavy Zephyr 4.x test workflow completes. Pulls the
# pre-built zephyr.elf, zephyr.map and linker.cmd artifacts staged by
# zephyr-test.sh and feeds them to the Membrowse memory-tracking service.
# This avoids duplicating the (slow) Zephyr build inside the Membrowse
# matrix.

on:
workflow_run:
workflows: [Zephyr 4.x tests]
types:
- completed

concurrency:
group: ${{ github.workflow }}-${{ github.event.workflow_run.head_sha }}
cancel-in-progress: true

jobs:
analyze:
runs-on: ubuntu-24.04
timeout-minutes: 10
# Only run from the wolfssl org to avoid burning forks' CI minutes
# and reporting fork builds to the membrowse backend.
if: >
github.event.workflow_run.conclusion == 'success' &&
github.repository_owner == 'wolfssl'
permissions:
contents: read
actions: read
strategy:
fail-fast: false
matrix:
include:
- target_name: zephyr-native_sim
artifact: membrowse-zephyr-native_sim
- target_name: zephyr-frdm_rw612
artifact: membrowse-zephyr-frdm_rw612
Comment thread
LinuxJedi marked this conversation as resolved.
steps:
# Check out the commit the Zephyr workflow actually built so Membrowse
# attributes the report to the right commit. Only the last 2 commits
# are needed (current + parent) to resolve the base for comparison.
- name: Checkout repository
uses: actions/checkout@v5
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 2

- name: Download Zephyr build artifact
id: download
uses: actions/download-artifact@v4
with:
name: ${{ matrix.artifact }}
path: zephyr-artifacts/${{ matrix.target_name }}
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true

- name: Verify artifact present
id: verify
run: |
ELF="zephyr-artifacts/${{ matrix.target_name }}/zephyr.elf"
LD="zephyr-artifacts/${{ matrix.target_name }}/linker.cmd"
MAP="zephyr-artifacts/${{ matrix.target_name }}/zephyr.map"
if [[ -f "$ELF" && -f "$LD" ]]; then
echo "have_artifacts=true" >> "$GITHUB_OUTPUT"
else
echo "have_artifacts=false" >> "$GITHUB_OUTPUT"
echo "::warning::Membrowse artifact for ${{ matrix.target_name }} not found; the matching cell of zephyr-4.x.yml may have been skipped or excluded."
fi
# The map file is optional; it enables library/object attribution.
if [[ -f "$MAP" ]]; then
echo "map_file=$MAP" >> "$GITHUB_OUTPUT"
else
echo "map_file=" >> "$GITHUB_OUTPUT"
fi

- name: Run Membrowse PR Action
if: steps.verify.outputs.have_artifacts == 'true'
uses: membrowse/membrowse-action@v1
with:
target_name: ${{ matrix.target_name }}
elf: zephyr-artifacts/${{ matrix.target_name }}/zephyr.elf
ld: zephyr-artifacts/${{ matrix.target_name }}/linker.cmd
map_file: ${{ steps.verify.outputs.map_file }}
linker_vars: ""
api_key: ${{ secrets.MEMBROWSE_API_KEY }}
api_url: ${{ vars.MEMBROWSE_API_URL }}
verbose: INFO

# Refresh the consolidated Membrowse PR comment after the Zephyr targets
# have been submitted, mirroring membrowse-comment.yml.
post-comment:
needs: analyze
runs-on: ubuntu-24.04
timeout-minutes: 10
if: >
github.event.workflow_run.event == 'pull_request' &&
github.repository_owner == 'wolfssl'
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Post Membrowse PR comment
if: ${{ env.MEMBROWSE_API_KEY != '' }}
uses: membrowse/membrowse-action/comment-action@v1
with:
api_key: ${{ secrets.MEMBROWSE_API_KEY }}
commit: ${{ github.event.workflow_run.head_sha }}
env:
MEMBROWSE_API_KEY: ${{ secrets.MEMBROWSE_API_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/zephyr-4.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,22 @@ jobs:
path: .github/scripts/zephyr-4.x/logs/
retention-days: 5
if-no-files-found: ignore

# Stage Membrowse artifacts only for the cells we want to track on the
# Membrowse dashboard. Keep this tight to avoid duplicate target_name
# entries on the dashboard and unnecessary artifact uploads.
- name: Upload Membrowse artifacts (selected cells only)
if: >
success() &&
matrix.zephyr-ref == 'v4.3.0' &&
matrix.sample == 'wolfssl_test' &&
matrix.extra-conf == ''
uses: actions/upload-artifact@v4
with:
name: membrowse-zephyr-${{ matrix.board == 'native_sim' && 'native_sim' || 'frdm_rw612' }}
path: |
.github/scripts/zephyr-4.x/artifacts/${{ matrix.board == 'native_sim' && 'native_sim' || 'frdm_rw612-rw612' }}-wolfssl_test/zephyr.elf
.github/scripts/zephyr-4.x/artifacts/${{ matrix.board == 'native_sim' && 'native_sim' || 'frdm_rw612-rw612' }}-wolfssl_test/linker.cmd
.github/scripts/zephyr-4.x/artifacts/${{ matrix.board == 'native_sim' && 'native_sim' || 'frdm_rw612-rw612' }}-wolfssl_test/zephyr.map
if-no-files-found: warn
retention-days: 1
5 changes: 2 additions & 3 deletions IDE/GCC-ARM/Header/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,10 @@ extern "C" {
/* Override Current Time */
/* Allows custom "custom_time()" function to be used for benchmark */
#define WOLFSSL_USER_CURRTIME
#define WOLFSSL_GMTIME
#define TIME_OVERRIDES
#define USER_TICKS
extern unsigned long my_time(unsigned long* timer);
#define XTIME my_time
#define XGMTIME my_gmtime


/* ------------------------------------------------------------------------- */
Expand Down Expand Up @@ -656,4 +656,3 @@ extern unsigned int my_rng_seed_gen(void);
#endif

#endif /* WOLFSSL_USER_SETTINGS_H */

5 changes: 5 additions & 0 deletions IDE/GCC-ARM/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ SRC_C += ../../src/sniffer.c
SRC_C += ../../src/ssl.c
SRC_C += ../../src/tls.c
SRC_C += ../../src/tls13.c
SRC_C += ../../src/dtls.c
SRC_C += ../../src/dtls13.c
SRC_C += ../../src/wolfio.c

# wolfCrypt Core (FIPS)
Expand Down Expand Up @@ -185,6 +187,9 @@ SRC_C += ../../wolfcrypt/src/dsa.c
SRC_C += ../../wolfcrypt/src/md2.c
SRC_C += ../../wolfcrypt/src/md4.c
SRC_C += ../../wolfcrypt/src/ripemd.c
SRC_C += ../../wolfcrypt/src/wc_mldsa.c
SRC_C += ../../wolfcrypt/src/wc_mlkem.c
SRC_C += ../../wolfcrypt/src/wc_mlkem_poly.c


FILENAMES_C = $(notdir $(SRC_C))
Expand Down
97 changes: 91 additions & 6 deletions IDE/GCC-ARM/Source/wolf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#ifdef NO_ASN_TIME
#include <time.h>
#endif


/* TIME CODE */
Expand All @@ -37,21 +40,103 @@ static int hw_get_time_sec(void)
{
#warning Must implement your own time source if validating certificates

return ++gTimeMs;
return ++gTimeMs;
}

static int IsLeapYear(int year)
{
return ((year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0));
}

/* This is used by wolfCrypt asn.c for cert time checking */
unsigned long my_time(unsigned long* timer)
time_t my_time(time_t* timer)
{
(void)timer;
return hw_get_time_sec();
time_t curTime = (time_t)hw_get_time_sec();

if (timer != NULL) {
*timer = curTime;
}

return curTime;
}

struct tm* my_gmtime(const time_t* timer, struct tm* tmp)
{
static struct tm staticTime;
static const unsigned char daysPerMonth[] =
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
time_t curTime;
long days;
long rem;
int year;
int yearDays;
int month;
int monthDays;

if (tmp == NULL) {
tmp = &staticTime;
}

curTime = (timer != NULL) ? *timer : my_time(NULL);
if (curTime < 0) {
curTime = 0;
}

days = (long)(curTime / 86400);
rem = (long)(curTime % 86400);

tmp->tm_hour = (int)(rem / 3600);
rem %= 3600;
tmp->tm_min = (int)(rem / 60);
tmp->tm_sec = (int)(rem % 60);
tmp->tm_wday = (int)((days + 4) % 7);

year = 1970;
while (1) {
yearDays = IsLeapYear(year) ? 366 : 365;
if (days < yearDays) {
break;
}
days -= yearDays;
year++;
}

tmp->tm_year = year - 1900;
tmp->tm_yday = (int)days;

for (month = 0; month < 12; month++) {
monthDays = daysPerMonth[month];
if (month == 1 && IsLeapYear(year)) {
monthDays++;
}
if (days < monthDays) {
break;
}
days -= monthDays;
}

tmp->tm_mon = month;
tmp->tm_mday = (int)days + 1;
tmp->tm_isdst = 0;

return tmp;
}

#ifndef WOLFCRYPT_ONLY
/* This is used by TLS only */
unsigned int LowResTimer(void)
word32 LowResTimer(void)
{
return (word32)hw_get_time_sec();
}

/* This is used by TLS 1.3 ticket and PSK timeouts. */
#ifdef WOLFSSL_32BIT_MILLI_TIME
word32 TimeNowInMilliseconds(void)
#else
sword64 TimeNowInMilliseconds(void)
#endif
{
return hw_get_time_sec();
return (sword64)my_time(NULL) * 1000;
}
#endif

Expand Down
1 change: 1 addition & 0 deletions IDE/GCC-ARM/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ EXTRA_DIST+= IDE/GCC-ARM/Source/test_main.c
EXTRA_DIST+= IDE/GCC-ARM/Source/tls_client.c
EXTRA_DIST+= IDE/GCC-ARM/Source/tls_server.c
EXTRA_DIST+= IDE/GCC-ARM/linker.ld
EXTRA_DIST+= IDE/GCC-ARM/linker_large.ld
EXTRA_DIST+= IDE/GCC-ARM/linker_fips.ld
EXTRA_DIST+= IDE/GCC-ARM/Makefile
EXTRA_DIST+= IDE/GCC-ARM/Makefile.bench
Expand Down
Loading
Loading