diff options
Diffstat (limited to 'firmware/zpu/usrp2p')
-rw-r--r-- | firmware/zpu/usrp2p/CMakeLists.txt | 6 | ||||
-rw-r--r-- | firmware/zpu/usrp2p/bootloader/CMakeLists.txt | 4 | ||||
-rw-r--r-- | firmware/zpu/usrp2p/bootloader/init_bootloader.c | 1 | ||||
-rw-r--r-- | firmware/zpu/usrp2p/spi_flash.h | 6 | ||||
-rw-r--r-- | firmware/zpu/usrp2p/spi_flash_read.c | 35 | ||||
-rw-r--r-- | firmware/zpu/usrp2p/u2p_init.c | 3 |
6 files changed, 24 insertions, 31 deletions
diff --git a/firmware/zpu/usrp2p/CMakeLists.txt b/firmware/zpu/usrp2p/CMakeLists.txt index 74d9e233d..f93924bc0 100644 --- a/firmware/zpu/usrp2p/CMakeLists.txt +++ b/firmware/zpu/usrp2p/CMakeLists.txt @@ -38,12 +38,12 @@ ADD_SUBDIRECTORY(bootloader) ######################################################################## ADD_EXECUTABLE(usrp2p_txrx_uhd.elf ${CMAKE_SOURCE_DIR}/apps/txrx_uhd.c) TARGET_LINK_LIBRARIES(usrp2p_txrx_uhd.elf libusrp2pfw) -GEN_OUTPUTS(usrp2p_txrx_uhd.elf) +GEN_OUTPUTS(usrp2p_txrx_uhd.elf 0x3fff) ADD_EXECUTABLE(usrp2p_blinkenlights.elf ${CMAKE_SOURCE_DIR}/apps/blinkenlights.c) TARGET_LINK_LIBRARIES(usrp2p_blinkenlights.elf libusrp2pfw) -GEN_OUTPUTS(usrp2p_blinkenlights.elf) +GEN_OUTPUTS(usrp2p_blinkenlights.elf 0x3fff) ADD_EXECUTABLE(usrp2p_uart_flash_loader.elf ${CMAKE_SOURCE_DIR}/apps/uart_flash_loader.c) TARGET_LINK_LIBRARIES(usrp2p_uart_flash_loader.elf libusrp2pfw) -GEN_OUTPUTS(usrp2p_uart_flash_loader.elf) +GEN_OUTPUTS(usrp2p_uart_flash_loader.elf 0x3fff) diff --git a/firmware/zpu/usrp2p/bootloader/CMakeLists.txt b/firmware/zpu/usrp2p/bootloader/CMakeLists.txt index 41c86cc9a..26836726d 100644 --- a/firmware/zpu/usrp2p/bootloader/CMakeLists.txt +++ b/firmware/zpu/usrp2p/bootloader/CMakeLists.txt @@ -24,7 +24,7 @@ MACRO(GEN_RMI target) ADD_CUSTOM_COMMAND( OUTPUT ${name}.rmi DEPENDS ${name}.bin COMMAND ${PYTHON_EXECUTABLE} - ARGS ${CMAKE_SOURCE_DIR}/bin/bin_to_ram_macro_init.py ${name}.bin ${name}.rmi + ${CMAKE_SOURCE_DIR}/bin/bin_to_ram_macro_init.py ${name}.bin ${name}.rmi ) #add a top level target for output files ADD_CUSTOM_TARGET( @@ -35,5 +35,5 @@ ENDMACRO(GEN_RMI) ######################################################################## ADD_EXECUTABLE(init_bootloader.elf init_bootloader.c) TARGET_LINK_LIBRARIES(init_bootloader.elf libusrp2pfw) -GEN_OUTPUTS(init_bootloader.elf) +GEN_OUTPUTS(init_bootloader.elf 0x1fff) GEN_RMI(init_bootloader.bin) diff --git a/firmware/zpu/usrp2p/bootloader/init_bootloader.c b/firmware/zpu/usrp2p/bootloader/init_bootloader.c index f71b0a7b2..e960fe474 100644 --- a/firmware/zpu/usrp2p/bootloader/init_bootloader.c +++ b/firmware/zpu/usrp2p/bootloader/init_bootloader.c @@ -57,7 +57,6 @@ int main(int argc, char *argv[]) { output_regs->leds = 0x00; hal_uart_init(); spif_init(); - spi_flash_init(); i2c_init(); //for EEPROM puts("USRP2+ bootloader super ultra ZPU edition\n"); diff --git a/firmware/zpu/usrp2p/spi_flash.h b/firmware/zpu/usrp2p/spi_flash.h index bfecab468..9a04df86b 100644 --- a/firmware/zpu/usrp2p/spi_flash.h +++ b/firmware/zpu/usrp2p/spi_flash.h @@ -31,13 +31,9 @@ uint32_t spi_flash_rdid(void); /* Read ID */ uint32_t spi_flash_rdsr(void); /* Read Status Register */ -//! call before using any spi flash utilities -void spi_flash_init(void); - +size_t spi_flash_log2_memory_size(void); size_t spi_flash_log2_sector_size(void); - size_t spi_flash_sector_size(void); - size_t spi_flash_memory_size(void); void spi_flash_read(uint32_t flash_addr, size_t nbytes, void *buf); diff --git a/firmware/zpu/usrp2p/spi_flash_read.c b/firmware/zpu/usrp2p/spi_flash_read.c index c65b8c1a1..47a79e7d1 100644 --- a/firmware/zpu/usrp2p/spi_flash_read.c +++ b/firmware/zpu/usrp2p/spi_flash_read.c @@ -27,38 +27,39 @@ spi_flash_rdid(void) return spif_transact(SPI_TXRX, SPI_SS_FLASH, RDID_CMD << 24, 32, FLAGS) & 0xffffff; } -static size_t _spi_flash_log2_memory_size, _spi_flash_log2_sector_size; - -void spi_flash_init(void) +size_t spi_flash_log2_memory_size(void) { - uint32_t id = spi_flash_rdid(); - uint8_t type = (id >> 8) & 0xff; - uint8_t size = (id >> 0) & 0xff; - if (type != 0x20 || size < 22 || size > 24) - abort(); - _spi_flash_log2_memory_size = size; + static size_t _spi_flash_log2_memory_size = 0; + if (_spi_flash_log2_memory_size == 0){ + uint32_t id = spi_flash_rdid(); + uint8_t type = (id >> 8) & 0xff; + uint8_t size = (id >> 0) & 0xff; + if (type != 0x20) abort(); + _spi_flash_log2_memory_size = size; + } + if (_spi_flash_log2_memory_size < 22 || + _spi_flash_log2_memory_size > 24 ) abort(); + return _spi_flash_log2_memory_size; +} +size_t spi_flash_log2_sector_size(void) +{ static unsigned char log2_sector_size[3] = { 16, /* M25P32 */ 16, /* M25P64 */ 18, /* M25P128 */ }; - _spi_flash_log2_sector_size = log2_sector_size[_spi_flash_log2_memory_size - 22]; -} - -size_t spi_flash_log2_sector_size(void) -{ - return _spi_flash_log2_sector_size; + return log2_sector_size[spi_flash_log2_memory_size() - 22]; } size_t spi_flash_sector_size(void) { - return ((size_t) 1) << _spi_flash_log2_sector_size; + return ((size_t) 1) << spi_flash_log2_sector_size(); } size_t spi_flash_memory_size(void) { - return ((size_t) 1) << _spi_flash_log2_memory_size; + return ((size_t) 1) << spi_flash_log2_memory_size(); } void diff --git a/firmware/zpu/usrp2p/u2p_init.c b/firmware/zpu/usrp2p/u2p_init.c index 6fe9729ac..381987ae6 100644 --- a/firmware/zpu/usrp2p/u2p_init.c +++ b/firmware/zpu/usrp2p/u2p_init.c @@ -16,13 +16,10 @@ */ #include "u2p_init.h" -#include "spi_flash.h" #include "i2c.h" #include "ethernet.h" void u2p_init(void){ - spi_flash_init(); - //we do this to see if we should set a default ip addr or not bool safe_fw = find_safe_booted_flag(); set_safe_booted_flag(0); |