Clean up includes everywhere.
All source files include general.h first and before anything else. This inlcludes platform.h and platform_support.h No header file needs to include to include any of these, but should include any others needed for it's own declarations.
This commit is contained in:
parent
9d80641261
commit
4d4813de87
|
@ -25,15 +25,10 @@
|
|||
* Currently doesn't use ROM table for introspection, just assumes
|
||||
* the device is Cortex-M3.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "jtag_scan.h"
|
||||
#include "gdb_packet.h"
|
||||
#include "adiv5.h"
|
||||
|
||||
#include "target.h"
|
||||
|
||||
#ifndef DO_RESET_SEQ
|
||||
|
|
|
@ -23,14 +23,11 @@
|
|||
*/
|
||||
|
||||
#include "general.h"
|
||||
#include "platform.h"
|
||||
#include "adiv5.h"
|
||||
#include "jtag_scan.h"
|
||||
#include "jtagtap.h"
|
||||
#include "morse.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define JTAGDP_ACK_OK 0x02
|
||||
#define JTAGDP_ACK_WAIT 0x01
|
||||
|
||||
|
|
|
@ -23,17 +23,12 @@
|
|||
*/
|
||||
|
||||
#include "general.h"
|
||||
#include "platform.h"
|
||||
#include "adiv5.h"
|
||||
|
||||
#include "swdptap.h"
|
||||
#include "jtagtap.h"
|
||||
|
||||
#include "command.h"
|
||||
#include "morse.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define SWDP_ACK_OK 0x01
|
||||
#define SWDP_ACK_WAIT 0x02
|
||||
#define SWDP_ACK_FAULT 0x04
|
||||
|
|
|
@ -24,14 +24,10 @@
|
|||
*/
|
||||
|
||||
#include "general.h"
|
||||
#include "platform.h"
|
||||
#include "target.h"
|
||||
#include "jtag_scan.h"
|
||||
#include "jtagtap.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* TODO:
|
||||
* Skeleton target.
|
||||
* EmbeddedICE registers, halt/resume target.
|
||||
|
|
|
@ -22,18 +22,12 @@
|
|||
* commands.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "general.h"
|
||||
|
||||
#include "command.h"
|
||||
#include "gdb_packet.h"
|
||||
|
||||
#include "jtag_scan.h"
|
||||
#include "target.h"
|
||||
#include "morse.h"
|
||||
|
||||
#include "adiv5.h"
|
||||
|
||||
#ifdef PLATFORM_HAS_TRACESWO
|
||||
|
|
|
@ -28,11 +28,6 @@
|
|||
* Issues:
|
||||
* There are way too many magic numbers used here.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "jtagtap.h"
|
||||
#include "jtag_scan.h"
|
||||
|
@ -42,6 +37,8 @@
|
|||
#include "gdb_packet.h"
|
||||
#include "cortexm.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
static char cortexm_driver_str[] = "ARM Cortex-M";
|
||||
|
||||
static bool cortexm_vector_catch(target *t, int argc, char *argv[]);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "target.h"
|
||||
|
||||
#if !defined(STM32F1) && !defined(STM32F4)
|
||||
|
|
|
@ -24,26 +24,15 @@
|
|||
* Originally written for GDB 6.8, updated and tested with GDB 7.2.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "general.h"
|
||||
#include "hex_utils.h"
|
||||
#include "gdb_if.h"
|
||||
#include "gdb_packet.h"
|
||||
#include "gdb_main.h"
|
||||
|
||||
#include "jtagtap.h"
|
||||
#include "jtag_scan.h"
|
||||
#include "adiv5.h"
|
||||
|
||||
#include "target.h"
|
||||
|
||||
#include "command.h"
|
||||
#include "crc32.h"
|
||||
|
||||
|
|
|
@ -22,18 +22,13 @@
|
|||
* reception and transmission as well as some convenience functions.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "gdb_if.h"
|
||||
#include "gdb_packet.h"
|
||||
#include "hex_utils.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
gdb_getpacket(unsigned char *packet, int size)
|
||||
{
|
||||
|
|
|
@ -21,9 +21,7 @@
|
|||
/* Convenience function to convert to/from ascii strings of hex digits.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "hex_utils.h"
|
||||
|
||||
static char hexdigits[] = "0123456789abcdef";
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#ifndef __ADIV5_H
|
||||
#define __ADIV5_H
|
||||
|
||||
#include "general.h"
|
||||
#include "jtag_scan.h"
|
||||
#include "target.h"
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#ifndef __ARM7TDMI_H
|
||||
#define __ARM7TDMI_H
|
||||
|
||||
#include "general.h"
|
||||
#include "jtag_scan.h"
|
||||
|
||||
void arm7tdmi_jtag_handler(jtag_dev_t *dev);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#ifndef __COMMAND_H
|
||||
#define __COMMAND_H
|
||||
|
||||
#include "general.h"
|
||||
#include "target.h"
|
||||
|
||||
int command_process(target *t, char *cmd);
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2015 Gareth McMullin <gareth@blacksphere.co.nz>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef __CORTEXM_H
|
||||
#define __CORTEXM_H
|
||||
|
||||
#include "target.h"
|
||||
|
||||
/* Private peripheral bus base address */
|
||||
#define CORTEXM_PPB_BASE 0xE0000000
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#ifndef __CRC32_H
|
||||
#define __CRC32_H
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
uint32_t crc32_calc(uint32_t crc, uint8_t data);
|
||||
uint32_t generic_crc32(struct target_s *target, uint32_t base, int len);
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#ifndef __GDB_PACKET_H
|
||||
#define __GDB_PACKET_H
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int gdb_getpacket(unsigned char *packet, int size);
|
||||
void gdb_putpacket(unsigned char *packet, int size);
|
||||
#define gdb_putpacketz(packet) gdb_putpacket((packet), strlen(packet))
|
||||
|
|
|
@ -21,15 +21,21 @@
|
|||
#ifndef __GENERAL_H
|
||||
#define __GENERAL_H
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "platform_support.h"
|
||||
|
||||
#ifndef DEBUG
|
||||
#include <stdio.h>
|
||||
#define DEBUG printf
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#ifndef __JTAG_SCAN_H
|
||||
#define __JTAG_SCAN_H
|
||||
|
||||
#include "general.h"
|
||||
|
||||
#define JTAG_MAX_DEVS 5
|
||||
#define JTAG_MAX_IR_LEN 16
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#ifndef __JTAGTAP_H
|
||||
#define __JTAGTAP_H
|
||||
|
||||
#include "general.h"
|
||||
|
||||
/* Note: Signal names are as for the device under test. */
|
||||
|
||||
int jtagtap_init(void);
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#ifndef __MORSE_H
|
||||
#define __MORSE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
extern const char *morse_msg;
|
||||
|
||||
void morse(const char *msg, char repeat);
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* Copyright (C) 2015 Gareth McMullin <gareth@blacksphere.co.nz>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __PLATFORM_SUPPORT_H
|
||||
#define __PLATFORM_SUPPORT_H
|
||||
|
||||
#ifndef __GENERAL_H
|
||||
# error "Include 'general.h' instead"
|
||||
#endif
|
||||
|
||||
#if defined(LIBFTDI)
|
||||
void platform_init(int argc, char **argv);
|
||||
#else
|
||||
void platform_init(void);
|
||||
#endif
|
||||
|
||||
const char *platform_target_voltage(void);
|
||||
int platform_hwversion(void);
|
||||
void platform_delay(uint32_t delay);
|
||||
void platform_srst_set_val(bool assert);
|
||||
bool platform_target_get_power(void);
|
||||
void platform_target_set_power(bool power);
|
||||
|
||||
#endif
|
||||
|
|
@ -21,8 +21,6 @@
|
|||
#ifndef __SWDPTAP_H
|
||||
#define __SWDPTAP_H
|
||||
|
||||
#include "general.h"
|
||||
|
||||
int swdptap_init(void);
|
||||
void swdptap_reset(void);
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@
|
|||
#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
|
||||
|
|
|
@ -22,19 +22,12 @@
|
|||
* to detect devices on the scan chain and read their IDCODEs.
|
||||
* It depends on the low-level function provided by the platform's jtagtap.c.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "jtagtap.h"
|
||||
#include "morse.h"
|
||||
#include "jtag_scan.h"
|
||||
|
||||
#include "gdb_packet.h"
|
||||
|
||||
#include "adiv5.h"
|
||||
#include "arm7tdmi.h"
|
||||
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
* the XML memory map and Flash memory programming.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "adiv5.h"
|
||||
#include "target.h"
|
||||
|
|
|
@ -27,9 +27,6 @@
|
|||
* Flash erase is very slow.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "adiv5.h"
|
||||
#include "target.h"
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/*
|
||||
* This file is part of the Black Magic Debug project.
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "general.h"
|
||||
#include "adiv5.h"
|
||||
#include "target.h"
|
||||
|
|
|
@ -17,11 +17,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "command.h"
|
||||
#include "general.h"
|
||||
#include "command.h"
|
||||
#include "adiv5.h"
|
||||
#include "target.h"
|
||||
#include "gdb_packet.h"
|
||||
|
|
10
src/main.c
10
src/main.c
|
@ -22,26 +22,22 @@
|
|||
* protocol loop.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "gdb_if.h"
|
||||
#include "gdb_main.h"
|
||||
#include "jtagtap.h"
|
||||
#include "jtag_scan.h"
|
||||
|
||||
#include "target.h"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
#if defined(LIBFTDI)
|
||||
assert(platform_init(argc, argv) == 0);
|
||||
platform_init(argc, argv);
|
||||
#else
|
||||
(void) argc;
|
||||
(void) argv;
|
||||
assert(platform_init() == 0);
|
||||
platform_init();
|
||||
#endif
|
||||
PLATFORM_SET_FATAL_ERROR_RECOVERY();
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
* the device, providing the XML memory map and Flash memory programming.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "adiv5.h"
|
||||
#include "target.h"
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
#include <libopencm3/usb/cdc.h>
|
||||
#include "general.h"
|
||||
|
||||
void usbuart_init(void);
|
||||
|
||||
|
|
|
@ -22,7 +22,11 @@
|
|||
* implementation.
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "cdcacm.h"
|
||||
#include "usbuart.h"
|
||||
#include "morse.h"
|
||||
|
||||
#include <libopencm3/stm32/f4/rcc.h>
|
||||
#include <libopencm3/cm3/systick.h>
|
||||
#include <libopencm3/cm3/scb.h>
|
||||
|
@ -32,16 +36,12 @@
|
|||
#include <libopencm3/stm32/syscfg.h>
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
||||
#include "jtag_scan.h"
|
||||
#include "usbuart.h"
|
||||
#include "morse.h"
|
||||
|
||||
uint8_t running_status;
|
||||
volatile uint32_t timeout_counter;
|
||||
|
||||
jmp_buf fatal_error_jmpbuf;
|
||||
|
||||
int platform_init(void)
|
||||
void platform_init(void)
|
||||
{
|
||||
/* Check the USER button*/
|
||||
rcc_peripheral_enable_clock(&RCC_AHB1ENR, RCC_AHB1ENR_IOPAEN);
|
||||
|
@ -86,17 +86,7 @@ int platform_init(void)
|
|||
systick_counter_enable();
|
||||
|
||||
usbuart_init();
|
||||
|
||||
cdcacm_init();
|
||||
|
||||
// Set recovery point
|
||||
if (setjmp(fatal_error_jmpbuf)) {
|
||||
return 0; // Do nothing on failure
|
||||
}
|
||||
|
||||
jtag_scan(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void platform_delay(uint32_t delay)
|
||||
|
|
|
@ -24,19 +24,12 @@
|
|||
#ifndef __PLATFORM_H
|
||||
#define __PLATFORM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <libopencm3/cm3/common.h>
|
||||
#include <libopencm3/stm32/f4/memorymap.h>
|
||||
#include <libopencm3/stm32/f4/gpio.h>
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <alloca.h>
|
||||
|
||||
#include "gdb_packet.h"
|
||||
#include "gpio.h"
|
||||
#include "morse.h"
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#define PLATFORM_HAS_TRACESWO
|
||||
#define BOARD_IDENT "Black Magic Probe (F4Discovery), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for F4Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
|
@ -173,9 +166,6 @@ extern jmp_buf fatal_error_jmpbuf;
|
|||
longjmp(fatal_error_jmpbuf, (error)); \
|
||||
}
|
||||
|
||||
int platform_init(void);
|
||||
const char *platform_target_voltage(void);
|
||||
void platform_delay(uint32_t delay);
|
||||
static inline int platform_hwversion(void)
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "general.h"
|
||||
#include "usbdfu.h"
|
||||
|
||||
#include <libopencm3/cm3/systick.h>
|
||||
#include <libopencm3/stm32/rcc.h>
|
||||
#include <libopencm3/stm32/gpio.h>
|
||||
#include <libopencm3/cm3/scb.h>
|
||||
|
||||
#include "usbdfu.h"
|
||||
|
||||
void dfu_detach(void)
|
||||
{
|
||||
/* USB device must detach, we just reset... */
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "gdb_if.h"
|
||||
#include "cdcacm.h"
|
||||
#include "usbuart.h"
|
||||
|
||||
#include <libopencm3/lm4f/rcc.h>
|
||||
|
@ -26,14 +27,14 @@ void sys_tick_handler(void)
|
|||
trace_tick();
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
platform_init(void)
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<1000000; i++);
|
||||
|
||||
rcc_sysclk_config(OSCSRC_MOSC, XTAL_16M, PLL_DIV_80MHZ);
|
||||
|
||||
|
||||
// Enable all JTAG ports and set pins to output
|
||||
periph_clock_enable(RCC_GPIOA);
|
||||
periph_clock_enable(RCC_GPIOB);
|
||||
|
@ -59,10 +60,6 @@ platform_init(void)
|
|||
|
||||
usbuart_init();
|
||||
cdcacm_init();
|
||||
|
||||
//jtag_scan(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void platform_delay(uint32_t delay)
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
#ifndef __PLATFORM_H
|
||||
#define __PLATFORM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "gdb_packet.h"
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <alloca.h>
|
||||
|
||||
#include <libopencm3/lm4f/gpio.h>
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
||||
#include "gdb_packet.h"
|
||||
|
||||
#define CDCACM_PACKET_SIZE 64
|
||||
#define BOARD_IDENT "Black Magic Probe (Launchpad ICDI), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for Launchpad, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
|
@ -110,8 +107,6 @@ extern usbd_driver lm4f_usb_driver;
|
|||
|
||||
#define PLATFORM_HAS_TRACESWO
|
||||
|
||||
int platform_init(void);
|
||||
|
||||
inline static void gpio_set_val(uint32_t port, uint8_t pin, uint8_t val) {
|
||||
gpio_write(port, pin, val == 0 ? 0 : 0xff);
|
||||
}
|
||||
|
@ -120,15 +115,6 @@ inline static uint8_t gpio_get(uint32_t port, uint8_t pin) {
|
|||
return !(gpio_read(port, pin) == 0);
|
||||
}
|
||||
|
||||
void platform_delay(uint32_t delay);
|
||||
const char *platform_target_voltage(void);
|
||||
|
||||
/* <cdcacm.c> */
|
||||
void cdcacm_init(void);
|
||||
/* Returns current usb configuration, or 0 if not configured. */
|
||||
int cdcacm_get_config(void);
|
||||
int cdcacm_get_dtr(void);
|
||||
|
||||
#define disconnect_usb() do { usbd_disconnect(usbdev,1); nvic_disable_irq(USB_IRQ);} while(0)
|
||||
#define setup_vbus_irq()
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ void jtagtap_reset(void)
|
|||
|
||||
void jtagtap_srst(bool assert)
|
||||
{
|
||||
(void)assert;
|
||||
platform_buffer_flush();
|
||||
//ftdi_write_data(ftdic, "\x80\x88\xAB", 3);
|
||||
//usleep(1000);
|
||||
|
|
|
@ -17,14 +17,10 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "gdb_if.h"
|
||||
#include "jtag_scan.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct ftdi_context *ftdic;
|
||||
|
||||
|
@ -121,7 +117,7 @@ static struct cable_desc_s {
|
|||
},
|
||||
};
|
||||
|
||||
int platform_init(int argc, char **argv)
|
||||
void platform_init(int argc, char **argv)
|
||||
{
|
||||
int err;
|
||||
int c;
|
||||
|
@ -149,7 +145,7 @@ int platform_init(int argc, char **argv)
|
|||
|
||||
if (index == sizeof(cable_desc)/sizeof(cable_desc[0])){
|
||||
fprintf(stderr, "No cable matching %s found\n",cablename);
|
||||
return -1;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (cable_desc[index].dbus_data)
|
||||
|
@ -212,12 +208,7 @@ int platform_init(int argc, char **argv)
|
|||
}
|
||||
|
||||
assert(ftdi_write_data(ftdic, ftdi_init, 9) == 9);
|
||||
|
||||
assert(gdb_if_init() == 0);
|
||||
|
||||
jtag_scan(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void platform_buffer_flush(void)
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#ifndef __PLATFORM_H
|
||||
#define __PLATFORM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ftdi.h>
|
||||
|
||||
#ifndef WIN32
|
||||
|
@ -42,10 +41,6 @@
|
|||
|
||||
extern struct ftdi_context *ftdic;
|
||||
|
||||
int platform_init(int argc, char **argv);
|
||||
const char *platform_target_voltage(void);
|
||||
void platform_delay(uint32_t delay);
|
||||
|
||||
void platform_buffer_flush(void);
|
||||
int platform_buffer_write(const uint8_t *data, int size);
|
||||
int platform_buffer_read(uint8_t *data, int size);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <assert.h>
|
||||
#include <ftdi.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "swdptap.h"
|
||||
|
||||
static void swdptap_turnaround(uint8_t dir);
|
||||
|
|
|
@ -22,7 +22,10 @@
|
|||
* implementation.
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "cdcacm.h"
|
||||
#include "usbuart.h"
|
||||
#include "morse.h"
|
||||
|
||||
#include <libopencm3/stm32/f1/rcc.h>
|
||||
#include <libopencm3/cm3/systick.h>
|
||||
|
@ -33,11 +36,6 @@
|
|||
#include <libopencm3/usb/usbd.h>
|
||||
#include <libopencm3/stm32/f1/adc.h>
|
||||
|
||||
#include "jtag_scan.h"
|
||||
#include "cdcacm.h"
|
||||
#include "usbuart.h"
|
||||
#include "morse.h"
|
||||
|
||||
uint8_t running_status;
|
||||
volatile uint32_t timeout_counter;
|
||||
|
||||
|
@ -62,7 +60,7 @@ int platform_hwversion(void)
|
|||
return hwversion;
|
||||
}
|
||||
|
||||
int platform_init(void)
|
||||
void platform_init(void)
|
||||
{
|
||||
rcc_clock_setup_in_hse_8mhz_out_72mhz();
|
||||
|
||||
|
@ -136,16 +134,6 @@ int platform_init(void)
|
|||
|
||||
cdcacm_init();
|
||||
usbuart_init();
|
||||
|
||||
/* Set recovery point */
|
||||
if (setjmp(fatal_error_jmpbuf)) {
|
||||
/* Do nothing on failure */
|
||||
return 0;
|
||||
}
|
||||
|
||||
jtag_scan(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void platform_srst_set_val(bool assert)
|
||||
|
|
|
@ -24,20 +24,12 @@
|
|||
#ifndef __PLATFORM_H
|
||||
#define __PLATFORM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <libopencm3/cm3/common.h>
|
||||
#include <libopencm3/stm32/f1/memorymap.h>
|
||||
|
||||
#include <libopencm3/stm32/f1/gpio.h>
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <alloca.h>
|
||||
|
||||
#include "gdb_packet.h"
|
||||
#include "gpio.h"
|
||||
#include "morse.h"
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#define PLATFORM_HAS_TRACESWO
|
||||
#define PLATFORM_HAS_POWER_SWITCH
|
||||
#define BOARD_IDENT "Black Magic Probe"
|
||||
|
@ -173,13 +165,6 @@ extern jmp_buf fatal_error_jmpbuf;
|
|||
longjmp(fatal_error_jmpbuf, (error)); \
|
||||
} while (0)
|
||||
|
||||
int platform_init(void);
|
||||
const char *platform_target_voltage(void);
|
||||
int platform_hwversion(void);
|
||||
void platform_set_timeout(uint32_t ms);
|
||||
bool platform_timeout_expired(void);
|
||||
void platform_delay(uint32_t delay);
|
||||
|
||||
/* Use newlib provided integer only stdio functions */
|
||||
#define sscanf siscanf
|
||||
#define sprintf siprintf
|
||||
|
@ -188,9 +173,6 @@ void platform_delay(uint32_t delay);
|
|||
#define disconnect_usb() gpio_set_mode(USB_PU_PORT, GPIO_MODE_INPUT, 0, USB_PU_PIN);
|
||||
void assert_boot_pin(void);
|
||||
void setup_vbus_irq(void);
|
||||
void platform_srst_set_val(bool assert);
|
||||
bool platform_target_get_power(void);
|
||||
void platform_target_set_power(bool power);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -22,7 +22,10 @@
|
|||
* implementation.
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "cdcacm.h"
|
||||
#include "usbuart.h"
|
||||
|
||||
#include <libopencm3/stm32/rcc.h>
|
||||
#include <libopencm3/cm3/systick.h>
|
||||
#include <libopencm3/cm3/scb.h>
|
||||
|
@ -31,11 +34,6 @@
|
|||
#include <libopencm3/usb/usbd.h>
|
||||
#include <libopencm3/stm32/adc.h>
|
||||
|
||||
#include "jtag_scan.h"
|
||||
#include <usbuart.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
uint8_t running_status;
|
||||
volatile uint32_t timeout_counter;
|
||||
|
||||
|
@ -68,7 +66,7 @@ int platform_hwversion(void)
|
|||
return hwversion;
|
||||
}
|
||||
|
||||
int platform_init(void)
|
||||
void platform_init(void)
|
||||
{
|
||||
rcc_clock_setup_in_hse_8mhz_out_72mhz();
|
||||
|
||||
|
@ -119,16 +117,6 @@ int platform_init(void)
|
|||
SCB_VTOR = 0x2000; /* Relocate interrupt vector table here */
|
||||
|
||||
cdcacm_init();
|
||||
|
||||
/* Set recovery point */
|
||||
if (setjmp(fatal_error_jmpbuf)) {
|
||||
/* Do nothing on failure */
|
||||
return 0;
|
||||
}
|
||||
|
||||
jtag_scan(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void platform_delay(uint32_t delay)
|
||||
|
|
|
@ -24,18 +24,14 @@
|
|||
#ifndef __PLATFORM_H
|
||||
#define __PLATFORM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "gdb_packet.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#include <libopencm3/cm3/common.h>
|
||||
#include <libopencm3/stm32/f1/memorymap.h>
|
||||
|
||||
#include <libopencm3/stm32/f1/gpio.h>
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <alloca.h>
|
||||
|
||||
#include "gdb_packet.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define BOARD_IDENT "Black Magic Probe (STLINK), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for STLink/Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
|
@ -151,11 +147,6 @@ extern uint16_t led_idle_run;
|
|||
longjmp(fatal_error_jmpbuf, (error)); \
|
||||
} while (0)
|
||||
|
||||
int platform_init(void);
|
||||
const char *platform_target_voltage(void);
|
||||
void platform_delay(uint32_t delay);
|
||||
void platform_srst_set_val(bool assert);
|
||||
|
||||
/* Use newlib provided integer only stdio functions */
|
||||
#define sscanf siscanf
|
||||
#define sprintf siprintf
|
||||
|
@ -163,6 +154,7 @@ void platform_srst_set_val(bool assert);
|
|||
|
||||
void disconnect_usb(void);
|
||||
void assert_boot_pin(void);
|
||||
void setup_vbus_irq(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <libopencm3/usb/dfu.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "gdb_if.h"
|
||||
#include "cdcacm.h"
|
||||
#if defined(PLATFORM_HAS_TRACESWO)
|
||||
|
|
|
@ -16,12 +16,11 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "usbdfu.h"
|
||||
|
||||
#include <libopencm3/stm32/f1/flash.h>
|
||||
#include <libopencm3/cm3/scb.h>
|
||||
#include "usbdfu.h"
|
||||
|
||||
#define FLASH_OBP_RDP 0x1FFFF800
|
||||
#define FLASH_OBP_WRP10 0x1FFFF808
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "usbdfu.h"
|
||||
|
||||
#if defined(STM32F2)
|
||||
# include <libopencm3/stm32/f2/flash.h>
|
||||
|
@ -26,8 +26,6 @@
|
|||
#endif
|
||||
#include <libopencm3/cm3/scb.h>
|
||||
|
||||
#include "usbdfu.h"
|
||||
|
||||
static uint32_t sector_addr[] = {
|
||||
0x8000000, 0x8004000, 0x8008000, 0x800c000,
|
||||
0x8010000, 0x8020000, 0x8040000, 0x8060000,
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
|
||||
#include <string.h>
|
||||
#if defined(STM32F1)
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* Serial Debugging protocol is implemented. This implementation for STM32
|
||||
* uses the USB CDC-ACM device bulk endpoints to implement the channel.
|
||||
*/
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "cdcacm.h"
|
||||
#include "gdb_if.h"
|
||||
|
||||
|
|
|
@ -20,6 +20,16 @@
|
|||
#ifndef __GPIO_H
|
||||
#define __GPIO_H
|
||||
|
||||
#include <libopencm3/cm3/common.h>
|
||||
|
||||
#ifndef STM32F4
|
||||
# include <libopencm3/stm32/f1/memorymap.h>
|
||||
# include <libopencm3/stm32/f1/gpio.h>
|
||||
#else
|
||||
# include <libopencm3/stm32/f4/memorymap.h>
|
||||
# include <libopencm3/stm32/f4/gpio.h>
|
||||
#endif
|
||||
|
||||
#define INLINE_GPIO
|
||||
|
||||
#define gpio_set_val(port, pin, val) do { \
|
||||
|
|
|
@ -23,9 +23,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "general.h"
|
||||
|
||||
#include "jtagtap.h"
|
||||
#include "platform.h"
|
||||
|
||||
int jtagtap_init(void)
|
||||
{
|
||||
|
|
|
@ -32,15 +32,12 @@
|
|||
* The core can then process the buffer to extract the frame.
|
||||
*/
|
||||
#include "general.h"
|
||||
#include "cdcacm.h"
|
||||
|
||||
#include <libopencm3/cm3/nvic.h>
|
||||
#include <libopencm3/stm32/timer.h>
|
||||
#include <libopencm3/stm32/f1/rcc.h>
|
||||
|
||||
#include <string.h>
|
||||
#include "platform.h"
|
||||
#include "cdcacm.h"
|
||||
|
||||
void traceswo_init(void)
|
||||
{
|
||||
TRACE_TIM_CLK_EN();
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <libopencm3/usb/usbd.h>
|
||||
#include <libopencm3/usb/cdc.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "cdcacm.h"
|
||||
|
||||
#define USBUART_TIMER_FREQ_HZ 1000000U /* 1us per tick */
|
||||
|
|
|
@ -22,7 +22,10 @@
|
|||
* implementation.
|
||||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "cdcacm.h"
|
||||
#include "usbuart.h"
|
||||
|
||||
#include <libopencm3/stm32/f1/rcc.h>
|
||||
#include <libopencm3/cm3/systick.h>
|
||||
#include <libopencm3/cm3/scb.h>
|
||||
|
@ -31,17 +34,12 @@
|
|||
#include <libopencm3/usb/usbd.h>
|
||||
#include <libopencm3/stm32/f1/adc.h>
|
||||
|
||||
#include "jtag_scan.h"
|
||||
#include <usbuart.h>
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
uint8_t running_status;
|
||||
volatile uint32_t timeout_counter;
|
||||
|
||||
jmp_buf fatal_error_jmpbuf;
|
||||
|
||||
int platform_init(void)
|
||||
void platform_init(void)
|
||||
{
|
||||
uint32_t data;
|
||||
rcc_clock_setup_in_hse_8mhz_out_72mhz();
|
||||
|
@ -98,15 +96,6 @@ int platform_init(void)
|
|||
SCB_VTOR = 0x2000; // Relocate interrupt vector table here
|
||||
|
||||
cdcacm_init();
|
||||
|
||||
// Set recovery point
|
||||
if (setjmp(fatal_error_jmpbuf)) {
|
||||
return 0; // Do nothing on failure
|
||||
}
|
||||
|
||||
jtag_scan(NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void platform_delay(uint32_t delay)
|
||||
|
|
|
@ -24,19 +24,11 @@
|
|||
#ifndef __PLATFORM_H
|
||||
#define __PLATFORM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <libopencm3/cm3/common.h>
|
||||
#include <libopencm3/stm32/f1/memorymap.h>
|
||||
|
||||
#include <libopencm3/stm32/f1/gpio.h>
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <alloca.h>
|
||||
|
||||
#include "gdb_packet.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#define BOARD_IDENT "Black Magic Probe (SWLINK), (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade), STM8S Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade), STM8S Discovery, (Firmware 1.5" VERSION_SUFFIX ", build " BUILDDATE ")"
|
||||
|
@ -149,10 +141,6 @@ extern jmp_buf fatal_error_jmpbuf;
|
|||
longjmp(fatal_error_jmpbuf, (error)); \
|
||||
}
|
||||
|
||||
int platform_init(void);
|
||||
const char *platform_target_voltage(void);
|
||||
void platform_delay(uint32_t delay);
|
||||
|
||||
/* Use newlib provided integer only stdio functions */
|
||||
#define sscanf siscanf
|
||||
#define sprintf siprintf
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <libopencm3/lm4f/usb.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "general.h"
|
||||
#include "gdb_if.h"
|
||||
#if defined(PLATFORM_HAS_TRACESWO)
|
||||
#include <traceswo.h>
|
||||
|
|
|
@ -22,10 +22,12 @@
|
|||
* Serial Debugging protocol is implemented. This implementation for STM32
|
||||
* uses the USB CDC-ACM device bulk endpoints to implement the channel.
|
||||
*/
|
||||
#include "platform.h"
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "gdb_if.h"
|
||||
#include "cdcacm.h"
|
||||
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
||||
static volatile uint32_t head_out, tail_out;
|
||||
static volatile uint32_t count_in;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "general.h"
|
||||
#include "jtagtap.h"
|
||||
|
||||
int
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "general.h"
|
||||
#include "platform.h"
|
||||
#include "swdptap.h"
|
||||
|
||||
static void swdptap_turnaround(uint8_t dir)
|
||||
|
|
|
@ -32,14 +32,9 @@
|
|||
#include <libopencm3/cm3/nvic.h>
|
||||
#include <libopencm3/lm4f/rcc.h>
|
||||
#include <libopencm3/lm4f/nvic.h>
|
||||
|
||||
#include <libopencm3/lm4f/uart.h>
|
||||
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
||||
#include <string.h>
|
||||
#include "platform.h"
|
||||
|
||||
void traceswo_init(void)
|
||||
{
|
||||
periph_clock_enable(RCC_GPIOD);
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "general.h"
|
||||
#include "cdcacm.h"
|
||||
|
||||
#include <libopencm3/cm3/nvic.h>
|
||||
#include <libopencm3/cm3/scs.h>
|
||||
|
@ -27,8 +29,6 @@
|
|||
#include <libopencm3/lm4f/rcc.h>
|
||||
#include <libopencm3/lm4f/uart.h>
|
||||
|
||||
#include <platform.h>
|
||||
|
||||
#define FIFO_SIZE 128
|
||||
|
||||
/* RX Fifo buffer */
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
* the device, providing the XML memory map and Flash memory programming.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "adiv5.h"
|
||||
#include "target.h"
|
||||
|
|
|
@ -32,10 +32,6 @@
|
|||
* particularly Sections 12. DSU and 20. NVMCTRL
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "jtagtap.h"
|
||||
#include "adiv5.h"
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
* Programming manual - STM32F10xxx Flash memory microcontrollers
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "adiv5.h"
|
||||
#include "target.h"
|
||||
|
|
|
@ -30,9 +30,6 @@
|
|||
* manual
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "adiv5.h"
|
||||
#include "target.h"
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
* Flash and EEPROM programming
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "general.h"
|
||||
#include "adiv5.h"
|
||||
#include "target.h"
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#include "general.h"
|
||||
#include "target.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
target *target_list = NULL;
|
||||
bool connect_assert_srst;
|
||||
|
||||
|
|
Loading…
Reference in New Issue