aboutsummaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorNick Foster <nick@nerdnetworks.org>2010-12-15 11:58:02 -0800
committerNick Foster <nick@nerdnetworks.org>2010-12-15 11:58:02 -0800
commit62338938a07123841f9622d69f0f07e4ab9cfcdb (patch)
treeea9d486f4d4a6a441513ae07e606df80a5233b20 /firmware
parent5afdc004a7a1d489af81c5d035aa84a16ac1a353 (diff)
downloaduhd-62338938a07123841f9622d69f0f07e4ab9cfcdb.tar.gz
uhd-62338938a07123841f9622d69f0f07e4ab9cfcdb.tar.bz2
uhd-62338938a07123841f9622d69f0f07e4ab9cfcdb.zip
ZPU: bootloader for 210 mods
Diffstat (limited to 'firmware')
-rw-r--r--firmware/microblaze/usrp2p/bootloader/init_bootloader.c8
-rw-r--r--firmware/microblaze/usrp2p/bootloader_utils.c11
-rw-r--r--firmware/microblaze/usrp2p/bootloader_utils.h6
-rw-r--r--firmware/microblaze/usrp2p/memory_map.h2
4 files changed, 15 insertions, 12 deletions
diff --git a/firmware/microblaze/usrp2p/bootloader/init_bootloader.c b/firmware/microblaze/usrp2p/bootloader/init_bootloader.c
index ab6c70a6b..53b50e34e 100644
--- a/firmware/microblaze/usrp2p/bootloader/init_bootloader.c
+++ b/firmware/microblaze/usrp2p/bootloader/init_bootloader.c
@@ -42,7 +42,7 @@ void load_ihex(void) { //simple IHEX parser to load proper records into RAM. loa
} else if(ihex_record.type == 1) { //end of record
puts("OK");
//load main firmware
- start_program(RAM_BASE);
+ start_program();
puts("ERROR: main image returned! Back in IHEX load mode.");
} else puts("NOK"); //RAM loads do not support extended segment address records (04) -- upper 16 bits are always "0".
} else puts("NOK");
@@ -71,7 +71,7 @@ int main(int argc, char *argv[]) {
if(is_valid_fw_image(SAFE_FW_IMAGE_LOCATION_ADDR)) {
set_safe_booted_flag(1); //let the firmware know it's the safe image
spi_flash_read(SAFE_FW_IMAGE_LOCATION_ADDR, FW_IMAGE_SIZE_BYTES, (void *)RAM_BASE);
- start_program(RAM_BASE);
+ start_program();
puts("ERROR: return from main program! This should never happen!");
icap_reload_fpga(SAFE_FPGA_IMAGE_LOCATION_ADDR);
} else {
@@ -93,7 +93,7 @@ int main(int argc, char *argv[]) {
if(is_valid_fw_image(PROD_FW_IMAGE_LOCATION_ADDR)) {
puts("Valid production firmware found. Loading...");
spi_flash_read(PROD_FW_IMAGE_LOCATION_ADDR, FW_IMAGE_SIZE_BYTES, (void *)RAM_BASE);
- start_program(RAM_BASE);
+ start_program();
puts("ERROR: Return from main program! This should never happen!");
//if this happens, though, the safest thing to do is reboot the whole FPGA and start over.
icap_reload_fpga(SAFE_FPGA_IMAGE_LOCATION_ADDR);
@@ -102,7 +102,7 @@ int main(int argc, char *argv[]) {
puts("No valid production firmware found. Trying safe firmware...");
if(is_valid_fw_image(SAFE_FW_IMAGE_LOCATION_ADDR)) {
spi_flash_read(SAFE_FW_IMAGE_LOCATION_ADDR, FW_IMAGE_SIZE_BYTES, (void *)RAM_BASE);
- start_program(RAM_BASE);
+ start_program();
puts("ERROR: return from main program! This should never happen!");
icap_reload_fpga(SAFE_FPGA_IMAGE_LOCATION_ADDR);
return 1;
diff --git a/firmware/microblaze/usrp2p/bootloader_utils.c b/firmware/microblaze/usrp2p/bootloader_utils.c
index d68fafcb3..d04cffcf6 100644
--- a/firmware/microblaze/usrp2p/bootloader_utils.c
+++ b/firmware/microblaze/usrp2p/bootloader_utils.c
@@ -10,6 +10,7 @@
#include <string.h>
#include <bootloader_utils.h>
#include <spi_flash.h>
+#include <memory_map.h>
int is_valid_fpga_image(uint32_t addr) {
uint8_t imgbuf[64];
@@ -25,15 +26,15 @@ int is_valid_fpga_image(uint32_t addr) {
}
int is_valid_fw_image(uint32_t addr) {
- static const uint8_t fwheader[] = {0x0b 0x0b 0x0b 0x0b 0x80 0x70}; //just lookin for a jump to anywhere located at the reset vector
+ static const uint8_t fwheader[] = {0x0b, 0x0b, 0x0b, 0x0b, 0x80, 0x70}; //just lookin for a jump to anywhere located at the reset vector
uint8_t buf[12];
spi_flash_read(addr, 6, buf);
return memcmp(buf, fwheader, 6) == 0;
}
-void start_program(uint32_t addr)
+void start_program(void)
{
- memcpy(0x00000000, addr+0x00000000, 0x3f); //copy the reset vector and interrupt vector
- typedef void (*fptr_t)(void);
- (*(fptr_t) 0x00000000)(); // most likely no return
+ //ignoring the addr now
+ //all this does is tap that register
+ *((volatile uint32_t *) SR_ADDR_BLDRDONE) = 1;
}
diff --git a/firmware/microblaze/usrp2p/bootloader_utils.h b/firmware/microblaze/usrp2p/bootloader_utils.h
index f597c0113..9fdeebf17 100644
--- a/firmware/microblaze/usrp2p/bootloader_utils.h
+++ b/firmware/microblaze/usrp2p/bootloader_utils.h
@@ -9,8 +9,8 @@
//we're working in bytes and byte addresses so we can run the same code with Flash chips of different sector sizes.
//it's really 1463736, but rounded up to 1.5MB
#define FPGA_IMAGE_SIZE_BYTES 1572864
-//instead of 32K, we write 31K because we're using the top 1K for stack space!
-#define FW_IMAGE_SIZE_BYTES 31744
+//16K
+#define FW_IMAGE_SIZE_BYTES 16384
#define SAFE_FPGA_IMAGE_LOCATION_ADDR 0x00000000
#define SAFE_FW_IMAGE_LOCATION_ADDR 0x003F0000
@@ -19,4 +19,4 @@
int is_valid_fpga_image(uint32_t addr);
int is_valid_fw_image(uint32_t addr);
-void start_program(uint32_t addr);
+void start_program(void);
diff --git a/firmware/microblaze/usrp2p/memory_map.h b/firmware/microblaze/usrp2p/memory_map.h
index 51e4b9413..659ded0b5 100644
--- a/firmware/microblaze/usrp2p/memory_map.h
+++ b/firmware/microblaze/usrp2p/memory_map.h
@@ -238,6 +238,8 @@ hwconfig_wishbone_divisor(void)
#define _SR_ADDR(sr) (MISC_OUTPUT_BASE + (sr) * sizeof(uint32_t))
+#define SR_ADDR_BLDRDONE _SR_ADDR(5)
+
// --- buffer pool control regs ---
typedef struct {