Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

FreeRTOS 7.4 :: LWIP :: configASSERT(xInsideISR == (portBASE_TYPE) 0);

Posted by xdan01 on November 15, 2013

Hello,

i am using lwip 1.4.1 and FreeRTOS 7.4. in sys_arch.c i am getting this assert:

configASSERT(xInsideISR == (portBASE_TYPE) 0); (full code below). So im asking why is that happened ?

I am rookie at these staff so be patient :)

If anyone can help :)

Full code:

u32t sysarchmboxfetch(sysmboxt *pxMailBox, void **ppvBuffer, u32_t ulTimeOut)

{

void *pvDummy;

portTickType xStartTime, xEndTime, xElapsed;

unsigned long ulReturn;

xStartTime = xTaskGetTickCount();

if(NULL == ppvBuffer) {

ppvBuffer = &pvDummy;

}

if(ulTimeOut != 0UL) {

configASSERT(xInsideISR == (portBASE_TYPE) 0);

if(pdTRUE == xQueueReceive(pxMailBox, &(ppvBuffer), ulTimeOut / portTICKRATEMS)) {

xEndTime = xTaskGetTickCount();

xElapsed = (xEndTime - xStartTime) * portTICKRATEMS;

ulReturn = xElapsed;

} else {

/* Timed out. */

*ppvBuffer = NULL;

ulReturn = SYSARCHTIMEOUT;

}

} else {

while(pdTRUE != xQueueReceive(pxMailBox, &(ppvBuffer), portMAX_DELAY));

xEndTime = xTaskGetTickCount();

xElapsed = (xEndTime - xStartTime) * portTICKRATEMS;

if(xElapsed == 0UL) {

xElapsed = 1UL;

}

ulReturn = xElapsed;

}

return ulReturn;

}


FreeRTOS 7.4 :: LWIP :: configASSERT(xInsideISR == (portBASE_TYPE) 0);

Posted by richardbarry on November 15, 2013

I didn't realise you posted the question here too. Here is a copy of the reply I just sent to the lwIP mailing list;

configASSERT(xInsideISR == (portBASE_TYPE) 0); (full code below). So im asking why is that happened ?

I am rookie at these staff so be patient :)

If anyone can help :)

Full code:

if(pdTRUE == xQueueReceive(pxMailBox, &(ppvBuffer), ulTimeOut / portTICKRATEMS)) {

I'm not sure which code you are basing your project on, or where the xInsideISR variable is getting set, but if the code really is being called from inside an interrupt then the assert is quite right to stop you. The line above (and several other lines in your post) have two issues for use in an interrupt:

1) FreeRTOS maintains a separate API for use inside and outside interrupts. This is for several reasons, but in summary, it means you don't need any special code when entering an interrupt, you don't need to count nesting, and both the code intended for use in an interrupt and outside of an interrupt can be optimised for their single purpose. Only FreeRTOS API functions that end in "FromISR" can be used in an interrupt.

2) It just makes no program flow/sequencing sense to define a block time when you are inside an interrupt.

In any case, generally it is best to get out of the interrupt as quickly as you can, and defer processing to a task. The simple Ethernet driver on the link below is an example of how that is done. The interrupt uses an xSemaphoreGiveFromISR() function to unblock a task, then requests a yield if the task unblocked by the semaphore has a higher priority than the task the interrupt interrupted. That way, the code still runs as the very next thing, as if it were actually executed in the interrupt, but it is actually executed in a task.

http://goo.gl/iubh1m -> see the ETH_Handler() interrupt handler and the prvEMACDeferredInterruptHandlerTask() task definition.


FreeRTOS 7.4 :: LWIP :: configASSERT(xInsideISR == (portBASE_TYPE) 0);

Posted by xdan01 on November 15, 2013

Hm. Thank you very much for the answer! Am I doing something wrong ?

I dont see any staff used from FreeRTOS here. My sources are from FreeRTOS Plus Demo 2. There is used LwIP as for example. Do I need some to adjust ? Thank you for replay.

I have this:

  • LWIP src/lwIP/netif/ethernetif.c ENET_IRQHandler

Which have:

void ENETIRQHandler(void) { uint32t ulInterruptCause; extern volatile portBASETYPE xInsideISR; struct pbuf *p; struct ethhdr *pxHeader;

xInsideISR++;

while((ulInterruptCause = LPCEMAC->IntStatus) != 0) { /* Clear the interrupt. */ LPCEMAC->IntClear = ulInterruptCause;

/* Clear fatal error conditions.  */
if((ulInterruptCause & EMAC_INT_TX_UNDERRUN) != 0U) {
  LPC_EMAC->Command |= EMAC_CR_TX_RES;
}

if((ulInterruptCause & EMAC_INT_RX_DONE) != 0UL) {
  /* A packet has been received. */
  if(EMAC_CheckReceiveIndex() != FALSE) {
    if(EMAC_CheckReceiveDataStatus(EMAC_RINFO_LAST_FLAG) == SET) {
      /* move received packet into a new pbuf */
      p = prvLowLevelInput();

      /* no packet could be read, silently ignore this */
      if(p != NULL) {
        /* points to packet payload, which starts with an Ethernet header */
        pxHeader = p->payload;

        switch(htons(pxHeader->type)) {
            /* IP or ARP packet? */
          case ETHTYPE_IP:
          case ETHTYPE_ARP:
            /* Full packet send to tcpip_thread to process */
            configASSERT(pxNetIfInUse);
            if(pxNetIfInUse->input(p, pxNetIfInUse) != ERR_OK) {
              LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
              pbuf_free(p);
              p = NULL;
            }
            break;

          default:
            pbuf_free(p);
            p = NULL;
            break;
        }
      } else {
    	  return;
        //configASSERT((volatile void *) NULL);
      }
    }

    /* Release the frame. */
    EMAC_UpdateRxConsumeIndex();
  }
}

if((ulInterruptCause & EMAC_INT_TX_DONE) != 0UL) {
  /* Nothing to do here. */
}

}

xInsideISR--; }


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS