-
Notifications
You must be signed in to change notification settings - Fork 3k
Enable FAT ChaN lib configuration with mbed_lib.json #11851
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
Conversation
|
@amq, thank you for your changes. |
|
Maybe it would make sense to move |
|
How often do these needs to be changed? This spawns a quite a lot of configurable parameters for such a rarely used component. We try to use LittleFS instead of FAT because it is more resilient for power losses. But.. well, if the component name is changed to |
|
@SeppoTakalo changed the component name to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally a library would provide a way to override and our config would just use these,
|
CI started |
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
|
Ah.. true.. All unittests that include these headers now fail: One option would be that you provide the previous version of the header in the |
|
@SeppoTakalo will simply adding the original header file without any changes work, won't there be "redefined" errors? (if this options works, ignore the next question) How would the CMake change work, could you give an example based on one define? |
|
@SeppoTakalo added the macros in the CMake file. |
|
CI restarted |
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
|
I restarted the unittests, I could find this one in the logs:
|
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
|
CI restarted |
Test run: FAILEDSummary: 1 of 11 test jobs failed Failed test jobs:
|
|
Internal error, pytest restarted |
|
Oh man.. This just build Bootloader build on all platform. Not sure if this also broke all Baremetal builds. |
|
Looks like the configuration is not there, a question is why? Neither our tests caught this one. |
|
Apparently Baremetal builds now need to include Which is logical.. but |
|
I am building a bootloader with CI, and I didn't have this issue when updating to 5.14.2 Could this be because in my case I'm not using KV, and the whole FAT ChaN is "self-confined" (only bootloader/mbed_app.json bootloader/bootloader.cpp #if !defined(BOOTLOADER_ADDR) && defined(POST_APPLICATION_ADDR)
#include "FlashIAPBlockDevice.h"
#include "LittleFileSystem.h"
#include "SDBlockDevice.h"
#include "FATFileSystem.h"
#include "mbed.h"
#define FS_MOUNT_PATH "fs"
#define FS_UPDATE_FILE_PATH "/" FS_MOUNT_PATH "/" MY_UPDATE_FILE_NAME
#define SD_MOUNT_PATH "sd"
#define SD_UPDATE_FILE_PATH "/" SD_MOUNT_PATH "/" MY_UPDATE_FILE_NAME
FlashIAPBlockDevice flashiap_bd(MY_FLASH_BD_START, MY_FLASH_BD_SIZE);
LittleFileSystem flashiap_fs(FS_MOUNT_PATH, &flashiap_bd);
SDBlockDevice sd_bd(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS);
FATFileSystem sd_fs(SD_MOUNT_PATH, &sd_bd);
FlashIAP mcuflash;
DigitalOut led(LED_RED);
bool update(const char *path);
void apply_update(FILE *file, uint32_t address);
int main() {
bool res = update(FS_UPDATE_FILE_PATH);
if (!res) {
update(SD_UPDATE_FILE_PATH);
}
mbed_start_application(POST_APPLICATION_ADDR);
}
bool update(const char *path) {
bool res = false;
FILE *file = fopen(path, "rb");
if (file != NULL) {
mcuflash.init();
apply_update(file, POST_APPLICATION_ADDR);
fclose(file);
remove(path);
mcuflash.deinit();
res = true;
}
return res;
}
void apply_update(FILE *file, uint32_t address) {
const uint32_t page_size = mcuflash.get_page_size();
char *page_buffer = new char[page_size];
uint32_t addr = address;
uint32_t next_sector = addr + mcuflash.get_sector_size(addr);
bool sector_erased = false;
size_t pages_flashed = 0;
while (true) {
// Read data for this page
memset(page_buffer, 0, sizeof(char) * page_size);
int size_read = fread(page_buffer, 1, page_size, file);
if (size_read <= 0) {
break;
}
// Erase this page if it hasn't been erased
if (!sector_erased) {
mcuflash.erase(addr, mcuflash.get_sector_size(addr));
sector_erased = true;
}
// Program page
mcuflash.program(page_buffer, addr, page_size);
addr += page_size;
if (addr >= next_sector) {
next_sector = addr + mcuflash.get_sector_size(addr);
sector_erased = false;
}
if (++pages_flashed % 24 == 0) {
led = !led;
}
}
led = 0;
delete[] page_buffer;
}
#endifWhen I tried building with |
Description (required)
Adds ability to configure the many FAT ChaN options using
mbed_lib.json.Summary of change (What the change is for and why)
All defines in
ffconf.hapart of Revision ID are made dynamically configurable using the standard Mbed OS mechanism.All values remain the same, so this change should be fully transparent for everyone.
Pull request type (required)
Test results (required)