Skip to content

Commit

Permalink
check devinfo from bootloader
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Oct 5, 2024
1 parent db1abdf commit 08125a0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1721,11 +1721,49 @@ void runBrushedLoop()
}
#endif


/*
check device info from the bootloader, confirming pin code and eeprom location
*/
static void checkDeviceInfo(void)
{
#define DEVINFO_MAGIC1 0x5925e3da
#define DEVINFO_MAGIC2 0x4eb863d9

const struct devinfo {
uint32_t magic1;
uint32_t magic2;
const uint8_t deviceInfo[9];
} *devinfo = (struct devinfo *)(0x1000 - 32);
if (devinfo->magic1 != DEVINFO_MAGIC1 ||
devinfo->magic2 != DEVINFO_MAGIC2) {
// bootloader does not support this feature, nothing to do
return;
}
// change eeprom_address based on the code in the bootloaders device info
switch (devinfo->deviceInfo[4]) {
case 0x1f:
eeprom_address = 0x08007c00;
break;
case 0x35:
eeprom_address = 0x0800f800;
break;
case 0x2b:
eeprom_address = 0x0801f800;
break;
}

// TODO: check pin code and reboot to bootloader if incorrect

}

int main(void)
{

initAfterJump();

checkDeviceInfo();

initCorePeripherals();

enableCorePeripherals();
Expand Down

0 comments on commit 08125a0

Please sign in to comment.