]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/arm926ejs/mxs/Makefile
arm: mxs: Add support for generating signed BootStream
[karo-tx-uboot.git] / arch / arm / cpu / arm926ejs / mxs / Makefile
1 #
2 # (C) Copyright 2000-2006
3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 #
5 # SPDX-License-Identifier:      GPL-2.0+
6 #
7
8 extra-$(CONFIG_SPL_BUILD) := start.o
9
10 obj-y   = clock.o mxs.o iomux.o timer.o
11
12 ifdef   CONFIG_SPL_BUILD
13 obj-y   += spl_boot.o spl_lradc_init.o spl_mem_init.o spl_power_init.o
14 endif
15
16 # Specify the target for use in elftosb call
17 MKIMAGE_TARGET-$(CONFIG_MX23) = mx23
18 MKIMAGE_TARGET-$(CONFIG_MX28) = mx28
19
20 # Convert hexadecimal value to bytes
21 define hex2bin
22 $(shell echo -n "$1" | sed 's/0x//;s/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/;s/../\\\\x&/g')
23 endef
24
25 # Compute the post-IVT size field value for the U-Boot binary.
26 # The value is the result of adding the following:
27 #  -> The size of U-Boot binary aligned to 64B (u-boot.bin)
28 #  -> The size of IVT block aligned to 64B (u-boot.ivt)
29 #  -> The size of U-Boot signature (u-boot.sig), 3904 B
30 #  -> The 64B hole in front of U-Boot binary for 'struct mxs_spl_data' passing
31 define uboot_ivt_size
32 $(shell expr `stat -c "%s" $1` + 64 + 3904 + 128 | xargs printf 0x%08x)
33 endef
34
35 $(OBJTREE)/mxsimage.cfg: $(SRCTREE)/$(CPUDIR)/$(SOC)/mxsimage.$(MKIMAGE_TARGET-y).cfg
36         sed "s@OBJTREE@$(OBJTREE)@g" $^ > $@
37
38 # HAB signature is i.MX28 only
39 $(OBJTREE)/mxsimage-signed.cfg: $(SRCTREE)/$(CPUDIR)/$(SOC)/mxsimage-signed.cfg
40         sed "s@OBJTREE@$(OBJTREE)@g" $^ > $@
41
42 $(OBJTREE)/spl/u-boot-spl.ivt: $(OBJTREE)/spl/u-boot-spl.bin
43         # Align U-Boot SPL binary to 64B
44         dd if=$^ of=$@ ibs=64 conv=sync 2>/dev/null
45         mv $@ $^
46         # Assemble IVT, append size field and align it to 64B.
47         (echo -ne "$(call hex2bin,0x402000d1)" ;                \
48          echo -ne "$(call hex2bin,$(CONFIG_SPL_TEXT_BASE))" ;   \
49          echo -ne "$(call hex2bin,0x00000000)" ;                \
50          echo -ne "$(call hex2bin,0x00000000)" ;                \
51          echo -ne "$(call hex2bin,0x00000000)" ;                \
52          echo -ne "$(call hex2bin,0x00008000)" ;                \
53          echo -ne "$(call hex2bin,0x00008040)" ;                \
54          echo -ne "$(call hex2bin,0x00000000)" ;                \
55          echo -ne "$(call hex2bin,$(call uboot_ivt_size,$^))"   \
56         ) | dd of=$@ ibs=64 count=1 conv=sync 2>/dev/null
57
58 $(OBJTREE)/u-boot.ivt: $(OBJTREE)/u-boot.bin
59         # Align U-Boot binary to 64B
60         dd if=$^ of=$@ ibs=64 conv=sync 2>/dev/null
61         mv $@ $^
62         # Assemble IVT, append size field and align it to 64B.
63         (echo -ne "$(call hex2bin,0x402000d1)" ;                \
64          echo -ne "$(call hex2bin,$(CONFIG_SYS_TEXT_BASE))" ;   \
65          echo -ne "$(call hex2bin,0x00000000)" ;                \
66          echo -ne "$(call hex2bin,0x00000000)" ;                \
67          echo -ne "$(call hex2bin,0x00000000)" ;                \
68          echo -ne "$(call hex2bin,0x40001000)" ;                \
69          echo -ne "$(call hex2bin,0x40001040)" ;                \
70          echo -ne "$(call hex2bin,0x00000000)" ;                \
71          echo -ne "$(call hex2bin,$(call uboot_ivt_size,$^))"   \
72         ) | dd of=$@ ibs=64 count=1 conv=sync 2>/dev/null
73
74 $(OBJTREE)/spl/u-boot-spl.csf: $(OBJTREE)/spl/u-boot-spl.ivt $(OBJTREE)/spl/u-boot-spl.bin $(TOPDIR)/board/$(VENDOR)/$(BOARD)/sign/u-boot-spl.csf
75         # Assemble the CSF file
76         sed "s@TOPDIR@$(TOPDIR)@g;s@VENDOR@$(VENDOR)@g;s@BOARD@$(BOARD)@g" \
77                 $(word 3,$^) > $@
78         sed -i "/^##Blocks.*/ d" $@
79         echo "  Blocks = $(CONFIG_SPL_TEXT_BASE) 0x0 "                  \
80                 "`stat -c '%s' $(word 2,$^)` \"$(word 2,$^)\" , \\"     \
81                 >> $@
82         echo "           0x8000 0x0 0x40 \"$(word 1,$^)\"" >> $@
83
84 $(OBJTREE)/u-boot.csf: $(OBJTREE)/u-boot.ivt $(OBJTREE)/u-boot.bin $(TOPDIR)/board/$(VENDOR)/$(BOARD)/sign/u-boot.csf
85         # Assemble the CSF file
86         sed "s@TOPDIR@$(TOPDIR)@g;s@VENDOR@$(VENDOR)@g;s@BOARD@$(BOARD)@g" \
87                 $(word 3,$^) > $@
88         sed -i "/^##Blocks.*/ d" $@
89         echo "  Blocks = $(CONFIG_SYS_TEXT_BASE) 0x0 "                  \
90                 "`stat -c '%s' $(word 2,$^)` \"$(word 2,$^)\" , \\"     \
91                 >> $@
92         echo "           0x40001000 0x0 0x40 \"$(word 1,$^)\"" >> $@
93
94 %.sig: %.csf
95         cst -o $@ < $^
96
97 $(OBJTREE)/u-boot-signed.sb: $(OBJTREE)/u-boot.ivt $(OBJTREE)/u-boot.sig $(OBJTREE)/spl/u-boot-spl.ivt $(OBJTREE)/spl/u-boot-spl.sig $(OBJTREE)/mxsimage-signed.cfg
98         $(OBJTREE)/tools/mkimage -n $(OBJTREE)/mxsimage-signed.cfg -T mxsimage $@
99
100 $(OBJTREE)/u-boot.sb: $(OBJTREE)/u-boot.bin $(OBJTREE)/spl/u-boot-spl.bin $(OBJTREE)/mxsimage.cfg
101         $(OBJTREE)/tools/mkimage -n $(OBJTREE)/mxsimage.cfg -T mxsimage $@