I need to enable GDMA in esp32c3 but I get descriptor error, did I fill descriptor correctly?

Abdulrhman_Battikh
Posts: 2
Joined: Thu Feb 23, 2023 7:34 pm

I need to enable GDMA in esp32c3 but I get descriptor error, did I fill descriptor correctly?

Postby Abdulrhman_Battikh » Thu Feb 23, 2023 8:15 pm

  1. #include "gdma_struct.h"
  2. typedef struct dma_link {
  3.     struct {
  4.         uint32_t size :    12;      //the size of buf, must be able to be divisible by 4
  5.         uint32_t length:   12;      //in link,
  6.         uint32_t reversed: 6;       //reversed
  7.         uint32_t eof:      1;       //if this dma link is the last one, you shoule set this bit 1.      
  8.         uint32_t owner:    1;       //the owner of buf, bit 1 : DMA, bit 0 : CPU.
  9.     } des;
  10.     uint8_t *buf;                   //the pointer of buf
  11.     struct dma_link *pnext;    //point to the next dma linke, if this link is the last one, set it NULL.
  12. } dma_link_t;
  13.  
  14. dma_link_t dma_trans;
  15. dma_link_t dma_receive;
  16.  
  17. uint8_t transmit[5]="hello";
  18. uint8_t receive[5]={0};
  19. void app_main()
  20. {
  21. //load outlink
  22. dma_trans.des.size = 0;
  23. dma_trans.des.length = 5;
  24. dma_trans.des.eof = 1;
  25. dma_trans.des.owner = 1;
  26. dma_trans.buf = transmit;
  27. dma_trans.pnext = NULL;
  28. //load inlink
  29. dma_receive.des.size = 5;
  30. dma_receive.des.length = 0;
  31. dma_receive.des.eof = 1;
  32. dma_receive.des.owner = 1;
  33. dma_receive.buf = receive;
  34. dma_receive.pnext = NULL;
  35.  
  36. //reset GDMA's transmit channel
  37. GDMA.channel[0].out.out_conf0.out_rst = 1;
  38. GDMA.channel[0].out.out_conf0.out_rst = 0;
  39. //reset GDMA's receive channel
  40. GDMA.channel[0].in.in_conf0.in_rst = 1;
  41. GDMA.channel[0].in.in_conf0.in_rst = 0;
  42. //address of the transmit descriptor  
  43. GDMA.channel[0].out.out_link.addr = (((uint32_t)&(dma_trans)) & (0xfffff << 0));
  44. //address of the receive descriptor
  45. GDMA.channel[0].in.in_link.addr = (((uint32_t)&(dma_receive)) & (0xfffff << 0));
  46. //enable memory to memory transfer
  47. GDMA.channel[0].in.in_conf0.mem_trans_en = 1;
  48. //enable transmit channel
  49. GDMA.channel[0].out.out_link.start = 1;
  50. //enable receive channel
  51. GDMA.channel[0].in.in_link.start = 1;
  52. }
  53.  

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: I need to enable GDMA in esp32c3 but I get descriptor error, did I fill descriptor correctly?

Postby ESP_Sprite » Fri Feb 24, 2023 1:36 am

Code: Select all

dma_trans.des.size = 0;
Try setting this to the same as .des.length, rounded to the next multiple of 4.

Abdulrhman_Battikh
Posts: 2
Joined: Thu Feb 23, 2023 7:34 pm

Re: I need to enable GDMA in esp32c3 but I get descriptor error, did I fill descriptor correctly?

Postby Abdulrhman_Battikh » Sat Feb 25, 2023 8:59 am

I set dma_trans.des.size but I did't get any response, but I read in technical reference for esp32c3 in system and memory chapter the following:
""when accessing a memory via GDMA, a corresponding access permission is nedded, otherwisethis access may fail""
also:
""All of the internal memories are managed by Permission Control module. An internal memory can only be accessed
when it is allowed by Permission Control, then the internal memory can be available to the CPU""
in the default mode, is access permission enabled for GDMA?
is there another reason for my problem?

Who is online

Users browsing this forum: Google [Bot] and 108 guests