The run subcommand executes a sequence
of operations defined in a JSON input file and optionally writes all results to a
JSON output file. Execution stops on the first error.
Generate a Template
Use generate-template to create a
starter JSON file containing one entry for every supported operation:
cfgmem_util generate-template --output ops.json
Output:
Wrote template with all operations to ops.json
The generated ops.json:
[
{ "operation": "get-flash-properties", "comment": "Query flash device identity and configuration" },
{ "operation": "get-status-register", "comment": "Read SPI status register" },
{ "operation": "get-flag-status-register", "comment": "Read flag status register (Micron devices)" },
{ "operation": "get-clk-prescaler", "comment": "Read current SPI clock prescaler" },
{ "operation": "set-clk-prescaler", "input": { "value": 2 }, "comment": "Set SPI clock prescaler (0-7)" },
{ "operation": "get-qe-bit", "comment": "Read Quad Enable bit status" },
{ "operation": "set-qe-bit", "input": { "value": 1 }, "comment": "Set Quad Enable bit (0 or 1)" },
{ "operation": "readback", "input": { "offset": "0x0", "size": "0x100", "output-file": "readback.bin" }, "comment": "Read flash contents to file" },
{ "operation": "send-spi-cmd", "input": { "opcode": "0x9F", "rx-len": 3 }, "comment": "Send raw SPI command (read JEDEC ID)" }
]
The "comment" field is informational
and ignored during execution.
Run Operations
Pass the input file with -i and
optionally capture all results to a JSON file with -o:
cfgmem_util run -u oyster11 -f ospi-single-x8 -i ops.json -o results.json
Example console output (after deployment):
[1/5] get-flash-properties... OK
JEDEC ID: 0x2C5B1C, Size: 256 MB, Sector: 128 KB
[2/5] get-status-register... OK (0x00)
[3/5] get-flag-status-register... OK (0x81)
[4/5] get-clk-prescaler... OK (5)
[5/5] send-spi-cmd: opcode=0x9F, rx_len=3... OK (2C 5B 1C)
Summary: 5/5 operations succeeded
Results written to results.json
-o is specified, partial results are written
for any operations that completed before the failure.JSON Format Reference
| Operation | Required Input Fields |
|---|---|
get-flash-properties
|
— |
get-status-register
|
— |
get-flag-status-register
|
— |
get-clk-prescaler
|
— |
set-clk-prescaler
|
value
|
get-qe-bit
|
— |
set-qe-bit
|
value
|
readback
|
offset, size, output-file
|
send-spi-cmd
|
opcode
|
Numeric format rules:
- Use hex strings with
0xprefix for addresses, sizes, and opcodes (for example,"offset": "0x0","opcode": "0x9F") - Use plain integers for counts and flag values (for example,
"rx-len": 3,"dummy": 2,"value": 1)
Output JSON format:
Each entry in the results array corresponds to one operation in the
input file. A successful operation has "status":
"ok" and a "result" object. A failed
operation has "status": "error" and an "error" field with the error message.
Example results.json:
[
{
"operation": "get-flash-properties",
"status": "ok",
"result": {
"jedec_id": "0x2C5B1C",
"flash_size": 268435456,
"flash_sector_size": 131072,
"bus_width": "x8",
"connection_mode": "single",
"device_type": "OSPI"
}
},
{
"operation": "get-status-register",
"status": "ok",
"result": { "value": "0x00", "byte_count": 1 }
},
{
"operation": "get-flag-status-register",
"status": "ok",
"result": { "value": "0x81", "byte_count": 1 }
},
{
"operation": "get-clk-prescaler",
"status": "ok",
"result": { "prescaler": 5 }
},
{
"operation": "send-spi-cmd",
"status": "ok",
"result": { "response": "2C 5B 1C" }
}
]