Skip to content

Commit ba615f1

Browse files
committed
project: Add README
1 parent 3fa49dd commit ba615f1

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

Diff for: README.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Overview
2+
3+
The goal of this project is to understand the various blobs provided by
4+
Allwinner for their `sunxi` series of ARM SoCs. This includes understanding the
5+
interfaces the blobs provide and the bits of undocumented hardware they use.
6+
Currently, the tools in this repository are set up to process two types of
7+
blobs: the boot ROMs and the ARISC firmware.
8+
9+
From the original, untouched blobs, the tools here can generate ELF objects with
10+
symbols, annotated assembly listings, and SVG graphs documenting the control
11+
flow of code within the blob.
12+
13+
## Boot ROMs (BROM)
14+
15+
The boot ROM, is flashed into the SoC hardware, and is generally the same for
16+
every chip of the same model. It comes in two flavors: normal (NBROM) and secure
17+
(SBROM). The secure boot ROM is much larger and more complicated because it must
18+
verify the next stage of firmware before running it. Unfortunately, only one of
19+
the ROMs is visible at a time, depending on the state of the device's "secure
20+
boot" eFuse.
21+
22+
The BROM blobs in this repository were dumped from running devices using `md`
23+
from within u-boot.
24+
25+
## ARISC firmware
26+
27+
These files are closed-source firmware provided by Allwinner with their board
28+
support package (BSP), usually with the name `scp.bin`. Slightly different
29+
versions of the firmware are provided in the BSPs from different board
30+
manufacturers. By looking at the changes between versions (and knowing the order
31+
from the embedded version number), we can determine the history of changes made
32+
to the firmware.
33+
34+
While the firmware is proprietary, source code is provided in an AES-encrypted
35+
tarball in [various released Linux kernel trees][tinalinux].
36+
37+
[tinalinux]:
38+
https://github.com/tinalinux/linux-3.10/tree/r18-v0.9/drivers/arisc/binary
39+
40+
# Prerequisites
41+
42+
These tools require a cross `binutils` (or full toolchain) for each architecture
43+
of blobs you want to process. Note that even on SoCs that support AArch64, the
44+
BROM is still AArch32, so you will need ARM cross tools for them. Cross
45+
toolchains can be downloaded from Linaro for ARM, [GitHub][or1k-toolchains] for
46+
OpenRISC, or they can be built manually with [musl-cross-make][musl-cross-make].
47+
If your cross toolchain is named differently, edit the top of the `Makefile` to
48+
provide your path or prefix.
49+
50+
[musl-cross-make]: https://github.com/smaeul/musl-cross-make
51+
[or1k-toolchains]: https://github.com/openrisc/or1k-gcc/releases
52+
53+
Beyond that, the scripts only require `bash` and standard POSIX utilities.
54+
55+
# Using the tools
56+
57+
`make BLOB=<soc>/<blob_name>` will build a single blob all the way from the
58+
hexdump to the call graph. You can simply run `make` to build all files for all
59+
blobs. You can run `make <soc>/<blob_name>/<file>` for any file (`annotated.s`
60+
`blob.elf`, `blob.s`, `callgraph.dot`, and `callgraph.svg`) to only make that
61+
file and its dependencies.
62+
63+
There are some additional scripts that are useful for processing newly-found
64+
blobs or forr other specific use cases. They are not hooked up to the
65+
`Makefile`, so they must be run manually. Documentation is at the top of each
66+
script.
67+
68+
# Contributing
69+
70+
After modifying the annotations in `annotated.s`, run `make save` to copy them
71+
back to the `comments` file. You can then commit your changes to `comments`. If
72+
you find a new, previously-unmarked function, create a symbol for it in the
73+
`symbols` file. *Add two blank lines before the first instruction in
74+
`annotated.s` and run `make save` before running `make` again*. This is
75+
important to keep the comments aligned, as `objdump` will place a blank line and
76+
a line with the symbol name before the function.
77+
78+
Please run `make check` to check the consistency of your symbols and sections
79+
files.

0 commit comments

Comments
 (0)