This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

(CycloneTCP) - osSemaphoreWait hangs

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.

Parents
  • 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 ?

Reply
  • 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 ?

Children
  • 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 :-)