Episode 01 lit the LED, Episode 02 exercised traps and interrupts. Episode 03 puts CVE2 in charge of the board-control plane: LEDs, KEYs, QSPI Flash, I²C EEPROM, the TF card and a 500 ms watchdog, while keeping the factory ACM:* serial protocol unchanged. On-board log: FLASH / EEPROM / SD all ok.
This episode replaces the control core, not the whole factory test. The factory project used a MicroBlaze to run the ACM protocol; EP03 implements the same command surface with CVE2 plus plain RTL peripherals. DDR3, ETH1, MIPI, ADC and HDMI_IN are not integrated here, and ACM:Auto honestly returns wait for them instead of pretending they are covered.
After programming the bitstream over JTAG, the complete boot log is shown below. ACM:Test=WDT then triggers a watchdog reset, the board prints BOOT CAUSE=WDT, and each ACM:Auto item is queried:
ALINX AR035 CVE2 Board Control EP03
BOOT CAUSE=WDT
CFG=000003c7
FLASH ID=00c84018 OK
EEPROM DATA=000000b2 ACK
SD R1=00000001 OK
LED TEST=PASS
KEY1=0 KEY2=0
READY
ACS:Auto=FLASH,result=ok
ACS:Auto=EEPROM,result=ok
ACS:Auto=SD,result=ok
CFG=000003c7 is debug telemetry: bit0 cfg_ready=1, bit1 EOS=1, bit2 MISO=1; the upper 16 bits count SCLK rising edges for this probe (0x3c7 >> 3 = 120 edges), proving that the STARTUPE2 CCLK really reaches the Flash.
| Category | Test | Expected | Measured | Result |
|---|---|---|---|---|
| Flash | QSPI JEDEC ID 9F | C8 40 18 | 00c84018 | ok |
| EEPROM | I²C 7-bit address 0x50, read address 0 | ACK + 1 byte | 0xB2 ACK | ok |
| TF card | SPI CMD0, R1 response | 0x01 idle | 0x01 | ok |
| LED | LED1–LED8 walk | Visible walk | LED TEST=PASS | pass |
| KEY | Read KEY1/KEY2 | Released = 0 | KEY1=0 KEY2=0 | readable |
| Watchdog | Arm, then stop kicking | Reset after 500 ms | BOOT CAUSE=WDT | pass |
| DDR3 / ETH1 / MIPI / ADC / HDMI_IN | ACM:Auto | Not covered here | result=wait | honest |
KEY verification only covers the released state. Pressing a key and the 20 ms debounce counter are left for a later episode.
GPIO outputs drive the off-chip devices directly; inputs are synchronized through two flip-flops before reaching the CPU. The Flash SCLK does not come from a normal pin: it uses STARTUPE2's USRCCLKO, so CCLK can continue as the QSPI clock after configuration.
| Address | Peripheral | Notes |
|---|---|---|
0x1000_0000 | UART | +0 TX, +4 status, +8 RX; 16-byte RX FIFO |
0x3000_0000 | WDT | +0 arm/disarm, +4 kick, +8 cause, +C status |
0x4000_0000 | LED | 8 bits, logic 1 = on |
0x4001_0000 | KEY | [1:0] currently pressed, [3:2] sticky seen |
0x4002_0000 | GPIO | +0 output, +4 input |
0x4003_0000 | DBG | cfg_ready / EOS / MISO / SCLK count |
The protocol text matches the factory firmware; CVE2 only replaces the execution side. The host tool does not need to change its command format:
| Command | CVE2 behavior | Response |
|---|---|---|
ACM:Support | Lists 8 Auto items, KEY1/2, LED1–8, Test=LED/WDT | ACS:Support,... |
ACM:Auto | Runs FLASH/EEPROM/SD; others return wait | ACS:Auto=NAME,result=ok/wait/err |
ACM:Auto=FLASH | Reads JEDEC ID and compares with C8 40 18 | result=ok |
ACM:Auto=EEPROM | I²C read at address 0, requires ACK | result=ok |
ACM:Auto=SD | SPI CMD0, R1=0x01 | result=ok |
ACM:GpioIn | Reads KEY1/KEY2 and sticky seen | status=on/off |
ACM:GpioOut=LEDn,set=on/off | Writes the LED register | ACS:GpioOut=ok |
ACM:Test=WDT | Arms the watchdog, then spins until reset | BOOT CAUSE=WDT after reset |
| Item | Value | Utilization |
|---|---|---|
| Slice LUTs | 3,413 | 16.41% |
| Slice Registers | 2,677 | 6.44% |
| Block RAM Tile | 8 | 16.00% |
| DSPs | 11 | 12.22% |
| Bonded IOB | 25 | 10.00% |
| WNS / WHS | 1.617 ns / 0.039 ns | TNS / THS = 0, 0 failing endpoints |
WHS is re-signoff with set_clock_uncertainty -hold 0.100. The earlier 0.150 constraint reported a false -0.002 ns violation; the routed checkpoint has positive physical margin at 0.100 with 0 failing endpoints. Bitstream: top_cve2_ep03.bit, 2,192,137 bytes, SHA-256 aca201c01d74591e6226124473d45cce9473ef7d2872a8ea1f8539fe1edec5b7.
flash_mosi assignment: the top level only declared the port and never assigned flash_mosi = gpio_reg[2]. Vivado synthesized P22 as TRISTATE, so the Flash never received 9F/FF/66/99 and always read back 00ffffff. Power cycling, exiting QPI and software reset were all useless; after adding the driver, the ID read C8 40 18 on the first try.0x4001_0000 >> 12 = 0x4_0010, but the constant was 0x4_0001. The first gpio_set never asserted data_gnt and the CPU waited forever. Only PC tracing in simulation located the first GPIO access.cfg_ready swallowed by board reset: EOS is a one-shot pulse; the original logic cleared it on rst_ni. It is now sticky after EOS and no longer cleared by user reset.rdata was a register, so reading while popping returned the previous byte. Changed to assign rdata = fifo[rd_ptr].wait was not a code bug: with an empty socket CMD0 necessarily gets no response. With a TF card inserted, R1=0x01 and ACM:Auto=SD turns ok.riscv-nuclei-elf-gcc (GCC 10.2).cd sw && make clean && make, confirm firmware.hex is updated.top_cve2_ep03.sv's INIT_FILE points to EP03's sw/firmware.hex.vivado -mode batch -source build_ep03.tcl.vivado -mode batch -source program_ep03.tcl.stty -F /dev/ttyUSB1 115200 cs8 -cstopb -parenb raw -echo; timeout 20 cat /dev/ttyUSB1.cd sw && make clean && make
cd ..
/media/alinx/nvme4t/Xilinx/2025.2/Vivado/bin/vivado -mode batch -source build_ep03.tcl
/media/alinx/nvme4t/Xilinx/2025.2/Vivado/bin/vivado -mode batch -source program_ep03.tcl
stty -F /dev/ttyUSB1 115200 cs8 -cstopb -parenb raw -echo
timeout 20 cat /dev/ttyUSB1
The files below come directly from the verified project and can be downloaded for inspection. The complete upstream CVE2 source is in the OpenHW repository.
Daily Briefing · Weekly Digest · Monthly Deep Dive