49072144692dcc7da46ae556f7df244be7e983f0
[openwrt/svn-archive/archive.git] / target / linux / rb532-2.6 / image / Makefile
1 #
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9 include $(INCLUDE_DIR)/kernel.mk
10
11 LOADADDR = 0x81000000 # RAM start + 16M
12 KERNEL_ENTRY = 0x80101000
13 RAMSIZE = 0x00100000 # 1MB
14 IMAGE_COPY = 1
15
16 LOADER_MAKEOPTS= \
17 KDIR=$(KDIR) \
18 LOADADDR=$(LOADADDR) \
19 KERNEL_ENTRY=$(KERNEL_ENTRY) \
20 RAMSIZE=$(RAMSIZE) \
21 IMAGE_COPY=$(IMAGE_COPY)
22
23 define Build/Compile
24 $(CC) -o $(STAGING_DIR)/bin/patch-cmdline $(PLATFORM_DIR)/src/patch-cmdline.c
25 endef
26
27 define Build/Clean
28 $(MAKE) -C ../../generic-2.6/image/lzma-loader $(LOADER_MAKEOPTS) clean
29 endef
30
31 define Image/Prepare
32 $(STAGING_DIR)/bin/patch-cmdline $(LINUX_DIR)/vmlinux 'root=/dev/cfa2 '
33 $(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
34 endef
35
36 define Image/BuildKernel
37 cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
38 $(MAKE) -C ../../generic-2.6/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
39 $(CP) $(KDIR)/loader.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux
40 endef
41
42 PARTITION1=\x80\x01\x01\x00\x27\x01\x20\x7b\x20\x00\x00\x00\xe0\x1e\x00\x00# 4 MB (kernel part)
43 PARTITION2=\x00\x00\x01\x7c\x83\x01\xa0\x64\x00\x1f\x00\x00\x40\x7a\x00\x00# 16 MB (rootfs part)
44
45 define Image/cmdline/jffs2-64k
46 block2mtd.block2mtd=/dev/cfa2,65536 root=/dev/mtdblock0 rootfstype=jffs2
47 endef
48
49 define Image/cmdline/jffs2-128k
50 block2mtd.block2mtd=/dev/cfa2,131072 root=/dev/mtdblock0 rootfstype=jffs2
51 endef
52
53 define Image/cmdline/ext2
54 root=/dev/cfa2 rootfstype=ext2
55 endef
56
57 define Image/Build
58 $(STAGING_DIR)/bin/patch-cmdline $(LINUX_DIR)/vmlinux '$(strip $(call Image/cmdline/$(1))) '
59 ( \
60 echo -ne OWRT | dd bs=$$$$((0x1be)) conv=sync; \
61 ( \
62 echo -ne '$(strip $(PARTITION1))'; \
63 echo -ne '$(strip $(PARTITION2))'; \
64 ) | dd bs=$$$$((0x40)) conv=sync; \
65 echo -ne '\x55\xaa'; \
66 dd if=/dev/zero bs=$$$$((0x3e00)) conv=sync count=1; \
67 dd if=$(LINUX_DIR)/vmlinux bs=$$$$((0x3dc000)) conv=sync; \
68 cat $(KDIR)/root.$(1); \
69 echo -ne '\xde\xad\xc0\xde'; \
70 ) > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin
71 endef
72
73 $(eval $(call BuildImage))