Skip to content

Commit 897d947

Browse files
committed
Add OfwFix Value to config
1 parent 5fbd5d3 commit 897d947

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

sd-bootloader-ng/bootmanager/config.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ sGeneralSettings Config_generalSettings = {
77
false, //waitForPress
88
60, //waitTimeoutInS
99
2100, //minBatteryLevel (Divide through around 700 to get voltage, so 3V should be save)
10+
0x0010014C, //ofwFixValue - Magic bytes from OFW BL
1011
#ifdef NO_DEBUG_LOG
1112
false, //serialLog
1213
#else
@@ -81,7 +82,13 @@ static void jsmn_obj_key(const char *key, size_t key_len, void *user_arg) {
8182
case 5:
8283
if (jsmn_hasIgnoreName())
8384
break;
84-
if (strncmp(jsonGroupName, "ofw", 3) == 0
85+
if (strcmp("general", jsonGroupName) == 0 && key_len == 2) {
86+
if (jsonArrayId == 0)
87+
Config_generalSettings.ofwFixValue = 0x00000000;
88+
if (jsonArrayId < 4)
89+
Config_generalSettings.ofwFixValue += xtob(key) << 8*jsonArrayId;
90+
jsonArrayId++;
91+
} else if (strncmp(jsonGroupName, "ofw", 3) == 0
8592
|| strncmp(jsonGroupName, "cfw", 3)
8693
|| strncmp(jsonGroupName, "add", 3))
8794
{

sd-bootloader-ng/bootmanager/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ typedef struct sGeneralSettings
2323
bool waitForPress;
2424
uint16_t waitTimeoutInS;
2525
uint16_t minBatteryLevel;
26+
uint32_t ofwFixValue;
2627
bool serialLog;
2728
uint8_t logLevel;
2829
bool logColor;

sd-bootloader-ng/bootmanager/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,9 @@ static bool prepareRun(sImageInfo* imageInfo, char* imagePath, uint32_t filesize
670670
|| strnlen(creationDate, 29) == 28) //old format
671671
Logger_info(" creationDate=%s", creationDate);
672672

673-
Logger_debug("Apply OFW fix");
673+
Logger_debug("Apply OFW fix 0x%08X", Config_generalSettings.ofwFixValue);
674674
if (*pCheck1 == 0xBEAC0005 && *pCheck1 == *pCheck2) {
675-
*pTarget = 0x0010014C;
675+
*pTarget = Config_generalSettings.ofwFixValue;
676676
} else {
677677
Logger_error("OFW fix failed");
678678
Logger_error(" *pCheck1=0x%X *pCheck2=0x%X *pTarget=0x%X", *pCheck1, *pCheck2, *pTarget);

sd-bootloader-ng/bootmanager/sd/revvox/boot/ngCfg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"waitTimeoutInS": 60,
66
"_descMinBatteryLevel": "Divide through around 700 to get voltage",
77
"minBatteryLevel": 2100,
8-
8+
"ofwFixValue": ["4C", "01", "10", "00"],
99
"_descSerialLog": "Logging only works with the debug build!",
1010
"serialLog": false,
1111
"_descLogLevel": "0:Trace - 5:Fatal",

wiki/Bootloader.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ The configuration for the bootloader is saved within [sd:/revvox/boot/ngCfg.json
4242
| waitForPress | Waits for an earpress on startup with a blink sequence (blue, green, cyan, black)| true, false | false |
4343
| waitTimeoutInS | Timeout in seconds for waitForPress if no earpress (hibernation) | 1-255 | 60 |
4444
| minBatteryLevel | Poweroff voltage to protect the battery. Divide through around 700 to get voltage (Standard 3V) | | 2100 |
45+
| ofwFixValue | Magic bytes to be placed into the OFW Image during boot (can be extracted from OFW BL data[-8:-4]) | hex array with 4 bytes | ["4C", "01", "10", "00"] |
4546
| serialLog | Enable log to UART (TX) @115200 baud. Only works for debug build! | true, false | true |
4647
| logLevel | Set Log level 0:Trace - 5:Fatal | 0-5 | DEBUG_LOG_LEVEL |
4748
| logColor | Enable colored log | true, false | false |

0 commit comments

Comments
 (0)