From 3d32ac3d2e5f0774513367770e5f78557f286d21 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 27 Sep 2021 15:03:07 +0200 Subject: [PATCH] software: Avoid libase renaming to libutils/libcomm and keep readchar/putsnonl retro-compatibility. We'll maybe do it but that's probably not the right time. We have to make the picolibc switch as smooth as possible for users (and so avoid update as much as possible). In the long term, it would be good to provide a LiteX C SDK, so we'll make eventual changes when doing this. --- litex/soc/integration/builder.py | 3 +-- litex/soc/software/bios/boot.c | 10 ++++---- litex/soc/software/bios/cmds/cmd_bios.c | 2 +- litex/soc/software/bios/cmds/cmd_i2c.c | 2 +- litex/soc/software/bios/cmds/cmd_litedram.c | 4 ++-- litex/soc/software/bios/cmds/cmd_mem.c | 2 +- litex/soc/software/bios/helpers.c | 4 ++-- litex/soc/software/bios/isr.c | 2 +- litex/soc/software/bios/main.c | 8 +++---- litex/soc/software/common.mak | 1 + litex/soc/software/demo/demo.py | 4 +--- litex/soc/software/demo/donut.c | 2 +- litex/soc/software/demo/isr.c | 2 +- litex/soc/software/demo/main.c | 4 ++-- .../software/{libutils => libbase}/Makefile | 15 +++++++----- .../software/{libutils => libbase}/console.h | 3 +++ .../soc/software/{libutils => libbase}/crc.h | 0 .../software/{libutils => libbase}/crc16.c | 0 .../software/{libutils => libbase}/crc32.c | 0 litex/soc/software/{libcomm => libbase}/i2c.c | 0 litex/soc/software/{libcomm => libbase}/i2c.h | 0 .../soc/software/{libutils => libbase}/jsmn.h | 0 .../soc/software/{libutils => libbase}/lfsr.h | 0 .../software/{libutils => libbase}/memtest.c | 0 .../software/{libutils => libbase}/memtest.h | 0 .../software/{libutils => libbase}/progress.c | 0 .../software/{libutils => libbase}/progress.h | 0 .../software/{libcomm => libbase}/spiflash.c | 0 .../software/{libcomm => libbase}/spiflash.h | 0 .../software/{libutils => libbase}/system.c | 0 .../soc/software/{libcomm => libbase}/uart.c | 0 .../soc/software/{libcomm => libbase}/uart.h | 0 litex/soc/software/libc/or1k/exception.c | 2 +- litex/soc/software/libc/stdio.c | 4 ++-- litex/soc/software/libcomm/Makefile | 24 ------------------- litex/soc/software/liblitedram/sdram.c | 4 ++-- litex/soc/software/libliteeth/tftp.c | 2 +- litex/soc/software/libliteeth/udp.c | 2 +- litex/soc/software/liblitespi/spiflash.c | 4 ++-- 39 files changed, 45 insertions(+), 65 deletions(-) mode change 100644 => 100755 litex/soc/software/demo/demo.py rename litex/soc/software/{libutils => libbase}/Makefile (63%) rename litex/soc/software/{libutils => libbase}/console.h (87%) rename litex/soc/software/{libutils => libbase}/crc.h (100%) rename litex/soc/software/{libutils => libbase}/crc16.c (100%) rename litex/soc/software/{libutils => libbase}/crc32.c (100%) rename litex/soc/software/{libcomm => libbase}/i2c.c (100%) rename litex/soc/software/{libcomm => libbase}/i2c.h (100%) rename litex/soc/software/{libutils => libbase}/jsmn.h (100%) rename litex/soc/software/{libutils => libbase}/lfsr.h (100%) rename litex/soc/software/{libutils => libbase}/memtest.c (100%) rename litex/soc/software/{libutils => libbase}/memtest.h (100%) rename litex/soc/software/{libutils => libbase}/progress.c (100%) rename litex/soc/software/{libutils => libbase}/progress.h (100%) rename litex/soc/software/{libcomm => libbase}/spiflash.c (100%) rename litex/soc/software/{libcomm => libbase}/spiflash.h (100%) rename litex/soc/software/{libutils => libbase}/system.c (100%) rename litex/soc/software/{libcomm => libbase}/uart.c (100%) rename litex/soc/software/{libcomm => libbase}/uart.h (100%) delete mode 100755 litex/soc/software/libcomm/Makefile diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index 94be6ddeb..e1c099e81 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -43,8 +43,7 @@ soc_software_packages = [ "libcompiler_rt", # LiteX cores. - "libutils", - "libcomm", + "libbase", # LiteX Ecosystem cores. "libfatfs", diff --git a/litex/soc/software/bios/boot.c b/litex/soc/software/bios/boot.c index b40a910c0..d802a1abc 100644 --- a/litex/soc/software/bios/boot.c +++ b/litex/soc/software/bios/boot.c @@ -21,12 +21,12 @@ #include "sfl.h" #include "boot.h" -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/litex/soc/software/bios/cmds/cmd_bios.c b/litex/soc/software/bios/cmds/cmd_bios.c index fead02fd1..1cd290f7b 100644 --- a/litex/soc/software/bios/cmds/cmd_bios.c +++ b/litex/soc/software/bios/cmds/cmd_bios.c @@ -4,7 +4,7 @@ #include #include -#include +#include #include diff --git a/litex/soc/software/bios/cmds/cmd_i2c.c b/litex/soc/software/bios/cmds/cmd_i2c.c index 8a934f31d..37c454c0f 100644 --- a/litex/soc/software/bios/cmds/cmd_i2c.c +++ b/litex/soc/software/bios/cmds/cmd_i2c.c @@ -5,7 +5,7 @@ #include #include -#include +#include #include "../command.h" #include "../helpers.h" diff --git a/litex/soc/software/bios/cmds/cmd_litedram.c b/litex/soc/software/bios/cmds/cmd_litedram.c index 3e6746ded..b955a0d98 100644 --- a/litex/soc/software/bios/cmds/cmd_litedram.c +++ b/litex/soc/software/bios/cmds/cmd_litedram.c @@ -4,11 +4,11 @@ #include #include #include -#include +#include #include #include -#include +#include #include #include diff --git a/litex/soc/software/bios/cmds/cmd_mem.c b/litex/soc/software/bios/cmds/cmd_mem.c index c1adffb5e..d2bb04fff 100644 --- a/litex/soc/software/bios/cmds/cmd_mem.c +++ b/litex/soc/software/bios/cmds/cmd_mem.c @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include diff --git a/litex/soc/software/bios/helpers.c b/litex/soc/software/bios/helpers.c index c5387e1c6..0f8e9bfab 100644 --- a/litex/soc/software/bios/helpers.c +++ b/litex/soc/software/bios/helpers.c @@ -5,8 +5,8 @@ #include #include -#include -#include +#include +#include #include "readline.h" #include "helpers.h" diff --git a/litex/soc/software/bios/isr.c b/litex/soc/software/bios/isr.c index 77bf6c8a2..a38c29422 100644 --- a/litex/soc/software/bios/isr.c +++ b/litex/soc/software/bios/isr.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #if defined(__microwatt__) diff --git a/litex/soc/software/bios/main.c b/litex/soc/software/bios/main.c index 0bcb27f4f..542b42d85 100644 --- a/litex/soc/software/bios/main.c +++ b/litex/soc/software/bios/main.c @@ -31,11 +31,11 @@ #include #include -#include -#include +#include +#include -#include -#include +#include +#include #include diff --git a/litex/soc/software/common.mak b/litex/soc/software/common.mak index a2d90b96d..fb9735434 100644 --- a/litex/soc/software/common.mak +++ b/litex/soc/software/common.mak @@ -47,6 +47,7 @@ DEPFLAGS += -MD -MP # INCLUDES = -I$(PICOLIBC_DIRECTORY)/newlib/libc/tinystdio \ -I$(PICOLIBC_DIRECTORY)/newlib/libc/include \ + -I$(LIBBASE_DIRECTORY) \ -I$(SOC_DIRECTORY)/software/include \ -I$(SOC_DIRECTORY)/software \ -I$(BUILDINC_DIRECTORY) \ diff --git a/litex/soc/software/demo/demo.py b/litex/soc/software/demo/demo.py old mode 100644 new mode 100755 index 6f94d4c32..5ad4ee8c3 --- a/litex/soc/software/demo/demo.py +++ b/litex/soc/software/demo/demo.py @@ -8,7 +8,6 @@ import os import argparse -from distutils.dir_util import copy_tree def main(): parser = argparse.ArgumentParser(description="LiteX Bare Metal Demo App.") @@ -20,8 +19,7 @@ def main(): os.makedirs("demo", exist_ok=True) # Copy contents to demo directory - src = os.path.abspath(os.path.dirname(__file__)) - copy_tree(src, "demo") + os.system(f"cp {os.path.abspath(os.path.dirname(__file__))}/* demo") # Compile demo build_path = args.build_path if os.path.isabs(args.build_path) else os.path.join("..", args.build_path) diff --git a/litex/soc/software/demo/donut.c b/litex/soc/software/demo/donut.c index 0e0b73a84..0aab4177e 100644 --- a/litex/soc/software/demo/donut.c +++ b/litex/soc/software/demo/donut.c @@ -9,7 +9,7 @@ #include #include -#include +#include #define R(mul,shift,x,y) \ _=x; \ diff --git a/litex/soc/software/demo/isr.c b/litex/soc/software/demo/isr.c index 97f0fc9df..797663181 100644 --- a/litex/soc/software/demo/isr.c +++ b/litex/soc/software/demo/isr.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include void isr(void); diff --git a/litex/soc/software/demo/main.c b/litex/soc/software/demo/main.c index 5581ed667..38c451fa6 100644 --- a/litex/soc/software/demo/main.c +++ b/litex/soc/software/demo/main.c @@ -6,8 +6,8 @@ #include #include -#include -#include +#include +#include #include /*-----------------------------------------------------------------------*/ diff --git a/litex/soc/software/libutils/Makefile b/litex/soc/software/libbase/Makefile similarity index 63% rename from litex/soc/software/libutils/Makefile rename to litex/soc/software/libbase/Makefile index 7dc3dbc8d..4cfa62e93 100755 --- a/litex/soc/software/libutils/Makefile +++ b/litex/soc/software/libbase/Makefile @@ -6,21 +6,24 @@ OBJECTS = \ crc32.o \ system.o \ progress.o \ - memtest.o + memtest.o \ + uart.o \ + spiflash.o \ + i2c.o -all: libutils.a +all: libbase.a -libutils.a: $(OBJECTS) - $(AR) crs libutils.a $(OBJECTS) +libbase.a: $(OBJECTS) + $(AR) crs libbase.a $(OBJECTS) # pull in dependency info for *existing* .o files -include $(OBJECTS:.o=.d) -%.o: $(LIBUTILS_DIRECTORY)/%.c +%.o: $(LIBBASE_DIRECTORY)/%.c $(compile) .PHONY: all clean clean: $(RM) $(OBJECTS) - $(RM) libutils.a .*~ *~ + $(RM) libbase.a .*~ *~ diff --git a/litex/soc/software/libutils/console.h b/litex/soc/software/libbase/console.h similarity index 87% rename from litex/soc/software/libutils/console.h rename to litex/soc/software/libbase/console.h index cd6c9c005..8776baf05 100644 --- a/litex/soc/software/libutils/console.h +++ b/litex/soc/software/libbase/console.h @@ -12,6 +12,9 @@ typedef int (*console_read_nonblock_hook)(void); void console_set_write_hook(console_write_hook h); void console_set_read_hook(console_read_hook r, console_read_nonblock_hook rn); +#define readchar getchar +#define putsnonl(X) fputs(X, stdout) + int readchar_nonblock(void); #ifdef __cplusplus diff --git a/litex/soc/software/libutils/crc.h b/litex/soc/software/libbase/crc.h similarity index 100% rename from litex/soc/software/libutils/crc.h rename to litex/soc/software/libbase/crc.h diff --git a/litex/soc/software/libutils/crc16.c b/litex/soc/software/libbase/crc16.c similarity index 100% rename from litex/soc/software/libutils/crc16.c rename to litex/soc/software/libbase/crc16.c diff --git a/litex/soc/software/libutils/crc32.c b/litex/soc/software/libbase/crc32.c similarity index 100% rename from litex/soc/software/libutils/crc32.c rename to litex/soc/software/libbase/crc32.c diff --git a/litex/soc/software/libcomm/i2c.c b/litex/soc/software/libbase/i2c.c similarity index 100% rename from litex/soc/software/libcomm/i2c.c rename to litex/soc/software/libbase/i2c.c diff --git a/litex/soc/software/libcomm/i2c.h b/litex/soc/software/libbase/i2c.h similarity index 100% rename from litex/soc/software/libcomm/i2c.h rename to litex/soc/software/libbase/i2c.h diff --git a/litex/soc/software/libutils/jsmn.h b/litex/soc/software/libbase/jsmn.h similarity index 100% rename from litex/soc/software/libutils/jsmn.h rename to litex/soc/software/libbase/jsmn.h diff --git a/litex/soc/software/libutils/lfsr.h b/litex/soc/software/libbase/lfsr.h similarity index 100% rename from litex/soc/software/libutils/lfsr.h rename to litex/soc/software/libbase/lfsr.h diff --git a/litex/soc/software/libutils/memtest.c b/litex/soc/software/libbase/memtest.c similarity index 100% rename from litex/soc/software/libutils/memtest.c rename to litex/soc/software/libbase/memtest.c diff --git a/litex/soc/software/libutils/memtest.h b/litex/soc/software/libbase/memtest.h similarity index 100% rename from litex/soc/software/libutils/memtest.h rename to litex/soc/software/libbase/memtest.h diff --git a/litex/soc/software/libutils/progress.c b/litex/soc/software/libbase/progress.c similarity index 100% rename from litex/soc/software/libutils/progress.c rename to litex/soc/software/libbase/progress.c diff --git a/litex/soc/software/libutils/progress.h b/litex/soc/software/libbase/progress.h similarity index 100% rename from litex/soc/software/libutils/progress.h rename to litex/soc/software/libbase/progress.h diff --git a/litex/soc/software/libcomm/spiflash.c b/litex/soc/software/libbase/spiflash.c similarity index 100% rename from litex/soc/software/libcomm/spiflash.c rename to litex/soc/software/libbase/spiflash.c diff --git a/litex/soc/software/libcomm/spiflash.h b/litex/soc/software/libbase/spiflash.h similarity index 100% rename from litex/soc/software/libcomm/spiflash.h rename to litex/soc/software/libbase/spiflash.h diff --git a/litex/soc/software/libutils/system.c b/litex/soc/software/libbase/system.c similarity index 100% rename from litex/soc/software/libutils/system.c rename to litex/soc/software/libbase/system.c diff --git a/litex/soc/software/libcomm/uart.c b/litex/soc/software/libbase/uart.c similarity index 100% rename from litex/soc/software/libcomm/uart.c rename to litex/soc/software/libbase/uart.c diff --git a/litex/soc/software/libcomm/uart.h b/litex/soc/software/libbase/uart.h similarity index 100% rename from litex/soc/software/libcomm/uart.h rename to litex/soc/software/libbase/uart.h diff --git a/litex/soc/software/libc/or1k/exception.c b/litex/soc/software/libc/or1k/exception.c index 95d96ca36..c4b893767 100644 --- a/litex/soc/software/libc/or1k/exception.c +++ b/litex/soc/software/libc/or1k/exception.c @@ -7,7 +7,7 @@ void isr(void); #ifdef __or1k__ -#include +#include #define EXTERNAL_IRQ 0x8 diff --git a/litex/soc/software/libc/stdio.c b/litex/soc/software/libc/stdio.c index dcf4f5f23..67ab0a990 100644 --- a/litex/soc/software/libc/stdio.c +++ b/litex/soc/software/libc/stdio.c @@ -16,8 +16,8 @@ #include -#include -#include +#include +#include #include diff --git a/litex/soc/software/libcomm/Makefile b/litex/soc/software/libcomm/Makefile deleted file mode 100755 index 7b25f1c25..000000000 --- a/litex/soc/software/libcomm/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -include ../include/generated/variables.mak -include $(SOC_DIRECTORY)/software/common.mak - -OBJECTS = \ - uart.o \ - spiflash.o \ - i2c.o \ - -all: libcomm.a - -libcomm.a: $(OBJECTS) - $(AR) crs libcomm.a $(OBJECTS) - -# pull in dependency info for *existing* .o files --include $(OBJECTS:.o=.d) - -%.o: $(LIBCOMM_DIRECTORY)/%.c - $(compile) - -.PHONY: all clean - -clean: - $(RM) $(OBJECTS) - $(RM) libcomm.a .*~ *~ diff --git a/litex/soc/software/liblitedram/sdram.c b/litex/soc/software/liblitedram/sdram.c index 1f543b3e1..de4958532 100644 --- a/litex/soc/software/liblitedram/sdram.c +++ b/litex/soc/software/liblitedram/sdram.c @@ -15,8 +15,8 @@ #include #include -#include -#include +#include +#include #ifdef CSR_SDRAM_BASE #include diff --git a/litex/soc/software/libliteeth/tftp.c b/litex/soc/software/libliteeth/tftp.c index c2ab86d67..48fb15419 100644 --- a/litex/soc/software/libliteeth/tftp.c +++ b/litex/soc/software/libliteeth/tftp.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include "udp.h" #include "tftp.h" diff --git a/litex/soc/software/libliteeth/udp.c b/litex/soc/software/libliteeth/udp.c index 330393962..7f201763c 100644 --- a/litex/soc/software/libliteeth/udp.c +++ b/litex/soc/software/libliteeth/udp.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include "udp.h" diff --git a/litex/soc/software/liblitespi/spiflash.c b/litex/soc/software/liblitespi/spiflash.c index d2e2f05b5..cdc4552e1 100644 --- a/litex/soc/software/liblitespi/spiflash.c +++ b/litex/soc/software/liblitespi/spiflash.c @@ -4,8 +4,8 @@ #include #include #include -#include -#include +#include +#include #include #include