-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (44 loc) · 1.69 KB
/
Makefile
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
#!/bin/make
#######################################################
# #
# Makefile for i.MX HAB authenticated (signed) boot #
# #
#######################################################
# required: bc, objcopy (any arch), sed, cst
# Usage:
#
# Copy u-boot.imx to this directory
#
# $ make
#
# Place u-boot-signed.imx on the boot medium
#
# Configuration
RSA_LENGTH?=4096
LOAD_ADDR?=0x87800000
#
MACHINE_BITS != getconf LONG_BIT
CST=../linux$(MACHINE_BITS)/cst
# keyfile dependency - remember to update also u-boot-sign.csf.in when changing filenames
KEYS=../crts/SRK_1_2_3_4_table.bin ../crts/CSF1_1_sha256_$(RSA_LENGTH)_65537_v3_usr_crt.pem ../crts/IMG1_1_sha256_$(RSA_LENGTH)_65537_v3_usr_crt.pem
# u-boot.imx size (hex)
UBOOT_SIZE != echo 0x`stat -c "obase=16; %s" u-boot.imx | bc`
# ivt address in DRAM (hex)
IVT_ADDR != echo 0x`echo "obase=16;ibase=16; $(LOAD_ADDR) - 0xC00" | sed -e "s/0x//g" | bc`
.PHONY: all
all: u-boot-signed.imx
u-boot-sign.csf: u-boot-sign.csf.in u-boot.imx
cat u-boot-sign.csf.in | sed \
-e "s/%%RSA_LENGTH%%/$(RSA_LENGTH)/" \
-e "s/%%IVT_ADDR%%/$(IVT_ADDR)/" \
-e "s/%%UBOOT_SIZE%%/$(UBOOT_SIZE)/" \
> u-boot-sign.csf
u-boot-hab.bin: u-boot-sign.csf u-boot.imx $(KEYS)
$(CST) -i u-boot-sign.csf -o u-boot-hab.bin
u-boot-hab_padded.bin: u-boot-hab.bin
$(OBJCOPY) objcopy -I binary -O binary --pad-to 0x2000 --gap-fill 0xff u-boot-hab.bin u-boot-hab_padded.bin
u-boot-signed.imx: u-boot.imx u-boot-hab_padded.bin
cat u-boot.imx u-boot-hab_padded.bin > u-boot-signed.imx
.PHONY: clean
clean:
rm -rf u-boot-sign.csf u-boot-hab.bin u-boot-hab_padded.bin u-boot-signed.imx