blob: 19dd5eb6f4990deb9a52f8df98fb687d47c1e44c [file] [log] [blame]
wdenk452cfd62002-11-19 11:04:11 +00001#
Marian Balakowiczd62379d2006-09-01 19:49:50 +02002# (C) Copyright 2000-2006
wdenk452cfd62002-11-19 11:04:11 +00003# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005# SPDX-License-Identifier: GPL-2.0+
wdenk452cfd62002-11-19 11:04:11 +00006#
7
8LOAD_ADDR = 0x40000
9
10include $(TOPDIR)/config.mk
11
Marian Balakowiczd62379d2006-09-01 19:49:50 +020012PROG = $(obj)updater
13IMAGE = $(obj)updater.image
wdenk452cfd62002-11-19 11:04:11 +000014
Marian Balakowiczd62379d2006-09-01 19:49:50 +020015COBJS = update.o flash.o flash_hw.o utils.o cmd_flash.o string.o ctype.o dummy.o
16COBJS_LINKS = stubs.o
17AOBJS = ppcstring.o
18AOBJS_LINKS = memio.o
19
20OBJS := $(addprefix $(obj),$(COBJS) $(COBJS_LINKS) $(AOBJS) $(AOBJS_LINKS))
21SRCS := $(COBJS:.o=.c) $(AOBJS:.o=.S) $(addprefix $(obj), $(COBJS_LINKS:.o:.c) $(AOBJS_LINKS:.o:.S))
wdenk452cfd62002-11-19 11:04:11 +000022
23CPPFLAGS += -I$(TOPDIR) -I$(TOPDIR)/board/MAI/AmigaOneG3SE
24CFLAGS += -I$(TOPDIR)/board/MAI/AmigaOneG3SE
Marian Balakowiczd62379d2006-09-01 19:49:50 +020025AFLAGS += -I$(TOPDIR)/board/MAI/AmigaOneG3SE
26
27DEPS = $(OBJTREE)/u-boot.bin $(OBJTREE)/tools/mkimage
28ifneq ($(DEPS),$(wildcard $(DEPS)))
29$(error "updater: Missing required objects, please run regular build first")
30endif
wdenk452cfd62002-11-19 11:04:11 +000031
Marian Balakowiczd62379d2006-09-01 19:49:50 +020032all: $(obj).depend $(PROG) $(IMAGE)
wdenk452cfd62002-11-19 11:04:11 +000033
34#########################################################################
wdenk452cfd62002-11-19 11:04:11 +000035
Marian Balakowiczd62379d2006-09-01 19:49:50 +020036$(obj)%.srec: %.o $(LIB)
wdenk452cfd62002-11-19 11:04:11 +000037 $(LD) -g -Ttext $(LOAD_ADDR) -o $(<:.o=) -e $(<:.o=) $< $(LIB)
38 $(OBJCOPY) -O srec $(<:.o=) $@
39
Marian Balakowiczd62379d2006-09-01 19:49:50 +020040$(obj)%.o: %.c
41 $(CC) $(CFLAGS) -c -o $@ $<
42
43$(obj)%.o: %.S
44 $(CC) $(AFLAGS) -c -o $@ $<
45
46$(obj)memio.o: $(obj)memio.S
47 $(CC) $(AFLAGS) -c -o $@ $<
wdenk452cfd62002-11-19 11:04:11 +000048
Marian Balakowiczd62379d2006-09-01 19:49:50 +020049$(obj)memio.S:
50 rm -f $(obj)memio.c
51 ln -s $(SRCTREE)/board/MAI/AmigaOneG3SE/memio.S $(obj)memio.S
52
53$(obj)stubs.o: $(obj)stubs.c
54 $(CC) $(CFLAGS) -c -o $@ $<
55
56$(obj)stubs.c:
57 rm -f $(obj)stubs.c
58 ln -s $(SRCTREE)/examples/stubs.c $(obj)stubs.c
wdenk452cfd62002-11-19 11:04:11 +000059
60#########################################################################
61
Marian Balakowiczd62379d2006-09-01 19:49:50 +020062$(obj)updater: $(OBJS)
63 $(LD) -g -Ttext $(LOAD_ADDR) -o $(obj)updater -e _main $(OBJS)
64 $(OBJCOPY) -O binary $(obj)updater $(obj)updater.bin
wdenk452cfd62002-11-19 11:04:11 +000065
Marian Balakowiczd62379d2006-09-01 19:49:50 +020066$(obj)updater.image: $(obj)updater $(OBJTREE)/u-boot.bin
67 cat >/tmp/tempimage $(obj)updater.bin junk $(OBJTREE)/u-boot.bin
68 $(OBJTREE)/tools/mkimage -A ppc -O u-boot -T standalone -C none -a $(LOAD_ADDR) \
69 -e `$(NM) $(obj)updater | grep _main | cut --bytes=0-8` \
70 -n "Firmware Updater" -d /tmp/tempimage $(obj)updater.image
wdenk452cfd62002-11-19 11:04:11 +000071 rm /tmp/tempimage
Marian Balakowiczd62379d2006-09-01 19:49:50 +020072 cp $(obj)updater.image /tftpboot
wdenk452cfd62002-11-19 11:04:11 +000073
Marian Balakowiczd62379d2006-09-01 19:49:50 +020074(obj)updater.image2: $(obj)updater $(OBJTREE)/u-boot.bin
75 cat >/tmp/tempimage $(obj)updater.bin junk ../../create_image/image
76 $(OBJTREE)/tools/mkimage -A ppc -O u-boot -T standalone -C none -a $(LOAD_ADDR) \
77 -e `$(NM) $(obj)updater | grep _main | cut --bytes=0-8` \
78 -n "Firmware Updater" -d /tmp/tempimage $(obj)updater.image
wdenk452cfd62002-11-19 11:04:11 +000079 rm /tmp/tempimage
Marian Balakowiczd62379d2006-09-01 19:49:50 +020080 cp $(obj)updater.image /tftpboot
wdenk452cfd62002-11-19 11:04:11 +000081
Marian Balakowiczd62379d2006-09-01 19:49:50 +020082#########################################################################
83
84# defines $(obj).depend target
85include $(SRCTREE)/rules.mk
wdenk452cfd62002-11-19 11:04:11 +000086
Marian Balakowiczd62379d2006-09-01 19:49:50 +020087sinclude $(obj).depend
wdenk452cfd62002-11-19 11:04:11 +000088
89#########################################################################