Bootloader: add bootloader version read out

This commit is contained in:
Thomas Klaehn 2021-11-18 10:32:07 +01:00
parent b55a05e7a0
commit 637ff7ea68
2 changed files with 11 additions and 4 deletions

View File

@ -56,8 +56,10 @@ void Bootloader::get_version()
int rec = uart.receive(buffer, sizeof(buffer)); int rec = uart.receive(buffer, sizeof(buffer));
if ((rec == 5) && ((buffer[0] == ACK) && (buffer[4] == ACK))) if ((rec == 5) && ((buffer[0] == ACK) && (buffer[4] == ACK)))
{ {
chip.bootloader_version_major = (buffer[1] & 0xf0) >> 4; // chip.bootloader_version_major = (buffer[1] & 0xf0) >> 4;
chip.bootloader_version_minor = buffer[1] & 0x0f; // chip.bootloader_version_minor = buffer[1] & 0x0f;
chip.option_byte_1 = buffer[2];
chip.option_byte_2 = buffer[3];
} }
} }
@ -79,9 +81,10 @@ void Bootloader::get_chip_id()
void Bootloader::get_bl_version() void Bootloader::get_bl_version()
{ {
unsigned char buffer[2]; unsigned char buffer[1];
read_memory(BL_VERSION_REGISTER_ADDRESS, buffer, sizeof(buffer)); read_memory(BL_VERSION_REGISTER_ADDRESS, buffer, sizeof(buffer));
chip.flash_size = ((buffer[1] << 8) + buffer[0]) * 1024; chip.bootloader_version_major = (buffer[0] & 0xf0) >> 4;
chip.bootloader_version_minor = buffer[0] & 0x0f;
} }
void Bootloader::get_flash_memory_size() void Bootloader::get_flash_memory_size()

View File

@ -29,6 +29,8 @@ public:
uint8_t bootloader_version_minor; uint8_t bootloader_version_minor;
uint8_t protocol_version_major; uint8_t protocol_version_major;
uint8_t protocol_version_minor; uint8_t protocol_version_minor;
uint8_t option_byte_1;
uint8_t option_byte_2;
uint32_t flash_size; uint32_t flash_size;
}; };
@ -85,6 +87,8 @@ private:
.bootloader_version_minor = 0, .bootloader_version_minor = 0,
.protocol_version_major = 0, .protocol_version_major = 0,
.protocol_version_minor = 0, .protocol_version_minor = 0,
.option_byte_1 = 0,
.option_byte_2 = 0,
.flash_size = 0, .flash_size = 0,
}; };