From 4a85d2ec9ee011e3add6077fbe72368c86b152a5 Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 16 Jan 2024 10:45:45 -0800 Subject: [PATCH] Added documentation for the two parsers (ELF and FDT). --- tools/elf-parser/Makefile | 2 +- tools/elf-parser/README.md | 23 +++++++++++++++++++++++ tools/fdt-parser/README.md | 30 ++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tools/elf-parser/README.md create mode 100644 tools/fdt-parser/README.md diff --git a/tools/elf-parser/Makefile b/tools/elf-parser/Makefile index 585d8a973..fd89e343c 100644 --- a/tools/elf-parser/Makefile +++ b/tools/elf-parser/Makefile @@ -4,7 +4,7 @@ CC=gcc CFLAGS=-Wall -g -ggdb -CFLAGS+=-I../../include -DWOLFBOOT_ELF -DELF_PARSER -DDEBUG_ELF -DPRINTF_ENABLED +CFLAGS+=-I../../include -DWOLFBOOT_ELF -DELF_PARSER -DPRINTF_ENABLED EXE=elf-parser LIBS= diff --git a/tools/elf-parser/README.md b/tools/elf-parser/README.md new file mode 100644 index 000000000..9e192b91c --- /dev/null +++ b/tools/elf-parser/README.md @@ -0,0 +1,23 @@ +# ELF Parser Tool + +This tool demonstrates parsing ELF32/ELF64, showing the clear/load sections and entry point. + +## Building elf-parser + +From root: `make elf-parser` +OR +From `tools/elf-parser` use `make clean && make` + +## Example Output + +```sh +% ./tools/elf-parser/elf-parser wolfboot.elf +ELF Parser: +Loading elf at 0x7f9a18008000 +Found valid elf32 (little endian) +Program Headers 2 (size 32) + Load 18340 bytes (offset 0x10000) to 0x8000000 (p 0x8000000) + Clear 72 bytes at 0x20000000 (p 0x80047a4) +Entry point 0x8000000 +Return 0, Load 0x8000000 +``` diff --git a/tools/fdt-parser/README.md b/tools/fdt-parser/README.md new file mode 100644 index 000000000..4b5045fc1 --- /dev/null +++ b/tools/fdt-parser/README.md @@ -0,0 +1,30 @@ +# Flattened Device Tree (FDT) Parser + +This tool uses our internal FDT (fdt.c) parsing code to dump the device tree. There is also a `-t` option that tests making several updates to the device tree. + +## Building fdt-parser + +From root: `make fdt-parser` +OR +From `tools/fdt-parser` use `make clean && make` + +## Example Output + +```sh +% ./tools/fdt-parser/fdt-parser ./tools/fdt-parser/nxp_t1024.dtb +FDT Parser (./tools/fdt-parser/nxp_t1024.dtb): +FDT Version 17, Size 31102 +root (node offset 0, depth 1, len 0): + compatible (prop offset 8, len 13): fsl,T1024RDB + #address-cells (prop offset 36, len 4): ....| 00 00 00 02 + #size-cells (prop offset 52, len 4): ....| 00 00 00 02 + interrupt-parent (prop offset 68, len 4): ....| 00 00 00 01 + model (prop offset 84, len 13): fsl,T1024RDB + cpus (node offset 112, depth 2, len 4): + power-isa-version (prop offset 124, len 5): 2.06 + power-isa-b (prop offset 144, len 0): NULL + power-isa-e (prop offset 156, len 0): NULL + power-isa-atb (prop offset 168, len 0): NULL + power-isa-cs (prop offset 180, len 0): NULL +... +```