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/bootloader/init_bootloader.c | 120 +++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 firmware/zpu/usrp2p/bootloader/init_bootloader.c (limited to 'firmware/zpu/usrp2p/bootloader/init_bootloader.c') diff --git a/firmware/zpu/usrp2p/bootloader/init_bootloader.c b/firmware/zpu/usrp2p/bootloader/init_bootloader.c new file mode 100644 index 000000000..cfa80ffea --- /dev/null +++ b/firmware/zpu/usrp2p/bootloader/init_bootloader.c @@ -0,0 +1,120 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Ettus Research LLC + * + */ + +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include "usrp2/fw_common.h" + +//void pic_interrupt_handler() __attribute__ ((interrupt_handler)); + +void pic_interrupt_handler() +{ + // nop stub +} + +void load_ihex(void) { //simple IHEX parser to load proper records into RAM. loads program when it receives end of record. + char buf[128]; //input data buffer + uint8_t ihx[32]; //ihex data buffer + + ihex_record_t ihex_record; + ihex_record.data = ihx; + + while(1) { + gets(buf); + + if(!ihex_parse(buf, &ihex_record)) { //RAM data record is valid + if(ihex_record.addr >= RAM_BASE) { //it's expecting to see FULLY RELOCATED IHX RECORDS. every address referenced to 0x8000, including vectors. + memcpy((void *) (ihex_record.addr), ihex_record.data, ihex_record.length); + puts("OK"); + } else if(ihex_record.type == 1) { //end of record + puts("OK"); + //load main firmware + 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"); + } +} + +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 + output_regs->leds = 0xFF; + delay(5000); + output_regs->leds = 0x00; + hal_uart_init(); + spif_init(); + i2c_init(); //for EEPROM + puts("USRP2+ bootloader super ultra ZPU edition\n"); + + bool production_image = find_safe_booted_flag(); + set_safe_booted_flag(0); //haven't booted yet + + if(BUTTON_PUSHED) { //see memory_map.h + puts("Starting USRP2+ in safe mode."); + 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(); + puts("ERROR: return from main program! This should never happen!"); + icap_reload_fpga(SAFE_FPGA_IMAGE_LOCATION_ADDR); + } else { + puts("ERROR: no safe firmware image available. I am a brick. Feel free to load IHEX to RAM."); + load_ihex(); + } + } + + if(!production_image) { + puts("Checking for valid production FPGA image..."); + 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 + icap_reload_fpga(PROD_FPGA_IMAGE_LOCATION_ADDR); + } + puts("No valid production FPGA image found.\nAttempting to load production firmware..."); + } + 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); + puts("Finished loading. Starting image."); + delay(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); + icap_reload_fpga(SAFE_FPGA_IMAGE_LOCATION_ADDR); + return 1; + } + 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); + puts("Finished loading. Starting image."); + delay(300); + start_program(); + puts("ERROR: return from main program! This should never happen!"); + delay(300); + icap_reload_fpga(SAFE_FPGA_IMAGE_LOCATION_ADDR); + return 1; + } + puts("ERROR: no safe firmware image available. I am a brick. Feel free to load IHEX to RAM."); + load_ihex(); + + return 0; +} -- 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/bootloader/init_bootloader.c') 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/bootloader/init_bootloader.c') 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 b61cdb8dde9938ffa4ffabc639807e3df6df2621 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 13 Jan 2011 16:34:13 -0800 Subject: usrp2: update copyright dates on firmware code --- firmware/zpu/lib/arp_cache.c | 2 +- firmware/zpu/lib/arp_cache.h | 2 +- firmware/zpu/lib/banal.c | 2 +- firmware/zpu/lib/banal.h | 2 +- firmware/zpu/lib/eth_addrs.c | 2 +- firmware/zpu/lib/ethertype.h | 2 +- firmware/zpu/lib/net/eth_mac_addr.h | 2 +- firmware/zpu/lib/nonstdio.h | 2 +- firmware/zpu/usrp2/sd.c | 2 +- firmware/zpu/usrp2/sd.h | 2 +- firmware/zpu/usrp2p/bootconfig.h | 2 +- firmware/zpu/usrp2p/bootloader/fpga_bootloader.c | 2 +- firmware/zpu/usrp2p/bootloader/fw_bootloader.c | 2 +- firmware/zpu/usrp2p/bootloader/init_bootloader.c | 2 +- firmware/zpu/usrp2p/bootloader/serial_loader_burner.c | 2 +- firmware/zpu/usrp2p/bootloader/spi_bootloader.c | 2 +- firmware/zpu/usrp2p/spi_flash.c | 2 +- firmware/zpu/usrp2p/spi_flash.h | 2 +- firmware/zpu/usrp2p/spi_flash_private.h | 2 +- firmware/zpu/usrp2p/spi_flash_read.c | 2 +- firmware/zpu/usrp2p/spif.c | 2 +- firmware/zpu/usrp2p/xilinx_s3_icap.c | 2 +- firmware/zpu/usrp2p/xilinx_s3_icap.h | 2 +- fix-copyright-years | 15 ++++++++++----- 24 files changed, 33 insertions(+), 28 deletions(-) (limited to 'firmware/zpu/usrp2p/bootloader/init_bootloader.c') diff --git a/firmware/zpu/lib/arp_cache.c b/firmware/zpu/lib/arp_cache.c index 9c586fa6b..8e14d8f17 100644 --- a/firmware/zpu/lib/arp_cache.c +++ b/firmware/zpu/lib/arp_cache.c @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/lib/arp_cache.h b/firmware/zpu/lib/arp_cache.h index 8e84a1f94..e0e125d89 100644 --- a/firmware/zpu/lib/arp_cache.h +++ b/firmware/zpu/lib/arp_cache.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/lib/banal.c b/firmware/zpu/lib/banal.c index 42937957f..dfb8df355 100644 --- a/firmware/zpu/lib/banal.c +++ b/firmware/zpu/lib/banal.c @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/lib/banal.h b/firmware/zpu/lib/banal.h index eb7ed509a..e9e55bca5 100644 --- a/firmware/zpu/lib/banal.h +++ b/firmware/zpu/lib/banal.h @@ -1,6 +1,6 @@ /* -*- c -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/lib/eth_addrs.c b/firmware/zpu/lib/eth_addrs.c index fc35a3c9b..c45ce7559 100644 --- a/firmware/zpu/lib/eth_addrs.c +++ b/firmware/zpu/lib/eth_addrs.c @@ -1,5 +1,5 @@ /* - * Copyright 2010 Ettus Research LLC + * Copyright 2010-2011 Ettus Research LLC * Copyright 2007 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify diff --git a/firmware/zpu/lib/ethertype.h b/firmware/zpu/lib/ethertype.h index 11f4bafec..235981193 100644 --- a/firmware/zpu/lib/ethertype.h +++ b/firmware/zpu/lib/ethertype.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/lib/net/eth_mac_addr.h b/firmware/zpu/lib/net/eth_mac_addr.h index b44fb68f7..01bf91988 100644 --- a/firmware/zpu/lib/net/eth_mac_addr.h +++ b/firmware/zpu/lib/net/eth_mac_addr.h @@ -1,5 +1,5 @@ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/lib/nonstdio.h b/firmware/zpu/lib/nonstdio.h index 2c4aeb961..a47a6df6e 100644 --- a/firmware/zpu/lib/nonstdio.h +++ b/firmware/zpu/lib/nonstdio.h @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // /* * Copyright 2007 Free Software Foundation, Inc. diff --git a/firmware/zpu/usrp2/sd.c b/firmware/zpu/usrp2/sd.c index d000b28ae..d634baea8 100644 --- a/firmware/zpu/usrp2/sd.c +++ b/firmware/zpu/usrp2/sd.c @@ -1,6 +1,6 @@ /* -*- c -*- */ /* - * Copyright 2008 Ettus Research LLC + * Copyright 2008-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/usrp2/sd.h b/firmware/zpu/usrp2/sd.h index e2d0ae38e..e4b4aae8b 100644 --- a/firmware/zpu/usrp2/sd.h +++ b/firmware/zpu/usrp2/sd.h @@ -1,6 +1,6 @@ /* -*- c -*- */ /* - * Copyright 2008 Ettus Research LLC + * Copyright 2008-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/bootconfig.h b/firmware/zpu/usrp2p/bootconfig.h index 35c2726ed..b64834d22 100644 --- a/firmware/zpu/usrp2p/bootconfig.h +++ b/firmware/zpu/usrp2p/bootconfig.h @@ -1,6 +1,6 @@ /* -*- c -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-2011 Ettus Research LLC * * This file is part of GNU Radio * diff --git a/firmware/zpu/usrp2p/bootloader/fpga_bootloader.c b/firmware/zpu/usrp2p/bootloader/fpga_bootloader.c index 9feff6ecd..f5a71a8bb 100644 --- a/firmware/zpu/usrp2p/bootloader/fpga_bootloader.c +++ b/firmware/zpu/usrp2p/bootloader/fpga_bootloader.c @@ -1,6 +1,6 @@ /* -*- c -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/fw_bootloader.c b/firmware/zpu/usrp2p/bootloader/fw_bootloader.c index a2c32bf8e..de561cf22 100644 --- a/firmware/zpu/usrp2p/bootloader/fw_bootloader.c +++ b/firmware/zpu/usrp2p/bootloader/fw_bootloader.c @@ -1,6 +1,6 @@ /* -*- c -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/init_bootloader.c b/firmware/zpu/usrp2p/bootloader/init_bootloader.c index e960fe474..f8b432c46 100644 --- a/firmware/zpu/usrp2p/bootloader/init_bootloader.c +++ b/firmware/zpu/usrp2p/bootloader/init_bootloader.c @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2010 Ettus Research LLC + * Copyright 2010-2011 Ettus Research LLC * */ diff --git a/firmware/zpu/usrp2p/bootloader/serial_loader_burner.c b/firmware/zpu/usrp2p/bootloader/serial_loader_burner.c index 4ac4df454..6d5d135ab 100644 --- a/firmware/zpu/usrp2p/bootloader/serial_loader_burner.c +++ b/firmware/zpu/usrp2p/bootloader/serial_loader_burner.c @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/spi_bootloader.c b/firmware/zpu/usrp2p/bootloader/spi_bootloader.c index 678e66cf7..3e66d41cb 100644 --- a/firmware/zpu/usrp2p/bootloader/spi_bootloader.c +++ b/firmware/zpu/usrp2p/bootloader/spi_bootloader.c @@ -1,6 +1,6 @@ /* -*- c -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/spi_flash.c b/firmware/zpu/usrp2p/spi_flash.c index 09b74a513..25fc239be 100644 --- a/firmware/zpu/usrp2p/spi_flash.c +++ b/firmware/zpu/usrp2p/spi_flash.c @@ -1,7 +1,7 @@ /* -*- c++ -*- */ /* * Copyright 2009 Free Software Foundation, Inc. - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/spi_flash.h b/firmware/zpu/usrp2p/spi_flash.h index 9a04df86b..a10533e08 100644 --- a/firmware/zpu/usrp2p/spi_flash.h +++ b/firmware/zpu/usrp2p/spi_flash.h @@ -1,7 +1,7 @@ /* -*- c -*- */ /* * Copyright 2009 Free Software Foundation, Inc. - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/spi_flash_private.h b/firmware/zpu/usrp2p/spi_flash_private.h index 9a1b8d3e3..6bf06fda8 100644 --- a/firmware/zpu/usrp2p/spi_flash_private.h +++ b/firmware/zpu/usrp2p/spi_flash_private.h @@ -1,7 +1,7 @@ /* -*- c++ -*- */ /* * Copyright 2009 Free Software Foundation, Inc. - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/spi_flash_read.c b/firmware/zpu/usrp2p/spi_flash_read.c index 47a79e7d1..fffc2a671 100644 --- a/firmware/zpu/usrp2p/spi_flash_read.c +++ b/firmware/zpu/usrp2p/spi_flash_read.c @@ -1,7 +1,7 @@ /* -*- c++ -*- */ /* * Copyright 2009 Free Software Foundation, Inc. - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/spif.c b/firmware/zpu/usrp2p/spif.c index 1c1a348f4..91da73155 100644 --- a/firmware/zpu/usrp2p/spif.c +++ b/firmware/zpu/usrp2p/spif.c @@ -1,6 +1,6 @@ /* * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/xilinx_s3_icap.c b/firmware/zpu/usrp2p/xilinx_s3_icap.c index 50c85231c..8995aa23d 100644 --- a/firmware/zpu/usrp2p/xilinx_s3_icap.c +++ b/firmware/zpu/usrp2p/xilinx_s3_icap.c @@ -1,6 +1,6 @@ /* -*- c -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/xilinx_s3_icap.h b/firmware/zpu/usrp2p/xilinx_s3_icap.h index 7b7e9eccc..d4238eee9 100644 --- a/firmware/zpu/usrp2p/xilinx_s3_icap.h +++ b/firmware/zpu/usrp2p/xilinx_s3_icap.h @@ -1,6 +1,6 @@ /* -*- c -*- */ /* - * Copyright 2009 Ettus Research LLC + * Copyright 2009-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/fix-copyright-years b/fix-copyright-years index c6ee16a21..97630041b 100755 --- a/fix-copyright-years +++ b/fix-copyright-years @@ -1,7 +1,7 @@ #!/usr/bin/env python import re -import sys +import optparse import datetime import subprocess import multiprocessing @@ -15,7 +15,7 @@ def get_co_line(lines): if co_line_matcher.match(line): return line, i return None, None -def fix_co_years(files): +def fix_co_years(files, keep_years): for file in files: print file lines = open(file).readlines() @@ -41,6 +41,9 @@ def fix_co_years(files): print ' format error on line %d: "%s"'%(num, line), e continue + #keep years means log years is a superset + if keep_years: log_years = min(co_years+log_years), max(co_years+log_years) + if log_years != co_years: print ' log years: %s != copyright years: %s'%(log_years, co_years) year_now = datetime.datetime.now().year @@ -51,15 +54,17 @@ def fix_co_years(files): open(file, 'w').write(new_text) if __name__ == "__main__": - if len(sys.argv) < 2: print "Usage: %s path/"%sys.argv[0]; exit() + parser = optparse.OptionParser(usage="usage: %prog [options] path") + parser.add_option("-k", "--keep", action="store_true", help="keep copyright years", default=False) + (options, args) = parser.parse_args() #get recursive list of files in the repo - files = command('git', 'ls-tree', '--name-only', 'HEAD', '-r', sys.argv[1]).splitlines() + files = command('git', 'ls-tree', '--name-only', 'HEAD', '-r', args[0]).splitlines() #start n+1 processes to handle the files num_procs = multiprocessing.cpu_count() procs = [multiprocessing.Process( - target=lambda *files: fix_co_years(files), + target=lambda *files: fix_co_years(files, keep_years=options.keep), args=files[num::num_procs], ) for num in range(num_procs)] map(multiprocessing.Process.start, procs) -- cgit v1.2.3