diff options
author | Roman Yeryomin <roman@advem.lv> | 2013-08-16 11:44:04 +0300 |
---|---|---|
committer | Roman Yeryomin <roman@advem.lv> | 2013-08-16 11:44:04 +0300 |
commit | dee99ab0143122146ab7713cfe171790bc796dd3 (patch) | |
tree | 907ad856f6ceae17a70dd1df004a1adee8a1b2fd /target/linux/realtek/image/Makefile | |
parent | 4ed5985ada0f0420d69d7d959ecc3c9c8515efa0 (diff) |
Get rid of rtkload. Use OpenWrt lzma-loader (with kernel_entry hack). Use mgbin for unified tftp image generation.
Signed-off-by: Roman Yeryomin <roman@advem.lv>
Diffstat (limited to 'target/linux/realtek/image/Makefile')
-rw-r--r-- | target/linux/realtek/image/Makefile | 96 |
1 files changed, 46 insertions, 50 deletions
diff --git a/target/linux/realtek/image/Makefile b/target/linux/realtek/image/Makefile index f5f1c4f56..d0dc6ab7e 100644 --- a/target/linux/realtek/image/Makefile +++ b/target/linux/realtek/image/Makefile @@ -7,76 +7,72 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/image.mk -#DROP_SECTIONS := .reginfo .mdebug .comment .note .pdr .options .MIPS.options -#OBJCOPY_BIN := $(TARGET_CROSS)objcopy -S -O bin $(addprefix --remove-section=,$(DROP_SECTIONS)) +JFFS2_BLOCKSIZE=4k -TCC=$(TARGET_CROSS)cc -TOBJCOPY=$(TARGET_CROSS)objcopy -TLD=$(TARGET_CROSS)ld +#OBJCOPY=$(TARGET_CROSS)objcopy +# define subtarget, should be replaced with $(SUBTARGET) when more chips will be introduced +STARGET=rtl8196c -JFFS2_BLOCKSIZE=4k +COMMA:=, +define mkcmdline +$(if $(1),board=$(1) )$(if $(2),console=$(2)$(COMMA)$(3)) +endef define Image/Prepare - gzip -9 < $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz +# $(KERNEL_CROSS)objcopy -O binary $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL) +# $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf2 + lzma e $(KDIR)/vmlinux -lc1 -lp2 -pb2 $(KDIR)/vmlinux.lzma endef define Image/BuildKernel - cp $(KDIR)/vmlinux.gz $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz - cp $(LINUX_DIR)/rtkload/linux.bin $(BIN_DIR)/$(IMG_PREFIX)-kernel.bin + $(call Image/BuildLoader,loader-$(STARGET),bin,$(call mkcmdline,$(PROFILE),ttyS0,38400) root=/dev/mtdblock2,${CONFIG_REALTEK_KERNEL_LOAD_ADDRESS},$(shell dd if=$(KDIR)/vmlinux.elf skip=24 bs=1 count=4 conv=swab 2>/dev/null | hexdump -v -e '"0x" 2/2 "%X"')) + cvimg linux $(KDIR)/loader-$(STARGET).bin \ + $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-kernel.bin \ + ${CONFIG_REALTEK_KERNEL_LOAD_ADDRESS} \ + ${CONFIG_REALTEK_KERNEL_OFFSET} endef define Image/Build/jffs2-4k - dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(1).img bs=4k conv=sync - cvimg root $(BIN_DIR)/$(IMG_PREFIX)-$(1).img $(BIN_DIR)/$(IMG_PREFIX)-$(1).bin F0000 ${CONFIG_REALTEK_ROOTFS_OFFSET} + dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-$(1).img bs=4k conv=sync + cvimg root $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-$(1).img \ + $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-$(1).bin \ + ${CONFIG_REALTEK_ROOTFS_OFFSET} \ + ${CONFIG_REALTEK_ROOTFS_OFFSET} endef -BS_KERNEL=$$$$((`printf %d 0x${CONFIG_REALTEK_ROOTFS_OFFSET}`-`printf %d 0x${CONFIG_REALTEK_KERNEL_OFFSET}`)) -BS_ROOTFS=$$$$((`printf %d ${CONFIG_REALTEK_FLASH_SIZE}`-`printf %d 0x${CONFIG_REALTEK_ROOTFS_OFFSET}`)) define Image/Build/squashfs $(call prepare_generic_squashfs,$(KDIR)/root.squashfs) - dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(1).img bs=128k conv=sync - cvimg root $(BIN_DIR)/$(IMG_PREFIX)-$(1).img $(BIN_DIR)/$(IMG_PREFIX)-$(1).bin F0000 ${CONFIG_REALTEK_ROOTFS_OFFSET} - echo "BS_KERNEL=$(BS_KERNEL)" - echo "BS_ROOTFS=$(BS_ROOTFS)" - ( \ - dd if=$(BIN_DIR)/$(IMG_PREFIX)-kernel.bin bs=$(BS_KERNEL) conv=sync; \ - dd if=$(BIN_DIR)/$(IMG_PREFIX)-$(1).img bs=$(BS_ROOTFS) conv=sync; \ - ) > $(BIN_DIR)/$(IMG_PREFIX)-$(1)-sysupgrade.img + dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-$(1).img bs=4k conv=sync + cvimg root $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-$(1).img \ + $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-$(1).bin \ + ${CONFIG_REALTEK_ROOTFS_OFFSET} \ + ${CONFIG_REALTEK_ROOTFS_OFFSET} endef - #need to fix this mess - JMM - # - #bixutil pack $(KDIR)/vmlinux.gz $(BIN_DIR)/kernel-$(BOARD)-$(KERNEL).bix - #cat $(KDIR)/vmlinux.gz \ - # $(KDIR)/root.$(1) \ - # > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin - # - # - # - #echo "void vmlinux_entry(void) { }" > vmlinux_img.c - #$(TCC) -fno-pic -mno-abicalls -Os -fomit-frame-pointer -D__KERNEL__ -c vmlinux_img.c -o vmlinux_img.o - #$(TOBJCOPY) --add-section .vmlinux=vmlinux_img.gz vmlinux_img.o - # - #echo "OUTPUT_ARCH(mips)" > ld.script - #echo "ENTRY(__start)" >> ld.script - #echo "SECTIONS" >> ld.script - #echo "{" >> ld.script - #echo " /* The loader itself */" >> ld.script - #echo " . = ${LOAD_STARTADDR};" >> ld.script - #echo " .text : { *(.text) }" >> ld.script - #echo " .rodata : { *(.rodata) }" >> ld.script - #echo " . = ALIGN(4);" >> ld.script - #echo " .data : { _fdata = . ; *(.data) . = ALIGN(1024); __vmlinux_start = .; *(.vmlinux) __vmlinux_end = .; . = ALIGN(1024); CONSTRUCTORS }" >> ld.script - #echo " .bss : { _bstart = . ; *(.bss) ; *(.sbss) ; *(COMMON) ; _bend = . ; }" >> ld.script - #echo " /DISCARD/ : { *(.reginfo) ; *(.note) ; *(.comment) *(__ex_table) ; }" >> ld.script - #echo "}" >> ld.script - #$(TLD) -static -nostdlib -G 0 -T ld.script -o mem $(START_FILE) $(LOADER_FILES) $(SUPPORT_FILES) vmlinux_img.o - - +BS_KERNEL=$$$$((`printf %d 0x${CONFIG_REALTEK_ROOTFS_OFFSET}`-`printf %d 0x${CONFIG_REALTEK_KERNEL_OFFSET}`)) +BS_ROOTFS=$$$$((`printf %d ${CONFIG_REALTEK_FLASH_SIZE}`-`printf %d 0x${CONFIG_REALTEK_ROOTFS_OFFSET}`)) define Image/Build $(call Image/Build/$(1),$(1)) + echo "BS_KERNEL=$(BS_KERNEL)" + echo "BS_ROOTFS=$(BS_ROOTFS)" + ( \ + dd if=$(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-kernel.bin bs=$(BS_KERNEL) conv=sync; \ + dd if=$(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-$(1).img bs=$(BS_ROOTFS) conv=sync; \ + ) > $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-$(1)-sysupgrade.img + mgbin -c -o $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-$(1)-fw.bin \ + $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-$(1).bin \ + $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-kernel.bin +endef + +LOADER_MAKE := $(NO_TRACE_MAKE) -C lzma-loader KDIR=$(KDIR) LINUX_DIR=$(LINUX_DIR) +define Image/BuildLoader + -rm -rf $(KDIR)/lzma-loader + $(LOADER_MAKE) LOADER=$(1).$(2) KERNEL_CMDLINE="$(3)" \ + LZMA_TEXT_START=$(4) LOADADDR=0x80000000 KERNELENTRY=$(5) \ + LOADER_DATA="$(KDIR)/vmlinux.lzma" BOARD="$(1)" \ + compile loader.$(2) endef $(eval $(call BuildImage)) |