Skip to content
Snippets Groups Projects
Commit 806dc9e8 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Implemented the read_memory command.

Added the EEPROM memory size in the data structures.
Added the feature to program EEPROM memory.
parent 04e7cf6c
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -219,17 +219,42 @@ int main(int argc,char *argv[])
done=hex_get_first_segment(hex_file,&base,&data_len);
while(!done)
{
if(base<0x08000000)
std::cout << "segment: start address: " << std::hex << base << ", length: " << std::dec << data_len << std::endl;
if(base<FLASH_START || base>FLASH_START+data_len)
{
std::cout << "Start address not in FLASH" << std::endl;
hex_close(hex_file);
return 1;
if(device_info->eeprom_size!=0)
{
if(base<EEPROM_START || base>EEPROM_START+data_len)
{
std::cout << "Start address not in FLASH" << std::endl;
hex_close(hex_file);
return 1;
}
else
{
if((base+data_len)>(EEPROM_START+device_info->eeprom_size*1024))
{
std::cout << "Segment does not fit in EEPROM" << std::endl;
hex_close(hex_file);
return 1;
}
}
}
else
{
std::cout << "Start address not in FLASH" << std::endl;
hex_close(hex_file);
return 1;
}
}
if((base+data_len)>0x08000000+device_info->flash_size*1024)
else
{
std::cout << "End address not in FLASH" << std::endl;
hex_close(hex_file);
return 1;
if((base+data_len)>(FLASH_START+device_info->flash_size*1024))
{
std::cout << "Segment does not fit in FLASH" << std::endl;
hex_close(hex_file);
return 1;
}
}
addr = base;
std::cout << '\xd';
......
This diff is collapsed.
......@@ -9,6 +9,9 @@
#define STM32_CMD_INIT 0x7F
#define STM32_CMD_GET 0x00 /* get the version and command supported */
#define FLASH_START 0x08000000
#define EEPROM_START 0x08080000
typedef struct {
uint8_t get;
uint8_t gvr;
......@@ -29,6 +32,7 @@ typedef struct {
uint16_t pid;
uint16_t flash_size;
uint16_t ram_size;
uint16_t eeprom_size;
}stm32_dev;
typedef struct {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment