File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -1721,11 +1721,49 @@ void runBrushedLoop()
1721
1721
}
1722
1722
#endif
1723
1723
1724
+
1725
+ /*
1726
+ check device info from the bootloader, confirming pin code and eeprom location
1727
+ */
1728
+ static void checkDeviceInfo (void )
1729
+ {
1730
+ #define DEVINFO_MAGIC1 0x5925e3da
1731
+ #define DEVINFO_MAGIC2 0x4eb863d9
1732
+
1733
+ const struct devinfo {
1734
+ uint32_t magic1 ;
1735
+ uint32_t magic2 ;
1736
+ const uint8_t deviceInfo [9 ];
1737
+ } * devinfo = (struct devinfo * )(0x1000 - 32 );
1738
+ if (devinfo -> magic1 != DEVINFO_MAGIC1 ||
1739
+ devinfo -> magic2 != DEVINFO_MAGIC2 ) {
1740
+ // bootloader does not support this feature, nothing to do
1741
+ return ;
1742
+ }
1743
+ // change eeprom_address based on the code in the bootloaders device info
1744
+ switch (devinfo -> deviceInfo [4 ]) {
1745
+ case 0x1f :
1746
+ eeprom_address = 0x08007c00 ;
1747
+ break ;
1748
+ case 0x35 :
1749
+ eeprom_address = 0x0800f800 ;
1750
+ break ;
1751
+ case 0x2b :
1752
+ eeprom_address = 0x0801f800 ;
1753
+ break ;
1754
+ }
1755
+
1756
+ // TODO: check pin code and reboot to bootloader if incorrect
1757
+
1758
+ }
1759
+
1724
1760
int main (void )
1725
1761
{
1726
1762
1727
1763
initAfterJump ();
1728
1764
1765
+ checkDeviceInfo ();
1766
+
1729
1767
initCorePeripherals ();
1730
1768
1731
1769
enableCorePeripherals ();
You can’t perform that action at this time.
0 commit comments