|
|
本帖最后由 liangws 于 2017-4-11 17:00 编辑 # u" K) ~6 v& O
5 L) u7 F( X/ G) d. t; |1 W问题描述:2 k9 M1 j/ ?6 q
在syslink模式下开发upp,在138端参考tl-upp_saver程序通过channel b发送数据到FPGA端,FPGA接收数据到FIFO,然后从FIFO端发送給138的upp channel A。fpga端程序通过仿真没有发现什么问题,具体方针波形如下:
0 ^- w( @( J' b. t
; |. x- Y, ?: K0 t图中的UPP_CH0*对应于138的Channel b通道,UPP_CH1*对应于138的channela通道。3 i; o S' ~5 b6 [1 w5 e
- d* q2 n( G0 y" O2 Z' S测试结果如下:8 ]3 z3 f" g: u) I
138端发送512字节,要连续发送8次,即8*512字节,接收端才能收满一个512字节数据,这个可能是什么问题引起的?
) m* Q( W0 R6 `3 ?* `) H/ F/ A# A2 J& N! N: B2 p% c
! m/ v' o1 w0 f% V3 B& ^
备注:, o7 v" H+ X# C& s
1、看了upp相关文档,绑定的窗口地址WindowAddress要8字节对齐,tl-upp_saver例程中只有发送端upp_buffer_b有8字节对齐,接收端没有8字节对齐,这个是否有问题?我上述问题是否由于这个引起?
}# L0 b/ t; M m K2、相关代码如下:
* J6 y G$ D& x" Y1 s% }7 p7 ~) S4 ?//UPP DMA缓冲大小512字节
; E% [ p" r$ N( ^8 u1 ~#define UPP_DMA_BYTE_COUNT (64) //DMA行字节数,每行64个字节,行的字节必须是64的整数倍& d2 l! P5 A8 a! ^7 P, ?
#define UPP_DMA_LINE_COUNT 8 //DMA行数, DMA行数 = DMA缓冲区大小/UPP_DMA_BYTE_COUNT
0 _% E6 U5 T3 \5 p#define UPP_DMA_BUFFER_SIZE (UPP_DMA_BYTE_COUNT * UPP_DMA_LINE_COUNT)
3 n$ K, R9 c* P7 V" K
1 @! b" ]; E" n2 ]' _+ }( z8 N2 C, L+ `6 \1 p# V" z' E
//upp接收、发送buffer: W3 \" [/ z4 ~- [. d) m% P! Y# c
#pragma DATA_ALIGN(upp_buffer_a, 8)
& p$ Z" Z, P( x#pragma DATA_ALIGN(upp_buffer_b, 8)
+ L& W% A, k* L8 c" V2 W& v: r4 W n8 K+ h. k
unsigned char upp_buffer_a[UPP_DMA_BUFFER_SIZE];6 f* [) s5 A5 G9 d" _5 Z% f; q
unsigned char upp_buffer_b[UPP_DMA_BUFFER_SIZE];1 B0 s% }4 ]3 H' T0 I7 _% I6 }
% [ k3 G3 l) `' v! p7 S- |1 m/ n1 D7 Q/ h6 `, X$ l
static bool server_upp_data_recv(Server *server)
; M0 U) U8 h) l2 b. d2 k{
. G& a5 x" T- g! d) H1 M; M8 Q if(server->upp_channel_a_recv == false) {. V. s& r6 X! a& v; R/ F
server_msg_send(server, APP_CMD_LOG, "upp recv: start");
7 D) e% b4 p, W P6 T$ k9 @ if(ListMP_empty(server->upp_recv_list_free) == FALSE) {& a/ x/ l/ C! i! p$ L
server_msg_send(server, APP_CMD_LOG, "upp recv: get node success");$ x8 m' h9 ~- Q
/ w% f- L3 @: I, Q( c$ E
; ?/ n( S& D8 F) e
memset(upp_buffer_a, 0, UPP_DMA_BUFFER_SIZE);
) S2 R5 q3 o' d/ o& {3 x! C( F9 M! f9 Z2 w4 v" f$ E
server->upp_channel_a_recv = true;//& r0 p- F! ~2 s1 y
server->transposeParA.WindowAddress = ((unsigned int *)upp_buffer_a);
5 A6 i+ K7 ~+ c1 `2 n N: \ server->transposeParA.LineCount = UPP_DMA_LINE_COUNT;" U q3 x. T0 ]! T. R; \
server->transposeParA.ByteCount = UPP_DMA_BYTE_COUNT;5 [2 r+ c: b# u' L
server->transposeParA.LineOffsetAddress = UPP_DMA_BYTE_COUNT;//
9 n( i3 ~# S$ `0 V i w0 x1 x% K `: e5 i/ m
upp_error_count = 0;
+ u3 P& v5 Q9 T- h' Y. U: v upp_dmai_int_cut = 0;
+ e& w, L! W8 [( i$ {& E
, o$ }! r7 I$ F k, F // fill in data
3 h7 L8 o3 |3 N+ ?: P5 G: Z uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHI, &server->transposeParA);
5 R4 c( U8 [2 Y9 U server_msg_send(server, APP_CMD_LOG, "upp recv: binding node to dma chi");( ~0 r8 D" h \2 v6 ?; E/ k
}
7 ?7 A k9 Z/ _& j5 w, P }! Z+ S) u" [7 I# D
else{' c1 y" p ^0 b0 d2 H6 ?
if (upp_dmai_int_cut > 0){
3 E% L, W0 d9 D& }5 b DataNode *node = (DataNode *)ListMP_getTail(server->upp_recv_list_free);
; ^9 @; `* h P5 i Uint8 *data = (Uint8 *)SharedRegion_getPtr(node->SR_buffer);- z" u* Z0 b2 f4 M1 J7 |# e0 a/ d
5 }/ F& s( ^9 U& l2 N
* u' ^. C* i2 S- X. E
//copy data to upp_recv_list_busy
4 Q" o9 U$ k9 o/ r6 S. j' X memcpy(data, upp_buffer_a, UPP_DMA_BUFFER_SIZE);: _4 h( _6 {& @, r2 ~" X
0 }( T" X" v( ^9 }4 Y# ~: f. V //' K4 y6 b; l; j \
ListMP_putHead(server->upp_recv_list_busy, (ListMP_Elem *)node);8 B3 p# c7 J% r5 t" J" K
* L1 Q3 W, t. g* k7 v: l6 g
//
, O( I1 K& r) r5 N) A. W server->upp_channel_a_recv = false;//
6 Q9 _: w' U; Z: `. _! H1 t% d
( T! X3 Y) y- V$ m8 m server_msg_send(server, APP_CMD_LOG, "upp recv: success");* n+ E& q, k5 u. t! ]
}
8 q9 t" q) t# N; l }
& I3 p1 `" d) J0 ^& I2 T, @! d9 U0 _+ X7 U
3 x. g7 z$ e+ u4 C ^ return true;) Y) p6 _0 i# j. j* c7 H
}
" w2 O Q' T/ N% j' d8 v$ ?# r2 `4 h+ J+ x% J! ?3 g
static bool server_upp_data_send(Server *server)' R4 W4 z G q$ f* V
{, K% W- [+ P6 r8 J" P+ q
if(ListMP_empty(server->upp_send_list_busy) == FALSE){) h$ H) ^- l8 E* C, l) f
DataNode *node = (DataNode *)ListMP_getTail(server->upp_send_list_busy);
) v0 f3 h5 V- |; t3 b unsigned char *data = (unsigned char *)SharedRegion_getPtr(node->SR_buffer);
+ \; u$ S; N% ?4 z* T+ W char tmp[128] ={0};
R1 r" Y3 L% L
1 n* ]2 P, |5 `5 U4 ^$ v server_msg_send(server, APP_CMD_LOG, "upp send: start");
/ r% I4 E: @3 D- { j# X print_log(server, data, 64);
/ p1 r) s5 V+ Q5 Z8 q% v6 F* [4 E4 N# f0 n0 z0 p, S7 K
//
5 L8 u2 f$ x2 a9 q5 D& ~. l memset(upp_buffer_b, 0, UPP_DMA_BUFFER_SIZE);. V+ Q. c) ~( O* x; R. a
memcpy(upp_buffer_b, data, UPP_DMA_BUFFER_SIZE);6 h/ ]( H0 U8 k5 \1 \2 t% [
print_log(server, upp_buffer_b, 64);1 c& Z6 b# p. C) s
4 _8 V5 u( H9 U1 @ server->transposeParB.WindowAddress = ((unsigned int *)upp_buffer_b);2 ?( @) V! ^. S, X+ ?
server->transposeParB.LineCount = UPP_DMA_LINE_COUNT;
4 ~; l* r) \' A8 l server->transposeParB.ByteCount = UPP_DMA_BYTE_COUNT;. ~3 t+ U% `% t9 Z2 \" z8 B8 k% G
server->transposeParB.LineOffsetAddress = UPP_DMA_BYTE_COUNT;- f9 E" n' Q+ l& D
" [4 b0 K9 s( k) X6 Y; f4 b2 G
memset(tmp, 0, sizeof(tmp));, ^" C. L) Y- @! o
sprintf(tmp, "upp send data: sizeof(unsigned int):%d, upp_buffer_b:%p, WindowAddress:%ud", 9 w* ^$ y: g* |9 P/ I/ @
sizeof(unsigned int), upp_buffer_b, server->transposeParB.WindowAddress);
+ _4 y( B, M) q% S; f# Y, l server_msg_send(server, APP_CMD_LOG, tmp);
5 K4 K7 o ^- x" b R8 f% L+ t; \1 v$ ?" k+ X2 Q
upp_error_count = 0;
: S4 X# ^# |; ?8 ?+ ~1 v upp_dmaq_int_cut = 0;
* p; h& } K1 h" x8 o, f- D // fill in data , _' g+ T! w- ~7 N6 G7 E, B1 `
uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHQ, &server->transposeParB);
9 F2 |" B) g9 _ server_msg_send(server, APP_CMD_LOG, "upp send: binding node to dma chq");
# [4 h; L* T2 \0 i0 W `# B
% K' h! M! T8 k: j8 _ // wait send success
* f1 d2 b: h* X, d1 L/ s while (upp_dmaq_int_cut < 1 && upp_error_count == 0);
8 }2 R3 j) H% k4 c' z
; `% Z' {6 I$ T. t% U. _% e8 p // make data node in free list
+ z h9 [5 e/ Q- R ListMP_putHead(server->upp_send_list_free, (ListMP_Elem *)node);
" R" G2 v$ g, V/ V- C1 ]$ b server_msg_send(server, APP_CMD_LOG, "upp send: success");
% M6 o/ @6 |7 k" C9 |# l+ d }, ^; t6 s. L. }2 _; F2 Z2 N
return true;
0 [) ]1 u4 j' D& Z- }# K8 i}
" ?* T0 ^% s! T! R" v9 _8 y/ Z* W+ G: _5 w% V1 G
8 u1 r, ~9 T# u& p, a* V7 O3 Q4 f0 b* p1 T2 s
! ~2 b, n1 d" x& x7 S0 c
2 l* t: _+ Y5 V9 y q9 y- [
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|