blob: 19dd5eb6f4990deb9a52f8df98fb687d47c1e44c [file] [log] [blame]
wdenkc7de8292002-11-19 11:04:11 +00001#
Marian Balakowiczf9328632006-09-01 19:49:50 +02002# (C) Copyright 2000-2006
wdenkc7de8292002-11-19 11:04:11 +00003# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4#
Wolfgang Denk1a459662013-07-08 09:37:19 +02005# SPDX-License-Identifier: GPL-2.0+
wdenkc7de8292002-11-19 11:04:11 +00006#
7
8LOAD_ADDR = 0x40000
9
10include $(TOPDIR)/config.mk
11
Marian Balakowiczf9328632006-09-01 19:49:50 +020012PROG = $(obj)updater
13IMAGE = $(obj)updater.image
wdenkc7de8292002-11-19 11:04:11 +000014
Marian Balakowiczf9328632006-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))
wdenkc7de8292002-11-19 11:04:11 +000022
23CPPFLAGS += -I$(TOPDIR) -I$(TOPDIR)/board/MAI/AmigaOneG3SE
24CFLAGS += -I$(TOPDIR)/board/MAI/AmigaOneG3SE
Marian Balakowiczf9328632006-09-01 19:49:50 +020025AFLAGS += -I$(TOPDIR)/board/MAI/AmigaOneG3SE
wdenkc7de8292002-11-19 11:04:11 +000026
Marian Balakowiczf9328632006-09-01 19:49:50 +020027DEPS = $(OBJTREE)/u-boot.bin $(OBJTREE)/tools/mkimage
28ifneq ($(DEPS),$(wildcard $(DEPS)))
29$(error "updater: Missing required objects, please run regular build first")
30endif
31
32all: $(obj).depend $(PROG) $(IMAGE)
wdenkc7de8292002-11-19 11:04:11 +000033
34#########################################################################
wdenkc7de8292002-11-19 11:04:11 +000035
Marian Balakowiczf9328632006-09-01 19:49:50 +020036$(obj)%.srec: %.o $(LIB)
wdenkc7de8292002-11-19 11:04:11 +000037 $(LD) -g -Ttext $(LOAD_ADDR) -o $(<:.o=) -e $(<:.o=) $< $(LIB)
38 $(OBJCOPY) -O srec $(<:.o=) $@
39
Marian Balakowiczf9328632006-09-01 19:49:50 +020040$(obj)%.o: %.c
41 $(CC) $(CFLAGS) -c -o $@ $<
wdenkc7de8292002-11-19 11:04:11 +000042
Marian Balakowiczf9328632006-09-01 19:49:50 +020043$(obj)%.o: %.S
44 $(CC) $(AFLAGS) -c -o $@ $<
45
46$(obj)memio.o: $(obj)memio.S
47 $(CC) $(AFLAGS) -c -o $@ $<
48
49$(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
wdenkc7de8292002-11-19 11:04:11 +000059
60#########################################################################
61
Marian Balakowiczf9328632006-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
wdenkc7de8292002-11-19 11:04:11 +000065
Marian Balakowiczf9328632006-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
wdenkc7de8292002-11-19 11:04:11 +000071 rm /tmp/tempimage
Marian Balakowiczf9328632006-09-01 19:49:50 +020072 cp $(obj)updater.image /tftpboot
wdenkc7de8292002-11-19 11:04:11 +000073
Marian Balakowiczf9328632006-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
wdenkc7de8292002-11-19 11:04:11 +000079 rm /tmp/tempimage
Marian Balakowiczf9328632006-09-01 19:49:50 +020080 cp $(obj)updater.image /tftpboot
wdenkc7de8292002-11-19 11:04:11 +000081
Marian Balakowiczf9328632006-09-01 19:49:50 +020082#########################################################################
wdenkc7de8292002-11-19 11:04:11 +000083
Marian Balakowiczf9328632006-09-01 19:49:50 +020084# defines $(obj).depend target
85include $(SRCTREE)/rules.mk
86
87sinclude $(obj).depend
wdenkc7de8292002-11-19 11:04:11 +000088
89#########################################################################