Fix RO evil bug on new install

This commit is contained in:
Armel FAUVEAU committed 2026-02-03 01:57:38 +01:00
1 parent e555b48811
commit 2b40d1216e
3 files changed
+43 -2

No files matched your search

+1 -1
View File
@@ -88,7 +88,7 @@ DECLARE_AIRCOPY_BANK(1)
// For settings only
static const AIRCOPY_Segment_t AIRCOPY_Segments_Settings[] = {
{ 0xA000, 0xA160, AIRCOPY_WRITE_BYTES },
{ 0xA000, 0xA170, AIRCOPY_WRITE_BYTES },
};
static const AIRCOPY_TransferMap_t AIRCOPY_Map_Settings = {
+2 -1
View File
@@ -52,7 +52,7 @@ static const AddrMapping_t ADDR_MAPPINGS[] = {
_MK_MAPPING(0x009000, 0x009000, 0x0090D6), // 14 VFO * 16 Bytes (ex 0x001000)
_MK_MAPPING(0x00A000, 0x00A000, 0x00A160), // Settings * 16 Bytes (ex 0x004000) 0x00A000 -> 0x00A010
_MK_MAPPING(0x00A000, 0x00A000, 0x00A170), // Settings * 16 Bytes (ex 0x004000) 0x00A000 -> 0x00A010
// Settings * 16 Bytes (ex 0x005000) 0x00A010 -> 0x00A020
// Settings FM * 8 Bytes (0x006000) 0x00A020 -> 0x00A028
// MR FM * 128 Bytes (0x003000) 0x00A028 -> 0x00A0A8
@@ -62,6 +62,7 @@ static const AddrMapping_t ADDR_MAPPINGS[] = {
// Settings AES * 16 Bytes (0x00A000) 0x00A140 -> 0x00A150
// Settings * 8 Bytes (0x00B000) 0x00A150 -> 0x00A158
// Settings F4HWN * 8 Bytes (0x00C000) 0x00A158 -> 0x00A160
// Settings Version * 16 Bytes 0x00A160 -> 0x00A170
_MK_MAPPING(0x010000, 0x00B000, 0x00B200), // Calibration 512 Bytes!!!
};
+40
View File
@@ -33,6 +33,46 @@ EEPROM_Config_t gEeprom = { 0 };
void SETTINGS_InitEEPROM(void)
{
uint8_t Data[16] = {0};
//
// Version check
// Read stored version from EEPROM and compare with VERSION_STRING_2
//
{
char storedVersion[16] = {0};
PY25Q16_ReadBuffer(0x00A160, storedVersion, sizeof(storedVersion));
// Compare with current version
if (strncmp(storedVersion, VERSION_STRING_2, sizeof(storedVersion)) != 0)
{
// Different version: new install or firmware update
// 1. Write new version to EEPROM
char newVersion[16] = {0};
strncpy(newVersion, VERSION_STRING_2, sizeof(newVersion));
PY25Q16_WriteBuffer(0x00A160, newVersion, sizeof(newVersion), false);
// 2. Reset sensitive parameters (MENU_LOCK, etc.)
uint8_t configByte[8] = {0};
PY25Q16_ReadBuffer(0x00A000, configByte, sizeof(configByte));
configByte[4] &= (uint8_t)~0x01; // KEY_LOCK = 0
configByte[4] &= (uint8_t)~0x02; // MENU_LOCK = 0
configByte[4] &= (uint8_t)~0x3C; // SET_KEY = 0
configByte[4] &= (uint8_t)~0x40; // SET_NAV = 0
PY25Q16_WriteBuffer(0x00A000, configByte, sizeof(configByte), false);
// 3. Reset display inversion (SET_INV = 0)
uint8_t displayByte[8] = {0};
PY25Q16_ReadBuffer(0x00A158, displayByte, sizeof(displayByte));
displayByte[5] &= (uint8_t)~0x10; // Clear bit 4 (SET_INV)
PY25Q16_WriteBuffer(0x00A158, displayByte, sizeof(displayByte), false);
}
}
// 0E70..0E77
PY25Q16_ReadBuffer(0x00A000, Data, 8);
#ifdef ENABLE_FEAT_F4HWN_AUDIO