Changed the chainloader to load payloads named "BUTTON_NAME.bin", to remember which payload is which. Original idea and code by @habbbe (many thanks!)

This commit is contained in:
Aurora
2016-04-17 18:57:25 +02:00
parent 0f64fd73ec
commit 06060c67b5
8 changed files with 53 additions and 42 deletions

View File

@@ -34,7 +34,7 @@
/ 2: Enable with LF-CRLF conversion. */
#define _USE_FIND 0
#define _USE_FIND 1
/* This option switches filtered directory read feature and related functions,
/ f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */

View File

@@ -64,16 +64,16 @@ u32 fileSize(const char *path)
return size;
}
u32 fileExists(const char *path)
u32 defPayloadExists(void)
{
FIL fp;
u32 exists = 0;
DIR dir;
FILINFO info = { .lfname = NULL };
if(f_open(&fp, path, FA_READ) == FR_OK) exists = 1;
FRESULT result = f_findfirst(&dir, &info, "/aurei/payloads", "def_*.bin");
f_close(&fp);
f_closedir(&dir);
return exists;
return (result == FR_OK && info.fname[0]);
}
void firmRead(void *dest, const char *firmFolder)

View File

@@ -12,5 +12,5 @@ u32 mountFs(void);
u32 fileRead(void *dest, const char *path, u32 size);
u32 fileWrite(const void *buffer, const char *path, u32 size);
u32 fileSize(const char *path);
u32 fileExists(const char *path);
u32 defPayloadExists(void);
void firmRead(void *dest, const char *firmFolder);

View File

@@ -14,7 +14,7 @@
void loadPayload(void)
{
if(fileExists("aurei/payloads/default.bin"))
if(defPayloadExists())
{
initScreens();
memcpy((void *)PAYLOAD_ADDRESS, loader, loader_size);