ArduPilot / ArduPilot/ardupilot

AP_Filesystem_ESP32.cpp - Disk Space return value failure

Open Beginner friendly
#33,522 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
15.9k
Forks
21.4k
Avg merge
3d 17h
Merged PRs (30d)
119

Description

## Bug Report
https://discuss.ardupilot.org/t/learning-ardupilot-starting-with-esp32/115834/28
https://discuss.ardupilot.org/t/learning-ardupilot-starting-with-esp32/115834/30

This error causes log files on the SD card to be deleted even though there is more than enough space available. However, this deletion process can lead to delays and potentially even system resets—though the latter remains to be verified.

### Issue details
The two functions
int64_t AP_Filesystem_ESP32::disk_free(const char *path){ }
int64_t AP_Filesystem_ESP32::disk_space(const char *path){ }
should return a 64-bit value.
Although an int64_t variable is defined for this purpose, the values ​​are truncated to 32 bits during the calculation.

Possible changes
int64_t AP_Filesystem_ESP32::disk_free(const char *path){
...
//remove
int64_t tmp_free_bytes = fre_sect * FF_SS_SDCARD;
return tmp_free_bytes;
// add
return (int64_t)fre_sect * FF_SS_SDCARD;
}

int64_t AP_Filesystem_ESP32::disk_space(const char *path){
...
//remove
int64_t tmp_total_bytes = tot_sect * FF_SS_SDCARD;
return tmp_total_bytes;
// add
return (int64_t)tot_sect * FF_SS_SDCARD;
}

**Version**
4.8.0 master

**Platform**
[ ] All
[ ] AntennaTracker
[ ] Copter
[ ] Plane
[x] Rover
[ ] Submarine

**Airframe type**
Rover

**Hardware type**
ESP32 DevKit WROOM-32

**Logs**

Contributor guide

Open the contributing guide

Research direction

Start in AP_Filesystem_ESP32.cpp at disk_free(const char *path) and disk_space(const char *path), then inspect the types of fre_sect, tot_sect, and FF_SS_SDCARD during multiplication. Confirm that both functions preserve the full 64-bit disk values and verify the behavior on the ESP32 filesystem or with the relevant filesystem checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.