2 # (C) Copyright 2000-2006
3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 # SPDX-License-Identifier: GPL-2.0+
8 extra-$(CONFIG_SPL_BUILD) := start.o
10 obj-y = clock.o mxs.o iomux.o timer.o
12 ifdef CONFIG_SPL_BUILD
13 obj-y += spl_boot.o spl_lradc_init.o spl_mem_init.o spl_power_init.o
16 # Specify the target for use in elftosb call
17 MKIMAGE_TARGET-$(CONFIG_MX23) = mx23
18 MKIMAGE_TARGET-$(CONFIG_MX28) = mx28
20 # Convert hexadecimal value to bytes
22 $(shell echo -n "$1" | sed 's/0x//;s/\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/;s/../\\\\x&/g')
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
32 $(shell expr `stat -c "%s" $1` + 64 + 3904 + 128 | xargs printf 0x%08x)
35 $(OBJTREE)/mxsimage.cfg: $(SRCTREE)/$(CPUDIR)/$(SOC)/mxsimage.$(MKIMAGE_TARGET-y).cfg
36 sed "s@OBJTREE@$(OBJTREE)@g" $^ > $@
38 # HAB signature is i.MX28 only
39 $(OBJTREE)/mxsimage-signed.cfg: $(SRCTREE)/$(CPUDIR)/$(SOC)/mxsimage-signed.cfg
40 sed "s@OBJTREE@$(OBJTREE)@g" $^ > $@
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
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
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
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
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" \
78 sed -i "/^##Blocks.*/ d" $@
79 echo " Blocks = $(CONFIG_SPL_TEXT_BASE) 0x0 " \
80 "`stat -c '%s' $(word 2,$^)` \"$(word 2,$^)\" , \\" \
82 echo " 0x8000 0x0 0x40 \"$(word 1,$^)\"" >> $@
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" \
88 sed -i "/^##Blocks.*/ d" $@
89 echo " Blocks = $(CONFIG_SYS_TEXT_BASE) 0x0 " \
90 "`stat -c '%s' $(word 2,$^)` \"$(word 2,$^)\" , \\" \
92 echo " 0x40001000 0x0 0x40 \"$(word 1,$^)\"" >> $@
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 $@
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 $@