-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
µSD-logging fails in combination with other SPI decks like loco-deck and flow-deck #270
Comments
I've started to investigate this and my first impression is that the usdWriteTask doesn't get time to run. Will investigate further why and if so really is the case. |
The problem has also been observed with the flow deck: https://forum.bitcraze.io/viewtopic.php?f=2&t=2821 |
I played around with changing the task priorities of the USDLOG_TASK_PRI and USDWRITE_TASK_PRI as well as the priority of the "pamotion" task of the flow deck (it was hard coded to 3). However, apart from not getting enough runtime, there also appears to be a mutex hold problem. For the values The following error occurs: With these settings this always happens, with the standard settings it only happens sometimes. |
I made an interesting discovery when playing around with the baudrate for SPI communication: Unfortunately, a watchdog timeout sometimes occurs when starting up using these settings (with no logged assert). I only have one crazyflie for testing, so I can't verify the behaviour. Well, priorities and baudrate are just the most obvious settings that I think may lead to this issue. |
I quickly looked at this too and I could not find an easy solution, but I got a bit wiser. Getting fast enough bus access is one of the reasons. The flow deck runs on max 2MHz clock and the loco deck does a lot of small accesses. Either of these is giving the sd-card problems. Why it just stops logging I don't know though, that feels like a bug. Optimizing the SPI access could be one way forward and e.g. only switch SPI speed of needed. Another thing would be to look at the mutex protection of the SPI driver. Maybe it doesn't work as it is supposed to. |
In order to use both flow and SD decks, I change the SD port from spi1 to spi3. After changing the related driver as well as DMA stream, it can log for any long time while flow deck is working. However, this is not the direct way to solve the bug. Look forward to seeing the smart solution. |
@shushuai3 can you share your changes (i.e which line of code was modified) to make this work ? For our research experiment this is very important. Thanks in advance :). |
@tungnx94 You can find the code on branch ''sdspi'' in https://github.com/shushuai3/crazyflie-firmware.git |
@shushuai3 I pulled your code just now. Can I use it rightaway or I need to modify anything ? |
@tungnx94 this requires to quite heavily patch the sd-card deck, nothing impossible but you need a good soldering iron and good soldering skills |
I just want to comment that I tried the code from SdSPIUpdate branch on tungnx94's fork. It worked. |
to keep using this hack in recent firmwares you must remove all reference to RZR platforms from cf2_platform.c |
In commit bfedc1c the work from @shushuai3 was merged and updated and now put behind a compile flag. To have the sd-card on SPI3 the SD-deck needs to be patched: A side effect is that the led-ring will not work due to DMA conflict with SPI3. |
thank you! this helps alot. just making sure - will this fix work on the Bolt? Since SPI configuration there is slightly different. |
I have tested this on the Bolt with the Loco deck and it is working. |
Are the schematic and layout files for the microSD deck available? What microSD and connector part numbers are used on the board? Seems only the Crazyflie 1.0 hardware is available on Bitcraze's GitHub, not the decks. |
@ZaneKaminski Both microSD and Crazyflie 2.0 schematics are in the wiki (https://wiki.bitcraze.io/projects:crazyflie2:index). |
Great to read this issue has been solved! Already wanted to celebrate, but I just tested this with the latest clean master (on both the CF2.1 and the Bolt) and, unfortunately, the logging will stop after a (very short) while and the crazyflie restarts, blinking red 5 times and showing the following console message:
No assert is what I got most of the times, however, once I also saw this
and once this
in the console just before the restart. The setup is CF2.1, Loco Deck & SD card Deck, LPS is set to TDoA v3, and I use the following config.txt:
At 10 Hz I get a few seconds of data before it crashes, going to 1Hz allows for ~30 seconds but then also crashes. Anyone else experiencing this? |
Switching to a different uSD card type indeed solved the problem (CF2.1, uSD & LPS with TDoA v3), thanks for the tip Tobias!
Still some glitches once in a while, but no more crashes: |
Glad it worked with another sd-card! It would be nice to get rid of the glitches and it might be possible by increasing the log buffer a lot. The problem is that the sd-card blockes from time to time to write down to flash. |
Using both the µSD-card deck and the loco deck, logging will work only a short time (a few 100 log entries) before it stops. Interestingly, this behaviour seems not to depend on variables logged, sampling rate or buffer used for µSD-config file but solely on time after startup, e.g. with 1000 Hz you'll get ~150 log entries while with 10 Hz you'll get only 20 or so (not exactly reproducible to my experience).
I used the latest firmware and VM2017.03 to reproduce this behaviour. Unfortunately, I don't have a debugger at hand currently. Maybe someone can have a look at the debug prints?
The text was updated successfully, but these errors were encountered: