""".format(platform_name, args.target, top_class.__name__)
linker_header = cpuif.get_linker_regions(soc.cpu_memory_regions)
write_to_file("software/include/generated/regions.ld", boilerplate + linker_header)
+ try:
+ flash_boot_address = soc.flash_boot_address
+ except AttributeError:
+ flash_boot_address = None
+ mem_header = cpuif.get_mem_header(soc.cpu_memory_regions, flash_boot_address)
+ write_to_file("software/include/generated/mem.h", boilerplate + mem_header)
csr_header = cpuif.get_csr_header(soc.csr_base, soc.csrbankarray, soc.interrupt_map)
write_to_file("software/include/generated/csr.h", boilerplate + csr_header)
if hasattr(soc, "ddrphy"):
r += "}\n"
return r
+def get_mem_header(regions, flash_boot_address):
+ r = "#ifndef __GENERATED_MEM_H\n#define __GENERATED_MEM_H\n\n"
+ for name, base, size in regions:
+ r += "#define {name}_BASE 0x{base:08x}\n#define {name}_SIZE 0x{size:08x}\n\n".format(name=name.upper(), base=base, size=size)
+ if flash_boot_address is not None:
+ r += "#define FLASH_BOOT_ADDRESS 0x{:08x}\n\n".format(flash_boot_address)
+ r += "#endif\n"
+ return r
+
def _get_rw_functions(reg_name, reg_base, size, read_only):
r = ""
#include <string.h>
#include <irq.h>
-#include <hw/mem.h>
+#include <generated/mem.h>
#include <generated/csr.h>
#include <net/microudp.h>
#endif
+#ifdef FLASH_BOOT_ADDRESS
void flashboot(void)
{
unsigned int *flashbase;
unsigned int got_crc;
printf("Booting from flash...\n");
- flashbase = (unsigned int *)FLASH_OFFSET_APP;
+ flashbase = (unsigned int *)FLASH_BOOT_ADDRESS;
length = *flashbase++;
crc = *flashbase++;
if((length < 32) || (length > 4*1024*1024)) {
}
boot(0, 0, 0, SDRAM_BASE);
}
+#endif
#include <crc.h>
#include <generated/csr.h>
+#include <generated/mem.h>
#include <net/microudp.h>
#include "sdram.h"
puts("netboot - boot via TFTP");
#endif
puts("serialboot - boot via SFL");
+#ifdef FLASH_BOOT_ADDRESS
puts("flashboot - boot from flash");
+#endif
puts("revision - display revision");
}
else if(strcmp(token, "crc") == 0) crc(get_token(&c), get_token(&c));
else if(strcmp(token, "flushl2") == 0) flush_l2_cache();
+#ifdef FLASH_BOOT_ADDRESS
else if(strcmp(token, "flashboot") == 0) flashboot();
+#endif
else if(strcmp(token, "serialboot") == 0) serialboot();
#ifdef MINIMAC_BASE
else if(strcmp(token, "netboot") == 0) netboot();
static void boot_sequence(void)
{
if(test_user_abort()) {
+#ifdef FLASH_BOOT_ADDRESS
flashboot();
+#endif
serialboot();
#ifdef MINIMAC_BASE
netboot();
#include <stdlib.h>
#include <generated/sdram_phy.h>
+#include <generated/mem.h>
#include <hw/flags.h>
-#include <hw/mem.h>
#include "sdram.h"
+++ /dev/null
-#ifndef __HW_MEM_H
-#define __HW_MEM_H
-
-/* TODO: those FLASH_ defines are platform-dependent, generate them from SoC description */
-#define FLASH_OFFSET_BITSTREAM 0x00000000 /* 1536k */
-#define FLASH_OFFSET_BIOS 0x00180000 /* 128k */
-#define FLASH_OFFSET_APP 0x001A0000 /* remaining space */
-
-#define FLASH_BLOCK_SIZE (128*1024)
-
-#define SDRAM_BASE 0x40000000
-
-#define MINIMAC_RX0_BASE 0xb0000000
-#define MINIMAC_RX1_BASE 0xb0000800
-#define MINIMAC_TX_BASE 0xb0001000
-
-#endif /* __HW_MEM_H */
--- /dev/null
+#ifndef __HW_MINIMAC_MEM_H
+#define __HW_MINIMAC_MEM_H
+
+#include <generated/mem.h>
+
+#define MINIMAC_RX0_BASE MINIMAC_BASE
+#define MINIMAC_RX1_BASE (MINIMAC_BASE+0x0800)
+#define MINIMAC_TX_BASE (MINIMAC_BASE+0x1000)
+
+#endif
#include <uart.h>
#include <system.h>
-#include <hw/mem.h>
+#include <generated/mem.h>
#include <generated/csr.h>
void flush_cpu_icache(void)
#include <system.h>
#include <crc.h>
#include <hw/flags.h>
-#include <hw/mem.h>
+#include <hw/minimac_mem.h>
#include <net/microudp.h>
#include <stdio.h>
#include <string.h>
-#include <hw/mem.h>
+#include <generated/mem.h>
#include "config.h"
-#define FLASH_OFFSET_CONFIG (FLASH_OFFSET_APP + FLASH_BLOCK_SIZE)
+#define FLASH_BLOCK_SIZE (128*1024)
+#define FLASH_OFFSET_CONFIG (FLASH_BOOT_ADDRESS + FLASH_BLOCK_SIZE)
static volatile unsigned short *flash_config = (unsigned short *)(0x80000000 | FLASH_OFFSET_CONFIG);
# Wishbone
self.submodules.norflash = norflash16.NorFlash16(platform.request("norflash"),
self.ns(110), self.ns(50))
- self.submodules.minimac = minimac3.MiniMAC(platform.request("eth"))
+ self.flash_boot_address = 0x001a0000
self.register_rom(self.norflash.bus)
+
+ self.submodules.minimac = minimac3.MiniMAC(platform.request("eth"))
self.add_wb_slave(lambda a: a[26:29] == 3, self.minimac.membus)
+ self.add_cpu_memory_region("minimac_mem", 0xb0000000, 0x1800)
# CSR
self.submodules.crg = mxcrg.MXCRG(_MXClockPads(platform), self.clk_freq)