Skip to content

Commit b15de3a

Browse files
authored
Merge pull request #1 from LinuxJedi/ATECC608Sim
Add ATECC608 simulator
2 parents 7458936 + 773fe70 commit b15de3a

66 files changed

Lines changed: 4666 additions & 929 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: ATECC608 SDK test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: ['**']
8+
workflow_dispatch:
9+
10+
jobs:
11+
sdk-test:
12+
name: cryptoauthlib + OpenSSL cross-verification
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: docker/setup-buildx-action@v3
18+
19+
- name: Build sdk-test image
20+
uses: docker/build-push-action@v6
21+
with:
22+
context: ATECC608Sim
23+
file: ATECC608Sim/Dockerfile.sdk-test
24+
tags: atecc608-sdk-test:ci
25+
load: true
26+
cache-from: type=gha
27+
cache-to: type=gha,mode=max
28+
29+
- name: Run sdk-test suite
30+
run: docker run --rm atecc608-sdk-test:ci
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: ATECC608 test suite
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: ['**']
8+
workflow_dispatch:
9+
10+
jobs:
11+
cargo-test:
12+
name: cargo test (unit + integration)
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: dtolnay/rust-toolchain@stable
18+
19+
- uses: Swatinem/rust-cache@v2
20+
with:
21+
workspaces: ATECC608Sim/atecc608-sim
22+
23+
- name: cargo test
24+
run: |
25+
cargo test --manifest-path ATECC608Sim/atecc608-sim/Cargo.toml \
26+
-- --test-threads=1
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: ATECC608 wolfCrypt test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: ['**']
8+
workflow_dispatch:
9+
10+
jobs:
11+
wolfcrypt-test:
12+
name: wolfCrypt + cryptoauthlib integration
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: docker/setup-buildx-action@v3
18+
19+
- name: Build wolfcrypt-test image
20+
uses: docker/build-push-action@v6
21+
with:
22+
context: ATECC608Sim
23+
file: ATECC608Sim/Dockerfile.wolfcrypt
24+
tags: atecc608-wolfcrypt-test:ci
25+
load: true
26+
cache-from: type=gha
27+
cache-to: type=gha,mode=max
28+
29+
- name: Run wolfCrypt test suite
30+
run: docker run --rm atecc608-wolfcrypt-test:ci

‎ATECC608Sim/.gitignore‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Build artifacts
2+
target/
3+
atecc608-sim/target/
4+
Cargo.lock
5+
6+
# Runtime state
7+
atecc608_store.json
8+
9+
# Editor files
10+
.idea/
11+
.vscode/
12+
*.swp
13+
*.swo
14+
*~
15+
16+
# OS files
17+
.DS_Store
18+
Thumbs.db

‎ATECC608Sim/Dockerfile‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM rust:1.85-bookworm
2+
3+
WORKDIR /app
4+
5+
COPY atecc608-sim/ /app/atecc608-sim/
6+
7+
RUN cd /app/atecc608-sim && cargo build 2>&1
8+
9+
CMD ["cargo", "test", "--manifest-path", "/app/atecc608-sim/Cargo.toml", "--", "--test-threads=1", "--nocapture"]

‎ATECC608Sim/Dockerfile.sdk-test‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Stage 1: build the Rust simulator TCP server
2+
FROM rust:1.85-bookworm AS sim-builder
3+
4+
WORKDIR /app
5+
COPY atecc608-sim/ /app/atecc608-sim/
6+
RUN cd /app/atecc608-sim && cargo build --release --bin tcp_server 2>&1
7+
8+
# =============================================================================
9+
# Stage 2: build cryptoauthlib + test binary
10+
# =============================================================================
11+
FROM debian:bookworm
12+
13+
RUN apt-get update && apt-get install -y \
14+
build-essential cmake git pkg-config \
15+
libssl-dev \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
COPY --from=sim-builder /app/atecc608-sim/target/release/tcp_server /app/atecc608-sim-server
19+
20+
# ---- Build cryptoauthlib ----
21+
WORKDIR /app
22+
# Pin to a recent known-working tag. v3.7.8 is the latest as of early 2026.
23+
RUN git clone --branch v3.7.8 --depth 1 \
24+
https://github.com/MicrochipTech/cryptoauthlib.git /app/cryptoauthlib
25+
26+
# We register our HAL at runtime by populating ATCAIfaceCfg.atcacustom, so
27+
# cryptoauthlib just needs ATCA_HAL_CUSTOM=ON and the other HALs disabled
28+
# (they pull in libraries we don't have in the container).
29+
RUN mkdir -p /app/cryptoauthlib/build && cd /app/cryptoauthlib/build && \
30+
cmake .. \
31+
-DCMAKE_BUILD_TYPE=Release \
32+
-DCMAKE_C_FLAGS="-fPIC" \
33+
-DATCA_HAL_CUSTOM=ON \
34+
-DATCA_HAL_I2C=OFF \
35+
-DATCA_HAL_SPI=OFF \
36+
-DATCA_HAL_KIT_UART=OFF \
37+
-DATCA_HAL_KIT_HID=OFF \
38+
-DATCA_HAL_KIT_BRIDGE=OFF \
39+
-DATCA_BUILD_SHARED_LIBS=OFF \
40+
-DATCA_OPENSSL=OFF \
41+
-DATCA_ATECC608_SUPPORT=ON \
42+
-DATCA_PRINTF=ON \
43+
2>&1 && \
44+
cmake --build . -j$(nproc) 2>&1 && \
45+
cmake --install . 2>&1
46+
47+
# ---- Build test binary ----
48+
COPY sdk-test/ /app/sdk-test/
49+
50+
# We link hal_tcp.c directly into the test binary (cryptoauthlib's CMake
51+
# compiles a stubbed `hal_custom.c` into the archive but doesn't link
52+
# user code, so we supply it here ourselves).
53+
RUN gcc -o /app/test_atecc608 \
54+
/app/sdk-test/test_atecc608.c \
55+
/app/sdk-test/hal_tcp.c \
56+
-I/app/sdk-test \
57+
-I/usr/include/cryptoauthlib \
58+
-I/app/cryptoauthlib/build/lib \
59+
-L/usr/lib \
60+
-lcryptoauth -lssl -lcrypto -lpthread \
61+
2>&1
62+
63+
COPY sdk-test/run_test.sh /app/run_test.sh
64+
RUN chmod +x /app/run_test.sh
65+
66+
CMD ["/app/run_test.sh"]

0 commit comments

Comments
 (0)