Skip to content

Commit

Permalink
Add some logging
Browse files Browse the repository at this point in the history
  • Loading branch information
SciLor committed Feb 17, 2021
1 parent bc911d1 commit 9154d26
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
8 changes: 5 additions & 3 deletions sd-bootloader-ng/bootmanager/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static void jsmn_str(const char *value, size_t len, void *user_arg) {
return;
if (jsmn_hasIgnoreName())
return;

if (strcmp("general", jsonGroupName) == 0) {
if (strcmp("activeImg", jsonValueName) == 0) {
Config_generalSettings.activeImage = getImageNumber(value);
Expand Down Expand Up @@ -193,8 +193,10 @@ void Config_ReadJsonCfg(void) {
char buffer[512];
while (allBytesRead<filesize) {
ffs_result = f_read(&ffile, buffer, COUNT_OF(buffer), &bytesRead);
if (ffs_result != FR_OK)
if (ffs_result != FR_OK) {
Logger_error("Error while reading config %s...", CFG_SD_PATH);
break;
}

for (uint16_t i = 0; i < bytesRead; i++)
{
Expand All @@ -209,6 +211,6 @@ void Config_ReadJsonCfg(void) {
Logger_setLevel(99); //Set it very high

} else {
Logger_error("sd:%s not found.", CFG_SD_PATH);
Logger_error("sd:%s could not be opened error=%i", CFG_SD_PATH, ffs_result);
}
}
15 changes: 9 additions & 6 deletions sd-bootloader-ng/bootmanager/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,27 +648,30 @@ int main()
Logger_info("Start firmware sd:%s ...", image);
Run((unsigned long)pImgRun);
} else {
Logger_error("Reading file failed error=%i", ffs_result);
UtilsDelayMsWD(1000);
prebootmgr_blink_error(4, 500);
UtilsDelayMsWD(2000);
prebootmgr_blink_error(ffs_result, 1000);
}
} else {
Logger_error("Opening file failed error=%i", ffs_result);
UtilsDelayMsWD(1000);
prebootmgr_blink_error(3, 500);
UtilsDelayMsWD(2000);
prebootmgr_blink_error(ffs_result, 1000);
}
}
UtilsDelayMsWD(2000);
Logger_error("No image found");
} else {
Logger_error("Mounting sd failed error=%i", ffs_result);
UtilsDelayMsWD(500);
prebootmgr_blink_error(2, 500);
UtilsDelayMsWD(500);
prebootmgr_blink_error(ffs_result, 1000);
}

Logger_error("Mounting sd failed!");
UtilsDelayMsWD(500);
prebootmgr_blink_error(2, 500);
UtilsDelayMsWD(500);
prebootmgr_blink_error(ffs_result, 1000);

SlFsFileInfo_t pFsFileInfo;
_i32 fhandle;
sl_Start(NULL, NULL, NULL); //for reading flash
Expand Down
6 changes: 4 additions & 2 deletions sd-bootloader-ng/bootmanager/patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,10 @@ void Patch_Apply(char* imageBytes, char* patchName, uint32_t imageLength) {
while (allBytesRead<filesize)
{
ffs_result = f_read(&ffile, buffer, COUNT_OF(buffer), &bytesRead);
if (ffs_result != FR_OK)
if (ffs_result != FR_OK) {
Logger_error("Error while reading patch %s file...", patchName);
break;
}

for (uint16_t i = 0; i < bytesRead; i++)
{
Expand All @@ -439,6 +441,6 @@ void Patch_Apply(char* imageBytes, char* patchName, uint32_t imageLength) {
}
f_close(&ffile);
} else {
Logger_error("Open sd:%s failed", filepath);
Logger_error("Open sd:%s failed error=%i", filepath, ffs_result);
}
}

0 comments on commit 9154d26

Please sign in to comment.