diff --git a/src/Makefile b/src/Makefile index a63d0b0..6699191 100644 --- a/src/Makefile +++ b/src/Makefile @@ -10,28 +10,30 @@ CFLAGS += -Wall -Wextra -Wno-pointer-sign -Wno-char-subscripts\ -I. -Iinclude -I$(PLATFORM_DIR) \ -DVERSION_SUFFIX=\"`../scripts/setlocalversion`\" -MD -SRC = gdb_if.c \ - gdb_packet.c \ - gdb_main.c \ - hex_utils.c \ - jtagtap.c \ - swdptap.c \ +SRC = \ adiv5.c \ - adiv5_swdp.c \ - cortexm.c \ - stm32f1.c \ - nxp_tgt.c \ - main.c \ - platform.c \ - command.c \ - jtag_scan.c \ adiv5_jtagdp.c \ - lmi.c \ + adiv5_swdp.c \ arm7tdmi.c \ + command.c \ + cortexm.c \ + crc32.c \ + gdb_if.c \ + gdb_main.c \ + gdb_packet.c \ + hex_utils.c \ + jtag_scan.c \ + jtagtap.c \ + lmi.c \ + lpc43xx.c \ + main.c \ + nxp_tgt.c \ + platform.c \ + sam3x.c \ + stm32f1.c \ stm32f4.c \ stm32l1.c \ - crc32.c \ - sam3x.c \ + swdptap.c \ target.c \ include $(PLATFORM_DIR)/Makefile.inc diff --git a/src/cortexm.c b/src/cortexm.c index b403c83..167fce8 100644 --- a/src/cortexm.c +++ b/src/cortexm.c @@ -363,6 +363,7 @@ cortexm_probe(struct target_s *target) PROBE(stm32f4_probe); PROBE(stm32l1_probe); PROBE(lpc11xx_probe); + PROBE(lpc43xx_probe); PROBE(sam3x_probe); /* Try LMI last, as it doesn't fail. */ PROBE(lmi_probe); diff --git a/src/include/target.h b/src/include/target.h index 6daf350..9be0e18 100644 --- a/src/include/target.h +++ b/src/include/target.h @@ -200,6 +200,7 @@ 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); #endif diff --git a/src/lpc43xx.c b/src/lpc43xx.c new file mode 100644 index 0000000..2652b42 --- /dev/null +++ b/src/lpc43xx.c @@ -0,0 +1,53 @@ +/* + * This file is part of the Black Magic Debug project. + * + * Copyright (C) 2012 Gareth McMullin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "general.h" +#include "adiv5.h" +#include "target.h" + +#define LPC43XX_CHIPID 0x40043200 +#define ARM_CPUID 0xE000ED00 + +int lpc43xx_probe(struct target_s *target) +{ + uint32_t chipid, cpuid; + + chipid = adiv5_ap_mem_read(adiv5_target_ap(target), LPC43XX_CHIPID); + cpuid = adiv5_ap_mem_read(adiv5_target_ap(target), ARM_CPUID); + + switch(chipid) { + case 0x4906002B: /* Parts with on-chip flash */ + case 0x5906002B: /* Flashless parts */ + case 0x6906002B: + switch (cpuid & 0xFF00FFF0) { + case 0x4100C240: + target->driver = "LPC43xx Cortex-M4"; + break; + case 0x4100C200: + target->driver = "LPC43xx Cortex-M0"; + break; + default: + target->driver = "LPC43xx "; + } + return 0; + } + + return -1; +} +