diff options
Diffstat (limited to 'firmware/microblaze')
-rw-r--r-- | firmware/microblaze/apps/txrx_uhd.c | 14 | ||||
-rw-r--r-- | firmware/microblaze/lib/eeprom.c | 12 | ||||
-rw-r--r-- | firmware/microblaze/lib/eth_addrs.c | 21 | ||||
-rw-r--r-- | firmware/microblaze/lib/ethernet.h | 6 | ||||
-rw-r--r-- | firmware/microblaze/lib/i2c.h | 3 | ||||
-rw-r--r-- | firmware/microblaze/lib/net_common.c | 11 | ||||
-rw-r--r-- | firmware/microblaze/lib/pic.c | 2 | ||||
-rw-r--r-- | firmware/microblaze/usrp2/memory_map.h | 4 | ||||
-rw-r--r-- | firmware/microblaze/usrp2p/Makefile.am | 3 | ||||
-rw-r--r-- | firmware/microblaze/usrp2p/bootloader/init_bootloader.c | 23 | ||||
-rw-r--r-- | firmware/microblaze/usrp2p/memory_map.h | 4 | ||||
-rw-r--r-- | firmware/microblaze/usrp2p/udp_fw_update.c | 4 |
12 files changed, 81 insertions, 26 deletions
diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index d00f2bc1f..9c1873e1c 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -396,7 +396,7 @@ eth_pkt_inspector(dbsm_t *sm, int bufno) // In the future, a hardware state machine will do this... if ( //warning! magic numbers approaching.... (((buff + ((2 + 14 + 20)/sizeof(uint32_t)))[0] & 0xffff) == USRP2_UDP_DATA_PORT) && - ((buff + ((2 + 14 + 20 + 8)/sizeof(uint32_t)))[0] != USRP2_INVALID_VRT_HEADER) + ((buff + ((2 + 14 + 20 + 8)/sizeof(uint32_t)))[1] != USRP2_INVALID_VRT_HEADER) ) return false; //test if its an ip recovery packet @@ -497,6 +497,16 @@ 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-NEWETH\n"); print_mac_addr(ethernet_mac_addr()->addr); newline(); @@ -507,7 +517,7 @@ main(void) //1) register the addresses into the network stack register_mac_addr(ethernet_mac_addr()); register_ip_addr(get_ip_addr()); - + //2) register callbacks for udp ports we service register_udp_listener(USRP2_UDP_CTRL_PORT, handle_udp_ctrl_packet); register_udp_listener(USRP2_UDP_DATA_PORT, handle_udp_data_packet); diff --git a/firmware/microblaze/lib/eeprom.c b/firmware/microblaze/lib/eeprom.c index b12ffe082..d4e170046 100644 --- a/firmware/microblaze/lib/eeprom.c +++ b/firmware/microblaze/lib/eeprom.c @@ -17,9 +17,21 @@ #include "i2c.h" #include "mdelay.h" +#include "usrp2/fw_common.h" static const int EEPROM_PAGESIZE = 16; +bool find_safe_booted_flag(void) { + unsigned char flag_byte; + eeprom_read(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_BOOTLOADER_FLAGS, &flag_byte, 1); + return (flag_byte == 0x5E); +} + +void set_safe_booted_flag(bool flag) { + unsigned char flag_byte = flag ? 0x5E : 0xDC; + eeprom_write(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_BOOTLOADER_FLAGS, &flag_byte, 1); +} + bool eeprom_write (int i2c_addr, int eeprom_offset, const void *buf, int len) { diff --git a/firmware/microblaze/lib/eth_addrs.c b/firmware/microblaze/lib/eth_addrs.c index c6320e4fa..ff5d04f4d 100644 --- a/firmware/microblaze/lib/eth_addrs.c +++ b/firmware/microblaze/lib/eth_addrs.c @@ -46,9 +46,20 @@ unprogrammed(const void *t, size_t len) //////////////////// MAC Addr Stuff /////////////////////// static int8_t src_mac_addr_initialized = false; + +static const eth_mac_addr_t default_mac_addr = {{ + 0x00, 0x50, 0xC2, 0x85, 0x3f, 0xff + }}; + static eth_mac_addr_t src_mac_addr = {{ 0x00, 0x50, 0xC2, 0x85, 0x3f, 0xff }}; + +void set_default_mac_addr(void) +{ + src_mac_addr_initialized = true; + src_mac_addr = default_mac_addr; +} const eth_mac_addr_t * ethernet_mac_addr(void) @@ -88,10 +99,20 @@ ethernet_set_mac_addr(const eth_mac_addr_t *t) //////////////////// IP Addr Stuff /////////////////////// static int8_t src_ip_addr_initialized = false; + +static const struct ip_addr default_ip_addr = { + (192 << 24 | 168 << 16 | 10 << 8 | 2 << 0) +}; + static struct ip_addr src_ip_addr = { (192 << 24 | 168 << 16 | 10 << 8 | 2 << 0) }; +void set_default_ip_addr(void) +{ + src_ip_addr_initialized = true; + src_ip_addr = default_ip_addr; +} const struct ip_addr *get_ip_addr(void) { diff --git a/firmware/microblaze/lib/ethernet.h b/firmware/microblaze/lib/ethernet.h index 8c6d8b567..52b297349 100644 --- a/firmware/microblaze/lib/ethernet.h +++ b/firmware/microblaze/lib/ethernet.h @@ -44,6 +44,9 @@ void ethernet_register_link_changed_callback(ethernet_link_changed_callback_t cb */ const eth_mac_addr_t *ethernet_mac_addr(void); +/*!set mac addr to default*/ +void set_default_mac_addr(void); + /*! * \brief write mac address to eeprom and begin using it */ @@ -54,6 +57,9 @@ bool ethernet_set_mac_addr(const eth_mac_addr_t *t); */ const struct ip_addr *get_ip_addr(void); +/*!set ip addr to default*/ +void set_default_ip_addr(void); + /*! * \brief write ip address to eeprom and begin using it */ diff --git a/firmware/microblaze/lib/i2c.h b/firmware/microblaze/lib/i2c.h index 6ff0e6982..1af4d72df 100644 --- a/firmware/microblaze/lib/i2c.h +++ b/firmware/microblaze/lib/i2c.h @@ -33,4 +33,7 @@ bool eeprom_write (int i2c_addr, int eeprom_offset, const void *buf, int len); bool eeprom_read (int i2c_addr, int eeprom_offset, void *buf, int len); +bool find_safe_booted_flag(void); +void set_safe_booted_flag(bool flag); + #endif /* INCLUDED_I2C_H */ diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c index beaaa5948..6305408d6 100644 --- a/firmware/microblaze/lib/net_common.c +++ b/firmware/microblaze/lib/net_common.c @@ -291,8 +291,17 @@ handle_icmp_packet(struct ip_addr src, struct ip_addr dst, { switch (icmp->type){ case ICMP_DUR: // Destinatino Unreachable - //stop_streaming(); //FIXME if (icmp->code == ICMP_DUR_PORT){ // port unreachable + //handle destination port unreachable (the host ctrl+c'd the app): + + //end async update packets per second + sr_tx_ctrl->cyc_per_up = 0; + + //the end continuous streaming command + sr_rx_ctrl->cmd = 1 << 31; //no samples now + sr_rx_ctrl->time_secs = 0; + sr_rx_ctrl->time_ticks = 0; //latch the command + //struct udp_hdr *udp = (struct udp_hdr *)((char *)icmp + 28); //printf("icmp port unr %d\n", udp->dest); putchar('i'); diff --git a/firmware/microblaze/lib/pic.c b/firmware/microblaze/lib/pic.c index e89d2b755..226da5f85 100644 --- a/firmware/microblaze/lib/pic.c +++ b/firmware/microblaze/lib/pic.c @@ -44,7 +44,7 @@ pic_init(void) // uP is level triggered pic_regs->mask = ~0; // mask all interrupts - pic_regs->edge_enable = PIC_ONETIME_INT; + pic_regs->edge_enable = PIC_ONETIME_INT | PIC_UNDERRUN_INT | PIC_OVERRUN_INT | PIC_PPS_INT; pic_regs->polarity = ~0 & ~PIC_PHY_INT; // rising edge pic_regs->pending = ~0; // clear all pending ints } diff --git a/firmware/microblaze/usrp2/memory_map.h b/firmware/microblaze/usrp2/memory_map.h index 41a2820bc..eac0c217f 100644 --- a/firmware/microblaze/usrp2/memory_map.h +++ b/firmware/microblaze/usrp2/memory_map.h @@ -463,6 +463,10 @@ typedef struct { typedef struct { volatile uint32_t num_chan; volatile uint32_t clear_state; // clears out state machine, fifos, + volatile uint32_t report_sid; + volatile uint32_t policy; + volatile uint32_t cyc_per_up; + volatile uint32_t packets_per_up; } sr_tx_ctrl_t; #define sr_tx_ctrl ((sr_tx_ctrl_t *) _SR_ADDR(SR_TX_CTRL)) diff --git a/firmware/microblaze/usrp2p/Makefile.am b/firmware/microblaze/usrp2p/Makefile.am index a5df3ff08..40766b406 100644 --- a/firmware/microblaze/usrp2p/Makefile.am +++ b/firmware/microblaze/usrp2p/Makefile.am @@ -18,7 +18,8 @@ include $(top_srcdir)/Makefile.common AM_CFLAGS = \ - $(COMMON_CFLAGS) + $(COMMON_CFLAGS) \ + -DUSRP2P AM_LDFLAGS = \ $(COMMON_LFLAGS) \ diff --git a/firmware/microblaze/usrp2p/bootloader/init_bootloader.c b/firmware/microblaze/usrp2p/bootloader/init_bootloader.c index 2bbbd405e..1d9d681d7 100644 --- a/firmware/microblaze/usrp2p/bootloader/init_bootloader.c +++ b/firmware/microblaze/usrp2p/bootloader/init_bootloader.c @@ -18,9 +18,6 @@ #include <i2c.h> #include "usrp2/fw_common.h" -bool find_safe_booted_flag(void); -void set_safe_booted_flag(bool flag); - void pic_interrupt_handler() __attribute__ ((interrupt_handler)); void pic_interrupt_handler() @@ -28,18 +25,6 @@ void pic_interrupt_handler() // nop stub } -bool find_safe_booted_flag(void) { - unsigned char flag_byte; - eeprom_read(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_BOOTLOADER_FLAGS, &flag_byte, 1); - return (flag_byte == 0x5E); -} - -void set_safe_booted_flag(bool flag) { - unsigned char flag_byte = flag ? 0x5E : 0xDC; - eeprom_write(USRP2_I2C_ADDR_MBOARD, USRP2_EE_MBOARD_BOOTLOADER_FLAGS, &flag_byte, 1); -} - - 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 @@ -79,22 +64,22 @@ int main(int argc, char *argv[]) { puts("USRP2+ bootloader\n"); bool production_image = find_safe_booted_flag(); - if(production_image) set_safe_booted_flag(0); //we're the production image, so we clear the flag for the next boot - + 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(RAM_BASE); 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."); - //puts("ERROR: no safe firmware image available. I am a brick."); load_ihex(); } } - + if(!production_image) { puts("Checking for valid production FPGA image..."); if(is_valid_fpga_image(PROD_FPGA_IMAGE_LOCATION_ADDR)) { diff --git a/firmware/microblaze/usrp2p/memory_map.h b/firmware/microblaze/usrp2p/memory_map.h index 8d0d0c365..3b2dc0057 100644 --- a/firmware/microblaze/usrp2p/memory_map.h +++ b/firmware/microblaze/usrp2p/memory_map.h @@ -490,6 +490,10 @@ typedef struct { typedef struct { volatile uint32_t num_chan; volatile uint32_t clear_state; // clears out state machine, fifos, + volatile uint32_t report_sid; + volatile uint32_t policy; + volatile uint32_t cyc_per_up; + volatile uint32_t packets_per_up; } sr_tx_ctrl_t; #define sr_tx_ctrl ((sr_tx_ctrl_t *) _SR_ADDR(SR_TX_CTRL)) diff --git a/firmware/microblaze/usrp2p/udp_fw_update.c b/firmware/microblaze/usrp2p/udp_fw_update.c index 55c206b1b..ead08ad2c 100644 --- a/firmware/microblaze/usrp2p/udp_fw_update.c +++ b/firmware/microblaze/usrp2p/udp_fw_update.c @@ -38,13 +38,13 @@ void handle_udp_fw_update_packet(struct socket_address src, struct socket_addres usrp2_fw_update_id_t update_data_in_id = update_data_in->id; //ensure that the protocol versions match - if (payload_len >= sizeof(uint32_t) && update_data_in->proto_ver != USRP2_FW_COMPAT_NUM){ +/* if (payload_len >= sizeof(uint32_t) && update_data_in->proto_ver != USRP2_FW_COMPAT_NUM){ printf("!Error in update packet handler: Expected compatibility number %d, but got %d\n", USRP2_FW_COMPAT_NUM, update_data_in->proto_ver ); update_data_in_id = USRP2_FW_UPDATE_ID_OHAI_LOL; //so we can respond } - +*/ //ensure that this is not a short packet if (payload_len < sizeof(usrp2_fw_update_data_t)){ printf("!Error in update packet handler: Expected payload length %d, but got %d\n", |