What is spinlock and how to avoid assert spinlock_acquire error

listout
Posts: 31
Joined: Wed Mar 16, 2022 10:54 am

What is spinlock and how to avoid assert spinlock_acquire error

Postby listout » Wed Jun 01, 2022 12:21 pm

I'm new to new to FreeRTOS. I'm getting this failed assert errors when writing to flash storage (SPIFFS file system). I don't know whether I'm doing something wrong. Any help would be good.

More info: I'm trying to write a character array of size 1024 ever 31 millisecond or almost at 10 Hz.

Little backtrace

Code: Select all

assert failed: spinlock_acquire spinlock.h:123 ((result == SPINLOCK_FREE) == (lock->count == 0))


Backtrace:0x40081bbe:0x3ffdbe700x400911e1:0x3ffdbe90 0x40095fed:0x3ffdbeb0
0x400916f5:0x3ffdbfd0 0x40091eec:0x3ffdbff0 0x40190f59:0x3ffdc030 0x400e76f1:0x3ffdc050 
0x400dfa48:0x3ffdc070 0x400dfa5f:0x3ffdc090 0x400e23cd:0x3ffdc0b0 0x400e2115:0x3ffdc0e0
0x400e1511:0x3ffdc110 0x400e154b:0x3ffdc150 0x400d9375:0x3ffdc180 0x400d9570:0x3ffdc1c0
From this https://www.esp32.com/viewtopic.php?p=35417#p35417 thread, I learned a little bit more about spinlock and would like to avoid these kinds of errors. Would using mutex help in such a situation?

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: What is spinlock and how to avoid assert spinlock_acquire error

Postby ESP_Sprite » Thu Jun 02, 2022 5:17 am

Spinlock errors tend to be caused by an issue somewhere else: memory corruption, using an API in unintended ways, ... Can you post your code (or even better: code that has as much as possible deleted while still showing the error) so we can see if there's something off about it?

brand17
Posts: 7
Joined: Wed Jun 01, 2022 6:16 pm

Re: What is spinlock and how to avoid assert spinlock_acquire error

Postby brand17 » Sat Jul 30, 2022 10:37 am

In my case it was a memory issue. See here https://stackoverflow.com/questions/731 ... ck-acquire

amnzak
Posts: 1
Joined: Sun May 05, 2024 1:55 pm

Re: What is spinlock and how to avoid assert spinlock_acquire error

Postby amnzak » Sun May 05, 2024 1:57 pm

I myself solved the problem with removing sscanf function, seems that has a problem with freertos.

Who is online

Users browsing this forum: Google [Bot] and 110 guests