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/CMakeLists.txt | 39 ++++ firmware/zpu/usrp2p/bootloader/Makefile.am | 39 ++++ firmware/zpu/usrp2p/bootloader/fpga_bootloader.c | 202 +++++++++++++++++++++ firmware/zpu/usrp2p/bootloader/fw_bootloader.c | 50 +++++ firmware/zpu/usrp2p/bootloader/icap_test.c | 31 ++++ firmware/zpu/usrp2p/bootloader/init_bootloader.c | 120 ++++++++++++ .../zpu/usrp2p/bootloader/serial_loader_burner.c | 49 +++++ firmware/zpu/usrp2p/bootloader/spi_bootloader.c | 134 ++++++++++++++ firmware/zpu/usrp2p/bootloader/u2p2-rom.ld | 190 +++++++++++++++++++ 9 files changed, 854 insertions(+) create mode 100644 firmware/zpu/usrp2p/bootloader/CMakeLists.txt create mode 100644 firmware/zpu/usrp2p/bootloader/Makefile.am create mode 100644 firmware/zpu/usrp2p/bootloader/fpga_bootloader.c create mode 100644 firmware/zpu/usrp2p/bootloader/fw_bootloader.c create mode 100644 firmware/zpu/usrp2p/bootloader/icap_test.c create mode 100644 firmware/zpu/usrp2p/bootloader/init_bootloader.c create mode 100644 firmware/zpu/usrp2p/bootloader/serial_loader_burner.c create mode 100644 firmware/zpu/usrp2p/bootloader/spi_bootloader.c create mode 100644 firmware/zpu/usrp2p/bootloader/u2p2-rom.ld (limited to 'firmware/zpu/usrp2p/bootloader') diff --git a/firmware/zpu/usrp2p/bootloader/CMakeLists.txt b/firmware/zpu/usrp2p/bootloader/CMakeLists.txt new file mode 100644 index 000000000..41c86cc9a --- /dev/null +++ b/firmware/zpu/usrp2p/bootloader/CMakeLists.txt @@ -0,0 +1,39 @@ +# +# 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(FindPythonInterp) + +MACRO(GEN_RMI target) + GET_FILENAME_COMPONENT(name ${target} NAME_WE) + #command to create a rmi from elf + 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 + ) + #add a top level target for output files + ADD_CUSTOM_TARGET( + ${name}_rmi ALL DEPENDS ${name}.rmi + ) +ENDMACRO(GEN_RMI) + +######################################################################## +ADD_EXECUTABLE(init_bootloader.elf init_bootloader.c) +TARGET_LINK_LIBRARIES(init_bootloader.elf libusrp2pfw) +GEN_OUTPUTS(init_bootloader.elf) +GEN_RMI(init_bootloader.bin) diff --git a/firmware/zpu/usrp2p/bootloader/Makefile.am b/firmware/zpu/usrp2p/bootloader/Makefile.am new file mode 100644 index 000000000..1fc5daf9c --- /dev/null +++ b/firmware/zpu/usrp2p/bootloader/Makefile.am @@ -0,0 +1,39 @@ +# +# Copyright 2007,2008,2009 Free Software Foundation, Inc. +# +# 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 $(top_srcdir)/Makefile.common + +ROM_LINKER_SCRIPT = u2p2-rom.ld + +# loads into 8K boot ram located at 0x0000_0000 +AM_CFLAGS = $(COMMON_CFLAGS) -I$(top_srcdir)/usrp2p +AM_LDFLAGS = -Wl,-T,$(ROM_LINKER_SCRIPT) $(COMMON_LFLAGS) -Wl,-defsym -Wl,_STACK_SIZE=1024 + +EXTRA_DIST = $(ROM_LINKER_SCRIPT) + +LDADD = $(top_srcdir)/usrp2p/libusrp2p.a + +noinst_PROGRAMS = \ + init_bootloader.elf + +init_bootloader_elf_SOURCES = init_bootloader.c + +.bin.rmi: + $(top_srcdir)/bin/bin_to_ram_macro_init.py $< $@ + +_generated_from_elf += \ + $(noinst_PROGRAMS:.elf=.rmi) diff --git a/firmware/zpu/usrp2p/bootloader/fpga_bootloader.c b/firmware/zpu/usrp2p/bootloader/fpga_bootloader.c new file mode 100644 index 000000000..9feff6ecd --- /dev/null +++ b/firmware/zpu/usrp2p/bootloader/fpga_bootloader.c @@ -0,0 +1,202 @@ +/* -*- c -*- */ +/* + * Copyright 2009 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 . + */ + +/* + * This code is bootloader f/w for the slot 0 fpga image. It's job is + * to figure out which fpga image should be loaded, and then to load + * that image from the SPI flash. (FIXME handle retries, errors, + * etc.) + * + * If the center button is down during boot, it loads firwmare + * from 0:0 instead of its normal action. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define VERBOSE 1 + +#define OUR_FPGA_IMAGE_NUMBER 0 // this code only runs in slot 0 + +void hal_uart_init(void); +void spif_init(void); +void i2c_init(void); +void bootconfig_init(void); + +void pic_interrupt_handler() __attribute__ ((interrupt_handler)); + +void pic_interrupt_handler() +{ + // nop stub +} + +static int +flash_addr_of_fpga_slot(unsigned int fpga_slot) +{ + const struct flashdir *fd = get_flashdir(); + return fd->slot[fpga_slot + fd->fpga_slot0].start << spi_flash_log2_sector_size(); +} + + +/* + * If the first 256 bytes of the image contain the string of bytes, + * ff ff ff ff aa 99 55 66, we consider it a likely bitstream. + */ +static bool +looks_like_a_bitstream(unsigned int fpga_slot) +{ + unsigned char buf[256]; + static const unsigned char pattern[] = { + 0xff, 0xff, 0xff, 0xff, 0xaa, 0x99, 0x55, 0x66 + }; + + // Read the first 256 bytes of the bitstream + spi_flash_read(flash_addr_of_fpga_slot(fpga_slot), sizeof(buf), buf); + + for (int i = 0; i <= sizeof(buf) - sizeof(pattern); i++) + if (memcmp(pattern, &buf[i], sizeof(pattern)) == 0) + return true; + + return false; +} + +static bool +plausible_bootconfig(bootconfig_t bc) +{ + // Are the fields in range? + if (!validate_bootconfig(bc)) + return false; + + if (!looks_like_a_bitstream(map_fpga_image_number_to_fpga_slot(bc.fpga_image_number))) + return false; + + return true; +} + +// Attempt to boot the fpga image specified in next_boot +static void +initial_boot_attempt(eeprom_boot_info_t *ee) +{ + if (ee->next_boot.fpga_image_number == OUR_FPGA_IMAGE_NUMBER){ + load_firmware(); + return; + } + + ee->nattempts = 1; + _bc_write_eeprom_shadow(); + + unsigned int target_slot = + map_fpga_image_number_to_fpga_slot(ee->next_boot.fpga_image_number); + int flash_addr = flash_addr_of_fpga_slot(target_slot); + + putstr("fpga_bootloader: chaining to "); + puthex4(ee->next_boot.fpga_image_number); + putchar(':'); + puthex4(ee->next_boot.firmware_image_number); + newline(); + mdelay(100); + + while (1){ + icap_reload_fpga(flash_addr); + } +} + +int +main(int argc, char **argv) +{ + hal_disable_ints(); // In case we got here via jmp 0x0 + hal_uart_init(); + i2c_init(); + bootconfig_init(); // Must come after i2c_init. + spif_init(); // Needed for get_flashdir. + + sr_leds->leds = 0xAAAA; + + putstr("\n\n>>> fpga_bootloader <<<\n"); + + putstr("\nBOOTSTS "); + int bootsts = icap_read_config_reg(rBOOTSTS); + puthex32_nl(bootsts); + putstr("STAT "); + int stat = icap_read_config_reg(rSTAT); + puthex32_nl(stat); + + bool fallback = + ((bootsts & (BOOTSTS_VALID_0 | BOOTSTS_FALLBACK_0)) + == (BOOTSTS_VALID_0 | BOOTSTS_FALLBACK_0)); + + if (fallback){ + puts("FALLBACK_0 is set"); + // FIXME handle fallback condition. + } + + const struct flashdir *fd = get_flashdir(); + if (fd == 0) + abort(); + + eeprom_boot_info_t *ee = _bc_get_eeprom_shadow(); + + if (VERBOSE){ + putstr("nattempts: "); + puthex8_nl(ee->nattempts); + } + + mdelay(500); // wait for low-pass on switches + putstr("switches: "); puthex32_nl(readback->switches); + + bool center_btn_down = (readback->switches & BTN_CENTER) != 0; + if (center_btn_down){ + putstr("Center button is down!\n"); + // Force boot of image 0:0 + ee->next_boot = make_bootconfig(0, 0); + } + + // if next_boot is valid, try it + if (plausible_bootconfig(ee->next_boot)) + initial_boot_attempt(ee); // no return + + // if default_boot is valid, try it + if (plausible_bootconfig(ee->default_boot)){ + ee->next_boot = ee->default_boot; + initial_boot_attempt(ee); // no return + } + + // If we're here, we're in trouble. Try all of them... + for (int i = 0; i < 4; i++){ + bootconfig_t bc = make_bootconfig(i, 0); + if (plausible_bootconfig(bc)){ + ee->next_boot = bc; + initial_boot_attempt(ee); // no return + } + } + + // FIXME, try to find something we can load + puts("\n!!! Failed to find a valid FPGA bitstream!\n\n"); + + return 0; +} diff --git a/firmware/zpu/usrp2p/bootloader/fw_bootloader.c b/firmware/zpu/usrp2p/bootloader/fw_bootloader.c new file mode 100644 index 000000000..a2c32bf8e --- /dev/null +++ b/firmware/zpu/usrp2p/bootloader/fw_bootloader.c @@ -0,0 +1,50 @@ +/* -*- c -*- */ +/* + * Copyright 2009 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 +#include +#include +#include +#include +#include +#include + + +void hal_uart_init(void); +void spif_init(void); +void i2c_init(void); +void bootconfig_init(void); + +void pic_interrupt_handler() __attribute__ ((interrupt_handler)); + +void pic_interrupt_handler() +{ + // nop stub +} + +int +main(int argc, char **argv) +{ + hal_disable_ints(); // In case we got here via jmp 0x0 + hal_uart_init(); + i2c_init(); + bootconfig_init(); // Must come after i2c_init. + spif_init(); // Needed for get_flashdir. + + load_firmware(); +} diff --git a/firmware/zpu/usrp2p/bootloader/icap_test.c b/firmware/zpu/usrp2p/bootloader/icap_test.c new file mode 100644 index 000000000..5feb9d014 --- /dev/null +++ b/firmware/zpu/usrp2p/bootloader/icap_test.c @@ -0,0 +1,31 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 Ettus Research LLC + * + */ + +#include +#include +#include +#include + +void delay(uint32_t t) { + while(t-- != 0) asm("NOP"); +} + + +int main(int argc, char *argv[]) { + pic_init(); + hal_uart_init(); + puts("\nStarting delay...\n"); + + output_regs->leds = 0xFF; + delay(4000000); + output_regs->leds = 0x00; + delay(4000000); + + puts("Rebooting FPGA to 0x00000000\n"); + icap_reload_fpga((uint32_t)0x00000000); + + return 0; +} 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; +} diff --git a/firmware/zpu/usrp2p/bootloader/serial_loader_burner.c b/firmware/zpu/usrp2p/bootloader/serial_loader_burner.c new file mode 100644 index 000000000..4ac4df454 --- /dev/null +++ b/firmware/zpu/usrp2p/bootloader/serial_loader_burner.c @@ -0,0 +1,49 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 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 +#include +#include +#include + +void hal_uart_init(void); +void spif_init(void); + +void pic_interrupt_handler() __attribute__ ((interrupt_handler)); + +void pic_interrupt_handler() +{ + // nop stub +} + +int +main(int argc, char **argv) +{ + hal_uart_init(); + spif_init(); + + sr_leds->leds = 0; + mdelay(100); + sr_leds->leds = ~0; + mdelay(100); + sr_leds->leds = 0; + + puts("\n\n>>> stage1: serial_loader_burner <<<"); + + gdbstub2_main_loop(); +} diff --git a/firmware/zpu/usrp2p/bootloader/spi_bootloader.c b/firmware/zpu/usrp2p/bootloader/spi_bootloader.c new file mode 100644 index 000000000..678e66cf7 --- /dev/null +++ b/firmware/zpu/usrp2p/bootloader/spi_bootloader.c @@ -0,0 +1,134 @@ +/* -*- c -*- */ +/* + * Copyright 2009 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 +#include +#include +#include +#include +#include +#include + + +void hal_uart_init(void); +void spif_init(void); + +void pic_interrupt_handler() __attribute__ ((interrupt_handler)); + +void pic_interrupt_handler() +{ + // nop stub +} + +static void +error(int e) +{ + putstr("ERR"); + puthex8(e); + newline(); +} + +static void +load(uint32_t flash_addr, uint32_t ram_addr, uint32_t size) +{ + spi_flash_read(flash_addr, size, (void *) ram_addr); +} + +static bool +load_from_slot(const struct flashdir *fd, int fw_slot) +{ + putstr("Loading f/w image "); + putchar('0' + fw_slot); + putstr("... "); + + if (fw_slot >= fd->fw_nslots){ + error(1); + return false; + } + + int slot = fw_slot + fd->fw_slot0; + if (fd->slot[slot].start == 0 || fd->slot[slot].start == 0xffff + || fd->slot[slot].len == 0 || fd->slot[slot].len == 0xffff){ + error(2); + return false; + } + + uint32_t sbf_base = fd->slot[slot].start << spi_flash_log2_sector_size(); + uint32_t sbf_len = fd->slot[slot].len << spi_flash_log2_sector_size(); + uint32_t sbf_offset = 0; + + struct sbf_header sbf; + spi_flash_read(sbf_base, sizeof(struct sbf_header), &sbf); + if (sbf.magic != SBF_MAGIC || sbf.nsections > SBF_MAX_SECTIONS){ + error(3); + return false; + } + sbf_offset += sizeof(struct sbf_header); + + unsigned int i; + for (i = 0; i < sbf.nsections; i++){ + if (sbf_offset + sbf.sec_desc[i].length > sbf_len){ + error(4); + return false; + } + load(sbf_offset + sbf_base, + sbf.sec_desc[i].target_addr, + sbf.sec_desc[i].length); + sbf_offset += sbf.sec_desc[i].length; + } + putstr("Done!"); + + typedef void (*fptr_t)(void); + (*(fptr_t) sbf.entry)(); // almost certainly no return + + return true; +} + +int +main(int argc, char **argv) +{ + hal_uart_init(); + spif_init(); + + sr_leds->leds = 0; + mdelay(100); + sr_leds->leds = ~0; + mdelay(100); + sr_leds->leds = 0; + + putstr("\n>>> spi_bootloader <<<\n"); + + const struct flashdir *fd = get_flashdir(); + if (fd == 0) + abort(); + + while(1){ + int sw; + int fw_slot; + + sw = readback->switches; + fw_slot = sw & 0x7; + + if (!load_from_slot(fd, fw_slot)){ + if (fw_slot != 0){ + putstr("Falling back to slot 0\n"); + load_from_slot(fd, 0); + } + } + } +} diff --git a/firmware/zpu/usrp2p/bootloader/u2p2-rom.ld b/firmware/zpu/usrp2p/bootloader/u2p2-rom.ld new file mode 100644 index 000000000..4c9eaa8e5 --- /dev/null +++ b/firmware/zpu/usrp2p/bootloader/u2p2-rom.ld @@ -0,0 +1,190 @@ +/* + * Same as default, but with bss and stack moved to top 2K of main ram + * Copied from qr-rom.ld + */ + +/* Default linker script, for normal executables */ +OUTPUT_FORMAT("elf32-microblaze", "", "") +/*SEARCH_DIR("/home/eb/build/Xilinx_EDK_GNU_10.1i/mb/release/lin/mb/microblaze-xilinx-elf/lib");*/ + + +ENTRY(_start) +_TEXT_START_ADDR = DEFINED(_TEXT_START_ADDR) ? _TEXT_START_ADDR : 0x50; +_HEAP_SIZE = DEFINED(_HEAP_SIZE) ? _HEAP_SIZE : 0x0; +_STACK_SIZE = DEFINED(_STACK_SIZE) ? _STACK_SIZE : 0x400; +_BSS_START_ADDR = DEFINED(_BSS_START_ADDR) ? _BSS_START_ADDR : 0xF800; +SECTIONS +{ + .vectors.reset 0x0 : { KEEP (*(.vectors.reset)) } = 0 + .vectors.sw_exception 0x8 : { KEEP (*(.vectors.sw_exception)) } = 0 + .vectors.interrupt 0x10 : { KEEP (*(.vectors.interrupt)) } = 0 + .vectors.debug_sw_break 0x18 : { KEEP (*(.vectors.debug_sw_break)) } = 0 + .vectors.hw_exception 0x20 : { KEEP (*(.vectors.hw_exception)) } = 0 + . = _TEXT_START_ADDR; + _ftext = .; + .text : { + *(.text) + *(.text.*) + *(.gnu.linkonce.t.*) + } + _etext = .; + .init : { KEEP (*(.init)) } =0 + .fini : { KEEP (*(.fini)) } =0 + PROVIDE (__CTOR_LIST__ = .); + PROVIDE (___CTOR_LIST__ = .); + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + /* We don't want to include the .ctor section from + from the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + PROVIDE (__CTOR_END__ = .); + PROVIDE (___CTOR_END__ = .); + PROVIDE (__DTOR_LIST__ = .); + PROVIDE (___DTOR_LIST__ = .); + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + PROVIDE (__DTOR_END__ = .); + PROVIDE (___DTOR_END__ = .); + . = ALIGN(4); + _frodata = . ; + .rodata : { + *(.rodata) + *(.rodata.*) + *(.gnu.linkonce.r.*) + CONSTRUCTORS; /* Is this needed? */ + } + _erodata = .; + /* Alignments by 8 to ensure that _SDA2_BASE_ on a word boundary */ + /* Note that .sdata2 and .sbss2 must be contiguous */ + . = ALIGN(8); + _ssrw = .; + .sdata2 : { + *(.sdata2) + *(.sdata2.*) + *(.gnu.linkonce.s2.*) + } + . = ALIGN(4); + .sbss2 : { + PROVIDE (__sbss2_start = .); + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + PROVIDE (__sbss2_end = .); + } + . = ALIGN(8); + _essrw = .; + _ssrw_size = _essrw - _ssrw; + PROVIDE (_SDA2_BASE_ = _ssrw + (_ssrw_size / 2 )); + . = ALIGN(4); + _fdata = .; + .data : { + *(.data) + *(.gnu.linkonce.d.*) + CONSTRUCTORS; /* Is this needed? */ + } + _edata = . ; + /* Added to handle pic code */ + .got : { + *(.got) + } + .got1 : { + *(.got1) + } + .got2 : { + *(.got2) + } + /* Added by Sathya to handle C++ exceptions */ + .eh_frame : { + *(.eh_frame) + } + .jcr : { + *(.jcr) + } + .gcc_except_table : { + *(.gcc_except_table) + } + /* Alignments by 8 to ensure that _SDA_BASE_ on a word boundary */ + /* Note that .sdata and .sbss must be contiguous */ + . = ALIGN(8); + _ssro = .; + .sdata : { + *(.sdata) + *(.sdata.*) + *(.gnu.linkonce.s.*) + } + . = ALIGN(4); + .sbss : { + PROVIDE (__sbss_start = .); + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + PROVIDE (__sbss_end = .); + } + . = ALIGN(8); + _essro = .; + _ssro_size = _essro - _ssro; + PROVIDE (_SDA_BASE_ = _ssro + (_ssro_size / 2 )); + . = _BSS_START_ADDR; + . = ALIGN(4); + _fbss = .; + .bss : { + PROVIDE (__bss_start = .); + *(.bss) + *(.bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(4); + PROVIDE (__bss_end = .); + } + . = ALIGN(4); + .heap : { + _heap = .; + _heap_start = .; + . += _HEAP_SIZE; + _heap_end = .; + } + _end = .; + . = ALIGN(4); + . = 0xFFF0; + .stack : { + /* + _stack_end = .; + . += _STACK_SIZE; + . = ALIGN(8); + _stack = .; + _end = .; + */ + _stack_end = .; + _stack = .; + } + .tdata : { + *(.tdata) + *(.tdata.*) + *(.gnu.linkonce.td.*) + } + .tbss : { + *(.tbss) + *(.tbss.*) + *(.gnu.linkonce.tb.*) + } +} -- cgit v1.2.3 From d34565968a4f764252a492de42c0e8f93f2e7666 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 22 Dec 2010 19:22:10 -0800 Subject: fw: edit readme, removed old files --- firmware/README | 8 +-- firmware/zpu/apps/cruft/Makefile.am | 82 ------------------------------ firmware/zpu/usrp2p/Makefile.am | 71 -------------------------- firmware/zpu/usrp2p/bootloader/Makefile.am | 39 -------------- 4 files changed, 5 insertions(+), 195 deletions(-) delete mode 100644 firmware/zpu/apps/cruft/Makefile.am delete mode 100644 firmware/zpu/usrp2p/Makefile.am delete mode 100644 firmware/zpu/usrp2p/bootloader/Makefile.am (limited to 'firmware/zpu/usrp2p/bootloader') diff --git a/firmware/README b/firmware/README index a010493c8..251486955 100644 --- a/firmware/README +++ b/firmware/README @@ -1,4 +1,6 @@ -This is a placeholder for the firmware code (microblaze and 8051). +######################################################################## +# Firmware for USRP devices +######################################################################## -The layout should have a common library of source and header files. -Each usrp-like will have its own device-specific libs and apps. +fx2 - firmware for USRP1 +zpu - firmware for USRP2 and N Series diff --git a/firmware/zpu/apps/cruft/Makefile.am b/firmware/zpu/apps/cruft/Makefile.am deleted file mode 100644 index a4f79935b..000000000 --- a/firmware/zpu/apps/cruft/Makefile.am +++ /dev/null @@ -1,82 +0,0 @@ -# -# Copyright 2010 Ettus Research LLC -# -# Copyright 2007,2008 Free Software Foundation, Inc. -# -# 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 $(top_srcdir)/Makefile.common - -LDADD = $(top_srcdir)/lib/libu2fw.a - -AM_CFLAGS += -I$(top_srcdir)/../../host/lib/usrp - -noinst_PROGRAMS = txrx_uhd.elf - -# blink_leds \ -# blink_leds2 \ -# buf_ram_test \ -# burn_dbsrx_eeprom \ -# can_i_sub \ -# echo \ -# hello \ -# read_dbids \ -# set_hw_rev \ -# test1 \ -# test_db_spi \ -# test_i2c \ -# test_sd \ -# test_ram \ -# test_phy_comm \ -# test_lsadc \ -# test_lsdac \ -# timer_test \ -# txrx \ -# burnrev30 \ -# burnrev31 \ -# burnrev40 \ -# sd_gentest \ -# sd_bounce -# - -#nononono = \ -# eth_serdes \ -# gen_eth_packets \ -# rcv_eth_packets \ -# tx_standalone \ -# factory_test \ -# serdes_txrx \ -# mimo_tx \ -# mimo_tx_slave \ -# ibs_rx_test \ -# ibs_tx_test - -# tx_drop_SOURCES = tx_drop.c app_common.c -# tx_drop_rate_limited_SOURCES = tx_drop_rate_limited.c app_common.c -# tx_drop2_SOURCES = tx_drop2.c app_common.c -txrx_uhd_elf_SOURCES = txrx_uhd.c -# app_common_v2.c -#factory_test_SOURCES = factory_test.c app_common_v2.c -#eth_serdes_SOURCES = eth_serdes.c app_passthru_v2.c -#serdes_txrx_SOURCES = serdes_txrx.c app_common_v2.c -#mimo_tx_SOURCES = mimo_tx.c mimo_app_common_v2.c -#mimo_tx_slave_SOURCES = mimo_tx_slave.c app_common_v2.c - -#noinst_HEADERS = \ -# app_common_v2.h \ -# app_passthru_v2.h \ -# mimo_app_common_v2.h -# - diff --git a/firmware/zpu/usrp2p/Makefile.am b/firmware/zpu/usrp2p/Makefile.am deleted file mode 100644 index 40766b406..000000000 --- a/firmware/zpu/usrp2p/Makefile.am +++ /dev/null @@ -1,71 +0,0 @@ -# -# 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 $(top_srcdir)/Makefile.common - -AM_CFLAGS = \ - $(COMMON_CFLAGS) \ - -DUSRP2P - -AM_LDFLAGS = \ - $(COMMON_LFLAGS) \ - -Wl,-defsym -Wl,_TEXT_START_ADDR=0x8050 \ - -Wl,-defsym -Wl,_STACK_SIZE=3072 - -LDADD = libusrp2p.a - -#all of this here is to relocate the hardware vectors to somewhere normal. -RELOCATE_ARGS = \ - --change-section-address .vectors.sw_exception+0x8000 \ - --change-section-address .vectors.hw_exception+0x8000 \ - --change-section-address .vectors.interrupt+0x8000 \ - --change-section-address .vectors.reset+0x8000 - -# $(MB_OBJCOPY) -O ihex $< $@ -# the below would work if objcopy weren't written by apes -# $(MB_OBJCOPY) -O ihex -w --change-section-address .vectors*+0x8000 $< $@ -# using the below will throw away the interrupt vectors when they get relocated below 0x0000. -# $(MB_OBJCOPY) -O ihex --change-addresses -0x8000 $< $@ - -######################################################################## -# USRP2P specific library and programs -######################################################################## -noinst_LIBRARIES = libusrp2p.a - -libusrp2p_a_SOURCES = \ - $(COMMON_SRCS) \ - spif.c \ - spi_flash.c \ - spi_flash_read.c \ - bootloader_utils.c \ - ethernet.c \ - xilinx_s3_icap.c \ - udp_fw_update.c - -noinst_PROGRAMS = \ - usrp2p_txrx_uhd.elf \ - usrp2p_blinkenlights.elf \ - usrp2p_uart_flash_loader.elf - -usrp2p_txrx_uhd_elf_SOURCES = \ - $(top_srcdir)/apps/txrx_uhd.c - -usrp2p_blinkenlights_elf_SOURCES = \ - $(top_srcdir)/apps/blinkenlights.c - -usrp2p_uart_flash_loader_elf_SOURCES = \ - $(top_srcdir)/apps/uart_flash_loader.c diff --git a/firmware/zpu/usrp2p/bootloader/Makefile.am b/firmware/zpu/usrp2p/bootloader/Makefile.am deleted file mode 100644 index 1fc5daf9c..000000000 --- a/firmware/zpu/usrp2p/bootloader/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright 2007,2008,2009 Free Software Foundation, Inc. -# -# 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 $(top_srcdir)/Makefile.common - -ROM_LINKER_SCRIPT = u2p2-rom.ld - -# loads into 8K boot ram located at 0x0000_0000 -AM_CFLAGS = $(COMMON_CFLAGS) -I$(top_srcdir)/usrp2p -AM_LDFLAGS = -Wl,-T,$(ROM_LINKER_SCRIPT) $(COMMON_LFLAGS) -Wl,-defsym -Wl,_STACK_SIZE=1024 - -EXTRA_DIST = $(ROM_LINKER_SCRIPT) - -LDADD = $(top_srcdir)/usrp2p/libusrp2p.a - -noinst_PROGRAMS = \ - init_bootloader.elf - -init_bootloader_elf_SOURCES = init_bootloader.c - -.bin.rmi: - $(top_srcdir)/bin/bin_to_ram_macro_init.py $< $@ - -_generated_from_elf += \ - $(noinst_PROGRAMS:.elf=.rmi) -- 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') 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') 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/bootloader') 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/bootloader') 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 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') 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