diff --git a/Makefile b/Makefile index e4eafa0..4a4b8b0 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,13 @@ GLIBC_PORTS_URL=ftp://ftp.gnu.org/gnu/glibc/$(GLIBC_PORTS_PACKAGE) KERNEL_HEADERS_PACKAGE=$(KERNEL_HEADERS_VER).tar.bz2 KERNEL_HEADERS_URL= +# for the device stage +FLASH_TOOL_PATH = ./flash-tool +FLASH_TOOL_BIN_PATH = $(FLASH_TOOL_PATH)/bin +STAGE1_PATH = $(FLASH_TOOL_PATH)/device_stage1 +STAGE2_PATH = $(FLASH_TOOL_PATH)/device_stage2 +CROSS_COMPILE ?= mipsel-linux- + CFLAGS="-O2" export PATH:=$(PWD)/install/bin:$(PATH) @@ -149,8 +156,20 @@ kernel: ### flash-boot .PHONY: flash-tool -flash-tool: - make -C ./flash-tool +flash-tool: #stage1 stage2 + mkdir -p $(FLASH_TOOL_BIN_PATH) + cp $(FLASH_TOOL_PATH)/usb_boot.cfg $(FLASH_TOOL_BIN_PATH) + cd $(FLASH_TOOL_PATH) && \ + ./autogen.sh && \ + ./configure && \ + make + cp $(FLASH_TOOL_PATH)/src/inflash $(FLASH_TOOL_BIN_PATH) + +stage1: + make CROSS_COMPILE=$(CROSS_COMPILE) -C $(STAGE1_PATH) + +stage2: + make CROSS_COMPILE=$(CROSS_COMPILE) -C $(STAGE2_PATH) ### clean up distclean: clean clean-toolchain diff --git a/flash-tool/Makefile b/flash-tool/Makefile deleted file mode 100644 index 500f8ed..0000000 --- a/flash-tool/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -# -# "Ingenic flash tool" - flash the Ingenic CPU via USB -# -# (C) Copyright 2009 -# Author: Marek Lindner -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# version 3 as published by the Free Software Foundation. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301, USA - - - -ifneq ($(findstring $(MAKEFLAGS),s),s) -ifndef V - Q_CC = @echo ' ' CC $@; - Q_LD = @echo ' ' LD $@; - export Q_CC - export Q_LD -endif -endif - -STAGE1_PATH = ./device_stage1 -STAGE2_PATH = ./device_stage2 - -CROSS_COMPILE ?= mipsel-linux- - -CC = gcc -CFLAGS += -pedantic -Wall -W -O1 -g3 -std=gnu99 -LDFLAGS += -lusb -lconfuse -BINARY_NAME = inflash -TARGETS = $(BINARY_NAME) stage1 stage2 - -SRC_C= main.c ingenic_cfg.c ingenic_usb.c cmd.c command_line.c -SRC_H= ingenic_cfg.h ingenic_usb.h usb_boot_defines.h \ - command_line.h cmd.h config.h -SRC_O= $(SRC_C:.c=.o) - -default: $(TARGETS) - -$(BINARY_NAME): $(SRC_O) $(SRC_H) Makefile - $(Q_LD)$(CC) -o $@ $(SRC_O) $(LDFLAGS) - -.c.o: - $(Q_CC)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -MD -c $< -o $@ --include $(SRC_C:.c=.d) - -# for the device stage -stage1: - make CROSS_COMPILE=$(CROSS_COMPILE) -C $(STAGE1_PATH) - -stage2: - make CROSS_COMPILE=$(CROSS_COMPILE) -C $(STAGE2_PATH) - -clean: - make CROSS_COMPILE=$(CROSS_COMPILE) -C $(STAGE1_PATH) clean - make CROSS_COMPILE=$(CROSS_COMPILE) -C $(STAGE2_PATH) clean - rm -f $(BINARY_NAME) *.o *~ - rm -f `find . -name '*.d' -print` diff --git a/flash-tool/config.h b/flash-tool/config.h deleted file mode 100644 index 15eb84d..0000000 --- a/flash-tool/config.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * "Ingenic flash tool" - flash the Ingenic CPU via USB - * - * (C) Copyright 2009 - * Author: Xiangfu Liu - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 3 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ -#ifndef __CONFIG_H__ -#define __CONFIG_H__ - -#define CURRENT_VERSION "1.0.0" - -#endif /* __CONFIG_H__ */ diff --git a/flash-tool/device_stage1/Makefile b/flash-tool/device_stage1/Makefile index 2d8cd02..8d463e9 100644 --- a/flash-tool/device_stage1/Makefile +++ b/flash-tool/device_stage1/Makefile @@ -18,13 +18,14 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301, USA -FLASH_TOOL_PATH = .. +FLASH_TOOL_BIN_PATH = ../bin +FLASH_TOOL_SRC_PATH = ../src ifeq ($(CROSS_COMPILE),) $(error CROSS_COMPILE variable not set) endif -CFLAGS := -O2 -mips32 -fno-pic -mno-abicalls -I.. +CFLAGS := -O2 -mips32 -fno-pic -mno-abicalls -I$(FLASH_TOOL_SRC_PATH) LDFLAGS := -nostdlib -EL -T target.ld OBJS = head.o main.o common.o board_4740.o board_4750.o debug.o @@ -36,7 +37,8 @@ fw.bin: fw.elf $(CROSS_COMPILE)objdump -D $< > fw.dump $(CROSS_COMPILE)objdump -h $< > fw.map $(CROSS_COMPILE)nm -n $< > System.map - cp fw.bin $(FLASH_TOOL_PATH) + mkdir -p $(FLASH_TOOL_BIN_PATH) + cp fw.bin $(FLASH_TOOL_BIN_PATH) fw.elf: $(OBJS) $(CROSS_COMPILE)ld $(LDFLAGS) $(OBJS) -o $@ diff --git a/flash-tool/device_stage2/Makefile b/flash-tool/device_stage2/Makefile index 779422c..a1d826b 100644 --- a/flash-tool/device_stage2/Makefile +++ b/flash-tool/device_stage2/Makefile @@ -7,7 +7,9 @@ # published by the Free Software Foundation. # -FLASH_TOOL_PATH = .. +FLASH_TOOL_BIN_PATH = ../bin +FLASH_TOOL_SRC_PATH = ../src + ifeq ($(CROSS_COMPILE),) $(error CROSS_COMPILE variable not set) @@ -48,7 +50,7 @@ HEADS := $(SOCDIR)/head.S CFLAGS += -I$(SOCDIR)/include -I$(USBBOOTDIR)/usb_boot \ -I$(USBBOOTDIR)/nandflash -I$(USBBOOTDIR)/include \ - -I.. + -I$(FLASH_TOOL_SRC_PATH) OBJS := $(addsuffix .o , $(basename $(notdir $(SOURCES)))) HEADO := $(addsuffix .o , $(basename $(notdir $(HEADS)))) @@ -64,6 +66,7 @@ all: $(APP) $(OBJDUMP) -D $(APP) > $(TARGET).dump $(NM) $(APP) | sort > $(TARGET).sym $(OBJDUMP) -h $(APP) > $(TARGET).map + mkdir -p $(FLASH_TOOL_BIN_PATH) cp usb_boot.bin $(FLASH_TOOL_PATH) $(APP): $(HEADO) $(OBJS) $(EXTLIBS) diff --git a/flash-tool/src/Makefile.am b/flash-tool/src/Makefile.am new file mode 100644 index 0000000..0d81168 --- /dev/null +++ b/flash-tool/src/Makefile.am @@ -0,0 +1,12 @@ +AM_CFLAGS = -pedantic -Wall -W -O1 -g3 -std=gnu99 -lusb -lconfuse +AM_LDFLAGS = -lusb -lconfuse + +inflash_version.h: + echo -e '#ifndef INFLASH_VERSION' \ + '\n#define INFLASH_VERSION "'`svnversion`'"' \ + '\n#endif' > inflash_version.h +BUILT_SOURCES = inflash_version.h + +bin_PROGRAMS = inflash +inflash_SOURCES = cmd.c command_line.c ingenic_cfg.c \ + ingenic_usb.c main.c diff --git a/flash-tool/cmd.c b/flash-tool/src/cmd.c similarity index 100% rename from flash-tool/cmd.c rename to flash-tool/src/cmd.c diff --git a/flash-tool/cmd.h b/flash-tool/src/cmd.h similarity index 100% rename from flash-tool/cmd.h rename to flash-tool/src/cmd.h diff --git a/flash-tool/command_line.c b/flash-tool/src/command_line.c similarity index 98% rename from flash-tool/command_line.c rename to flash-tool/src/command_line.c index 922b013..f87714c 100644 --- a/flash-tool/command_line.c +++ b/flash-tool/src/command_line.c @@ -25,7 +25,7 @@ #include "usb_boot_defines.h" #include "ingenic_usb.h" #include "cmd.h" -#include "config.h" +#include "inflash_version.h" extern struct nand_in nand_in; int com_argc; @@ -94,7 +94,7 @@ static int handle_help(void) static int handle_version(void) { - printf("\n USB Boot Software current version: %s", CURRENT_VERSION); + printf("\n USB Boot Software current version: %s", INFLASH_VERSION); return 1; } diff --git a/flash-tool/command_line.h b/flash-tool/src/command_line.h similarity index 100% rename from flash-tool/command_line.h rename to flash-tool/src/command_line.h diff --git a/flash-tool/ingenic_cfg.c b/flash-tool/src/ingenic_cfg.c similarity index 100% rename from flash-tool/ingenic_cfg.c rename to flash-tool/src/ingenic_cfg.c diff --git a/flash-tool/ingenic_cfg.h b/flash-tool/src/ingenic_cfg.h similarity index 100% rename from flash-tool/ingenic_cfg.h rename to flash-tool/src/ingenic_cfg.h diff --git a/flash-tool/ingenic_usb.c b/flash-tool/src/ingenic_usb.c similarity index 100% rename from flash-tool/ingenic_usb.c rename to flash-tool/src/ingenic_usb.c diff --git a/flash-tool/ingenic_usb.h b/flash-tool/src/ingenic_usb.h similarity index 100% rename from flash-tool/ingenic_usb.h rename to flash-tool/src/ingenic_usb.h diff --git a/flash-tool/main.c b/flash-tool/src/main.c similarity index 97% rename from flash-tool/main.c rename to flash-tool/src/main.c index cb96636..7fb9ba8 100644 --- a/flash-tool/main.c +++ b/flash-tool/src/main.c @@ -22,7 +22,7 @@ #include #include #include -#include "config.h" +#include "inflash_version.h" #include "command_line.h" #include "ingenic_usb.h" #include "ingenic_cfg.h" @@ -42,7 +42,7 @@ static void help(void) static void print_version(void) { - printf("inflash version: %s\n", CURRENT_VERSION); + printf("inflash version: %s\n", INFLASH_VERSION); } static struct option opts[] = { diff --git a/flash-tool/usb_boot_defines.h b/flash-tool/src/usb_boot_defines.h similarity index 100% rename from flash-tool/usb_boot_defines.h rename to flash-tool/src/usb_boot_defines.h