|
|
本帖最后由 liangws 于 2017-4-11 17:00 编辑
: o( x6 b+ Q! w' Y% Y: n( K* k5 m8 u* M' E. B
问题描述:& K) J! n) U+ F0 X
在syslink模式下开发upp,在138端参考tl-upp_saver程序通过channel b发送数据到FPGA端,FPGA接收数据到FIFO,然后从FIFO端发送給138的upp channel A。fpga端程序通过仿真没有发现什么问题,具体方针波形如下:8 [# N) B/ k' r t7 s7 i
, A0 Z2 V& L$ }; y图中的UPP_CH0*对应于138的Channel b通道,UPP_CH1*对应于138的channela通道。
4 @+ D5 T5 I+ N I3 a8 u. k9 G) V% R4 p( c! i
测试结果如下:9 U7 }# m1 t+ ]" G' Y8 C+ I& i
138端发送512字节,要连续发送8次,即8*512字节,接收端才能收满一个512字节数据,这个可能是什么问题引起的?
# t% D+ Y& m( T
. L0 f$ S4 T' K1 H/ M W! B p0 Q" F) h# h+ g
备注:
3 D8 v" N# k% z1、看了upp相关文档,绑定的窗口地址WindowAddress要8字节对齐,tl-upp_saver例程中只有发送端upp_buffer_b有8字节对齐,接收端没有8字节对齐,这个是否有问题?我上述问题是否由于这个引起?
5 N L7 G, P) w; r5 |2、相关代码如下:5 c; T' S; d7 h" ~9 ` K" Y& k7 ]
//UPP DMA缓冲大小512字节
4 m& y1 t& h2 }, C- o! k9 ?/ J#define UPP_DMA_BYTE_COUNT (64) //DMA行字节数,每行64个字节,行的字节必须是64的整数倍
6 n, \0 [. S3 G2 e+ q: l$ C7 G+ o#define UPP_DMA_LINE_COUNT 8 //DMA行数, DMA行数 = DMA缓冲区大小/UPP_DMA_BYTE_COUNT
& Z- u( \; v6 t, I5 b# Y( m#define UPP_DMA_BUFFER_SIZE (UPP_DMA_BYTE_COUNT * UPP_DMA_LINE_COUNT)
/ ~! j/ Y. B+ ^2 I0 _; `" ]" Q6 G; M
; N8 ?6 K# g* }& N2 I8 A/ C
" |# p; R1 h" h8 S5 m$ p//upp接收、发送buffer
, g, u+ B# g: S; E; o9 b#pragma DATA_ALIGN(upp_buffer_a, 8); K1 }! T4 c. z. c( Y
#pragma DATA_ALIGN(upp_buffer_b, 8)
! K& P3 K# @% g7 |* Z& M) l1 i8 \- F5 W D
unsigned char upp_buffer_a[UPP_DMA_BUFFER_SIZE];
+ ~/ u' u8 d0 q( u! f+ Sunsigned char upp_buffer_b[UPP_DMA_BUFFER_SIZE];! i. L/ o( Y) {, H
7 e6 y: @1 N& o0 g) A7 n3 M8 a6 D
+ b1 h8 r5 K) D& [5 g5 G& d! Rstatic bool server_upp_data_recv(Server *server)
! x0 ~# n8 ^2 X5 u+ ^{+ x% f- h8 H1 E, p5 I9 k
if(server->upp_channel_a_recv == false) {
6 E$ F% i- @# E: \, H! @( b server_msg_send(server, APP_CMD_LOG, "upp recv: start");/ O' C% }8 `0 Y/ P0 W5 m& _4 M, E" N
if(ListMP_empty(server->upp_recv_list_free) == FALSE) {2 P8 p$ O: e) n$ x0 K
server_msg_send(server, APP_CMD_LOG, "upp recv: get node success");4 N A9 v. n* v$ x0 [
3 k# n2 o" U; x2 S G2 S' G& r
; E+ Z! l. l. j- M) S/ U( V8 P memset(upp_buffer_a, 0, UPP_DMA_BUFFER_SIZE); T8 b& U8 [# t+ Z1 J1 M
9 c5 y/ w9 J* B6 o3 } server->upp_channel_a_recv = true;//
$ i. ~0 `. K( j: I1 @+ v server->transposeParA.WindowAddress = ((unsigned int *)upp_buffer_a);$ C2 \5 P% C' p! Y0 W& s0 I: Q' s
server->transposeParA.LineCount = UPP_DMA_LINE_COUNT;
/ M. i5 ^; p+ A: ] server->transposeParA.ByteCount = UPP_DMA_BYTE_COUNT;1 I# F/ j; y5 A
server->transposeParA.LineOffsetAddress = UPP_DMA_BYTE_COUNT;//7 @- L5 j* ~( z3 b: T! i0 V
' ?# V$ i6 Y! W0 }' C) Z \
upp_error_count = 0;2 y- B% q: {- [/ n' w
upp_dmai_int_cut = 0;7 t) O! k( ~6 {3 Z7 s
& ~0 Y9 L6 K6 u // fill in data
. J" t, h# i$ X. } uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHI, &server->transposeParA);
' Q3 E! {- o4 o2 A server_msg_send(server, APP_CMD_LOG, "upp recv: binding node to dma chi");
% v4 p) k v& Y! G' M- `9 }& u( e }
9 v" s2 j. F, S; L( U! X }
6 E: _# i/ E z& a* ] else{
: m4 O9 S* s& W/ P( s$ V4 E) U if (upp_dmai_int_cut > 0){
4 C" h4 ]" x6 t0 ]" T DataNode *node = (DataNode *)ListMP_getTail(server->upp_recv_list_free); T* j) K; j+ J1 i/ v
Uint8 *data = (Uint8 *)SharedRegion_getPtr(node->SR_buffer);6 W3 \4 T% P0 Z" H5 o7 b( ^: Y
% ^0 F% Z& D2 p: O3 T
( m( T1 c. d% T1 `: t
//copy data to upp_recv_list_busy
6 C& V+ O/ ~! I' q memcpy(data, upp_buffer_a, UPP_DMA_BUFFER_SIZE);
; T& [/ W7 v8 F* n6 n3 f
5 V7 j& w3 _4 i6 n5 b //% V5 P, @+ q; C) O
ListMP_putHead(server->upp_recv_list_busy, (ListMP_Elem *)node);
# j! }9 p: n z% w c
7 K$ _- @, E* q //
% x; E" i J! [% L7 f server->upp_channel_a_recv = false;//$ K$ `8 ], h! S4 k' V
7 X! W% H/ N0 f9 w% f' L0 O server_msg_send(server, APP_CMD_LOG, "upp recv: success");' j3 i! A+ f+ q+ t7 b; }
}
8 b. ?1 I& C! d- r }
2 |% ~8 d. f2 p1 e, a
6 b1 ] A% X+ p2 i5 S3 R/ ^$ l* b# g) a* Y; @9 P
return true;
$ C3 Y3 a, _' N" @}
* |: i( f/ ~6 I
0 c0 S5 D8 ~3 K7 j0 h7 sstatic bool server_upp_data_send(Server *server)" D" u8 t: M, y/ }: M" {
{
/ A$ ]6 i* F# m, x! L: |7 K if(ListMP_empty(server->upp_send_list_busy) == FALSE){
6 D* _' H7 ?& j l DataNode *node = (DataNode *)ListMP_getTail(server->upp_send_list_busy);! H' u- n+ h) T3 h5 M5 e% N
unsigned char *data = (unsigned char *)SharedRegion_getPtr(node->SR_buffer);& H7 E; e. g; l; p3 I; E
char tmp[128] ={0}; b) B- Y% F# i" A% e" K
$ \6 Q( N6 l# D/ b4 V server_msg_send(server, APP_CMD_LOG, "upp send: start");
( I: E5 n& w# ~3 }' x& ] print_log(server, data, 64);$ O" E' \) F! p1 h2 i$ H% l
' v7 o# |3 R' K2 m4 } //- Q# h: I6 m! M0 K2 ~. A* b
memset(upp_buffer_b, 0, UPP_DMA_BUFFER_SIZE);
# _ F7 d* `6 T# R memcpy(upp_buffer_b, data, UPP_DMA_BUFFER_SIZE);* L* t5 r$ M# k" L4 ^
print_log(server, upp_buffer_b, 64);
# L/ ?6 n! ]7 v* C, F/ D. e" q: V, L- P# C1 _. K
server->transposeParB.WindowAddress = ((unsigned int *)upp_buffer_b);/ G5 B# O3 N# T1 \0 B0 g! j8 Z
server->transposeParB.LineCount = UPP_DMA_LINE_COUNT;
+ N8 Y1 F' c; p) W) R# a( Q server->transposeParB.ByteCount = UPP_DMA_BYTE_COUNT;9 v( l9 Y) q' P4 h1 x8 h% }
server->transposeParB.LineOffsetAddress = UPP_DMA_BYTE_COUNT;
' [! N2 H4 x- J6 u! b' Z7 g8 _0 X' ?1 M! z# B
memset(tmp, 0, sizeof(tmp));
6 g# b d% b9 F4 I6 H sprintf(tmp, "upp send data: sizeof(unsigned int):%d, upp_buffer_b:%p, WindowAddress:%ud",
) E7 ], i1 I2 q; F7 J& a sizeof(unsigned int), upp_buffer_b, server->transposeParB.WindowAddress);) X( {' h( ?* b9 V6 ^/ j3 |
server_msg_send(server, APP_CMD_LOG, tmp);
' ^9 `0 e' A+ P& ^4 `. e7 V% k8 y6 y" X2 Q) Q) U9 m; J6 p
upp_error_count = 0;
" U5 R1 U+ N/ ^5 G upp_dmaq_int_cut = 0;$ e0 h( [. Q. A
// fill in data / C1 |3 A* f+ n9 l2 A% U, H2 |
uPPDMATransfer(SOC_UPP_0_REGS, uPP_DMA_CHQ, &server->transposeParB); , R1 E/ J- T" v5 [1 x# u; s, N/ g
server_msg_send(server, APP_CMD_LOG, "upp send: binding node to dma chq");$ U6 u* {! T" `2 Z- u5 [6 s
" O8 L7 D& B5 Z" I [+ B; K // wait send success
+ M) b+ |' Q0 N# f while (upp_dmaq_int_cut < 1 && upp_error_count == 0);
" J! S3 m1 m# u, K% |8 P% `( V: P3 v1 g/ `
// make data node in free list : Q- T) u6 o: c1 k1 Y
ListMP_putHead(server->upp_send_list_free, (ListMP_Elem *)node);; {* s; T$ _3 z! |& I1 \4 H$ \
server_msg_send(server, APP_CMD_LOG, "upp send: success");
6 `( J5 @$ R! s/ R }
% I- q8 ?8 B- A) ^ return true;& f% ^/ U2 D2 w
}0 C( U* {; \# z+ ^9 ]2 O
1 m$ ]4 u. h5 y# }$ M- d L9 s* q2 ?6 h. Q
4 s0 _* h X% B6 c5 E& u% N5 Z" W8 Q7 t5 i6 L" y
0 P" ~5 J9 Z6 x; |5 y4 F+ v7 ^
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|