strange behavior of the scheduler on STM32F070 Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: strange behavior of the scheduler on STM32F070

Postby Giovanni » Sun Nov 11, 2018 9:56 pm

Is the USB connected to an host?

Giovanni

dash
Posts: 17
Joined: Thu Oct 25, 2012 10:16 pm
Has thanked: 1 time
Been thanked: 4 times

Re: strange behavior of the scheduler on STM32F070

Postby dash » Sun Nov 11, 2018 10:09 pm

yes, the USB connected to host.
I just checked, without connection (power only), the system works for a long time

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

Re: strange behavior of the scheduler on STM32F070

Postby Giovanni » Sun Nov 11, 2018 10:20 pm

Then it is likely related to USB, probably the simple code you shown is not relevant to the problem.

Giovanni

dash
Posts: 17
Joined: Thu Oct 25, 2012 10:16 pm
Has thanked: 1 time
Been thanked: 4 times

Re: strange behavior of the scheduler on STM32F070

Postby dash » Sun Nov 11, 2018 10:58 pm

yes, it seems to USB-related, but the chThdSleepMillisecond() also has an impact
for example, this code works fine

Code: Select all

  while (true)
  {
    uint8_t rxbyte = streamGet(&SDU1);
  }

moreover, commands are correctly received and sent over USB-serial.
more complex code works fine (with SPI and PWM blocks enabled)
but as soon as I insert chThdSleepMillisecond(), I get a system crash :(

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: strange behavior of the scheduler on STM32F070

Postby faisal » Sun Nov 11, 2018 11:20 pm

Please post the version output from your compiler.

dash
Posts: 17
Joined: Thu Oct 25, 2012 10:16 pm
Has thanked: 1 time
Been thanked: 4 times

Re: strange behavior of the scheduler on STM32F070

Postby dash » Sun Nov 11, 2018 11:35 pm

arm-none-eabi-gcc.exe (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907]
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


btw, with disabled optimizations (-O0) it works :)
Now I will find a module that is incorrectly compiled

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: strange behavior of the scheduler on STM32F070

Postby faisal » Sun Nov 11, 2018 11:43 pm

I haven't looked at this issue in detail sorry. But have you considered placing a hardware memory watchpoint in a strategic location to catch the culprit in action?

dash
Posts: 17
Joined: Thu Oct 25, 2012 10:16 pm
Has thanked: 1 time
Been thanked: 4 times

Re: strange behavior of the scheduler on STM32F070

Postby dash » Mon Nov 12, 2018 12:50 am

disabling of optimization for the os/hal/ports/STM32/LLD/TIMv1/hal_st_lld.c seems to have completely solved the problem.

hmm... faisal, I don't know where is this strategic location. empty readylist is normal situation, but chSchDoReschedule() call should be blocked by chSchIsPreemptionRequired()
in this case chSchDoReschedule() is in some fantastic way called bypassing conditions
besides, I don't really understand how context switching happens

in addition, the cortex-m0 has very limited debugging facilities. I could not even set a memory breakpoint with write condition :(

dash
Posts: 17
Joined: Thu Oct 25, 2012 10:16 pm
Has thanked: 1 time
Been thanked: 4 times

Re: strange behavior of the scheduler on STM32F070

Postby dash » Mon Nov 12, 2018 6:57 pm

as I expected, the function ST_HANDLER is incorrectly optimized. Unfortunately, gcc does not allow switching the optimization inside the function.
going to deeply learn ARM assembler :)

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

Re: strange behavior of the scheduler on STM32F070

Postby Giovanni » Mon Nov 12, 2018 7:04 pm

Yes, GCC allows to optimize the single function, look into the manual, it is one of the __attribute__ of functions.

Strange anyway, I never experienced it, you could return to one of the 6.x versions, it would also be a good idea to report it.

Could you explain the problem? just to make sure it is not a problem in OUR code.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 15 guests