An assembly bring-up check compares the chip's straps and tied inputs with a table of expected values. It fails at entry 4. Find the transfer the check failed on, and decide who is wrong.
A bring-up check runs from SRAM, so the board holds the BOOT strap high. It walks a table of entries: an address, a mask and the value expected under that mask. It ends with fail code 4: entry 4 did not match.
The chip is ap_soc v1.5, the good chip. Either the chip answered wrongly, or the table expects the wrong value.
The trace below shows 18 of 18 retired loads and stores after main, cycles 12 to 95. Name the transfer that went wrong first: its cycle, the wrong part, its address and its register. Then choose the cause.
Full specification
li s0, SYSCTL
csrr t0, mhartid
bnez t0, hart # one hart: its ID is tied to 0
la s1, checks
li s2, 0
next:
lw t1, 0(s1) # the register's address; 0 ends the table
beqz t1, done
lw t2, 4(s1) # the mask
lw t3, 8(s1) # the expected value
lw t4, 0(t1) # read the register
and t4, t4, t2
addi s2, s2, 1
bne t4, t3, fail
addi s1, s1, 12
j next
done:
li t1, 0x900D
sw t1, TB_STATUS(s0)
1: j 1b
hart:
li s2, 0x10
fail:
li t1, 0xBAD00000
or t1, t1, s2 # fail code: the number of the entry
sw t1, TB_STATUS(s0)
2: j 2b
checks:
.word 0x10004000, 0xFFFFFFFF, 0x2A5310C5 # 1 CHIP_ID
.word 0x1000400C, 0x00000001, 0x00000001 # 2 STRAPS: BOOT, as the board holds it
.word 0x10004004, 0x00000010, 0x00000000 # 3 RESET_CAUSE: the debug cause
.word 0x10002020, 0x00000002, 0x00000000 # 4 TIMER_EVENT: online
.word 0x10004014, 0x0000001F, 0x0000001F # 5 CLK_GATE: every clock on
.word 0
| Entry | Register | Mask | What it checks |
|---|---|---|---|
| 1 | CHIP_ID | all | The chip's identity |
| 2 | STRAPS | bit 0 | BOOT as sampled |
| 3 | RESET_CAUSE | bit 4 | The debug reset cause |
| 4 | TIMER_EVENT | bit 1 | ONLINE: read only |
| 5 | CLK_GATE | bits 4:0 | Every block's clock |
The register list names every address the answer may use. Addresses are in hex without 0x in the trace; write them with or without 0x in the form.
Diagnose the Failing Run
Recorded Console and Result
verdict=fail reason=status_fail status=bad00004 cycles=103 traps=0 mismatches=0
Retired Memory Transfers
| Cycle | PC (hex) | Operation | Address (hex) | Data (hex) |
|---|---|---|---|---|
| 12 | 80000008 | store | 10004020 | 00000002 |
| 22 | 80000024 | load | 80000070 | 10004000 |
| 26 | 8000002c | load | 80000074 | ffffffff |
| 28 | 80000030 | load | 80000078 | 2a5310c5 |
| 30 | 80000034 | load | 10004000 | 2a5310c5 |
| 40 | 80000024 | load | 8000007c | 1000400c |
| 44 | 8000002c | load | 80000080 | 00000001 |
| 46 | 80000030 | load | 80000084 | 00000001 |
| 48 | 80000034 | load | 1000400c | 00000001 |
| 58 | 80000024 | load | 80000088 | 10004004 |
| 62 | 8000002c | load | 8000008c | 00000010 |
| 64 | 80000030 | load | 80000090 | 00000000 |
| 66 | 80000034 | load | 10004004 | 00000001 |
| 76 | 80000024 | load | 80000094 | 10002020 |
| 80 | 8000002c | load | 80000098 | 00000002 |
| 82 | 80000030 | load | 8000009c | 00000000 |
| 84 | 80000034 | load | 10002020 | 00000002 |
| 95 | 80000068 | store | 10004020 | bad00004 |
Given Files
Use the register map to identify the transfer in the recording.
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
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. |
Timer and PWM · register manual
| Offset | Register | Bits | Field | Access | Reset | Held by | Meaning |
|---|---|---|---|---|---|---|---|
0x000 | RUN | 0 | run | rw | 0x0 | regs | Starts and stops the counter. 1: the counter runs. |
0x004 | DUTY | 2:0 | slots | rw | 0x0 | regs | How many of the four slots drive the PWM pin high. 0 to 4. |
0x008 | CAPTURED | 1:0 | slot | ro | block | The slot number saved when the capture input fired. Slot number. | |
0x00C | DIV_TOP | 7:0 | top | rw | 0x00 | regs | Prescaler: the last count before the slot number steps. A write restarts the prescaler. Last prescaler count. |
0x010 | COMPARE | 1:0 | slot | rw | 0x0 | regs | The slot number that raises match. Slot number. |
0x014 | IRQ_CLEAR | 0 | match | wo | not stored | Writing 1 to bit 0 clears the stored match flag. 1 clears the flag. | |
0x018 | IRQ_ENABLE | 0 | match | rw | 0x0 | regs | Lets the stored match flag raise interrupt source 3. 1 enables the request. |
0x020 | EVENT | 0 | enable | rw | 0x0 | regs | Six teaching fields (S6.8). Plain read and write. |
0x020 | EVENT | 1 | online | ro | block | A level from the hardware. | |
0x020 | EVENT | 2 | kick | wo | not stored | A written 1 makes one pulse. | |
0x020 | EVENT | 3 | pending | w1c | block | Set by an event; a written 1 clears it. | |
0x020 | EVENT | 4 | seen | rc | block | Set by an event; a read clears it. | |
0x020 | EVENT | 5 | route | rw | 0x0 | block | Takes the first write only. |
0x024 | EVENT_COUNT_LOW | 31:0 | value | ro | block | Low 32 bits of the 64-bit event counter. Count, low word. | |
0x028 | EVENT_COUNT_HIGH | 31:0 | value | ro | block | High 32 bits of the event counter. Count, high word. |
## Timer and PWM (base 0x1000_2000, interrupt source 3, clk_sys, PD_PER) | Offset | Register | Bits | Field | Access | Reset | Held by | Meaning | | --- | --- | --- | --- | --- | --- | --- | --- | | `0x000` | RUN | 0 | run | rw | `0x0` | regs | Starts and stops the counter. 1: the counter runs. | | `0x004` | DUTY | 2:0 | slots | rw | `0x0` | regs | How many of the four slots drive the PWM pin high. 0 to 4. | | `0x008` | CAPTURED | 1:0 | slot | ro | | block | The slot number saved when the capture input fired. Slot number. | | `0x00C` | DIV_TOP | 7:0 | top | rw | `0x00` | regs | Prescaler: the last count before the slot number steps. A write restarts the prescaler. Last prescaler count. | | `0x010` | COMPARE | 1:0 | slot | rw | `0x0` | regs | The slot number that raises match. Slot number. | | `0x014` | IRQ_CLEAR | 0 | match | wo | | not stored | Writing 1 to bit 0 clears the stored match flag. 1 clears the flag. | | `0x018` | IRQ_ENABLE | 0 | match | rw | `0x0` | regs | Lets the stored match flag raise interrupt source 3. 1 enables the request. | | `0x020` | EVENT | 0 | enable | rw | `0x0` | regs | Six teaching fields (S6.8). Plain read and write. | | `0x020` | EVENT | 1 | online | ro | | block | A level from the hardware. | | `0x020` | EVENT | 2 | kick | wo | | not stored | A written 1 makes one pulse. | | `0x020` | EVENT | 3 | pending | w1c | | block | Set by an event; a written 1 clears it. | | `0x020` | EVENT | 4 | seen | rc | | block | Set by an event; a read clears it. | | `0x020` | EVENT | 5 | route | rw | `0x0` | block | Takes the first write only. | | `0x024` | EVENT_COUNT_LOW | 31:0 | value | ro | | block | Low 32 bits of the 64-bit event counter. Count, low word. | | `0x028` | EVENT_COUNT_HIGH | 31:0 | value | ro | | block | High 32 bits of the event counter. Count, high word. |