1 ################################################################################
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; version 2 of the License.
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
13 ################################################################################
15 -include ..
/..
/..
/..
/..
/.xcompile
16 GCC_PREFIX?
=$(CROSS_COMPILE_arm
)
20 OBJCOPY
= $(GCC_PREFIX
)objcopy
28 SIGKEY
= 00000000000000000000000000000000
31 all: tegra_lp0_resume.fw
33 tegra_lp0_resume.elf
: tegra_lp0_resume.
ld tegra_lp0_resume.c
34 $(CC
) -marm
-march
=armv4t
-mno-unaligned-access
-nostdlib
-static \
35 -Os
-fpie
-Wl
,--build-id
=none
-ggdb3
-T tegra_lp0_resume.
ld \
36 -include ..
/..
/..
/..
/include/stdint.h \
37 -include ..
/..
/..
/..
/commonlib
/bsd
/include/commonlib
/bsd
/compiler.h \
38 -o
$@
$(filter %.c
,$+)
40 tegra_lp0_resume.fw
: tegra_lp0_resume.elf
41 @
# Get rid of any files we're about to create.
42 $(RM
) -f
$@.nosig
$@.sig
$@.tosig
43 @
# Convert the ELF image into a binary image.
44 $(OBJCOPY
) -O binary
$< $@.nosig
45 @
# Extract the part of the binary which needs to be signed.
46 $(DD
) bs
=1 skip
=544 if
=$@.nosig of
=$@.tosig
47 @
# Calculate a signature for that part.
48 $(OPENSSL
) dgst
-mac cmac
-macopt cipher
:aes-128-cbc \
49 -macopt hexkey
:$(SIGKEY
) -md5
-binary \
51 @
# Inject the signature into the binary image's header.
52 $(DD
) conv
=notrunc bs
=1 seek
=272 count
=16 if
=$@.sig of
=$@.nosig
53 @
# Copy the signed binary to the target file name.
57 $(RM
) -f tegra_lp0_resume.fw tegra_lp0_resume.fw.sig
58 $(RM
) -f tegra_lp0_resume.fw.tosig tegra_lp0_resume.elf