| 1 |
|
| 2 |
|
| 3 |
xcompile ?= ../../../../../build/xcompile |
| 4 |
-include $(xcompile) |
| 5 |
|
| 6 |
GCC_PREFIX?=$(CROSS_COMPILE_arm) |
| 7 |
|
| 8 |
CC = $(GCC_PREFIX)gcc |
| 9 |
NM = $(GCC_PREFIX)nm |
| 10 |
OBJCOPY = $(GCC_PREFIX)objcopy |
| 11 |
|
| 12 |
OPENSSL = openssl |
| 13 |
DD = dd |
| 14 |
CP = cp |
| 15 |
MV = mv |
| 16 |
RM = rm |
| 17 |
|
| 18 |
SIGKEY = 00000000000000000000000000000000 |
| 19 |
|
| 20 |
.PHONY: all |
| 21 |
all: tegra_lp0_resume.fw |
| 22 |
|
| 23 |
tegra_lp0_resume.elf: tegra_lp0_resume.ld tegra_lp0_resume.c |
| 24 |
$(CC) -marm -march=armv4t -mno-unaligned-access -nostdlib -static \ |
| 25 |
-Os -fpie -Wl,--build-id=none -ggdb3 -T tegra_lp0_resume.ld \ |
| 26 |
-include ../../../../include/stdint.h \ |
| 27 |
-include ../../../../commonlib/bsd/include/commonlib/bsd/compiler.h \ |
| 28 |
-o $@ $(filter %.c,$+) |
| 29 |
|
| 30 |
tegra_lp0_resume.fw: tegra_lp0_resume.elf |
| 31 |
@# Get rid of any files we're about to create. |
| 32 |
$(RM) -f [email protected] [email protected] [email protected] |
| 33 |
@# Convert the ELF image into a binary image. |
| 34 |
$(OBJCOPY) -O binary $< [email protected] |
| 35 |
@# Extract the part of the binary which needs to be signed. |
| 36 |
$(DD) bs=1 skip=544 [email protected] [email protected] |
| 37 |
@# Calculate a signature for that part. |
| 38 |
$(OPENSSL) dgst -mac cmac -macopt cipher:aes-128-cbc \ |
| 39 |
-macopt hexkey:$(SIGKEY) -md5 -binary \ |
| 40 |
[email protected] > [email protected] |
| 41 |
@# Inject the signature into the binary image's header. |
| 42 |
$(DD) conv=notrunc bs=1 seek=272 count=16 [email protected] [email protected] |
| 43 |
@# Copy the signed binary to the target file name. |
| 44 |
$(MV) [email protected] $@ |
| 45 |
|
| 46 |
distclean clean: |
| 47 |
$(RM) -f tegra_lp0_resume.fw tegra_lp0_resume.fw.sig |
| 48 |
$(RM) -f tegra_lp0_resume.fw.tosig tegra_lp0_resume.elf |