From 56b8723b72d17a850983b3003d1128d50e58ec3a Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 19:59:28 +0200 Subject: [PATCH 01/11] software/bios: rename cmd_mem_access to cmd_mem. --- litex/soc/software/bios/Makefile | 2 +- .../soc/software/bios/commands/{cmd_mem_access.c => cmd_mem.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename litex/soc/software/bios/commands/{cmd_mem_access.c => cmd_mem.c} (100%) diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index 9fba33a62..ac7725e60 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -21,7 +21,7 @@ OBJECTS = isr.o \ cmd_boot.o \ cmd_dram.o \ cmd_mdio.o \ - cmd_mem_access.o \ + cmd_mem.o \ cmd_sdcard.o \ cmd_spi_flash.o \ diff --git a/litex/soc/software/bios/commands/cmd_mem_access.c b/litex/soc/software/bios/commands/cmd_mem.c similarity index 100% rename from litex/soc/software/bios/commands/cmd_mem_access.c rename to litex/soc/software/bios/commands/cmd_mem.c From 70a67ce7ed0791eb79eb05d075f310612f9f50fb Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 21:04:54 +0200 Subject: [PATCH 02/11] software/bios: rename libnet to libliteeth and move all ethernet files to it. --- litex/soc/integration/builder.py | 2 +- litex/soc/software/bios/Makefile | 6 +-- litex/soc/software/bios/boot.c | 6 +-- litex/soc/software/bios/main.c | 2 +- litex/soc/software/common.mak | 7 ++- litex/soc/software/include/net/microudp.h | 20 -------- .../software/{libnet => libliteeth}/Makefile | 12 ++--- .../software/{libnet => libliteeth}/tftp.c | 48 +++++++++---------- .../{include/net => libliteeth}/tftp.h | 0 .../{libnet/microudp.c => libliteeth/udp.c} | 24 +++++----- litex/soc/software/libliteeth/udp.h | 20 ++++++++ 11 files changed, 76 insertions(+), 71 deletions(-) delete mode 100644 litex/soc/software/include/net/microudp.h rename litex/soc/software/{libnet => libliteeth}/Makefile (57%) rename litex/soc/software/{libnet => libliteeth}/tftp.c (83%) rename litex/soc/software/{include/net => libliteeth}/tftp.h (100%) rename litex/soc/software/{libnet/microudp.c => libliteeth/udp.c} (96%) create mode 100644 litex/soc/software/libliteeth/udp.h diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index 4fd1b2330..79c6b95d3 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -25,7 +25,7 @@ __all__ = ["soc_software_packages", "soc_directory", soc_software_packages = [ "libcompiler_rt", "libbase", - "libnet", + "libliteeth", "bios" ] diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index ac7725e60..8d4090b7b 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -59,15 +59,15 @@ endif bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS) -%.elf: ../libbase/crt0-ctr.o ../libnet/libnet.a ../libbase/libbase-nofloat.a ../libcompiler_rt/libcompiler_rt.a +%.elf: ../libbase/crt0-ctr.o ../libliteeth/libliteeth.a ../libbase/libbase-nofloat.a ../libcompiler_rt/libcompiler_rt.a $(LD) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \ ../libbase/crt0-ctr.o \ $(OBJECTS) \ - -L../libnet \ + -L../libliteeth \ -L../libbase \ -L../libcompiler_rt \ $(BP_LIBS) \ - -lnet -lbase-nofloat -lcompiler_rt \ + -lliteeth -lbase-nofloat -lcompiler_rt \ $(BP_FLAGS) ifneq ($(OS),Windows_NT) diff --git a/litex/soc/software/bios/boot.c b/litex/soc/software/bios/boot.c index c12cfe251..36993a6fe 100644 --- a/litex/soc/software/bios/boot.c +++ b/litex/soc/software/bios/boot.c @@ -21,8 +21,8 @@ #include #ifdef CSR_ETHMAC_BASE -#include -#include +#include +#include #endif #ifdef CSR_SPIFLASH_BASE @@ -340,7 +340,7 @@ void netboot(void) ip = IPTOINT(REMOTEIP1, REMOTEIP2, REMOTEIP3, REMOTEIP4); - microudp_start(macadr, IPTOINT(LOCALIP1, LOCALIP2, LOCALIP3, LOCALIP4)); + udp_start(macadr, IPTOINT(LOCALIP1, LOCALIP2, LOCALIP3, LOCALIP4)); tftp_port = TFTP_SERVER_PORT; printf("Fetching from: UDP/%d\n", tftp_port); diff --git a/litex/soc/software/bios/main.c b/litex/soc/software/bios/main.c index 7864260aa..a9857c88d 100644 --- a/litex/soc/software/bios/main.c +++ b/litex/soc/software/bios/main.c @@ -30,7 +30,7 @@ #include #ifdef CSR_ETHMAC_BASE -#include +#include "udp.h" #endif #ifdef CSR_SPIFLASH_BASE diff --git a/litex/soc/software/common.mak b/litex/soc/software/common.mak index 83f1aba42..fb97fc480 100644 --- a/litex/soc/software/common.mak +++ b/litex/soc/software/common.mak @@ -45,7 +45,12 @@ DEPFLAGS += -MD -MP # Toolchain options # -INCLUDES = -I$(SOC_DIRECTORY)/software/include/base -I$(SOC_DIRECTORY)/software/include -I$(SOC_DIRECTORY)/common -I$(BUILDINC_DIRECTORY) -I$(CPU_DIRECTORY) +INCLUDES = -I$(SOC_DIRECTORY)/software/include/base \ + -I$(SOC_DIRECTORY)/software/include \ + -I$(SOC_DIRECTORY)/common \ + -I$(BUILDINC_DIRECTORY) \ + -I$(CPU_DIRECTORY) \ + -I$(SOC_DIRECTORY)/software/libliteeth COMMONFLAGS = $(DEPFLAGS) -Os $(CPUFLAGS) -g3 -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(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 diff --git a/litex/soc/software/include/net/microudp.h b/litex/soc/software/include/net/microudp.h deleted file mode 100644 index f148a3411..000000000 --- a/litex/soc/software/include/net/microudp.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __MICROUDP_H -#define __MICROUDP_H - -#define IPTOINT(a, b, c, d) ((a << 24)|(b << 16)|(c << 8)|d) - -#define MICROUDP_BUFSIZE (5*1532) - -typedef void (*udp_callback)(unsigned int src_ip, unsigned short src_port, unsigned short dst_port, void *data, unsigned int length); - -void microudp_start(const unsigned char *macaddr, unsigned int ip); -int microudp_arp_resolve(unsigned int ip); -void *microudp_get_tx_buffer(void); -int microudp_send(unsigned short src_port, unsigned short dst_port, unsigned int length); -void microudp_set_callback(udp_callback callback); -void microudp_service(void); - -void eth_init(void); -void eth_mode(void); - -#endif /* __MICROUDP_H */ diff --git a/litex/soc/software/libnet/Makefile b/litex/soc/software/libliteeth/Makefile similarity index 57% rename from litex/soc/software/libnet/Makefile rename to litex/soc/software/libliteeth/Makefile index 188e48d64..593acc203 100644 --- a/litex/soc/software/libnet/Makefile +++ b/litex/soc/software/libliteeth/Makefile @@ -1,17 +1,17 @@ include ../include/generated/variables.mak include $(SOC_DIRECTORY)/software/common.mak -OBJECTS=microudp.o tftp.o +OBJECTS=udp.o tftp.o -all: libnet.a +all: libliteeth.a -libnet.a: $(OBJECTS) - $(AR) crs libnet.a $(OBJECTS) +libliteeth.a: $(OBJECTS) + $(AR) crs libliteeth.a $(OBJECTS) # pull in dependency info for *existing* .o files -include $(OBJECTS:.o=.d) -%.o: $(LIBNET_DIRECTORY)/%.c +%.o: $(LIBLITEETH_DIRECTORY)/%.c $(compile) %.o: %.S @@ -20,4 +20,4 @@ libnet.a: $(OBJECTS) .PHONY: all clean clean: - $(RM) $(OBJECTS) libnet.a .*~ *~ + $(RM) $(OBJECTS) libliteeth.a .*~ *~ diff --git a/litex/soc/software/libnet/tftp.c b/litex/soc/software/libliteeth/tftp.c similarity index 83% rename from litex/soc/software/libnet/tftp.c rename to litex/soc/software/libliteeth/tftp.c index 439b3e075..c5ac5f389 100644 --- a/litex/soc/software/libnet/tftp.c +++ b/litex/soc/software/libliteeth/tftp.c @@ -10,8 +10,8 @@ #include #include -#include -#include +#include "udp.h" +#include "tftp.h" /* Local TFTP client port (arbitrary) */ #define PORT_IN 7642 @@ -99,9 +99,9 @@ static void rx_callback(uint32_t src_ip, uint16_t src_port, if(length < BLOCK_SIZE) transfer_finished = 1; - packet_data = microudp_get_tx_buffer(); + packet_data = udp_get_tx_buffer(); length = format_ack(packet_data, block); - microudp_send(PORT_IN, src_port, length); + udp_send(PORT_IN, src_port, length); } if(opcode == TFTP_ERROR) { /* Error */ total_length = -1; @@ -118,10 +118,10 @@ int tftp_get(uint32_t ip, uint16_t server_port, const char *filename, int length_before; int spin = 0; - if(!microudp_arp_resolve(ip)) + if(!udp_arp_resolve(ip)) return -1; - microudp_set_callback(rx_callback); + udp_set_callback(rx_callback); dst_buffer = buffer; @@ -129,17 +129,17 @@ int tftp_get(uint32_t ip, uint16_t server_port, const char *filename, transfer_finished = 0; tries = 5; while(1) { - packet_data = microudp_get_tx_buffer(); + packet_data = udp_get_tx_buffer(); len = format_request(packet_data, TFTP_RRQ, filename); - microudp_send(PORT_IN, server_port, len); + udp_send(PORT_IN, server_port, len); for(i=0;i<2000000;i++) { - microudp_service(); + udp_service(); if((total_length > 0) || transfer_finished) break; } if((total_length > 0) || transfer_finished) break; tries--; if(tries == 0) { - microudp_set_callback(NULL); + udp_set_callback(NULL); return -1; } } @@ -156,13 +156,13 @@ int tftp_get(uint32_t ip, uint16_t server_port, const char *filename, } } if(i-- == 0) { - microudp_set_callback(NULL); + udp_set_callback(NULL); return -1; } - microudp_service(); + udp_service(); } - microudp_set_callback(NULL); + udp_set_callback(NULL); return total_length; } @@ -175,23 +175,23 @@ int tftp_put(uint32_t ip, uint16_t server_port, const char *filename, int i; int block = 0, sent = 0; - if(!microudp_arp_resolve(ip)) + if(!udp_arp_resolve(ip)) return -1; - microudp_set_callback(rx_callback); + udp_set_callback(rx_callback); - packet_data = microudp_get_tx_buffer(); + packet_data = udp_get_tx_buffer(); total_length = 0; transfer_finished = 0; tries = 5; while(1) { - packet_data = microudp_get_tx_buffer(); + packet_data = udp_get_tx_buffer(); len = format_request(packet_data, TFTP_WRQ, filename); - microudp_send(PORT_IN, server_port, len); + udp_send(PORT_IN, server_port, len); for(i=0;i<2000000;i++) { last_ack = -1; - microudp_service(); + udp_service(); if(last_ack == block) goto send_data; if(transfer_finished) @@ -208,11 +208,11 @@ send_data: send = sent+BLOCK_SIZE > size ? size-sent : BLOCK_SIZE; tries = 5; while(1) { - packet_data = microudp_get_tx_buffer(); + packet_data = udp_get_tx_buffer(); len = format_data(packet_data, block, buffer, send); - microudp_send(PORT_IN, data_port, len); + udp_send(PORT_IN, data_port, len); for(i=0;i<12000000;i++) { - microudp_service(); + udp_service(); if(transfer_finished) goto fail; if(last_ack == block) @@ -226,11 +226,11 @@ next: buffer += send; } while (send == BLOCK_SIZE); - microudp_set_callback(NULL); + udp_set_callback(NULL); return sent; fail: - microudp_set_callback(NULL); + udp_set_callback(NULL); return -1; } diff --git a/litex/soc/software/include/net/tftp.h b/litex/soc/software/libliteeth/tftp.h similarity index 100% rename from litex/soc/software/include/net/tftp.h rename to litex/soc/software/libliteeth/tftp.h diff --git a/litex/soc/software/libnet/microudp.c b/litex/soc/software/libliteeth/udp.c similarity index 96% rename from litex/soc/software/libnet/microudp.c rename to litex/soc/software/libliteeth/udp.c index 3199456e7..d86962132 100644 --- a/litex/soc/software/libnet/microudp.c +++ b/litex/soc/software/libliteeth/udp.c @@ -16,10 +16,10 @@ #include #include -#include +#include "udp.h" -//#define DEBUG_MICROUDP_TX -//#define DEBUG_MICROUDP_RX +//#define DEBUG_UDP_TX +//#define DEBUG_UDP_RX #define ETHERTYPE_ARP 0x0806 #define ETHERTYPE_IP 0x0800 @@ -145,7 +145,7 @@ static void send_packet(void) txlen += 4; #endif -#ifdef DEBUG_MICROUDP_TX +#ifdef DEBUG_LITEETH_UDP_TX int j; printf(">>>> txlen : %d\n", txlen); for(j=0;jframe.contents.udp.payload; } @@ -301,7 +301,7 @@ struct pseudo_header { unsigned short length; } __attribute__((packed)); -int microudp_send(unsigned short src_port, unsigned short dst_port, unsigned int length) +int udp_send(unsigned short src_port, unsigned short dst_port, unsigned int length) { struct pseudo_header h; unsigned int r; @@ -373,7 +373,7 @@ static void process_ip(void) udp_ip->payload, ntohs(udp_ip->udp.length)-sizeof(struct udp_header)); } -void microudp_set_callback(udp_callback callback) +void udp_set_callback(udp_callback callback) { rx_callback = callback; } @@ -382,7 +382,7 @@ static void process_frame(void) { flush_cpu_dcache(); -#ifdef DEBUG_MICROUDP_RX +#ifdef DEBUG_LITEETH_UDP_RX int j; printf("<<< rxlen : %d\n", rxlen); for(j=0;jframe.eth_header.ethertype) == ETHERTYPE_IP) process_ip(); } -void microudp_start(const unsigned char *macaddr, unsigned int ip) +void udp_start(const unsigned char *macaddr, unsigned int ip) { int i; ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER); @@ -437,7 +437,7 @@ void microudp_start(const unsigned char *macaddr, unsigned int ip) rx_callback = (udp_callback)0; } -void microudp_service(void) +void udp_service(void) { if(ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER) { rxslot = ethmac_sram_writer_slot_read(); diff --git a/litex/soc/software/libliteeth/udp.h b/litex/soc/software/libliteeth/udp.h new file mode 100644 index 000000000..132ef76d3 --- /dev/null +++ b/litex/soc/software/libliteeth/udp.h @@ -0,0 +1,20 @@ +#ifndef __UDP_H +#define __UDP_H + +#define IPTOINT(a, b, c, d) ((a << 24)|(b << 16)|(c << 8)|d) + +#define UDP_BUFSIZE (5*1532) + +typedef void (*udp_callback)(unsigned int src_ip, unsigned short src_port, unsigned short dst_port, void *data, unsigned int length); + +void udp_start(const unsigned char *macaddr, unsigned int ip); +int udp_arp_resolve(unsigned int ip); +void *udp_get_tx_buffer(void); +int udp_send(unsigned short src_port, unsigned short dst_port, unsigned int length); +void udp_set_callback(udp_callback callback); +void udp_service(void); + +void eth_init(void); +void eth_mode(void); + +#endif /* __UDP_H */ From ff8d9e61bf893dba6170722d0e7b6730d8f1c07d Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 21:09:41 +0200 Subject: [PATCH 03/11] software/bios: move mdio to libliteeth. --- litex/soc/software/bios/commands/cmd_mdio.c | 2 +- litex/soc/software/bios/main.c | 2 +- litex/soc/software/libbase/Makefile | 2 +- litex/soc/software/libliteeth/Makefile | 2 +- litex/soc/software/{libbase => libliteeth}/mdio.c | 0 litex/soc/software/{include/base => libliteeth}/mdio.h | 0 6 files changed, 4 insertions(+), 4 deletions(-) rename litex/soc/software/{libbase => libliteeth}/mdio.c (100%) rename litex/soc/software/{include/base => libliteeth}/mdio.h (100%) diff --git a/litex/soc/software/bios/commands/cmd_mdio.c b/litex/soc/software/bios/commands/cmd_mdio.c index 35b020737..86e8fc8a9 100644 --- a/litex/soc/software/bios/commands/cmd_mdio.c +++ b/litex/soc/software/bios/commands/cmd_mdio.c @@ -5,7 +5,7 @@ #include -#include +#include "mdio.h" #include "../command.h" #include "../helpers.h" diff --git a/litex/soc/software/bios/main.c b/litex/soc/software/bios/main.c index a9857c88d..2379dbee2 100644 --- a/litex/soc/software/bios/main.c +++ b/litex/soc/software/bios/main.c @@ -38,7 +38,7 @@ #endif #ifdef CSR_ETHPHY_MDIO_W_ADDR -#include +#include "mdio.h" #endif #include "sdram.h" diff --git a/litex/soc/software/libbase/Makefile b/litex/soc/software/libbase/Makefile index 13680ad0e..55380d8e7 100755 --- a/litex/soc/software/libbase/Makefile +++ b/litex/soc/software/libbase/Makefile @@ -2,7 +2,7 @@ include ../include/generated/variables.mak include $(SOC_DIRECTORY)/software/common.mak OBJECTS=exception.o libc.o errno.o crc16.o crc32.o console.o \ - system.o id.o uart.o time.o qsort.o strtod.o spiflash.o spisdcard.o strcasecmp.o mdio.o + system.o id.o uart.o time.o qsort.o strtod.o spiflash.o spisdcard.o strcasecmp.o all: crt0-ctr.o crt0-xip.o libbase.a libbase-nofloat.a diff --git a/litex/soc/software/libliteeth/Makefile b/litex/soc/software/libliteeth/Makefile index 593acc203..c3cf0b98f 100644 --- a/litex/soc/software/libliteeth/Makefile +++ b/litex/soc/software/libliteeth/Makefile @@ -1,7 +1,7 @@ include ../include/generated/variables.mak include $(SOC_DIRECTORY)/software/common.mak -OBJECTS=udp.o tftp.o +OBJECTS=udp.o tftp.o mdio.o all: libliteeth.a diff --git a/litex/soc/software/libbase/mdio.c b/litex/soc/software/libliteeth/mdio.c similarity index 100% rename from litex/soc/software/libbase/mdio.c rename to litex/soc/software/libliteeth/mdio.c diff --git a/litex/soc/software/include/base/mdio.h b/litex/soc/software/libliteeth/mdio.h similarity index 100% rename from litex/soc/software/include/base/mdio.h rename to litex/soc/software/libliteeth/mdio.h From 573a881529d2d6a4edfcd864de74ddc6602c5f5a Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 22:16:20 +0200 Subject: [PATCH 04/11] software/bios/commands: rename cmd_mdio to cmd_liteeth. --- litex/soc/software/bios/Makefile | 2 +- litex/soc/software/bios/commands/{cmd_mdio.c => cmd_liteeth.c} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename litex/soc/software/bios/commands/{cmd_mdio.c => cmd_liteeth.c} (100%) diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index 8d4090b7b..fe809fe87 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -20,7 +20,7 @@ OBJECTS = isr.o \ cmd_bios.o \ cmd_boot.o \ cmd_dram.o \ - cmd_mdio.o \ + cmd_liteeth.o \ cmd_mem.o \ cmd_sdcard.o \ cmd_spi_flash.o \ diff --git a/litex/soc/software/bios/commands/cmd_mdio.c b/litex/soc/software/bios/commands/cmd_liteeth.c similarity index 100% rename from litex/soc/software/bios/commands/cmd_mdio.c rename to litex/soc/software/bios/commands/cmd_liteeth.c From c95084e5c69bd57b894138cdfec5c360f13111e4 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 22:19:02 +0200 Subject: [PATCH 05/11] bios/software: rename cmd_dram/cmd_sdcard/cmd_spi_flash to cmd_litedram/cmd_litesdcard/cmd_spiflash. --- litex/soc/software/bios/Makefile | 6 +++--- .../software/bios/commands/{cmd_dram.c => cmd_litedram.c} | 2 +- .../bios/commands/{cmd_sdcard.c => cmd_litesdcard.c} | 0 .../bios/commands/{cmd_spi_flash.c => cmd_spiflash.c} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename litex/soc/software/bios/commands/{cmd_dram.c => cmd_litedram.c} (99%) rename litex/soc/software/bios/commands/{cmd_sdcard.c => cmd_litesdcard.c} (100%) rename litex/soc/software/bios/commands/{cmd_spi_flash.c => cmd_spiflash.c} (100%) diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index fe809fe87..24d33a504 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -19,11 +19,11 @@ OBJECTS = isr.o \ helpers.o \ cmd_bios.o \ cmd_boot.o \ - cmd_dram.o \ + cmd_litedram.o \ cmd_liteeth.o \ cmd_mem.o \ - cmd_sdcard.o \ - cmd_spi_flash.o \ + cmd_litesdcard.o \ + cmd_spiflash.o \ ifneq "$(or $(TERM_NO_COMPLETE),$(TERM_MINI))" "" CFLAGS += -DTERM_NO_COMPLETE diff --git a/litex/soc/software/bios/commands/cmd_dram.c b/litex/soc/software/bios/commands/cmd_litedram.c similarity index 99% rename from litex/soc/software/bios/commands/cmd_dram.c rename to litex/soc/software/bios/commands/cmd_litedram.c index 0d6fa1d46..dbca41291 100644 --- a/litex/soc/software/bios/commands/cmd_dram.c +++ b/litex/soc/software/bios/commands/cmd_litedram.c @@ -25,7 +25,7 @@ static void sdrrow_handler(int nb_params, char **params) sdrrow(0); printf("Precharged"); } - + row = strtoul(params[0], &c, 0); if (*c != 0) { printf("Incorrect row"); diff --git a/litex/soc/software/bios/commands/cmd_sdcard.c b/litex/soc/software/bios/commands/cmd_litesdcard.c similarity index 100% rename from litex/soc/software/bios/commands/cmd_sdcard.c rename to litex/soc/software/bios/commands/cmd_litesdcard.c diff --git a/litex/soc/software/bios/commands/cmd_spi_flash.c b/litex/soc/software/bios/commands/cmd_spiflash.c similarity index 100% rename from litex/soc/software/bios/commands/cmd_spi_flash.c rename to litex/soc/software/bios/commands/cmd_spiflash.c From 920d0ee53683e59a3dc1cc65e8ab7bcf4f388076 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 22:39:59 +0200 Subject: [PATCH 06/11] software: create liblitedram and move sdram init/test code to it. --- litex/soc/integration/builder.py | 1 + litex/soc/software/bios/Makefile | 14 +++++++---- litex/soc/software/common.mak | 1 + litex/soc/software/liblitedram/Makefile | 23 +++++++++++++++++++ .../soc/software/{bios => liblitedram}/lfsr.h | 0 .../software/{bios => liblitedram}/sdram.c | 0 .../software/{bios => liblitedram}/sdram.h | 0 7 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 litex/soc/software/liblitedram/Makefile rename litex/soc/software/{bios => liblitedram}/lfsr.h (100%) rename litex/soc/software/{bios => liblitedram}/sdram.c (100%) rename litex/soc/software/{bios => liblitedram}/sdram.h (100%) diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index 79c6b95d3..64dca9d61 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -25,6 +25,7 @@ __all__ = ["soc_software_packages", "soc_directory", soc_software_packages = [ "libcompiler_rt", "libbase", + "liblitedram", "libliteeth", "bios" ] diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index 24d33a504..73d9ed0a2 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -11,7 +11,6 @@ CFLAGS += -DTFTP_SERVER_PORT=$(TFTP_SERVER_PORT) endif OBJECTS = isr.o \ - sdram.o \ sdcard.o \ main.o \ boot-helper.o \ @@ -59,15 +58,20 @@ endif bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS) -%.elf: ../libbase/crt0-ctr.o ../libliteeth/libliteeth.a ../libbase/libbase-nofloat.a ../libcompiler_rt/libcompiler_rt.a +%.elf: ../libbase/crt0-ctr.o \ + ../libcompiler_rt/libcompiler_rt.a \ + ../libbase/libbase-nofloat.a \ + ../liblitedram/liblitedram.a \ + ../libliteeth/libliteeth.a $(LD) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \ ../libbase/crt0-ctr.o \ $(OBJECTS) \ - -L../libliteeth \ - -L../libbase \ -L../libcompiler_rt \ + -L../libbase \ + -L../liblitedram \ + -L../libliteeth \ $(BP_LIBS) \ - -lliteeth -lbase-nofloat -lcompiler_rt \ + -lcompiler_rt -lbase-nofloat -llitedram -lliteeth \ $(BP_FLAGS) ifneq ($(OS),Windows_NT) diff --git a/litex/soc/software/common.mak b/litex/soc/software/common.mak index fb97fc480..808915315 100644 --- a/litex/soc/software/common.mak +++ b/litex/soc/software/common.mak @@ -50,6 +50,7 @@ INCLUDES = -I$(SOC_DIRECTORY)/software/include/base \ -I$(SOC_DIRECTORY)/common \ -I$(BUILDINC_DIRECTORY) \ -I$(CPU_DIRECTORY) \ + -I$(SOC_DIRECTORY)/software/liblitedram \ -I$(SOC_DIRECTORY)/software/libliteeth COMMONFLAGS = $(DEPFLAGS) -Os $(CPUFLAGS) -g3 -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(INCLUDES) CFLAGS = $(COMMONFLAGS) -fexceptions -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes diff --git a/litex/soc/software/liblitedram/Makefile b/litex/soc/software/liblitedram/Makefile new file mode 100644 index 000000000..070263252 --- /dev/null +++ b/litex/soc/software/liblitedram/Makefile @@ -0,0 +1,23 @@ +include ../include/generated/variables.mak +include $(SOC_DIRECTORY)/software/common.mak + +OBJECTS=sdram.o + +all: liblitedram.a + +liblitedram.a: $(OBJECTS) + $(AR) crs liblitedram.a $(OBJECTS) + +# pull in dependency info for *existing* .o files +-include $(OBJECTS:.o=.d) + +%.o: $(LIBLITEDRAM_DIRECTORY)/%.c + $(compile) + +%.o: %.S + $(assemble) + +.PHONY: all clean + +clean: + $(RM) $(OBJECTS) liblitedram.a .*~ *~ diff --git a/litex/soc/software/bios/lfsr.h b/litex/soc/software/liblitedram/lfsr.h similarity index 100% rename from litex/soc/software/bios/lfsr.h rename to litex/soc/software/liblitedram/lfsr.h diff --git a/litex/soc/software/bios/sdram.c b/litex/soc/software/liblitedram/sdram.c similarity index 100% rename from litex/soc/software/bios/sdram.c rename to litex/soc/software/liblitedram/sdram.c diff --git a/litex/soc/software/bios/sdram.h b/litex/soc/software/liblitedram/sdram.h similarity index 100% rename from litex/soc/software/bios/sdram.h rename to litex/soc/software/liblitedram/sdram.h From 403355a8edf41745b7ac301337d53e978b489f42 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 22:49:12 +0200 Subject: [PATCH 07/11] software: create liblitescard and move sdcard init/test code to it. --- litex/soc/integration/builder.py | 1 + litex/soc/software/bios/Makefile | 15 ++++++------ .../soc/software/bios/commands/cmd_litedram.c | 3 ++- .../software/bios/commands/cmd_litesdcard.c | 3 ++- litex/soc/software/common.mak | 3 ++- litex/soc/software/liblitesdcard/Makefile | 23 +++++++++++++++++++ .../software/{bios => liblitesdcard}/sdcard.c | 0 .../software/{bios => liblitesdcard}/sdcard.h | 0 8 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 litex/soc/software/liblitesdcard/Makefile rename litex/soc/software/{bios => liblitesdcard}/sdcard.c (100%) rename litex/soc/software/{bios => liblitesdcard}/sdcard.h (100%) diff --git a/litex/soc/integration/builder.py b/litex/soc/integration/builder.py index 64dca9d61..496903eb7 100644 --- a/litex/soc/integration/builder.py +++ b/litex/soc/integration/builder.py @@ -27,6 +27,7 @@ soc_software_packages = [ "libbase", "liblitedram", "libliteeth", + "liblitesdcard", "bios" ] diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index 73d9ed0a2..a4c39660c 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -11,18 +11,17 @@ CFLAGS += -DTFTP_SERVER_PORT=$(TFTP_SERVER_PORT) endif OBJECTS = isr.o \ - sdcard.o \ - main.o \ boot-helper.o \ boot.o \ helpers.o \ cmd_bios.o \ + cmd_mem.o \ cmd_boot.o \ + cmd_spiflash.o \ cmd_litedram.o \ cmd_liteeth.o \ - cmd_mem.o \ - cmd_litesdcard.o \ - cmd_spiflash.o \ + cmd_litesdcard.o \ + main.o ifneq "$(or $(TERM_NO_COMPLETE),$(TERM_MINI))" "" CFLAGS += -DTERM_NO_COMPLETE @@ -62,7 +61,8 @@ bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS) ../libcompiler_rt/libcompiler_rt.a \ ../libbase/libbase-nofloat.a \ ../liblitedram/liblitedram.a \ - ../libliteeth/libliteeth.a + ../libliteeth/libliteeth.a \ + ../liblitesdcard/liblitesdcard.a $(LD) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \ ../libbase/crt0-ctr.o \ $(OBJECTS) \ @@ -70,8 +70,9 @@ bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS) -L../libbase \ -L../liblitedram \ -L../libliteeth \ + -L../liblitesdcard \ $(BP_LIBS) \ - -lcompiler_rt -lbase-nofloat -llitedram -lliteeth \ + -lcompiler_rt -lbase-nofloat -llitedram -lliteeth -llitesdcard \ $(BP_FLAGS) ifneq ($(OS),Windows_NT) diff --git a/litex/soc/software/bios/commands/cmd_litedram.c b/litex/soc/software/bios/commands/cmd_litedram.c index dbca41291..0d05b2533 100644 --- a/litex/soc/software/bios/commands/cmd_litedram.c +++ b/litex/soc/software/bios/commands/cmd_litedram.c @@ -5,9 +5,10 @@ #include +#include "sdram.h" + #include "../command.h" #include "../helpers.h" -#include "../sdram.h" /** * Command "sdrrow" diff --git a/litex/soc/software/bios/commands/cmd_litesdcard.c b/litex/soc/software/bios/commands/cmd_litesdcard.c index d9545e07a..63347667d 100644 --- a/litex/soc/software/bios/commands/cmd_litesdcard.c +++ b/litex/soc/software/bios/commands/cmd_litesdcard.c @@ -5,9 +5,10 @@ #include +#include "sdcard.h" + #include "../command.h" #include "../helpers.h" -#include "../sdcard.h" /** * Command "sdclk" diff --git a/litex/soc/software/common.mak b/litex/soc/software/common.mak index 808915315..1431ad552 100644 --- a/litex/soc/software/common.mak +++ b/litex/soc/software/common.mak @@ -51,7 +51,8 @@ INCLUDES = -I$(SOC_DIRECTORY)/software/include/base \ -I$(BUILDINC_DIRECTORY) \ -I$(CPU_DIRECTORY) \ -I$(SOC_DIRECTORY)/software/liblitedram \ - -I$(SOC_DIRECTORY)/software/libliteeth + -I$(SOC_DIRECTORY)/software/libliteeth \ + -I$(SOC_DIRECTORY)/software/liblitesdcard COMMONFLAGS = $(DEPFLAGS) -Os $(CPUFLAGS) -g3 -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(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 diff --git a/litex/soc/software/liblitesdcard/Makefile b/litex/soc/software/liblitesdcard/Makefile new file mode 100644 index 000000000..7b0c749a7 --- /dev/null +++ b/litex/soc/software/liblitesdcard/Makefile @@ -0,0 +1,23 @@ +include ../include/generated/variables.mak +include $(SOC_DIRECTORY)/software/common.mak + +OBJECTS=sdcard.o + +all: liblitesdcard.a + +liblitesdcard.a: $(OBJECTS) + $(AR) crs liblitesdcard.a $(OBJECTS) + +# pull in dependency info for *existing* .o files +-include $(OBJECTS:.o=.d) + +%.o: $(LIBLITESDCARD_DIRECTORY)/%.c + $(compile) + +%.o: %.S + $(assemble) + +.PHONY: all clean + +clean: + $(RM) $(OBJECTS) liblitesdcard.a .*~ *~ diff --git a/litex/soc/software/bios/sdcard.c b/litex/soc/software/liblitesdcard/sdcard.c similarity index 100% rename from litex/soc/software/bios/sdcard.c rename to litex/soc/software/liblitesdcard/sdcard.c diff --git a/litex/soc/software/bios/sdcard.h b/litex/soc/software/liblitesdcard/sdcard.h similarity index 100% rename from litex/soc/software/bios/sdcard.h rename to litex/soc/software/liblitesdcard/sdcard.h From 33f6ce74314a01ef4d11a89030d47c78f49be52d Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 23:09:31 +0200 Subject: [PATCH 08/11] software/bios: move hw flags definitions to respective libs, remove hw/flags.h. --- litex/soc/software/include/base/uart.h | 3 ++ litex/soc/software/include/hw/flags.h | 40 ----------------------- litex/soc/software/libbase/exception.c | 2 -- litex/soc/software/libbase/uart.c | 1 - litex/soc/software/liblitedram/sdram.c | 1 - litex/soc/software/libliteeth/udp.c | 1 - litex/soc/software/libliteeth/udp.h | 3 ++ litex/soc/software/liblitesdcard/sdcard.c | 1 - litex/soc/software/liblitesdcard/sdcard.h | 4 +++ 9 files changed, 10 insertions(+), 46 deletions(-) delete mode 100644 litex/soc/software/include/hw/flags.h diff --git a/litex/soc/software/include/base/uart.h b/litex/soc/software/include/base/uart.h index 3d8a4fcf4..bda2dd296 100644 --- a/litex/soc/software/include/base/uart.h +++ b/litex/soc/software/include/base/uart.h @@ -5,6 +5,9 @@ extern "C" { #endif +#define UART_EV_TX 0x1 +#define UART_EV_RX 0x2 + void uart_init(void); void uart_isr(void); void uart_sync(void); diff --git a/litex/soc/software/include/hw/flags.h b/litex/soc/software/include/hw/flags.h deleted file mode 100644 index 911a1b68d..000000000 --- a/litex/soc/software/include/hw/flags.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __HW_FLAGS_H -#define __HW_FLAGS_H - -#define UART_EV_TX 0x1 -#define UART_EV_RX 0x2 - -#define DFII_CONTROL_SEL 0x01 -#define DFII_CONTROL_CKE 0x02 -#define DFII_CONTROL_ODT 0x04 -#define DFII_CONTROL_RESET_N 0x08 - -#define DFII_COMMAND_CS 0x01 -#define DFII_COMMAND_WE 0x02 -#define DFII_COMMAND_CAS 0x04 -#define DFII_COMMAND_RAS 0x08 -#define DFII_COMMAND_WRDATA 0x10 -#define DFII_COMMAND_RDDATA 0x20 - -#define ETHMAC_EV_SRAM_WRITER 0x1 -#define ETHMAC_EV_SRAM_READER 0x1 - -#define CLKGEN_STATUS_BUSY 0x1 -#define CLKGEN_STATUS_PROGDONE 0x2 -#define CLKGEN_STATUS_LOCKED 0x4 - -#define DVISAMPLER_TOO_LATE 0x1 -#define DVISAMPLER_TOO_EARLY 0x2 - -#define DVISAMPLER_DELAY_MASTER_CAL 0x01 -#define DVISAMPLER_DELAY_MASTER_RST 0x02 -#define DVISAMPLER_DELAY_SLAVE_CAL 0x04 -#define DVISAMPLER_DELAY_SLAVE_RST 0x08 -#define DVISAMPLER_DELAY_INC 0x10 -#define DVISAMPLER_DELAY_DEC 0x20 - -#define DVISAMPLER_SLOT_EMPTY 0 -#define DVISAMPLER_SLOT_LOADED 1 -#define DVISAMPLER_SLOT_PENDING 2 - -#endif /* __HW_FLAGS_H */ diff --git a/litex/soc/software/libbase/exception.c b/litex/soc/software/libbase/exception.c index 09b26399a..0ac917272 100644 --- a/litex/soc/software/libbase/exception.c +++ b/litex/soc/software/libbase/exception.c @@ -6,8 +6,6 @@ void isr(void); #ifdef __or1k__ -#include - #define EXTERNAL_IRQ 0x8 static void emerg_printf(const char *fmt, ...) diff --git a/litex/soc/software/libbase/uart.c b/litex/soc/software/libbase/uart.c index 4fac827fa..81aa128b4 100644 --- a/litex/soc/software/libbase/uart.c +++ b/litex/soc/software/libbase/uart.c @@ -1,7 +1,6 @@ #include #include #include -#include /* * Buffer sizes must be a power of 2 so that modulos can be computed diff --git a/litex/soc/software/liblitedram/sdram.c b/litex/soc/software/liblitedram/sdram.c index 81b169cf8..44cab02fa 100644 --- a/litex/soc/software/liblitedram/sdram.c +++ b/litex/soc/software/liblitedram/sdram.c @@ -17,7 +17,6 @@ #include #endif #include -#include #include #include "sdram.h" diff --git a/litex/soc/software/libliteeth/udp.c b/litex/soc/software/libliteeth/udp.c index d86962132..486a2efa6 100644 --- a/litex/soc/software/libliteeth/udp.c +++ b/litex/soc/software/libliteeth/udp.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "udp.h" diff --git a/litex/soc/software/libliteeth/udp.h b/litex/soc/software/libliteeth/udp.h index 132ef76d3..47e844b8a 100644 --- a/litex/soc/software/libliteeth/udp.h +++ b/litex/soc/software/libliteeth/udp.h @@ -1,6 +1,9 @@ #ifndef __UDP_H #define __UDP_H +#define ETHMAC_EV_SRAM_WRITER 0x1 +#define ETHMAC_EV_SRAM_READER 0x1 + #define IPTOINT(a, b, c, d) ((a << 24)|(b << 16)|(c << 8)|d) #define UDP_BUFSIZE (5*1532) diff --git a/litex/soc/software/liblitesdcard/sdcard.c b/litex/soc/software/liblitesdcard/sdcard.c index 274f3cfac..f21f53c6e 100644 --- a/litex/soc/software/liblitesdcard/sdcard.c +++ b/litex/soc/software/liblitesdcard/sdcard.c @@ -10,7 +10,6 @@ #include #include -#include #include #include "sdcard.h" diff --git a/litex/soc/software/liblitesdcard/sdcard.h b/litex/soc/software/liblitesdcard/sdcard.h index 690d85bc6..109735341 100644 --- a/litex/soc/software/liblitesdcard/sdcard.h +++ b/litex/soc/software/liblitesdcard/sdcard.h @@ -6,6 +6,10 @@ #include +#define CLKGEN_STATUS_BUSY 0x1 +#define CLKGEN_STATUS_PROGDONE 0x2 +#define CLKGEN_STATUS_LOCKED 0x4 + #ifdef CSR_SDCORE_BASE #define SD_OK 0 From 21e2a34c3fda459ac4dc930892112197a38c153b Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 23:26:51 +0200 Subject: [PATCH 09/11] software/bios: rename commands to cmds and update with libs' names. --- litex/soc/software/bios/Makefile | 2 +- .../bios/{commands => cmds}/cmd_bios.c | 0 .../bios/{commands => cmds}/cmd_boot.c | 0 .../bios/{commands => cmds}/cmd_litedram.c | 24 +++++++++---------- .../bios/{commands => cmds}/cmd_liteeth.c | 6 ++--- .../bios/{commands => cmds}/cmd_litesdcard.c | 10 ++++---- .../bios/{commands => cmds}/cmd_mem.c | 0 .../bios/{commands => cmds}/cmd_spiflash.c | 0 litex/soc/software/bios/command.h | 21 ++++++++-------- 9 files changed, 31 insertions(+), 32 deletions(-) rename litex/soc/software/bios/{commands => cmds}/cmd_bios.c (100%) rename litex/soc/software/bios/{commands => cmds}/cmd_boot.c (100%) rename litex/soc/software/bios/{commands => cmds}/cmd_litedram.c (82%) rename litex/soc/software/bios/{commands => cmds}/cmd_liteeth.c (90%) rename litex/soc/software/bios/{commands => cmds}/cmd_litesdcard.c (83%) rename litex/soc/software/bios/{commands => cmds}/cmd_mem.c (100%) rename litex/soc/software/bios/{commands => cmds}/cmd_spiflash.c (100%) diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index a4c39660c..0e288a43b 100755 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -85,7 +85,7 @@ endif %.o: $(BIOS_DIRECTORY)/%.c $(compile) -%.o: $(BIOS_DIRECTORY)/commands/%.c +%.o: $(BIOS_DIRECTORY)/cmds/%.c $(compile) %.o: $(BIOS_DIRECTORY)/%.S diff --git a/litex/soc/software/bios/commands/cmd_bios.c b/litex/soc/software/bios/cmds/cmd_bios.c similarity index 100% rename from litex/soc/software/bios/commands/cmd_bios.c rename to litex/soc/software/bios/cmds/cmd_bios.c diff --git a/litex/soc/software/bios/commands/cmd_boot.c b/litex/soc/software/bios/cmds/cmd_boot.c similarity index 100% rename from litex/soc/software/bios/commands/cmd_boot.c rename to litex/soc/software/bios/cmds/cmd_boot.c diff --git a/litex/soc/software/bios/commands/cmd_litedram.c b/litex/soc/software/bios/cmds/cmd_litedram.c similarity index 82% rename from litex/soc/software/bios/commands/cmd_litedram.c rename to litex/soc/software/bios/cmds/cmd_litedram.c index 0d05b2533..0b9ea2280 100644 --- a/litex/soc/software/bios/commands/cmd_litedram.c +++ b/litex/soc/software/bios/cmds/cmd_litedram.c @@ -36,7 +36,7 @@ static void sdrrow_handler(int nb_params, char **params) sdrrow(row); printf("Activated row %d", row); } -define_command(sdrrow, sdrrow_handler, "Precharge/Activate row", DRAM_CMDS); +define_command(sdrrow, sdrrow_handler, "Precharge/Activate row", LITEDRAM_CMDS); #endif /** @@ -46,7 +46,7 @@ define_command(sdrrow, sdrrow_handler, "Precharge/Activate row", DRAM_CMDS); * */ #ifdef CSR_SDRAM_BASE -define_command(sdrsw, sdrsw, "Gives SDRAM control to SW", DRAM_CMDS); +define_command(sdrsw, sdrsw, "Gives SDRAM control to SW", LITEDRAM_CMDS); #endif /** @@ -56,7 +56,7 @@ define_command(sdrsw, sdrsw, "Gives SDRAM control to SW", DRAM_CMDS); * */ #ifdef CSR_SDRAM_BASE -define_command(sdrhw, sdrhw, "Gives SDRAM control to HW", DRAM_CMDS); +define_command(sdrhw, sdrhw, "Gives SDRAM control to HW", LITEDRAM_CMDS); #endif /** @@ -71,7 +71,7 @@ static void sdrrdbuf_handler(int nb_params, char **params) sdrrdbuf(-1); } -define_command(sdrrdbuf, sdrrdbuf_handler, "Dump SDRAM read buffer", DRAM_CMDS); +define_command(sdrrdbuf, sdrrdbuf_handler, "Dump SDRAM read buffer", LITEDRAM_CMDS); #endif /** @@ -111,7 +111,7 @@ static void sdrrd_handler(int nb_params, char **params) sdrrd(addr, dq); } -define_command(sdrrd, sdrrd_handler, "Read SDRAM data", DRAM_CMDS); +define_command(sdrrd, sdrrd_handler, "Read SDRAM data", LITEDRAM_CMDS); #endif /** @@ -140,7 +140,7 @@ static void sdrrderr_handler(int nb_params, char **params) sdrrderr(count); } -define_command(sdrrderr, sdrrderr_handler, "Print SDRAM read errors", DRAM_CMDS); +define_command(sdrrderr, sdrrderr_handler, "Print SDRAM read errors", LITEDRAM_CMDS); #endif /** @@ -169,7 +169,7 @@ static void sdrwr_handler(int nb_params, char **params) sdrwr(addr); } -define_command(sdrwr, sdrwr_handler, "Write SDRAM test data", DRAM_CMDS); +define_command(sdrwr, sdrwr_handler, "Write SDRAM test data", LITEDRAM_CMDS); #endif /** @@ -179,7 +179,7 @@ define_command(sdrwr, sdrwr_handler, "Write SDRAM test data", DRAM_CMDS); * */ #if defined(CSR_SDRAM_BASE) && defined(CSR_DDRPHY_BASE) -define_command(sdrinit, sdrinit, "Start SDRAM initialisation", DRAM_CMDS); +define_command(sdrinit, sdrinit, "Start SDRAM initialisation", LITEDRAM_CMDS); #endif /** @@ -189,7 +189,7 @@ define_command(sdrinit, sdrinit, "Start SDRAM initialisation", DRAM_CMDS); * */ #if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE) -define_command(sdrwlon, sdrwlon, "Enable write leveling", DRAM_CMDS); +define_command(sdrwlon, sdrwlon, "Enable write leveling", LITEDRAM_CMDS); #endif /** @@ -199,7 +199,7 @@ define_command(sdrwlon, sdrwlon, "Enable write leveling", DRAM_CMDS); * */ #if defined(CSR_DDRPHY_BASE) && defined(SDRAM_PHY_WRITE_LEVELING_CAPABLE) && defined(CSR_SDRAM_BASE) -define_command(sdrwloff, sdrwloff, "Disable write leveling", DRAM_CMDS); +define_command(sdrwloff, sdrwloff, "Disable write leveling", LITEDRAM_CMDS); #endif /** @@ -209,7 +209,7 @@ define_command(sdrwloff, sdrwloff, "Disable write leveling", DRAM_CMDS); * */ #if defined(CSR_DDRPHY_BASE) && defined(CSR_SDRAM_BASE) -define_command(sdrlevel, sdrlevel, "Perform read/write leveling", DRAM_CMDS); +define_command(sdrlevel, sdrlevel, "Perform read/write leveling", LITEDRAM_CMDS); #endif /** @@ -219,5 +219,5 @@ define_command(sdrlevel, sdrlevel, "Perform read/write leveling", DRAM_CMDS); * */ #ifdef CSR_SDRAM_BASE -define_command(memtest, memtest, "Run a memory test", DRAM_CMDS); +define_command(memtest, memtest, "Run a memory test", LITEDRAM_CMDS); #endif diff --git a/litex/soc/software/bios/commands/cmd_liteeth.c b/litex/soc/software/bios/cmds/cmd_liteeth.c similarity index 90% rename from litex/soc/software/bios/commands/cmd_liteeth.c rename to litex/soc/software/bios/cmds/cmd_liteeth.c index 86e8fc8a9..f9df1d248 100644 --- a/litex/soc/software/bios/commands/cmd_liteeth.c +++ b/litex/soc/software/bios/cmds/cmd_liteeth.c @@ -50,7 +50,7 @@ static void mdiow(int nb_params, char **params) mdio_write(phyadr2, reg2, val2); } -define_command(mdiow, mdiow, "Write MDIO register", MDIO_CMDS); +define_command(mdiow, mdiow, "Write MDIO register", LITEETH_CMDS); #endif /** @@ -88,7 +88,7 @@ static void mdior(int nb_params, char **params) printf("Reg %d: 0x%04x", reg2, val); } -define_command(mdior, mdior, "Read MDIO register", MDIO_CMDS); +define_command(mdior, mdior, "Read MDIO register", LITEETH_CMDS); #endif /** @@ -130,5 +130,5 @@ static void mdiod(int nb_params, char **params) } } -define_command(mdiod, mdiod, "Dump MDIO registers", MDIO_CMDS); +define_command(mdiod, mdiod, "Dump MDIO registers", LITEETH_CMDS); #endif diff --git a/litex/soc/software/bios/commands/cmd_litesdcard.c b/litex/soc/software/bios/cmds/cmd_litesdcard.c similarity index 83% rename from litex/soc/software/bios/commands/cmd_litesdcard.c rename to litex/soc/software/bios/cmds/cmd_litesdcard.c index 63347667d..d5d1651f8 100644 --- a/litex/soc/software/bios/commands/cmd_litesdcard.c +++ b/litex/soc/software/bios/cmds/cmd_litesdcard.c @@ -43,7 +43,7 @@ struct command_struct cmd_sdclk = .help = "SDCard set clk frequency (Mhz)", }; -define_command(sdclk, sdclk, "SDCard set clk frequency (Mhz)", SD_CMDS); +define_command(sdclk, sdclk, "SDCard set clk frequency (Mhz)", LITESDCARD_CMDS); #endif /** @@ -53,7 +53,7 @@ define_command(sdclk, sdclk, "SDCard set clk frequency (Mhz)", SD_CMDS); * */ #ifdef CSR_SDCORE_BASE -define_command(sdinit, sdcard_init, "SDCard initialization", SD_CMDS); +define_command(sdinit, sdcard_init, "SDCard initialization", LITESDCARD_CMDS); #endif /** @@ -82,7 +82,7 @@ static void sdtest(int nb_params, char **params) sdcard_test(blocks); } -define_command(sdtest, sdtest, "SDCard test", SD_CMDS); +define_command(sdtest, sdtest, "SDCard test", LITESDCARD_CMDS); #endif /** @@ -111,7 +111,7 @@ static void sdtestread(int nb_params, char **params) sdcard_test_read(block); } -define_command(sdtestread, sdtestread, "SDCard test read", SD_CMDS); +define_command(sdtestread, sdtestread, "SDCard test read", LITESDCARD_CMDS); #endif /** @@ -140,5 +140,5 @@ static void sdtestwrite(int nb_params, char **params) sdcard_test_write(block, params[1]); } -define_command(sdtestwrite, sdtestwrite, "SDCard test write", SD_CMDS); +define_command(sdtestwrite, sdtestwrite, "SDCard test write", LITESDCARD_CMDS); #endif diff --git a/litex/soc/software/bios/commands/cmd_mem.c b/litex/soc/software/bios/cmds/cmd_mem.c similarity index 100% rename from litex/soc/software/bios/commands/cmd_mem.c rename to litex/soc/software/bios/cmds/cmd_mem.c diff --git a/litex/soc/software/bios/commands/cmd_spiflash.c b/litex/soc/software/bios/cmds/cmd_spiflash.c similarity index 100% rename from litex/soc/software/bios/commands/cmd_spiflash.c rename to litex/soc/software/bios/cmds/cmd_spiflash.c diff --git a/litex/soc/software/bios/command.h b/litex/soc/software/bios/command.h index 693d79825..1640231ff 100644 --- a/litex/soc/software/bios/command.h +++ b/litex/soc/software/bios/command.h @@ -9,17 +9,16 @@ #define HIST_DEPTH 10 /* Used in string list, complete.c */ -#define MISC_CMDS 0 -#define SYSTEM_CMDS 1 -#define CACHE_CMDS 2 -#define BOOT_CMDS 3 -#define DRAM_CMDS 4 -#define MDIO_CMDS 5 -#define MEM_CMDS 6 -#define SD_CMDS 7 -#define SPIFLASH_CMDS 8 -#define DDR_CMDS 9 -#define NB_OF_GROUPS 10 +#define MISC_CMDS 0 +#define SYSTEM_CMDS 1 +#define CACHE_CMDS 2 +#define MEM_CMDS 3 +#define BOOT_CMDS 3 +#define SPIFLASH_CMDS 4 +#define LITEDRAM_CMDS 4 +#define LITEETH_CMDS 5 +#define LITESDCARD_CMDS 7 +#define NB_OF_GROUPS 8 typedef void (*cmd_handler)(int nb_params, char **params); From b4b84def3c4ea921e3abbfc90a092a0b9782fca9 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 23:33:34 +0200 Subject: [PATCH 10/11] software/bios: mode spisdcard code to liblitesdcard. --- litex/soc/software/bios/boot.c | 2 +- litex/soc/software/libbase/Makefile | 2 +- litex/soc/software/liblitesdcard/Makefile | 2 +- litex/soc/software/{libbase => liblitesdcard}/spisdcard.c | 2 +- litex/soc/software/{include/base => liblitesdcard}/spisdcard.h | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename litex/soc/software/{libbase => liblitesdcard}/spisdcard.c (99%) rename litex/soc/software/{include/base => liblitesdcard}/spisdcard.h (100%) diff --git a/litex/soc/software/bios/boot.c b/litex/soc/software/bios/boot.c index 36993a6fe..a85bca2d6 100644 --- a/litex/soc/software/bios/boot.c +++ b/litex/soc/software/bios/boot.c @@ -497,7 +497,7 @@ void romboot(void) // SPI HARDWARE BITBANG #ifdef CSR_SPISDCARD_BASE -#include +#include "spisdcard.h" void spisdcardboot(void) { diff --git a/litex/soc/software/libbase/Makefile b/litex/soc/software/libbase/Makefile index 55380d8e7..b29bffb42 100755 --- a/litex/soc/software/libbase/Makefile +++ b/litex/soc/software/libbase/Makefile @@ -2,7 +2,7 @@ include ../include/generated/variables.mak include $(SOC_DIRECTORY)/software/common.mak OBJECTS=exception.o libc.o errno.o crc16.o crc32.o console.o \ - system.o id.o uart.o time.o qsort.o strtod.o spiflash.o spisdcard.o strcasecmp.o + system.o id.o uart.o time.o qsort.o strtod.o spiflash.o strcasecmp.o all: crt0-ctr.o crt0-xip.o libbase.a libbase-nofloat.a diff --git a/litex/soc/software/liblitesdcard/Makefile b/litex/soc/software/liblitesdcard/Makefile index 7b0c749a7..48b39261e 100644 --- a/litex/soc/software/liblitesdcard/Makefile +++ b/litex/soc/software/liblitesdcard/Makefile @@ -1,7 +1,7 @@ include ../include/generated/variables.mak include $(SOC_DIRECTORY)/software/common.mak -OBJECTS=sdcard.o +OBJECTS=sdcard.o spisdcard.o all: liblitesdcard.a diff --git a/litex/soc/software/libbase/spisdcard.c b/litex/soc/software/liblitesdcard/spisdcard.c similarity index 99% rename from litex/soc/software/libbase/spisdcard.c rename to litex/soc/software/liblitesdcard/spisdcard.c index ae3ec7305..b335da401 100644 --- a/litex/soc/software/libbase/spisdcard.c +++ b/litex/soc/software/liblitesdcard/spisdcard.c @@ -26,7 +26,7 @@ #ifdef CSR_SPISDCARD_BASE // Import prototypes for the functions -#include +#include "spisdcard.h" // SPI // cs line - high to indicate DESELECT diff --git a/litex/soc/software/include/base/spisdcard.h b/litex/soc/software/liblitesdcard/spisdcard.h similarity index 100% rename from litex/soc/software/include/base/spisdcard.h rename to litex/soc/software/liblitesdcard/spisdcard.h From 7192397ab44067e53b33117a65583a68c3421662 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 18 May 2020 23:35:48 +0200 Subject: [PATCH 11/11] software/libbase: remove linker-sdram (unused). --- litex/soc/software/libbase/linker-sdram.ld | 64 ---------------------- 1 file changed, 64 deletions(-) delete mode 100644 litex/soc/software/libbase/linker-sdram.ld diff --git a/litex/soc/software/libbase/linker-sdram.ld b/litex/soc/software/libbase/linker-sdram.ld deleted file mode 100644 index b55b50f2a..000000000 --- a/litex/soc/software/libbase/linker-sdram.ld +++ /dev/null @@ -1,64 +0,0 @@ -INCLUDE generated/output_format.ld -ENTRY(_start) - -__DYNAMIC = 0; - -INCLUDE generated/regions.ld - -SECTIONS -{ - .text : - { - _ftext = .; - *(.text .stub .text.* .gnu.linkonce.t.*) - _etext = .; - } > main_ram - - .got : - { - _GLOBAL_OFFSET_TABLE_ = .; - *(.got) - } > main_ram - - .got.plt : - { - *(.got.plt) - } > main_ram - - .rodata : - { - . = ALIGN(4); - _frodata = .; - *(.rodata .rodata.* .gnu.linkonce.r.*) - *(.rodata1) - _erodata = .; - } > main_ram - - .data : - { - . = ALIGN(4); - _fdata = .; - *(.data .data.* .gnu.linkonce.d.*) - *(.data1) - *(.sdata .sdata.* .gnu.linkonce.s.*) - _edata = .; - } > main_ram - - .bss : - { - . = ALIGN(4); - _fbss = .; - *(.dynsbss) - *(.sbss .sbss.* .gnu.linkonce.sb.*) - *(.scommon) - *(.dynbss) - *(.bss .bss.* .gnu.linkonce.b.*) - *(COMMON) - . = ALIGN(4); - _ebss = .; - . = ALIGN(8); - _heapstart = .; - } > main_ram -} - -PROVIDE(_fstack = ORIGIN(main_ram) + LENGTH(main_ram) - 4);