Merge pull request #315 from schodet/l1xx-cat2-support

Add STM32L1xx Cat.2 devices support
pull/316/head
texane 2015-05-25 18:09:15 +02:00
commit fdfb82b53c
2 zmienionych plików z 36 dodań i 21 usunięć

Wyświetl plik

@ -463,6 +463,8 @@ int stlink_load_device_params(stlink_t *sl) {
if ((sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS) && ( flash_size == 0 )) { if ((sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS) && ( flash_size == 0 )) {
sl->flash_size = 128 * 1024; sl->flash_size = 128 * 1024;
} else if (sl->chip_id == STM32_CHIPID_L1_CAT2) {
sl->flash_size = (flash_size & 0xff) * 1024;
} else if ((sl->chip_id & 0xFFF) == STM32_CHIPID_L1_HIGH) { } else if ((sl->chip_id & 0xFFF) == STM32_CHIPID_L1_HIGH) {
// 0 is 384k and 1 is 256k // 0 is 384k and 1 is 256k
if ( flash_size == 0 ) { if ( flash_size == 0 ) {
@ -934,8 +936,9 @@ int stlink_fread(stlink_t* sl, const char* path, stm32_addr_t addr, size_t size)
int error = -1; int error = -1;
size_t off; size_t off;
int num_empty = 0; int num_empty = 0;
unsigned char erased_pattern = (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS unsigned char erased_pattern = (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_CAT2
|| sl->chip_id == STM32_CHIPID_L1_HIGH || sl->chip_id == STM32_CHIPID_L152_RE) ? 0:0xff; || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS || sl->chip_id == STM32_CHIPID_L1_HIGH
|| sl->chip_id == STM32_CHIPID_L152_RE) ? 0:0xff;
const int fd = open(path, O_RDWR | O_TRUNC | O_CREAT, 00700); const int fd = open(path, O_RDWR | O_TRUNC | O_CREAT, 00700);
if (fd == -1) { if (fd == -1) {
@ -1074,9 +1077,9 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr)
#if DEBUG_FLASH #if DEBUG_FLASH
fprintf(stdout, "Erase Final CR:0x%x\n", read_flash_cr(sl)); fprintf(stdout, "Erase Final CR:0x%x\n", read_flash_cr(sl));
#endif #endif
} else if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS } else if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_CAT2
|| sl->chip_id == STM32_CHIPID_L1_HIGH || sl->chip_id == STM32_CHIPID_L152_RE || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS || sl->chip_id == STM32_CHIPID_L1_HIGH
|| sl->chip_id == STM32_CHIPID_L0) { || sl->chip_id == STM32_CHIPID_L152_RE || sl->chip_id == STM32_CHIPID_L0) {
uint32_t val; uint32_t val;
uint32_t flash_regs_base; uint32_t flash_regs_base;
@ -1179,9 +1182,9 @@ int stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr)
} }
int stlink_erase_flash_mass(stlink_t *sl) { int stlink_erase_flash_mass(stlink_t *sl) {
if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_CAT2
|| sl->chip_id == STM32_CHIPID_L1_HIGH || sl->chip_id == STM32_CHIPID_L152_RE || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS || sl->chip_id == STM32_CHIPID_L1_HIGH
|| sl->chip_id == STM32_CHIPID_L0) { || sl->chip_id == STM32_CHIPID_L152_RE || sl->chip_id == STM32_CHIPID_L0) {
/* erase each page */ /* erase each page */
int i = 0, num_pages = sl->flash_size/sl->flash_pgsz; int i = 0, num_pages = sl->flash_size/sl->flash_pgsz;
for (i = 0; i < num_pages; i++) { for (i = 0; i < num_pages; i++) {
@ -1374,8 +1377,9 @@ int write_loader_to_sram(stlink_t *sl, stm32_addr_t* addr, size_t* size) {
const uint8_t* loader_code; const uint8_t* loader_code;
size_t loader_size; size_t loader_size;
if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_CAT2
|| sl->chip_id == STM32_CHIPID_L1_HIGH || sl->chip_id == STM32_CHIPID_L152_RE) { /* stm32l */ || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS || sl->chip_id == STM32_CHIPID_L1_HIGH
|| sl->chip_id == STM32_CHIPID_L152_RE) { /* stm32l */
loader_code = loader_code_stm32l; loader_code = loader_code_stm32l;
loader_size = sizeof(loader_code_stm32l); loader_size = sizeof(loader_code_stm32l);
} else if (sl->core_id == STM32VL_CORE_ID } else if (sl->core_id == STM32VL_CORE_ID
@ -1607,9 +1611,9 @@ int stlink_write_flash(stlink_t *sl, stm32_addr_t addr, uint8_t* base, uint32_t
} //STM32F4END } //STM32F4END
else if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS else if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_CAT2
|| sl->chip_id == STM32_CHIPID_L1_HIGH || sl->chip_id == STM32_CHIPID_L152_RE || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS || sl->chip_id == STM32_CHIPID_L1_HIGH
|| sl->chip_id == STM32_CHIPID_L0) { || sl->chip_id == STM32_CHIPID_L152_RE || sl->chip_id == STM32_CHIPID_L0) {
/* use fast word write. todo: half page. */ /* use fast word write. todo: half page. */
uint32_t val; uint32_t val;
uint32_t flash_regs_base; uint32_t flash_regs_base;
@ -1738,8 +1742,9 @@ int stlink_fwrite_flash(stlink_t *sl, const char* path, stm32_addr_t addr) {
/* write the file in flash at addr */ /* write the file in flash at addr */
int err; int err;
unsigned int num_empty = 0, index; unsigned int num_empty = 0, index;
unsigned char erased_pattern =(sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS unsigned char erased_pattern = (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_CAT2
|| sl->chip_id == STM32_CHIPID_L1_HIGH || sl->chip_id == STM32_CHIPID_L152_RE )?0:0xff; || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS || sl->chip_id == STM32_CHIPID_L1_HIGH
|| sl->chip_id == STM32_CHIPID_L152_RE) ? 0:0xff;
mapped_file_t mf = MAPPED_FILE_INITIALIZER; mapped_file_t mf = MAPPED_FILE_INITIALIZER;
if (map_file(&mf, path) == -1) { if (map_file(&mf, path) == -1) {
ELOG("map_file() == -1\n"); ELOG("map_file() == -1\n");
@ -1779,9 +1784,9 @@ int run_flash_loader(stlink_t *sl, flash_loader_t* fl, stm32_addr_t target, cons
return -1; return -1;
} }
if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_CAT2
|| sl->chip_id == STM32_CHIPID_L1_HIGH || sl->chip_id == STM32_CHIPID_L152_RE || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS || sl->chip_id == STM32_CHIPID_L1_HIGH
|| sl->chip_id == STM32_CHIPID_L0) { || sl->chip_id == STM32_CHIPID_L152_RE || sl->chip_id == STM32_CHIPID_L0) {
size_t count = size / sizeof(uint32_t); size_t count = size / sizeof(uint32_t);
if (size % sizeof(uint32_t)) ++count; if (size % sizeof(uint32_t)) ++count;
@ -1843,9 +1848,9 @@ int run_flash_loader(stlink_t *sl, flash_loader_t* fl, stm32_addr_t target, cons
} }
/* check written byte count */ /* check written byte count */
if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS if (sl->chip_id == STM32_CHIPID_L1_MEDIUM || sl->chip_id == STM32_CHIPID_L1_CAT2
|| sl->chip_id == STM32_CHIPID_L1_HIGH || sl->chip_id == STM32_CHIPID_L152_RE || sl->chip_id == STM32_CHIPID_L1_MEDIUM_PLUS || sl->chip_id == STM32_CHIPID_L1_HIGH
|| sl->chip_id == STM32_CHIPID_L0) { || sl->chip_id == STM32_CHIPID_L152_RE || sl->chip_id == STM32_CHIPID_L0) {
size_t count = size / sizeof(uint32_t); size_t count = size / sizeof(uint32_t);
if (size % sizeof(uint32_t)) ++count; if (size % sizeof(uint32_t)) ++count;

Wyświetl plik

@ -117,6 +117,7 @@ extern "C" {
#define STM32_CHIPID_L1_MEDIUM_PLUS 0x427 #define STM32_CHIPID_L1_MEDIUM_PLUS 0x427
#define STM32_CHIPID_F1_VL_HIGH 0x428 #define STM32_CHIPID_F1_VL_HIGH 0x428
#define STM32_CHIPID_L1_CAT2 0x429
#define STM32_CHIPID_F1_XL 0x430 #define STM32_CHIPID_F1_XL 0x430
@ -264,6 +265,15 @@ extern "C" {
.bootrom_base = 0x1ff00000, .bootrom_base = 0x1ff00000,
.bootrom_size = 0x1000 .bootrom_size = 0x1000
}, },
{
.chip_id = STM32_CHIPID_L1_CAT2,
.description = "L1 Cat.2 device",
.flash_size_reg = 0x1ff8004c,
.flash_pagesize = 0x100,
.sram_size = 0x8000,
.bootrom_base = 0x1ff00000,
.bootrom_size = 0x1000
},
{ {
.chip_id = STM32_CHIPID_L1_MEDIUM_PLUS, .chip_id = STM32_CHIPID_L1_MEDIUM_PLUS,
.description = "L1 Medium-Plus-density device", .description = "L1 Medium-Plus-density device",