mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 14:21:25 +03:00
Fix serial upload bug
This commit is contained in:
parent
bb79d51377
commit
df42bfa90e
19
app/uart.c
19
app/uart.c
@ -299,7 +299,7 @@ static void cmd_051D(const uint8_t *pBuffer)
|
|||||||
{
|
{
|
||||||
const unsigned int write_size = 8;
|
const unsigned int write_size = 8;
|
||||||
const cmd_051D_t *pCmd = (const cmd_051D_t *)pBuffer;
|
const cmd_051D_t *pCmd = (const cmd_051D_t *)pBuffer;
|
||||||
unsigned int addr = pCmd->Offset;
|
const unsigned int addr = pCmd->Offset;
|
||||||
unsigned int size = pCmd->Size;
|
unsigned int size = pCmd->Size;
|
||||||
#ifdef INCLUDE_AES
|
#ifdef INCLUDE_AES
|
||||||
bool reload_eeprom = false;
|
bool reload_eeprom = false;
|
||||||
@ -315,8 +315,6 @@ static void cmd_051D(const uint8_t *pBuffer)
|
|||||||
if (addr >= EEPROM_SIZE)
|
if (addr >= EEPROM_SIZE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (size > sizeof(reply.Data))
|
|
||||||
size = sizeof(reply.Data);
|
|
||||||
if (size > (EEPROM_SIZE - addr))
|
if (size > (EEPROM_SIZE - addr))
|
||||||
size = EEPROM_SIZE - addr;
|
size = EEPROM_SIZE - addr;
|
||||||
|
|
||||||
@ -332,11 +330,13 @@ static void cmd_051D(const uint8_t *pBuffer)
|
|||||||
if (!locked)
|
if (!locked)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
const uint8_t *data = (uint8_t *)&pCmd + sizeof(cmd_051D_t); // point to the RX'ed data to write to eeprom
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < (size / write_size); i++)
|
for (i = 0; i < (size / write_size); i++)
|
||||||
{
|
{
|
||||||
const uint16_t Offset = addr + (i * write_size);
|
const unsigned int k = i * write_size;
|
||||||
|
const unsigned int Offset = addr + k;
|
||||||
|
uint8_t *data = (uint8_t *)pCmd + sizeof(cmd_051D_t) + k;
|
||||||
|
|
||||||
if ((Offset + write_size) > EEPROM_SIZE)
|
if ((Offset + write_size) > EEPROM_SIZE)
|
||||||
break;
|
break;
|
||||||
@ -345,13 +345,18 @@ static void cmd_051D(const uint8_t *pBuffer)
|
|||||||
if (Offset >= 0x0F30 && Offset < 0x0F40) // AES key
|
if (Offset >= 0x0F30 && Offset < 0x0F40) // AES key
|
||||||
if (!is_locked)
|
if (!is_locked)
|
||||||
reload_eeprom = true;
|
reload_eeprom = true;
|
||||||
|
#else
|
||||||
|
if (Offset == 0x0F30)
|
||||||
|
memset(data, 0xff, 8); // wipe the AES key
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_PWRON_PASSWORD
|
#ifdef ENABLE_PWRON_PASSWORD
|
||||||
if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !g_password_locked || pCmd->allow_password)
|
if ((Offset < 0x0E98 || Offset >= 0x0EA0) || !g_password_locked || pCmd->allow_password)
|
||||||
EEPROM_WriteBuffer(Offset, &data[i * write_size]);
|
EEPROM_WriteBuffer(Offset, data);
|
||||||
#else
|
#else
|
||||||
EEPROM_WriteBuffer(Offset, &data[i * write_size]);
|
if (Offset == 0x0E90)
|
||||||
|
memset(data + 8, 0xff, 4); // wipe the password
|
||||||
|
EEPROM_WriteBuffer(Offset, data);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user