Crashing in ulPortSetInterruptMask within xPortSysTickHandler (Attempting new port for STM32F107)

dibosco wrote on Wednesday, May 18, 2016:

I’ve spent a lot of time fruitlessly trying to get USB going on the very old STM32F107 port for Rowley Crossworks that we’ve been using for a couple of years with uIP. Then we tried generating a FreeRTOS project from STM’s Cube to get the USB going, but although that kind of worked, if you plugged and unplugged, then replugged the USB cable it crashed. I spent some time on this and just couldn’t fathom it.

So, finally today I decided to create a new FreeRTOS Project with Rowley Crossworks, use the latest STM libraries and import an run to complete project that works with USB as a CDC class just fine.

Everything seemed to be going well, I got an LED flash task going and I was happy, until I tried sending what was coming in on the virtual com port to a queue rather than just echoing it back within the interrupt. I’m now chasing my tail trying to stop it getting hard fault handler errors all the time.

I found that my two threads (USB thread to handle what was put in the CDC queue within the USB interrupt and an LED flash thread) were not getting called more than once. I then wondered whether the timer tick wasn’t set up properly, compared interrupt vectors in my old F107 project and realised that vectors were indeed not set up. I imported the startup.s file and modified the vectors to be the same as the old F107 FreeRTOS project, but now I am just getting crashes all the time, no matter what I try. I’ve had it crash at SVC_Handler and now after tinkering a bit more I’m just crashing all the time in xPortSysTickHandler() when it calls ulPortSetInterruptMask(). As soon as I step into the asm_volatile line that is in the ulPortSetInterruptMask function, I get a hard fault exception.

I suspect this isn’t really enough to help me track this down, but thought it was worth a try. I’m running the project on the STM3210C-EVAL for what it’s worth.

If anyone has any pointers or needs any more information to try to track this down I’d be most grateful.



dibosco wrote on Wednesday, May 18, 2016:

For the moment, I’ve recreated from scratch the basic bare bones
FreeRTOS with just the LED flash and it’s working. I’ve put it into
Mercurial this time so can always roll back to here. I’ll add the USB
and see whether I get back to this same stage.

I’d forgotten I’d added the three lines:

#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler

To FreeRTOSConfig.h and that it can’t have been a timer tick issue
because the LED Flash thread was originally working fine.

I may be back for advice if I keep struggling when adding the queue in
the USB code hinders me.