lzma loader patch from oleg, great thanks good work, saves another 300 kb flashmemory

SVN-Revision: 513
This commit is contained in:
Waldemar Brodkorb 2005-04-02 12:12:58 +00:00
parent d2a31e404c
commit 8f80e98934
11 changed files with 45 additions and 88 deletions

View file

@ -11,8 +11,10 @@ the kernel and all choosen applications.
You can use scripts/flash.sh for remotely updating your embedded system You can use scripts/flash.sh for remotely updating your embedded system
via tftp. via tftp.
Be happy.. The buildroot system is documented in docs/buildroot-documentation.html.
Sunshine!
Your OpenWrt Project Your OpenWrt Project
http://www.openwrt.org http://openwrt.org

View file

@ -3,6 +3,7 @@
menu "OpenWrt Package Selection" menu "OpenWrt Package Selection"
comment "The default set" comment "The default set"
source "package/loader/Config.in"
source "package/busybox/Config.in" source "package/busybox/Config.in"
source "package/dnsmasq/Config.in" source "package/dnsmasq/Config.in"
source "package/iptables/Config.in" source "package/iptables/Config.in"

View file

@ -19,6 +19,7 @@ package-$(BR2_PACKAGE_IPTABLES) += iptables
package-$(BR2_PACKAGE_IPROUTE2) += iproute2 package-$(BR2_PACKAGE_IPROUTE2) += iproute2
package-$(BR2_PACKAGE_LCD4LINUX) += lcd4linux package-$(BR2_PACKAGE_LCD4LINUX) += lcd4linux
package-$(BR2_PACKAGE_LIBELF) += libelf package-$(BR2_PACKAGE_LIBELF) += libelf
package-$(BR2_PACKAGE_LOADER) += loader
package-$(BR2_PACKAGE_LZO) += lzo package-$(BR2_PACKAGE_LZO) += lzo
package-$(BR2_PACKAGE_MATRIXSSL) += matrixssl package-$(BR2_PACKAGE_MATRIXSSL) += matrixssl
package-$(BR2_PACKAGE_MICROPERL) += microperl package-$(BR2_PACKAGE_MICROPERL) += microperl

View file

@ -11,40 +11,11 @@
# #
# $Id$ # $Id$
# #
# Copyright 2004 Manuel Novoa III <mjn3@codepoet.org>
# Modified to support bzip'd kernels.
# Of course, it would be better to integrate bunzip capability into CFE.
#
# Link at 3 MB offset in RAM
#TEXT_START ?= 0x80300000
TEXT_START ?= 0x80001000
BZ_MEM_TOP := 0x81000000
BZ_TEXT_START := BZ_MEM_TOP-0x4000
BZ_STACK_TOP := BZ_TEXT_START-4
OBJCOPY := $(CROSS_COMPILE)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S OBJCOPY := $(CROSS_COMPILE)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
SRCBASE := $(TOPDIR)/../..
VPATH := $(SRCBASE)/shared
ASFLAGS += -D__ASSEMBLY__ -I$(SRCBASE)/include -DLOADADDR=$(LOADADDR)
ASFLAGS += -DBZ_MEM_TOP=$(BZ_MEM_TOP)
ASFLAGS += -DBZ_TEXT_START=$(BZ_TEXT_START)
ASFLAGS += -DBZ_STACK_TOP=$(BZ_STACK_TOP)
CFLAGS += -I$(SRCBASE)/include -DLOADADDR=$(LOADADDR)
CFLAGS += -DBZ_MEM_TOP=$(BZ_MEM_TOP)
CFLAGS += -DBZ_TEXT_START=$(BZ_TEXT_START)
CFLAGS += -DBZ_STACK_TOP=$(BZ_STACK_TOP)
ifdef CONFIG_MCOUNT
CFLAGS := $(subst -pg,,$(CFLAGS))
endif
CFLAGS += -ffunction-sections $(call check_gcc, -fvtable-gc, )
SEDFLAGS := s/BZ_TEXT_START/$(BZ_TEXT_START)/;s/BZ_MEM_TOP/$(BZ_MEM_TOP)/;s/TEXT_START/$(TEXT_START)/
SYSTEM ?= $(TOPDIR)/vmlinux SYSTEM ?= $(TOPDIR)/vmlinux
OBJECTS := head.o data.o
all: bzImage vmlinuz all: vmlinuz
# Don't build dependencies, this may die if $(CC) isn't gcc # Don't build dependencies, this may die if $(CC) isn't gcc
dep: dep:
@ -53,48 +24,10 @@ dep:
vmlinuz: piggy vmlinuz: piggy
gzip -c9 $< > $@ gzip -c9 $< > $@
# Our bzImage is a gzip'd binary that decompresses and runs
# the appended bzip'd kernel.
bzImage: bzLoaderImage.gz piggz
cat bzLoaderImage.gz piggz > $@
bzLoaderImage.gz: bzLoaderImage
gzip -nc9 $< > $@
bzLoaderImage: bzLoader
$(OBJCOPY) $< $@
bzLoader: vmlinux.lds $(OBJECTS)
$(LD) -static --gc-sections -no-warn-mismatch -T vmlinux.lds -o $@ $(OBJECTS)
vmlinux.lds: vmlinux.lds.in Makefile
@sed "$(SEDFLAGS)" < $< > $@
piggz: piggy
bzip2 -c9 $< > $@
piggy: $(SYSTEM) piggy: $(SYSTEM)
$(OBJCOPY) $< $@ $(OBJCOPY) $< $@
data.o: data.lds data.image
$(LD) -no-warn-mismatch -T data.lds -r -o $@ -b binary data.image -b elf32-tradlittlemips
data.lds:
@echo "SECTIONS { .data : { code_start = .; *(.data) code_stop = .; }}" > $@
data.image: decompress_bunzip2.image
$(OBJCOPY) $< $@
decompress_bunzip2.image: decompress_bunzip2.lds decompress_bunzip2.o
$(LD) -static --gc-sections -no-warn-mismatch -T decompress_bunzip2.lds -o $@ decompress_bunzip2.o
decompress_bunzip2.lds: decompress_bunzip2.lds.in Makefile
@sed "$(SEDFLAGS)" < $< > $@
mrproper: clean mrproper: clean
clean: clean:
rm -f vmlinux vmlinuz piggz piggy *.lds *.o \ rm -f vmlinuz piggy
bzLoader bzLoaderImage bzLoaderImage.gz bzImage \
data.lds data.image \
decompress_bunzip2.lds decompress_bunzip2.image

View file

@ -195,7 +195,8 @@ find_root(struct mtd_info *mtd, size_t size, struct mtd_partition *part)
/* found a TRX header */ /* found a TRX header */
if (le32_to_cpu(trx->magic) == TRX_MAGIC) { if (le32_to_cpu(trx->magic) == TRX_MAGIC) {
part->offset = le32_to_cpu(trx->offsets[1]); part->offset = le32_to_cpu(trx->offsets[2]) ? :
le32_to_cpu(trx->offsets[1]);
part->size = le32_to_cpu(trx->len); part->size = le32_to_cpu(trx->len);
part->size -= part->offset; part->size -= part->offset;

View file

@ -25,7 +25,7 @@ LINUX_SOURCE=linux-$(LINUX_VERSION).tar.bz2
LINUX_KCONFIG=./linux.config LINUX_KCONFIG=./linux.config
LINUX_PATCHES=./kernel-patches LINUX_PATCHES=./kernel-patches
LINUX_KERNEL_SOURCE=./kernel-source LINUX_KERNEL_SOURCE=./kernel-source
LINUX_BINLOC=arch/$(LINUX_KARCH)/brcm-boards/bcm947xx/compressed/vmlinuz LINUX_BINLOC=arch/$(LINUX_KARCH)/brcm-boards/bcm947xx/compressed/piggy
# Used by pcmcia-cs and others # Used by pcmcia-cs and others
LINUX_SOURCE_DIR=$(LINUX_DIR)-$(LINUX_VERSION) LINUX_SOURCE_DIR=$(LINUX_DIR)-$(LINUX_VERSION)

View file

@ -73,6 +73,8 @@ int main(int argc, char **argv)
int fd; int fd;
unsigned long len; unsigned long len;
struct trx_header *ptr; struct trx_header *ptr;
unsigned offset;
if (((fd = open(FILENAME, O_RDWR)) < 0) if (((fd = open(FILENAME, O_RDWR)) < 0)
|| ((len = lseek(fd, 0, SEEK_END)) < 0) || ((len = lseek(fd, 0, SEEK_END)) < 0)
|| ((ptr = (struct trx_header *) mmap(0, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1)) || ((ptr = (struct trx_header *) mmap(0, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1))
@ -81,17 +83,20 @@ int main(int argc, char **argv)
exit(-1); exit(-1);
} }
/* treat last partition as rootfs offset */
offset = ptr->offsets[2] ? : ptr->offsets[1];
if (argc > 1 && !strcmp(argv[1],"--move")) { if (argc > 1 && !strcmp(argv[1],"--move")) {
if (ptr->offsets[1] >= ptr->len) { if (offset >= ptr->len) {
printf("Partition already moved outside trx\n"); printf("Partition already moved outside trx\n");
#if 0 #if 0
} else if (ptr->offsets[1] & 0x0001ffff) { } else if (offset & 0x0001ffff) {
printf("Partition does not start on a block boundary\n"); printf("Partition does not start on a block boundary\n");
#endif #endif
} else { } else {
init_crc32(); init_crc32();
//bzero((void *)((int)ptr + ptr->len), (size_t)(len - ptr->len)); //bzero((void *)((int)ptr + ptr->len), (size_t)(len - ptr->len));
ptr->len = ptr->offsets[1]; ptr->len = offset;
ptr->crc32 = crc32buf((void *) &(ptr->flag_version), ptr->len - offsetof(struct trx_header, flag_version)); ptr->crc32 = crc32buf((void *) &(ptr->flag_version), ptr->len - offsetof(struct trx_header, flag_version));
msync(ptr,len,MS_SYNC|MS_INVALIDATE); msync(ptr,len,MS_SYNC|MS_INVALIDATE);
printf("Partition moved; please reboot\n"); printf("Partition moved; please reboot\n");

View file

@ -29,6 +29,20 @@ IMAGE_TARGETS += $(BIN_DIR)/openwrt-motorola-$(1).bin
endif endif
endef endef
# Enable loader and prepare kernel
ifeq ($(strip $(BR2_PACKAGE_LOADER)),y)
export LINUX_LOADER=$(BUILD_DIR)/lzmaldr
export LINUX_IMAGE=$(BUILD_DIR)/piggy.lzma
else
export LINUX_IMAGE=$(BUILD_DIR)/piggy.gz
endif
$(BUILD_DIR)/piggy.lzma: $(LINUX_KERNEL)
cat $^ | $(BUILD_DIR)/lzma/lzma e -si -so -eos > $@ || (rm -f $@ && false)
$(BUILD_DIR)/piggy.gz: $(LINUX_KERNEL)
cat $^ | gzip -c9 $^ > $@ || (rm -f $@ && false)
TARGET_DIRS:= TARGET_DIRS:=
TARGET_FS:= TARGET_FS:=
IMAGE_TARGETS:= IMAGE_TARGETS:=
@ -70,7 +84,7 @@ $(BIN_DIR):
mkdir -p $(BIN_DIR) mkdir -p $(BIN_DIR)
compile: $(patsubst %,%-compile,$(TARGET_DIRS)) compile: $(patsubst %,%-compile,$(TARGET_DIRS))
install: utils-install $(patsubst %,%-install,$(TARGET_DIRS)) $(IMAGE_TARGETS) install: utils-install lzma-install $(LINUX_IMAGE) $(patsubst %,%-install,$(TARGET_DIRS)) $(IMAGE_TARGETS)
clean: $(patsubst %,%-clean,$(TARGET_DIRS)) image_clean clean: $(patsubst %,%-clean,$(TARGET_DIRS)) image_clean
image_clean: image_clean:

View file

@ -12,14 +12,14 @@ clean: jffs2root-dirclean
$(BIN_DIR)/openwrt-generic-jffs2-4MB.trx: $(BIN_DIR)/openwrt-generic-jffs2-4MB.trx:
$(MKFS_JFFS2) --pad --little-endian --squash -e 0x10000 \ $(MKFS_JFFS2) --pad --little-endian --squash -e 0x10000 \
-d $(TARGET_DIR) -o $(IMAGE)-4MB.jffs2 -d $(TARGET_DIR) -o $(IMAGE)-4MB.jffs2
PATH=$(TARGET_PATH) trx -o $@ \ PATH=$(TARGET_PATH) trx -o $@ $(LINUX_LOADER) \
$(LINUX_KERNEL) -a 0x10000 $(IMAGE)-4MB.jffs2 $(LINUX_IMAGE) -a 0x10000 $(IMAGE)-4MB.jffs2
$(BIN_DIR)/openwrt-generic-jffs2-8MB.trx: $(BIN_DIR)/openwrt-generic-jffs2-8MB.trx:
$(MKFS_JFFS2) --pad --little-endian --squash -e 0x20000 \ $(MKFS_JFFS2) --pad --little-endian --squash -e 0x20000 \
-d $(TARGET_DIR) -o $(IMAGE)-8MB.jffs2 -d $(TARGET_DIR) -o $(IMAGE)-8MB.jffs2
PATH=$(TARGET_PATH) trx -o $@ \ PATH=$(TARGET_PATH) trx -o $@ $(LINUX_LOADER) \
$(LINUX_KERNEL) -a 0x20000 $(IMAGE)-8MB.jffs2 $(LINUX_IMAGE) -a 0x20000 $(IMAGE)-8MB.jffs2
$(BIN_DIR)/openwrt-wrt54g-jffs2.bin: $(BIN_DIR)/openwrt-generic-jffs2-4MB.trx $(BIN_DIR)/openwrt-wrt54g-jffs2.bin: $(BIN_DIR)/openwrt-generic-jffs2-4MB.trx
PATH=$(TARGET_PATH) addpattern -2 -i $< -o $@ -g PATH=$(TARGET_PATH) addpattern -2 -i $< -o $@ -g

View file

@ -11,6 +11,6 @@ clean: squashfslzmaroot-dirclean
$(BIN_DIR)/openwrt-generic-squashfs.trx: $(BIN_DIR)/openwrt-generic-squashfs.trx:
@mkdir -p $(TARGET_DIR)/jffs @mkdir -p $(TARGET_DIR)/jffs
$(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs-lzma $(TARGET_DIR) $(IMAGE).squashfslzma -noappend -root-owned -le $(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs-lzma $(TARGET_DIR) $(IMAGE).squashfslzma -noappend -root-owned -le
PATH=$(TARGET_PATH) trx -o $@ \ PATH=$(TARGET_PATH) trx -o $@ $(LINUX_LOADER) \
$(LINUX_KERNEL) $(IMAGE).squashfslzma $(LINUX_IMAGE) $(IMAGE).squashfslzma

View file

@ -4,20 +4,20 @@
# #
############################################################# #############################################################
SQUASHFSLZMA_DIR=$(BUILD_DIR)/squashfs2.1-r2-lzma SQUASHFSLZMA_DIR=$(BUILD_DIR)/squashfs2.1-r2
SQUASHFSLZMA_SOURCE=squashfs2.1-r2-lzma.tar.gz SQUASHFSLZMA_SOURCE=squashfs2.1-r2.tar.gz
SQUASHFSLZMA_SITE=http://openwrt.openbsd-geek.de SQUASHFSLZMA_SITE=http://mesh.dl.sourceforge.net/sourceforge/squashfs/
$(DL_DIR)/$(SQUASHFSLZMA_SOURCE): $(DL_DIR)/$(SQUASHFSLZMA_SOURCE):
$(SCRIPT_DIR)/download.pl $(DL_DIR) $(SQUASHFSLZMA_SOURCE) x $(SQUASHFSLZMA_SITE) $(SCRIPT_DIR)/download.pl $(DL_DIR) $(SQUASHFSLZMA_SOURCE) x $(SQUASHFSLZMA_SITE)
$(SQUASHFSLZMA_DIR)/.unpacked: $(DL_DIR)/$(SQUASHFSLZMA_SOURCE) $(SQUASHFSLZMA_DIR)/.unpacked: $(DL_DIR)/$(SQUASHFSLZMA_SOURCE)
zcat $(DL_DIR)/$(SQUASHFSLZMA_SOURCE) | tar -C $(BUILD_DIR) -xvf - zcat $(DL_DIR)/$(SQUASHFSLZMA_SOURCE) | tar -C $(BUILD_DIR) -xvf -
patch -d $(SQUASHFSLZMA_DIR) -p1 < squashfs2.0-tools-lzma.patch
touch $(SQUASHFSLZMA_DIR)/.unpacked touch $(SQUASHFSLZMA_DIR)/.unpacked
$(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs: $(SQUASHFSLZMA_DIR)/.unpacked $(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs: $(SQUASHFSLZMA_DIR)/.unpacked
$(MAKE) -C $(SQUASHFSLZMA_DIR)/lzma/SRC/7zip/Compress/LZMA_Lib $(MAKE) -C $(SQUASHFSLZMA_DIR)/squashfs-tools mksquashfs-lzma LZMAPATH=$(BUILD_DIR)/lzma
$(MAKE) -C $(SQUASHFSLZMA_DIR)/squashfs-tools mksquashfs-lzma
squashfslzma: $(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs squashfslzma: $(SQUASHFSLZMA_DIR)/squashfs-tools/mksquashfs