How to debug EventFlags::set mbed OS Error Info

Hi all,

I’m working with EventFlags as a simple signal between 2 different processes.

I’m calling EventFlags::set from within a mbed::CriticalSectionLock (which I’m not sure is relevant) and am getting the following error:

++ MbedOS Error Info ++
Error Status: 0x80010137 Code: 311 Module: 1
Error Message: EventFlags: 0x0, Parameter error
Location: 0x459F7
Error Value: 0x0
Current Thread: ble event processing Id: 0x20000A28 Entry: 0x47D1D StackSize: 0x1000 StackMem: 0x200151E0 SP: 0x2001607C 
For more info, visit: https://mbed.com/s/error?error=0x80010137&tgt=ARDUINO_NANO33BLE
-- MbedOS Error Info --

I’m confident the issue is related to the set as the error is not present if I remove that set. I would post the code here, however I’ve been unable to create a minimal re-production of it and it is heavily integrated into other frameworks.

My main issue is I don’t understand how set could cause this error – I did look at the source code some to try and understand, but I don’t know how to debug further.

Any help is much appreciated,
Thanks,
Tyler Hartwig

Hello Tyler,

The

static uint32_t svcRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) 

function can report a Parameter error in the following if statement:

  os_event_flags_t *ef = osRtxEventFlagsId(ef_id);
  os_thread_t      *thread;
  os_thread_t      *thread_next;
  uint32_t          event_flags;
  uint32_t          event_flags0;

  // Check parameters
  if ((ef == NULL) || (ef->id != osRtxIdEventFlags) ||
      ((flags & ~(((uint32_t)1U << osRtxEventFlagsLimit) - 1U)) != 0U)) {
    EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter);
    //lint -e{904} "Return statement before end of function" [MISRA Note 1]
    return ((uint32_t)osErrorParameter);
  }

I would recommend you to run the program with a debugger:

  • Setup a breakpoint at line 266 in file
    mbed-os/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source/rtx_evflags.c
266:        EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter);
  • When the debugger stops at this line check which parameter is wrong and try to understand why.

Best regards, Zoltan

Thanks Zoltan,

I don’t currently have a debugger, I’m additionally running on the Arduino Nano 33 BLE – so I’m not compiling mbed from source either. (GitHub - arduino/ArduinoCore-mbed)

I previously followed this source a bit deeper – I believe the “Error Value: 0x0” should correspond to the ef parameter in the if statement. If that’s the case, and ef has a value of 0x0 – that seems odd to me, I wouldn’t expect this flag to be at address 0x0. I may be misunderstanding of course.

I know a debugger would be the best way to address this, but is there any other good way to approach this? I’m confident it’s either ef == NULL or ef->id != osRtxIdEventFlags. Reflecting on that, it’s likely ef == NULL due to the Error Value.

If I’m not mistaken, that likely means some how the pointer is getting confused at some point? Best I can tell the underlying _id value shouldn’t be set to NULL from mbed.

Without a debugger it’s a very difficult task to fix it. Double check that all your objects (especially pointers) are initialized correctly …

I really appreciate the help. Is there any debugger you’d recommend for the future?

For the moment I realized a different way to implement it that will use static flags instead of flags allocated on the object – since the addressing seemed to be funky. Seems to have fixed it in my context, but it’s still a curious incident.

Previously it was allocated on an object deriving from ble::Gap::EventHandler and was setting the flags upon BLE initialization completion. The processEvents was run via event queue and dedicated thread. Just adding that for context incase someone else comes across this in the future.

Thanks again!