V8.5.1 The Check That Expected Too Little

MediumDebug20 minap_soc v1.5 · recorded bootReview the topic

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
The program of the recorded run.
    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
EntryRegisterMaskWhat it checks
1CHIP_IDallThe chip's identity
2STRAPSbit 0BOOT as sampled
3RESET_CAUSEbit 4The debug reset cause
4TIMER_EVENTbit 1ONLINE: read only
5CLK_GATEbits 4:0Every 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

CyclePC (hex)OperationAddress (hex)Data (hex)
1280000008store1000402000000002
2280000024load8000007010004000
268000002cload80000074ffffffff
2880000030load800000782a5310c5
3080000034load100040002a5310c5
4080000024load8000007c1000400c
448000002cload8000008000000001
4680000030load8000008400000001
4880000034load1000400c00000001
5880000024load8000008810004004
628000002cload8000008c00000010
6480000030load8000009000000000
6680000034load1000400400000001
7680000024load8000009410002020
808000002cload8000009800000002
8280000030load8000009c00000000
8480000034load1000202000000002
9580000068store10004020bad00004
Step 1 · The first bad cycle and signal
Step 2 · The cause

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
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x000CHIP_ID31:0valuero0x2A5310C5constThe chip's identity: the IDCODE of the TAP. Fixed number.
0x004RESET_CAUSE0power_onroblockSticky record of reset sources since power-on. Power-on reset.
0x004RESET_CAUSE1pinroblockReset pin.
0x004RESET_CAUSE2watchdogroblockWatchdog.
0x004RESET_CAUSE3softwareroblockSoftware request.
0x004RESET_CAUSE4debugroblockDebug request.
0x008SOFT_RESET0timerwonot storedReset requests from software. 1 arms one restart of the timer.
0x008SOFT_RESET1chipwonot stored1 requests the software reset (new in v1.5).
0x00CSTRAPS0bootroblockStraps as sampled at power-up (new in v1.5). 0: start in the boot ROM. 1: start in SRAM.
0x010PINMUX31:0selectrw0x00000000regsTwo bits for each of sixteen pads: 0 released, 1 GPIO, 2 serial, 3 auxiliary. Pad n uses bits 2n+1 and 2n.
0x014CLK_GATE0uart0rw0x1regs1 lets that block's clock run (new in v1.5). UART0.
0x014CLK_GATE1gpiorw0x1regsGPIO.
0x014CLK_GATE2timerrw0x1regsTimer and PWM.
0x014CLK_GATE3spirw0x1regsSPI.
0x014CLK_GATE4dmarw0x1regsDMA.
0x018LOCK0pinmuxw1s0x0regsWrite-once locks. Only a reset clears one (new in v1.5). 1: PINMUX ignores writes.
0x018LOCK1clk_gatew1s0x0regs1: CLK_GATE ignores writes.
0x018LOCK2debugw1s0x0regs1: the debug lock is closed.
0x020TB_STATUS31:0valuerw0x00000000regs (power-on reset only)Scratch word 0. The firmware kit reports progress, pass and fail here. Plain storage.
0x024TB_PUTC31:0valuerw0x00000000regs (power-on reset only)Scratch word 1. The firmware kit writes one character here. Plain storage.
0x028TB_EVENT31:0valuerw0x00000000regs (power-on reset only)Scratch word 2. The firmware kit writes an event number here. Plain storage.
0x02CTB_ARG31:0valuerw0x00000000regs (power-on reset only)Scratch word 3. A bench leaves a word for the firmware here. Plain storage.
Timer and PWM · register manual
OffsetRegisterBitsFieldAccessResetHeld byMeaning
0x000RUN0runrw0x0regsStarts and stops the counter. 1: the counter runs.
0x004DUTY2:0slotsrw0x0regsHow many of the four slots drive the PWM pin high. 0 to 4.
0x008CAPTURED1:0slotroblockThe slot number saved when the capture input fired. Slot number.
0x00CDIV_TOP7:0toprw0x00regsPrescaler: the last count before the slot number steps. A write restarts the prescaler. Last prescaler count.
0x010COMPARE1:0slotrw0x0regsThe slot number that raises match. Slot number.
0x014IRQ_CLEAR0matchwonot storedWriting 1 to bit 0 clears the stored match flag. 1 clears the flag.
0x018IRQ_ENABLE0matchrw0x0regsLets the stored match flag raise interrupt source 3. 1 enables the request.
0x020EVENT0enablerw0x0regsSix teaching fields (S6.8). Plain read and write.
0x020EVENT1onlineroblockA level from the hardware.
0x020EVENT2kickwonot storedA written 1 makes one pulse.
0x020EVENT3pendingw1cblockSet by an event; a written 1 clears it.
0x020EVENT4seenrcblockSet by an event; a read clears it.
0x020EVENT5routerw0x0blockTakes the first write only.
0x024EVENT_COUNT_LOW31:0valueroblockLow 32 bits of the 64-bit event counter. Count, low word.
0x028EVENT_COUNT_HIGH31:0valueroblockHigh 32 bits of the event counter. Count, high word.