Skip to content

Commit

Permalink
Use autotools as build system
Browse files Browse the repository at this point in the history
Change the build system from simple Makefile to autotools.

This will provide the missing install and uninstall targets.
Furthermore passing CPPFLAGS will be supported.

Signed-off-by: Heinrich Schuchardt <[email protected]>
  • Loading branch information
xypron committed May 16, 2017
1 parent 5e01cba commit e765cae
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 21 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Andreas Färber <[email protected]>
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Version 0.2, 2017-xx-yy
Use autotools as build system
Version 0.1, 2017-05-01
Initial release
21 changes: 0 additions & 21 deletions Makefile

This file was deleted.

3 changes: 3 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUBDIRS = src

ACLOCAL_AMFLAGS = -I m4
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Version 0.1, 2017-05-01
Initial Release
76 changes: 76 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# meson-tools

meson-tools is a collection of tools for use with the Amlogic Meson family of ARM based SoCs.

Name-wise it was inspired by [sunxi-tools](https://github.com/linux-sunxi/sunxi-tools/).

## amlbootsig

Usage:
```
amlbootsig boot_new.bin u-boot.img
```

This tool is supposed to provide equivalent output to:
```
aml_encrypt_gxb --bootsig --input boot_new.bin --output u-boot.img
```
with the tool version distributed by Hardkernel for their Odroid-C2 board (S905 / Meson GXBaby).

### How to compare output

```
hexdump -C a/u-boot.img > a/u-boot.img.hex
hexdump -C b/u-boot.img > b/u-boot.img.hex
diff -u a/u-boot.img.hex b/u-boot.img.hex | less
```

This should result in a diff with only the following differences:

* First 16 bytes will be random in original.
* The header for each FIP TOC entry will contain 4 bytes of random data.
* Due to FIP TOC entry headers differing, the SHA256 hash in the header will differ as well.

For testing identity of output files, modify the code to use the random bytes from the file you are testing against.

### Known limitations

* Correctness: Since amlbootsig was designed to binary-match previously created output files, it may still have some numbers hard-coded or may do calculations in a way that happened to match tested input/output but may break for other input files. Please report such cases as GitHub issues.
* Endianness: Only Little Endian byte order has been considered. Running it on Big Endian hosts may misinterpret file input and/or result in wrong output and/or other misbehavior. The solution would be byte swaps, but those depend on the field width, which is guessed only and thus may change as the format is being better understood.
* Security: The tool was not designed to defend against invalid or evil file input.

## unamlbootsig

Usage:
```
unamlbootsig u-boot.img boot_new.bin
```

This tool is supposed to do the reverse of `amlbootsig`, i.e. drop the boot signature.

The output may differ from the original `aml_encrypt_gxb --bootsig`/`amlbootsig` input from 0xb000 to 0xbfff as well as in FIP TOC entry size 16-byte alignment.

### Known limitations

See `amlbootsig`.

## amlinfo

Usage:
```
amlinfo u-boot.img
```

This tool dumps info about an existing image file.

It supports the following inputs:
* `amlbootsig` output
* `aml_encrypt_gxb --bootsig` output, except when using `--amluserkey` or `--efuse`
* `dd if=u-boot.img bs=512 skip=96` output for either of them (FIP TOC with headered entries)
* `dd if=u-boot.img bs=1 skip=16` output, i.e. raw `@AML` header, of at least 64 bytes

### Known limitations

* Correctness: Since there seems to be no public documentation for the @AML headers, any field names printed are guesses and may need to be revised once their meaning becauses clearer.
* Endianness: Only Little Endian byte order has been considered, see above.
* Security: See above.
12 changes: 12 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

test -f configure.ac || {
echo "Please, run this script in the top level project directory."
exit
}

libtoolize --force --copy
aclocal -I m4
autoconf
automake --add-missing --copy

26 changes: 26 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
dnl meson-tools

dnl Initialization
AC_INIT([meson-tools], [0.2], [Andreas Färber <[email protected]>])
AM_INIT_AUTOMAKE
LT_INIT

dnl Configure macros
AC_CONFIG_MACRO_DIR([m4])

LDFLAGS+=" -lcrypto"

AC_CHECK_HEADER([openssl/sha.h],
[],
[AC_MSG_ERROR([openssl/sha.h not found. Please, install libssl-dev.])]
)

dnl Makefiles
AC_CONFIG_FILES([
Makefile
src/Makefile
])

dnl Generate files
AC_OUTPUT

5 changes: 5 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin_PROGRAMS = amlbootsig unamlbootsig amlinfo

amlbootsig_SOURCES = amlbootsig.c fip.h meson.h
unamlbootsig_SOURCES = unamlbootsig.c fip.h meson.h
amlinfo_SOURCES = amlinfo.c fip.h meson.h
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e765cae

Please sign in to comment.