



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Linkers Programmers Booting an embedded CPU Debuggers JTAG
Subsequent lectures deal with embedded C
Compiler turns compilation unit into an object file
text segment โ executable code data segment โ initialized data BSS segment โ uninitialized data Other stuff โ debugging symbols, etc.
Relocatable Code and data addresses are symbolic โ not yet bound to physical addresses Contain unresolved references
1. Merge text, data, BSS segments of individual object files Including libraries **Including processor boot code
Weak โ uninitialized globals Strong โ functions and initialized globals
Bizarre consequence: Same object file might have to appear on command line multiple times
int foo=5;
p1() { }
int foo;
p2() { }
p1.c p2.c
strong
weak
strong
strong
otherwise error
I.e. all references to that name resolve to the strong symbol
uh oh
Needs a โprogramโ to tell it how to link for a given embedded platform Linker script syntax looks just like GNU linker
Put parts of executable into the right parts of memory Insert padding to meet alignment requirements Define extra symbols Do arithmetic Keep track of current position in memory as โ.โ
code (RX) : ORIGIN = 0x00000500, LENGTH = 0x0003FB userram (RWX) : ORIGIN = 0x20000400, LENGTH = 0x00007C }
___heap_size = 0x1000; ___stack_size = 0x1000; }
RAMBAR = 0x20000000; RAMBAR_SIZE = 0x00008000;
FLASHBAR = 0x00000000; FLASHBAR_SIZE = 0x00040000;
.vectors : { mcf5xxx_vectors.s (.text)
. = ALIGN (0x4); } >> vectorrom
*.text : { (.text)
*. = ALIGN (0x4); (.rodata) . = ALIGN (0x4); ___ROM_AT = .; ___DATA_ROM = .; } >> code
.data : { ___DATA_RAM = .;
. = ALIGN(0x4);
_sinit = .; STATICINIT __START_DATA = .;
*(.data)
. = ALIGN (0x4); __END_DATA = .;
} >> userram
Plus lots more
Observability โ See internal processor state Real-time analysis โ Follow execution without slowing it down or stopping it Run control โ Start and stop the processor, set breakpoints, watches, etc.
Which capabilities does it provide? What are its other pros and cons?
Minimal workable debugging environment A most unpleasant way to debug complex software
Severely perturbs timing, typically Generally, a debug printf() is synchronous Means: Hangs the system until the printf completes Why?
Timing mode โ displays logic transitions on pins State mode โ decode executing instructions, bus transactions, etc. Triggers โ give the analyzer conditions on which to start a detailed trace Triggers can be highly elaborate
Debugging stub runs on embedded processor Main debugger (e.g., GDB) runs on a separate machine The two communicate using Ethernet, serial line, or whatever
Basically just hardware implementations of debugging stubs
Acts like your embedded processor but provides lots of extra functionality Runs at full speed Typically expensive
Looks like ROM, actually RAM + processor At minimum supports rapid loading of new SW Can implement breakpoints, execution tracing
Maximum controllability and observability Often slow Hard to interface to the real world Easy to simulate the CPU, hard to simulate everything else
Each I/O pin, register, etc. can be โsniffedโ by a JTAG cell JTAG cells are connected in a โJTAG loopโ Contents of entire JTAG loop can be read using a shift register Can also be written External tool can reconstruct machine state from the JTAG bit stream
Each JTAG cell โsniffsโ the state of the corresponding output bit of the IC
JTAG bit stream in JTAG bit stream out
Bit stream forms one long shift-register
PC Board
JTAG Connector
Processor Core
Program Counter - PC
Register R
Register R
Register Rn
Addr Bus Interface
Data Bus Interface
Status Bus Interface
JTAG Control State Machine
JTAG in
Clock in (^) JTAG out
โSPECIALโ REGISTER SET
Simple Requires few pins
End up reading and writing a lot of data just to change one register
Commands โ Directly change a single register or memory cell Addressable loops โ smaller JTAG loops each containing a subset of the machine state
TCK โ clock TDI โ input data stream, sampled on rising edge of TCK TDO โ output data stream, updated on falling edge of TCK TRST โ Resets JTAG state machine (optional) TMS โ Test mode select: advances JTAG state machine
โLow costโ solutions may be $ However, all-software solutions (on the host side) exist MCF52233 has JTAG