From b0104554156bec0335ea628428dc43cb23dd9f05 Mon Sep 17 00:00:00 2001 From: Christian Klarhorst Date: Mon, 29 Aug 2022 10:40:31 +0200 Subject: [PATCH 1/2] integration/builder Make bios console configurable --- litex/soc/integration/builder.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index 692bfd44c..de711012b 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -117,7 +117,6 @@ class Builder: # List software packages and libraries. self.software_packages = [] self.software_libraries = [] - for name in soc_software_packages: self.add_software_package(name) self.add_software_library(name) @@ -398,6 +397,7 @@ def builder_args(parser): builder_group.add_argument("--no-compile-software", action="store_true", help="Disable Software compilation only.") builder_group.add_argument("--no-compile-gateware", action="store_true", help="Disable Gateware compilation only.") builder_group.add_argument("--lto", action="store_true", help="Enable LTO (Link Time Optimization) for Software compilation.") + builder_group.add_argument("--bios-console", default=[], help="Select bios options.", choices=["TERM_NO_HIST", "TERM_MINI", "TERM_NO_COMPLETE"], nargs=1) builder_group.add_argument("--csr-csv", default=None, help="Write SoC mapping to the specified CSV file.") builder_group.add_argument("--csr-json", default=None, help="Write SoC mapping to the specified JSON file.") builder_group.add_argument("--csr-svd", default=None, help="Write SoC mapping to the specified SVD file.") @@ -415,6 +415,7 @@ def builder_argdict(args): "compile_software" : (not args.no_compile) and (not args.no_compile_software), "compile_gateware" : (not args.no_compile) and (not args.no_compile_gateware), "lto" : args.lto, + "bios_options" : args.bios_console, "csr_csv" : args.csr_csv, "csr_json" : args.csr_json, "csr_svd" : args.csr_svd, From 9e4df3c1d2c3205bcff3a549ee8f2b85140f23da Mon Sep 17 00:00:00 2001 From: Christian Klarhorst Date: Mon, 29 Aug 2022 10:55:39 +0200 Subject: [PATCH 2/2] integration/builder Add no bios console option This allows to deactivate the cmd_handlers and the serial parsing code to reduce the bios size. --- litex/soc/integration/builder.py | 4 ++-- litex/soc/software/bios/Makefile | 4 ++++ litex/soc/software/bios/command.h | 27 +++++++++++++++------------ litex/soc/software/bios/main.c | 6 ++++++ 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index de711012b..ae3bc58e3 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -163,7 +163,7 @@ class Builder: # Define Compile/BIOS Options. define("LTO", f"{self.lto:d}") for bios_option in self.bios_options: - assert bios_option in ["TERM_NO_HIST", "TERM_MINI", "TERM_NO_COMPLETE"] + assert bios_option in ["TERM_NO_HIST", "TERM_MINI", "TERM_NO_COMPLETE", "NO_TERM"] define(bios_option, "1") return "\n".join(variables_contents) @@ -397,7 +397,7 @@ def builder_args(parser): builder_group.add_argument("--no-compile-software", action="store_true", help="Disable Software compilation only.") builder_group.add_argument("--no-compile-gateware", action="store_true", help="Disable Gateware compilation only.") builder_group.add_argument("--lto", action="store_true", help="Enable LTO (Link Time Optimization) for Software compilation.") - builder_group.add_argument("--bios-console", default=[], help="Select bios options.", choices=["TERM_NO_HIST", "TERM_MINI", "TERM_NO_COMPLETE"], nargs=1) + builder_group.add_argument("--bios-console", default=[], help="Select bios options.", choices=["TERM_NO_HIST", "TERM_MINI", "TERM_NO_COMPLETE", "NO_TERM"], nargs=1) builder_group.add_argument("--csr-csv", default=None, help="Write SoC mapping to the specified CSV file.") builder_group.add_argument("--csr-json", default=None, help="Write SoC mapping to the specified JSON file.") builder_group.add_argument("--csr-svd", default=None, help="Write SoC mapping to the specified SVD file.") diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index 3dd797933..729b2b51f 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -31,6 +31,10 @@ ifdef TERM_NO_HIST CFLAGS += -DTERM_NO_HIST endif +ifdef NO_TERM +CFLAGS += -DNO_TERM +endif + ifdef TERM_MINI CFLAGS += -DTERM_MINI OBJECTS += readline_simple.o diff --git a/litex/soc/software/bios/command.h b/litex/soc/software/bios/command.h index 5124d24c8..effcb83d9 100644 --- a/litex/soc/software/bios/command.h +++ b/litex/soc/software/bios/command.h @@ -32,17 +32,20 @@ struct command_struct { extern struct command_struct *const __bios_cmd_start[]; extern struct command_struct *const __bios_cmd_end[]; -#define define_command(cmd_name, handler, help_txt, group_id) \ - struct command_struct s_##cmd_name = { \ - .func = (cmd_handler)handler, \ - .name = #cmd_name, \ - .help = help_txt, \ - .group = group_id, \ - }; \ - const struct command_struct *__bios_cmd_##cmd_name __attribute__((__used__)) \ - __attribute__((__section__(".bios_cmd"))) = &s_##cmd_name +#ifdef NO_TERM + #define define_command(cmd_name, handler, help_txt, group_id) +#else + #define define_command(cmd_name, handler, help_txt, group_id) \ + struct command_struct s_##cmd_name = { \ + .func = (cmd_handler)handler, \ + .name = #cmd_name, \ + .help = help_txt, \ + .group = group_id, \ + }; \ + const struct command_struct *__bios_cmd_##cmd_name __attribute__((__used__)) \ + __attribute__((__section__(".bios_cmd"))) = &s_##cmd_name + struct command_struct *command_dispatcher(char *command, int nb_params, char **params); -struct command_struct *command_dispatcher(char *command, int nb_params, char **params); - -#endif + #endif +#endif \ No newline at end of file diff --git a/litex/soc/software/bios/main.c b/litex/soc/software/bios/main.c index d92694b9b..6da53fea9 100644 --- a/litex/soc/software/bios/main.c +++ b/litex/soc/software/bios/main.c @@ -80,11 +80,13 @@ static void boot_sequence(void) __attribute__((__used__)) int main(int i, char **c) { +#ifndef NO_TERM char buffer[CMD_LINE_BUFFER_SIZE]; char *params[MAX_PARAM]; char *command; struct command_struct *cmd; int nb_params; +#endif int sdr_ok; #ifdef CONFIG_CPU_HAS_INTERRUPT @@ -206,6 +208,9 @@ __attribute__((__used__)) int main(int i, char **c) } #endif +#ifdef NO_TERM + printf("--============= \e[1mBuild without Console!\e[0m ================--\n"); +#else /* Console */ printf("--============= \e[1mConsole\e[0m ================--\n"); #if !defined(TERM_MINI) && !defined(TERM_NO_HIST) @@ -223,5 +228,6 @@ __attribute__((__used__)) int main(int i, char **c) } printf("\n%s", PROMPT); } +#endif return 0; }