diff options
author | Nick Foster <nick@nerdnetworks.org> | 2010-10-07 18:09:53 -0700 |
---|---|---|
committer | Nick Foster <nick@nerdnetworks.org> | 2010-10-07 18:09:53 -0700 |
commit | c205cd329b37f24060ff20c23bc91249969502a1 (patch) | |
tree | ac22251643a2ad98f5ebc92414d9334365d10348 /firmware/microblaze/usrp2p/bootloader_utils.c | |
parent | b6dae16e5bbddf1fcb9bc77a526f912a15cabbae (diff) | |
download | uhd-c205cd329b37f24060ff20c23bc91249969502a1.tar.gz uhd-c205cd329b37f24060ff20c23bc91249969502a1.tar.bz2 uhd-c205cd329b37f24060ff20c23bc91249969502a1.zip |
U2P: Bootloader/ICAP updates. 2-stage bootloader works. Uses EEPROM for state info.
Diffstat (limited to 'firmware/microblaze/usrp2p/bootloader_utils.c')
-rw-r--r-- | firmware/microblaze/usrp2p/bootloader_utils.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/firmware/microblaze/usrp2p/bootloader_utils.c b/firmware/microblaze/usrp2p/bootloader_utils.c index 00893db02..fadd225bb 100644 --- a/firmware/microblaze/usrp2p/bootloader_utils.c +++ b/firmware/microblaze/usrp2p/bootloader_utils.c @@ -5,16 +5,23 @@ */ //contains routines for loading programs from Flash. depends on Flash libraries. +//also contains routines for reading / writing EEPROM flags for the bootloader +#include <stdbool.h> #include <string.h> #include <bootloader_utils.h> #include <spi_flash.h> - int is_valid_fpga_image(uint32_t addr) { - static const uint8_t fpgaheader[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0x99}; //AA 99 is the standard Xilinx sync sequence, and it's always prefixed with 0xFF padding - uint8_t buf[10]; - spi_flash_read(addr, 6, buf); - return memcmp(buf, fpgaheader, 6) == 0; + uint8_t imgbuf[64]; + spi_flash_read(addr, 64, imgbuf); + //we're just looking for leading 0xFF padding, followed by the sync bytes 0xAA 0x99 + int i = 0; + for(i; i<63; i++) { + if(imgbuf[i] == 0xFF) continue; + if(imgbuf[i] == 0xAA && imgbuf[i+1] == 0x99) return 1; + } + + return 0; } int is_valid_fw_image(uint32_t addr) { @@ -30,4 +37,3 @@ void start_program(uint32_t addr) typedef void (*fptr_t)(void); (*(fptr_t) 0x00000000)(); // most likely no return } - |