Skip to content

Instantly share code, notes, and snippets.

View sidprice's full-sized avatar
💭
So much to learn ... what a cool life!

Sid Price sidprice

💭
So much to learn ... what a cool life!
View GitHub Profile
INFO: Open USB 046d:c318 class 0 failed
BMP hosted v1.7.1-116-g897b3ca42
for ST-Link V2/3, CMSIS_DAP, JLINK and LIBFTDI/MPSSE
Using 1d50:6018 7BAF7095 Black Sphere Technologies
Black Magic Probe v1.7.1-116-g897b3ca42
prefix 7&29f9091&0
SYSTEM\CurrentControlSet\Enum\USB\VID_1D50&PID_6018&MI_00\7&29f9091&0&0000\Device Parameters
Portname COM12
+#!GA#
K v1.7.1-116-g897b3ca42#
Problem:
While the USART Rx is working and collects data into a buffer calls to write the data to the trace endpoint are failing. The locm3 function returns zero.
Observations:
"usbd_ep_write_packet" returns a value of zero.
Tracing the above call reveals the locm3 function "dwc_ep_write_packet" is called by the above function and the first test made in that method is causing an immediate return:
uint16_t dwc_ep_write_packet(usbd_device *usbd_dev, uint8_t addr,
void trace_init(uint32_t bitrate, uint32_t channelmask, uint32_t cpu_clock_frequency)
{
CoreDebug->DEMCR = CoreDebug_DEMCR_TRCENA_Msk ;
TPI->CSPSR = 1 ; // Protocol width = 1 bit
TPI->SPPR = 1 ; // 1 = Manchester, 2 = Asynchronous
TPI->ACPR = (cpu_clock_frequency / (2 * bitrate)) - 1 ;
TPI->FFCR = 0 ; // Turn off formatter, discard ETM output
ITM->LAR = 0xC5ACCE55 ; // unlock access to ITM
gcc -L -g -obmdebug.exe bmdebug.o bmscan.o bmp-script.o elf-postlink.o guidriver.o minIni.o rs232.o specialfolder.o strlcpy.o decodectf.o parsetsdl.o swotrace.o nuklear.o nuklear_gdip.o noc_file_dialog.o -lm -lgdiplus -lwinusb
guidriver.o: In function `guidriver_init':
C:\DataRoot\Projects\Black-Magic-Probe-Book\source/guidriver.c:101: undefined reference to `__imp_GetStockObject'
swotrace.o: In function `usb_GetDevicePath':
C:\DataRoot\Projects\Black-Magic-Probe-Book\source/swotrace.c:499: undefined reference to `__imp_SetupDiGetClassDevsA'
C:\DataRoot\Projects\Black-Magic-Probe-Book\source/swotrace.c:506: undefined reference to `__imp_SetupDiEnumDeviceInterfaces'
C:\DataRoot\Projects\Black-Magic-Probe-Book\source/swotrace.c:517: undefined reference to `__imp_SetupDiGetDeviceInterfaceDetailA'
C:\DataRoot\Projects\Black-Magic-Probe-Book\source/swotrace.c:527: undefined reference to `__imp_SetupDiGetDeviceInterfaceDetailA'
C:\DataRoot\Projects\Black-Magic-Probe-Book\source/swotrace.c:543: undefined reference t
@sidprice
sidprice / linker_errors
Created July 18, 2019 15:32
Output when building libftdi (BMP)
PS C:\DataRoot\Projects\blackmagic\src> make CC=gcc V=1 PROBE_HOST=LIBFTDI
echo " GIT include/version.h"
" GIT include/version.h"
echo #define FIRMWARE_VERSION "v1.6.1-292-g3165d64" > include/version.h
" CC target/adiv5.c"
gcc -Wall -Wextra -Werror -Wno-char-subscripts -Wno-cast-function-type -O2 -std=gnu99 -g3 -MD -I. -Iinclude -Iplatforms/common -Iplatforms/LIBFTDI -DLIBFTDI -DENABLE_DEBUG -Wno-cast-function-type -c target/adiv5.c -o adiv5.o
" CC target/adiv5_jtagdp.c"
gcc -Wall -Wextra -Werror -Wno-char-subscripts -Wno-cast-function-type -O2 -std=gnu99 -g3 -MD -I. -Iinclude -Iplatforms/common -Iplatforms/LIBFTDI -DLIBFTDI -DENABLE_DEBUG -Wno-cast-function-type -c target/adiv5_jtagdp.c -o adiv5_jtagdp.o
" CC target/adiv5_swdp.c"
gcc -Wall -Wextra -Werror -Wno-char-subscripts -Wno-cast-function-type -O2 -std=gnu99 -g3 -MD -I. -Iinclude -Iplatforms/common -Iplatforms/LIBFTDI -DLIBFTDI -DENABLE_DEBUG -Wno-cast-function-type -c target/adiv5_swdp.c -o adiv5_swdp.o
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xmlns:saxon="http://saxon.sf.net//"
schemaVersion="1.3"
xs:schemaLocation="http://www.atmel.com/schemas/pack-device-atmel-extension PACK.DEVICE.ATMEL.EXTENSION.xsd"
xs:noNamespaceSchemaLocation="PACK.xsd">
<vendor>Atmel</vendor>
<url>http://packs.download.atmel.com/</url>
<name>SAMR21_DFP</name>
<description>Atmel SAMR21 Series Device Support</description>
gcc -Wall -Wextra -Werror -Wno-char-subscripts -Wno-cast-function-type -Ic:\libusb\include -Og -g -std=gnu99 -g3 -MD -I. -Iinclude -Iplatfor
ms/common -Iplatforms/stlinkv2 -DLIBFTDI -DSTLINKV2 -DJTAG_HL -I ./target -Wno-cast-function-type -c command.c -o command.o
In file included from command.c:31:0:
include/version.h:1:1: error: expected identifier or '(' before string constant
"#define FIRMWARE_VERSION \"`git describe --always --dirty`\""
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
command.c:41:2: error: unknown type name 'cmd_handler'
cmd_handler handler;
^~~~~~~~~~~
command.c:67:15: error: 'cmd_handler' undeclared here (not in a function); did you mean 'cmd_hard_srst'?
#define WDBP_BATTERY_INPUT 0 // ADC Channel for battery input
#define WDBP_TARGET_VOLTAGE_INPUT 8 // ADC Chanmel for target voltage
#define WDBP_ADC_BATTERY 0
#define WDBP_ADC_TARGET 1
static uint32_t inputVoltages[2] = { 0 };
static uint8_t adcChannels[2] = { WDBP_BATTERY_INPUT , WDBP_TARGET_VOLTAGE_INPUT };
////////////////////////////////////////////////////////////////////////////////////////////////////
In file included from /usr/include/w32api/winsock2.h:56:0,
from platforms/libftdi/gdb_if.c:33:
/usr/include/w32api/psdk_inc/_fd_types.h:100:2: error: #warning "fd_set and associated macros have been defined in sys/types. This can cause runtime problems with W32 sockets" [-Werror=cpp]
#warning "fd_set and associated macros have been defined in sys/types. \
^~~~~~~
In file included from platforms/libftdi/gdb_if.c:33:0:
/usr/include/w32api/winsock2.h:995:34: error: conflicting types for ‘select’
WINSOCK_API_LINKAGE int WSAAPI select(int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,const PTIMEVAL timeout);
^~~~~~
In file included from /usr/include/sys/types.h:68:0,
CC platforms/libftdi/gdb_if.c
platforms/libftdi/gdb_if.c:27:16: error: extra tokens at end of #ifndef directive [-Werror]
#ifndef _WIN32 || defined __CYGWIN__
^~
platforms/libftdi/gdb_if.c: In function ‘gdb_if_init’:
platforms/libftdi/gdb_if.c:47:15: error: extra tokens at end of #ifdef directive [-Werror]
#ifdef _WIN32 || defined __CYGWIN__
^~
platforms/libftdi/gdb_if.c: At top level:
cc1: error: unrecognized command line option ‘-Wno-cast-function-type’ [-Werror]