Compare commits

..

No commits in common. "master" and "147ee2469ec1bbe9eb73f441d7c62321fc891970" have entirely different histories.

4 changed files with 1 additions and 43 deletions

7
.vscode/launch.json vendored
View File

@ -6,12 +6,7 @@
"type": "cppdbg", "type": "cppdbg",
"request": "launch", "request": "launch",
"program": "${workspaceFolder}/bin/bootloader", "program": "${workspaceFolder}/bin/bootloader",
"args": [ "args": [],
"-p",
"/dev/ttyACM1",
"-f",
"nucleo.bin"
],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"environment": [], "environment": [],

View File

@ -7,10 +7,8 @@ Bootloader::Bootloader(Uart &uart) : uart(uart)
{ {
syn(); syn();
get(); get();
get_version();
get_chip_id(); get_chip_id();
get_flash_memory_size(); get_flash_memory_size();
get_bl_version();
} }
void Bootloader::syn() void Bootloader::syn()
@ -48,21 +46,6 @@ void Bootloader::get()
} }
} }
void Bootloader::get_version()
{
unsigned char buffer[0xff];
send_command(commands.get_version_and_read_protection_status);
usleep(10000);
int rec = uart.receive(buffer, sizeof(buffer));
if ((rec == 5) && ((buffer[0] == ACK) && (buffer[4] == ACK)))
{
// chip.bootloader_version_major = (buffer[1] & 0xf0) >> 4;
// chip.bootloader_version_minor = buffer[1] & 0x0f;
chip.option_byte_1 = buffer[2];
chip.option_byte_2 = buffer[3];
}
}
void Bootloader::get_chip_id() void Bootloader::get_chip_id()
{ {
unsigned char buffer[0xff]; unsigned char buffer[0xff];
@ -79,14 +62,6 @@ void Bootloader::get_chip_id()
} }
} }
void Bootloader::get_bl_version()
{
unsigned char buffer[1];
read_memory(BL_VERSION_REGISTER_ADDRESS, buffer, sizeof(buffer));
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()
{ {
unsigned char buffer[2]; unsigned char buffer[2];

View File

@ -25,12 +25,8 @@ public:
struct ChipData struct ChipData
{ {
uint16_t id; uint16_t id;
uint8_t bootloader_version_major;
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;
}; };
@ -52,17 +48,14 @@ public:
private: private:
void syn(); void syn();
void get(); void get();
void get_version();
void get_chip_id(); void get_chip_id();
void get_flash_memory_size(); void get_flash_memory_size();
void get_bl_version();
void send_command(uint8_t command); void send_command(uint8_t command);
void send_address(uint32_t address); void send_address(uint32_t address);
bool wait_for_ack(); bool wait_for_ack();
const uint32_t FLASH_MEMORY_SIZE_DATA_REGISTER_ADDRESS = 0x1fff75e0; const uint32_t FLASH_MEMORY_SIZE_DATA_REGISTER_ADDRESS = 0x1fff75e0;
const uint32_t BL_VERSION_REGISTER_ADDRESS = 0x1fff1ffe;
const uint16_t SUPPORTED_DEVICE_ID = 0x466; const uint16_t SUPPORTED_DEVICE_ID = 0x466;
const uint8_t ACK = 0x79; const uint8_t ACK = 0x79;
const uint8_t NAK = 0x1f; const uint8_t NAK = 0x1f;
@ -83,12 +76,8 @@ private:
ChipData chip = { ChipData chip = {
.id = 0, .id = 0,
.bootloader_version_major = 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,
}; };

View File

@ -11,7 +11,6 @@
int main() int main()
{ {
Uart uart("/dev/ttyACM1"); Uart uart("/dev/ttyACM1");
// Uart uart("/dev/ttyUSB0");
Bootloader bootloader(uart); Bootloader bootloader(uart);
if (bootloader.chip_is_supported()) if (bootloader.chip_is_supported())