Changeset 9142
- Timestamp:
- 08/01/08 14:34:19
- Files:
-
- usrp2/trunk/firmware/apps/Makefile.am (modified) (4 diffs)
- usrp2/trunk/firmware/apps/app_common.h (deleted)
- usrp2/trunk/firmware/apps/app_common_v2.c (modified) (7 diffs)
- usrp2/trunk/firmware/apps/app_common_v2.h (modified) (1 diff)
- usrp2/trunk/firmware/apps/rx_only.c (deleted)
- usrp2/trunk/firmware/apps/tx_only.c (deleted)
- usrp2/trunk/firmware/include/usrp2_bytesex.h (deleted)
- usrp2/trunk/firmware/include/usrp2_eth_packet.h (modified) (12 diffs)
- usrp2/trunk/firmware/lib/memory_map.h (modified) (2 diffs)
- usrp2/trunk/firmware/lib/usrp2_bytesex.h (copied) (copied from usrp2/branches/developers/eb/merge-wip/firmware/lib/usrp2_bytesex.h)
- usrp2/trunk/firmware/u2_flash_tool (modified) (4 diffs)
- usrp2/trunk/host-ng/apps (modified) (1 prop)
- usrp2/trunk/host-ng/apps/Makefile.am (modified) (1 diff)
- usrp2/trunk/host-ng/apps/find_usrps.cc (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/apps/find_usrps.cc)
- usrp2/trunk/host-ng/apps/gen_2tone.py (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/apps/gen_2tone.py)
- usrp2/trunk/host-ng/apps/gen_const.cc (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/apps/gen_const.cc)
- usrp2/trunk/host-ng/apps/gen_sine.py (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/apps/gen_sine.py)
- usrp2/trunk/host-ng/apps/rx_samples.cc (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/apps/rx_samples.cc)
- usrp2/trunk/host-ng/apps/stdin_int32_fft.py (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/apps/stdin_int32_fft.py)
- usrp2/trunk/host-ng/apps/streaming_fft.py (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/apps/streaming_fft.py)
- usrp2/trunk/host-ng/apps/test.sh (modified) (1 diff)
- usrp2/trunk/host-ng/apps/test2_usrp2.cc (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/apps/test2_usrp2.cc)
- usrp2/trunk/host-ng/apps/test_usrp2.cc (modified) (5 diffs)
- usrp2/trunk/host-ng/apps/tx_samples.cc (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/apps/tx_samples.cc)
- usrp2/trunk/host-ng/apps/u2_burn_mac_addr.cc (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/apps/u2_burn_mac_addr.cc)
- usrp2/trunk/host-ng/configure.ac (modified) (3 diffs)
- usrp2/trunk/host-ng/include/usrp2/Makefile.am (modified) (1 diff)
- usrp2/trunk/host-ng/include/usrp2/copiers.h (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/include/usrp2/copiers.h)
- usrp2/trunk/host-ng/include/usrp2/copy_handler.h (modified) (1 diff)
- usrp2/trunk/host-ng/include/usrp2/data_handler.h (modified) (1 diff)
- usrp2/trunk/host-ng/include/usrp2/metadata.h (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/include/usrp2/metadata.h)
- usrp2/trunk/host-ng/include/usrp2/rx_sample_handler.h (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/include/usrp2/rx_sample_handler.h)
- usrp2/trunk/host-ng/include/usrp2/strtod_si.h (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/include/usrp2/strtod_si.h)
- usrp2/trunk/host-ng/include/usrp2/tune_result.h (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/include/usrp2/tune_result.h)
- usrp2/trunk/host-ng/include/usrp2/usrp2.h (modified) (1 diff)
- usrp2/trunk/host-ng/lib/Makefile.am (modified) (4 diffs)
- usrp2/trunk/host-ng/lib/control.cc (modified) (3 diffs)
- usrp2/trunk/host-ng/lib/control.h (modified) (6 diffs)
- usrp2/trunk/host-ng/lib/copiers.cc (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/lib/copiers.cc)
- usrp2/trunk/host-ng/lib/copy_handler.cc (modified) (3 diffs)
- usrp2/trunk/host-ng/lib/data_handler.cc (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/lib/data_handler.cc)
- usrp2/trunk/host-ng/lib/eth_buffer.cc (modified) (13 diffs)
- usrp2/trunk/host-ng/lib/eth_buffer.h (modified) (8 diffs)
- usrp2/trunk/host-ng/lib/ethernet.cc (modified) (1 diff)
- usrp2/trunk/host-ng/lib/ethernet.h (modified) (2 diffs)
- usrp2/trunk/host-ng/lib/find.cc (modified) (4 diffs)
- usrp2/trunk/host-ng/lib/ring.cc (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/lib/ring.cc)
- usrp2/trunk/host-ng/lib/ring.h (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/lib/ring.h)
- usrp2/trunk/host-ng/lib/rx_sample_handler.cc (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/lib/rx_sample_handler.cc)
- usrp2/trunk/host-ng/lib/strtod_si.c (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/lib/strtod_si.c)
- usrp2/trunk/host-ng/lib/usrp2.cc (modified) (3 diffs)
- usrp2/trunk/host-ng/lib/usrp2_bytesex.h (copied) (copied from usrp2/branches/developers/eb/merge-wip/host-ng/lib/usrp2_bytesex.h)
- usrp2/trunk/host-ng/lib/usrp2_impl.cc (modified) (12 diffs)
- usrp2/trunk/host-ng/lib/usrp2_impl.h (modified) (4 diffs)
- usrp2/trunk/host-ng/lib/usrp2_thread.cc (modified) (3 diffs)
- usrp2/trunk/host/apps/find_usrps.cc (deleted)
- usrp2/trunk/host/apps/gen_2tone.py (deleted)
- usrp2/trunk/host/apps/gen_const.cc (deleted)
- usrp2/trunk/host/apps/gen_sine.py (deleted)
- usrp2/trunk/host/apps/rx_samples.cc (deleted)
- usrp2/trunk/host/apps/stdin_int32_fft.py (deleted)
- usrp2/trunk/host/apps/streaming_fft.py (deleted)
- usrp2/trunk/host/apps/tx_samples.cc (deleted)
- usrp2/trunk/host/apps/u2_burn_mac_addr.cc (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
usrp2/trunk/firmware/apps/Makefile.am
r8936 r9142 1 1 # 2 # Copyright 2007 Free Software Foundation, Inc.2 # Copyright 2007,2008 Free Software Foundation, Inc. 3 3 # 4 4 # This program is free software: you can redistribute it and/or modify … … 31 31 ibs_tx_test \ 32 32 rcv_eth_packets \ 33 rx_only \34 33 rx_only_v2 \ 35 34 read_dbids \ … … 42 41 test_serdes \ 43 42 timer_test \ 44 tx_only \45 43 tx_only_v2 \ 46 44 tx_standalone \ 47 45 txrx \ 48 eth_to_serdes \49 serdes_to_dsp \50 46 sd_gentest \ 51 47 sd_bounce … … 55 51 # tx_drop_rate_limited_SOURCES = tx_drop_rate_limited.c app_common.c 56 52 # tx_drop2_SOURCES = tx_drop2.c app_common.c 57 tx_only_SOURCES = tx_only.c app_common.c58 rx_only_SOURCES = rx_only.c app_common.c59 53 rx_only_v2_SOURCES = rx_only_v2.c app_common_v2.c 60 54 tx_only_v2_SOURCES = tx_only_v2.c app_common_v2.c 61 55 txrx_SOURCES = txrx.c app_common_v2.c 62 eth_to_serdes_SOURCES = eth_to_serdes.c app_passthru.c63 serdes_to_dsp_SOURCES = serdes_to_dsp.c app_common.c56 #eth_to_serdes_SOURCES = eth_to_serdes.c app_passthru.c 57 #serdes_to_dsp_SOURCES = serdes_to_dsp.c app_common.c 64 58 65 59 usrp2/trunk/firmware/apps/app_common_v2.c
r9090 r9142 40 40 41 41 42 void config_mimo_cmd(op_config_mimo_t *p /* , op_generic_t *r */); 43 44 45 static void 42 static bool 46 43 burn_mac_addr(const op_burn_mac_addr_t *p) 47 44 { 48 ethernet_set_mac_addr(&p->addr); 45 return ethernet_set_mac_addr(&p->addr); 46 } 47 48 static bool 49 config_mimo_cmd(const op_config_mimo_t *p) 50 { 51 clocks_mimo_config(p->flags); 52 return true; 49 53 } 50 54 … … 95 99 96 100 97 void 98 handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) 99 { 100 unsigned char reply[sizeof(u2_eth_packet_t) + sizeof(u2_subpkt_t)] _AL4; 101 unsigned char *s = &reply[sizeof(u2_eth_packet_t)]; 102 size_t reply_len = 0; 103 104 // initialize reply 105 memset(reply, 0, sizeof(reply)); 106 set_reply_hdr((u2_eth_packet_t *) reply, pkt); 107 108 // point to beginning of payload (subpackets) 109 unsigned char *p = ((unsigned char *) pkt) + sizeof(u2_eth_packet_t); 110 111 // FIXME iterate over payload, handling more than a single subpacket 112 113 int opcode = p[0]; 114 115 switch(opcode){ 116 case OP_ID: 117 { 118 op_id_reply_t *r = (op_id_reply_t *) s; 119 reply_len = sizeof(u2_eth_packet_t) + sizeof(op_id_reply_t); 120 r->opcode = OP_ID_REPLY; 121 r->len = sizeof(op_id_reply_t); 122 r->rid = ((op_id_t *) p)->rid; 123 r->addr = *ethernet_mac_addr(); 124 r->hw_rev = 0x0000; // FIXME 125 // r->fpga_md5sum = ; // FIXME 126 // r->sw_md5sum = ; // FIXME 127 128 // FIXME Add d'board info, including dbid, min/max gain, min/max freq 129 } 130 send_reply(reply, reply_len); 131 break; 132 133 case OP_CONFIG_TX_V2: 134 config_tx_v2_cmd((op_config_tx_v2_t *) p, (op_config_tx_reply_v2_t *) s); 135 send_reply(reply, sizeof(u2_eth_packet_t) + s[1]); 136 break; 137 138 case OP_CONFIG_RX_V2: 139 config_rx_v2_cmd((op_config_rx_v2_t *) p, (op_config_rx_reply_v2_t *) s); 140 send_reply(reply, sizeof(u2_eth_packet_t) + s[1]); 141 break; 142 143 case OP_START_RX_STREAMING: 144 start_rx_streaming_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *) p); 145 break; 146 147 case OP_STOP_RX: 148 stop_rx_cmd(); 149 break; 150 151 case OP_BURN_MAC_ADDR: 152 burn_mac_addr((op_burn_mac_addr_t *) p); 153 break; 154 155 case OP_READ_TIME: 156 { 157 op_read_time_reply_t *r = (op_read_time_reply_t *) s; 158 reply_len = sizeof(u2_eth_packet_t) + sizeof(op_read_time_reply_t); 159 r->opcode = OP_READ_TIME_REPLY; 160 r->len = sizeof(op_read_time_reply_t); 161 r->rid = ((op_read_time_t *) p)->rid; 162 r->time = timer_regs->time; 163 } 164 send_reply(reply, reply_len); 165 break; 166 167 case OP_CONFIG_MIMO: 168 config_mimo_cmd((op_config_mimo_t *) p); 169 break; 170 171 default: 172 printf("app_common_v2: unhandled opcode = %d\n", opcode); 173 break; 174 } 175 } 176 177 178 /* 179 * Called when an ethernet packet is received. 180 * Return true if we handled it here, otherwise 181 * it'll be passed on to the DSP Tx pipe 182 */ 183 bool 184 eth_pkt_inspector(dbsm_t *sm, int bufno) 185 { 186 u2_eth_packet_t *pkt = (u2_eth_packet_t *) buffer_ram(bufno); 187 size_t byte_len = (buffer_pool_status->last_line[bufno] - 3) * 4; 188 189 // static size_t last_len = 0; // kludge 190 191 // hal_toggle_leds(0x1); 192 193 // inspect rcvd frame and figure out what do do. 194 195 if (pkt->ehdr.ethertype != U2_ETHERTYPE) 196 return true; // ignore, probably bogus PAUSE frame from MAC 197 198 int chan = u2p_chan(&pkt->fixed); 199 200 switch (chan){ 201 case CONTROL_CHAN: 202 handle_control_chan_frame(pkt, byte_len); 203 return true; // we handled the packet 204 break; 205 206 case 0: 207 default: 208 #if 0 209 if (last_len != 0){ 210 if (byte_len != last_len){ 211 printf("Len: %d last: %d\n", byte_len, last_len); 212 } 213 } 214 last_len = byte_len; 215 216 if((pkt->thdr.seqno) == exp_seqno){ 217 exp_seqno++; 218 //putchar('.'); 219 } 220 else { 221 puts("Seq"); 222 //printf("S%d %d ",exp_seqno,pkt->thdr.seqno); 223 exp_seqno = pkt->thdr.seqno + 1; 224 } 225 #endif 226 return false; // pass it on to Tx DSP 227 break; 228 } 229 } 230 231 /* 232 * Called when eth phy state changes (w/ interrupts disabled) 233 */ 234 void 235 link_changed_callback(int speed) 236 { 237 link_is_up = speed != 0; 238 hal_set_leds(link_is_up ? 0x10 : 0x0, 0x10); 239 printf("\neth link changed: speed = %d\n", speed); 240 } 241 242 243 void 244 print_tune_result(char *msg, bool tune_ok, 245 u2_fxpt_freq_t target_freq, struct tune_result *r) 246 { 247 printf("db_tune %s %s\n", msg, tune_ok ? "true" : "false"); 248 putstr(" target_freq "); print_fxpt_freq(target_freq); newline(); 249 putstr(" baseband_freq "); print_fxpt_freq(r->baseband_freq); newline(); 250 putstr(" dxc_freq "); print_fxpt_freq(r->dxc_freq); newline(); 251 putstr(" residual_freq "); print_fxpt_freq(r->residual_freq); newline(); 252 printf(" inverted %s\n", r->inverted ? "true" : "false"); 253 } 254 255 256 void 257 config_tx_v2_cmd(const op_config_tx_v2_t *p, op_config_tx_reply_v2_t *r) 258 { 101 static size_t 102 op_id_cmd(const op_generic_t *p, 103 void *reply_payload, size_t reply_payload_space) 104 { 105 op_id_reply_t *r = (op_id_reply_t *) reply_payload; 106 if (reply_payload_space < sizeof(*r)) // no room 107 return 0; 108 109 // Build reply subpacket 110 111 r->opcode = OP_ID_REPLY; 112 r->len = sizeof(op_id_reply_t); 113 r->rid = p->rid; 114 r->addr = *ethernet_mac_addr(); 115 r->hw_rev = 0x0000; // FIXME 116 // r->fpga_md5sum = ; // FIXME 117 // r->sw_md5sum = ; // FIXME 118 119 // FIXME Add d'board info, including dbid, min/max gain, min/max freq 120 121 return r->len; 122 } 123 124 125 static size_t 126 config_tx_v2_cmd(const op_config_tx_v2_t *p, 127 void *reply_payload, size_t reply_payload_space) 128 { 129 op_config_tx_reply_v2_t *r = (op_config_tx_reply_v2_t *) reply_payload; 130 if (reply_payload_space < sizeof(*r)) 131 return 0; // no room 132 259 133 struct tune_result tune_result; 260 134 memset(&tune_result, 0, sizeof(tune_result)); … … 277 151 int hb1 = 0; 278 152 int hb2 = 0; 279 280 if(!(interp & 1)) { 153 154 if (!(interp & 1)){ 155 hb2 = 1; 156 interp = interp >> 1; 157 } 158 159 if (!(interp & 1)){ 281 160 hb1 = 1; 282 161 interp = interp >> 1; 283 } 284 285 if(!(interp & 1)) { 286 hb2 = 1; 287 interp = interp >> 1; 288 } 289 290 dsp_tx_regs->interp_rate =(hb1<<9) | (hb2<<8) | interp; 291 // printf("Interp: %d, register %d\n", p->interp, (hb1<<9) | (hb2<<8) | interp); 292 } 293 162 } 163 164 if (p->interp < MIN_INTERP || p->interp > MAX_INTERP) 165 ok = false; 166 else { 167 dsp_tx_regs->interp_rate = (hb1<<9) | (hb2<<8) | interp; 168 // printf("Interp: %d, register %d\n", p->interp, (hb1<<9) | (hb2<<8) | interp); 169 } 170 } 171 294 172 if (p->valid & CFGV_SCALE_IQ){ 295 173 dsp_tx_regs->scale_iq = p->scale_iq; 296 174 } 297 175 298 // Build reply ; it's sent by our caller.176 // Build reply subpacket 299 177 300 178 r->opcode = OP_CONFIG_TX_REPLY_V2; 301 r->len = sizeof( op_config_tx_reply_v2_t);179 r->len = sizeof(*r); 302 180 r->rid = p->rid; 303 181 r->ok = ok; … … 309 187 r->residual_freq_hi = u2_fxpt_freq_hi(tune_result.residual_freq); 310 188 r->residual_freq_lo = u2_fxpt_freq_lo(tune_result.residual_freq); 311 } 312 313 void 314 config_rx_v2_cmd(const op_config_rx_v2_t *p, op_config_rx_reply_v2_t *r) 315 { 189 return r->len; 190 } 191 192 static size_t 193 config_rx_v2_cmd(const op_config_rx_v2_t *p, 194 void *reply_payload, size_t reply_payload_space) 195 { 196 op_config_rx_reply_v2_t *r = (op_config_rx_reply_v2_t *) reply_payload; 197 if (reply_payload_space < sizeof(*r)) 198 return 0; // no room 199 316 200 struct tune_result tune_result; 317 201 memset(&tune_result, 0, sizeof(tune_result)); … … 345 229 } 346 230 347 dsp_rx_regs->decim_rate = (hb1<<9) | (hb2<<8) | decim; 348 // printf("Decim: %d, register %d\n", p->decim, (hb1<<9) | (hb2<<8) | decim); 231 if (decim < MIN_DECIM || decim > MAX_DECIM) 232 ok = false; 233 else { 234 dsp_rx_regs->decim_rate = (hb1<<9) | (hb2<<8) | decim; 235 // printf("Decim: %d, register %d\n", p->decim, (hb1<<9) | (hb2<<8) | decim); 236 } 349 237 } 350 238 … … 353 241 } 354 242 355 // Build reply ; it's sent by our caller.243 // Build reply subpacket 356 244 357 245 r->opcode = OP_CONFIG_RX_REPLY_V2; 358 r->len = sizeof( op_config_rx_reply_v2_t);246 r->len = sizeof(*r); 359 247 r->rid = p->rid; 360 248 r->ok = ok; … … 366 254 r->residual_freq_hi = u2_fxpt_freq_hi(tune_result.residual_freq); 367 255 r->residual_freq_lo = u2_fxpt_freq_lo(tune_result.residual_freq); 256 257 return r->len; 258 } 259 260 static size_t 261 read_time_cmd(const op_generic_t *p, 262 void *reply_payload, size_t reply_payload_space) 263 { 264 op_read_time_reply_t *r = (op_read_time_reply_t *) reply_payload; 265 if (reply_payload_space < sizeof(*r)) 266 return 0; // no room 267 268 r->opcode = OP_READ_TIME_REPLY; 269 r->len = sizeof(*r); 270 r->rid = p->rid; 271 r->time = timer_regs->time; 272 273 return r->len; 274 } 275 276 static size_t 277 generic_reply(const op_generic_t *p, 278 void *reply_payload, size_t reply_payload_space, 279 bool ok) 280 { 281 op_generic_t *r = (op_generic_t *) reply_payload; 282 if (reply_payload_space < sizeof(*r)) 283 return 0; // no room 284 285 r->opcode = p->opcode | OP_REPLY_BIT; 286 r->len = sizeof(*r); 287 r->rid = p->rid; 288 r->ok = ok; 289 290 return r->len; 291 } 292 293 static size_t 294 add_eop(void *reply_payload, size_t reply_payload_space) 295 { 296 op_generic_t *r = (op_generic_t *) reply_payload; 297 if (reply_payload_space < sizeof(*r)) 298 return 0; // no room 299 300 r->opcode = OP_EOP; 301 r->len = sizeof(*r); 302 r->rid = 0; 303 r->ok = 0; 304 305 return r->len; 368 306 } 369 307 370 308 void 371 config_mimo_cmd(op_config_mimo_t *p /* , op_generic_t *r */) 372 { 373 clocks_mimo_config(p->flags); 374 // FIXME build generic reply 375 } 309 handle_control_chan_frame(u2_eth_packet_t *pkt, size_t len) 310 { 311 unsigned char reply[sizeof(u2_eth_packet_t) + 4 * sizeof(u2_subpkt_t)] _AL4; 312 unsigned char *reply_payload = &reply[sizeof(u2_eth_packet_t)]; 313 int reply_payload_space = sizeof(reply) - sizeof(u2_eth_packet_t); 314 315 // initialize reply 316 memset(reply, 0, sizeof(reply)); 317 set_reply_hdr((u2_eth_packet_t *) reply, pkt); 318 319 // point to beginning of payload (subpackets) 320 unsigned char *payload = ((unsigned char *) pkt) + sizeof(u2_eth_packet_t); 321 int payload_len = len - sizeof(u2_eth_packet_t); 322 323 size_t subpktlen = 0; 324 325 while (payload_len >= sizeof(op_generic_t)){ 326 const op_generic_t *gp = (const op_generic_t *) payload; 327 subpktlen = 0; 328 329 switch(gp->opcode){ 330 case OP_EOP: // end of subpackets 331 goto end_of_subpackets; 332 333 case OP_ID: 334 subpktlen = op_id_cmd(gp, reply_payload, reply_payload_space); 335 break; 336 337 case OP_CONFIG_TX_V2: 338 subpktlen = config_tx_v2_cmd((op_config_tx_v2_t *) payload, 339 reply_payload, reply_payload_space); 340 break; 341 342 case OP_CONFIG_RX_V2: 343 subpktlen = config_rx_v2_cmd((op_config_rx_v2_t *) payload, 344 reply_payload, reply_payload_space); 345 break; 346 347 case OP_START_RX_STREAMING: 348 start_rx_streaming_cmd(&pkt->ehdr.src, (op_start_rx_streaming_t *) payload); 349 subpktlen = generic_reply(gp, reply_payload, reply_payload_space, true); 350 break; 351 352 case OP_STOP_RX: 353 stop_rx_cmd(); 354 subpktlen = generic_reply(gp, reply_payload, reply_payload_space, true); 355 break; 356 357 case OP_BURN_MAC_ADDR: 358 subpktlen = generic_reply(gp, reply_payload, reply_payload_space, 359 burn_mac_addr((op_burn_mac_addr_t *) payload)); 360 break; 361 362 case OP_CONFIG_MIMO: 363 subpktlen = generic_reply(gp, reply_payload, reply_payload_space, 364 config_mimo_cmd((op_config_mimo_t *) payload)); 365 break; 366 367 case OP_READ_TIME: 368 subpktlen = read_time_cmd(gp, reply_payload, reply_payload_space); 369 break; 370 371 default: 372 printf("app_common_v2: unhandled opcode = %d\n", gp->opcode); 373 break; 374 } 375 376 int t = (gp->len + 3) & ~3; // bump to a multiple of 4 377 payload += t; 378 payload_len -= t; 379 380 subpktlen = (subpktlen + 3) & ~3; // bump to a multiple of 4 381 reply_payload += subpktlen; 382 reply_payload_space -= subpktlen; 383 } 384 385 end_of_subpackets: 386 387 // add the EOP marker 388 subpktlen = add_eop(reply_payload, reply_payload_space); 389 subpktlen = (subpktlen + 3) & ~3; // bump to a multiple of 4 390 reply_payload += subpktlen; 391 reply_payload_space -= subpktlen; 392 393 send_reply(reply, reply_payload - reply); 394 } 395 396 397 /* 398 * Called when an ethernet packet is received. 399 * Return true if we handled it here, otherwise 400 * it'll be passed on to the DSP Tx pipe 401 */ 402 bool 403 eth_pkt_inspector(dbsm_t *sm, int bufno) 404 { 405 u2_eth_packet_t *pkt = (u2_eth_packet_t *) buffer_ram(bufno); 406 size_t byte_len = (buffer_pool_status->last_line[bufno] - 3) * 4; 407 408 //static size_t last_len = 0; 409 410 // hal_toggle_leds(0x1); 411 412 // inspect rcvd frame and figure out what do do. 413 414 if (pkt->ehdr.ethertype != U2_ETHERTYPE) 415 return true; // ignore, probably bogus PAUSE frame from MAC 416 417 int chan = u2p_chan(&pkt->fixed); 418 419 switch (chan){ 420 case CONTROL_CHAN: 421 handle_control_chan_frame(pkt, byte_len); 422 return true; // we handled the packet 423 break; 424 425 case 0: 426 default: 427 #if 0 428 if (last_len != 0){ 429 if (byte_len != last_len){ 430 printf("Len: %d last: %d\n", byte_len, last_len); 431 } 432 } 433 last_len = byte_len; 434 435 if((pkt->thdr.seqno) == exp_seqno){ 436 exp_seqno++; 437 //putchar('.'); 438 } 439 else { 440 // putchar('S'); 441 //printf("S%d %d ",exp_seqno,pkt->thdr.seqno); 442 exp_seqno = pkt->thdr.seqno + 1; 443 } 444 #endif 445 return false; // pass it on to Tx DSP 446 break; 447 } 448 } 449 450 /* 451 * Called when eth phy state changes (w/ interrupts disabled) 452 */ 453 void 454 link_changed_callback(int speed) 455 { 456 link_is_up = speed != 0; 457 hal_set_leds(link_is_up ? 0x10 : 0x0, 0x10); 458 printf("\neth link changed: speed = %d\n", speed); 459 } 460 461 462 void 463 print_tune_result(char *msg, bool tune_ok, 464 u2_fxpt_freq_t target_freq, struct tune_result *r) 465 { 466 printf("db_tune %s %s\n", msg, tune_ok ? "true" : "false"); 467 putstr(" target_freq "); print_fxpt_freq(target_freq); newline(); 468 putstr(" baseband_freq "); print_fxpt_freq(r->baseband_freq); newline(); 469 putstr(" dxc_freq "); print_fxpt_freq(r->dxc_freq); newline(); 470 putstr(" residual_freq "); print_fxpt_freq(r->residual_freq); newline(); 471 printf(" inverted %s\n", r->inverted ? "true" : "false"); 472 } usrp2/trunk/firmware/apps/app_common_v2.h
r8596 r9142 55 55 56 56 57 void config_tx_v2_cmd(const op_config_tx_v2_t *p, op_config_tx_reply_v2_t *r);58 void config_rx_v2_cmd(const op_config_rx_v2_t *p, op_config_rx_reply_v2_t *r);59 57 void start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p); 60 58 void stop_rx_cmd(void); usrp2/trunk/firmware/include/usrp2_eth_packet.h
r8995 r9142 1 1 /* -*- c++ -*- */ 2 2 /* 3 * Copyright 2007 Free Software Foundation, Inc.3 * Copyright 2007,2008 Free Software Foundation, Inc. 4 4 * 5 5 * This program is free software: you can redistribute it and/or modify … … 33 33 * All these data structures are BIG-ENDIAN on the wire 34 34 */ 35 36 // FIXME gcc specific. Really ought to come from compiler.h 37 #define _AL4 __attribute__((aligned (4))) 35 38 36 39 /* … … 156 159 /* 157 160 * Opcodes for control channel 158 */ 159 #define OP_EOP 0 // marks last subpacket in packet 160 #define OP_ID 1 161 #define OP_ID_REPLY 2 162 #define OP_BURN_MAC_ADDR 3 163 #define OP_READ_TIME 4 // What time is it? (100 MHz counter) 164 #define OP_READ_TIME_REPLY 5 // This time. 165 #define OP_CONFIG_RX_V2 6 166 #define OP_CONFIG_RX_REPLY_V2 7 167 #define OP_CONFIG_TX_V2 8 168 #define OP_CONFIG_TX_REPLY_V2 9 169 #define OP_START_RX_STREAMING 10 170 #define OP_STOP_RX 11 171 #define OP_CONFIG_MIMO 12 // FIXME on merge 172 173 #define OP_START_RX 20 // deprecated 174 #define OP_CONFIG_TX 21 // deprecated 175 176 #define OP_WRITE_REG 25 // not implemented 177 #define OP_WRITE_REG_MASKED 26 178 #define OP_READ_REG 27 179 #define OP_READ_REG_REPLY 28 180 181 182 /*! 183 * \brief Marker for last subpacket in packet 184 */ 185 typedef struct { 186 uint8_t opcode; 187 uint8_t len; 188 uint16_t mbz; 189 } op_eop_t; 190 191 /*! 192 * \brief Look for USRP2's 193 */ 194 typedef struct { 195 uint8_t opcode; 196 uint8_t len; 197 uint8_t rid; 198 uint8_t mbz; 199 } op_id_t; 161 * 162 * Reply opcodes are the same as the request opcode with the OP_REPLY_BIT set (0x80). 163 */ 164 #define OP_REPLY_BIT 0x80 165 166 #define OP_EOP 0 // marks last subpacket in packet 167 168 #define OP_ID 1 169 #define OP_ID_REPLY (OP_ID | OP_REPLY_BIT) 170 #define OP_BURN_MAC_ADDR 2 171 #define OP_BURN_MAC_ADDR_REPLY (OP_BURN_MAC_ADDR | OP_REPLY_BIT) 172 #define OP_READ_TIME 3 // What time is it? (100 MHz counter) 173 #define OP_READ_TIME_REPLY (OP_READ_TIME | OP_REPLY_BIT) 174 #define OP_CONFIG_RX_V2 4 175 #define OP_CONFIG_RX_REPLY_V2 (OP_CONFIG_RX_V2 | OP_REPLY_BIT) 176 #define OP_CONFIG_TX_V2 5 177 #define OP_CONFIG_TX_REPLY_V2 (OP_CONFIG_TX_V2 | OP_REPLY_BIT) 178 #define OP_START_RX_STREAMING 6 179 #define OP_START_RX_STREAMING_REPLY (OP_START_RX_STREAMING | OP_REPLY_BIT) 180 #define OP_STOP_RX 7 181 #define OP_STOP_RX_REPLY (OP_STOP_RX | OP_REPLY_BIT) 182 #define OP_CONFIG_MIMO 8 183 #define OP_CONFIG_MIMO_REPLY (OP_CONFIG_MIMO | OP_REPLY_BIT) 184 185 186 //#define OP_WRITE_REG xx // not implemented 187 //#define OP_WRITE_REG_MASKED xx 188 //#define OP_READ_REG xx 189 //#define OP_READ_REG_REPLY xx 190 191 /* 192 * All subpackets are a multiple of 4 bytes long. 193 * All subpackets start with an 8-bit opcode, an 8-bit len and an 8-bit rid. 194 */ 195 196 197 /*! 198 * \brief Generic request and reply packet 199 * 200 * Used by: 201 * OP_EOP, OP_BURN_MAC_ADDR_REPLY, OP_START_RX_STREAMING_REPLY, 202 * OP_STOP_RX_REPLY 203 */ 204 typedef struct { 205 uint8_t opcode; 206 uint8_t len; 207 uint8_t rid; 208 uint8_t ok; // bool 209 } _AL4 op_generic_t; 200 210 201 211 /*! … … 211 221 uint8_t fpga_md5sum[16]; 212 222 uint8_t sw_md5sum[16]; 213 } op_id_reply_t; 214 215 typedef struct { 216 uint8_t opcode; 217 uint8_t len; 218 uint16_t mbz; 223 } _AL4 op_id_reply_t; 224 225 typedef struct { 226 uint8_t opcode; 227 uint8_t len; 228 uint8_t rid; 229 uint8_t mbz; 219 230 uint32_t items_per_frame; // # of 32-bit data items; MTU=1500: [9,371] 220 } op_start_rx_streaming_t; 221 222 typedef struct { 223 uint8_t opcode; 224 uint8_t len; 225 uint16_t mbz; 226 } op_stop_rx_t; 227 228 typedef struct { 229 uint8_t opcode; 230 uint8_t len; 231 } _AL4 op_start_rx_streaming_t; 232 233 typedef struct { 234 uint8_t opcode; 235 uint8_t len; 236 uint8_t rid; 231 237 u2_mac_addr_t addr; 232 } op_burn_mac_addr_t; 233 234 typedef struct { 235 uint8_t opcode; 236 uint8_t len; 237 uint8_t rid; 238 uint8_t mbz; 239 } op_read_time_t; 238 } _AL4 op_burn_mac_addr_t; 240 239 241 240 typedef struct { … … 245 244 uint8_t mbz; 246 245 uint32_t time; 247 } op_read_time_reply_t;246 } _AL4 op_read_time_reply_t; 248 247 249 248 … … 263 262 uint32_t decim; // desired decimation factor (NOT -1) 264 263 uint32_t scale_iq; // (scale_i << 16) | scale_q [16.0 format] 265 } op_config_rx_v2_t;264 } _AL4 op_config_rx_v2_t; 266 265 267 266 // bitmask for "valid" field. If the bit is set, there's … … 295 294 uint32_t residual_freq_lo; 296 295 297 } op_config_rx_reply_v2_t;296 } _AL4 op_config_rx_reply_v2_t; 298 297 299 298 /*! … … 313 312 uint32_t interp; // desired interpolation factor (NOT -1) 314 313 uint32_t scale_iq; // (scale_i << 16) | scale_q [16.0 format] 315 } op_config_tx_v2_t;314 } _AL4 op_config_tx_v2_t; 316 315 317 316 /*! … … 337 336 uint32_t residual_freq_lo; 338 337 339 } op_config_tx_reply_v2_t;338 } _AL4 op_config_tx_reply_v2_t; 340 339 341 340 /*! … … 349 348 } op_config_mimo_t; 350 349 351 352 /*353 * ================================================================354 * deprecated subpacket types355 * ================================================================356 */357 358 typedef struct { // Deprecated. Don't use.359 uint8_t opcode;360 uint8_t len;361 uint8_t rx_now; // 1 -> receive now, 0 -> at rx_time362 uint8_t mbz;363 int32_t phase_inc; // 2**32 * desired_freq/100e6364 uint32_t scale_iq; // (scale_i << 16) | scale_q [16.0 format]365 uint32_t decim; // desired decimation factor (NOT -1)366 uint32_t samples_per_frame; // MTU=1500: [9,372]; MTU=2034: [9,506]367 uint32_t total_samples; // [9, 2^21-1] == [9, 2,097,151]368 uint32_t rx_time; // when to begin receiving369 } op_start_rx_t;370 371 typedef struct { // Deprecated. Don't use372 uint8_t opcode;373 uint8_t len;374 uint16_t mbz;375 int32_t phase_inc; // 2**32 * desired_freq/100e6376 uint32_t scale_iq; // (scale_i << 16) | scale_q [16.0 format]377 uint32_t interp; // desired interpolation factor (NOT -1)378 } op_config_tx_t;379 350 380 351 /* … … 384 355 */ 385 356 typedef union { 386 op_eop_t op_eop; 387 op_ id_t op_id;357 358 op_generic_t op_generic; 388 359 op_id_reply_t op_id_reply; 389 360 op_start_rx_streaming_t op_start_rx_streaming; 390 op_stop_rx_t op_stop_rx;391 361 op_burn_mac_addr_t op_burn_mac_addr; 392 op_read_time_t op_read_time;393 362 op_read_time_reply_t op_read_time_reply; 394 363 op_config_rx_v2_t op_config_rx_v2; … … 396 365 op_config_tx_v2_t op_config_tx_v2; 397 366 op_config_tx_reply_v2_t op_config_tx_reply_v2; 398 399 op_start_rx_t op_start_rx; // deprecated 400 op_config_tx_t op_config_tx; // deprecated 367 op_config_mimo_t op_config_mimo; 401 368 402 369 } u2_subpkt_t; usrp2/trunk/firmware/lib/memory_map.h
r9090 r9142 368 368 // --- dsp tx regs --- 369 369 370 #define MIN_INTERP 1 371 #define MAX_INTERP 128 372 370 373 typedef struct { 371 374 volatile int32_t freq; … … 381 384 382 385 #define T_NOW (-1) 386 387 #define MIN_DECIM 1 388 #define MAX_DECIM 128 383 389 384 390 typedef struct { usrp2/trunk/firmware/u2_flash_tool
r7339 r9142 53 53 return False 54 54 55 def read_flash(offset, filename, devname): 56 dev = open(devname, "rb") 57 dev.seek(offset, 0) # seek to absolute byte offset 58 dev_data = dev.read(MAX_FILE_SIZE) 59 dev.close() 60 open(filename, "wb").write(dev_data) 61 55 62 56 63 def main(): … … 60 67 parser.add_option("-v", "--verify", action="store_const", const="verify", dest="mode", 61 68 help="verify FILE against TARGET slot") 69 parser.add_option("-r", "--read", action="store_const", const="read", dest="mode", 70 help="read TARGET slot, write to FILE") 62 71 parser.add_option("-t", "--target", type="choice", choices=("fpga", "s/w"), default="s/w", 63 72 help="select TARGET slot from: fpga, s/w [default=%default]") … … 74 83 75 84 if options.mode is None: 76 sys.stderr.write("specify mode with -w or -v\n")85 sys.stderr.write("specify mode with -w, -v or -r\n") 77 86 parser.print_help() 78 87 raise SystemExit … … 88 97 r = (write_flash(offset, filename, options.dev) 89 98 and verify_flash(offset, filename, options.dev)) 99 elif options.mode == "verify": 100 r = verify_flash(offset, filename, options.dev) 101 elif options.mode == "read": 102 r = read_flash(offset, filename, options.dev) 90 103 else: 91 r = verify_flash(offset, filename, options.dev)104 raise NotImplemented 92 105 93 106 if not r: usrp2/trunk/host-ng/apps
- Property svn:ignore changed from Makefile Makefile.in .libs .deps test_eth test_usrp2 cerr *.sh to Makefile Makefile.in .libs .deps test_eth test_usrp2 test2_usrp2 gen_const find_usrps cerr *.sh tx_samples
usrp2/trunk/host-ng/apps/Makefile.am
r8600 r9142 18 18 include $(top_srcdir)/Makefile.common 19 19 20 AM_CPPFLAGS = -Wall -Werror 21 INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) 20 AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) $(GRUEL_CFLAGS) 22 21 23 22 LDADD = \ 24 23 ../lib/libusrp2ng.la \ 25 $(GNURADIO_CORE_LIBS) 24 -lgruel 25 26 bin_PROGRAMS = \ 27 find_usrps 26 28 27 29 noinst_PROGRAMS = \ 28 test_usrp2 30 gen_const \ 31 test2_usrp2 \ 32 tx_samples 29 33 30 test_usrp2_SOURCES = \ 31 test_usrp2.cc 32 34 find_usrps = find_usrps.cc 35 test2_usrp2_SOURCES = test2_usrp2.cc
