I'm currently getting my feet wet with logging using the SD deck. Unfortunately, I experience issues that apparently have been solved before. This post tries to outline these issues. Maybe we find out that they are not solved, or that the behavior points to other errors (or a faulty setup on my side). Sorry for creating yet another post on SD deck problems, but I didn't find a specific post where it'd be best to chime in.
I have a Crazyflie 2.1 flashed with the newest firmware (2022.01). The SD card is some multiple year old 16 GB Samsung EVO formatted with FAT32 (I currently have no information about its writing speed).
I report tests in these four conditions:
Code: Select all
| all decks mounted | only SD deck mounted
-------------------------------------------------------------------
fixed frequency logs | test #1 | test #4
event-based logs | test #2 | test #3
For experiments with fixed frequency, this is the log config file:
Code: Select all
1 # version
2048 # buffer size in bytes
sd_log # file name
0 # enable on startup (0/1)
on:fixedFrequency
100 # frequency
1 # mode (0: disabled, 1: synchronous stabilizer, 2: asynchronous)
# IMU
acc.x
acc.y
acc.z
gyro.x
gyro.y
gyro.z
Code: Select all
1 # version
2048 # buffer size in bytes
sd_log # file name
0 # enable on startup (0/1)
on:estGyroscope
gyro.x
gyro.y
gyro.z
on:estAcceleration
acc.x
acc.y
acc.z
* adapt log config file on sd card to fit the desired conditions
* mount or unmount decks to fit the desired conditions
* insert sd card into Crazyflie
* start Crazyflie
* connect to Crazyflie via cfclient
* set parameter usd.logging to 1 to start logging
* wait a bit to collect data
* set parameter usd.logging to 0 to stop logging
* turn off Crazyflie
* store console output for reporting in the forum
* copy resulting log from sd card for reporting in the forum
Here are the console outputs for the four experiments:
Test 1: all decks, fixed frequency
Code: Select all
SYS: Crazyflie 2.1 is up and running!
SYS: Build 0:31573f2fd1d5 (2022.01) CLEAN
SYS: I am 0x20303743575350170023001F and I have 1024KB of flash!
CFGBLK: v1, verification [OK]
DECK_CORE: 4 deck(s) found
DECK_CORE: Calling INIT on driver bcUSD for deck 0
uSD: mount SD-Card [OK].
DECK_CORE: Calling INIT on driver bcMultiranger for deck 1
uSD: wait for sensors
DECK_CORE: Calling INIT on driver bcFlow2 for deck 2
ZR2: Z-down sensor [OK]
PMW: Motion chip id: 0x49:0xB6
DECK_CORE: Calling INIT on driver bcDWM1000 for deck 3
IMU: BMI088: Using I2C interface.
IMU: BMI088 Gyro connection [OK].
IMU: BMI088 Accel connection [OK]
IMU: BMP388 I2C connection [OK]
ESTIMATOR: Using Kalman (2) estimator
CONTROLLER: Using PID (1) controller
MTR-DRV: Using brushed motor driver
SYS: About to run tests in system.c.
EEPROM: I2C connection [OK].
STORAGE: Storage check [OK].
IMU: BMI088 gyro self-test [OK]
DECK_CORE: Deck 0 test [OK].
MR: Init front sensor [OK]
MR: Init back sensor [OK]
MR: Init up sensor [OK]
MR: Init left sensor [OK]
MR: Init right sensor [OK]
DECK_CORE: Deck 1 test [OK].
DECK_CORE: Deck 2 test [OK].
DECK_CORE: Deck 3 test [OK].
SYS: Self test passed!
STAB: Wait for sensor calibration...
SYS: Free heap: 11840 bytes
STAB: Ready to fly.
uSD: Config read [OK].
uSD: malloc buffer 2048 bytes uSD: [OK].
uSD: Logging to: sd_log15
uSD: Wrote 28588 B to: sd_log15 (2856 of 2856 events)
Test 2: all decks, event-based
Code: Select all
SYS: ----------------------------
SYS: Crazyflie 2.1 is up and running!
SYS: Build 0:31573f2fd1d5 (2022.01) CLEAN
SYS: I am 0x20303743575350170023001F and I have 1024KB of flash!
CFGBLK: v1, verification [OK]
DECK_CORE: 4 deck(s) found
DECK_CORE: Calling INIT on driver bcUSD for deck 0
uSD: mount SD-Card [OK].
DECK_CORE: Calling INIT on driver bcMultiranger for deck 1
uSD: wait for sensors
DECK_CORE: Calling INIT on driver bcFlow2 for deck 2
ZR2: Z-down sensor [OK]
PMW: Motion chip id: 0x49:0xB6
DECK_CORE: Calling INIT on driver bcDWM1000 for deck 3
IMU: BMI088: Using I2C interface.
IMU: BMI088 Gyro connection [OK].
IMU: BMI088 Accel connection [OK]
IMU: BMP388 I2C connection [OK]
ESTIMATOR: Using Kalman (2) estimator
CONTROLLER: Using PID (1) controller
MTR-DRV: Using brushed motor driver
SYS: About to run tests in system.c.
EEPROM: I2C connection [OK].
STORAGE: Storage check [OK].
IMU: BMI088 gyro self-test [OK]
DECK_CORE: Deck 0 test [OK].
MR: Init front sensor [OK]
MR: Init back sensor [OK]
MR: Init up sensor [OK]
MR: Init left sensor [OK]
MR: Init right sensor [OK]
DECK_CORE: Deck 1 test [OK].
DECK_CORE: Deck 2 test [OK].
DECK_CORE: Deck 3 test [OK].
SYS: Self test passed!
STAB: Wait for sensor calibration...
SYS: Free heap: 11840 bytes
STAB: Ready to fly.
uSD: Config read [OK].
uSD: malloc buffer 2048 bytes uSD: [OK].
uSD: Logging to: sd_log16
SYS: ----------------------------
SYS: Crazyflie 2.1 is up and running!
SYS: Build 0:31573f2fd1d5 (2022.01) CLEAN
ash!
CFGBLK: v1, verification [OK]
OW: Cmd 0x22 timeout.
DECK_INFO: Reading deck nr:0 [FAILED]. No driver will be initialized!
OW: Cmd 0x22 timeout.
DECK_INFO: Reading deck nr:1 [FAILED]. No driver will be initialized!
DECK_CORE: 0 deck(s) found
IMU: BMI088: Using I2C interface.
IMU: BMI088 Gyro connection [OK].
IMU: BMI088 Accel connection [OK]
IMU: BMP388 I2C connection [OK]
ESTIMATOR: Using Complementary (1) estimator
CONTROLLER: Using PID (1) controller
MTR-DRV: Using brushed motor driver
SYS: About to run tests in system.c.
EEPROM: I2C connection [OK].
STORAGE: Storage check [OK].
IMU: BMI088 gyro self-test [OK]
SYS: The system resumed after a failed assert [WARNING]
SYS: Assert failed at .//src/deck/drivers/src/usddeck.c:795
SYS: cfAssertNormalStart [FAIL]
Test 3: only SD deck, event-based
Code: Select all
SYS: ----------------------------
SYS: Crazyflie 2.1 is up and running!
SYS: Build 0:31573f2fd1d5 (2022.01) CLEAN
SYS: I am 0x20303743575350170023001F and I have 1024KB of flash!
CFGBLK: v1, verification [OK]
DECK_CORE: 1 deck(s) found
DECK_CORE: Calling INIT on driver bcUSD for deck 0
uSD: mount SD-Card [OK].
IMU: BMI088: Using I2C interface.
uSD: wait for sensors
IMU: BMI088 Gyro connection [OK].
IMU: BMI088 Accel connection [OK]
IMU: BMP388 I2C connection [OK]
ESTIMATOR: Using Complementary (1) estimator
CONTROLLER: Using PID (1) controller
MTR-DRV: Using brushed motor driver
SYS: About to run tests in system.c.
EEPROM: I2C connection [OK].
STORAGE: Storage check [OK].
IMU: BMI088 gyro self-test [OK]
DECK_CORE: Deck 0 test [OK].
SYS: Self test passed!
STAB: Wait for sensor calibration...
SYS: Free heap: 18712 bytes
STAB: Ready to fly.
uSD: Config read [OK].
uSD: malloc buffer 2048 bytes uSD: [OK].
uSD: Logging to: sd_log17
uSD: Wrote 770367 B to: sd_log17 (35012 of 38622 events)
Test 4: only SD deck, fixed frequency
Code: Select all
SYS: ----------------------------
SYS: Crazyflie 2.1 is up and running!
SYS: Build 0:31573f2fd1d5 (2022.01) CLEAN
SYS: I am 0x20303743575350170023001F and I have 1024KB of flash!
CFGBLK: v1, verification [OK]
DECK_CORE: 1 deck(s) found
DECK_CORE: Calling INIT on driver bcUSD for deck 0
uSD: mount SD-Card [OK].
IMU: BMI088: Using I2C interface.
uSD: wait for sensors
IMU: BMI088 Gyro connection [OK].
IMU: BMI088 Accel connection [OK]
IMU: BMP388 I2C connection [OK]
ESTIMATOR: Using Complementary (1) estimator
CONTROLLER: Using PID (1) controller
MTR-DRV: Using brushed motor driver
SYS: About to run tests in system.c.
EEPROM: I2C connection [OK].
STORAGE: Storage check [OK].
IMU: BMI088 gyro self-test [OK]
DECK_CORE: Deck 0 test [OK].
SYS: Self test passed!
STAB: Wait for sensor calibration...
SYS: Free heap: 18712 bytes
STAB: Ready to fly.
uSD: Config read [OK].
uSD: malloc buffer 2048 bytes uSD: [OK].
uSD: Logging to: sd_log18
uSD: Wrote 22008 B to: sd_log18 (2198 of 2198 events)
test 1: sd_log15
test 2: The file on my PC has 0 Byte, but upon uploading the forum says "Error: file too large". Sorry for that.
test 3: sd_log17
test 4: sd_log18
Note: I had to add .txt in order to upload it to the forum, but these are actually binaries without file extension):
Summary of the results
Code: Select all
| all decks mounted | only SD deck mounted
------------------------------------------------------------------------------------------------------
fixed frequency logs | only some timestamps logged | only some timestamps logged
event-based logs | assert error | works
When using event-based logs with only the SD deck (test 3) it works well. This is good to know as a baseline (aka the SD card works, the Crazyflie works etc.). However, I am mostly interested in logging UWB and flow values, so it's not enough in my case.
With fixed frequency (tests 1 and 4) I only receive timestamps in the logs irrespective of the amount of decks. I've reported this initially in this issue, but thought I'll collect it into this analysis too. The logs are considerably smaller than the functioning log from test 3. Thus I think it's not simply a problem with reading the log incorrectly, but rather actually a writing problem.
When using event-based logs and all decks mounted (test 2), I receive an assert error. Such errors have been reported previously both in this issue and in this issue. In both cases, the errors were solved with a pull request. Unfortunately, that is not true for me here.
Just as a side note: Before updating to the newest firmware I had a Build 68:308ceb323945 (2021.06 +68) flashed on the Crazyflie. In this configuration and for test 2 (event-based logs, all decks mounted), a log file was created (console output said "uSD: Logging to: log09") but in that very moment the red LED stopped. Also, it was not possible to deactivate logging via the cfclient. The parameter value would always stay at 1 and became highlighted in red. When checking the file on the SD card, it was empty. This might not be relevant here, as it could be a bug that was solved by moving to 2022.01. However, it could be relevant because at least the assert error was not present at this stage (or the code just failed before reaching the assert call).
I hope my exhaustive report allows us to figure out what the problem(s) is (are). Hopefully, it's just a stupid mistake somewhere on my side