blob: bea8b9c2a7cf6f9bc2667c53eafcf152dec6fa3f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#
Jesper Nilsson63e6b9a2007-11-30 16:11:38 +01002# Makefile for rescue (bootstrap) code
Linus Torvalds1da177e2005-04-16 15:20:36 -07003#
Mikael Starvik3e41d652005-07-27 11:44:30 -07004
Jesper Nilssonbdb144b2008-06-29 23:15:19 +02005ccflags-y += -O2 $(LINUXINCLUDE)
6asflags-y += $(LINUXINCLUDE)
Jesper Nilsson546cc142008-01-17 11:22:41 +01007ldflags-y += -T $(obj)/rescue.ld
Linus Torvalds1da177e2005-04-16 15:20:36 -07008OBJCOPYFLAGS = -O binary --remove-section=.bss
Jesper Nilsson63e6b9a2007-11-30 16:11:38 +01009obj-$(CONFIG_ETRAX_AXISFLASHMAP) = head.o
10OBJECT := $(obj)/head.o
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Jesper Nilsson63e6b9a2007-11-30 16:11:38 +010012targets := rescue.o rescue.bin
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Jesper Nilsson63e6b9a2007-11-30 16:11:38 +010014$(obj)/rescue.o: $(OBJECT) FORCE
15 $(call if_changed,ld)
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Jesper Nilsson63e6b9a2007-11-30 16:11:38 +010017$(obj)/rescue.bin: $(obj)/rescue.o FORCE
18 $(call if_changed,objcopy)
19 cp -p $(obj)/rescue.bin $(objtree)
20
21$(obj)/testrescue.bin: $(obj)/testrescue.o
22 $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/testrescue.o tr.bin
Linus Torvalds1da177e2005-04-16 15:20:36 -070023# Pad it to 784 bytes
24 dd if=/dev/zero of=tmp2423 bs=1 count=784
25 cat tr.bin tmp2423 >testrescue_tmp.bin
Jesper Nilsson63e6b9a2007-11-30 16:11:38 +010026 dd if=testrescue_tmp.bin of=$(obj)/testrescue.bin bs=1 count=784
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 rm tr.bin tmp2423 testrescue_tmp.bin
28
Jesper Nilsson63e6b9a2007-11-30 16:11:38 +010029$(obj)/kimagerescue.bin: $(obj)/kimagerescue.o
30 $(OBJCOPY) $(OBJCOPYFLAGS) $(obj)/kimagerescue.o ktr.bin
Linus Torvalds1da177e2005-04-16 15:20:36 -070031# Pad it to 784 bytes, that's what the rescue loader expects
32 dd if=/dev/zero of=tmp2423 bs=1 count=784
33 cat ktr.bin tmp2423 >kimagerescue_tmp.bin
Jesper Nilsson63e6b9a2007-11-30 16:11:38 +010034 dd if=kimagerescue_tmp.bin of=$(obj)/kimagerescue.bin bs=1 count=784
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 rm ktr.bin tmp2423 kimagerescue_tmp.bin