|
|
本帖最后由 liangws 于 2017-4-11 17:00 编辑
/ |6 R7 [% ^, V- ^+ m P) X* h
- d: `+ s% x2 z3 o问题描述:! w$ {6 S8 z9 S4 f& K0 t' W
在syslink模式下开发upp,在138端参考tl-upp_saver程序通过channel b发送数据到FPGA端,FPGA接收数据到FIFO,然后从FIFO端发送給138的upp channel A。fpga端程序通过仿真没有发现什么问题,具体方针波形如下:
5 c4 B7 k! e2 | c+ ? b7 J% y' T" o8 s' B+ m: p- i' a7 _
图中的UPP_CH0*对应于138的Channel b通道,UPP_CH1*对应于138的channela通道。
/ {* t7 z8 f; ^) |
" V! j7 c B8 H6 U" c测试结果如下:
! Y! k7 R) M3 c: E2 ~8 ]$ r138端发送512字节,要连续发送8次,即8*512字节,接收端才能收满一个512字节数据,这个可能是什么问题引起的?
7 }) y2 Z) P( u1 N7 ]
4 T$ g* ]% y- K& h0 R5 g9 ^" l9 j8 b% _- n! @$ p% n
备注:
% N6 X3 ^* a9 I+ H! A1、看了upp相关文档,绑定的窗口地址WindowAddress要8字节对齐,tl-upp_saver例程中只有发送端upp_buffer_b有8字节对齐,接收端没有8字节对齐,这个是否有问题?我上述问题是否由于这个引起?
7 v1 h( m- P6 o3 O" k0 g) D2、相关代码如下:
0 \* Z4 O* j4 R& D//UPP DMA缓冲大小512字节
9 S( g1 c# q6 U7 c) ~) J#define UPP_DMA_BYTE_COUNT (64) //DMA行字节数,每行64个字节,行的字节必须是64的整数倍7 O: [) o& f' ?: J" o7 w& S% r
#define UPP_DMA_LINE_COUNT 8 //DMA行数, DMA行数 = DMA缓冲区大小/UPP_DMA_BYTE_COUNT$ b G; b4 j) r
#define UPP_DMA_BUFFER_SIZE (UPP_DMA_BYTE_COUNT * UPP_DMA_LINE_COUNT)2 \3 p, b! j2 S: z
0 H, L2 V, Q( Q1 t! g
& g, `/ e. B+ Q. r0 }! H//upp接收、发送buffer- j/ U/ h1 U6 X% I
#pragma DATA_ALIGN(upp_buffer_a, 8)9 w) b T: A u* k- h
#pragma DATA_ALIGN(upp_buffer_b, 8)
- y6 X2 c; Z5 }+ @6 X$ b5 f. p& i1 ?) u- J6 D; ?& n0 n+ z
unsigned char upp_buffer_a[UPP_DMA_BUFFER_SIZE];
+ C. ^& h; S4 U* w! m6 munsigned char upp_buffer_b[UPP_DMA_BUFFER_SIZE];1 [ n2 U: n' A+ O
) n8 P v! t# D9 T3 A$ {
# N& C. w1 \$ P$ h6 i9 [4 |% c L3 E/ j
static bool server_upp_data_recv(Server *server)
$ U' Z3 |# J# K& r& x! _' y) C' G! Q{( F( Y' R8 P& |
if(server->upp_channel_a_recv == false) {
/ {6 u# D$ n! v; z3 B server_msg_send(server, APP_CMD_LOG, "upp recv: start");+ P% O4 z h& V* p6 K, P
if(ListMP_empty(server->upp_recv_list_free) == FALSE) {$ u( Y5 F ]# a1 }
server_msg_send(server, APP_CMD_LOG, "upp recv: get node success");# P# I/ n7 s: E9 V7 H# f/ L
8 Z% e2 d$ [2 F+ W9 C8 S$ a% g
" l$ P5 f1 w0 R6 N; c2 u2 N4 Q memset(upp_buffer_a, 0, UPP_DMA_BUFFER_SIZE);
! [) D& P! G1 o$ ]1 b
- x, P8 @& J/ {$ Y. y4 w server->upp_channel_a_recv = true;//
0 a3 f$ R% {* G% a2 i+ O$ p server->transposeParA.WindowAddress = ((unsigned int *)upp_buffer_a);/ u& B3 l c( H+ R* l9 ]
server->transposeParA.LineCount = UPP_DMA_LINE_COUNT;0 X0 ~& v# q( }' N/ E9 J
server->transposeParA.ByteCount = UPP_DMA_BYTE_COUNT;
0 O8 l6 n8 [7 G6 U+ ^; b server->transposeParA.LineOffsetAddress = UPP_DMA_BYTE_COUNT;//$ G; `4 Q9 ~( L! b: ]. w
+ Z, a( ~, n% u7 j5 W% Y
upp_error_count = 0;6 w L+ J- P' t9 F
upp_dmai_int_cut = 0;* G. }$ ? |/ Q3 u" f( J0 t- r p w, _
; U' e/ J5 {# ?$ b j" S9 v // fill in data # t* ~% `1 n* P- T' w* e
uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHI, &server->transposeParA);; ]9 M- {2 b( e8 k- M4 ^& e1 f6 h) `0 j
server_msg_send(server, APP_CMD_LOG, "upp recv: binding node to dma chi");( M! ^; {* a2 \% g. s' T0 v2 |6 ~, Z
}
& m P' R1 V) W$ x) @& ] }
' m& y$ b5 {; h$ B; {7 d9 H4 p else{
$ k$ v k/ H+ q, | if (upp_dmai_int_cut > 0){
8 m1 w: ^( J0 ~( J1 d" I DataNode *node = (DataNode *)ListMP_getTail(server->upp_recv_list_free);
2 O4 x2 n9 o* q3 P( N Uint8 *data = (Uint8 *)SharedRegion_getPtr(node->SR_buffer);1 U1 A8 `8 e6 x4 l$ ^% W2 x5 \
9 q- v$ g4 G! P# e! G# C! ^# G$ F3 i) `( O
//copy data to upp_recv_list_busy
9 \) q; J# Q4 W7 e% Y) m" |3 b$ i memcpy(data, upp_buffer_a, UPP_DMA_BUFFER_SIZE);
& b" a- s7 a1 `) r$ w* y1 e5 \2 s( u5 ]# ^7 r
//
' B3 F7 b1 F; U. H: ] ListMP_putHead(server->upp_recv_list_busy, (ListMP_Elem *)node);
9 B1 ?7 s- M/ S1 K2 ^' b3 s2 G( N$ P5 u* y8 J. y X$ z
//, `# a; r/ E1 N$ S, ]
server->upp_channel_a_recv = false;//6 `7 F7 G! k$ B" S) E" o! i
, D- W3 a' B: C' k, K+ \. U
server_msg_send(server, APP_CMD_LOG, "upp recv: success");4 h2 m1 r: X/ }1 _: j6 W
}; r* A `2 O' I% i9 ?; u
}
' D$ @/ P2 Y& h7 s1 h- ^! O- v4 K' u# o! Z, `) e7 |( g
) _1 P+ X+ w# h6 e1 A! [ return true;
: ^* a6 c9 P7 r: @0 K2 a}, p# P$ j8 t7 S- y9 L/ `4 S. p3 j d
: j3 V. N1 r; `1 U6 [; X' ^1 K! R) kstatic bool server_upp_data_send(Server *server)
% J& e l6 G- }8 s* x: h{
: [+ ^* O8 s1 @4 O if(ListMP_empty(server->upp_send_list_busy) == FALSE){4 Q+ q/ @- O1 n1 u+ M
DataNode *node = (DataNode *)ListMP_getTail(server->upp_send_list_busy);
. T3 L5 r7 A7 [. u8 E, t unsigned char *data = (unsigned char *)SharedRegion_getPtr(node->SR_buffer);; y: h- a; z e6 h+ v( v
char tmp[128] ={0};* }" I! d1 A- S) z! b
! g( L4 v) G' n
server_msg_send(server, APP_CMD_LOG, "upp send: start");. j$ `2 N$ P6 l4 G4 E. E7 F
print_log(server, data, 64);
( W; c' ~" q0 q: L6 n
c2 R7 d' o$ k9 {# {! P% Q" } //
: m9 a5 U+ I$ y8 l memset(upp_buffer_b, 0, UPP_DMA_BUFFER_SIZE);
! M. v& ?; e0 H- \7 J- L( C memcpy(upp_buffer_b, data, UPP_DMA_BUFFER_SIZE);
: {% D# g4 m6 L2 P( P print_log(server, upp_buffer_b, 64);
9 s5 B2 u/ ]4 _) B+ Q5 c9 h+ W# A9 o; J4 W$ [3 P- ^
server->transposeParB.WindowAddress = ((unsigned int *)upp_buffer_b);
: l. z# A9 \( t' W server->transposeParB.LineCount = UPP_DMA_LINE_COUNT;
: K4 g, s: P" s! }0 S server->transposeParB.ByteCount = UPP_DMA_BYTE_COUNT;2 T$ J5 r2 n+ i
server->transposeParB.LineOffsetAddress = UPP_DMA_BYTE_COUNT;
. o3 G0 G! z9 |& ^3 y& r }: Q
7 x3 _1 ?9 {- x5 L; M" U# b memset(tmp, 0, sizeof(tmp));; z, [0 }3 K% R3 l
sprintf(tmp, "upp send data: sizeof(unsigned int):%d, upp_buffer_b:%p, WindowAddress:%ud", % e4 {' I# ?, `4 {; ] E; v# L
sizeof(unsigned int), upp_buffer_b, server->transposeParB.WindowAddress);
+ |4 W9 O: ]2 \( F server_msg_send(server, APP_CMD_LOG, tmp);! B1 v- X8 {6 F/ c5 n
0 j( e& F) h8 g+ m% t$ M% [ N
upp_error_count = 0;3 ~0 L0 {0 q9 I5 O' O
upp_dmaq_int_cut = 0;! p$ V0 ]+ \7 @
// fill in data ; F! @2 I# O4 ~4 g
uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHQ, &server->transposeParB);
' z$ @8 b9 d0 G; N" C server_msg_send(server, APP_CMD_LOG, "upp send: binding node to dma chq");* X' e; N: D2 }
2 s, w3 `# i; L/ c7 T2 h
// wait send success+ Q2 s9 @5 F0 L' a0 [: r
while (upp_dmaq_int_cut < 1 && upp_error_count == 0); 4 f$ C* G; h+ ?8 ~' }! Q8 v2 D4 `
( g. \. b2 Q4 ` q$ X // make data node in free list 0 R" s# U6 i9 ^6 y3 O9 \
ListMP_putHead(server->upp_send_list_free, (ListMP_Elem *)node);
* O% P0 c' ~5 j# J: Q4 T server_msg_send(server, APP_CMD_LOG, "upp send: success");
6 j4 \0 J* k' O$ h( x U1 A, I3 O }
2 q9 Y3 V7 m7 D! ]0 _ return true;; l8 m5 X( w W- ?0 a# ]7 u
}
6 S: J8 I) V$ z9 F" t% F% I: z% K0 Z- P( Y# O1 A/ y5 Y, {
1 x) \ R8 z$ t ^- v
! {7 \( H" _* U/ ~6 F9 L7 s+ h* \6 z' @! d2 E& e* g8 m
$ ]$ u5 L$ R& U! f2 Y, j/ h2 l) e
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|