Hello! Is there any examples or documents where I can find information on how to configure and use ENET on MPC5748G?
Solved! Go to Solution.
Hi alextimpau, here is the code.
It is targeted to NXP X-MPC574xG-Mother board and Daughter card board. And this project is made using S32 Design Studio for Power.
It will toggle LED DS2 when it receives the data.
You can use Packet Sender app for this.
Finally it sends packets using UDP protocol.
You can check the D-Cache at first, I disable the D-cache in the startup.S. Because the Rx Description and Tx Description for ENET must be in the un-cachable memory space. The default project which is built by S32DS enables the D-cache. I disable D-cache just for convenient. You can configure the D-cache for memory and put the Rx Description and Tx Description in the un-cachable memory space.
Best Regards
Neil Li (李越)
How to configure the D-cache for memory and put the ENET Rx Description and Tx Description in the un-cachable memory space?
Hi tomyqg,
as lukaszadrapa mentioned in this thread mpc5748g enet d-cache you have to configure the SMPU (System Memory Protection Unit) according to the example. To only have the Rx and Tx descriptors non cachable I defined a section in Project_Settings/Linker_Files/sections.ld at the text section with this content:
/* area excluded from d-cache and i-cache via smpu */
.non_cache (NOLOAD) : ALIGN(64)
{
__NON_CACHE_START = .;
*(.lwip_descriptors);
__NON_CACHE_END = .;
} > m_data AT>m_text
Then I told the linker to put the descriptors to this section (in eth.c):
__attribute__(( aligned(64), section(".lwip_descriptors") ))
Finally the SMPU must be configured to prevent caching at this section (this is mostly copied from the example):
extern char __NON_CACHE_START; // sourced from Project_Settings/Startup_Code/sections.ld
extern char __NON_CACHE_END; // sourced fromProject_Settings/Startup_Code/sections.ld
void smpu_config(void) {
/* Ensure SMPU modules are disabled */
SMPU_0.CES0.B.GVLD = 0; /* Allow all accesses from all masters to SMPU0 */
SMPU_1.CES0.B.GVLD = 0; /* Allow all accesses from all masters to SMPU1 */
/* Create desired memory regions */
/* Region 0: From __NON_CACHE_START to __NON_CACHE_STOP disable caching
this is from the beginning of RAM to __NON_CACHE_STOP */
SMPU_1.RGD[0].WORD0.R = (uint32_t)&__NON_CACHE_START; /* Region start addr- start of SRAM */
SMPU_1.RGD[0].WORD1.R = (uint32_t)&__NON_CACHE_END; /* Region end addr- end of SRAM */
SMPU_1.RGD[0].WORD2.FMT0.R = 0xFFFFFFFF; /* ALL masters can read/write */
SMPU_1.RGD[0].WORD3.R = 0x00000002; /* Region non-cacheable: Cache Inhibit=2*/
SMPU_1.RGD[0].WORD4.R = 0x00000000; /* PID not included in region eval. */
SMPU_1.RGD[0].WORD5.R = 0x00000001; /* Region is valid without lock */
/* Region 1: enable caching for the rest of RAM */
SMPU_1.RGD[1].WORD0.R = (uint32_t)&__NON_CACHE_END; /* Reg start addr*/
SMPU_1.RGD[1].WORD1.R = 0x400BFFFF; /*Region end */
SMPU_1.RGD[1].WORD2.FMT0.R = 0xFFFFFFFF; /* ALL masters can read/write */
SMPU_1.RGD[1].WORD3.R = 0x00000000; /* Region cacheable: Cache Inhibit=0*/
SMPU_1.RGD[1].WORD4.R = 0x00000000; /* PID not included in region eval. */
SMPU_1.RGD[1].WORD5.R = 0x00000001; /* Region is valid without lock */
/* Enable all SMPU regions in module */
/* SMPU_0.CES0.B.GVLD = 1;*/ /* -- NOT USED IN CODE EXAMPLE --SMPU0 */
SMPU_1.CES0.B.GVLD = 1; /* SMPU1 is enabled */
}
I hope that helps.
Regards,
Bernhard
I am also working on the Ethernet for MPC5748G. I am also having same trouble. sondre89 did you successfully run the ENET program. If yes please can you share the code.
Thanks.
Hello! Im currently working with something else right now, so i have not been able to complete my ethernet code. However, I have confirmed that the example code, with some changes to the gpio's to fit 5748G, is able to transmit data out of the processor to the ethernet controller.
Thank you sondre89 for the reply. I was able to run the Ethernet program after changing GPIO.
Thank you.
Hello, Kushal Shah! I am also working on the Ethernet for MPC5748G, but i don't know what i need to change in the example code to run the Ethernet program correctly. if it's possible, please can you share your project code.
Regards,
Alex.
Hi alextimpau, here is the code.
It is targeted to NXP X-MPC574xG-Mother board and Daughter card board. And this project is made using S32 Design Studio for Power.
It will toggle LED DS2 when it receives the data.
You can use Packet Sender app for this.
Finally it sends packets using UDP protocol.
hi
in attached file "Ethernet_udp_S32DS" file i don't see main.c file then how to use these
file.is these file compatible for mpc5775b
Thank you, this code clarified my ideas.
Now I would like to make two boards communicate between them via ENET and I suppose I need to set a static IP in order to setup the data exchange, but I am not sure I will only need that.
I would appreciate a lot if you could give me some tips.
Thanks in advance,
Antonio
Hi,Kushal:
Can I share "Ethernet_udp_S32DS. Zip" again?
I downloaded the decompression times error, indicating that the data is corrupted.
Best Regards
Arlene
Hi Kushal !
Thanks for the code. I am able to transmitt and trace packets sent by EVAL board to PC but I am not able to receive the packets using packet sender app. I configured IP and port correctly but I am not able receive the frames. What changes needs to do in the code to do the same?
kushalshah13, that worked perfectly! I finally had time to work on this issue again. I have not tried the Lwip project yet, however this does the job I was looking for. In my project I was using c++, do you know if there is any issues using c++ instead of C?
sondre89 That is great. Can you share what was the problem? And can you share the working project so others can take reference too. I think there should not be any issue with C++.
The problem was that I used ARP type value in my UDP packet frame. I also added the peri_clock_gating. Not quite sure what this does. Need to read more about that.
Now I'm using wireshark to listen to the traffic that i generate and I can see the UDP traffic. I also have packet sender (the application) up and running. Still have some issues with receving part. However that can be the packet sender application, or maby some user issues :smileywink: Before I uploading the code I need to cleen it up and the receive part need to work :smileyhappy:
I fixed IPv4 and UDP checksum problem. One bit need to set, even if use or no FIFO mode. The document show it need to set, but don't explain why.
ENET.TFWR.B.STRFWD =1; | // Enabled Store And Forward |
Hi Kushal Shah
I'm working with MPC5748G rev1. It could send UDP packagee, but IP checksum and UDP checksum are zero.
I seted the IP and UDP checksum field to be cleared on the frame, and seted
/* chechsum on Initialize
ENET.TACC.B.PROCHK = 1;
ENET.TACC.B.IPCHK = 1;
txbd[j].status8 = TX_BD_S8_PINS | TX_BD_S8_IINS |TX_BD_S8_INT; //Add Protocol header checksum and IP header checksum
But it was strange that IP checksum and UDP checksum on any receive package are zero. It looked like Insert checksum did not work.
Best regards,
Yu
Hi Kushal Shah,
Does this project work for both TX and RX? I have a modified version working for the MPC5777M and TX is working perfectly, however, on receiving a packet, the buffer that the FEC RX Buffer Register points to is only updated once upon reception (as tested through a debugger's memory map interrupt). In this way, if i receive a packet, i can read the data fine, and the second packet is also able to be read (as there are two buffers defined), but in receiving further packets, the FEC RXF interrupt goes high, but the buffer is not updated. TX is working perfectly; buffer et al. Any ideas on this?
I looked at the program. It seems like it receives ARP packets sent by computer. But it is not receiving the UDP packets. I am still looking at the problem.
Hi kushalshah13,
Thank you for your example project.
I am also working on the Ethernet for MPC5748G. I have the X-MPC574xG-Mother board and Daughter card board.
Can you tell me how to you test the project whether it works right?
Did you recrive packet by Wireshark?
And can you tell me which Packet Sender app can be helpful?
Thank you very much!
Qiang