Compare commits
No commits in common. "master" and "147ee2469ec1bbe9eb73f441d7c62321fc891970" have entirely different histories.
master
...
147ee2469e
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@ -6,12 +6,7 @@
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/bin/bootloader",
|
||||
"args": [
|
||||
"-p",
|
||||
"/dev/ttyACM1",
|
||||
"-f",
|
||||
"nucleo.bin"
|
||||
],
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
"environment": [],
|
||||
|
@ -7,10 +7,8 @@ Bootloader::Bootloader(Uart &uart) : uart(uart)
|
||||
{
|
||||
syn();
|
||||
get();
|
||||
get_version();
|
||||
get_chip_id();
|
||||
get_flash_memory_size();
|
||||
get_bl_version();
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
unsigned char buffer[2];
|
||||
|
@ -25,12 +25,8 @@ public:
|
||||
struct ChipData
|
||||
{
|
||||
uint16_t id;
|
||||
uint8_t bootloader_version_major;
|
||||
uint8_t bootloader_version_minor;
|
||||
uint8_t protocol_version_major;
|
||||
uint8_t protocol_version_minor;
|
||||
uint8_t option_byte_1;
|
||||
uint8_t option_byte_2;
|
||||
uint32_t flash_size;
|
||||
};
|
||||
|
||||
@ -52,17 +48,14 @@ public:
|
||||
private:
|
||||
void syn();
|
||||
void get();
|
||||
void get_version();
|
||||
void get_chip_id();
|
||||
void get_flash_memory_size();
|
||||
void get_bl_version();
|
||||
|
||||
void send_command(uint8_t command);
|
||||
void send_address(uint32_t address);
|
||||
bool wait_for_ack();
|
||||
|
||||
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 uint8_t ACK = 0x79;
|
||||
const uint8_t NAK = 0x1f;
|
||||
@ -83,12 +76,8 @@ private:
|
||||
|
||||
ChipData chip = {
|
||||
.id = 0,
|
||||
.bootloader_version_major = 0,
|
||||
.bootloader_version_minor = 0,
|
||||
.protocol_version_major = 0,
|
||||
.protocol_version_minor = 0,
|
||||
.option_byte_1 = 0,
|
||||
.option_byte_2 = 0,
|
||||
.flash_size = 0,
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
int main()
|
||||
{
|
||||
Uart uart("/dev/ttyACM1");
|
||||
// Uart uart("/dev/ttyUSB0");
|
||||
Bootloader bootloader(uart);
|
||||
|
||||
if (bootloader.chip_is_supported())
|
||||
|
Loading…
Reference in New Issue
Block a user