From 22ed61f97815856bf74cec25ae6bca88bfbe5f44 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 22 Dec 2010 19:19:14 -0800 Subject: zpu: renamed the directory for the usrp2 fw to zpu to reflect the cpu type --- firmware/zpu/usrp2p/CMakeLists.txt | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 firmware/zpu/usrp2p/CMakeLists.txt (limited to 'firmware/zpu/usrp2p/CMakeLists.txt') diff --git a/firmware/zpu/usrp2p/CMakeLists.txt b/firmware/zpu/usrp2p/CMakeLists.txt new file mode 100644 index 000000000..41ef8f1dd --- /dev/null +++ b/firmware/zpu/usrp2p/CMakeLists.txt @@ -0,0 +1,48 @@ +# +# Copyright 2010 Ettus Research LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +######################################################################## +INCLUDE(${CMAKE_SOURCE_DIR}/lib/CMakeLists.txt) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +ADD_DEFINITIONS(-DUSRP2P) + +ADD_LIBRARY(libusrp2pfw STATIC + ${COMMON_SRCS} + spif.c + spi_flash.c + spi_flash_read.c + bootloader_utils.c + ethernet.c + xilinx_s3_icap.c + udp_fw_update.c +) + +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) + +ADD_EXECUTABLE(usrp2p_blinkenlights.elf ${CMAKE_SOURCE_DIR}/apps/blinkenlights.c) +TARGET_LINK_LIBRARIES(usrp2p_blinkenlights.elf libusrp2pfw) +GEN_OUTPUTS(usrp2p_blinkenlights.elf) + +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) -- cgit v1.2.3 From ac97f5ba9c07b29840eddc9f3ecfcac5d9926efd Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 9 Jan 2011 20:45:35 -0800 Subject: usrp-n210: firmware changes related to init and bootloader added u2p init file that is called by u2init added spi flash init and added to u2pinit implemented mdelay usage in bootloader --- firmware/zpu/apps/txrx_uhd.c | 10 ------ firmware/zpu/lib/u2_init.c | 7 ++++ firmware/zpu/usrp2p/CMakeLists.txt | 1 + firmware/zpu/usrp2p/bootloader/init_bootloader.c | 20 +++++------ firmware/zpu/usrp2p/spi_flash.h | 23 +++++------- firmware/zpu/usrp2p/spi_flash_read.c | 46 ++++++++++++------------ firmware/zpu/usrp2p/u2p_init.c | 33 +++++++++++++++++ firmware/zpu/usrp2p/u2p_init.h | 18 ++++++++++ 8 files changed, 101 insertions(+), 57 deletions(-) create mode 100644 firmware/zpu/usrp2p/u2p_init.c create mode 100644 firmware/zpu/usrp2p/u2p_init.h (limited to 'firmware/zpu/usrp2p/CMakeLists.txt') diff --git a/firmware/zpu/apps/txrx_uhd.c b/firmware/zpu/apps/txrx_uhd.c index 3fcda8a4e..79f301d42 100644 --- a/firmware/zpu/apps/txrx_uhd.c +++ b/firmware/zpu/apps/txrx_uhd.c @@ -333,16 +333,6 @@ main(void) { u2_init(); -//we do this to see if we should set a default ip addr or not -#ifdef USRP2P - bool safe_fw = find_safe_booted_flag(); - set_safe_booted_flag(0); - if(safe_fw) { - set_default_ip_addr(); - set_default_mac_addr(); - } -#endif - putstr("\nTxRx-UHD-ZPU\n"); print_mac_addr(ethernet_mac_addr()); newline(); print_ip_addr(get_ip_addr()); newline(); diff --git a/firmware/zpu/lib/u2_init.c b/firmware/zpu/lib/u2_init.c index 71bd2c594..db26be538 100644 --- a/firmware/zpu/lib/u2_init.c +++ b/firmware/zpu/lib/u2_init.c @@ -26,6 +26,9 @@ #include "clocks.h" #include "usrp2/fw_common.h" #include "nonstdio.h" +#ifdef USRP2P +#include "u2p_init.h" +#endif /* * We ought to arrange for this to be called before main, but for now, @@ -50,6 +53,10 @@ u2_init(void) i2c_init(); hal_enable_ints(); +#ifdef USRP2P + u2p_init(); +#endif + // flash all leds to let us know board is alive hal_set_led_src(0x0, 0x1f); /* software ctrl */ hal_set_leds(0x0, 0x1f); mdelay(300); diff --git a/firmware/zpu/usrp2p/CMakeLists.txt b/firmware/zpu/usrp2p/CMakeLists.txt index 41ef8f1dd..74d9e233d 100644 --- a/firmware/zpu/usrp2p/CMakeLists.txt +++ b/firmware/zpu/usrp2p/CMakeLists.txt @@ -30,6 +30,7 @@ ADD_LIBRARY(libusrp2pfw STATIC ethernet.c xilinx_s3_icap.c udp_fw_update.c + u2p_init.c ) ADD_SUBDIRECTORY(bootloader) diff --git a/firmware/zpu/usrp2p/bootloader/init_bootloader.c b/firmware/zpu/usrp2p/bootloader/init_bootloader.c index cfa80ffea..f71b0a7b2 100644 --- a/firmware/zpu/usrp2p/bootloader/init_bootloader.c +++ b/firmware/zpu/usrp2p/bootloader/init_bootloader.c @@ -11,6 +11,7 @@ #include #include //#include +#include #include #include #include @@ -49,17 +50,14 @@ void load_ihex(void) { //simple IHEX parser to load proper records into RAM. loa } } -void delay(uint32_t t) { - while(t-- != 0) asm("NOP"); -} - int main(int argc, char *argv[]) { - hal_disable_ints(); // In case we got here via jmp 0x0 + hal_disable_ints(); // In case we got here via jmp 0x0 output_regs->leds = 0xFF; - delay(5000); + mdelay(100); output_regs->leds = 0x00; hal_uart_init(); spif_init(); + spi_flash_init(); i2c_init(); //for EEPROM puts("USRP2+ bootloader super ultra ZPU edition\n"); @@ -85,7 +83,7 @@ int main(int argc, char *argv[]) { if(is_valid_fpga_image(PROD_FPGA_IMAGE_LOCATION_ADDR)) { puts("Valid production FPGA image found. Attempting to boot."); set_safe_booted_flag(1); - delay(300); //so serial output can finish + mdelay(300); //so serial output can finish icap_reload_fpga(PROD_FPGA_IMAGE_LOCATION_ADDR); } puts("No valid production FPGA image found.\nAttempting to load production firmware..."); @@ -94,11 +92,11 @@ int main(int argc, char *argv[]) { puts("Valid production firmware found. Loading..."); spi_flash_read(PROD_FW_IMAGE_LOCATION_ADDR, FW_IMAGE_SIZE_BYTES, (void *)RAM_BASE); puts("Finished loading. Starting image."); - delay(300); + mdelay(300); 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. - delay(300); + mdelay(300); icap_reload_fpga(SAFE_FPGA_IMAGE_LOCATION_ADDR); return 1; } @@ -106,10 +104,10 @@ int main(int argc, char *argv[]) { 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); puts("Finished loading. Starting image."); - delay(300); + mdelay(300); start_program(); puts("ERROR: return from main program! This should never happen!"); - delay(300); + mdelay(300); icap_reload_fpga(SAFE_FPGA_IMAGE_LOCATION_ADDR); return 1; } diff --git a/firmware/zpu/usrp2p/spi_flash.h b/firmware/zpu/usrp2p/spi_flash.h index bbe7b650d..bfecab468 100644 --- a/firmware/zpu/usrp2p/spi_flash.h +++ b/firmware/zpu/usrp2p/spi_flash.h @@ -30,20 +30,15 @@ uint32_t spi_flash_rdid(void); /* Read ID */ uint32_t spi_flash_rdsr(void); /* Read Status Register */ -size_t spi_flash_log2_sector_size(void) __attribute__((pure)); /* either 16 or 18 */ -size_t spi_flash_log2_memory_size(void); - -static inline size_t -spi_flash_sector_size(void) -{ - return ((size_t) 1) << spi_flash_log2_sector_size(); -} - -static inline size_t -spi_flash_memory_size(void) -{ - return ((size_t) 1) << spi_flash_log2_memory_size(); -} + +//! call before using any spi flash utilities +void spi_flash_init(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 75721b0f7..c65b8c1a1 100644 --- a/firmware/zpu/usrp2p/spi_flash_read.c +++ b/firmware/zpu/usrp2p/spi_flash_read.c @@ -21,42 +21,44 @@ #include // abort #include -//FIXME cannot be zero or it gets optimized out and the get size functions break... -#define UNINITIALIZED 0xdeadbeef - uint32_t spi_flash_rdid(void) { return spif_transact(SPI_TXRX, SPI_SS_FLASH, RDID_CMD << 24, 32, FLAGS) & 0xffffff; } -size_t -spi_flash_log2_sector_size(void) -{ - static unsigned char log2_sector_size[3] = { - 16, /* M25P32 */ - 16, /* M25P64 */ - 18, /* M25P128 */ - }; - return log2_sector_size[spi_flash_log2_memory_size() - 22]; -} +static size_t _spi_flash_log2_memory_size, _spi_flash_log2_sector_size; -size_t -spi_flash_log2_memory_size(void) +void spi_flash_init(void) { - static size_t _spi_flash_log2_memory_size = UNINITIALIZED; - - if (_spi_flash_log2_memory_size == UNINITIALIZED){ 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(); - + abort(); _spi_flash_log2_memory_size = size; - } - return _spi_flash_log2_memory_size; + 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; +} + +size_t spi_flash_sector_size(void) +{ + 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; } void diff --git a/firmware/zpu/usrp2p/u2p_init.c b/firmware/zpu/usrp2p/u2p_init.c new file mode 100644 index 000000000..6fe9729ac --- /dev/null +++ b/firmware/zpu/usrp2p/u2p_init.c @@ -0,0 +1,33 @@ +/* + * Copyright 2011 Ettus Research LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#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); + if (safe_fw) { + set_default_ip_addr(); + set_default_mac_addr(); + } +} diff --git a/firmware/zpu/usrp2p/u2p_init.h b/firmware/zpu/usrp2p/u2p_init.h new file mode 100644 index 000000000..b0dc20f1f --- /dev/null +++ b/firmware/zpu/usrp2p/u2p_init.h @@ -0,0 +1,18 @@ +/* + * Copyright 2011 Ettus Research LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +void u2p_init(void); -- cgit v1.2.3 From 2106c6cf594866061f56b09d1396bb80df51802e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 10 Jan 2011 12:23:08 -0800 Subject: usrp2: firmware pad bins to zero to deal with optimizing out the static vars that init to zero removed the spi flash init in favor of an initialization constant at zero tweaked the cmakelists flags list added pad option to the gen binaries macro --- firmware/zpu/CMakeLists.txt | 24 ++++++++-------- firmware/zpu/bin/bin_to_ram_macro_init.py | 5 ++-- firmware/zpu/usrp2/CMakeLists.txt | 4 +-- firmware/zpu/usrp2p/CMakeLists.txt | 6 ++-- firmware/zpu/usrp2p/bootloader/CMakeLists.txt | 4 +-- firmware/zpu/usrp2p/bootloader/init_bootloader.c | 1 - firmware/zpu/usrp2p/spi_flash.h | 6 +--- firmware/zpu/usrp2p/spi_flash_read.c | 35 ++++++++++++------------ firmware/zpu/usrp2p/u2p_init.c | 3 -- 9 files changed, 41 insertions(+), 47 deletions(-) mode change 100755 => 100644 firmware/zpu/bin/bin_to_ram_macro_init.py (limited to 'firmware/zpu/usrp2p/CMakeLists.txt') diff --git a/firmware/zpu/CMakeLists.txt b/firmware/zpu/CMakeLists.txt index f79e48f8a..9a32d1834 100644 --- a/firmware/zpu/CMakeLists.txt +++ b/firmware/zpu/CMakeLists.txt @@ -20,6 +20,7 @@ ######################################################################## CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(CMAKE_C_COMPILER zpu-elf-gcc) +#force the compiler because the check wont use the special flag below SET(CMAKE_C_COMPILER_WORKS TRUE) SET(CMAKE_C_COMPILER_FORCED TRUE) PROJECT(USRP_NXXX_FW C) @@ -40,7 +41,11 @@ INCLUDE_DIRECTORIES( # misc flags for the gcc compiler ######################################################################## SET(CMAKE_C_FLAGS -phi) #always needed compile time and link time -ADD_DEFINITIONS(-Os --std=gnu99 -Wall -Werror-implicit-function-declaration -ffunction-sections) +ADD_DEFINITIONS(-Os) +ADD_DEFINITIONS(--std=gnu99) +ADD_DEFINITIONS(-Wall) +ADD_DEFINITIONS(-Werror-implicit-function-declaration) +ADD_DEFINITIONS(-ffunction-sections) MACRO(ADD_LINKER_FLAGS flags) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flags}") @@ -74,37 +79,32 @@ FIND_PROGRAM(HEXDUMP hexdump) ######################################################################## # helper functions to build output formats ######################################################################## -MACRO(GEN_OUTPUTS target) +MACRO(GEN_OUTPUTS target pad) GET_FILENAME_COMPONENT(name ${target} NAME_WE) #command to create a map from elf ADD_CUSTOM_COMMAND( OUTPUT ${name}.map DEPENDS ${target} - COMMAND ${LINKER} - ARGS -Map ${name}.map ${target} + COMMAND ${LINKER} -Map ${name}.map ${target} ) #command to create a bin from elf ADD_CUSTOM_COMMAND( OUTPUT ${name}.bin DEPENDS ${target} - COMMAND ${OBJCOPY} - ARGS -O binary ${target} ${name}.bin + COMMAND ${OBJCOPY} --pad-to ${pad} -O binary ${target} ${name}.bin ) #command to create a ihx from elf ADD_CUSTOM_COMMAND( OUTPUT ${name}.ihx DEPENDS ${target} - COMMAND ${OBJCOPY} - ARGS -O ihex ${target} ${name}.ihx + COMMAND ${OBJCOPY} --pad-to ${pad} -O ihex ${target} ${name}.ihx ) #command to create a dump from elf ADD_CUSTOM_COMMAND( OUTPUT ${name}.dump DEPENDS ${target} - COMMAND ${OBJDUMP} - ARGS -DSC ${target} > ${name}.dump + COMMAND ${OBJDUMP} -DSC ${target} > ${name}.dump ) #command to create a rom from bin ADD_CUSTOM_COMMAND( OUTPUT ${name}.rom DEPENDS ${name}.bin - COMMAND ${HEXDUMP} - ARGS -v -e'1/1 \"%.2X\\n\"' ${name}.bin > ${name}.rom + COMMAND ${HEXDUMP} -v -e'1/1 \"%.2X\\n\"' ${name}.bin > ${name}.rom ) #add a top level target for output files ADD_CUSTOM_TARGET( diff --git a/firmware/zpu/bin/bin_to_ram_macro_init.py b/firmware/zpu/bin/bin_to_ram_macro_init.py old mode 100755 new mode 100644 index 65cf2dbdf..085045290 --- a/firmware/zpu/bin/bin_to_ram_macro_init.py +++ b/firmware/zpu/bin/bin_to_ram_macro_init.py @@ -12,8 +12,9 @@ def bin_to_ram_macro_init(bin_input_file, ram_init_output_file): ifile = open(bin_input_file, 'rb') ofile = open(ram_init_output_file, 'w') idata = ifile.read() - fmt = ">%dI" % ((len(idata) / 4),) - words = struct.unpack(fmt, idata) + idata_words = len(idata) / 4 + fmt = ">%dI"%idata_words + words = struct.unpack(fmt, idata[:idata_words*4]) # pad to a multiple of 8 words r = len(words) % 8 diff --git a/firmware/zpu/usrp2/CMakeLists.txt b/firmware/zpu/usrp2/CMakeLists.txt index ca5c6d92a..db434567d 100644 --- a/firmware/zpu/usrp2/CMakeLists.txt +++ b/firmware/zpu/usrp2/CMakeLists.txt @@ -28,8 +28,8 @@ ADD_LIBRARY(libusrp2fw STATIC ######################################################################## ADD_EXECUTABLE(usrp2_txrx_uhd.elf ${CMAKE_SOURCE_DIR}/apps/txrx_uhd.c) TARGET_LINK_LIBRARIES(usrp2_txrx_uhd.elf libusrp2fw) -GEN_OUTPUTS(usrp2_txrx_uhd.elf) +GEN_OUTPUTS(usrp2_txrx_uhd.elf 0x3fff) ADD_EXECUTABLE(usrp2_blinkenlights.elf ${CMAKE_SOURCE_DIR}/apps/blinkenlights.c) TARGET_LINK_LIBRARIES(usrp2_blinkenlights.elf libusrp2fw) -GEN_OUTPUTS(usrp2_blinkenlights.elf) +GEN_OUTPUTS(usrp2_blinkenlights.elf 0x3fff) 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); -- cgit v1.2.3 From d52cf5e16d6d3769071da4ae23408ddac300beeb Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 10 Jan 2011 13:36:36 -0800 Subject: usrp2: replaced pad argument to gen bins macro with a setting variable, simplifies code --- firmware/zpu/CMakeLists.txt | 9 ++++++--- firmware/zpu/bin/bin_to_ram_macro_init.py | 0 firmware/zpu/bin/sbf.py | 0 firmware/zpu/usrp2/CMakeLists.txt | 6 ++++-- firmware/zpu/usrp2p/CMakeLists.txt | 8 +++++--- firmware/zpu/usrp2p/bootloader/CMakeLists.txt | 3 ++- 6 files changed, 17 insertions(+), 9 deletions(-) mode change 100644 => 100755 firmware/zpu/bin/bin_to_ram_macro_init.py mode change 100644 => 100755 firmware/zpu/bin/sbf.py (limited to 'firmware/zpu/usrp2p/CMakeLists.txt') diff --git a/firmware/zpu/CMakeLists.txt b/firmware/zpu/CMakeLists.txt index 9a32d1834..2df0a6140 100644 --- a/firmware/zpu/CMakeLists.txt +++ b/firmware/zpu/CMakeLists.txt @@ -79,7 +79,8 @@ FIND_PROGRAM(HEXDUMP hexdump) ######################################################################## # helper functions to build output formats ######################################################################## -MACRO(GEN_OUTPUTS target pad) +SET(GEN_OUTPUTS_BIN_SIZE "bin_size_not_set") #set before calling +MACRO(GEN_OUTPUTS target) GET_FILENAME_COMPONENT(name ${target} NAME_WE) #command to create a map from elf ADD_CUSTOM_COMMAND( @@ -89,12 +90,14 @@ MACRO(GEN_OUTPUTS target pad) #command to create a bin from elf ADD_CUSTOM_COMMAND( OUTPUT ${name}.bin DEPENDS ${target} - COMMAND ${OBJCOPY} --pad-to ${pad} -O binary ${target} ${name}.bin + COMMAND ${OBJCOPY} -O binary ${target} ${name}.bin + --pad-to ${GEN_OUTPUTS_BIN_SIZE} ) #command to create a ihx from elf ADD_CUSTOM_COMMAND( OUTPUT ${name}.ihx DEPENDS ${target} - COMMAND ${OBJCOPY} --pad-to ${pad} -O ihex ${target} ${name}.ihx + COMMAND ${OBJCOPY} -O ihex ${target} ${name}.ihx + --pad-to ${GEN_OUTPUTS_BIN_SIZE} ) #command to create a dump from elf ADD_CUSTOM_COMMAND( diff --git a/firmware/zpu/bin/bin_to_ram_macro_init.py b/firmware/zpu/bin/bin_to_ram_macro_init.py old mode 100644 new mode 100755 diff --git a/firmware/zpu/bin/sbf.py b/firmware/zpu/bin/sbf.py old mode 100644 new mode 100755 diff --git a/firmware/zpu/usrp2/CMakeLists.txt b/firmware/zpu/usrp2/CMakeLists.txt index db434567d..d126c921c 100644 --- a/firmware/zpu/usrp2/CMakeLists.txt +++ b/firmware/zpu/usrp2/CMakeLists.txt @@ -26,10 +26,12 @@ ADD_LIBRARY(libusrp2fw STATIC ) ######################################################################## +SET(GEN_OUTPUTS_BIN_SIZE 0x3fff) + ADD_EXECUTABLE(usrp2_txrx_uhd.elf ${CMAKE_SOURCE_DIR}/apps/txrx_uhd.c) TARGET_LINK_LIBRARIES(usrp2_txrx_uhd.elf libusrp2fw) -GEN_OUTPUTS(usrp2_txrx_uhd.elf 0x3fff) +GEN_OUTPUTS(usrp2_txrx_uhd.elf) ADD_EXECUTABLE(usrp2_blinkenlights.elf ${CMAKE_SOURCE_DIR}/apps/blinkenlights.c) TARGET_LINK_LIBRARIES(usrp2_blinkenlights.elf libusrp2fw) -GEN_OUTPUTS(usrp2_blinkenlights.elf 0x3fff) +GEN_OUTPUTS(usrp2_blinkenlights.elf) diff --git a/firmware/zpu/usrp2p/CMakeLists.txt b/firmware/zpu/usrp2p/CMakeLists.txt index f93924bc0..93ccf82c3 100644 --- a/firmware/zpu/usrp2p/CMakeLists.txt +++ b/firmware/zpu/usrp2p/CMakeLists.txt @@ -36,14 +36,16 @@ ADD_LIBRARY(libusrp2pfw STATIC ADD_SUBDIRECTORY(bootloader) ######################################################################## +SET(GEN_OUTPUTS_BIN_SIZE 0x3fff) + 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 0x3fff) +GEN_OUTPUTS(usrp2p_txrx_uhd.elf) ADD_EXECUTABLE(usrp2p_blinkenlights.elf ${CMAKE_SOURCE_DIR}/apps/blinkenlights.c) TARGET_LINK_LIBRARIES(usrp2p_blinkenlights.elf libusrp2pfw) -GEN_OUTPUTS(usrp2p_blinkenlights.elf 0x3fff) +GEN_OUTPUTS(usrp2p_blinkenlights.elf) 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 0x3fff) +GEN_OUTPUTS(usrp2p_uart_flash_loader.elf) diff --git a/firmware/zpu/usrp2p/bootloader/CMakeLists.txt b/firmware/zpu/usrp2p/bootloader/CMakeLists.txt index 26836726d..155915011 100644 --- a/firmware/zpu/usrp2p/bootloader/CMakeLists.txt +++ b/firmware/zpu/usrp2p/bootloader/CMakeLists.txt @@ -35,5 +35,6 @@ ENDMACRO(GEN_RMI) ######################################################################## ADD_EXECUTABLE(init_bootloader.elf init_bootloader.c) TARGET_LINK_LIBRARIES(init_bootloader.elf libusrp2pfw) -GEN_OUTPUTS(init_bootloader.elf 0x1fff) +SET(GEN_OUTPUTS_BIN_SIZE 0x1fff) +GEN_OUTPUTS(init_bootloader.elf) GEN_RMI(init_bootloader.bin) -- cgit v1.2.3 From 599771914d0848875a0056cd60850eec39b06654 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 11 Jan 2011 12:19:22 -0800 Subject: usrp2: restart read before mode switch, added comments use cmake compiler force macro (to simplify things), added copyright updates dates to some files --- firmware/zpu/CMakeLists.txt | 7 +++---- firmware/zpu/apps/txrx_uhd.c | 2 +- firmware/zpu/lib/pkt_ctrl.c | 16 +++++++--------- firmware/zpu/lib/pkt_ctrl.h | 6 +++--- firmware/zpu/usrp2/CMakeLists.txt | 2 +- firmware/zpu/usrp2p/CMakeLists.txt | 2 +- firmware/zpu/usrp2p/bootloader/CMakeLists.txt | 2 +- host/lib/convert/convert_with_neon.cpp | 1 - 8 files changed, 17 insertions(+), 21 deletions(-) (limited to 'firmware/zpu/usrp2p/CMakeLists.txt') diff --git a/firmware/zpu/CMakeLists.txt b/firmware/zpu/CMakeLists.txt index 2df0a6140..d7cedbfb9 100644 --- a/firmware/zpu/CMakeLists.txt +++ b/firmware/zpu/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,10 +19,9 @@ # setup project and compiler ######################################################################## CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -SET(CMAKE_C_COMPILER zpu-elf-gcc) #force the compiler because the check wont use the special flag below -SET(CMAKE_C_COMPILER_WORKS TRUE) -SET(CMAKE_C_COMPILER_FORCED TRUE) +INCLUDE(CMakeForceCompiler) +CMAKE_FORCE_C_COMPILER(zpu-elf-gcc GNU) PROJECT(USRP_NXXX_FW C) ######################################################################## diff --git a/firmware/zpu/apps/txrx_uhd.c b/firmware/zpu/apps/txrx_uhd.c index ab960dac8..61a2c1f76 100644 --- a/firmware/zpu/apps/txrx_uhd.c +++ b/firmware/zpu/apps/txrx_uhd.c @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // /* * Copyright 2007,2008 Free Software Foundation, Inc. diff --git a/firmware/zpu/lib/pkt_ctrl.c b/firmware/zpu/lib/pkt_ctrl.c index 341ad44e1..2bbe2f843 100644 --- a/firmware/zpu/lib/pkt_ctrl.c +++ b/firmware/zpu/lib/pkt_ctrl.c @@ -1,5 +1,5 @@ /* - * Copyright 2010 Ettus Research LLC + * Copyright 2010-2011 Ettus Research LLC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,7 +18,6 @@ #include "pkt_ctrl.h" #include "memory_map.h" #include -#include //status signals from WB into PR #define CPU_STAT_RD_DONE (1 << 0) @@ -46,13 +45,12 @@ void pkt_ctrl_program_inspector( } void pkt_ctrl_set_routing_mode(pkt_ctrl_routing_mode_t mode){ - mdelay(100); //give a little delay to space out subsequent calls - switch(mode){ - case PKT_CTRL_ROUTING_MODE_SLAVE: router_ctrl->mode_ctrl = 0; break; - case PKT_CTRL_ROUTING_MODE_MASTER: router_ctrl->mode_ctrl = 1; break; - } - router_ctrl->iface_ctrl = CPU_CTRL_WR_CLEAR; //reset the write state machine - pkt_ctrl_release_incoming_buffer(); //reset the read state machine, and read + //About to change the mode; ensure that we are accepting packets. + //The plumbing will not switch if it cannot pass an end of packet. + pkt_ctrl_release_incoming_buffer(); + + //Change the mode; this switches the valves and crossbars. + router_ctrl->mode_ctrl = mode; } static inline void cpu_stat_wait_for(int bm){ diff --git a/firmware/zpu/lib/pkt_ctrl.h b/firmware/zpu/lib/pkt_ctrl.h index 410ffdaa4..15e4b0c4d 100644 --- a/firmware/zpu/lib/pkt_ctrl.h +++ b/firmware/zpu/lib/pkt_ctrl.h @@ -1,5 +1,5 @@ /* - * Copyright 2010 Ettus Research LLC + * Copyright 2010-2011 Ettus Research LLC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,8 +24,8 @@ #include typedef enum { - PKT_CTRL_ROUTING_MODE_SLAVE, - PKT_CTRL_ROUTING_MODE_MASTER, + PKT_CTRL_ROUTING_MODE_SLAVE = 0, + PKT_CTRL_ROUTING_MODE_MASTER = 1 } pkt_ctrl_routing_mode_t; //! Program the decision values into the packet inspector diff --git a/firmware/zpu/usrp2/CMakeLists.txt b/firmware/zpu/usrp2/CMakeLists.txt index d126c921c..e54499084 100644 --- a/firmware/zpu/usrp2/CMakeLists.txt +++ b/firmware/zpu/usrp2/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/firmware/zpu/usrp2p/CMakeLists.txt b/firmware/zpu/usrp2p/CMakeLists.txt index 93ccf82c3..c7ab9abdb 100644 --- a/firmware/zpu/usrp2p/CMakeLists.txt +++ b/firmware/zpu/usrp2p/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/firmware/zpu/usrp2p/bootloader/CMakeLists.txt b/firmware/zpu/usrp2p/bootloader/CMakeLists.txt index 155915011..2c7efb43a 100644 --- a/firmware/zpu/usrp2p/bootloader/CMakeLists.txt +++ b/firmware/zpu/usrp2p/bootloader/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/host/lib/convert/convert_with_neon.cpp b/host/lib/convert/convert_with_neon.cpp index f379f4d29..3d677db5b 100644 --- a/host/lib/convert/convert_with_neon.cpp +++ b/host/lib/convert/convert_with_neon.cpp @@ -16,7 +16,6 @@ // #include "convert_common.hpp" -#include #include using namespace uhd::convert; -- cgit v1.2.3