|
|
本帖最后由 liangws 于 2017-4-11 17:00 编辑
- Q3 |9 [+ M" {5 b: {- W( `
! R" Z# N, F7 r问题描述:
+ E- l7 F% E, @% \. t7 e% }在syslink模式下开发upp,在138端参考tl-upp_saver程序通过channel b发送数据到FPGA端,FPGA接收数据到FIFO,然后从FIFO端发送給138的upp channel A。fpga端程序通过仿真没有发现什么问题,具体方针波形如下:8 c2 Z0 d0 e4 b' i. l7 E6 O% z/ ~
; u6 j0 Q6 A3 J+ o# n
图中的UPP_CH0*对应于138的Channel b通道,UPP_CH1*对应于138的channela通道。
. l7 x8 c# }) M3 c) L1 D
( i% s3 L: N- e |; ^测试结果如下:$ n3 _) p7 q: G6 G% ~! L- ^% Y6 Y! T
138端发送512字节,要连续发送8次,即8*512字节,接收端才能收满一个512字节数据,这个可能是什么问题引起的?8 P5 g6 o- |* B6 x: R: p
* k C; v* H! [8 f# o% L7 k
+ {" }! D* K- M- N3 P备注:
! h8 r) V4 Z6 _% T% u1、看了upp相关文档,绑定的窗口地址WindowAddress要8字节对齐,tl-upp_saver例程中只有发送端upp_buffer_b有8字节对齐,接收端没有8字节对齐,这个是否有问题?我上述问题是否由于这个引起?
5 \- d( Y6 V: v) g X1 i2、相关代码如下:7 Q" `* u$ @9 a) d
//UPP DMA缓冲大小512字节
6 \3 |; b% e4 p# Y4 I' ~, ]#define UPP_DMA_BYTE_COUNT (64) //DMA行字节数,每行64个字节,行的字节必须是64的整数倍) e: Y/ r) \) C/ d* }
#define UPP_DMA_LINE_COUNT 8 //DMA行数, DMA行数 = DMA缓冲区大小/UPP_DMA_BYTE_COUNT
! G) v& B8 G2 `! J#define UPP_DMA_BUFFER_SIZE (UPP_DMA_BYTE_COUNT * UPP_DMA_LINE_COUNT)7 d! _! K- L1 G$ X, `1 o8 d! }0 O
/ z4 `7 I9 B7 Z$ I. k8 D
+ u# Y& X9 y9 ]6 A9 R//upp接收、发送buffer
, S5 |. y; c6 a8 Q# T$ R#pragma DATA_ALIGN(upp_buffer_a, 8)
. _4 F9 c6 ]( d& K6 F#pragma DATA_ALIGN(upp_buffer_b, 8)
$ V6 i- t4 ]( S& t" Z2 J' a* p' s. O, W
unsigned char upp_buffer_a[UPP_DMA_BUFFER_SIZE];% T6 y$ n; a! t1 U' _2 V4 |
unsigned char upp_buffer_b[UPP_DMA_BUFFER_SIZE];9 S* Z$ e8 J3 @4 v$ D' I5 T- Y
: N D" D; f" I e9 z
8 a9 [, {/ r5 }5 f7 Sstatic bool server_upp_data_recv(Server *server)
' V& g0 H9 b6 T; ]{$ e& q: S# ]- b' X" u6 U) ]( i
if(server->upp_channel_a_recv == false) {
# Z+ Q$ u! y, p0 d3 Z5 m F server_msg_send(server, APP_CMD_LOG, "upp recv: start");% _0 `+ ~5 m# ]9 G, `) \- U" G
if(ListMP_empty(server->upp_recv_list_free) == FALSE) {
0 J- s) P5 C7 ?. d5 u server_msg_send(server, APP_CMD_LOG, "upp recv: get node success");! H5 ~ X! @: q2 N' w
: Y6 B" h* [4 D( `# G8 m; w
+ x7 i/ V) X" x! _4 R2 @" W8 N( d memset(upp_buffer_a, 0, UPP_DMA_BUFFER_SIZE);, a( j% ]# D- |' b& N/ c
7 x# Q3 m3 p0 ~ L4 i8 O server->upp_channel_a_recv = true;//1 B# j5 ~8 i. Q
server->transposeParA.WindowAddress = ((unsigned int *)upp_buffer_a);: b! J8 g9 f' Z" ~
server->transposeParA.LineCount = UPP_DMA_LINE_COUNT;
4 x" r- d* L9 h. o: [0 _ server->transposeParA.ByteCount = UPP_DMA_BYTE_COUNT;2 ~+ O2 A5 ]1 W7 k
server->transposeParA.LineOffsetAddress = UPP_DMA_BYTE_COUNT;//" m) D, `: u M A
F+ n8 B) L8 p6 {' d& L5 ?, g& } upp_error_count = 0;& g$ _2 T! e. X
upp_dmai_int_cut = 0;6 L7 i! }, q7 y, z$ S
1 [+ j" X! V. }& N# G J3 p& H/ f // fill in data : X$ t2 a" g( U4 ]0 g+ M
uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHI, &server->transposeParA);: l5 W; k+ O6 Z
server_msg_send(server, APP_CMD_LOG, "upp recv: binding node to dma chi");
+ j( Y: Z4 ` F; N9 b }
: D& c$ |7 { J! H4 G }- G- B. r) g" m2 e) g6 {
else{- y; R1 x8 ]( e* G9 ]+ c8 s
if (upp_dmai_int_cut > 0){$ B4 i, C* r- S) \& y0 M: d: c$ h: C
DataNode *node = (DataNode *)ListMP_getTail(server->upp_recv_list_free);. E0 r3 J. J: {- `1 N
Uint8 *data = (Uint8 *)SharedRegion_getPtr(node->SR_buffer);
+ p% E- B' [7 U" }6 g: p# ~
7 d2 a l( h0 X! Q
- A0 w& T9 |( H3 s- r //copy data to upp_recv_list_busy3 ]/ w; ^6 Q* c% Z. e0 y) ^+ U
memcpy(data, upp_buffer_a, UPP_DMA_BUFFER_SIZE);
3 |' z' F# ^) W0 e* j3 S) B
) _) Y7 S# \5 D( R5 p8 A //
. m; m- b* ]7 u! s ListMP_putHead(server->upp_recv_list_busy, (ListMP_Elem *)node);- R/ W2 [# `+ K5 C' ~
! A; ]) a$ T9 h. W //
5 J: Q# m1 W3 p server->upp_channel_a_recv = false;//+ ?; W- _6 A! b; N
% @/ |5 u7 S: c0 N% i" V T. v( Y
server_msg_send(server, APP_CMD_LOG, "upp recv: success");
+ V$ _7 @: ~( o& E9 N8 b: d' g }6 P% G6 r3 |6 B1 @: c
}
* f6 a* D* Z" C- z) p" h3 s. y6 l7 y! m$ Z L( ^" ^& x2 p, ]
' b1 m0 y: Z# `
return true;, M% C$ j2 w+ N9 t6 E9 a0 p$ C
}
9 [9 C" C- V: g9 \- ~& Q7 i# r" t5 C, p6 M1 k- X
static bool server_upp_data_send(Server *server)
- J" L6 a( Z! d: r{
' Y3 }( L4 z3 r$ l( I O- | if(ListMP_empty(server->upp_send_list_busy) == FALSE){
- Q$ L6 B- c. e DataNode *node = (DataNode *)ListMP_getTail(server->upp_send_list_busy);
* B! o6 A# z- o- \; O% J1 E; v unsigned char *data = (unsigned char *)SharedRegion_getPtr(node->SR_buffer);
2 ?2 S, b2 j- p3 ?( b char tmp[128] ={0};, Y) U$ p; P1 D1 G9 x+ O
+ C& |8 I0 b; p
server_msg_send(server, APP_CMD_LOG, "upp send: start");( e1 ?0 z9 X( r5 ~: U; K
print_log(server, data, 64);
3 j' M7 Q6 N9 |* }) v9 a
& \8 c- U+ W9 [# V6 i //0 ~- @2 _5 Q5 L" v6 z! B3 Q
memset(upp_buffer_b, 0, UPP_DMA_BUFFER_SIZE);6 `- j/ [2 A9 s0 _# q9 }; \% X
memcpy(upp_buffer_b, data, UPP_DMA_BUFFER_SIZE);7 t: b" g, w# e' }4 _7 N$ i8 y% z& k+ M$ o
print_log(server, upp_buffer_b, 64);6 g+ x7 o$ k3 v- t
4 h" j9 V& K) \) i, N5 O, b server->transposeParB.WindowAddress = ((unsigned int *)upp_buffer_b);
/ }, K* Y& O: r, M6 f( R3 V7 \' _ server->transposeParB.LineCount = UPP_DMA_LINE_COUNT; 6 S; |/ i( x, Y1 f
server->transposeParB.ByteCount = UPP_DMA_BYTE_COUNT;
( Y. }0 J4 I M( u3 v server->transposeParB.LineOffsetAddress = UPP_DMA_BYTE_COUNT;: `7 i" Q# h# k! N% A5 n2 J5 T
' h8 Q+ r8 K9 m- f memset(tmp, 0, sizeof(tmp));1 D- y8 I5 g, H
sprintf(tmp, "upp send data: sizeof(unsigned int):%d, upp_buffer_b:%p, WindowAddress:%ud", & _0 R% s/ h. K& B. t
sizeof(unsigned int), upp_buffer_b, server->transposeParB.WindowAddress);; ? {: o9 D, L3 t) c
server_msg_send(server, APP_CMD_LOG, tmp);: U: `' T- D- a$ y
( r) j; a9 w+ h
upp_error_count = 0;$ Q% F- {) ]/ F" T5 ?
upp_dmaq_int_cut = 0;2 E' Q3 ]2 L* p" F& P+ u* r
// fill in data 4 f9 D6 }4 m# @+ D: N! D5 P
uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHQ, &server->transposeParB); ! ~2 D) Y* f* x% d, S
server_msg_send(server, APP_CMD_LOG, "upp send: binding node to dma chq");
4 l" P! k2 x# W7 \5 f8 t
. m! ^2 {7 d8 X: T% M# ~ // wait send success4 ?! T: O7 g* ^" U' a4 E9 B
while (upp_dmaq_int_cut < 1 && upp_error_count == 0);
2 P9 T. i3 g5 K" _6 p7 n7 x) u" N! K- v1 q
. m# K$ Q4 p* ]# J // make data node in free list
- z0 S- x$ r% u' D* e ListMP_putHead(server->upp_send_list_free, (ListMP_Elem *)node);6 y/ u; ~" q4 z( \; l X2 U
server_msg_send(server, APP_CMD_LOG, "upp send: success");
! m+ P9 d; ~. O; b. C+ X }* V. \% A9 }7 o. C5 R0 [+ x
return true;
- H+ t+ [' y+ \' w, W" J}+ H! G# O; j& U- E" k' ^3 X
! b3 X; U5 j& _% F2 h' @
' e7 r3 D$ R, {9 E" X' G' `4 c% Z# q
' g( ^! z8 T K w3 ^8 Q6 {. F! n( `* r4 h+ y
- L* N" a! p2 U: H2 V |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|