Menu

#167 Dummy StaticTimer_t size does not match Timer_t size

v1.0 (example)
closed-fixed
nobody
None
5
2018-05-08
2018-05-02
No

I am running FreeRTOS 10.0.1.
When creating a static timer using xTimerCreateStatic, the following is assserted:
configASSERT( xSize == sizeof( Timer_t ) );

This is because StaticTimer_t is 26 bytes long and Timer_t is 24 bytes long.
Can you tell me the best way to get around this? I currently have the assert commented out, but I really don't want to modify the base Timers.c file.

Thanks!

Discussion

  • Richard Barry

    Richard Barry - 2018-05-02

    Do you have configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES set to a non zero
    value? If so, please try it with
    configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES set to 0 and report back. If
    that fixes your issue then have a look at this post:
    https://sourceforge.net/p/freertos/bugs/166/

     
  • Nicole Hughes

    Nicole Hughes - 2018-05-03

    Hi Richard.
    Thanks for the quick response. I did see that other post before I submitted mine. Unfortuanatley, setting configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES to 0 doesn't resolve the issue. These static timer structures don't actually use the integrity check bytes.

    It looks to me like the reason the reason StaticTimer_t doesn't match XTIMER is that XTIMER contains a callback function and StaticTimer_t does not:
    TimerCallbackFunction_t pxCallbackFunction

    Let me know what you think.
    Nicole

     
    • Richard Barry

      Richard Barry - 2018-05-03

      List_t is used in the timer structure, hence
      configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES makes a difference to the size
      of the timer structure, but not the static timer structure.

      The callback function is accounted for by the second position in the
      pvDummy5[2] array.

      Our tests do not show a discrepancy here - both structures appear to
      have the same size, but not 26 bytes or 24 bytes, so we must be using
      different ports. Can you please tell me which FreeRTOS port (chip) you
      are using.

       
  • Nicole Hughes

    Nicole Hughes - 2018-05-03

    We are using the IAR MSP430X port.

    I figured out the problem, though. I am using the MEDIUM data model and in that model a void pointer is 2 bytes, but the function pointer TimerCallbackFunctiont pxCallbackFunction is 4 bytes. So, that is why the two structures weren't equal.

    I can switch to the Large model and both structures are equal and that fixes the issue. However, that is going to greatly increase the data size.

    Is there a plan to port the Timers code for MSP430X, so the Medium model can be used?

     
    • Richard Barry

      Richard Barry - 2018-05-03

      That is good information. Can you please try replacing the definition
      of StaticTimer_t with the following, and let me know if this now works
      with both memory models:

      typedef struct xSTATIC_TIMER
      {
          void                *pvDummy1;
          StaticListItem_t    xDummy2;
          TickType_t          xDummy3;
          UBaseType_t         uxDummy4;
          void                *pvDummy5;
          TaskFunction_t      *pvDummy6;
          #if( configUSE_TRACE_FACILITY == 1 )
              UBaseType_t     uxDummy7;
          #endif
      
          #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( 
      configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
              uint8_t         ucDummy8;
          #endif
      
      } StaticTimer_t;
      
       
  • Nicole Hughes

    Nicole Hughes - 2018-05-07

    Almost. It works with both memory models if you remove the pointer from pvDummy6. Like this:

    typedef struct xSTATIC_TIMER
    {
    void pvDummy1;
    StaticListItem_t xDummy2;
    TickType_t xDummy3;
    UBaseType_t uxDummy4;
    void
    pvDummy5;
    TaskFunction_t xDummy6;
    #if( configUSE_TRACE_FACILITY == 1 )
    UBaseType_t uxDummy7;
    #endif

    #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && (configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
        uint8_t         ucDummy8;
    #endif
    

    } StaticTimer_t;

    Is this something we can expect in a future release?
    I am not sure if there are other issues like this in other areas of Timers.c. I've only tried the Static Timers.

    Thanks,

    Nicole

     
  • Nicole Hughes

    Nicole Hughes - 2018-05-07

    Let me try formatting that again:

    typedef struct xSTATIC_TIMER
    {
        void                *pvDummy1;
        StaticListItem_t    xDummy2;
        TickType_t          xDummy3;
        UBaseType_t         uxDummy4;
        void                *pvDummy5;
        TaskFunction_t      xDummy6;
        #if( configUSE_TRACE_FACILITY == 1 )
            UBaseType_t     uxDummy7;
        #endif
    
        #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && (configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
            uint8_t         ucDummy8;
        #endif
    
    } StaticTimer_t;
    
     
  • Richard Barry

    Richard Barry - 2018-05-07
    • status: open --> closed-fixed
     
  • Richard Barry

    Richard Barry - 2018-05-07

    Ah - right yes - TaskFunction_t is already a pointer so the way I posted it it was a pointer to a pointer. That didn't show in my test as the function pointer and pointer to pointer were the same size.

    Yes, if this works for you then I can check it in (with the pointer removed as per your post). Setting ticket to 'closed fix' with this solution.

     
  • Nicole Hughes

    Nicole Hughes - 2018-05-08

    Yes, sounds good. Do you know what release this might go into?

     

Log in to post a comment.

Auth0 Logo