Escapement Project

Buses

The LPC55S69's AHB matrix arbitrates per slave port: two masters that reach the same port in the same cycle take turns, and the loser stalls. Code that times the wire by counting cycles (the SWD, JTAG and cJTAG paths, generated or not) is only exact while nothing else is on the ports it uses: a stalled access moves every edge after it. So the bit paths use the secure GPIO block on port 10, away from the ordinary GPIO CPU 0 polls on port 8, and no timed path touches port 7, which every APB peripheral shares.

Keep this file current. Adding a peripheral access, a DMA channel, or a buffer in a new SRAM bank means a row here, and anything that lands on a port a timed window uses needs a handshake or another port.

Source: UM11126 rev 2.8 tables 4, 5 and 6.

Slave ports#

PortAddresses (non-secure; secure is +0x1000_0000)What is there
00x0000_0000 flash, 0x0300_0000 boot ROMBoth cores' C code (CPU 0 from 0x200, CPU 1 from 0x4_0000)
10x0400_0000 SRAMX, 32 KBGenerated code: SWD's in the lower 16 KB, JTAG's in all of it. A lab build keeps JTAG's to the lower half and has the code lab's arena at 0x0400_4000
20x2000_0000 SRAM0, 64 KBCPU 0's data, stack (top 4 KB, see Stacks) and .ramfunc (vcom_task and the energy integration among them); the consoles' receive rings, send buffers and ring descriptors, and the energy ring, its reload descriptors and its integration state (energy_integration), which DMA0 reaches
30x2001_0000 SRAM1, 64 KBCPU 1's full 16 KiB stack in the bottom quarter. From 0x2001_4000, in this order: its .ramfunc (command processing around the generated code), the SWD generator and the JTAG generator's scans, .data, .bss and .cold_bss. They run on into SRAM2
40x2002_0000 SRAM2, 64 KBWhere CPU 1's RAM code and data run on from SRAM1. How far into the list above the boundary falls depends on the compiler: GCC's product image crosses it at the end of .data, clang's inside the JTAG generator. In both, .bss, with response_copy and the abort byte CPU 0 sets, is here. tools/image.py refuses a product image whose RAM code or data, .cold_bss aside, reaches SRAM3. In the ARM reference build, its .bss
50x2003_0000 SRAM3, 64 KBdap_stage in the top 8 KB from 0x2003_E000: packet-sized commands and replies CPU 0 stages for CPU 1, every HID reply, and Verge Aux's request slot. Below it, nothing of a product image's CPU 1. .cold_bss (the JTAG generator's two saved builds, 32 KB, touched only on a wire or configuration switch) comes after every other .bss and may reach here.
60x2004_0000 SRAM4, 16 KBStream message storage in the lower 8 KB from 0x2004_0000; upper 8 KB unused
70x4000_0000 APB bridge 0 and 0x4002_0000 APB bridge 1Every APB peripheral, both bridges on one port (below)
80x4008_0000DMA0 regs, SCTimer, Flexcomm 0 to 4, mailbox, ordinary GPIO
90x4009_0000USB HS device regs, CRC, Flexcomm 5 to 7, SDIO, debug mailbox, HS SPI
100x400A_0000ADC0, USB hosts, Hash-AES, Casper, PowerQuad, DMA1 regs, secure GPIO, AHB secure control
110x4010_0000 USB SRAM, 16 KBUSB buffers (CPU 0), dap_shared at 0x4010_1000: queues, DMA0's descriptor table, SWO ring, shared state

APB bridge 0: SYSCON, IOCON, GINT0/1, PINT, secure PINT, INPUTMUX, CTimer 0 and 1, WWDT, MRT, UTICK, analog controls. APB bridge 1: SYSCTL, CTimer 2, 3 and 4, RTC, OS event timer, flash controller, PRINCE, USB HS PHY, RNG, PUF, PLU. Since both bridges are port 7, any APB access contends with any other.

Masters and what they reach#

MasterPortWhatWhen
CPU 11Generated code fetchEvery generated transfer
CPU 13, 4Shared generator event workspace, 1280 events with JTAG or 256 for SWD onlyBuilds run serially between timed windows; each schedule is consumed before reuse
CPU 13, 4The SWD generator and the JTAG generator's scans (src/gen.c, src/swd_gen.c, src/jtag_gen.c)Each build, between timed windows
CPU 110Secure GPIO (DBGIF_GPIO): every SWDIO, SWCLK, TMS, TDI, TDO accessInside every timed window
CPU 10ARM's bit paths in the ARM reference build, run from flashInside their timed windows
CPU 15Each command's request in dap_stage, and each bulk command's reply: the generated transfers load write data and store read data thereInside timed windows
CPU 14Its own response_copy: every HID command's reply. The generated transfers store read data thereInside timed windows
CPU 15Each HID reply's report, from response_copy into dap_stageBetween timed windows
CPU 15Verge Aux's slot in dap_stage: its state before each command, and an aux request and its replyBetween commands
CPU 17CTimer 4's counter, the energy stream's clock: read at each start, resume, hold and release, and to stamp each markerEnergy commands and 0x94, and around a read-latency measurement, outside its window
CPU 10, 3, 4, 5C code, .ramfunc, data and stack between transfersBetween timed windows
CPU 111dap_shared: the queues and the LED inputsBetween timed windows
CPU 111dap_shared: SWO's ring, its descriptors and channel entry, its segment count, and swo_lost, which it clears as the ring startsSWO commands only
CPU 110ADC0 (target sense and its 0x86, the Pro's energy calibration) and settled energy FIFO resultsOwn core, never during a window: at boot on the Pro, a host's sense reads, a start that calibrates; FIFO drain at capture pause/stop
CPU 12CPU 0's energy_integration in SRAM0: ring reads for latest-sample replies and the unconsumed capture tail; each start's identity, publication sequence, tables, constants, descriptors and position; the running flag; the segment count a capture started at; the energy stream's timeline, and its message indices at a start, pause or stop; a hold's record after each read-latency measurement; a marker's record, and the stream's marking and busy flags, for each 0x94Host polls while capture runs; tail drain and capture setup around the quiet handshake; the running flag before each read-latency measurement and around each sense conversion; the DIO edges recorded since the last message, at a pause or stop. Never during a window
CPU 18Ordinary GPIO ports 0 and 1: the DIO pins, the Pro's with their translators' directions and the standalone board's J8 (dio.c), port 0 pin 8 for the target regulator (target_power.c), and the energy circuit's latch and calibration pins (energy_monitor.c)Vendor 0x8E, 0x8F and 0x90, and the energy calibration at boot; own core, never during a window
CPU 17RNG registers, SYSCON clock/reset and PMC power control for the capture's 128-bit boot valueAt a capture start, until one initialization succeeds; bounded entropy/health waits; own core, outside every wire window
CPU 17CTimer 2 for the Pro's energy-capture trigger; SYSCON, IOCON and INPUTMUX for setupEnergy capture start/stop, and IOCON at boot on the Pro; CTimer 2 stopped and started around each read-latency measurement
CPU 18, 10DMA0's busy bit and ADC0's status, polled until the held capture is idleBefore each read-latency measurement, while capture runs
CPU 18, 10DMA0's error bits, channel 21's two completion flags and ADC0's status, to tell a failed capture (energy_capture_failed)Energy commands and 0x94 while a capture runs; own core, never during a window
CPU 18Channel 21's completion flags and XFERCFG, for the ring's position (ring_written)The latest sample (0x90 mode 1) while a capture runs, and a pause's drain; own core, never during a window
CPU 17SYSCON clocks and IOCON for the DIO pins (dio_init)Boot only, on the Pro and the standalone board
CPU 17PINT's enables for the DIO pins, turned off as SPI takes them (dio_spi_begin)Each 0x91 SPI command, on the Pro; own core, never during a window
CPU 17CTimer 4's count, the stamp for SPI's edge gap, only once an energy capture has clocked it (dio_spi_begin)Each 0x91 SPI command, on the Pro; own core, never during a window
CPU 17SYSCON clock selects and IOCON for the bridges' pins: DIO0 to DIO3 for SPI, P0_4 and P0_21 for I2CEach 0x91 and 0x92 command, on the Pro; own core, never during a window
CPU 19HS SPI (Flexcomm 8): its configuration and FIFO, polled through each transferEach 0x91 command, on the Pro; own core, never during a window
CPU 18Flexcomm 3 as I2C master, polled through each transfer, and port 0's GPIO for P0_4 and P0_21 when it clears a stuck busEach 0x92 command, on the Pro, with SWO off; own core, never during a window
CPU 17, 8SWO: SYSCON resets and clocks, Flexcomm 3, DMA0 channel 8's regs and its bit in the shared ones, each written one bit per channel; its two completion flags and XFERCFG for the ring's position, and the stop and restart after a lost countSWO commands only
DMA08 then 11Flexcomm 3 FIFO to the SWO ringWhenever SWO bytes arrive
DMA08 then 2Flexcomm 0 and 1 FIFOs to the consoles' receive ringsWhenever console bytes arrive
DMA02 then 8The consoles' send buffers to Flexcomm 0 and 1 FIFOsEach send from the host
DMA011, 2Descriptors: channel entries and SWO's ring in dap_shared, the consoles' rings in SRAM0Each send, and each segment of a ring
DMA010, 2, 11ADC0 RESFIFO to the energy ring in SRAM0, two segments of 16 to 512 words, about 1 ms each at the capture's rate; channel 21's table entry in dap_shared, its reload descriptors in SRAM0While energy capture runs, except during a read-latency measurement; about seven DMA reads per voltage/current/range sample from 10,000 samples/s and 6.4 below 3,000, measured: the voltage's and the current's results arrive together, and up to two reads after each burst find the FIFO empty; 1,000 to 2,000 interrupts/s from 2,286 samples/s, about 1,370/s at 100 ksamples/s, two fifths of the sample rate below 2,286
USB HS controller11Endpoint buffers in USB SRAMEvery USB transfer
CPU 00, 2Code and dataAlways
CPU 03, 4 or 5DAP_TransferAbort, one byte in CPU 1's .bss, through dap_shared.transfer_abortThe moment an abort arrives, so possibly during a window
CPU 09, 11USB device regs and buffers (TinyUSB)Every USB transfer
CPU 011 then 5Each staged command, from its USB slot into dap_stage, and each staged reply backAs each arrives and as each starts to send, so during CPU 1's windows when commands are queued
CPU 05 then 11Each HID reply, from dap_stage into TinyUSB's HID bufferAs each starts to send, so during CPU 1's windows when commands are queued
CPU 011 then 5Each Verge Aux request, from its USB buffer into dap_stage, and each reply backOn the Pro and the standalone board, as each arrives and as each reply is taken, so during CPU 1's windows
CPU 0, CPU 16Stream message payload slots, 16 × 512 bytes, reserved at 0x2004_0000 in both linkers: one queue, for one stream at a timeThe capture owner builds each message before publishing its SRAM0 length and index; CPU 0 sends published slots. CPU 1 writes only outside timed windows under capture ownership; no DMA uses this bank
CPU 06 then 11Each energy stream message, from its reserved SRAM4 slots to Verge Aux's USB bufferWhile a stream runs, up to about 1,000 times a second
CPU 08USART0/1 (VCOM), mailbox, DMA0 regs: its setup, the console channels, both completion flags of every ring in the interruptContinuously; the consoles' ring positions while it waits
CPU 02, 6, 8, 10, 11Integrates each completed energy segment in the DMA interrupt, running from SRAM0: checks DMA0's error bits and channel 21's completion flags and ADC0's overflow bit, reads the samples and its state in SRAM0, and writes stream payloads in SRAM4, and updates the accumulator in dap_sharedEach completed energy segment, except while CPU 1 owns capture state
CPU 08GPIO0: reads P0_29 and P0_30, pulses P0_17, to re-arm the energy capture's low rangeAt most once per completed energy-ring segment, after one that stayed on the high range under the low range's limit
CPU 07CTimer 2's counter and match output, polled until the ADC is between samples for that re-arm (ADC0's own status is on port 10, so CPU 0 does not poll it)From such a segment's end to the re-arm, while the conversion timer runs: each pass of CPU 0's loop polls once, and the loop keeps passing (its usual accesses, dap_stage on port 5 among them) until a pass lands in the window. A hold stops the timer, and the loop then waits as usual
CPU 011The consoles' channel entries in DMA0's tableEach send
CPU 011dap_shared.swo_segments, and swo_lost when SWO's count is lostEach SWO segment's interrupt
CPU 07CTimer 3 (the status LED), and on the Pro CTimer 1 (FUNC)488 times a second
CPU 07, 8, 11, 2The DIO edge interrupt (dio_edges.c): CTimer 4's counter and PINT's latches on port 7, both GPIO ports' PIN registers on port 8 (port 1's alone on the standalone MCU-Link), dap_shared.dio_spi_turns on port 11, an entry in the edge record in SRAM0Each run, while a stream reports edges: at most 100,000 a second on average
CPU 07PINT's enables and latches, CTimer 4's counter for the 10 ms check and, in a DIO stream, to move its origin and time its quietCPU 0's loop, while a stream reports edges
CPU 07, 2CTimer 4's counter and the oldest marker's stamp in SRAM0, for the markers' 10 ms checkCPU 0's loop, while a stream has markers waiting
CPU 07INPUTMUX's pin interrupt selects, PINT's reset and modeBoot only, on the Pro and the standalone MCU-Link
CPU 07SYSCON's CTimer 4 clock select, enable and reset, and CTimer 4's prescale, match control and run bitBoot only, on a board with DIO pins and no energy capture, where no capture starts CTimer 4
CPU 08Ordinary GPIO port 1 (the Pro's switched LEDs)488 times a second, on the Pro
CPU 07SYSCON and IOCON through vcom_start (USART_Init, CLOCK_*)Console initialization; line-coding changes touch only port 8
CPU 07SYSCON and IOCON reads for the SWO status request; SYSCON NMISRC for the CPU 1 wakeThose vendor control requests
CPU 07SYSCON (CPU 1 start), PMC (restart)Boot and restart only
CPU 08Ordinary GPIO (the board straps)Boot only

Concurrency has how the cores, the interrupts and DMA order their accesses to this state.

Timed windows and their exposure#

  • Bit paths, all wires (port 10 secure GPIO; code from port 1, or 0 in the ARM reference build, whose bit paths run from flash). The ordinary GPIO on port 8 shares with Flexcomm 0 to 4 and the mailbox, which CPU 0 polls, so the bit paths use the secure GPIO block instead. During energy capture, DMA0 reads ADC0 on port 10 and writes the ring on port 2. CPU 1's data bus wins every tie, but a DMA0 read of ADC0 already under way holds a secure GPIO access up to 2 cycles. A held store holds every edge after it, which only stretches a phase. A held sample placed after the next rising edge reads the next bit. So with capture asked for, the generated SWD and JTAG paths keep 2 cycles at the late end of such a sample's window, and their clocks lengthen where that leaves no room (gen_stall, Code generation). cJTAG samples come before that edge. Holding the conversion trigger for a measurement (energy_monitor_hold) stops the ADC reads, the ring writes and CPU 0's segment interrupts together, so latency measurements run without the stall. Capture is disabled by default. CPU 0's segment interrupt reads ADC0's status once a segment, on port 10 too. Apart from CPU 0's abort byte, no other master accesses SRAMX, SRAM1 or SRAM2. During capture, DMA0 writes SRAM0 and CPU 1 reads it, between windows.
  • A staged command's buffers (port 5). CPU 0 copies the next command in and the last reply out while CPU 1's transfer runs. CPU 0 boots with CPU 1's data bus at the top AHB matrix priority (SYSCON AHBMATPRIO, set in start_core1), so CPU 1 wins every tie there and on every other port. The lab measurement below found no cycle lost to CPU 0 at that priority.

No timed window uses port 7, so CPU 0's APB accesses (the LED, the DIO edge interrupt, the console initialization, the SWO status request) cannot move an edge. A timed path that touches an APB peripheral would bring all of them back as exposures.

What a port costs#

  • Port 7. A CTimer store stalls the core about 4 cycles, two in a row about 10, and a load about 9. The emulator's timing model counts none of these, so no timed window reaches an APB peripheral.
  • CPU 0 on CPU 1's SRAM port. At the reset priorities, CPU 0 copying within the bank CPU 1 was using cost CPU 1 cycles: 2 to 13 in a body of 256 loads and stores, in 8 to 55% of bodies. With CPU 1's data bus at the top priority, as start_core1 sets it, it cost none.
  • SRAM4 is slower than SRAM2 and SRAM3 with nothing else running: a load next to a store costs an extra cycle, 386 cycles against 259 for 128 load-store pairs. That is why dap_stage is in SRAM3. SRAMX through the data side costs two cycles an access.

From mculink-verge, where changes to this page go.