[U-Boot] [PATCH] [PoC] basic kbuild output support
Mike Frysinger
vapier at gentoo.org
Sat Jun 25 06:39:48 CEST 2011
I know at first blush this isn't going to be supported, but it's just
a PoC that things are (mostly) possible without much effort.
Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
Makefile | 54 ++++++++++++++++++++++-------------------
common/kgdb.c | 52 +++++++++++++++++++++------------------
config.mk | 30 ++++++++++++++++++----
examples/api/Makefile | 11 +++++---
examples/standalone/Makefile | 9 ++++--
tools/Makefile | 48 +++++++++++++++++++++----------------
6 files changed, 121 insertions(+), 83 deletions(-)
diff --git a/Makefile b/Makefile
index 43a9145..407bf22 100644
--- a/Makefile
+++ b/Makefile
@@ -53,18 +53,12 @@ SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
export HOSTARCH HOSTOS SHELL
+MAKEFLAGS += --no-print-directory
+
# Deal with colliding definitions from tcsh etc.
VENDOR=
#########################################################################
-# Allow for silent builds
-ifeq (,$(findstring s,$(MAKEFLAGS)))
-XECHO = echo
-else
-XECHO = :
-endif
-
-#########################################################################
#
# U-boot build supports producing a object files to the separate external
# directory. Two use cases are supported:
@@ -327,25 +321,31 @@ ALL += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND) $(U_BO
all: $(ALL)
$(obj)u-boot.hex: $(obj)u-boot
- $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
+ @$(XECHO) " OBJCOPY $@"
+ $(Q)$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@
$(obj)u-boot.srec: $(obj)u-boot
- $(OBJCOPY) -O srec $< $@
+ @$(XECHO) " OBJCOPY $@"
+ $(Q)$(OBJCOPY) -O srec $< $@
$(obj)u-boot.bin: $(obj)u-boot
- $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
+ @$(XECHO) " OBJCOPY $@"
+ $(Q)$(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
$(BOARD_SIZE_CHECK)
$(obj)u-boot.ldr: $(obj)u-boot
- $(CREATE_LDR_ENV)
- $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
+ @$(XECHO) " LDR $@"
+ $(Q)$(CREATE_LDR_ENV)
+ $(Q)$(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS)
$(BOARD_SIZE_CHECK)
$(obj)u-boot.ldr.hex: $(obj)u-boot.ldr
- $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
+ @$(XECHO) " OBJCOPY $@"
+ $(Q)$(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary
$(obj)u-boot.ldr.srec: $(obj)u-boot.ldr
- $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
+ @$(XECHO) " OBJCOPY $@"
+ $(Q)$(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary
$(obj)u-boot.img: $(obj)u-boot.bin
$(obj)tools/mkimage -A $(ARCH) -T firmware -C none \
@@ -376,29 +376,32 @@ GEN_UBOOT = \
-Map u-boot.map -o u-boot
$(obj)u-boot: depend \
$(SUBDIRS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds
- $(GEN_UBOOT)
+ @$(XECHO) " LD $@"
+ $(Q)$(GEN_UBOOT)
ifeq ($(CONFIG_KALLSYMS),y)
- smap=`$(call SYSTEM_MAP,u-boot) | \
+ @$(XECHO) " SYMMAP $@"
+ $(Q)smap=`$(call SYSTEM_MAP,u-boot) | \
awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
$(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \
-c common/system_map.c -o $(obj)common/system_map.o
- $(GEN_UBOOT) $(obj)common/system_map.o
+ @$(XECHO) " LD $@"
+ $(Q)$(GEN_UBOOT) $(obj)common/system_map.o
endif
$(OBJS): depend
- $(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))
+ $(Q)$(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))
$(LIBS): depend $(SUBDIRS)
- $(MAKE) -C $(dir $(subst $(obj),,$@))
+ $(Q)$(MAKE) -C $(dir $(subst $(obj),,$@))
$(LIBBOARD): depend $(LIBS)
- $(MAKE) -C $(dir $(subst $(obj),,$@))
+ $(Q)$(MAKE) -C $(dir $(subst $(obj),,$@))
$(SUBDIRS): depend
- $(MAKE) -C $@ all
+ $(Q)$(MAKE) -C $@ all
$(LDSCRIPT): depend
- $(MAKE) -C $(dir $@) $(notdir $@)
+ $(Q)$(MAKE) -C $(dir $@) $(notdir $@)
# The linker script lacks proper dependency information atm, so force it
# to be regenerated on every link. This shouldn't be to big of an issue
@@ -407,7 +410,8 @@ $(LDSCRIPT): depend
# board config file ...
.PHONY: $(obj)u-boot.lds
$(obj)u-boot.lds: $(LDSCRIPT)
- $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
+ @$(XECHO) " CPP $@"
+ $(Q)$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@
$(NAND_SPL): $(TIMESTAMP_FILE) $(VERSION_FILE) depend
$(MAKE) -C nand_spl/board/$(BOARDDIR) all
@@ -442,7 +446,7 @@ updater:
depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \
$(obj)include/autoconf.mk \
$(obj)include/generated/generic-asm-offsets.h
- for dir in $(SUBDIRS) $(CPUDIR) $(dir $(LDSCRIPT)) ; do \
+ $(Q)for dir in $(SUBDIRS) $(CPUDIR) $(dir $(LDSCRIPT)) ; do \
$(MAKE) -C $$dir _depend ; done
TAG_SUBDIRS = $(SUBDIRS)
diff --git a/common/kgdb.c b/common/kgdb.c
index 8a621ad..5bfd58d 100644
--- a/common/kgdb.c
+++ b/common/kgdb.c
@@ -87,13 +87,13 @@
*
****************************************************************************/
+#define DEBUG 1
+
#include <common.h>
#include <kgdb.h>
#include <command.h>
-#undef KGDB_DEBUG
-
/*
* BUFMAX defines the maximum number of characters in inbound/outbound buffers
*/
@@ -107,7 +107,8 @@ static int kgdb_active = 0, first_entry = 1;
static struct pt_regs entry_regs;
static long error_jmp_buf[BUFMAX/2];
static int longjmp_on_fault = 0;
-#ifdef KGDB_DEBUG
+
+#ifdef DEBUG
static int kdebug = 1;
#endif
@@ -230,16 +231,13 @@ getpacket(char *buffer)
int count;
unsigned char ch;
+ debugX(kdebug, "waiting for $...# packet\n");
+
do {
/* wait around for the start character, ignore all other
* characters */
- while ((ch = (getDebugChar() & 0x7f)) != '$') {
-#ifdef KGDB_DEBUG
- if (kdebug)
- putc(ch);
-#endif
+ while ((ch = (getDebugChar() & 0x7f)) != '$')
;
- }
checksum = 0;
xmitcsum = -1;
@@ -287,8 +285,12 @@ static void
putpacket(unsigned char *buffer)
{
unsigned char checksum;
- int count;
+ int count, i, j;
unsigned char ch, recv;
+ char buf[256];
+
+ i = 0;
+ debugX(kdebug, "waiting for '+' ack packet\n");
/* $<packet info>#<checksum>. */
do {
@@ -306,7 +308,15 @@ putpacket(unsigned char *buffer)
putDebugChar(hexchars[checksum >> 4]);
putDebugChar(hexchars[checksum & 0xf]);
recv = getDebugChar();
+ buf[i++] = recv;
+// if ((recv & 0x7f) != '+')
+// debugX(kdebug, "waiting for '+', but got %i:%c\n", recv, recv);
} while ((recv & 0x7f) != '+');
+
+ debug("got back: ");
+ for (j = 0; j < i; ++j)
+ debug("%i:%c ", buf[j], buf[j]);
+ debug("\n");
}
/*
@@ -378,12 +388,12 @@ handle_exception (struct pt_regs *regs)
*ptr = 0;
-#ifdef KGDB_DEBUG
- if (kdebug)
- printf("kgdb: remcomOutBuffer: %s\n", remcomOutBuffer);
-#endif
+ debugX(kdebug, "kgdb: remcomOutBuffer: %s\n", remcomOutBuffer);
- putpacket((unsigned char *)&remcomOutBuffer);
+ while (serial_tstc())
+ serial_getc();
+
+// putpacket((unsigned char *)&remcomOutBuffer);
while (1) {
volatile int errnum;
@@ -393,10 +403,7 @@ handle_exception (struct pt_regs *regs)
getpacket(remcomInBuffer);
ptr = &remcomInBuffer[1];
-#ifdef KGDB_DEBUG
- if (kdebug)
- printf("kgdb: remcomInBuffer: %s\n", remcomInBuffer);
-#endif
+ debugX(kdebug, "kgdb: remcomInBuffer: %s\n", remcomInBuffer);
errnum = kgdb_setjmp(error_jmp_buf);
@@ -409,7 +416,7 @@ handle_exception (struct pt_regs *regs)
remcomOutBuffer[3] = 0;
break;
-#ifdef KGDB_DEBUG
+#ifdef DEBUG
case 'd':
/* toggle debug flag */
kdebug ^= 1;
@@ -521,10 +528,7 @@ handle_exception (struct pt_regs *regs)
if (errnum != 0)
sprintf(remcomOutBuffer, "E%02d", errnum);
-#ifdef KGDB_DEBUG
- if (kdebug)
- printf("kgdb: remcomOutBuffer: %s\n", remcomOutBuffer);
-#endif
+ debugX(kdebug, "kgdb: remcomOutBuffer: %s\n", remcomOutBuffer);
/* reply to the request */
putpacket((unsigned char *)&remcomOutBuffer);
diff --git a/config.mk b/config.mk
index 97d2631..653d52d 100644
--- a/config.mk
+++ b/config.mk
@@ -45,6 +45,16 @@ PLATFORM_CPPFLAGS =
PLATFORM_LDFLAGS =
#########################################################################
+# Allow for silent builds
+ifeq (,$(findstring s,$(MAKEFLAGS)))
+XECHO = echo
+Q = @
+else
+XECHO = :
+Q =
+endif
+
+#########################################################################
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
$(HOSTCPPFLAGS)
@@ -253,21 +263,29 @@ BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
$(obj)%.s: %.S
- $(CPP) $(ALL_AFLAGS) -o $@ $<
+ @$(XECHO) " CPP $@"
+ $(Q)$(CPP) $(ALL_AFLAGS) -o $@ $<
$(obj)%.o: %.S
- $(CC) $(ALL_AFLAGS) -o $@ $< -c
+ @$(XECHO) " CC $@"
+ $(Q)$(CC) $(ALL_AFLAGS) -o $@ $< -c
$(obj)%.o: %.c
- $(CC) $(ALL_CFLAGS) -o $@ $< -c
+ @$(XECHO) " CC $@"
+ $(Q)$(CC) $(ALL_CFLAGS) -o $@ $< -c
$(obj)%.i: %.c
- $(CPP) $(ALL_CFLAGS) -o $@ $< -c
+ @$(XECHO) " CPP $@"
+ $(Q)$(CPP) $(ALL_CFLAGS) -o $@ $< -c
$(obj)%.s: %.c
- $(CC) $(ALL_CFLAGS) -o $@ $< -c -S
+ @$(XECHO) " CC $@"
+ $(Q)$(CC) $(ALL_CFLAGS) -o $@ $< -c -S
#########################################################################
# If the list of objects to link is empty, just create an empty built-in.o
cmd_link_o_target = $(if $(strip $1),\
+ @$(XECHO) " LD $@"; \
$(LD) $(LDFLAGS) -r -o $@ $1,\
- rm -f $@; $(AR) rcs $@ )
+ @rm -f $@; \
+ $(XECHO) " LD $@"; \
+ $(AR) rcs $@)
#########################################################################
diff --git a/examples/api/Makefile b/examples/api/Makefile
index 5b5f7a6..9b3757c 100644
--- a/examples/api/Makefile
+++ b/examples/api/Makefile
@@ -71,16 +71,19 @@ all: $(obj).depend $(OUTPUT)
#########################################################################
$(OUTPUT): $(OBJS)
- $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc
- $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
+ @$(XECHO) " LD $@"
+ $(Q)$(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc
+ $(Q)$(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
# Rule to build generic library C files
$(obj)%.o: $(SRCTREE)/lib/%.c
- $(CC) -g $(CFLAGS) -c -o $@ $<
+ @$(XECHO) " CC $@"
+ $(Q)$(CC) -g $(CFLAGS) -c -o $@ $<
# Rule to build architecture-specific library assembly files
$(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
- $(CC) -g $(CFLAGS) -c -o $@ $<
+ @$(XECHO) " CC $@"
+ $(Q)$(CC) -g $(CFLAGS) -c -o $@ $<
#########################################################################
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index c1dfdce..6b97d00 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -95,17 +95,20 @@ $(LIB): $(obj).depend $(LIBOBJS)
$(ELF):
$(obj)%: $(obj)%.o $(LIB)
- $(LD) -g -Ttext $(STANDALONE_LOAD_ADDR) \
+ @$(XECHO) " CC $@"
+ $(Q)$(LD) -g -Ttext $(STANDALONE_LOAD_ADDR) \
-o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
-L$(gcclibdir) -lgcc
$(SREC):
$(obj)%.srec: $(obj)%
- $(OBJCOPY) -O srec $< $@ 2>/dev/null
+ @$(XECHO) " OBJCOPY $@"
+ $(Q)$(OBJCOPY) -O srec $< $@ 2>/dev/null
$(BIN):
$(obj)%.bin: $(obj)%
- $(OBJCOPY) -O binary $< $@ 2>/dev/null
+ @$(XECHO) " OBJCOPY $@"
+ $(Q)$(OBJCOPY) -O binary $< $@ 2>/dev/null
#########################################################################
diff --git a/tools/Makefile b/tools/Makefile
index 97f83f8..121cc62 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -156,28 +156,37 @@ HOSTCPPFLAGS = -idirafter $(SRCTREE)/include \
all: $(obj).depend $(BINS) $(LOGO-y) subdirs
-$(obj)bin2header$(SFX): $(obj)bin2header.o
- $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+cmd_host_link = \
+ @set -e; \
+ $(XECHO) " HOSTCC $@"; \
+ $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^; \
$(HOSTSTRIP) $@
+cmd_host_cc_noped = \
+ @set -e; \
+ $(XECHO) " HOSTCC $@"; \
+ $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
+cmd_host_cc = \
+ @set -e; \
+ $(XECHO) " HOSTCC $@"; \
+ $(HOSTCC) -g $(HOSTCFLAGS) -c -o $@ $<
+
+$(obj)bin2header$(SFX): $(obj)bin2header.o
+ $(cmd_host_link)
$(obj)bmp_logo$(SFX): $(obj)bmp_logo.o
- $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
- $(HOSTSTRIP) $@
+ $(cmd_host_link)
$(obj)envcrc$(SFX): $(obj)crc32.o $(obj)env_embedded.o $(obj)envcrc.o $(obj)sha1.o
- $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(cmd_host_link)
$(obj)gen_eth_addr$(SFX): $(obj)gen_eth_addr.o
- $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
- $(HOSTSTRIP) $@
+ $(cmd_host_link)
$(obj)img2srec$(SFX): $(obj)img2srec.o
- $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
- $(HOSTSTRIP) $@
+ $(cmd_host_link)
$(obj)inca-swap-bytes$(SFX): $(obj)inca-swap-bytes.o
- $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
- $(HOSTSTRIP) $@
+ $(cmd_host_link)
$(obj)mkimage$(SFX): $(obj)crc32.o \
$(obj)default_image.o \
@@ -190,29 +199,26 @@ $(obj)mkimage$(SFX): $(obj)crc32.o \
$(obj)os_support.o \
$(obj)sha1.o \
$(LIBFDT_OBJS)
- $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
- $(HOSTSTRIP) $@
+ $(cmd_host_link)
$(obj)mpc86x_clk$(SFX): $(obj)mpc86x_clk.o
- $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
- $(HOSTSTRIP) $@
+ $(cmd_host_link)
$(obj)ncb$(SFX): $(obj)ncb.o
- $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
- $(HOSTSTRIP) $@
+ $(cmd_host_link)
$(obj)ubsha1$(SFX): $(obj)os_support.o $(obj)sha1.o $(obj)ubsha1.o
- $(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $^
+ $(cmd_host_link)
# Some of the tool objects need to be accessed from outside the tools directory
$(obj)%.o: $(SRCTREE)/common/%.c
- $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
+ $(cmd_host_cc_noped)
$(obj)%.o: $(SRCTREE)/lib/%.c
- $(HOSTCC) -g $(HOSTCFLAGS) -c -o $@ $<
+ $(cmd_host_cc)
$(obj)%.o: $(SRCTREE)/lib/libfdt/%.c
- $(HOSTCC) -g $(HOSTCFLAGS_NOPED) -c -o $@ $<
+ $(cmd_host_cc_noped)
subdirs:
ifeq ($(TOOLSUBDIRS),)
--
1.7.5.3
More information about the U-Boot
mailing list