gd32f1/f3 detection and ram/flash autoset

This commit is contained in:
mean 2020-12-03 07:30:24 +01:00 committed by UweBonnes
parent 575c25e570
commit e3fd12ebc6
4 changed files with 38 additions and 1 deletions

View File

@ -97,8 +97,9 @@
#define AP_DESIGNER_ARM 0x43b
/*LPC845 with designer 501. Strange!? */
#define AP_DESIGNER_SPECULAR 0x501
#define AP_DESIGNER_CS 0x555
#define AP_DESIGNER_ENERGY_MICRO 0x673
#define AP_DESIGNER_CS 0x555
#define AP_DESIGNER_GIGADEVICE 0x751
/* AP Control and Status Word (CSW) */
#define ADIV5_AP_CSW_DBGSWENABLE (1u << 31)

View File

@ -390,6 +390,9 @@ bool cortexm_probe(ADIv5_AP_t *ap)
case AP_DESIGNER_CS:
PROBE(stm32f1_probe);
break;
case AP_DESIGNER_GIGADEVICE:
PROBE(gd32f1_probe);
break;
case AP_DESIGNER_STM:
PROBE(stm32f1_probe);
PROBE(stm32f4_probe);

View File

@ -116,6 +116,38 @@ static void stm32f1_add_flash(target *t,
target_add_flash(t, f);
}
/**
\brief identify the correct gd32 f1/f3 chip
GD32 : STM32 compatible chip
*/
bool gd32f1_probe(target *t)
{
uint16_t stored_idcode = t->idcode;
// M3 & M4 & riscV only afaik
t->idcode = target_mem_read32(t, DBGMCU_IDCODE) & 0xfff;
uint32_t signature= target_mem_read32(t, FLASHSIZE);
uint32_t flashSize=signature & 0xFFFF;
uint32_t ramSize=signature >>16 ;
switch(t->idcode) {
case 0x414: /* Gigadevice gd32f303 */
t->driver = "GD32F3";
break;
case 0x410: /* Gigadevice gd32f103 */
t->driver = "GD32F1";
break;
default:
t->idcode = stored_idcode;
return false;
}
target_add_ram(t, 0x20000000, ramSize*1024);
stm32f1_add_flash(t, 0x8000000, flashSize*1024, 0x400);
target_add_commands(t, stm32f1_cmd_list, t->driver);
return true;
}
/**
\brief identify the stm32f1 chip
*/
bool stm32f1_probe(target *t)
{
uint16_t stored_idcode = t->idcode;

View File

@ -169,6 +169,7 @@ int tc_system(target *t, target_addr cmd, size_t cmdlen);
/* Probe for various targets.
* Actual functions implemented in their respective drivers.
*/
bool gd32f1_probe(target *t);
bool stm32f1_probe(target *t);
bool stm32f4_probe(target *t);
bool stm32h7_probe(target *t);