Skip to content

Commit

Permalink
integration/builder: Add bios_format/--bios-format support to allow s…
Browse files Browse the repository at this point in the history
…electing printf format and pass it to picolibc.

Useful to printf of float/double is required.
  • Loading branch information
enjoy-digital committed Nov 16, 2023
1 parent 6d9cacd commit aa8e9dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions litex/soc/integration/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def __init__(self, soc,

# BIOS.
bios_lto = False,
bios_format = "integer",
bios_console = "full",

# Documentation.
Expand Down Expand Up @@ -113,6 +114,7 @@ def __init__(self, soc,

# BIOS.
self.bios_lto = bios_lto
self.bios_format = bios_format
self.bios_console = bios_console

# Documentation.
Expand Down Expand Up @@ -159,6 +161,7 @@ def define(k, v):

define("SOC_DIRECTORY", soc_directory)
define("PICOLIBC_DIRECTORY", picolibc_directory)
define("PICOLIBC_FORMAT", self.bios_format)
define("COMPILER_RT_DIRECTORY", compiler_rt_directory)
variables_contents.append("export BUILDINC_DIRECTORY")
define("BUILDINC_DIRECTORY", self.include_dir)
Expand Down Expand Up @@ -406,6 +409,7 @@ def builder_args(parser):
builder_group.add_argument("--doc", action="store_true", help="Generate SoC Documentation.")
bios_group = parser.add_argument_group(title="BIOS options") # FIXME: Move?
bios_group.add_argument("--bios-lto", action="store_true", help="Enable BIOS LTO (Link Time Optimization) compilation.")
bios_group.add_argument("--bios-format", default="integer", help="Select BIOS printf format.", choices=["integer", "float", "double"])
bios_group.add_argument("--bios-console", default="full" , help="Select BIOS console config.", choices=["full", "no-history", "no-autocomplete", "lite", "disable"])

def builder_argdict(args):
Expand All @@ -424,5 +428,6 @@ def builder_argdict(args):
"memory_x" : args.memory_x,
"generate_doc" : args.doc,
"bios_lto" : args.bios_lto,
"bios_format" : args.bios_format,
"bios_console" : args.bios_console,
}
2 changes: 1 addition & 1 deletion litex/soc/software/libc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ __libc.a: cross.txt
-Datomic-ungetc=false \
-Dthread-local-storage=false \
-Dio-long-long=true \
-Dformat-default=integer \
-Dformat-default=$(PICOLIBC_FORMAT) \
-Dincludedir=picolibc/$(TRIPLE)/include \
-Dlibdir=picolibc/$(TRIPLE)/lib \
--cross-file cross.txt
Expand Down

0 comments on commit aa8e9dc

Please sign in to comment.