d7f2c9f89526424d4fd8f719570fcca7cf37c2fa
[openwrt/svn-archive/archive.git] / target / linux / leon / patches / 002-sparc_uimage_target.patch
1 From 234ef25344b567b3b8dad62c0863ebe16377528f Mon Sep 17 00:00:00 2001
2 From: Daniel Hellstrom <daniel@gaisler.com>
3 Date: Tue, 14 Sep 2010 11:26:55 +0200
4 Subject: [PATCH] SPARC: added U-Boot build target: uImage
5
6 ---
7 arch/sparc/Makefile | 3 ++-
8 arch/sparc/boot/Makefile | 35 +++++++++++++++++++++++++++++++++++
9 2 files changed, 37 insertions(+), 1 deletions(-)
10
11 --- a/arch/sparc/Makefile
12 +++ b/arch/sparc/Makefile
13 @@ -88,7 +88,7 @@ boot := arch/sparc/boot
14 # Default target
15 all: zImage
16
17 -image zImage tftpboot.img vmlinux.aout: vmlinux
18 +image zImage uImage tftpboot.img vmlinux.aout: vmlinux
19 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
20
21 archclean:
22 @@ -102,6 +102,7 @@ ifeq ($(ARCH),sparc)
23 define archhelp
24 echo '* image - kernel image ($(boot)/image)'
25 echo '* zImage - stripped kernel image ($(boot)/zImage)'
26 + echo ' uImage - U-Boot SPARC32/LEON Image'
27 echo ' tftpboot.img - image prepared for tftp'
28 endef
29 else
30 --- a/arch/sparc/boot/Makefile
31 +++ b/arch/sparc/boot/Makefile
32 @@ -5,6 +5,7 @@
33
34 ROOT_IMG := /usr/src/root.img
35 ELFTOAOUT := elftoaout
36 +MKIMAGE := $(srctree)/scripts/mkuboot.sh
37
38 hostprogs-y := piggyback_32 piggyback_64 btfixupprep
39 targets := tftpboot.img btfix.o btfix.S image zImage vmlinux.aout
40 @@ -90,5 +91,39 @@ $(obj)/tftpboot.img: $(obj)/image $(obj)
41 $(obj)/vmlinux.aout: vmlinux FORCE
42 $(call if_changed,elftoaout)
43 @echo ' kernel: $@ is ready'
44 +else
45 +
46 +# The following lines make a readable image for U-Boot.
47 +# uImage - Binary file read by U-boot
48 +# uImage.o - object file of uImage for loading with a
49 +# flash programmer understanding ELF.
50 +
51 +OBJCOPYFLAGS_image.bin := -S -O binary -R .note -R .comment
52 +$(obj)/image.bin: $(obj)/image FORCE
53 + $(call if_changed,objcopy)
54 +
55 +$(obj)/image.gz: $(obj)/image.bin
56 + $(call if_changed,gzip)
57 +
58 +# Start of Main memory
59 +ifndef UIMAGE_LOADADDR
60 +UIMAGE_LOADADDR=0x40004000
61 endif
62
63 +# The first sector after the U-Boot image (256k)
64 +ifndef UIMAGE_FLASHADDR
65 +UIMAGE_FLASHADDR=0x00040000
66 +endif
67 +
68 +quiet_cmd_uimage = UIMAGE $@
69 + cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sparc -O linux -T kernel \
70 + -C gzip -a $(UIMAGE_LOADADDR) -e 0xf0004000 -n 'Linux-$(KERNELRELEASE)' \
71 + -d $< $@
72 +
73 +targets += uImage
74 +$(obj)/uImage: $(obj)/image.gz
75 + $(call if_changed,uimage)
76 + sparc-linux-ld -Tdata $(UIMAGE_FLASHADDR) -r -b binary arch/sparc/boot/uImage -o arch/sparc/boot/uImage.o
77 + @echo ' Image $@ is ready'
78 +
79 +endif