Write the boot self-test in assembly, the language of boot code. Loaded by the back door, it tests each piece the boot ROM's loader relies on. Those are the boot mode, the pads, the SPI controller and the flash. It passes on ap_soc and fails visibly on every faulty chip of a hidden set.
Hardware context: The boot path of ap_soc v1.5: the BOOT strap, the boot ROM's loader, the SPI pads and a flash model. An assembly self-test of the boot device.
A front-door boot is the honest test of a boot path, but its failure says little. When the flash stays silent, the loader copies nothing useful, the core runs garbage, and the run ends at the cycle limit. So boot verification also has a back-door half. A self-test checks each piece the loader relies on, and names the one that failed.
Write that self-test in assembly, as boot code is written. It is loaded by the back door, so STRAPS bit 0 must read 1. Route pads IO0 to IO5 to their serial functions (PINMUX 0xAAA). Ask the flash for its ID with command 0x9F; it must answer 0xC0FFEE. Then send 0x66 (back to byte 0) and 0x03, which returns the first three bytes, the first in bits 23 to 16.
TB_ARG holds the three bytes the bench put at the start of its flash. Compare. Write the pass word if every check holds, a fail word otherwise, and give every wait a limit. A faulty chip is caught when your test writes a fail word, or a check of the bench fails. A run that ends at the cycle limit is not caught.
Full specification
| SPI register | Address | Use |
|---|---|---|
| DATA | 0x1000_5000 | Write: a command byte starts a frame of 8 clocks out and 24 back. Read: the 24 bits that came back |
| STATUS | 0x1000_5004 | Bit 1 DONE: the frame has ended; write 1 to clear it. Bit 0 BUSY |
| Flash command | Answer |
|---|---|
| 0x9F | 0xC0FFEE, its ID |
| 0x66 | back to byte 0 (the answer is not data) |
| 0x03 | the next three bytes, the first in bits 23 to 16 |
| any other | 0xC0FFEE |
The recorded reference took 515 cycles and three frames. A front-door boot of the same 192-byte program took 11,782 cycles and 65 frames of the loader (recorded). Three instructions are put in front of your program (TB_STATUS = 2, "main entered").
Given Files
Read-only files supplied by the bench.
defs.S
# defs.S: addresses and helpers of the smoke programs of ap_soc v1.5 (stage E4).
# check-soc-top.mjs puts this text in front of every program. Numbers: gen/ap_soc_regs.h.
.equ ROM, 0x00000000
.equ CLINT, 0x02000000
.equ PLIC, 0x0C000000
.equ UART, 0x10000000
.equ GPIO, 0x10001000
.equ TIMER, 0x10002000
.equ WDOG, 0x10003000
.equ SYSCTL, 0x10004000
.equ SPI, 0x10005000
.equ DMA, 0x10006000
.equ HOLE, 0x10007000
.equ PWRCTL, 0x10008000
.equ SRAM, 0x80000000
.equ TB_STATUS, 0x20
.equ TB_PUTC, 0x24
.equ TB_EVENT, 0x28
.equ TB_ARG, 0x2C
SPI · register manual
| Offset | Register | Bits | Field | Access | Reset | Held by | Meaning |
|---|---|---|---|---|---|---|---|
0x000 | DATA | 7:0 | command | wo | not stored | Write: a command byte; the write starts a frame of 32 serial clocks. Read: the last 24 bits received. Command byte. | |
0x000 | DATA | 23:0 | received | ro | block | Last 24 bits received. | |
0x004 | STATUS | 0 | busy | ro | block | Frame state. A frame is running, and chip select is low. | |
0x004 | STATUS | 1 | done | w1c | block | A frame has ended (new in v1.5). | |
0x008 | IRQ_ENABLE | 0 | done | rw | 0x0 | regs | Lets DONE raise interrupt source 4 (new in v1.5). 1 enables the request. |
## SPI (base 0x1000_5000, interrupt source 4, clk_sys, PD_PER) | Offset | Register | Bits | Field | Access | Reset | Held by | Meaning | | --- | --- | --- | --- | --- | --- | --- | --- | | `0x000` | DATA | 7:0 | command | wo | | not stored | Write: a command byte; the write starts a frame of 32 serial clocks. Read: the last 24 bits received. Command byte. | | `0x000` | DATA | 23:0 | received | ro | | block | Last 24 bits received. | | `0x004` | STATUS | 0 | busy | ro | | block | Frame state. A frame is running, and chip select is low. | | `0x004` | STATUS | 1 | done | w1c | | block | A frame has ended (new in v1.5). | | `0x008` | IRQ_ENABLE | 0 | done | rw | `0x0` | regs | Lets DONE raise interrupt source 4 (new in v1.5). 1 enables the request. |
ap_sysctl · register manual
| Offset | Register | Bits | Field | Access | Reset | Held by | Meaning |
|---|---|---|---|---|---|---|---|
0x000 | CHIP_ID | 31:0 | value | ro | 0x2A5310C5 | const | The chip's identity: the IDCODE of the TAP. Fixed number. |
0x004 | RESET_CAUSE | 0 | power_on | ro | block | Sticky record of reset sources since power-on. Power-on reset. | |
0x004 | RESET_CAUSE | 1 | pin | ro | block | Reset pin. | |
0x004 | RESET_CAUSE | 2 | watchdog | ro | block | Watchdog. | |
0x004 | RESET_CAUSE | 3 | software | ro | block | Software request. | |
0x004 | RESET_CAUSE | 4 | debug | ro | block | Debug request. | |
0x008 | SOFT_RESET | 0 | timer | wo | not stored | Reset requests from software. 1 arms one restart of the timer. | |
0x008 | SOFT_RESET | 1 | chip | wo | not stored | 1 requests the software reset (new in v1.5). | |
0x00C | STRAPS | 0 | boot | ro | block | Straps as sampled at power-up (new in v1.5). 0: start in the boot ROM. 1: start in SRAM. | |
0x010 | PINMUX | 31:0 | select | rw | 0x00000000 | regs | Two bits for each of sixteen pads: 0 released, 1 GPIO, 2 serial, 3 auxiliary. Pad n uses bits 2n+1 and 2n. |
0x014 | CLK_GATE | 0 | uart0 | rw | 0x1 | regs | 1 lets that block's clock run (new in v1.5). UART0. |
0x014 | CLK_GATE | 1 | gpio | rw | 0x1 | regs | GPIO. |
0x014 | CLK_GATE | 2 | timer | rw | 0x1 | regs | Timer and PWM. |
0x014 | CLK_GATE | 3 | spi | rw | 0x1 | regs | SPI. |
0x014 | CLK_GATE | 4 | dma | rw | 0x1 | regs | DMA. |
0x018 | LOCK | 0 | pinmux | w1s | 0x0 | regs | Write-once locks. Only a reset clears one (new in v1.5). 1: PINMUX ignores writes. |
0x018 | LOCK | 1 | clk_gate | w1s | 0x0 | regs | 1: CLK_GATE ignores writes. |
0x018 | LOCK | 2 | debug | w1s | 0x0 | regs | 1: the debug lock is closed. |
0x020 | TB_STATUS | 31:0 | value | rw | 0x00000000 | regs (power-on reset only) | Scratch word 0. The firmware kit reports progress, pass and fail here. Plain storage. |
0x024 | TB_PUTC | 31:0 | value | rw | 0x00000000 | regs (power-on reset only) | Scratch word 1. The firmware kit writes one character here. Plain storage. |
0x028 | TB_EVENT | 31:0 | value | rw | 0x00000000 | regs (power-on reset only) | Scratch word 2. The firmware kit writes an event number here. Plain storage. |
0x02C | TB_ARG | 31:0 | value | rw | 0x00000000 | regs (power-on reset only) | Scratch word 3. A bench leaves a word for the firmware here. Plain storage. |
## ap_sysctl (base 0x1000_4000, clk_sys, PD_MAIN) | Offset | Register | Bits | Field | Access | Reset | Held by | Meaning | | --- | --- | --- | --- | --- | --- | --- | --- | | `0x000` | CHIP_ID | 31:0 | value | ro | `0x2A5310C5` | const | The chip's identity: the IDCODE of the TAP. Fixed number. | | `0x004` | RESET_CAUSE | 0 | power_on | ro | | block | Sticky record of reset sources since power-on. Power-on reset. | | `0x004` | RESET_CAUSE | 1 | pin | ro | | block | Reset pin. | | `0x004` | RESET_CAUSE | 2 | watchdog | ro | | block | Watchdog. | | `0x004` | RESET_CAUSE | 3 | software | ro | | block | Software request. | | `0x004` | RESET_CAUSE | 4 | debug | ro | | block | Debug request. | | `0x008` | SOFT_RESET | 0 | timer | wo | | not stored | Reset requests from software. 1 arms one restart of the timer. | | `0x008` | SOFT_RESET | 1 | chip | wo | | not stored | 1 requests the software reset (new in v1.5). | | `0x00C` | STRAPS | 0 | boot | ro | | block | Straps as sampled at power-up (new in v1.5). 0: start in the boot ROM. 1: start in SRAM. | | `0x010` | PINMUX | 31:0 | select | rw | `0x00000000` | regs | Two bits for each of sixteen pads: 0 released, 1 GPIO, 2 serial, 3 auxiliary. Pad n uses bits 2n+1 and 2n. | | `0x014` | CLK_GATE | 0 | uart0 | rw | `0x1` | regs | 1 lets that block's clock run (new in v1.5). UART0. | | `0x014` | CLK_GATE | 1 | gpio | rw | `0x1` | regs | GPIO. | | `0x014` | CLK_GATE | 2 | timer | rw | `0x1` | regs | Timer and PWM. | | `0x014` | CLK_GATE | 3 | spi | rw | `0x1` | regs | SPI. | | `0x014` | CLK_GATE | 4 | dma | rw | `0x1` | regs | DMA. | | `0x018` | LOCK | 0 | pinmux | w1s | `0x0` | regs | Write-once locks. Only a reset clears one (new in v1.5). 1: PINMUX ignores writes. | | `0x018` | LOCK | 1 | clk_gate | w1s | `0x0` | regs | 1: CLK_GATE ignores writes. | | `0x018` | LOCK | 2 | debug | w1s | `0x0` | regs | 1: the debug lock is closed. | | `0x020` | TB_STATUS | 31:0 | value | rw | `0x00000000` | regs (power-on reset only) | Scratch word 0. The firmware kit reports progress, pass and fail here. Plain storage. | | `0x024` | TB_PUTC | 31:0 | value | rw | `0x00000000` | regs (power-on reset only) | Scratch word 1. The firmware kit writes one character here. Plain storage. | | `0x028` | TB_EVENT | 31:0 | value | rw | `0x00000000` | regs (power-on reset only) | Scratch word 2. The firmware kit writes an event number here. Plain storage. | | `0x02C` | TB_ARG | 31:0 | value | rw | `0x00000000` | regs (power-on reset only) | Scratch word 3. A bench leaves a word for the firmware here. Plain storage. |
Examples
Example 1
The Good Chip- Input
The bench's flash starts with 5A 3C 97
- Output
pass, 3 SPI frames
STRAPS is 1. The flash answers its ID, then 0x5A3C97, the bench's first three bytes.
Example 2
Another Pattern- Input
The bench's flash starts with 0F E1 2B
- Output
pass, 3 SPI frames
The same test with another flash: TB_ARG now holds 0x0FE12B. A test that compared with a constant fails here.
Example 3
A Silent Flash- Input
a hidden chip
- Output
your fail word
A front-door boot of this chip ends at the cycle limit and explains nothing. The self-test asks the flash, waits with a limit, and fails with a code.
Constraints and Contract
- Assembly for the SRAM layout, with the names of defs.S.
- Two cases, each run on the good chip and on every hidden chip. The good chip must pass both.
- The hidden set holds faults on the boot path between the pins of the SPI controller and the flash.
Hints
Hint 1
What does your test do if the flash never answers, or DONE never rises?
Hint 2
The flash sends the first byte first. Where does it land in DATA?
Hint 3
Which value tells you what the flash should hold? It changes from case to case.
What the grader checks: Each case runs on the good chip and on every hidden faulty chip. The good chip must pass both cases. Each faulty chip must end with a fail word or a bench check in every case. The bench's SPI monitor checks every frame on the pads. So one hidden fault is caught by any test that makes a frame. The other only your own checks can catch. The grader cannot see whether your waits have limits on these chips: give them limits anyway.
2 checks on ap_soc v1.5 · assembly · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your text only; the chip, the bench and the hidden checks stay on the server. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 3 problems on this path