Firmware and Other Architectures
Everything so far had it easy: a well-behaved Linux program that announced its format, its processor, and even its function names. Firmware — the software baked into routers, cameras, sensors, and controllers — announces nothing. It is often a raw slab of bytes with no headers, no symbols, and no entry point, built for a processor that may not be the one in your computer. This chapter is a survey of how Ghidra meets that, with one part of it proven on real bytes.
Languages: naming a processor precisely
Chapter 2's language decision becomes manual
here. A Ghidra language is named in parts —
processor : endianness : size : variant —
and the vocabulary is concrete: the 12.2
tree carries 39 processor families, among
them AARCH64, ARM, MIPS, RISCV,
PowerPC, x86, and older lines like 6502
and Z80, each with its variants. Naming
one looks like AARCH64:LE:64:v8A: 64-bit
ARM, little-endian, version 8A instruction
set. Endianness and width are not paperwork:
guess them wrong and the disassembly is
confident nonsense, which troubleshooting
(chapter 15) teaches you to recognise.
Eight bytes, read for real
For the lab, two ARM64 instructions were
assembled by hand — mov w0, #0x2a (put 42
in a register) and ret — eight bytes with
no header, no format, no hints, kept as
examples/raw-sensor.bin. Imported headlessly
as raw bytes at base address 0x8000:
analyzeHeadless <project folder> GuideProject \
-import raw-sensor.bin \
-processor "AARCH64:LE:64:v8A" \
-loader BinaryLoader -loader-baseAddr 0x8000
A raw import has no entry point, so
auto-analysis found nothing to start from —
a lab script disassembled at the load
address instead, and Ghidra read the bytes
exactly as assembled (kept in
examples/headless-raw-arm64.txt):
00008000 mov w0,#0x2a
00008004 ret
That is the firmware workflow in miniature: you supply what the file would have said — processor, endianness, load address — and the engines do the rest. Every real firmware job is this, plus archaeology.
The archaeology, surveyed (documented)
Real firmware adds problems the eight bytes don't have, and honesty requires listing the big ones rather than pretending the demo was the job:
- Finding the load address. Code in a raw image refers to itself by absolute addresses; load the image at the wrong base and every reference points into fog. Analysts recover the true base from the device's documentation, from the update package's headers, or from the pattern of the addresses themselves.
- Finding where code starts. With no entry point, likely starting places are the reset vector (many processors store the first address at a known location in the image) and the neighbourhoods of recognisable strings — chapter 9's strings again, doing reconnaissance.
- Peripherals are just addresses. Firmware talks to hardware through memory-mapped registers: reads and writes to fixed addresses that are really buttons and sensors. Naming those regions (chapter 7's renaming, applied to memory) is much of real firmware annotation.
- Getting the bytes is its own subject. Extracting an image from an update file, a flash chip, or a running device is upstream of Ghidra entirely, and outside this guide's scope.
Check: the survey's promise is modest and kept — pointed at headerless bytes with the right processor and base, Ghidra disassembles them correctly, as the eight bytes prove. The judgement about which processor, which base, and where to start is the analyst's, and no tool in this guide supplies it.