From 297d08db0d7723ced8374dab99335451fb5ddee4 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Mon, 8 Sep 2014 00:53:59 +0200 Subject: [PATCH] Initial support for RAM version of this U-Boot modification (tested, working). Usage: uncomment 13 line in top Makefile, build image for selected model, load image to address 0x80100000 and execute it from there. DO NOT use RAM version images for booting from FLASH - that will brick your device! RAM version DOES NOT contain low level initialization (clocks, PLL, etc.). --- Makefile | 93 ++++++--- u-boot/Makefile | 112 ++++++----- u-boot/board/ar7240/ap121/ap121.c | 10 +- u-boot/board/ar7240/ap121/config.mk | 13 +- u-boot/board/ar7240/db12x/config.mk | 18 +- u-boot/board/ar7240/db12x/db12x.c | 11 +- u-boot/cpu/mips/ar7240/meminit.c | 7 +- u-boot/cpu/mips/start.S | 283 +++++++++++++++++++++++++++- u-boot/lib_mips/board.c | 17 +- 9 files changed, 465 insertions(+), 99 deletions(-) diff --git a/Makefile b/Makefile index 89eb5d6..cb106ca 100755 --- a/Makefile +++ b/Makefile @@ -9,153 +9,172 @@ export CONFIG_BOOTDELAY=1 # uncomment following line, to disable output in U-Boot console #export DISABLE_CONSOLE_OUTPUT=1 +# uncomment following line, to build RAM version images (without low level initialization) +#export CONFIG_SKIP_LOWLEVEL_INIT=1 + tplink_mr3020: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-mr3020 tplink_mr3020: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_mr3020: export COMPRESSED_UBOOT=1 +endif tplink_mr3020: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) mr3020_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size - + tplink_wr703n: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-wr703n tplink_wr703n: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_wr703n: export COMPRESSED_UBOOT=1 +endif tplink_wr703n: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) wr703n_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size tplink_wr720n_v3_CH: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-wr720n_v3_CH tplink_wr720n_v3_CH: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_wr720n_v3_CH: export COMPRESSED_UBOOT=1 +endif tplink_wr720n_v3_CH: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) wr720n_v3_CH_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size tplink_wr710n: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-wr710n tplink_wr710n: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_wr710n: export COMPRESSED_UBOOT=1 +endif tplink_wr710n: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) wr710n_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size tplink_mr3040: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-mr3040 tplink_mr3040: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_mr3040: export COMPRESSED_UBOOT=1 +endif tplink_mr3040: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) mr3040_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size tplink_mr10u: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-mr10u tplink_mr10u: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_mr10u: export COMPRESSED_UBOOT=1 +endif tplink_mr10u: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) mr10u_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size -tplink_mr13u: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-mr13u -tplink_mr13u: export MAX_UBOOT_SIZE=64 -tplink_mr13u: export COMPRESSED_UBOOT=1 +tplink_mr13u: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-mr13u +tplink_mr13u: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT +tplink_mr13u: export COMPRESSED_UBOOT=1 +endif tplink_mr13u: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) mr13u_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size tplink_wr740n_v4: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-wr740n_v4 tplink_wr740n_v4: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_wr740n_v4: export COMPRESSED_UBOOT=1 +endif tplink_wr740n_v4: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) wr740n_v4_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size tplink_mr3220_v2: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-mr3220_v2 tplink_mr3220_v2: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_mr3220_v2: export COMPRESSED_UBOOT=1 +endif tplink_mr3220_v2: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) mr3220_v2_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size tplink_wdr3600_43x0: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-wdr3600-43x0 tplink_wdr3600_43x0: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_wdr3600_43x0: export COMPRESSED_UBOOT=1 +endif tplink_wdr3600_43x0: export ETH_CONFIG=_s17 tplink_wdr3600_43x0: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) wdr3600_43x0_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size tplink_wdr3500: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-wdr3500 tplink_wdr3500: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_wdr3500: export COMPRESSED_UBOOT=1 +endif tplink_wdr3500: export ETH_CONFIG=_s27 tplink_wdr3500: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) wdr3500_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size tplink_mr3420_v2: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-mr3420_v2 tplink_mr3420_v2: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_mr3420_v2: export COMPRESSED_UBOOT=1 +endif tplink_mr3420_v2: export ETH_CONFIG=_s27 tplink_mr3420_v2: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) mr3420_v2_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size tplink_wr841n_v8: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-wr841n_v8 tplink_wr841n_v8: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_wr841n_v8: export COMPRESSED_UBOOT=1 +endif tplink_wr841n_v8: export ETH_CONFIG=_s27 tplink_wr841n_v8: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) wr841n_v8_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size tplink_wa830re_v2_wa801nd_v2: export UBOOT_FILE_NAME=uboot_for_tp-link_tl-wa830re_v2_tl-wa801nd_v2 tplink_wa830re_v2_wa801nd_v2: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT tplink_wa830re_v2_wa801nd_v2: export COMPRESSED_UBOOT=1 +endif tplink_wa830re_v2_wa801nd_v2: export ETH_CONFIG=_s27 tplink_wa830re_v2_wa801nd_v2: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) wa830re_v2_wa801nd_v2_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size dlink_dir505: export UBOOT_FILE_NAME=uboot_for_d-link_dir-505 dlink_dir505: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT dlink_dir505: export COMPRESSED_UBOOT=1 +endif dlink_dir505: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) dir505_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size gs-oolite_v1_dev: export UBOOT_FILE_NAME=uboot_for_gs-oolite_v1_dev gs-oolite_v1_dev: export MAX_UBOOT_SIZE=64 +ifndef CONFIG_SKIP_LOWLEVEL_INIT gs-oolite_v1_dev: export COMPRESSED_UBOOT=1 +endif gs-oolite_v1_dev: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) gs_oolite_v1_dev_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size 8devices_carambola2: export UBOOT_FILE_NAME=uboot_for_8devices_carambola2 @@ -163,7 +182,6 @@ gs-oolite_v1_dev: 8devices_carambola2: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) carambola2_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/u-boot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size dragino_v2_ms14: export UBOOT_FILE_NAME=uboot_for_dragino_v2_ms14 @@ -172,25 +190,40 @@ dragino_v2_ms14: export DEVICE_VENDOR=dragino dragino_v2_ms14: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) dragino_v2_ms14_config @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) ENDIANNESS=-EB V=1 all - @cp $(BUILD_TOPDIR)/u-boot/u-boot.bin $(BUILD_TOPDIR)/bin/temp.bin @make --no-print-directory show_size +ifdef CONFIG_SKIP_LOWLEVEL_INIT +show_size: export UBOOT_FILE_NAME_SUFFIX=__RAM +endif show_size: - @/bin/echo -e "\e[32m" +ifdef COMPRESSED_UBOOT + @cp $(BUILD_TOPDIR)/u-boot/tuboot.bin $(BUILD_TOPDIR)/bin/temp.bin +else + @cp $(BUILD_TOPDIR)/u-boot/u-boot.bin $(BUILD_TOPDIR)/bin/temp.bin +endif + @/bin/echo -ne "\e[32m" +ifndef CONFIG_SKIP_LOWLEVEL_INIT @echo "> Preparing $(MAX_UBOOT_SIZE)KB file filled with 0xFF..." - @`tr "\000" "\377" < /dev/zero | dd ibs=1k count=$(MAX_UBOOT_SIZE) of=$(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME).bin 2> /dev/null` + @`tr "\000" "\377" < /dev/zero | dd ibs=1k count=$(MAX_UBOOT_SIZE) of=$(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME)$(UBOOT_FILE_NAME_SUFFIX).bin 2> /dev/null` @echo "> Copying U-Boot image..." - @`dd if=$(BUILD_TOPDIR)/bin/temp.bin of=$(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME).bin conv=notrunc 2> /dev/null` + @`dd if=$(BUILD_TOPDIR)/bin/temp.bin of=$(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME)$(UBOOT_FILE_NAME_SUFFIX).bin conv=notrunc 2> /dev/null` @`rm $(BUILD_TOPDIR)/bin/temp.bin` - @echo "> U-Boot image ready, size:" `wc -c < $(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME).bin`" bytes" - @`md5sum $(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME).bin | awk '{print $$1}' | tr -d '\n' > $(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME).md5` - @`echo ' *'$(UBOOT_FILE_NAME).bin >> $(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME).md5` +else + @echo "> Copying U-Boot image..." + @`mv $(BUILD_TOPDIR)/bin/temp.bin $(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME)$(UBOOT_FILE_NAME_SUFFIX).bin` +endif + @echo "> U-Boot image ready, size:" `wc -c < $(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME)$(UBOOT_FILE_NAME_SUFFIX).bin`" bytes" + @`md5sum $(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME)$(UBOOT_FILE_NAME_SUFFIX).bin | awk '{print $$1}' | tr -d '\n' > $(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME)$(UBOOT_FILE_NAME_SUFFIX).md5` + @`echo ' *'$(UBOOT_FILE_NAME)$(UBOOT_FILE_NAME_SUFFIX).bin >> $(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME)$(UBOOT_FILE_NAME_SUFFIX).md5` +# Do not check image size for RAM version +ifndef CONFIG_SKIP_LOWLEVEL_INIT @if [ "`wc -c < $(BUILD_TOPDIR)/bin/$(UBOOT_FILE_NAME).bin`" -gt "`/bin/echo '$(MAX_UBOOT_SIZE)*1024' | bc`" ]; then \ /bin/echo -e "\e[31m\n**************************************************"; \ /bin/echo "* WARNING: U-BOOT IMAGE SIZE IS TOO BIG! *"; \ /bin/echo -e "**************************************************"; \ - fi; - @/bin/echo -e "\e[0m" + fi; +endif + @/bin/echo -ne "\e[0m" clean: @cd $(BUILD_TOPDIR)/u-boot/ && $(MAKECMD) --no-print-directory distclean diff --git a/u-boot/Makefile b/u-boot/Makefile index c277ab3..e9113ee 100755 --- a/u-boot/Makefile +++ b/u-boot/Makefile @@ -49,9 +49,11 @@ VENDOR= TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) export TOPDIR -ifeq ($(COMPRESSED_UBOOT),1) +ifdef COMPRESSED_UBOOT + ifndef CONFIG_SKIP_LOWLEVEL_INIT COMPRESSED_UBOOT = 1 export export COMPRESSED_UBOOT + endif endif ifeq (include/config.mk,$(wildcard include/config.mk)) @@ -106,8 +108,10 @@ include $(TOPDIR)/config.mk # U-Boot objects....order is important (i.e. start must be first) OBJS = cpu/$(CPU)/start.o -ifeq ($(COMPRESSED_UBOOT),1) +ifdef COMPRESSED_UBOOT + ifndef CONFIG_SKIP_LOWLEVEL_INIT OBJS_BOOTSTRAP = cpu/$(CPU)/start_bootstrap.o + endif endif LIBS = lib_generic/libgeneric.a @@ -126,17 +130,21 @@ LIBS += rtc/librtc.a LIBS += httpd/libhttpd.a LIBS += $(BOARDLIBS) -ifeq ($(COMPRESSED_UBOOT),1) +ifdef COMPRESSED_UBOOT + ifndef CONFIG_SKIP_LOWLEVEL_INIT LIBS_BOOTSTRAP = lib_bootstrap/libbootstrap.a LIBS_BOOTSTRAP += board/$(BOARDDIR)/lib$(BOARD).a LIBS_BOOTSTRAP += cpu/$(CPU)/lib$(CPU).a LIBS_BOOTSTRAP += cpu/$(CPU)/$(SOC)/lib$(SOC).a + endif endif .PHONY : $(LIBS) -ifeq ($(COMPRESSED_UBOOT),1) +ifdef COMPRESSED_UBOOT + ifndef CONFIG_SKIP_LOWLEVEL_INIT .PHONY : $(LIBS_BOOTSTRAP) + endif endif # Add GCC lib @@ -153,101 +161,106 @@ SUBDIRS = tools ALL = u-boot.srec u-boot.bin System.map -ifeq ($(COMPRESSED_UBOOT),1) -all: $(ALL) tuboot.bin +ifdef COMPRESSED_UBOOT +ifndef CONFIG_SKIP_LOWLEVEL_INIT +all: $(ALL) tuboot.bin else -all: $(ALL) +all: $(ALL) u-boot.img +endif +else +all: $(ALL) u-boot.img endif u-boot.hex: u-boot - $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ + $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ u-boot.srec: u-boot - $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ + $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ u-boot.bin: u-boot - $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ + $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ u-boot.img: u-boot.bin - @/bin/echo -e "\n\e[32m> Preparing U-Boot image...\e[0m" - ./tools/mkimage -A $(ARCH) -T firmware -C none \ + @/bin/echo -e "\e[32m> Preparing U-Boot image \"u-boot.img\"...\e[0m" + ./tools/mkimage -A $(ARCH) -T firmware -C none \ -a $(TEXT_BASE) -e 0 \ -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \ - sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \ + sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \ -d $< $@ u-boot.dis: u-boot - $(OBJDUMP) -d $< > $@ + $(OBJDUMP) -d $< > $@ -u-boot: depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT) - UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ +u-boot: depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT) + UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ $(LD) $(LDFLAGS) $$UNDEF_SYM $(OBJS) \ - --start-group $(LIBS) --end-group $(PLATFORM_LIBS) \ - -Map u-boot.map -o u-boot + --start-group $(LIBS) --end-group $(PLATFORM_LIBS) \ + -Map u-boot.map -o u-boot $(LIBS): - $(MAKE) -C `dirname $@` + $(MAKE) -C `dirname $@` $(SUBDIRS): - $(MAKE) -C $@ all + $(MAKE) -C $@ all -ifeq ($(COMPRESSED_UBOOT),1) +ifdef COMPRESSED_UBOOT +ifndef CONFIG_SKIP_LOWLEVEL_INIT LZMA = $(BUILD_TOPDIR)/host_util/lzma tuboot.bin: System.map bootstrap.bin u-boot.lzimg - @cat bootstrap.bin > $@ - @cat u-boot.lzimg >> $@ + @cat bootstrap.bin > $@ + @cat u-boot.lzimg >> $@ u-boot.lzimg: $(obj)u-boot.bin System.map - @rm -rf u-boot.bin.lzma - #$(LZMA) e $(obj)u-boot.bin u-boot.bin.lzma - $(LZMA) --best --keep $(obj)u-boot.bin - @/bin/echo -e "\n\e[32m> Preparing U-Boot image...\e[0m" - ./tools/mkimage -A mips -T firmware -C lzma \ + @rm -rf u-boot.bin.lzma + $(LZMA) --best --keep $(obj)u-boot.bin + @/bin/echo -e "\e[32m> Preparing compressed U-Boot image \"u-boot.lzimg\"...\e[0m" + ./tools/mkimage -A mips -T firmware -C lzma \ -a 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \ -e 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \ -n 'u-boot image' -d $(obj)u-boot.bin.lzma $@ bootstrap.bin: bootstrap - $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ + $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ bootstrap: depend version $(SUBDIRS) $(OBJS_BOOTSTRAP) $(LIBS_BOOTSTRAP) $(LDSCRIPT_BOOTSTRAP) - UNDEF_SYM=`$(OBJDUMP) -x $(LIBS_BOOTSTRAP) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ + UNDEF_SYM=`$(OBJDUMP) -x $(LIBS_BOOTSTRAP) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ $(LD) $(LDFLAGS_BOOTSTRAP) $$UNDEF_SYM $(OBJS_BOOTSTRAP) \ - --start-group $(LIBS_BOOTSTRAP) --end-group $(PLATFORM_LIBS) \ - -Map bootstrap.map -o bootstrap + --start-group $(LIBS_BOOTSTRAP) --end-group $(PLATFORM_LIBS) \ + -Map bootstrap.map -o bootstrap $(LIBS_BOOTSTRAP): - $(MAKE) -C `dirname $@` + $(MAKE) -C `dirname $@` +endif endif version: - @echo -n "#define U_BOOT_VERSION \"U-Boot " > $(VERSION_FILE); \ + @echo -n "#define U_BOOT_VERSION \"U-Boot " > $(VERSION_FILE); \ echo -n "$(U_BOOT_VERSION)" >> $(VERSION_FILE); \ echo "\"" >> $(VERSION_FILE) gdbtools: - $(MAKE) -C tools/gdb || exit 1 + $(MAKE) -C tools/gdb || exit 1 depend dep: - @for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir .depend ; done + @for dir in $(SUBDIRS) ; do $(MAKE) -C $$dir .depend ; done tags: - ctags -w `find $(SUBDIRS) include \ - lib_generic board/$(BOARDDIR) cpu/$(CPU) lib_$(ARCH) \ - fs/cramfs fs/fat fs/fdos fs/jffs2 \ - net disk rtc dtt drivers drivers/sk98lin common \ - \( -name CVS -prune \) -o \( -name '*.[ch]' -print \)` + ctags -w `find $(SUBDIRS) include \ + lib_generic board/$(BOARDDIR) cpu/$(CPU) lib_$(ARCH) \ + fs/cramfs fs/fat fs/fdos fs/jffs2 \ + net disk rtc dtt drivers drivers/sk98lin common \ + \( -name CVS -prune \) -o \( -name '*.[ch]' -print \)` etags: - etags -a `find $(SUBDIRS) include \ - lib_generic board/$(BOARDDIR) cpu/$(CPU) lib_$(ARCH) \ - fs/cramfs fs/fat fs/fdos fs/jffs2 \ - net disk rtc dtt drivers drivers/sk98lin common \ - \( -name CVS -prune \) -o \( -name '*.[ch]' -print \)` + etags -a `find $(SUBDIRS) include \ + lib_generic board/$(BOARDDIR) cpu/$(CPU) lib_$(ARCH) \ + fs/cramfs fs/fat fs/fdos fs/jffs2 \ + net disk rtc dtt drivers drivers/sk98lin common \ + \( -name CVS -prune \) -o \( -name '*.[ch]' -print \)` System.map: u-boot - @$(NM) $< | \ + @$(NM) $< | \ grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ sort > System.map @@ -284,6 +297,11 @@ ifdef DISABLE_CONSOLE_OUTPUT @echo "#define CONFIG_SILENT_CONSOLE 1" >> include/config.h endif +ifdef CONFIG_SKIP_LOWLEVEL_INIT + @echo "#define CONFIG_SKIP_LOWLEVEL_INIT 1" >> include/config.h + @echo "#undef COMPRESSED_UBOOT" >> include/config.h +endif + @echo "#define CONFIG_DELAY_TO_AUTORUN_HTTPD 3" >> include/config.h @echo "#define CONFIG_DELAY_TO_AUTORUN_CONSOLE 5" >> include/config.h @echo "#define CONFIG_DELAY_TO_AUTORUN_NETCONSOLE 7" >> include/config.h diff --git a/u-boot/board/ar7240/ap121/ap121.c b/u-boot/board/ar7240/ap121/ap121.c index f3882ba..bd9d264 100755 --- a/u-boot/board/ar7240/ap121/ap121.c +++ b/u-boot/board/ar7240/ap121/ap121.c @@ -205,8 +205,10 @@ void gpio_config(void){ ar7240_reg_wr(AR7240_GPIO_FUNC, (ar7240_reg_rd(AR7240_GPIO_FUNC) & 0xEF84E0FB)); +#ifndef CONFIG_SKIP_LOWLEVEL_INIT /* Disable EJTAG functionality to enable GPIO functionality */ ar7240_reg_wr(AR7240_GPIO_FUNC, (ar7240_reg_rd(AR7240_GPIO_FUNC) | 0x8001)); +#endif /* Set HORNET_BOOTSTRAP_STATUS BIT18 to ensure that software can control GPIO26 and GPIO27 */ ar7240_reg_wr(HORNET_BOOTSTRAP_STATUS, (ar7240_reg_rd(HORNET_BOOTSTRAP_STATUS) | (0x1<<18))); @@ -374,18 +376,22 @@ void gpio_config(void){ } int ar7240_mem_config(void){ -#ifndef COMPRESSED_UBOOT +#ifndef CONFIG_SKIP_LOWLEVEL_INIT + #ifndef COMPRESSED_UBOOT hornet_ddr_init(); -#endif + #endif /* Default tap values for starting the tap_init*/ ar7240_reg_wr(AR7240_DDR_TAP_CONTROL0, CFG_DDR_TAP0_VAL); ar7240_reg_wr(AR7240_DDR_TAP_CONTROL1, CFG_DDR_TAP1_VAL); +#endif gpio_config(); all_led_off(); +#ifndef CONFIG_SKIP_LOWLEVEL_INIT hornet_ddr_tap_init(); +#endif // return memory size return(ar7240_ddr_find_size()); diff --git a/u-boot/board/ar7240/ap121/config.mk b/u-boot/board/ar7240/ap121/config.mk index 34198a1..64383b6 100755 --- a/u-boot/board/ar7240/ap121/config.mk +++ b/u-boot/board/ar7240/ap121/config.mk @@ -1,7 +1,12 @@ # ROM version -ifeq ($(COMPRESSED_UBOOT),1) -TEXT_BASE = 0x80010000 -BOOTSTRAP_TEXT_BASE = 0x9F000000 +ifdef COMPRESSED_UBOOT + TEXT_BASE = 0x80010000 + BOOTSTRAP_TEXT_BASE = 0x9F000000 +# RAM version else -TEXT_BASE = 0x9F000000 + ifdef CONFIG_SKIP_LOWLEVEL_INIT + TEXT_BASE = 0x80100000 + else + TEXT_BASE = 0x9F000000 + endif endif \ No newline at end of file diff --git a/u-boot/board/ar7240/db12x/config.mk b/u-boot/board/ar7240/db12x/config.mk index 76b95d5..64383b6 100755 --- a/u-boot/board/ar7240/db12x/config.mk +++ b/u-boot/board/ar7240/db12x/config.mk @@ -1,10 +1,12 @@ # ROM version -TEXT_BASE = 0x80010000 -BOOTSTRAP_TEXT_BASE = 0x9F000000 - -# SDRAM version -# TEXT_BASE = 0x80000000 - +ifdef COMPRESSED_UBOOT + TEXT_BASE = 0x80010000 + BOOTSTRAP_TEXT_BASE = 0x9F000000 # RAM version -# TEXT_BASE = 0x83FC0000 -# TEXT_BASE = 0x80100000 +else + ifdef CONFIG_SKIP_LOWLEVEL_INIT + TEXT_BASE = 0x80100000 + else + TEXT_BASE = 0x9F000000 + endif +endif \ No newline at end of file diff --git a/u-boot/board/ar7240/db12x/db12x.c b/u-boot/board/ar7240/db12x/db12x.c index 7f91510..e37ace4 100755 --- a/u-boot/board/ar7240/db12x/db12x.c +++ b/u-boot/board/ar7240/db12x/db12x.c @@ -190,6 +190,7 @@ void ath_set_tuning_caps(void){ } int wasp_mem_config(void){ +#ifndef CONFIG_SKIP_LOWLEVEL_INIT unsigned int reg32; wasp_ddr_initial_config(CFG_DDR_REFRESH_VAL); @@ -208,7 +209,8 @@ int wasp_mem_config(void){ /* Needed here not to mess with Ethernet clocks */ ath_set_tuning_caps(); - + +#endif // return memory size return(ar7240_ddr_find_size()); } @@ -217,6 +219,13 @@ long int initdram(){ return((long int)wasp_mem_config()); } +#ifndef COMPRESSED_UBOOT +int checkboard(void){ + printf(BOARD_CUSTOM_STRING"\n\n"); + return(0); +} +#endif + /* * Returns a string with memory type preceded by a space sign */ diff --git a/u-boot/cpu/mips/ar7240/meminit.c b/u-boot/cpu/mips/ar7240/meminit.c index 88721e9..bfedccf 100755 --- a/u-boot/cpu/mips/ar7240/meminit.c +++ b/u-boot/cpu/mips/ar7240/meminit.c @@ -68,8 +68,13 @@ int ar7240_ddr_find_size(void){ break; } } - +#ifndef CONFIG_SKIP_LOWLEVEL_INIT return(i * AR7240_DDR_SIZE_INCR); +#else + // TODO: something is wrong with relocation, + // need to fix it for boards with > 32M of RAM + return((i * AR7240_DDR_SIZE_INCR) - 1024*1024); +#endif } #if defined(CONFIG_WASP) diff --git a/u-boot/cpu/mips/start.S b/u-boot/cpu/mips/start.S index 11f358a..5e6e9e4 100755 --- a/u-boot/cpu/mips/start.S +++ b/u-boot/cpu/mips/start.S @@ -184,6 +184,276 @@ _start: .align 4 reset: + +#if defined(CONFIG_WASP_SUPPORT) + + // Disable JTAG (bit 1 set) and ALL clock observation (bit 2~9 reset) + // Do not do this in RAM version! + li a1, AR934X_GPIO_FUNCTION +#ifndef CONFIG_SKIP_LOWLEVEL_INIT + li v1, 0x2 +#else + li v1, 0x0 +#endif + sw v1, 0(a1) + +#if defined(CONFIG_FOR_TPLINK_WDR3600_WDR43X0_V1) + /* + * LEDs and buttons GPIOs on WDR3600/WDR43x0 v1: + * + * 11 => USB1 LED + * 12 => USB2 LED + * 13 => WLAN2G + * 14 => SYS + * 15 => QSS + * 21 => USB2 POWER (active high) + * 22 => USB1 POWER (active high) + * + * 16 => Reset button + * 17 => Wi-Fi ON/OFF switch + * + * All OUT GPIOs are active LOW if not stated otherwise + */ + + // GPIO Init + li a1, AR934X_GPIO_OE + lw v1, 0(a1) + // Set GPIOs 11~15 and 21~22 as outputs + and v1, v1, 0xFF9F07FF + // Set GPIOs 16~17 as inputs + or v1, v1, 0x30000 + sw v1, 0(a1) + + // Set GPIO function for GPIO 11 + li a1, AR934X_GPIO_OUT_FUNCTION2 + lw v1, 0(a1) + and v1, v1, 0x00FFFFFF + sw v1, 0(a1) + + // Set GPIO function for GPIOs 12~15 + li a1, AR934X_GPIO_OUT_FUNCTION3 + li v1, 0x0 + sw v1, 0(a1) + + // Turn on power on both USB + li a1, AR934X_GPIO_SET + li v1, 0x600000 + sw v1, 0(a1) + + // Turn off all LEDs + li a1, AR934X_GPIO_SET + li v1, 0xF800 + sw v1, 0(a1) + +#elif defined(CONFIG_FOR_TPLINK_WDR3500_V1) + /* + * LEDs and buttons GPIOs on WDR3500 v1: + * + * 11 => USB LED + * 12 => USB POWER (active high) + * 13 => WLAN2G + * 14 => SYS + * 15 => QSS + * 18 => WAN + * 19 => LAN1 + * 20 => LAN2 + * 21 => LAN3 + * 22 => LAN4 + * + * 16 => Reset button + * 17 => Wi-Fi ON/OFF switch + * + * All OUT GPIOs are active LOW if not stated otherwise + */ + + // GPIO Init + li a1, AR934X_GPIO_OE + lw v1, 0(a1) + // Set GPIOs 11~15 and 18~22 as outputs + and v1, v1, 0xFF8307FF + // Set GPIOs 16~17 as inputs + or v1, v1, 0x30000 + sw v1, 0(a1) + + // Set GPIO function for GPIO 11 + li a1, AR934X_GPIO_OUT_FUNCTION2 + lw v1, 0(a1) + and v1, v1, 0x00FFFFFF + sw v1, 0(a1) + + // Set GPIO function for GPIOs 12~15 + li a1, AR934X_GPIO_OUT_FUNCTION3 + li v1, 0x0 + sw v1, 0(a1) + + // Set GPIO function for GPIOs 18~19 + li a1, AR934X_GPIO_OUT_FUNCTION4 + lw v1, 0(a1) + and v1, v1, 0xFFFF + sw v1, 0(a1) + + // Turn on power on USB + li a1, AR934X_GPIO_SET + li v1, 0x1000 + sw v1, 0(a1) + + // Turn off all LEDs + li a1, AR934X_GPIO_SET + li v1, 0x7CF800 + sw v1, 0(a1) + +#elif defined(CONFIG_FOR_TPLINK_WR841N_V8) + /* + * LEDs and buttons GPIOs on WR841N/D v8: + * + * 12 => LAN4 + * 13 => WLAN + * 14 => SYS + * 15 => QSS + * 18 => WAN + * 19 => LAN1 + * 20 => LAN2 + * 21 => LAN3 + * + * 16 => Wi-Fi ON/OFF switch + * 17 => Reset button + * + * All OUT GPIOs are active LOW if not stated otherwise + */ + + // GPIOs init + li a1, AR934X_GPIO_OE + lw v1, 0(a1) + // Set GPIOs 12~15 and 18~21 as outputs + and v1, v1, 0xFFC30FFF + // Set GPIOs 16~17 as inputs + or v1, v1, 0x30000 + sw v1, 0(a1) + + // Set gpio function for GPIOs 12~15 + li a1, AR934X_GPIO_OUT_FUNCTION3 + li v1, 0x0 + sw v1, 0(a1) + + // Set GPIO function for GPIOs 18~19 + li a1, AR934X_GPIO_OUT_FUNCTION4 + lw v1, 0(a1) + and v1, v1, 0xFFFF + sw v1, 0(a1) + + // Turn off all LEDs + li a1, AR934X_GPIO_SET + li v1, 0x3CF000 + sw v1, 0(a1) + +#elif defined(CONFIG_FOR_TPLINK_MR3420_V2) + /* + * LEDs and buttons GPIOs on MR3420 v2: + * + * 4 => USB Power (active high) + * 11 => USB/3G LED + * 12 => LAN4 + * 13 => WLAN + * 14 => SYS + * 15 => QSS + * 18 => WAN + * 19 => LAN1 + * 20 => LAN2 + * 21 => LAN3 + * + * 16 => WPS button + * 17 => Reset button + * + * All OUT GPIOs are active LOW if not stated otherwise + */ + + // GPIOs init + li a1, AR934X_GPIO_OE + lw v1, 0(a1) + // Set GPIOs 4, 11~15 and 18~21 as outputs + and v1, v1, 0xFFC307EF + // Set GPIOs 16~17 as inputs + or v1, v1, 0x30000 + sw v1, 0(a1) + + // Set GPIO function for GPIO 4 + li a1, AR934X_GPIO_OUT_FUNCTION1 + lw v1, 0(a1) + and v1, v1, 0xFFFFFF00 + sw v1, 0(a1) + + // Set GPIO function for GPIO 11 + li a1, AR934X_GPIO_OUT_FUNCTION2 + lw v1, 0(a1) + and v1, v1, 0x00FFFFFF + sw v1, 0(a1) + + // Set GPIO function for GPIOs 12~15 + li a1, AR934X_GPIO_OUT_FUNCTION3 + li v1, 0x0 + sw v1, 0(a1) + + // Set GPIO function for GPIOs 18~19 + li a1, AR934X_GPIO_OUT_FUNCTION4 + lw v1, 0(a1) + and v1, v1, 0xFFFF + sw v1, 0(a1) + + // Turn on power on USB + li a1, AR934X_GPIO_SET + li v1, 0x10 + sw v1, 0(a1) + + // Turn off all LEDs + li a1, AR934X_GPIO_SET + li v1, 0x3CF800 + sw v1, 0(a1) + +#elif defined(CONFIG_FOR_TPLINK_WA830RE_V2_WA801ND_V2) + /* + * LEDs and buttons GPIOs on WA830REv2 and WA801ND v2: + * + * 13 => WLAN + * 14 => SYS + * 15 => QSS + * 18 => LAN + * + * 16 => Range Extender + * 17 => Reset button + * + * All OUT GPIOs are active LOW if not stated otherwise + */ + + // GPIOs init + li a1, AR934X_GPIO_OE + lw v1, 0(a1) + // Set GPIOs 13~15 and 18 as outputs + and v1, v1, 0xFFFB1FFF + // Set GPIOs 16~17 as inputs + or v1, v1, 0x30000 + sw v1, 0(a1) + + // Set GPIO function for GPIOs 13~15 + li a1, AR934X_GPIO_OUT_FUNCTION3 + lw v1, 0(a1) + and v1, v1, 0xFF + sw v1, 0(a1) + + // Set GPIO function for GPIO 18 + li a1, AR934X_GPIO_OUT_FUNCTION4 + lw v1, 0(a1) + and v1, v1, 0xFF00FFFF + sw v1, 0(a1) + + // Turn off all LEDs + li a1, AR934X_GPIO_SET + li v1, 0x4E000 + sw v1, 0(a1) + +#endif + +#endif /* #if defined(CONFIG_WASP_SUPPORT) */ + /* * Clearing CP0 registers - This is generally required for the MIPS-24k * core used by Atheros. @@ -206,22 +476,19 @@ reset: mtc0 zero, $14 mtc0 zero, $15 mtc0 zero, $16 -#if !defined(CONFIG_WASP_SUPPORT) mtc0 zero, $17 -#endif mtc0 zero, $18 mtc0 zero, $19 -#if !defined(CONFIG_WASP_SUPPORT) mtc0 zero, $20 mtc0 zero, $21 mtc0 zero, $22 -#endif mtc0 zero, $23 mtc0 zero, $24 mtc0 zero, $25 mtc0 zero, $26 mtc0 zero, $27 mtc0 zero, $28 + #ifdef CONFIG_WASP_SUPPORT mtc0 zero, $29 # C0_TagHi mtc0 zero, $28, 2 # C0_DTagLo @@ -249,9 +516,11 @@ reset: mtc0 zero, CP0_COUNT mtc0 zero, CP0_COMPARE +#ifndef CONFIG_SKIP_LOWLEVEL_INIT /* CONFIG0 register */ li t0, CONF_CM_UNCACHED mtc0 t0, CP0_CONFIG +#endif /* #ifndef CONFIG_SKIP_LOWLEVEL_INIT */ #endif /* #ifndef COMPRESSED_UBOOT */ @@ -266,6 +535,7 @@ reset: #ifndef COMPRESSED_UBOOT +#ifndef CONFIG_SKIP_LOWLEVEL_INIT #if defined(CONFIG_MACH_HORNET) && defined(CONFIG_HORNET_1_1_WAR) /**************************************************************************/ /* @@ -293,11 +563,13 @@ do_reset: normal_path: #endif /* CONFIG_MACH_HORNET */ +#endif /**************************************************************************/ /* Initialize any external memory. */ +#ifndef CONFIG_SKIP_LOWLEVEL_INIT #if defined(CONFIG_AR7100) || defined(CONFIG_AR7240) || defined(CONFIG_ATHEROS) la t9, lowlevel_init jalr t9 @@ -315,6 +587,7 @@ normal_path: j t0 nop #endif +#endif /* #ifndef CONFIG_SKIP_LOWLEVEL_INIT */ rel_start: @@ -333,6 +606,7 @@ rel_start: sw t0, 0(a0) #endif +#ifndef CONFIG_SKIP_LOWLEVEL_INIT /* Initialize caches... */ la t9, simple_mips_cache_reset @@ -370,6 +644,7 @@ rel_start: jalr t9 nop #endif +#endif /* #ifndef CONFIG_SKIP_LOWLEVEL_INIT */ #endif /* #ifndef COMPRESSED_UBOOT */ diff --git a/u-boot/lib_mips/board.c b/u-boot/lib_mips/board.c index 451e094..68a95eb 100755 --- a/u-boot/lib_mips/board.c +++ b/u-boot/lib_mips/board.c @@ -57,7 +57,7 @@ extern void ar7240_sys_frequency(u32 *cpu_freq, u32 *ddr_freq, u32 *ahb_freq); ulong monitor_flash_len; -const char version_string[] = U_BOOT_VERSION" (" __DATE__ ")"; +const char version_string[] = U_BOOT_VERSION" (" __DATE__ ", " __TIME__ ")"; // Begin and End of memory area for malloc(), and current "brk" static ulong mem_malloc_start; @@ -87,7 +87,15 @@ void *sbrk(ptrdiff_t increment){ } static int display_banner(void){ - printf("\n\n*********************************************\n* %s *\n*********************************************\n\n", version_string); +#ifndef CONFIG_SKIP_LOWLEVEL_INIT + printf("\n\n*********************************************\n* %s *\n*********************************************\n\n", version_string); +#else + printf("\n\n*********************************************\n"); + printf("* *\n"); + printf("* RAM VERSION *\n"); + printf("* *\n"); + printf("*********************************************\n* %s *\n*********************************************\n\n", version_string); +#endif return(0); } @@ -101,7 +109,12 @@ static int init_func_ram(void){ puts("DRAM: "); if((gd->ram_size = initdram()) > 0){ +#ifndef CONFIG_SKIP_LOWLEVEL_INIT print_size(gd->ram_size, print_mem_type()); +#else + // TODO: fix me! + print_size(gd->ram_size + 1024*1024, print_mem_type()); +#endif puts("\n"); return(0); } -- 2.25.1