STM32F103C8T6 I2C halting with "priority prder violation" Topic is solved

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

Moderator: RoccoMarco

Post Reply
ManWithACrowbar
Posts: 3
Joined: Thu Dec 18, 2025 5:42 pm
Been thanked: 1 time

STM32F103C8T6 I2C halting with "priority prder violation"

Post by ManWithACrowbar »

Hello, everyone. I was trying to implement a simple I2C scanner using ChibiOS v. 7.0.5 on STM32F103C8T6 using custom build environment (CMake-based). I ran into issue, when I try to scan the bus, chSysUnlock() in i2cReleaseBus fails on assert "priority order violation". I do not understand, what am I doing wrong, since I am not using any locking in my own code whatsoever. Could anyone please help me resolve the issue? Code can be accessed by link: https://github.com/PortiaLabiata/katetris. Thanks!
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F103C8T6 I2C halting with "priority prder violation"

Post by Giovanni »

You are getting a ready list corruption probably caused by invalid API usage, try enabling the "state checker" in chconf.h and verify if there are context violations.

Giovanni
ManWithACrowbar
Posts: 3
Joined: Thu Dec 18, 2025 5:42 pm
Been thanked: 1 time

Re: STM32F103C8T6 I2C halting with "priority prder violation"

Post by ManWithACrowbar »

Thank you for your reply. State checking is already enabled and doesn't seem to fire (as I understand, it is supposed to halt system in case of a context violation, but halt happens from here:
[spoil]#0 chSysHalt (
reason=reason@entry=0x8006e78 <__func__.4> "chSysUnlock")
at /home/portia_labiata/katetris/chibios/os/rt/src/chsys.c:232
#1 0x08004ee6 in chSysUnlock ()
at /home/portia_labiata/katetris/chibios/os/rt/include/chsys.h:430
#2 chMtxUnlock (mp=mp@entry=0x200020cc <I2CD1+12>)
at /home/portia_labiata/katetris/chibios/os/rt/src/chmtx.c:396
#3 0x08001c0e in osalMutexUnlock (mp=0x200020cc <I2CD1+12>)
at /home/portia_labiata/katetris/chibios/os/hal/osal/rt-nil/osal.h:1082
#4 i2cReleaseBus (i2cp=i2cp@entry=0x200020c0 <I2CD1>)
at /home/portia_labiata/katetris/chibios/os/hal/src/hal_i2c.c:297
#5 0x080002c6 in i2c_scan ()
at /home/portia_labiata/katetris/display.c:35
#6 0x0800017e in thd_video (arg=<optimized out>)
at /home/portia_labiata/katetris/main.c:27
#7 0x080041ca in __port_thread_start ()
at /home/portia_labiata/katetris/chibios/os/common/ports/ARMv7-M/compilers/GCC/chcoreasm.S:203[/spoil]
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F103C8T6 I2C halting with "priority prder violation"

Post by Giovanni »

Check for possible stack overflows also, try increasing stacks and see if there is change.

Giovanni
ManWithACrowbar
Posts: 3
Joined: Thu Dec 18, 2025 5:42 pm
Been thanked: 1 time

Re: STM32F103C8T6 I2C halting with "priority prder violation"

Post by ManWithACrowbar »

I found the issue, appearently I forgot to divide sizeof of int array by sizeof(int), which caused loop to go over a huge chunk of RAM, likely corrupting ready list in the process. Thank you, please close the thread.
Post Reply