2 # Copyright (C) 2006 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
10 LOADADDR = 0x80010000 # RAM start + 16M
11 KERNEL_ENTRY = $(LOADADDR) # Newer kernels add a jmp to the kernel_entry at the start of the binary
12 RAMSIZE = 0x01000000 # 64MB
16 LOADADDR=$(LOADADDR) \
17 KERNEL_ENTRY=$(KERNEL_ENTRY) \
20 define trxalign/jffs2-128k
23 define trxalign/jffs2-64k
26 define trxalign/squashfs
30 define Image/Build/CFE
31 # Generate the tagged image
32 $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \
33 -o $(BIN_DIR)/openwrt-$(2)-$(1)-cfe.bin \
34 -b $(2) -c $(3) -e $(LOADADDR) -l $(LOADADDR)
35 # -b $(2) -c $(3) -e $(KERNEL_ENTRY) -l $(LOADADDR)
37 $(call prepare_generic_squashfs,$(BIN_DIR)/openwrt-$(2)-$(1)-cfe.bin)
40 define Image/Build/RedBoot
41 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(1)-vmlinux.elf
42 gzip -9 -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz
43 $(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux $(KDIR)/vmlinux.bin.l7
44 dd if=$(KDIR)/vmlinux.bin.l7 of=$(BIN_DIR)/openwrt-$(1)-vmlinux.lzma bs=65536 conv=sync
45 dd if=$(KDIR)/vmlinux.bin.gz of=$(BIN_DIR)/openwrt-$(1)-vmlinux.gz bs=65536 conv=sync
49 $(MAKE) -C lzma-loader clean
53 # Standard LZMA kernel
54 cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
56 # CFE is a LZMA nazi! It took me hours to find out the parameters!
57 # Also I think lzma has a bug cause it generates different output depending on
58 # if you use stdin / stdout or not. Use files instead of stdio here, cause
59 # otherwise CFE will complain and not boot the image.
60 $(STAGING_DIR_HOST)/bin/lzma e -d22 -fb64 -a1 $(KDIR)/vmlinux $(KDIR)/vmlinux.lzma.tmp
62 # Strip out the length, CFE doesn't like this
63 dd if=$(KDIR)/vmlinux.lzma.tmp of=$(KDIR)/vmlinux.lzma.cfe bs=5 count=1
64 dd if=$(KDIR)/vmlinux.lzma.tmp of=$(KDIR)/vmlinux.lzma.cfe ibs=13 obs=5 skip=1 seek=1 conv=notrunc
65 rm -f $(KDIR)/vmlinux.lzma.tmp
67 # Build the LZMA loader
68 rm -f $(KDIR)/loader.gz
69 $(MAKE) -C lzma-loader \
74 echo -ne "\\x00" >> $(KDIR)/loader.gz
77 $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
81 $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(1).trx -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma $(call trxalign/$(1)) -f $(KDIR)/root.$(1)
82 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/openwrt-$(BOARD)-root.$(1) bs=128k conv=sync
83 $(call Image/Build/CFE,$(1),96345GW2,6345)
84 $(call Image/Build/CFE,$(1),96348GW,6348)
86 $(call Image/Build/CFE,$(1),96358VW,6358)
88 $(call Image/Build/CFE,$(1),96348GW-11,6348)
90 $(call Image/Build/CFE,$(1),96348GW-10,6348)
92 $(call Image/Build/CFE,$(1),F@ST2404,6348)
94 $(call Image/Build/RedBoot,livebox)
97 $(eval $(call BuildImage))