From 3f3cf502063c8bc7733147260cf71f43540176c0 Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Thu, 21 Feb 2019 14:26:02 +0100 Subject: commands: dmesg: add print raw parameter Add -r option to mimic functionality of linux dmesg. It will prefix log level and timestamp to each buffer: <6>[ 460us] barebox 2019.02.0-00266-g6aea757067-dirty #355 Thu Feb 21 11:51:43 CET 2019 <6>[ 6279us] Board: DPTechnics DPT-Module <6>[ 209281us] mdio_bus: miibus0: probed <6>[ 210184us] ag71xx-gmac 18070000.mac@19000000.of: network device registered <6>[ 216051us] m25p80 w25q128@00: w25q128 (16384 Kbytes) <6>[ 219913us] netconsole: registered as netconsole-1 <6>[ 223312us] malloc space: 0x80c00000 -> 0x80ffffff (size 4 MiB) <6>[ 228255us] eth0: got preset MAC address: c4:93:00:00:ae:89 <6>[ 246363us] running /env/bin/init... Signed-off-by: Oleksij Rempel Signed-off-by: Sascha Hauer --- common/console_common.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common') diff --git a/common/console_common.c b/common/console_common.c index 0131a1190a..bc3a305b27 100644 --- a/common/console_common.c +++ b/common/console_common.c @@ -202,6 +202,9 @@ void log_print(unsigned flags) uint64_t diff = log->timestamp - time_beginning; unsigned long difful; + if (flags & (BAREBOX_LOG_PRINT_RAW)) + printf("<%i>", log->level); + do_div(diff, 1000); difful = diff; -- cgit v1.2.3 From 34b9ee02ae460f4283f6096db308d5e7f8f36d45 Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Thu, 21 Feb 2019 14:26:03 +0100 Subject: commands: dmesg: add -l option to restrict output level Same as linux dmesg, barebox dmesg will be able to restrict output level by using -l option. For example "dmesg -l err,warn" This functionality can be used for test automation. Signed-off-by: Oleksij Rempel Signed-off-by: Sascha Hauer --- commands/dmesg.c | 48 +++++++++++++++++++++++++++++++++++++++++++++--- common/console_common.c | 5 ++++- include/printk.h | 20 +++++++++++++++----- 3 files changed, 64 insertions(+), 9 deletions(-) (limited to 'common') diff --git a/commands/dmesg.c b/commands/dmesg.c index 5c2728581d..a7def2f158 100644 --- a/commands/dmesg.c +++ b/commands/dmesg.c @@ -24,13 +24,49 @@ #include #include +static unsigned dmesg_get_levels(const char *__args) +{ + char *args = xstrdup(__args); + char *str, *levels = args; + unsigned flags = 0; + + while (1) { + str = strsep(&levels, ","); + if (!str) + break; + + if(!strcmp(str, "vdebug")) + flags |= BAREBOX_LOG_PRINT_VDEBUG; + else if(!strcmp(str, "debug")) + flags |= BAREBOX_LOG_PRINT_DEBUG; + else if(!strcmp(str, "info")) + flags |= BAREBOX_LOG_PRINT_INFO; + else if(!strcmp(str, "notice")) + flags |= BAREBOX_LOG_PRINT_NOTICE; + else if(!strcmp(str, "warn")) + flags |= BAREBOX_LOG_PRINT_WARNING; + else if(!strcmp(str, "err")) + flags |= BAREBOX_LOG_PRINT_ERR; + else if(!strcmp(str, "crit")) + flags |= BAREBOX_LOG_PRINT_CRIT; + else if(!strcmp(str, "alert")) + flags |= BAREBOX_LOG_PRINT_ALERT; + else if(!strcmp(str, "emerg")) + flags |= BAREBOX_LOG_PRINT_EMERG; + } + + free(args); + + return flags; +} + static int do_dmesg(int argc, char *argv[]) { int opt, i; int delete_buf = 0, emit = 0; - unsigned flags = 0; + unsigned flags = 0, levels = 0; - while ((opt = getopt(argc, argv, "ctder")) > 0) { + while ((opt = getopt(argc, argv, "ctderl:")) > 0) { switch (opt) { case 'c': delete_buf = 1; @@ -44,6 +80,11 @@ static int do_dmesg(int argc, char *argv[]) case 'e': emit = 1; break; + case 'l': + levels = dmesg_get_levels(optarg); + if (!levels) + return COMMAND_ERROR_USAGE; + break; case 'r': flags |= BAREBOX_LOG_PRINT_RAW | BAREBOX_LOG_PRINT_TIME; break; @@ -78,7 +119,7 @@ static int do_dmesg(int argc, char *argv[]) return 0; } - log_print(flags); + log_print(flags, levels); if (delete_buf) log_clean(10); @@ -91,6 +132,7 @@ BAREBOX_CMD_HELP_TEXT("Options:") BAREBOX_CMD_HELP_OPT ("-c", "Delete messages after printing them") BAREBOX_CMD_HELP_OPT ("-d", "Show a time delta to the last message") BAREBOX_CMD_HELP_OPT ("-e ", "Emit a log message") +BAREBOX_CMD_HELP_OPT ("-l ", "Restrict output to the given (comma-separated) list of levels") BAREBOX_CMD_HELP_OPT ("-r", "Print timestamp and log-level prefixes.") BAREBOX_CMD_HELP_OPT ("-t", "Show timestamp informations") BAREBOX_CMD_HELP_END diff --git a/common/console_common.c b/common/console_common.c index bc3a305b27..4aa54de97a 100644 --- a/common/console_common.c +++ b/common/console_common.c @@ -193,7 +193,7 @@ static int console_common_init(void) } device_initcall(console_common_init); -void log_print(unsigned flags) +void log_print(unsigned flags, unsigned levels) { struct log_entry *log; unsigned long last = 0; @@ -202,6 +202,9 @@ void log_print(unsigned flags) uint64_t diff = log->timestamp - time_beginning; unsigned long difful; + if (levels && !(levels & (1 << log->level))) + continue; + if (flags & (BAREBOX_LOG_PRINT_RAW)) printf("<%i>", log->level); diff --git a/include/printk.h b/include/printk.h index 64205b2880..b0d5d09f83 100644 --- a/include/printk.h +++ b/include/printk.h @@ -134,11 +134,21 @@ extern struct list_head barebox_logbuf; extern void log_clean(unsigned int limit); -#define BAREBOX_LOG_PRINT_TIME (1 << 0) -#define BAREBOX_LOG_DIFF_TIME (1 << 1) -#define BAREBOX_LOG_PRINT_RAW (1 << 2) - -void log_print(unsigned flags); +#define BAREBOX_LOG_PRINT_RAW BIT(2) +#define BAREBOX_LOG_DIFF_TIME BIT(1) +#define BAREBOX_LOG_PRINT_TIME BIT(0) + +#define BAREBOX_LOG_PRINT_VDEBUG BIT(8) +#define BAREBOX_LOG_PRINT_DEBUG BIT(7) +#define BAREBOX_LOG_PRINT_INFO BIT(6) +#define BAREBOX_LOG_PRINT_NOTICE BIT(5) +#define BAREBOX_LOG_PRINT_WARNING BIT(4) +#define BAREBOX_LOG_PRINT_ERR BIT(3) +#define BAREBOX_LOG_PRINT_CRIT BIT(2) +#define BAREBOX_LOG_PRINT_ALERT BIT(1) +#define BAREBOX_LOG_PRINT_EMERG BIT(0) + +void log_print(unsigned flags, unsigned levels); struct va_format { const char *fmt; -- cgit v1.2.3 From 1c0e8268ead48c1a94ab189dd0f2a5c03b1a9af3 Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Thu, 21 Feb 2019 14:55:48 +0100 Subject: common: console_common: do not store color additions to the log buffer it is needed for raw dmesg output Signed-off-by: Oleksij Rempel Signed-off-by: Sascha Hauer --- common/console_common.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'common') diff --git a/common/console_common.c b/common/console_common.c index 4aa54de97a..a4d2636753 100644 --- a/common/console_common.c +++ b/common/console_common.c @@ -79,6 +79,18 @@ void log_clean(unsigned int limit) } } +static void print_colored_log_level(const int level) +{ + if (!console_allow_color()) + return; + if (level >= ARRAY_SIZE(colored_log_level)) + return; + if (!colored_log_level[level]) + return; + + puts(colored_log_level[level]); +} + static void pr_puts(int level, const char *str) { struct log_entry *log; @@ -108,21 +120,10 @@ nolog: if (level > barebox_loglevel) return; + print_colored_log_level(level); puts(str); } -static void print_colored_log_level(const int level) -{ - if (!console_allow_color()) - return; - if (level >= ARRAY_SIZE(colored_log_level)) - return; - if (!colored_log_level[level]) - return; - - pr_puts(level, colored_log_level[level]); -} - int pr_print(int level, const char *fmt, ...) { va_list args; @@ -132,8 +133,6 @@ int pr_print(int level, const char *fmt, ...) if (!IS_ENABLED(CONFIG_LOGBUF) && level > barebox_loglevel) return 0; - print_colored_log_level(level); - va_start(args, fmt); i = vsprintf(printbuffer, fmt, args); va_end(args); @@ -152,8 +151,6 @@ int dev_printf(int level, const struct device_d *dev, const char *format, ...) if (!IS_ENABLED(CONFIG_LOGBUF) && level > barebox_loglevel) return 0; - print_colored_log_level(level); - if (dev->driver && dev->driver->name) ret += sprintf(printbuffer, "%s ", dev->driver->name); @@ -205,7 +202,11 @@ void log_print(unsigned flags, unsigned levels) if (levels && !(levels & (1 << log->level))) continue; - if (flags & (BAREBOX_LOG_PRINT_RAW)) + if (!(flags & (BAREBOX_LOG_PRINT_RAW | BAREBOX_LOG_PRINT_TIME + | BAREBOX_LOG_DIFF_TIME))) + print_colored_log_level(log->level); + + if (flags & BAREBOX_LOG_PRINT_RAW) printf("<%i>", log->level); do_div(diff, 1000); -- cgit v1.2.3 From 9e72ea7a006cd0931913dd958746963961479a4a Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Tue, 19 Feb 2019 13:10:17 +0100 Subject: images: pbl: verify CONFIG_BAREBOX_MAX_IMAGE_SIZE is not exceeded For platforms such as the at91, the boot ROM imposes an upper limit on barebox file size. Prior to 5a1a5ed253 ("ARM: images: use piggydata"), BAREBOX_MAX_PBLX_SIZE seems to have been the way to go for limiting the size of the final barebox binary when using the PBL. With pblx removed, this variable is of no use, so have the existing BAREBOX_MAX_IMAGE_SIZE replace its functionality. Currently BAREBOX_MAX_IMAGE_SIZE is only checked against in the non-PBL case, so add a check in the PBL case as well. Signed-off-by: Ahmad Fatoum Signed-off-by: Sascha Hauer --- arch/arm/configs/am335x_mlo_defconfig | 2 +- common/Kconfig | 10 ---------- images/Makefile | 1 + 3 files changed, 2 insertions(+), 11 deletions(-) (limited to 'common') diff --git a/arch/arm/configs/am335x_mlo_defconfig b/arch/arm/configs/am335x_mlo_defconfig index b58b71a859..d6909154c4 100644 --- a/arch/arm/configs/am335x_mlo_defconfig +++ b/arch/arm/configs/am335x_mlo_defconfig @@ -8,7 +8,7 @@ CONFIG_MACH_PHYTEC_SOM_AM335X=y CONFIG_THUMB2_BAREBOX=y # CONFIG_MEMINFO is not set CONFIG_MMU=y -CONFIG_BAREBOX_MAX_PBLX_SIZE=0x1b400 +CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x1b400 CONFIG_MALLOC_SIZE=0x0 CONFIG_MALLOC_TLSF=y CONFIG_RELOCATABLE=y diff --git a/common/Kconfig b/common/Kconfig index 21b33f06f7..42769333fe 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -245,16 +245,6 @@ config BAREBOX_MAX_BARE_INIT_SIZE this will allow your bare_init to fit in SRAM as example ARCH can overwrite it via ARCH_BAREBOX_MAX_BARE_INIT_SIZE -config BAREBOX_MAX_PBLX_SIZE - depends on PBL_MULTI_IMAGES - depends on IMAGE_COMPRESSION - prompt "Maximum PBLX size" - hex - default 0xffffffff - help - Define the maximum size of the PBLX image. - The pblx is a self extracting barebox binary. - config HAVE_CONFIGURABLE_MEMORY_LAYOUT bool diff --git a/images/Makefile b/images/Makefile index 4e82dc92ee..59b81f9b6d 100644 --- a/images/Makefile +++ b/images/Makefile @@ -66,6 +66,7 @@ $(obj)/%.pbl: $(pbl-lds) $(barebox-pbl-common) $(obj)/piggy.o FORCE $(obj)/%.pblb: $(obj)/%.pbl FORCE $(call if_changed,objcopy_bin,$(*F)) + $(call cmd,check_file_size,$@,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE)) $(obj)/%.s: $(obj)/% FORCE $(call if_changed,disasm) -- cgit v1.2.3 From 4902e6c5e3be35f5653b304f4b578026473c91a3 Mon Sep 17 00:00:00 2001 From: Tomaz Solc Date: Tue, 5 Mar 2019 09:57:52 +0100 Subject: common: Kconfig: improve help text for DEBUG_LL This adopts the help text used in Linux for the same setting. It clarifies that a build with DEBUG_LL enabled will only work on the system you chose the debug UART for. Signed-off-by: Sascha Hauer --- common/Kconfig | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/Kconfig b/common/Kconfig index 42769333fe..53052c9cc1 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -1006,11 +1006,21 @@ config DEBUG_INFO config DEBUG_LL bool depends on HAS_DEBUG_LL - prompt "low level debug messages" + prompt "Low level debug messages (read help)" help - Enable this to get low level debug messages during barebox initialization. - This requires SoC specific support. Most SoCs require the debug UART to be - initialized by a debugger or first stage bootloader. + Enable this to get low level debug messages during barebox + initialization. This is helpful if you are debugging code that + executes before the console is initialized. + + This requires SoC specific support. Most SoCs require the + debug UART to be initialized by a debugger or first stage + bootloader. + + Note that selecting this option will limit barebox to a single + UART definition, as specified below under "low-level debugging + port". Attempting to boot the resulting image on a different + platform *will not work*, so this option should not be enabled + for builds that are intended to be portable. choice prompt "Kernel low-level debugging port" -- cgit v1.2.3