V3.3.2 The Configuration Block That Was Not There

MediumDebug20 minap_soc v1.5 · recorded bootReview the topic

The bench loads a test and its configuration block by the back door, and the firmware finds no configuration. Read the run and the image file, name the first transfer that went wrong, and say why.

A test reads a configuration block at SRAM + 0x100: a magic word 0x5A5A_C0DE, then a count of rounds. A script appends the block to the image file that the bench loads with $readmemh. The firmware prints "cfg missing" and fails.

The last three lines of the image file (43 lines in all; the program's words come first, from line 3).
@00000100
5a5ac0de
00000003

The program loads the word at SRAM + 0x100 and compares it with 0x5A5A_C0DE. If they differ, it prints "cfg missing" and writes the fail word 0xBAD0_0001. Otherwise it reads the count and passes. Its assembly is in the full specification.

FactValue
$readmemhReads one element of the memory a line
A line "@n"Sets where the next line goes
The SRAM of ap_socAn array of 16,384 words of 32 bits, from 0x8000_0000

Find the first transfer whose value is not what the test needed, and choose the cause.

Full specification
The program, in SRAM; the bench writes TB_STATUS = 2 before it starts.
li   s0, SYSCTL
    li   s1, SRAM + 0x100          # the configuration block, loaded with the image
    lw   t1, 0(s1)                 # its magic word
    li   t2, 0x5A5AC0DE
    bne  t1, t2, bad
    lw   s2, 4(s1)                 # how many rounds the bench asks for
    la   a1, t_ok
    call puts
    li   t3, 0x900D
    j    finish
bad:
    la   a1, t_bad
    call puts
    li   t3, 0xBAD00001
finish:
    sw   t3, TB_STATUS(s0)
9:  j    9b

Diagnose the Failing Run

Recorded Console and Result

CONSOLE 143: cfg missing
verdict=fail
reason=status_fail
status=bad00001
mismatches=0
cycles=169

Retired Memory Transfers

CyclePC (hex)OperationAddress (hex)Data (hex)
1280000008store1000402000000002
1680000018load8000010000000000
3480000070store1000402400000063
4480000070store1000402400000066
5480000070store1000402400000067
6480000070store1000402400000020
7480000070store100040240000006d
8480000070store1000402400000069
9480000070store1000402400000073
10480000070store1000402400000073
11480000070store1000402400000069
12480000070store100040240000006e
13480000070store1000402400000067
14480000070store100040240000000a
16180000060store10004020bad00001
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.