From 081714b4ce40701067e5513127dd9b9322cbfa5d Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 12 Jan 2012 11:03:43 -0800 Subject: B100 firmware changes to allow slave mode TX/RX. --- firmware/fx2/b100/usrp_common.c | 17 +++-- firmware/fx2/b100/usrp_main.c | 159 +++++++++------------------------------- firmware/fx2/b100/usrp_regs.h | 28 ------- firmware/fx2/common/fx2regs.h | 17 ++++- 4 files changed, 59 insertions(+), 162 deletions(-) (limited to 'firmware') diff --git a/firmware/fx2/b100/usrp_common.c b/firmware/fx2/b100/usrp_common.c index 4b6dde881..7aedce9f7 100644 --- a/firmware/fx2/b100/usrp_common.c +++ b/firmware/fx2/b100/usrp_common.c @@ -32,12 +32,11 @@ init_usrp (void) CPUCS = bmCLKSPD1; // CPU runs @ 48 MHz CKCON = 0; // MOVX takes 2 cycles - // IFCLK is generated internally and runs at 48 MHz; GPIF "master mode" - - IFCONFIG = bmIFCLKSRC | bm3048MHZ | bmIFCLKOE | bmIFCLKPOL | bmIFGPIF; + // IFCLK is generated internally and runs at 48 MHz; slave FIFO mode + IFCONFIG = bmIFCLKSRC | bm3048MHZ | bmIFCLKOE | bmIFSLAVE; SYNCDELAY; - // configure IO ports (B and D are used by GPIF) + // configure IO ports (B and D are used by slave FIFO) IOA = bmPORT_A_INITIAL; // Port A initial state OEA = bmPORT_A_OUTPUTS; // Port A direction register @@ -77,23 +76,25 @@ init_usrp (void) EP2FIFOCFG = bmWORDWIDE; SYNCDELAY; EP2FIFOCFG = bmAUTOOUT | bmWORDWIDE; SYNCDELAY; - EP6FIFOCFG = bmZEROLENIN | bmWORDWIDE; SYNCDELAY; + EP6FIFOCFG = bmZEROLENIN | bmWORDWIDE; SYNCDELAY; + EP6FIFOCFG = bmZEROLENIN | bmAUTOIN | bmWORDWIDE; SYNCDELAY; //EP6FIFOCFG = bmWORDWIDE; SYNCDELAY; EP4FIFOCFG = bmWORDWIDE; SYNCDELAY; EP4FIFOCFG = bmAUTOOUT | bmWORDWIDE; SYNCDELAY; - EP8FIFOCFG = bmAUTOIN | bmWORDWIDE; SYNCDELAY; + EP8FIFOCFG = bmZEROLENIN | bmWORDWIDE; SYNCDELAY; + EP8FIFOCFG = bmZEROLENIN | bmAUTOIN | bmWORDWIDE; SYNCDELAY; EP0BCH = 0; SYNCDELAY; // arm EP1OUT so we can receive "out" packets (TRM pg 8-8) EP1OUTBC = 0; SYNCDELAY; - +/* EP2GPIFFLGSEL = 0x00; SYNCDELAY; // For EP2OUT, GPIF uses EF flag EP6GPIFFLGSEL = 0x00; SYNCDELAY; // For EP6IN, GPIF uses FF flag EP4GPIFFLGSEL = 0x00; SYNCDELAY; EP8GPIFFLGSEL = 0x00; SYNCDELAY; - +*/ // set autoin length for EP6 // FIXME should be f(enumeration) diff --git a/firmware/fx2/b100/usrp_main.c b/firmware/fx2/b100/usrp_main.c index 391a6d94f..45fa60ae9 100644 --- a/firmware/fx2/b100/usrp_main.c +++ b/firmware/fx2/b100/usrp_main.c @@ -21,7 +21,6 @@ #include "usrp_common.h" #include "usrp_commands.h" #include "fpga.h" -#include "usrp_gpif_inline.h" #include "timer.h" #include "i2c.h" #include "isr.h" @@ -64,7 +63,7 @@ bit enable_gpif = 0; #define USRP_HASH_SIZE 16 xdata at USRP_HASH_SLOT_1_ADDR unsigned char hash1[USRP_HASH_SIZE]; -void clear_fpga_data_fifo(void); +//void clear_fpga_data_fifo(void); static void get_ep0_data (void) @@ -175,12 +174,10 @@ app_vendor_cmd (void) break; case VRQ_ENABLE_GPIF: - enable_gpif = (wValueL != 0) ? 1 : 0; - set_led_1(enable_gpif); break; case VRQ_CLEAR_FPGA_FIFO: - clear_fpga_data_fifo(); + //clear_fpga_data_fifo(); break; default: @@ -194,125 +191,12 @@ app_vendor_cmd (void) return 1; } -static int short_pkt_state = 0; -#define SHORT_PACKET_DETECTED (short_pkt_state != bitSHORT_PACKET_SIGNAL) - -//yes, this is a little opaque -//basically this is necessary because while all the logic to inform the FPGA -//of what we're trying to do via the CTL pins is contained within the flowstates, -//we need to assert the endpoint select pin one clock cycle before the flowstate starts. -//this is the job of the wave descriptor. rather than switch between waves, since that -//involves a little more setup, we just modify the wave table on the fly. -inline static void setup_wave_data_read(void) { - GPIF_WAVE_DATA[80] = 0x06; - GPIF_WAVE_DATA[81] = 0x06; -} - -inline static void setup_wave_ctrl_read(void) { - GPIF_WAVE_DATA[80] = 0x0E; - GPIF_WAVE_DATA[81] = 0x0E; -} - -inline static void setup_wave_data_write(void) { - GPIF_WAVE_DATA[112] = 0x00; - GPIF_WAVE_DATA[113] = 0x00; -} - -inline static void setup_wave_ctrl_write(void) { - GPIF_WAVE_DATA[112] = 0x08; - GPIF_WAVE_DATA[113] = 0x08; -} - -inline static void handle_data_write(void) { - GPIFTCB1 = 0x01; //SYNCDELAY; - GPIFTCB0 = 0x00; - setup_flowstate_data_write (); - setup_wave_data_write(); - GPIFTRIG = bmGPIF_EP2_START | bmGPIF_WRITE; // start the xfer - SYNCDELAY; - while (!(GPIFTRIG & bmGPIF_IDLE)); -} - -inline static void handle_ctrl_write(void) { - GPIFTCB1 = 0x00; - GPIFTCB0 = 0x10; - setup_flowstate_ctrl_write (); - setup_wave_ctrl_write(); - GPIFTRIG = bmGPIF_EP4_START | bmGPIF_WRITE; // start the xfer - SYNCDELAY; - while (!(GPIFTRIG & bmGPIF_IDLE)); -} - -inline static void handle_data_read(void) { - GPIFTCB1 = 0x01; - GPIFTCB0 = 0x00; - setup_flowstate_data_read (); - setup_wave_data_read(); - short_pkt_state = bitSHORT_PACKET_SIGNAL; - GPIFTRIG = bmGPIF_EP6_START | bmGPIF_READ; // start the xfer - SYNCDELAY; - while (!(GPIFTRIG & bmGPIF_IDLE)); - INPKTEND = 0x06; // tell USB we filled buffer (6 is our endpoint num) - SYNCDELAY; - if(SHORT_PACKET_DETECTED) { - while(!(EP6CS & bmEPEMPTY)); //wait for packet to send - INPKTEND = 0x06; //send a ZLP - //toggle_led_1(); //FIXME DEBUG - } -} - -inline static void handle_ctrl_read(void) { - GPIFTCB1 = 0x00; - GPIFTCB0 = 0x10; - setup_flowstate_ctrl_read (); - setup_wave_ctrl_read(); - GPIFTRIG = bmGPIF_EP8_START | bmGPIF_READ; // start the xfer - SYNCDELAY; - while (!(GPIFTRIG & bmGPIF_IDLE)); - INPKTEND = 8; // tell USB we filled buffer (8 is our endpoint num) -} - -//clear the FPGA datapath by reading but not submitting, instead clearing the FIFO after each transaction -void clear_fpga_data_fifo(void) { - while(fpga_has_data_packet_avail()) { - GPIFTCB1 = 0x01; - GPIFTCB0 = 0x00; - setup_flowstate_data_read (); - setup_wave_data_read(); - GPIFTRIG = bmGPIF_EP6_START | bmGPIF_READ; // start the xfer - SYNCDELAY; - while (!(GPIFTRIG & bmGPIF_IDLE)); - initialize_gpif_buffer(6); //reset the FIFO instead of committing it - } -} - static void main_loop (void) { while (1){ if (usb_setup_packet_avail ()) usb_handle_setup_packet (); - - if(enable_gpif){ - if (fx2_has_ctrl_packet_avail() && fpga_has_room_for_ctrl_packet()) handle_ctrl_write(); - if (fx2_has_room_for_ctrl_packet() && fpga_has_ctrl_packet_avail()) handle_ctrl_read(); - - //we do this - if (fx2_has_data_packet_avail() && fpga_has_room_for_data_packet()) handle_data_write(); - if (fx2_has_room_for_data_packet() && fpga_has_data_packet_avail()) handle_data_read(); - //five times so that - if (fx2_has_data_packet_avail() && fpga_has_room_for_data_packet()) handle_data_write(); - if (fx2_has_room_for_data_packet() && fpga_has_data_packet_avail()) handle_data_read(); - //we can piggyback - if (fx2_has_data_packet_avail() && fpga_has_room_for_data_packet()) handle_data_write(); - if (fx2_has_room_for_data_packet() && fpga_has_data_packet_avail()) handle_data_read(); - //data transfers - if (fx2_has_data_packet_avail() && fpga_has_room_for_data_packet()) handle_data_write(); - if (fx2_has_room_for_data_packet() && fpga_has_data_packet_avail()) handle_data_read(); - //without loop overhead - if (fx2_has_data_packet_avail() && fpga_has_room_for_data_packet()) handle_data_write(); - if (fx2_has_room_for_data_packet() && fpga_has_data_packet_avail()) handle_data_read(); - } } } @@ -363,15 +247,9 @@ patch_usb_descriptors(void) void main (void) { - enable_gpif = 0; - memset (hash1, 0, USRP_HASH_SIZE); // zero fpga bitstream hash. This forces reload init_usrp (); - init_gpif (); - - // if (UC_START_WITH_GSTATE_OUTPUT_ENABLED) - //IFCONFIG |= bmGSTATE; // no conflict, start with it on set_led_0 (0); set_led_1 (0); @@ -389,6 +267,37 @@ main (void) fx2_renumerate (); // simulates disconnect / reconnect - setup_flowstate_common(); +// setup_flowstate_common(); + +//set up gpif slave mode here + //set slave FIFO mode + //set synchronous slave mode + ////both done in init_usrp() + + //set FLAGA, FLAGB, FLAGC, FLAGD to be EP2EF, EP4EF, EP6PF, EP8PF + PINFLAGSAB = (bmEP2EF) | (bmEP4EF << 4); + PINFLAGSCD = (bmEP6PF) | (bmEP8PF << 4); + + //ok as far as i can tell, DECIS is reversed compared to the FX2 TRM. + //p15.34 says DECIS high implements [assert when (fill > level)], observed opposite + + EP6FIFOPFH = 0x09; + SYNCDELAY; + EP6FIFOPFL = 0xFD; + SYNCDELAY; + +// EP2FIFOPFH = 0x08; +// SYNCDELAY; +// EP2FIFOPFL = 0x00; +// SYNCDELAY; + + //assert FIFOEMPTY one cycle sooner so we get it in time at the FPGA + EP2FIFOCFG |= bmBIT5; + + //set FIFOPINPOLAR to normal (active low) mode + FIFOPINPOLAR = 0x00; + SYNCDELAY; + PORTACFG = 0x80; + main_loop (); } diff --git a/firmware/fx2/b100/usrp_regs.h b/firmware/fx2/b100/usrp_regs.h index f6695d9f9..3d65337f5 100644 --- a/firmware/fx2/b100/usrp_regs.h +++ b/firmware/fx2/b100/usrp_regs.h @@ -41,8 +41,6 @@ #define bmALTERA_NCONFIG bmBIT1 #define bmALTERA_DATA0 bmBIT3 #define bmALTERA_NSTATUS bmBIT4 -#define bmRESET_FPGA_FIFOS bmBIT7 - #define bmALTERA_BITS (bmALTERA_DCLK \ | bmALTERA_NCONFIG \ @@ -64,7 +62,6 @@ sbit at PORT_A_ADDR+0 bitALTERA_DCLK; // 0x80 is the bit address of PORT A sbit at PORT_A_ADDR+1 bitALTERA_NCONFIG; sbit at PORT_A_ADDR+3 bitALTERA_DATA0; -sbit at PORT_A_ADDR+6 bitSHORT_PACKET_SIGNAL; sbit at PORT_C_ADDR+7 bitALTERA_CONF_DONE; @@ -102,29 +99,4 @@ sbit at PORT_C_ADDR+7 bitALTERA_CONF_DONE; #define bmPORT_E_OUTPUTS (0) #define bmPORT_E_INITIAL (0) -/* - * FPGA output lines that are tied to FX2 RDYx inputs. - * These are readable using GPIFREADYSTAT. - */ -//#define bmFPGA_HAS_SPACE bmBIT0 // usbrdy[0] has room for 512 byte packet -//#define bmFPGA_PKT_AVAIL bmBIT1 // usbrdy[1] has >= 512 bytes available - -#define bmDATA_EMPTY bmBIT0 //data output FIFO has no data ready -#define bmDATA_FIFO_FULL bmBIT1 //data input FIFO is full -#define bmCTRL_EMPTY bmBIT2 //control output FIFO has no data ready -#define bmCTRL_FIFO_FULL bmBIT3 //control input FIFO is full - -// #define bmTX_UNDERRUN bmBIT2 // usbrdy[2] D/A ran out of data -// #define bmRX_OVERRUN bmBIT3 // usbrdy[3] A/D ran out of buffer - -/* - * FPGA input lines that are tied to the FX2 CTLx outputs. - * - * These are controlled by the GPIF microprogram... - */ -// WE bmBIT0 // usbctl[0] write enable -// RE bmBIT1 // usbctl[1] read enable -// OE bmBIT2 // usbctl[2] output enable -// EP bmBIT3 // usbctl[3] endpoint select (data/ctrl) - #endif /* _USRP_REV1_REGS_H_ */ diff --git a/firmware/fx2/common/fx2regs.h b/firmware/fx2/common/fx2regs.h index aa44791d0..acbc0b89e 100644 --- a/firmware/fx2/common/fx2regs.h +++ b/firmware/fx2/common/fx2regs.h @@ -91,7 +91,6 @@ EXTERN xdata _AT_(0xE60A) volatile BYTE REVID ; // Chip Revision EXTERN xdata _AT_(0xE60B) volatile BYTE REVCTL ; // Chip Revision Control // Endpoint Configuration - EXTERN xdata _AT_(0xE610) volatile BYTE EP1OUTCFG ; // Endpoint 1-OUT Configuration EXTERN xdata _AT_(0xE611) volatile BYTE EP1INCFG ; // Endpoint 1-IN Configuration EXTERN xdata _AT_(0xE612) volatile BYTE EP2CFG ; // Endpoint 2 Configuration @@ -654,6 +653,22 @@ sfr at 0xF8 EIP; // EIP Bit Values differ from Reg320 #define bmIFCFG0 bmBIT0 #define bmIFCFGMASK (bmIFCFG0 | bmIFCFG1) #define bmIFGPIF bmIFCFG1 +#define bmIFSLAVE (bmIFCFG0 | bmIFCFG1) + +/* Slave FIFO pin flags configuration bits (PINFLAGS) */ +#define bmINDEXED 0x0 //which fifo selected by FIFOADR +#define bmEP2PF 0x4 +#define bmEP4PF 0x5 +#define bmEP6PF 0x6 +#define bmEP8PF 0x7 +#define bmEP2EF 0x8 +#define bmEP4EF 0x9 +#define bmEP6EF 0xA +#define bmEP8EF 0xB +#define bmEP2FF 0xC +#define bmEP4FF 0xD +#define bmEP6FF 0xE +#define bmEP8FF 0xF /* EP 2468 FIFO Configuration bits (EP2FIFOCFG,EP4FIFOCFG,EP6FIFOCFG,EP8FIFOCFG) */ #define bmINFM bmBIT6 -- cgit v1.2.3 From a0887f3bd37e840f5b8ccb894478213e5eae7ed1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 12 Jan 2012 20:05:38 -0800 Subject: b100: bump compat numbers for slave fifo mode Conflicts: host/lib/usrp/b100/b100_impl.hpp --- firmware/fx2/b100/usrp_main.c | 2 +- host/lib/usrp/b100/b100_impl.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'firmware') diff --git a/firmware/fx2/b100/usrp_main.c b/firmware/fx2/b100/usrp_main.c index 45fa60ae9..fdc4fce48 100644 --- a/firmware/fx2/b100/usrp_main.c +++ b/firmware/fx2/b100/usrp_main.c @@ -111,7 +111,7 @@ app_vendor_cmd (void) case VRQ_FW_COMPAT: EP0BCH = 0; - EP0BCL = 2; + EP0BCL = 3; break; default: diff --git a/host/lib/usrp/b100/b100_impl.hpp b/host/lib/usrp/b100/b100_impl.hpp index ec86e41a2..433f45aef 100644 --- a/host/lib/usrp/b100/b100_impl.hpp +++ b/host/lib/usrp/b100/b100_impl.hpp @@ -47,7 +47,7 @@ static const double B100_LINK_RATE_BPS = 256e6/5; //pratical link rate (< 480 Mbps) static const std::string B100_FW_FILE_NAME = "usrp_b100_fw.ihx"; static const std::string B100_FPGA_FILE_NAME = "usrp_b100_fpga.bin"; -static const boost::uint16_t B100_FW_COMPAT_NUM = 0x02; +static const boost::uint16_t B100_FW_COMPAT_NUM = 0x03; static const boost::uint16_t B100_FPGA_COMPAT_NUM = 0x09; static const boost::uint32_t B100_RX_SID_BASE = 2; static const boost::uint32_t B100_TX_ASYNC_SID = 1; -- cgit v1.2.3 From 0d2acffaf4d3e3b02dc9745e94b407356650f923 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Fri, 3 Feb 2012 17:36:07 -0800 Subject: B100/B150: firmware disable FIFOs until host enables to keep junk out --- firmware/fx2/b100/usrp_common.c | 2 +- firmware/fx2/b100/usrp_main.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'firmware') diff --git a/firmware/fx2/b100/usrp_common.c b/firmware/fx2/b100/usrp_common.c index 7aedce9f7..a8f29d1fa 100644 --- a/firmware/fx2/b100/usrp_common.c +++ b/firmware/fx2/b100/usrp_common.c @@ -33,7 +33,7 @@ init_usrp (void) CKCON = 0; // MOVX takes 2 cycles // IFCLK is generated internally and runs at 48 MHz; slave FIFO mode - IFCONFIG = bmIFCLKSRC | bm3048MHZ | bmIFCLKOE | bmIFSLAVE; + IFCONFIG = bmIFCLKSRC | bm3048MHZ | bmIFCLKOE; SYNCDELAY; // configure IO ports (B and D are used by slave FIFO) diff --git a/firmware/fx2/b100/usrp_main.c b/firmware/fx2/b100/usrp_main.c index fdc4fce48..436bdeb36 100644 --- a/firmware/fx2/b100/usrp_main.c +++ b/firmware/fx2/b100/usrp_main.c @@ -81,6 +81,15 @@ static void initialize_gpif_buffer(int ep) { FIFORESET = 0x00; SYNCDELAY; } +void enable_xfers(int enable) { + if(enable) { + IFCONFIG |= bmIFSLAVE; + } else { + IFCONFIG &= ~bmIFSLAVE; + } + set_led_0(enable); +} + /* * Handle our "Vendor Extension" commands on endpoint 0. * If we handle this one, return non-zero. @@ -174,6 +183,7 @@ app_vendor_cmd (void) break; case VRQ_ENABLE_GPIF: + enable_xfers(wValueL); break; case VRQ_CLEAR_FPGA_FIFO: @@ -266,13 +276,6 @@ main (void) EA = 1; // global interrupt enable fx2_renumerate (); // simulates disconnect / reconnect - -// setup_flowstate_common(); - -//set up gpif slave mode here - //set slave FIFO mode - //set synchronous slave mode - ////both done in init_usrp() //set FLAGA, FLAGB, FLAGC, FLAGD to be EP2EF, EP4EF, EP6PF, EP8PF PINFLAGSAB = (bmEP2EF) | (bmEP4EF << 4); -- cgit v1.2.3 From 1e3cb86432ee1d695a12fd99590206e43caab2cc Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 4 Feb 2012 15:12:37 -0800 Subject: uhd: added/renamed various readme files --- README.txt | 19 ++++++++++++++ firmware/README | 6 ----- firmware/README.txt | 31 +++++++++++++++++++++++ fix-copyright-years | 71 ----------------------------------------------------- fpga/README | 4 --- images/README | 25 ------------------- images/README.txt | 25 +++++++++++++++++++ 7 files changed, 75 insertions(+), 106 deletions(-) create mode 100644 README.txt delete mode 100644 firmware/README create mode 100644 firmware/README.txt delete mode 100755 fix-copyright-years delete mode 100644 fpga/README delete mode 100644 images/README create mode 100644 images/README.txt (limited to 'firmware') diff --git a/README.txt b/README.txt new file mode 100644 index 000000000..64066d522 --- /dev/null +++ b/README.txt @@ -0,0 +1,19 @@ +######################################################################## +## Welcome to the USRP source code tree +######################################################################## + +host/ + + Description: source code for user-space driver + +firmware/ + + Description: source code for various micro processors + +fpga/ + + Description: source code for FPGA designs + +images/ + + Description: package builder for FPGA and firmware images diff --git a/firmware/README b/firmware/README deleted file mode 100644 index 251486955..000000000 --- a/firmware/README +++ /dev/null @@ -1,6 +0,0 @@ -######################################################################## -# Firmware for USRP devices -######################################################################## - -fx2 - firmware for USRP1 -zpu - firmware for USRP2 and N Series diff --git a/firmware/README.txt b/firmware/README.txt new file mode 100644 index 000000000..1c233de1d --- /dev/null +++ b/firmware/README.txt @@ -0,0 +1,31 @@ +######################################################################## +# Firmware for USRP devices +######################################################################## + +fx2/ + + Description: firmware for FX2 device + + Devices: USRP1 and B100 + + Tools: sdcc, cmake + + Build Instructions: + 1) mkdir + 2) cd + 3) cmake + 4) make + +zpu/ + + Description: firmware for soft CPU in FPGA + + Devices: USRP2 and N Series + + Tools: zpu-gcc, cmake + + Build Instructions: + 1) mkdir + 2) cd + 3) cmake + 4) make diff --git a/fix-copyright-years b/fix-copyright-years deleted file mode 100755 index 97630041b..000000000 --- a/fix-copyright-years +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python - -import re -import optparse -import datetime -import subprocess -import multiprocessing - -co_line_matcher = re.compile('^.*Copyright (.*) Ettus Research LLC$') - -def command(*args): return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0] - -def get_co_line(lines): - for i, line in enumerate(lines[:5]): - if co_line_matcher.match(line): return line, i - return None, None - -def fix_co_years(files, keep_years): - for file in files: - print file - lines = open(file).readlines() - line, num = get_co_line(lines) - if line is None: continue - - #extract the years from the git history - log_years = map( - lambda l: int(l.split()[-2]), - filter( - lambda l: l.startswith('Date'), - command('git', 'log', file).splitlines(), - ), - ) - log_years = min(log_years), max(log_years) - - #extract years from co string - try: - co_years_str = co_line_matcher.match(line).groups()[0] - co_years = map(int, co_years_str.split('-')) - co_years = min(co_years), max(co_years) - except Exception, e: - 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 - all_years = min(log_years), max(list(log_years)+[year_now]) #add the current year - all_years_str = '%s-%s'%all_years - if all_years[0] == all_years[1]: all_years_str = str(all_years[0]) - new_text = ''.join(lines[:num] + [line.replace(co_years_str, all_years_str)] + lines[num+1:]) - open(file, 'w').write(new_text) - -if __name__ == "__main__": - 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', 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, keep_years=options.keep), - args=files[num::num_procs], - ) for num in range(num_procs)] - map(multiprocessing.Process.start, procs) - map(multiprocessing.Process.join, procs) diff --git a/fpga/README b/fpga/README deleted file mode 100644 index aacafecfd..000000000 --- a/fpga/README +++ /dev/null @@ -1,4 +0,0 @@ -This is a placeholder for the fpga code (verilog, makefiles, corgens...) - -The layout should have a common library and various top level builds -and testbenches that are organized hierarchically. diff --git a/images/README b/images/README deleted file mode 100644 index 2f9c6a95e..000000000 --- a/images/README +++ /dev/null @@ -1,25 +0,0 @@ -The images directory contains the following: - - a Makefile for building firmware and fpga images - - a CMake file for building an images package - -The Makefile and build systems for the images are probably Unix specific. -Its best to build the images on a Unix system with standard build tools. -The CMake package target will create an images package for your system. - -To build the images (unix): - make clean - make images - -To build the package (unix): - mkdir build - cd build - cmake -DCPACK_GENERATOR= ../ - make package - -The package generator types are described here: - http://www.cmake.org/Wiki/CMake:CPackPackageGenerators - -Fedora note: - The sdcc binaries are prefixed with "sdcc-" which breaks the build. - However, /usr/libexec/sdcc contains properly named sdcc binaries. - export PATH=${PATH}:/usr/libexec/sdcc diff --git a/images/README.txt b/images/README.txt new file mode 100644 index 000000000..2f9c6a95e --- /dev/null +++ b/images/README.txt @@ -0,0 +1,25 @@ +The images directory contains the following: + - a Makefile for building firmware and fpga images + - a CMake file for building an images package + +The Makefile and build systems for the images are probably Unix specific. +Its best to build the images on a Unix system with standard build tools. +The CMake package target will create an images package for your system. + +To build the images (unix): + make clean + make images + +To build the package (unix): + mkdir build + cd build + cmake -DCPACK_GENERATOR= ../ + make package + +The package generator types are described here: + http://www.cmake.org/Wiki/CMake:CPackPackageGenerators + +Fedora note: + The sdcc binaries are prefixed with "sdcc-" which breaks the build. + However, /usr/libexec/sdcc contains properly named sdcc binaries. + export PATH=${PATH}:/usr/libexec/sdcc -- cgit v1.2.3 From 5c56ca574ffdf7ad469ab3a3f54def944a978bee Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 6 Feb 2012 13:01:15 -0800 Subject: B100: use FPGA external reset on init --- firmware/fx2/b100/usrp_main.c | 7 ++++++- host/lib/usrp/b100/b100_impl.cpp | 6 ++++++ host/lib/usrp/b100/b100_impl.hpp | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'firmware') diff --git a/firmware/fx2/b100/usrp_main.c b/firmware/fx2/b100/usrp_main.c index 436bdeb36..d9e09ca34 100644 --- a/firmware/fx2/b100/usrp_main.c +++ b/firmware/fx2/b100/usrp_main.c @@ -65,6 +65,11 @@ xdata at USRP_HASH_SLOT_1_ADDR unsigned char hash1[USRP_HASH_SIZE]; //void clear_fpga_data_fifo(void); +//use the B100 fpga_config_cclk/ext_reset line to reset the FPGA +void fpga_reset(int level) { + bitALTERA_DCLK = level; +} + static void get_ep0_data (void) { @@ -169,7 +174,7 @@ app_vendor_cmd (void) break; case VRQ_FPGA_SET_RESET: - //fpga_set_reset (wValueL); + fpga_reset(wValueL); break; case VRQ_I2C_WRITE: diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index 455efa2fe..08a2cdeec 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -181,6 +181,8 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ //load FPGA image, gpif is disabled while loading this->enable_gpif(false); _fx2_ctrl->usrp_load_fpga(b100_fpga_image); + this->set_reset_fpga(1); + this->set_reset_fpga(0); this->enable_gpif(true); //create the control transport @@ -525,6 +527,10 @@ void b100_impl::clear_fpga_fifo(void) { _fx2_ctrl->usrp_control_write(VRQ_CLEAR_FPGA_FIFO, 0, 0, 0, 0); } +void b100_impl::set_reset_fpga(const bool en) { + _fx2_ctrl->usrp_control_write(VRQ_FPGA_SET_RESET, en ? 0 : 1, 0, 0, 0); +} + sensor_value_t b100_impl::get_ref_locked(void){ const bool lock = _clock_ctrl->get_locked(); return sensor_value_t("Ref", lock, "locked", "unlocked"); diff --git a/host/lib/usrp/b100/b100_impl.hpp b/host/lib/usrp/b100/b100_impl.hpp index 49a3139f0..b71b65562 100644 --- a/host/lib/usrp/b100/b100_impl.hpp +++ b/host/lib/usrp/b100/b100_impl.hpp @@ -126,6 +126,7 @@ private: void reset_gpif(const boost::uint16_t); void enable_gpif(const bool); void clear_fpga_fifo(void); + void set_reset_fpga(const bool en); void handle_async_message(uhd::transport::managed_recv_buffer::sptr); uhd::sensor_value_t get_ref_locked(void); void set_rx_fe_corrections(const double); -- cgit v1.2.3 From 10a4d951a1548a99cfd7ac8c015e0bb18ce5e343 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 9 Feb 2012 10:53:39 -0800 Subject: B100: Firmware reset tweaks. --- firmware/fx2/b100/usrp_common.c | 46 +++++++++++++++++++++++----------------- firmware/fx2/b100/usrp_main.c | 30 ++------------------------ host/lib/usrp/b100/b100_impl.cpp | 2 +- 3 files changed, 30 insertions(+), 48 deletions(-) (limited to 'firmware') diff --git a/firmware/fx2/b100/usrp_common.c b/firmware/fx2/b100/usrp_common.c index a8f29d1fa..a21353688 100644 --- a/firmware/fx2/b100/usrp_common.c +++ b/firmware/fx2/b100/usrp_common.c @@ -32,12 +32,11 @@ init_usrp (void) CPUCS = bmCLKSPD1; // CPU runs @ 48 MHz CKCON = 0; // MOVX takes 2 cycles - // IFCLK is generated internally and runs at 48 MHz; slave FIFO mode + // IFCLK is generated internally and runs at 48 MHz, external clk en IFCONFIG = bmIFCLKSRC | bm3048MHZ | bmIFCLKOE; SYNCDELAY; // configure IO ports (B and D are used by slave FIFO) - IOA = bmPORT_A_INITIAL; // Port A initial state OEA = bmPORT_A_OUTPUTS; // Port A direction register @@ -52,7 +51,6 @@ init_usrp (void) // SYNCDELAY; // configure end points - EP1OUTCFG = bmVALID | bmBULK; SYNCDELAY; EP1INCFG = bmVALID | bmBULK | bmIN; SYNCDELAY; @@ -62,7 +60,6 @@ init_usrp (void) EP8CFG = bmVALID | bmBULK | bmDOUBLEBUF | bmIN; SYNCDELAY; // 512 dbl bulk IN // reset FIFOs - FIFORESET = bmNAKALL; SYNCDELAY; FIFORESET = 2; SYNCDELAY; FIFORESET = 4; SYNCDELAY; @@ -71,39 +68,50 @@ init_usrp (void) FIFORESET = 0; SYNCDELAY; // configure end point FIFOs - - // let core see 0 to 1 transistion of autoout bit - + // let core see 0 to 1 transistion of autoin/out bit EP2FIFOCFG = bmWORDWIDE; SYNCDELAY; EP2FIFOCFG = bmAUTOOUT | bmWORDWIDE; SYNCDELAY; EP6FIFOCFG = bmZEROLENIN | bmWORDWIDE; SYNCDELAY; EP6FIFOCFG = bmZEROLENIN | bmAUTOIN | bmWORDWIDE; SYNCDELAY; - //EP6FIFOCFG = bmWORDWIDE; SYNCDELAY; EP4FIFOCFG = bmWORDWIDE; SYNCDELAY; EP4FIFOCFG = bmAUTOOUT | bmWORDWIDE; SYNCDELAY; EP8FIFOCFG = bmZEROLENIN | bmWORDWIDE; SYNCDELAY; EP8FIFOCFG = bmZEROLENIN | bmAUTOIN | bmWORDWIDE; SYNCDELAY; EP0BCH = 0; SYNCDELAY; - // arm EP1OUT so we can receive "out" packets (TRM pg 8-8) - EP1OUTBC = 0; SYNCDELAY; -/* - EP2GPIFFLGSEL = 0x00; SYNCDELAY; // For EP2OUT, GPIF uses EF flag - EP6GPIFFLGSEL = 0x00; SYNCDELAY; // For EP6IN, GPIF uses FF flag - EP4GPIFFLGSEL = 0x00; SYNCDELAY; - EP8GPIFFLGSEL = 0x00; SYNCDELAY; -*/ - // set autoin length for EP6 - // FIXME should be f(enumeration) + // set autoin length for EP6/EP8 EP6AUTOINLENH = (512) >> 8; SYNCDELAY; // this is the length for high speed EP6AUTOINLENL = (512) & 0xff; SYNCDELAY; - EP8AUTOINLENH = (32) >> 8; SYNCDELAY; EP8AUTOINLENL = (32) & 0xff; SYNCDELAY; + //set FLAGA, FLAGB, FLAGC, FLAGD to be EP2EF, EP4EF, EP6PF, EP8PF + PINFLAGSAB = (bmEP2EF) | (bmEP4EF << 4); + PINFLAGSCD = (bmEP6PF) | (bmEP8PF << 4); + + //ok as far as i can tell, DECIS is reversed compared to the FX2 TRM. + //p15.34 says DECIS high implements [assert when (fill > level)], observed opposite + EP6FIFOPFH = 0x09; + SYNCDELAY; + EP6FIFOPFL = 0xFD; + SYNCDELAY; + +// EP2FIFOPFH = 0x08; +// SYNCDELAY; +// EP2FIFOPFL = 0x00; +// SYNCDELAY; + + //assert FIFOEMPTY one cycle sooner so we get it in time at the FPGA + EP2FIFOCFG |= bmBIT5; + + //set FIFOPINPOLAR to normal (active low) mode + FIFOPINPOLAR = 0x00; + SYNCDELAY; + PORTACFG = 0x80; + init_board (); } diff --git a/firmware/fx2/b100/usrp_main.c b/firmware/fx2/b100/usrp_main.c index d9e09ca34..7c4dd479d 100644 --- a/firmware/fx2/b100/usrp_main.c +++ b/firmware/fx2/b100/usrp_main.c @@ -79,8 +79,7 @@ get_ep0_data (void) ; } -static void initialize_gpif_buffer(int ep) { - //clear the GPIF buffers on startup to keep crap out of the data path +static void clear_fifo(int ep) { FIFORESET = 0x80; SYNCDELAY; //activate NAKALL FIFORESET = ep; SYNCDELAY; FIFORESET = 0x00; SYNCDELAY; @@ -184,7 +183,7 @@ app_vendor_cmd (void) break; case VRQ_RESET_GPIF: - initialize_gpif_buffer(wValueL); + clear_fifo(wValueL); break; case VRQ_ENABLE_GPIF: @@ -282,30 +281,5 @@ main (void) fx2_renumerate (); // simulates disconnect / reconnect - //set FLAGA, FLAGB, FLAGC, FLAGD to be EP2EF, EP4EF, EP6PF, EP8PF - PINFLAGSAB = (bmEP2EF) | (bmEP4EF << 4); - PINFLAGSCD = (bmEP6PF) | (bmEP8PF << 4); - - //ok as far as i can tell, DECIS is reversed compared to the FX2 TRM. - //p15.34 says DECIS high implements [assert when (fill > level)], observed opposite - - EP6FIFOPFH = 0x09; - SYNCDELAY; - EP6FIFOPFL = 0xFD; - SYNCDELAY; - -// EP2FIFOPFH = 0x08; -// SYNCDELAY; -// EP2FIFOPFL = 0x00; -// SYNCDELAY; - - //assert FIFOEMPTY one cycle sooner so we get it in time at the FPGA - EP2FIFOCFG |= bmBIT5; - - //set FIFOPINPOLAR to normal (active low) mode - FIFOPINPOLAR = 0x00; - SYNCDELAY; - PORTACFG = 0x80; - main_loop (); } diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index ce0b9453b..4c9f93249 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -181,9 +181,9 @@ b100_impl::b100_impl(const device_addr_t &device_addr){ //load FPGA image, gpif is disabled while loading this->enable_gpif(false); _fx2_ctrl->usrp_load_fpga(b100_fpga_image); + this->enable_gpif(true); this->set_reset_fpga(1); this->set_reset_fpga(0); - this->enable_gpif(true); //create the control transport device_addr_t ctrl_xport_args; -- cgit v1.2.3