Code hangs in _port_switch, any clues?

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: barthess, RoccoMarco

Glowtape
Posts: 2
Joined: Sun Dec 24, 2017 2:49 am

Code hangs in _port_switch, any clues?

Postby Glowtape » Sun Dec 24, 2017 2:56 am

Hi,

I've been moving the flight firmware dRonin from ChibiOS 2.6.6 onto 17.6.3. Everything seems to compile fine and the STM32F405RGT-based test boards fire up and reach the main() function just fine, halInit() and chSysInit() execute without error. But once I create the very first thread (outside ChibiOS' idle thread), the MCU will hang at _port_switch in chcoreasm_v7m.s. At least that's where I've tracked it down to with a code canary. I haven't any more details, I'm yet to receive my STLink (never really needed it up until now). Any ideas what this might usually be a symptom of?

Thanks for any hints.

User avatar
Giovanni
Site Admin
Posts: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: Code hangs in _port_switch, any clues?

Postby Giovanni » Sun Dec 24, 2017 7:06 am

Hi,

Hard to tell but please make sure:
1) Use a makefile from the new version.
2) Use xxxconf.h files from the new version.
3) Enable debug options in chconf.h and see if something is caught.

Giovanni

Glowtape
Posts: 2
Joined: Sun Dec 24, 2017 2:49 am

Re: Code hangs in _port_switch, any clues?

Postby Glowtape » Thu Jan 04, 2018 6:12 pm

I got my STLink and had a fun time.

The reason things went sideways were how our Makefiles and ChibiOS went together. A bunch of changes I made to get things to compile caused the FPU configuration not being handled correctly, leading to the CORTEX_USE_FPU flag being present in the assembler compilation, but not in the C compilation. So the context struct didn't have any FPU registers, but the context switching code assumed them to be there. So it picked the data for the program counter from the wrong place.

User avatar
Giovanni
Site Admin
Posts: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: Code hangs in _port_switch, any clues?

Postby Giovanni » Thu Jan 04, 2018 6:46 pm

Hi,

Makefiles pass those flags to both C and ASM modules. If in doubt look in makefiles provided with demos.

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 10 guests