summaryrefslogtreecommitdiffstats
path: root/src/soc/nvidia/tegra124/lp0/Makefile
blob: e82edaa8c87a909317644e3a8d41834892261962 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
################################################################################
##
## Copyright 2014 Google Inc.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
################################################################################

-include ../../../../../.xcompile
GCC_PREFIX?=$(CROSS_COMPILE_arm)

CC = $(GCC_PREFIX)gcc
NM = $(GCC_PREFIX)nm
OBJCOPY = $(GCC_PREFIX)objcopy

OPENSSL = openssl
DD = dd
CP = cp
MV = mv
RM = rm

SIGKEY = 00000000000000000000000000000000

.PHONY: all
all: tegra_lp0_resume.fw

tegra_lp0_resume.elf: tegra_lp0_resume.ld tegra_lp0_resume.c
	$(CC) -marm -march=armv4t -mno-unaligned-access -nostdlib -static \
		-Os -fpie -Wl,--build-id=none -ggdb3 -T tegra_lp0_resume.ld \
		-include ../../../../include/stdint.h \
		-include ../../../../commonlib/include/commonlib/compiler.h \
		-o $@ $(filter %.c,$+)

tegra_lp0_resume.fw: tegra_lp0_resume.elf
	@# Get rid of any files we're about to create.
	$(RM) -f $@.nosig $@.sig $@.tosig
	@# Convert the ELF image into a binary image.
	$(OBJCOPY) -O binary $< $@.nosig
	@# Extract the part of the binary which needs to be signed.
	$(DD) bs=1 skip=544 if=$@.nosig of=$@.tosig
	@# Calculate a signature for that part.
	$(OPENSSL) dgst -mac cmac -macopt cipher:aes-128-cbc \
		-macopt hexkey:$(SIGKEY) -md5 -binary \
		$@.tosig > $@.sig
	@# Inject the signature into the binary image's header.
	$(DD) conv=notrunc bs=1 seek=272 count=16 if=$@.sig of=$@.nosig
	@# Copy the signed binary to the target file name.
	$(MV) $@.nosig $@

distclean clean:
	$(RM) -f tegra_lp0_resume.fw tegra_lp0_resume.fw.sig
	$(RM) -f tegra_lp0_resume.fw.tosig tegra_lp0_resume.elf