efm32/samd/samx5x: Remove static allocates strings. Allocate in priv_storage.
Static allocated variables in the different targets eat up common RAM and will collide in chains with multiple similar targets.
This commit is contained in:
parent
cddf02f174
commit
ac7c1057cc
@ -584,7 +584,10 @@ static efm32_device_t const * efm32_get_device(size_t index)
|
|||||||
/**
|
/**
|
||||||
* Probe
|
* Probe
|
||||||
*/
|
*/
|
||||||
static char efm32_variant_string[60];
|
struct efm32_priv_s {
|
||||||
|
char efm32_variant_string[60];
|
||||||
|
};
|
||||||
|
|
||||||
bool efm32_probe(target *t)
|
bool efm32_probe(target *t)
|
||||||
{
|
{
|
||||||
uint8_t di_version = 1;
|
uint8_t di_version = 1;
|
||||||
@ -636,13 +639,17 @@ bool efm32_probe(target *t)
|
|||||||
uint32_t ram_size = ram_kib * 0x400;
|
uint32_t ram_size = ram_kib * 0x400;
|
||||||
uint32_t flash_page_size = device->flash_page_size;
|
uint32_t flash_page_size = device->flash_page_size;
|
||||||
|
|
||||||
snprintf(efm32_variant_string, sizeof(efm32_variant_string), "%c\b%c\b%s %d F%d %s",
|
struct efm32_priv_s *priv_storage = calloc(1, sizeof(*priv_storage));
|
||||||
|
t->target_storage = (void*)priv_storage;
|
||||||
|
|
||||||
|
snprintf(priv_storage->efm32_variant_string,
|
||||||
|
sizeof(priv_storage->efm32_variant_string), "%c\b%c\b%s %d F%d %s",
|
||||||
di_version + 48, (uint8_t)device_index + 32,
|
di_version + 48, (uint8_t)device_index + 32,
|
||||||
device->name, part_number, flash_kib, device->description);
|
device->name, part_number, flash_kib, device->description);
|
||||||
|
|
||||||
/* Setup Target */
|
/* Setup Target */
|
||||||
t->target_options |= CORTEXM_TOPT_INHIBIT_SRST;
|
t->target_options |= CORTEXM_TOPT_INHIBIT_SRST;
|
||||||
t->driver = efm32_variant_string;
|
t->driver = priv_storage->efm32_variant_string;
|
||||||
tc_printf(t, "flash size %d page size %d\n", flash_size, flash_page_size);
|
tc_printf(t, "flash size %d page size %d\n", flash_size, flash_page_size);
|
||||||
target_add_ram (t, SRAM_BASE, ram_size);
|
target_add_ram (t, SRAM_BASE, ram_size);
|
||||||
efm32_add_flash(t, 0x00000000, flash_size, flash_page_size);
|
efm32_add_flash(t, 0x00000000, flash_size, flash_page_size);
|
||||||
@ -980,7 +987,10 @@ static bool nop_function(void)
|
|||||||
/**
|
/**
|
||||||
* AAP Probe
|
* AAP Probe
|
||||||
*/
|
*/
|
||||||
char aap_driver_string[42];
|
struct efm32_aap_priv_s {
|
||||||
|
char aap_driver_string[42];
|
||||||
|
};
|
||||||
|
|
||||||
void efm32_aap_probe(ADIv5_AP_t *ap)
|
void efm32_aap_probe(ADIv5_AP_t *ap)
|
||||||
{
|
{
|
||||||
if ((ap->idr & EFM32_APP_IDR_MASK) == EFM32_AAP_IDR) {
|
if ((ap->idr & EFM32_APP_IDR_MASK) == EFM32_AAP_IDR) {
|
||||||
@ -1004,10 +1014,11 @@ void efm32_aap_probe(ADIv5_AP_t *ap)
|
|||||||
/* Read status */
|
/* Read status */
|
||||||
DEBUG_INFO("EFM32: AAP STATUS=%08"PRIx32"\n", adiv5_ap_read(ap, AAP_STATUS));
|
DEBUG_INFO("EFM32: AAP STATUS=%08"PRIx32"\n", adiv5_ap_read(ap, AAP_STATUS));
|
||||||
|
|
||||||
sprintf(aap_driver_string,
|
struct efm32_aap_priv_s *priv_storage = calloc(1, sizeof(*priv_storage));
|
||||||
|
sprintf(priv_storage->aap_driver_string,
|
||||||
"EFM32 Authentication Access Port rev.%d",
|
"EFM32 Authentication Access Port rev.%d",
|
||||||
aap_revision);
|
aap_revision);
|
||||||
t->driver = aap_driver_string;
|
t->driver = priv_storage->aap_driver_string;
|
||||||
t->attach = (void*)nop_function;
|
t->attach = (void*)nop_function;
|
||||||
t->detach = (void*)nop_function;
|
t->detach = (void*)nop_function;
|
||||||
t->check_error = (void*)nop_function;
|
t->check_error = (void*)nop_function;
|
||||||
|
@ -441,7 +441,10 @@ static void samd_add_flash(target *t, uint32_t addr, size_t length)
|
|||||||
target_add_flash(t, f);
|
target_add_flash(t, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char samd_variant_string[60];
|
struct samd_priv_s {
|
||||||
|
char samd_variant_string[60];
|
||||||
|
};
|
||||||
|
|
||||||
bool samd_probe(target *t)
|
bool samd_probe(target *t)
|
||||||
{
|
{
|
||||||
ADIv5_AP_t *ap = cortexm_ap(t);
|
ADIv5_AP_t *ap = cortexm_ap(t);
|
||||||
@ -460,6 +463,9 @@ bool samd_probe(target *t)
|
|||||||
if ((did & SAMD_DID_MASK) != SAMD_DID_CONST_VALUE)
|
if ((did & SAMD_DID_MASK) != SAMD_DID_CONST_VALUE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
struct samd_priv_s *priv_storage = calloc(1, sizeof(*priv_storage));
|
||||||
|
t->target_storage = (void*)priv_storage;
|
||||||
|
|
||||||
uint32_t ctrlstat = target_mem_read32(t, SAMD_DSU_CTRLSTAT);
|
uint32_t ctrlstat = target_mem_read32(t, SAMD_DSU_CTRLSTAT);
|
||||||
struct samd_descr samd = samd_parse_device_id(did);
|
struct samd_descr samd = samd_parse_device_id(did);
|
||||||
|
|
||||||
@ -468,14 +474,14 @@ bool samd_probe(target *t)
|
|||||||
|
|
||||||
/* Part String */
|
/* Part String */
|
||||||
if (protected) {
|
if (protected) {
|
||||||
sprintf(samd_variant_string,
|
sprintf(priv_storage->samd_variant_string,
|
||||||
"Atmel SAM%c%d%c%d%c%s (rev %c) (PROT=1)",
|
"Atmel SAM%c%d%c%d%c%s (rev %c) (PROT=1)",
|
||||||
samd.family,
|
samd.family,
|
||||||
samd.series, samd.pin, samd.mem,
|
samd.series, samd.pin, samd.mem,
|
||||||
samd.variant,
|
samd.variant,
|
||||||
samd.package, samd.revision);
|
samd.package, samd.revision);
|
||||||
} else {
|
} else {
|
||||||
sprintf(samd_variant_string,
|
sprintf(priv_storage->samd_variant_string,
|
||||||
"Atmel SAM%c%d%c%d%c%s (rev %c)",
|
"Atmel SAM%c%d%c%d%c%s (rev %c)",
|
||||||
samd.family,
|
samd.family,
|
||||||
samd.series, samd.pin, samd.mem,
|
samd.series, samd.pin, samd.mem,
|
||||||
@ -484,7 +490,7 @@ bool samd_probe(target *t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Setup Target */
|
/* Setup Target */
|
||||||
t->driver = samd_variant_string;
|
t->driver = priv_storage->samd_variant_string;
|
||||||
t->reset = samd_reset;
|
t->reset = samd_reset;
|
||||||
|
|
||||||
if (samd.series == 20 && samd.revision == 'B') {
|
if (samd.series == 20 && samd.revision == 'B') {
|
||||||
|
@ -344,7 +344,10 @@ static void samx5x_add_flash(target *t, uint32_t addr, size_t length,
|
|||||||
target_add_flash(t, f);
|
target_add_flash(t, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char samx5x_variant_string[60];
|
struct samx5x_priv_s {
|
||||||
|
char samx5x_variant_string[60];
|
||||||
|
};
|
||||||
|
|
||||||
bool samx5x_probe(target *t)
|
bool samx5x_probe(target *t)
|
||||||
{
|
{
|
||||||
ADIv5_AP_t *ap = cortexm_ap(t);
|
ADIv5_AP_t *ap = cortexm_ap(t);
|
||||||
@ -370,20 +373,25 @@ bool samx5x_probe(target *t)
|
|||||||
bool protected = (ctrlstat & SAMX5X_STATUSB_PROT);
|
bool protected = (ctrlstat & SAMX5X_STATUSB_PROT);
|
||||||
|
|
||||||
/* Part String */
|
/* Part String */
|
||||||
|
struct samx5x_priv_s *priv_storage = calloc(1, sizeof(*priv_storage));
|
||||||
|
t->target_storage = (void*)priv_storage;
|
||||||
|
|
||||||
if (protected) {
|
if (protected) {
|
||||||
snprintf(samx5x_variant_string, sizeof(samx5x_variant_string),
|
snprintf(priv_storage->samx5x_variant_string,
|
||||||
|
sizeof(priv_storage->samx5x_variant_string),
|
||||||
"Microchip SAM%c%d%c%dA (rev %c) (PROT=1)",
|
"Microchip SAM%c%d%c%dA (rev %c) (PROT=1)",
|
||||||
samx5x.series_letter, samx5x.series_number,
|
samx5x.series_letter, samx5x.series_number,
|
||||||
samx5x.pin, samx5x.mem, samx5x.revision);
|
samx5x.pin, samx5x.mem, samx5x.revision);
|
||||||
} else {
|
} else {
|
||||||
snprintf(samx5x_variant_string, sizeof(samx5x_variant_string),
|
snprintf(priv_storage->samx5x_variant_string,
|
||||||
|
sizeof(priv_storage->samx5x_variant_string),
|
||||||
"Microchip SAM%c%d%c%dA (rev %c)",
|
"Microchip SAM%c%d%c%dA (rev %c)",
|
||||||
samx5x.series_letter, samx5x.series_number,
|
samx5x.series_letter, samx5x.series_number,
|
||||||
samx5x.pin, samx5x.mem, samx5x.revision);
|
samx5x.pin, samx5x.mem, samx5x.revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup Target */
|
/* Setup Target */
|
||||||
t->driver = samx5x_variant_string;
|
t->driver = priv_storage->samx5x_variant_string;
|
||||||
t->reset = samx5x_reset;
|
t->reset = samx5x_reset;
|
||||||
|
|
||||||
if (protected) {
|
if (protected) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user