Posts Tagged ‘read microcontroller dsp mcu encrypted eeprom’
Read a DSP Plus MCU Program: The Shared Memory Arbitration Window
Devices that combine a DSP core and a microcontroller core on one die solve a system problem elegantly: the DSP handles deterministic signal processing, the MCU handles control and communication, and they exchange data through memory that both can reach. That shared memory is the feature that makes the architecture attractive and the obstacle that makes reading the device difficult.
The obstacle is arbitration. Two cores cannot write the same memory bank in the same cycle, so a hardware arbiter grants access according to a policy. A read issued by a debugger or a loader is a third contender, and it competes with both cores. If the read takes longer than one grant, the value it returns may combine bytes from before and after a write by one of the cores.
What the arbiter actually does
| Policy | Behaviour | Effect on a read |
|---|---|---|
| Fixed priority | One core always wins | The other can be starved; reads may be blocked |
| Round robin | Access alternates per cycle | A multi-cycle read spans several grants |
| Burst-aware | A core keeps the bus for a burst | Reads wait for the burst to end |
| Time-slot | Each core has reserved slots | Reads must fit within an unused slot |
The second row is where torn reads come from. A 32-bit read that takes two bus cycles will, under round-robin arbitration, be served one cycle at a time with the other core interleaved between them. If the other core writes the same word in between, the read returns a value composed of two different writes.
What a torn read looks like
A torn value is not obviously wrong. It is the concatenation of a valid high half and a valid low half, and each half is a number the program could legitimately have written.
| Content type | Effect of a torn read |
|---|---|
| A counter | A value that jumps backwards or forwards implausibly |
| A pointer | An address that is aligned but points somewhere unrelated |
| A status word | Bits that contradict each other |
| A floating-point value | A plausible but wrong number |
| A checksum | A mismatch that disappears on a second read |
The last row is the diagnostic. A checksum failure that does not reproduce on a second read is almost always a torn read rather than a corrupted memory.
Reading safely
There are four practical approaches, and they differ in how much they perturb the system.
| Approach | Method | Cost |
|---|---|---|
| Halt both cores | Stop execution, then read | Requires control of both cores |
| Halt one core, read through the other | Use the running core as the reader | Requires code execution ability |
| Read twice and compare | Detect tearing statistically | No control needed; slower |
| Read with the arbiter in a fixed grant | Force a policy, then read | Requires arbiter control |
The second row is underused and often the only option on a device where the debug access is attached to one core. The running core reads its own memory in a way the arbiter treats as a normal access, and the values are consistent because they come from a single grant.
The third row is the fallback and it is genuinely useful: reading the same region several times and keeping only the words that are identical across all reads filters out most tearing, at the cost of missing the values that are legitimately changing.
The regions and their behaviour
Not all memory behaves the same, and knowing the map is half the work.
| Region | Accessed by | Read behaviour |
|---|---|---|
| DSP-private RAM | DSP only | Stable if the DSP is halted |
| MCU-private RAM | MCU only | Stable if the MCU is halted |
| Shared RAM, single-ported | Both, arbitrated | Torn reads possible |
| Shared RAM, dual-ported | Both, simultaneously | Stable, unless both write |
| Shared registers | Both, hardware synchronised | Stable; designed for this |
| Message RAM with semaphores | Both, software protocol | Stable if the protocol is respected |
The fourth row describes true dual-port memory, which is genuinely immune to tearing at the hardware level but still permits a logical race: two simultaneous writes leave one value, and which one is undefined.
Semaphores are a hint about the protocol
Where the design uses hardware semaphores or a message protocol, those structures document the intended producer-consumer relationship, and reading them tells you which regions are exchanged and in which direction.
| Structure | What it reveals |
|---|---|
| Semaphore registers | Which regions are shared, and by how many parties |
| Mailbox registers | Command and response formats |
| Interrupt flags | Event direction and priority |
| Ring buffer indices | The exchange data structure and its size |
The fourth row is the most informative. A pair of indices at the start of a shared buffer defines a producer-consumer ring, and reading them establishes the element size, the buffer length, and which core is the producer — all from two words.
Why this affects the deliverable
A read that ignores arbitration produces an image with scattered errors, and those errors are hard to distinguish from genuine data. The analyst then spends time explaining anomalies that are artefacts of the read method.
| Deliverable | Without arbitration handling | With it |
|---|---|---|
| DSP image | Scattered wrong words | Consistent |
| MCU image | Scattered wrong words | Consistent |
| Shared region | Torn values | Stable snapshot |
| Interface spec | Derived from faulty data | Derived from evidence |
The distinction between reading a device and reading a system is the theme of reading DSP and CPLD dump information, which deals with the same problem across two separate chips rather than two cores. Where the shared region holds the DSP’s coefficients, reading DSP chip program covers why those tables matter so much. The section layout of each core’s own image is in reading DSP embedded source code.
Services at this boundary
Work covers core and memory map identification, arbitration policy determination, halt-and-read where control is available, double-read filtering where it is not, and validation of the recovered image against known-good checksums. It does not cover producing a coherent snapshot of a system that is running with no way to quiesce it, because coherence requires either a halt or a protocol.
The practical statement is that shared memory is not memory as far as reading is concerned; it is a moving target with a rule, and the rule has to be known before the read means anything.