From 4e9848ab3abfbfd53b33179eb6bc34ca010f57c0 Mon Sep 17 00:00:00 2001 From: Michael Oborne Date: Thu, 3 Sep 2020 18:08:24 +0800 Subject: [PATCH] HAL_ChibiOS: fix sdcard param init the write was failing because of a 0 byte write attempt, the response was -1 vs 0 this results in not using the sdcard backend for storage for all boots after the initial --- libraries/AP_HAL_ChibiOS/Storage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/AP_HAL_ChibiOS/Storage.cpp b/libraries/AP_HAL_ChibiOS/Storage.cpp index bc1b10e30b7..e91f7ce66fd 100644 --- a/libraries/AP_HAL_ChibiOS/Storage.cpp +++ b/libraries/AP_HAL_ChibiOS/Storage.cpp @@ -103,7 +103,7 @@ void Storage::_storage_open(void) } // pre-fill to full size if (AP::FS().lseek(log_fd, ret, SEEK_SET) != ret || - AP::FS().write(log_fd, &_buffer[ret], CH_STORAGE_SIZE-ret) != CH_STORAGE_SIZE-ret) { + (CH_STORAGE_SIZE-ret > 0 && AP::FS().write(log_fd, &_buffer[ret], CH_STORAGE_SIZE-ret) != CH_STORAGE_SIZE-ret)) { ::printf("setup failed for " HAL_STORAGE_FILE "\n"); AP::FS().close(log_fd); log_fd = -1;