Probe function return bool, true if device identified.

Correctly identify LM3S3748.
This commit is contained in:
Gareth McMullin 2012-11-03 23:51:53 +13:00
parent e1c1162a1a
commit 2637f072a1
9 changed files with 50 additions and 48 deletions

View File

@ -315,7 +315,7 @@ static const char tdesc_cortex_mf[] =
" </feature>"
"</target>";
int
bool
cortexm_probe(struct target_s *target)
{
target->driver = cortexm_driver_str;
@ -357,7 +357,7 @@ cortexm_probe(struct target_s *target)
CORTEXM_DEMCR_VC_CORERESET;
#define PROBE(x) \
do { if (!(x)(target)) return 0; else target_check_error(target); } while (0)
do { if ((x)(target)) return true; else target_check_error(target); } while (0)
PROBE(stm32f1_probe);
PROBE(stm32f4_probe);
@ -365,11 +365,10 @@ cortexm_probe(struct target_s *target)
PROBE(lpc11xx_probe);
PROBE(lpc43xx_probe);
PROBE(sam3x_probe);
/* Try LMI last, as it doesn't fail. */
PROBE(lmi_probe);
#undef PROBE
return 0;
return true;
}
static bool

View File

@ -25,6 +25,8 @@
#ifndef __TARGET_H
#define __TARGET_H
#include "general.h"
typedef struct target_s target;
/* The destroy callback function will be called by target_list_free() just
@ -194,14 +196,14 @@ void target_add_commands(target *t, const struct command_s *cmds, const char *na
/* Probe for various targets.
* Actual functions implemented in their respective drivers.
*/
int cortexm_probe(struct target_s *target);
int stm32f1_probe(struct target_s *target);
int stm32f4_probe(struct target_s *target);
int stm32l1_probe(struct target_s *target);
int lmi_probe(struct target_s *target);
int lpc11xx_probe(struct target_s *target);
int lpc43xx_probe(struct target_s *target);
int sam3x_probe(struct target_s *target);
bool cortexm_probe(struct target_s *target);
bool stm32f1_probe(struct target_s *target);
bool stm32f4_probe(struct target_s *target);
bool stm32l1_probe(struct target_s *target);
bool lmi_probe(struct target_s *target);
bool lpc11xx_probe(struct target_s *target);
bool lpc43xx_probe(struct target_s *target);
bool sam3x_probe(struct target_s *target);
#endif

View File

@ -90,14 +90,18 @@ uint16_t lmi_flash_write_stub[] = {
// ...
};
int lmi_probe(struct target_s *target)
bool lmi_probe(struct target_s *target)
{
/* How do we really probe the LMI device??? */
uint32_t did1 = adiv5_ap_mem_read(adiv5_target_ap(target), 0x400FE004);
switch (did1 >> 16) {
case 0x1049: /* LM3S3748 */
target->driver = lmi_driver_str;
target->xml_mem_map = lmi_xml_memory_map;
target->flash_erase = lmi_flash_erase;
target->flash_write = lmi_flash_write;
return 0;
return true;
}
return false;
}
int lmi_flash_erase(struct target_s *target, uint32_t addr, int len)

View File

@ -24,7 +24,7 @@
#define LPC43XX_CHIPID 0x40043200
#define ARM_CPUID 0xE000ED00
int lpc43xx_probe(struct target_s *target)
bool lpc43xx_probe(struct target_s *target)
{
uint32_t chipid, cpuid;
@ -45,9 +45,9 @@ int lpc43xx_probe(struct target_s *target)
default:
target->driver = "LPC43xx <Unknown>";
}
return 0;
return true;
}
return -1;
return false;
}

View File

@ -67,7 +67,7 @@ static const char lpc11xx_xml_memory_map[] = "<?xml version=\"1.0\"?>"
"</memory-map>";
int
bool
lpc11xx_probe(struct target_s *target)
{
uint32_t idcode;
@ -101,13 +101,10 @@ lpc11xx_probe(struct target_s *target)
target->flash_erase = lpc11xx_flash_erase;
target->flash_write = lpc11xx_flash_write;
return 0;
default:
break;
return true;
}
return -1;
return false;
}
static void

View File

@ -109,7 +109,7 @@ static const char sam3x_xml_memory_map[] = "<?xml version=\"1.0\"?>"
#define PAGE_SIZE 256
int sam3x_probe(struct target_s *target)
bool sam3x_probe(struct target_s *target)
{
ADIv5_AP_t *ap = adiv5_target_ap(target);
@ -125,9 +125,9 @@ int sam3x_probe(struct target_s *target)
target->flash_erase = sam3x_flash_erase;
target->flash_write = sam3x_flash_write;
target_add_commands(target, sam3x_cmd_list, sam3x_driver_str);
return 0;
return true;
}
return -1;
return false;
}
static int

View File

@ -151,7 +151,7 @@ uint16_t stm32f1_flash_write_stub[] = {
// ...
};
int stm32f1_probe(struct target_s *target)
bool stm32f1_probe(struct target_s *target)
{
uint32_t idcode;
@ -165,7 +165,7 @@ int stm32f1_probe(struct target_s *target)
target->flash_erase = stm32md_flash_erase;
target->flash_write = stm32f1_flash_write;
target_add_commands(target, stm32f1_cmd_list, "STM32");
return 0;
return true;
case 0x414: /* High density */
case 0x418: /* Connectivity Line */
case 0x428: /* Value Line, High Density */
@ -174,14 +174,14 @@ int stm32f1_probe(struct target_s *target)
target->flash_erase = stm32hd_flash_erase;
target->flash_write = stm32f1_flash_write;
target_add_commands(target, stm32f1_cmd_list, "STM32");
return 0;
return true;
case 0x422: /* STM32F3 */
target->driver = stm32f3_driver_str;
target->xml_mem_map = stm32hd_xml_memory_map;
target->flash_erase = stm32hd_flash_erase;
target->flash_write = stm32f1_flash_write;
target_add_commands(target, stm32f1_cmd_list, "STM32");
return 0;
return true;
}
idcode = adiv5_ap_mem_read(adiv5_target_ap(target), DBGMCU_IDCODE_F0);
@ -192,10 +192,10 @@ int stm32f1_probe(struct target_s *target)
target->flash_erase = stm32md_flash_erase;
target->flash_write = stm32f1_flash_write;
target_add_commands(target, stm32f1_cmd_list, "STM32");
return 0;
return true;
}
return -1;
return false;
}
static void stm32f1_flash_unlock(ADIv5_AP_t *ap)

View File

@ -133,7 +133,7 @@ uint16_t stm32f4_flash_write_stub[] = {
// ...
};
int stm32f4_probe(struct target_s *target)
bool stm32f4_probe(struct target_s *target)
{
uint32_t idcode;
@ -145,9 +145,9 @@ int stm32f4_probe(struct target_s *target)
target->xml_mem_map = stm32f4_xml_memory_map;
target->flash_erase = stm32f4_flash_erase;
target->flash_write = stm32f4_flash_write;
return 0;
return true;
}
return -1;
return false;
}

View File

@ -85,7 +85,7 @@ static const char stm32l1_xml_memory_map[] = "<?xml version=\"1.0\"?>"
#define DBGMCU_IDCODE 0xE0042000
int stm32l1_probe(struct target_s *target)
bool stm32l1_probe(struct target_s *target)
{
uint32_t idcode;
@ -97,10 +97,10 @@ int stm32l1_probe(struct target_s *target)
target->xml_mem_map = stm32l1_xml_memory_map;
target->flash_erase = stm32l1_flash_erase;
target->flash_write = stm32l1_flash_write;
return 0;
return true;
}
return -1;
return false;
}
static void stm32l1_flash_unlock(ADIv5_AP_t *ap)