diff --git a/litex/soc/software/common.mak b/litex/soc/software/common.mak index 6d8486b5a..a2d90b96d 100644 --- a/litex/soc/software/common.mak +++ b/litex/soc/software/common.mak @@ -52,11 +52,10 @@ INCLUDES = -I$(PICOLIBC_DIRECTORY)/newlib/libc/tinystdio \ -I$(BUILDINC_DIRECTORY) \ -I$(BUILDINC_DIRECTORY)/../libc \ -I$(CPU_DIRECTORY) -PICOLIBC_SPECS = --specs=$(BUILDINC_DIRECTORY)/../libc/picolibc.specs -DPICOLIBC_INTEGER_PRINTF_SCANF COMMONFLAGS = $(DEPFLAGS) -Os $(CPUFLAGS) -g3 -fomit-frame-pointer -Wall -fno-builtin -fno-stack-protector -flto $(INCLUDES) CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes CXXFLAGS = $(COMMONFLAGS) -std=c++11 -I$(SOC_DIRECTORY)/software/include/basec++ -fexceptions -fno-rtti -ffreestanding -LDFLAGS = -nostdlib -nodefaultlibs -Wl,--no-dynamic-linker -Wl,--build-id=none $(CFLAGS) -L$(BUILDINC_DIRECTORY) $(PICOLIBC_SPECS) +LDFLAGS = -nostdlib -nodefaultlibs -Wl,--no-dynamic-linker -Wl,--build-id=none $(CFLAGS) -L$(BUILDINC_DIRECTORY) define compilexx $(CX) -c $(CXXFLAGS) $(1) $< -o $@ diff --git a/litex/soc/software/libc/Makefile b/litex/soc/software/libc/Makefile index 9cfdfee97..62982ea15 100644 --- a/litex/soc/software/libc/Makefile +++ b/litex/soc/software/libc/Makefile @@ -1,7 +1,7 @@ include ../include/generated/variables.mak include $(SOC_DIRECTORY)/software/common.mak -all: libc.a iob.c.o missing.c.o +all: libc.a stdio.c.o missing.c.o CPUFAMILY= @@ -53,6 +53,7 @@ libc.a: cross.txt -Dpicocrt=false \ -Dthread-local-storage=false \ -Dio-long-long=true \ + -Dformat-default=integer \ -Dincludedir=picolibc/$(TRIPLE)/include \ -Dlibdir=picolibc/$(TRIPLE)/lib \ --cross-file cross.txt @@ -60,7 +61,7 @@ libc.a: cross.txt meson compile cp newlib/libc.a libc.a -iob.c.o: $(LIBC_DIRECTORY)/iob.c +stdio.c.o: $(LIBC_DIRECTORY)/stdio.c $(compile) $(AR) csr libc.a $@ diff --git a/litex/soc/software/libc/iob.c b/litex/soc/software/libc/stdio.c similarity index 87% rename from litex/soc/software/libc/iob.c rename to litex/soc/software/libc/stdio.c index bf05cd16f..dcf4f5f23 100644 --- a/litex/soc/software/libc/iob.c +++ b/litex/soc/software/libc/stdio.c @@ -1,7 +1,7 @@ /* Most of the code here is ported from console.c * with slightly changed function signatures and - * names. Picolibc requires providing __iob array - * which contains stdin, stdout and stderr files. + * names. It sets up for stdin, stdout and + * stderr files. * To simpify things, we can create one file * which can be both read from and written to, * and assign it to all three of them. @@ -10,8 +10,8 @@ * provide stderr for example which could be non- * blocking for example. * - * For more information on __iob and how to create - * it look into picolibc/doc/os.md. + * For more information on usage and how to create + * those files look into picolibc/doc/os.md. */ #include @@ -96,5 +96,7 @@ int readchar_nonblock(void) static FILE __stdio = FDEV_SETUP_STREAM(dummy_putc, dummy_getc, NULL, _FDEV_SETUP_RW); -FILE *const __iob[3] = { &__stdio, &__stdio, &__stdio }; +FILE *const stdout = &__stdio; +FILE *const stderr = &__stdio; +FILE *const stdin = &__stdio;