Skip to main content

Crate tag_test

Crate tag_test 

Source
Expand description

tag-test: set the RTC and execute tag self-tests.

Port of host/commandline/test.cc. Prints the tag’s information, its clock drift before and after an RTC sync, its state and state log, then, if the tag is IDLE, runs the requested self-test (--test, by TestReq name or number) and polls until the tag returns to IDLE or --test-timeout expires, and prints the test result. The RTC is synced again afterwards, since a test may alter it.

Usage: tag-test [-d] [-b BUS:DEVICE] [-t|--test NAME|NUMBER] [--test-timeout S] (defaults RUN_ALL and 30 s). Status is polled once a second while the test runs. Clock drift prints in seconds (tag minus host), voltage in volts.

§Exit status

0 when the test finished with ALL_PASSED and the clock was re-synced. 1 for a test that finished with any other TestResult (after printing it and re-syncing the clock), an unknown test, a failed attach, info or status read or clock sync, a tag that is not IDLE, a refused test request, or a test that does not finish within --test-timeout. Option errors exit 2 (clap).

§Hardware side effects

The attach resets the tag, its clock is set from the host twice, and the self-test exercises the hardware. On a tag with external NAND, the external-flash test can write the NAND bad-block map. Run it after every flash, before measuring anything (step 4 of the flashing protocol in AGENTS.md).

Structs§

Cli 🔒
sets the RTC and executes tag self-tests

Functions§

main 🔒
Attaches, prints the tag’s information and clock drift, sets the clock, prints the state log, runs the self-test and reports its result.
parse_c_int 🔒
Parses an integer as std::stoi(s, &parsed, 0) does (leading whitespace, optional sign, 0x hex or leading-0 octal), requiring the whole string to be consumed and the value to fit an int.
parse_test_req 🔒
A TestReq by protobuf name, or by a number that names a valid value.
rtc_drift 🔒
The tag clock’s offset from the host clock in seconds (tag minus host), echoing any firmware debug message to stderr. None if status failed.