diff --git a/litex/build/generic_programmer.py b/litex/build/generic_programmer.py index b9540415c..23a9eb12f 100644 --- a/litex/build/generic_programmer.py +++ b/litex/build/generic_programmer.py @@ -17,7 +17,10 @@ class GenericProgrammer: fullname = os.path.join(fulldir, self.flash_proxy_basename) if os.path.exists(fullname): return fullname - raise OSError("Failed to find flash proxy bitstream") + raise OSError( + "Failed to find flash proxy bitstream %s, searched:\n %s\n" % ( + self.flash_proxy_basename, + "\n ".join(self.flash_proxy_dirs))) # must be overloaded by specific programmer def load_bitstream(self, bitstream_file): diff --git a/litex/soc/software/bios/Makefile b/litex/soc/software/bios/Makefile index e00e4a706..6fd21dd27 100644 --- a/litex/soc/software/bios/Makefile +++ b/litex/soc/software/bios/Makefile @@ -12,8 +12,8 @@ all: bios.bin bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS) -%.elf: - $(LD) $(LDFLAGS) -T $< -N -o $@ \ +%.elf: ../libbase/crt0-$(CPU).o ../libnet/libnet.a ../libbase/libbase-nofloat.a ../libcompiler_rt/libcompiler_rt.a + $(LD) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \ ../libbase/crt0-$(CPU).o \ $(OBJECTS) \ -L../libnet \ diff --git a/litex/soc/software/bios/boot.c b/litex/soc/software/bios/boot.c index e0ff8ba95..ed7d3cbaf 100644 --- a/litex/soc/software/bios/boot.c +++ b/litex/soc/software/bios/boot.c @@ -18,7 +18,7 @@ extern void boot_helper(unsigned int r1, unsigned int r2, unsigned int r3, unsig static void __attribute__((noreturn)) boot(unsigned int r1, unsigned int r2, unsigned int r3, unsigned int addr) { - printf("Executing booted program.\n"); + printf("Executing booted program at 0x%08x\n", addr); uart_sync(); irq_setmask(0); irq_setie(0); diff --git a/litex/soc/software/common.mak b/litex/soc/software/common.mak index 7ef85aae7..11e8fc385 100644 --- a/litex/soc/software/common.mak +++ b/litex/soc/software/common.mak @@ -42,7 +42,7 @@ DEPFLAGS += -MD -MP # Toolchain options # INCLUDES = -I$(SOC_DIRECTORY)/software/include/base -I$(SOC_DIRECTORY)/software/include -I$(SOC_DIRECTORY)/common -I$(BUILDINC_DIRECTORY) -COMMONFLAGS = $(DEPFLAGS) -Os $(CPUFLAGS) -fomit-frame-pointer -Wall -fno-builtin -nostdinc $(INCLUDES) +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 LDFLAGS = -nostdlib -nodefaultlibs -L$(BUILDINC_DIRECTORY) diff --git a/litex/soc/software/libbase/crt0-or1k.S b/litex/soc/software/libbase/crt0-or1k.S index 5db4142af..ff77910dc 100644 --- a/litex/soc/software/libbase/crt0-or1k.S +++ b/litex/soc/software/libbase/crt0-or1k.S @@ -19,7 +19,18 @@ #include -#define EXCEPTION_STACK_SIZE (4*32) +/* + * OR1K Architecture has a 128 byte "red zone" after the stack that can not be + * touched by exception handlers. GCC uses this red zone for locals and + * temps without needing to change the stack pointer. + */ +#define OR1K_RED_ZONE_SIZE 128 + +/* + * We need 4 bytes (32 bits) * 32 registers space on the stack to save all the + * registers. + */ +#define EXCEPTION_STACK_SIZE ((4*32) + OR1K_RED_ZONE_SIZE) #define HANDLE_EXCEPTION ; \ l.addi r1, r1, -EXCEPTION_STACK_SIZE ; \