Re-implementation of rustbootd's ecat_el6695_* examples as a single binary with fixes found in review and on hardware: - DC-follow PLL hardened against period-2 hunting: slew-limited anchor (+/-50us/cycle), bistable-trap snap re-anchor, re-prime on stale deadline - drift-free absolute-grid ticker mode; probe mode for timestamp forensics - bounded-memory online stats (histograms), graceful SIGINT/SIGTERM shutdown with full report, error-streak abort - timestamp plausibility filter comparing against the previous raw sample (avoids the deadlock after a startup outlier) - XFC scope waveform options: --el2202 (with --el2202-dual), --el2262, --el1252 latch timestamp readback with per-channel edge statistics - register access unified in regs.rs: named bit constants everywhere, read-modify-write for enable/activation bytes - vendored patched ethercrab 0.7.1 (sdo_write_complete, send_raw_coe) Verified on J1900 (PREEMPT_RT 6.6.135): 600k cycles/600s exact 1 kHz, tx/rx zero errors, phase_err p50=164us std=5us; EL2202<->EL1252 loopback edge interval mean 2000.24us std=24.65us.
121 lines
3.9 KiB
Makefile
121 lines
3.9 KiB
Makefile
linux-example example *args:
|
|
cargo build --example {{example}} && \
|
|
sudo setcap cap_net_raw=pe ./target/debug/examples/{{example}} && \
|
|
./target/debug/examples/{{example}} {{args}}
|
|
|
|
linux-example-release example *args:
|
|
cargo build --example {{example}} --release && \
|
|
sudo setcap cap_net_raw=pe ./target/release/examples/{{example}} && \
|
|
./target/release/examples/{{example}} {{args}}
|
|
|
|
linux-test *args:
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
OUT=$(cargo test --no-run 2>&1 | tee /dev/tty | grep -oE '\(target/.+\)' | sed 's/[)(]//g')
|
|
# BINS=$(echo $OUT)
|
|
|
|
mapfile -t BINS < <( echo "$OUT" )
|
|
|
|
for BIN in "${BINS[@]}"
|
|
do
|
|
echo " Setcap for test binary $BIN"
|
|
sudo setcap cap_net_raw=pe $BIN
|
|
done
|
|
|
|
# We've now setcap'd everything so we should be able to run this again without perm issues
|
|
cargo test {{args}}
|
|
|
|
miri *args:
|
|
MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-isolation-error=warn -Zdeduplicate-diagnostics=yes" cargo +nightly-2025-03-29 miri test --target aarch64-unknown-linux-gnu {{args}}
|
|
|
|
miri-nextest *args:
|
|
MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-isolation-error=warn -Zdeduplicate-diagnostics=yes" cargo +nightly-2025-03-29 miri nextest run --target aarch64-unknown-linux-gnu {{args}}
|
|
|
|
_generate-readme path:
|
|
cargo readme --project-root "{{path}}" --template README.tpl --output README.md
|
|
# Remove unprocessed doc links
|
|
sed -i 's/\[\(`[^`]*`\)] /\1 /g' README.md
|
|
|
|
_check-readme path: (_generate-readme path)
|
|
git diff --quiet --exit-code "{{path}}/README.md"
|
|
|
|
check-readmes: (_check-readme ".") (_check-readme "./ethercrab-wire") (_check-readme "./ethercrab-wire-derive")
|
|
|
|
generate-readmes: (_generate-readme ".") (_generate-readme "./ethercrab-wire") (_generate-readme "./ethercrab-wire-derive")
|
|
|
|
dump-eeprom *args:
|
|
cargo build --example dump-eeprom --features "std" --release && \
|
|
sudo setcap cap_net_raw=pe ./target/release/examples/dump-eeprom && \
|
|
./target/release/examples/dump-eeprom {{args}}
|
|
|
|
test-replay test_file *args:
|
|
cargo test {{ replace(test_file, '-', '_') }}
|
|
|
|
capture-replay test_name interface *args:
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# Kill child tshark on failure
|
|
trap 'killall tshark' EXIT
|
|
|
|
test_file=$(echo "{{test_name}}" | tr '_' '-')
|
|
|
|
if [ ! -f "tests/${test_file}.rs" ]; then
|
|
echo "Test file tests/${test_file}.rs does not exist"
|
|
|
|
exit 1
|
|
fi
|
|
|
|
cargo build --tests --release
|
|
sudo echo
|
|
fd . --type executable ./target/debug/deps -x sudo setcap cap_net_raw=pe
|
|
fd . --type executable ./target/release -x sudo setcap cap_net_raw=pe
|
|
|
|
tshark -Q -w "tests/${test_file}.pcapng" --interface {{interface}} -f 'ether proto 0x88a4' &
|
|
|
|
# Wait for tshark to start
|
|
sleep 1
|
|
|
|
test_name=$(echo "${test_file}" | tr '-' '_')
|
|
|
|
# Set env var to put test in capture mode
|
|
INTERFACE="{{interface}}" cargo test "${test_name}" --release -- {{args}}
|
|
|
|
# Let tshark finish up
|
|
sleep 1
|
|
|
|
killall tshark
|
|
|
|
capture-all-replays interface *args:
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
for file in `ls tests/replay-*.rs`; do
|
|
test_name=$(basename "${file%.*}" | tr '-' '_')
|
|
|
|
echo "Capturing $test_name, test is:"
|
|
echo ""
|
|
grep '//!' $file
|
|
echo ""
|
|
|
|
read -p "Prepare hardware then press any key to continue." </dev/tty
|
|
|
|
just capture-replay ${test_name} {{interface}} {{args}}
|
|
|
|
echo ""
|
|
done
|
|
|
|
# Run and example in release mode on a remote testbench PC, capturing traffic with `tshark`.
|
|
#
|
|
# E.g. `just run-remote ek1100 c6015 enp1s0`
|
|
run-remote example remote +args:
|
|
cargo build --example {{example}} --release
|
|
scp target/release/examples/{{example}} {{remote}}:~
|
|
ssh james@{{remote}} 'sudo setcap cap_net_raw=pe ~/{{example}}'
|
|
ssh -t james@{{remote}} "RUST_LOG=info,ethercrab::subdevice_group=debug,ethercrab::{{example}}=debug ~/{{example}} {{args}} || true"
|
|
rsync -avzh james@{{remote}}:~/*.csv ./ || true
|