Commit c118ac41 authored by Alessandro Rubini's avatar Alessandro Rubini

shell: add "config" command.

This command can return the .config file to the user. It can be useful
to trace what is actually running, as addition to the "ver"
command.  It is optional because it costs .5kB of binary size.

Example:

  wrc# config
    Current WRPC-SW configuration:
  CONFIG_RAMSIZE=90112
  # CONFIG_PTP_NOPOSIX is not set
  CONFIG_PPSI=y
  # CONFIG_CHECK_RESET is not set
  CONFIG_PPSI_VERBOSITY=0
  CONFIG_PPSI_RUNTIME_VERBOSITY=y
  CONFIG_STACKSIZE=2048
  CONFIG_PP_PRINTF=y
  # CONFIG_PRINTF_FULL is not set
  CONFIG_PRINTF_XINT=y
  # CONFIG_PRINTF_MINI is not set
  # CONFIG_PRINTF_NONE is not set
  CONFIG_PRINT_BUFSIZE=128
  CONFIG_ETHERBONE=y
  # CONFIG_DETERMINISTIC_BINARY is not set
  CONFIG_CMD_CONFIG=y

(This configuration amounts to a binary size of 86252 bytes, at this
commit).
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 78e9e68d
......@@ -130,4 +130,9 @@ config DETERMINISTIC_BINARY
If in doubt, say No.
config CMD_CONFIG
boolean "Include configuration in the output binary"
help
This options adds the "config" command to the shell, which
reports the current configuration. This adds half a kilobyte
to the binary size (100b for the code plus the .config file).
......@@ -120,15 +120,22 @@ $(PPSI)/ppsi.o:
$(MAKE) -C $(PPSI) ARCH=spec PROTO_EXT=whiterabbit \
CROSS_COMPILE=$(CROSS_COMPILE) CONFIG_NO_PRINTF=y
$(OUTPUT).elf: $(LDS) $(AUTOCONF) gitmodules $(OUTPUT).o
$(OUTPUT).elf: $(LDS) $(AUTOCONF) gitmodules $(OUTPUT).o config.o
$(CC) $(CFLAGS) -DGIT_REVISION=\"$(REVISION)\" -c revision.c
${CC} -o $@ revision.o $(OUTPUT).o $(LDFLAGS)
${CC} -o $@ revision.o config.o $(OUTPUT).o $(LDFLAGS)
${OBJDUMP} -d $(OUTPUT).elf > $(OUTPUT)_disasm.S
$(SIZE) $@
$(OUTPUT).o: $(OBJS)
$(LD) --gc-sections -e _start -r $(OBJS) -T bigobj.lds -o $@
config.o: .config
sed '1,3d' .config > .config.bin
dd bs=1 count=1 if=/dev/zero 2> /dev/null >> .config.bin
$(OBJCOPY) -I binary -O elf32-lm32 -B lm32 \
--rename-section .data=.data.config .config.bin $@
rm -f .config.bin
%.bin: %.elf
${OBJCOPY} -O binary $^ $@
......
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2012 CERN (www.cern.ch)
* Author: Alessandro Rubini <rubini@gnudd.com>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <stdlib.h>
#include <string.h>
#include <wrc.h>
#include <shell.h>
extern char _binary__config_bin_start[];
static int cmd_config(const char *args[])
{
pp_printf(" Current WRPC-SW configuration:\n");
puts(_binary__config_bin_start);
return 0;
}
DEFINE_WRC_COMMAND(config) = {
.name = "config",
.exec = cmd_config,
};
......@@ -15,5 +15,6 @@ obj-y += \
shell/cmd_ptrack.o \
shell/cmd_help.o
obj-$(CONFIG_ETHERBONE) += shell/cmd_ip.o
obj-$(CONFIG_PPSI_RUNTIME_VERBOSITY) += shell/cmd_verbose.o
obj-$(CONFIG_ETHERBONE) += shell/cmd_ip.o
obj-$(CONFIG_PPSI_RUNTIME_VERBOSITY) += shell/cmd_verbose.o
obj-$(CONFIG_CMD_CONFIG) += shell/cmd_config.o
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment