|
|
本帖最后由 liangws 于 2017-4-11 17:00 编辑 7 H1 _" q" V6 D5 A- X! b! O
9 @; C( W! R' g' X6 B, A问题描述:
- O! o9 M8 K( q% p' R在syslink模式下开发upp,在138端参考tl-upp_saver程序通过channel b发送数据到FPGA端,FPGA接收数据到FIFO,然后从FIFO端发送給138的upp channel A。fpga端程序通过仿真没有发现什么问题,具体方针波形如下:
( O8 l% k2 E: Q. h3 F6 u6 z% i- ]" G( q" y9 O; X
图中的UPP_CH0*对应于138的Channel b通道,UPP_CH1*对应于138的channela通道。
- t* ^% t( H% O) f0 Y
, j4 E. n. c) H9 Y A; ?测试结果如下:! Q1 G; z1 `2 `6 @6 {; D$ F
138端发送512字节,要连续发送8次,即8*512字节,接收端才能收满一个512字节数据,这个可能是什么问题引起的?6 B' `, _1 O( \* S
1 f0 }2 U2 z7 J$ F3 [1 {0 p3 l: @7 ~/ H8 S4 D5 [& d {
备注:
: s5 o) ]5 `9 ^0 {1、看了upp相关文档,绑定的窗口地址WindowAddress要8字节对齐,tl-upp_saver例程中只有发送端upp_buffer_b有8字节对齐,接收端没有8字节对齐,这个是否有问题?我上述问题是否由于这个引起?
" G$ y- D8 _( p. E/ |) X% r3 I1 h2、相关代码如下:
+ }; f+ O* x/ d& J8 o! k//UPP DMA缓冲大小512字节- `7 K0 L0 w% g- F+ b( O; ^
#define UPP_DMA_BYTE_COUNT (64) //DMA行字节数,每行64个字节,行的字节必须是64的整数倍
0 R5 b+ V+ ?, G+ R#define UPP_DMA_LINE_COUNT 8 //DMA行数, DMA行数 = DMA缓冲区大小/UPP_DMA_BYTE_COUNT
* _& q8 ~2 ], x( z! x+ t6 h% ?#define UPP_DMA_BUFFER_SIZE (UPP_DMA_BYTE_COUNT * UPP_DMA_LINE_COUNT)
a. X4 y5 F3 b9 X# f
, {8 p* G. d# T" q. |) n4 g* J7 G
7 S' s1 V% o% M& I$ Y9 F: O- v: k//upp接收、发送buffer$ I' ]3 t* ?- W" A. x; q
#pragma DATA_ALIGN(upp_buffer_a, 8)# d$ N% `. f7 o' ~
#pragma DATA_ALIGN(upp_buffer_b, 8)( l: `8 P8 d; W% t Z
) }- J2 E5 O4 x1 Z2 J" Dunsigned char upp_buffer_a[UPP_DMA_BUFFER_SIZE];
% O4 `" F, g8 c4 l8 Iunsigned char upp_buffer_b[UPP_DMA_BUFFER_SIZE];
9 c" K' Z. u+ E
* y- M3 m4 o: A; t3 N" ~5 f5 D
1 F) G3 E+ m- ^( I" U* ]! M2 ]# Kstatic bool server_upp_data_recv(Server *server) 2 q( x% j1 }2 X, S7 \
{
. N* Y/ g; d, g( C# s3 \ if(server->upp_channel_a_recv == false) {+ f0 b7 p t' q9 a8 L3 N
server_msg_send(server, APP_CMD_LOG, "upp recv: start");, W9 s$ s% V$ E
if(ListMP_empty(server->upp_recv_list_free) == FALSE) {' r( k1 Z( P1 h$ t( B
server_msg_send(server, APP_CMD_LOG, "upp recv: get node success");
3 t5 i# B8 T8 J. |4 }* D% n+ C" g' D( Z1 i4 k, ^% _3 w9 Y6 s
5 z% Y8 Q$ X* J0 O( G6 \ g* S
memset(upp_buffer_a, 0, UPP_DMA_BUFFER_SIZE);
+ F0 D* [. B+ q2 @$ V/ i$ b1 w+ g) f- s# Z8 f
server->upp_channel_a_recv = true;//
! S; N- J0 E3 g! S1 n. J+ j server->transposeParA.WindowAddress = ((unsigned int *)upp_buffer_a);2 z |* x& [' q, {3 H
server->transposeParA.LineCount = UPP_DMA_LINE_COUNT;$ s5 i$ h: N- B9 S0 o# `* a
server->transposeParA.ByteCount = UPP_DMA_BYTE_COUNT;5 }) ~& J1 c/ I
server->transposeParA.LineOffsetAddress = UPP_DMA_BYTE_COUNT;//# T6 ^- _2 L2 x7 Q+ L' k& t) S
% `) q2 ^# `- e+ {) z5 L
upp_error_count = 0;
3 w; H# Z# e% m" k- M upp_dmai_int_cut = 0;
' d, h6 ]; E4 \% ?, n0 o
9 T1 q' }6 e# X( o: ^7 i% V; C/ ~ // fill in data
; a/ N9 w0 J6 u uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHI, &server->transposeParA);1 \9 F" S% R8 i8 Y8 [/ B" E
server_msg_send(server, APP_CMD_LOG, "upp recv: binding node to dma chi");4 C% h' c7 q) z8 M
}. d/ I/ X9 g( {3 x
}
) B! J, V8 {; t8 ~ else{- i6 {0 b" h0 o+ [/ \5 G0 {0 g+ v
if (upp_dmai_int_cut > 0){
+ r8 b* |/ Y$ U$ X" q DataNode *node = (DataNode *)ListMP_getTail(server->upp_recv_list_free);
- }2 k- d) U' Z8 } Uint8 *data = (Uint8 *)SharedRegion_getPtr(node->SR_buffer);
* \2 c0 w) B1 B1 h! x5 p
8 q+ l% s* h- @# k! X6 q) H0 k8 u6 \
//copy data to upp_recv_list_busy# x. t; F$ K" w
memcpy(data, upp_buffer_a, UPP_DMA_BUFFER_SIZE);
. a" q; |5 S' _5 k5 X; B. k- x! ?1 j; Q7 N7 a
//' q: \4 M& K' D$ E
ListMP_putHead(server->upp_recv_list_busy, (ListMP_Elem *)node);' q! A9 @# ]# }, A3 o1 \/ m
2 Z ^ N8 P; h( q% I% r
//
% o( e) X# M) y4 H server->upp_channel_a_recv = false;//
) W3 }) g5 q9 d
I. O, v& e N; M server_msg_send(server, APP_CMD_LOG, "upp recv: success");
7 _# w* D% |: Q" r6 v1 ^. J; H }
! G5 ^8 h. g- i& c- f T0 W }% u+ O8 o/ D% h' h" o" V
% C; v9 H; f# c+ g/ D3 E6 U+ J# Q8 Q" P5 p2 W! o: S
return true;/ D, R i3 c6 D' y- E. h* ^
}. }. Q! p, |4 }9 G, ~' c" l8 w
9 ~" p: t `0 dstatic bool server_upp_data_send(Server *server)' U c1 [- a% d
{
8 k' h1 `+ h8 z9 p) e9 c: M0 X& a if(ListMP_empty(server->upp_send_list_busy) == FALSE){# X- t5 ?0 K E' ~7 E
DataNode *node = (DataNode *)ListMP_getTail(server->upp_send_list_busy);
# y3 d* |+ d- H) s6 x. y unsigned char *data = (unsigned char *)SharedRegion_getPtr(node->SR_buffer); Q( f' O2 ]5 {* I$ x* k, G! A$ L) g0 G
char tmp[128] ={0};. _% ^0 Z9 v( B- L; O- Y
& |: F c( E# z
server_msg_send(server, APP_CMD_LOG, "upp send: start");
1 ?+ z7 q3 X8 N1 N; e Z print_log(server, data, 64);% k2 `7 o( m. s, _
3 h: v: V5 I1 {, U8 ~6 w
//3 M6 r% X! |3 t7 \' `# z" p
memset(upp_buffer_b, 0, UPP_DMA_BUFFER_SIZE);: H, ]3 W" ?# ^
memcpy(upp_buffer_b, data, UPP_DMA_BUFFER_SIZE);& Z" n$ X2 y; p) W6 _
print_log(server, upp_buffer_b, 64);- y2 A- z; C2 ^
1 s/ b7 b5 u2 F g8 B- Z server->transposeParB.WindowAddress = ((unsigned int *)upp_buffer_b);% @) r' ` P+ I7 k& Z! U
server->transposeParB.LineCount = UPP_DMA_LINE_COUNT; : B7 e( I7 w. l' a6 M' N
server->transposeParB.ByteCount = UPP_DMA_BYTE_COUNT;
, P' Y2 P7 n" G server->transposeParB.LineOffsetAddress = UPP_DMA_BYTE_COUNT;# C. P3 @$ O3 Y; f+ f$ H9 {, H
" p ?4 N9 |' i/ \# @3 |- f memset(tmp, 0, sizeof(tmp));' d4 @) t* h4 a% B/ J
sprintf(tmp, "upp send data: sizeof(unsigned int):%d, upp_buffer_b:%p, WindowAddress:%ud",
& D4 K/ o4 _- S" @6 h% C1 t sizeof(unsigned int), upp_buffer_b, server->transposeParB.WindowAddress);
7 h/ _0 O, e% I0 q. K% } server_msg_send(server, APP_CMD_LOG, tmp);
\# _2 K$ g8 Z/ B% z- w; r
6 \/ M5 g3 |* u u, Y$ S2 Q/ k upp_error_count = 0;
* p0 U% X, {0 _2 j2 Q3 | upp_dmaq_int_cut = 0;- d) [, z/ C0 b: T1 y) G3 q
// fill in data 5 r8 H; O5 h9 U6 b
uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHQ, &server->transposeParB); 5 M" \' U* z/ }1 q& y3 O
server_msg_send(server, APP_CMD_LOG, "upp send: binding node to dma chq");5 g( c/ v. m3 x1 o
; e9 L" B& q! i" ]& }6 m0 j0 U1 c // wait send success
# A2 F( \ B4 ?3 H# v( w while (upp_dmaq_int_cut < 1 && upp_error_count == 0);
, v7 t; X. R$ ~/ K( s: T1 L
: b0 f! `7 N# u3 J7 Z // make data node in free list - f" k0 `3 S0 M' ?$ q" Q
ListMP_putHead(server->upp_send_list_free, (ListMP_Elem *)node);4 L* @! M+ ~& @1 q
server_msg_send(server, APP_CMD_LOG, "upp send: success");! B& F& f4 n% d
}
5 h& x- b0 c v3 g+ p4 C) i! U return true;7 \( d+ P- o( L: D, I8 [! y
}
5 X- [- K: h: {7 S* j M; c) i8 y2 m r& Z1 D: i1 x
* C8 F" {. I! j2 v) O% V, h o
/ K( [8 D+ ^% N: K) u: T
( w2 w a4 q) z, [; u- ^# Y0 G2 ?) f7 o9 y8 h0 h
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|