I have installed CMSIS_RTX on my Infineon XMC4800 microcontroller (ARM Cortex M4). I have also installed CycloneTCP Tcp/Ip stack on top of it and everything compiles fine. CycloneTCP is a free, opensource library which implements a lot of protocols.
However, when I try one of the examples comming with CycloneTCP for XMC4800, the system hangs when the tcp/ip stack is initialized at the very beginning of the code.
At some place, an OsEventCreate call is made which creates a semaphore. The semaphore is created successfully, but the call to osSemaphoreWait hangs.
bool_t osCreateEvent(OsEvent *event) { //Create a binary semaphore object event->id = osSemaphoreCreate(&semaphoreDef, 1); //Check whether the returned semaphore ID is valid if(event->id != NULL) { //Force the specified event to the nonsignaled state osSemaphoreWait(event->id, 0); ...
I am using the correct drivers for my PHY and for my Ethernet Interface.
Does someone know/have the same experience why the system hangs. It seems unlogical because the call to osSemaphoreWait should return immediately when the resource is locked.
I blocks on the instruction BLX R4 in SVC_User() function in HAL_CM4.S
I have little experience in RTOS, so any help is very welcome. I'm glad to hear it if more info is needed.
Thanks for the answer. I have checked it and the Infineon Optimized IFX library is included.
Meanwhile, I have changed from the Infineon DAVE IDE to the KEIL uVision 5 IDE. I have created a project including the cycloneTCP pack and the following CMSIS components:
- CMSIS Core 5.0.0 - CMSIS / RTOS (API) / Keil RTX (IFX variant) - optimized for Infineon XMC - CMSIS Driver / Ethernet PHY / KSZ8081 - Device / Startup - System startup for infineon
My project compiles fine but it hangs again. Keil UVision has better thread-inspect features and I see the following thread status :
- osTimerThread - prio HIGH - Wait_MBX - main - prio NORMAL - Ready - netTask - prio ABOVENORMAL - Running
So it seems that the osTimerThread is waiting on some mailbox message.
//TCP/IP stack initialization TRACE_INFO("Before netInit()\r\n"); error = netInit(); TRACE_INFO("After netInit()\r\n"); //Any error to report? if (error) { //Debug message TRACE_ERROR("Failed to initialize TCP/IP stack!\r\n"); } //Configure the first Ethernet interface interface = &netInterface[0]; //Set interface name TRACE_INFO("Before netSetInterfaceName()\r\n"); netSetInterfaceName(interface, "eth0"); TRACE_INFO("After netSetInterfaceName()\r\n");
The system blocks on the 'netSetInterfaceName(...)' function. In my terminal, the 'after netsetinterfacename' debug string never appears.
Running the HTTP Server demo included with the CycloneTCP works immediately out of the box/without any change on the Keil Uvision IDE. The same piece of code as above is used and it works perfectly. However, this example uses FreeRTOS.
Any idea what could be wrong here ?
Update: After some further debugging, I found that I got a stackoverflow error. So increasing the statcksize solved the problem and de tcp/ip stack is initialized.
The next problem I have to solve now is that during the ARP (address resolution protocol), I get a message "memory allocation failed!".
Ethernet frame received (64 bytes)... Dest Addr = FF-FF-FF-FF-FF-FF Src Addr = B8-27-EB-80-45-B3 Type = 0x0806 ARP packet received (46 bytes)... Hardware Type (hrd) = 0x0001 Protocol Type (pro) = 0x0800 Hardware Address Length (hln) = 6 Protocol Address Length (pln) = 4 Opcode (op) = 1 Sender Hardware Address (sha)= B8-27-EB-80-45-B3 Sender Protocol Address (spa) = 10.0.0.2 Target Hardware Address (tha)= 00-00-00-00-00-00 Target Protocol Address (tpa) = 10.0.0.3 ARP Request received... Memory allocation failed!
The microcontroller has IP address 10.0.0.3 and my Raspberry Pi has 10.0.0.2
Probably, my Heap size is too small ?
Hello Dimitri,
By upgrading Oryx-Embedded::Middleware software pack to version 1.7.6, you will find some ready-to-compile examples that demonstrate CycloneTCP + CMSIS-RTOS directly on the XMC4800 Relax Kit (HTTP server, MQTT client and SNMP agent).
If you consider CMSIS-RTOS2 (RTX v5) instead of CMSIS-RTOS, you can modify the project as follows:
- Open "Manage Run-Time Environment" - Unselect CycloneCommon::RTOS Port::CMSIS-RTOS component - Select CycloneCommon::RTOS Port::CMSIS-RTOS2 component - Unselect RTOS::Keil RTX component - Select RTOS2::Keil RTX5 component - Edit RTX configuration file (CMSIS -> RTX_Config.c) and change the default of OS_DYNAMIC_MEM_SIZE. A value of 30000 is OK to start with
Regards,
Thanks for the reply.
I managed already to get the CycloneTCP working with Keil. Indeed, it seemed that my stack and heap sizes were too small. I am still a newby on embedded software etc. So it took me a while to figure it out.
I works like a charm now :-)