[Solved] Conversion of Not so good value STM32F103C8T6 Board to BMP

flodejr
Posts: 37
Joined: Sat Sep 16, 2017 2:46 pm

[Solved] Conversion of Not so good value STM32F103C8T6 Board to BMP

Post by flodejr » Sun Sep 24, 2017 10:31 am

Hi all,

I am pretty new to STM32 and I am the sucker who bought this board http://stm32duino.com/viewtopic.php?f=28&t=1663 which was supposed to be USB to UART/I2C/SPI board, but due to lack of documentation besides being a USB-UART, the I2C/SPI is almost impossible to figure out. The expanded pins are limited and thus not good for a general development board. So I am thinking of converting it to a Black Magic Probe. But I have some questions regarding the conversion.

Firstly, is the DFU really required? All the guides I googled instructed first to burn the DFU and then load the firmware via the DFU. Can I not burn directly the firmware without the DFU? Since after all, the main functionality exist in the main firmware. The board does not have the boot0 and boot1 pins exposed and I would try avoid any soldering on smd (clumsy fingers). Will there be any problems if I use a Stlink v2 clone to flash directly the firmware. (Hmm think to self : maybe it are the boot and jump addresses, so maybe I can flash both via SWD so that addresses stay same).

Secondly, due to the number of broken out pins on this STMF103C8T6 board, what I can identify are the hardware pins for I2C1 (PB6, PB7), SPI1 (PA5,PA6,PA7), UART2(PA2, PA3), SWIO(PA13,PA14), this doesn't map to the pinouts of the default BMP SWD(PA5,PB14), Serial(PA2, PA3). The PB14 for my board is missing the breakout. I have seen the code for BMP on the hardware mappin:

Code: Select all

/* Hardware definitions... */
#define TDI_PORT	GPIOA
#define TMS_PORT	GPIOB
#define TCK_PORT	GPIOA
#define TDO_PORT	GPIOA
#define TDI_PIN		GPIO7
#define TMS_PIN		GPIO14
#define TCK_PIN		GPIO5
#define TDO_PIN		GPIO6


PB14 is defined as the TMS_PORT in the software, If i map this to another pin which is available to me, will there be an issue and which pin would be the most suitable?

Thanks in advance for reading this long post and your replies to this noob sucker :P
Last edited by flodejr on Mon Sep 25, 2017 5:54 am, edited 1 time in total.

User avatar
Pito
Posts: 1739
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Conversion of Not so good value STM32F103C8T6 Board to BMP

Post by Pito » Sun Sep 24, 2017 10:58 am

Will there be any problems if I use a Stlink v2 clone to flash directly the firmware.
You can flash with STLINK any binary into it, of course, provided you have got the SWD pins available on the header (SWIO, SWCLK).
Is there any schematics of this BadValue (BV) board available??
You may also flash the bootloader for BluePill into it and use it.. (there is the 1k5 resistor there on the pcb so the bootloader may work).
Pukao Hats Cleaning Services Ltd.

flodejr
Posts: 37
Joined: Sat Sep 16, 2017 2:46 pm

Re: Conversion of Not so good value STM32F103C8T6 Board to BMP

Post by flodejr » Sun Sep 24, 2017 4:02 pm

Pito wrote:
Sun Sep 24, 2017 10:58 am
Is there any schematics of this BadValue (BV) board available??
No there are no user-guide nor schematics available for the board, however, what I can confirm are the break-outs of the SPI1, I2C1, UART2 pins and also the SWIO pins. I have also written a simple program to scan all the pins and it seems that the 3 LEDs on board, the first nearest to the micro USB connector is the directly connected to VCC, the one next to it is actuall PORTB Pin 11 and after that is PORTB Pin 12, both pins are pulled high. Out of the 20 broken out pins, there are 2 +5V and 4 +3.3V and 3 GND connections. So the usage I think is pretty limited.

User avatar
Rick Kimball
Posts: 1078
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Conversion of Not so good value STM32F103C8T6 Board to BMP

Post by Rick Kimball » Sun Sep 24, 2017 4:24 pm

I would use the SCL SDA pins (PB6, PB7) for the SWD pins, that way they physically line up in a row (3v3, SCL, SDA, GND) making the wire connection simpler. The change should just be a few defines in the header you pointed at above. I've never spent any time trying to get the JTAG feature of BMP working. If you are mostly planning to use it with ARM cortex-m boards, SWD is all you need.

I can't tell if your board has a USB_DISCONNECT pin. Have you checked out the PCB for a transistor that connects and disconnects a pull up resistor to the PA12 pin? Have you asked the manufacturer for a schematic? If it turns out that there isn't a USB disconnect circuit, you should be able to use the BMP STLINK platform with some minor port/pin changes. To get the your board to USB enumerate, just disconnect the USB cable and reconnect.
-rick

flodejr
Posts: 37
Joined: Sat Sep 16, 2017 2:46 pm

Re: Conversion of Not so good value STM32F103C8T6 Board to BMP

Post by flodejr » Mon Sep 25, 2017 2:19 am

I have mapped the pins as such :

Code: Select all

/* Hardware definitions... */
#define TDI_PORT	GPIOA  // JTAG TEST DATA IN PORT
#define TDI_PIN		GPIO6  // JTAG TEST DATA IN PIN <-> SPI1 MISO

#define TMS_PORT	GPIOB  // SWDIO_PORT 
#define TMS_PIN		GPIO7  // SWDIO_PIN <-> I2C1 SDA

#define TCK_PORT	GPIOB  // SWCLK_PORT
#define TCK_PIN		GPIO6  // SWCLK_PIN <-> I2C1 SCL

#define TDO_PORT	GPIOA  // JTAG TEST DATA OUT PORT
#define TDO_PIN		GPIO7  // JTAG TEST DATA OUT PIN <-> SPI1 MOSI

#define SWDIO_PORT 	TMS_PORT
#define SWCLK_PORT 	TCK_PORT
#define SWDIO_PIN	TMS_PIN
#define SWCLK_PIN	TCK_PIN

#define SRST_PORT	GPIOA  // JTAG TEST RESET PORT
#define SRST_PIN_V1	GPIO9  // JTAG TEST RESET PIN1
#define SRST_PIN_V2	GPIO8  // JTAG TEST RESET PIN2

#define LED_PORT	GPIOB
/* Use PC14 for a "dummy" uart led. So we can observere at least with scope*/
#define LED_PORT_UART	GPIOB
#define LED_UART	GPIO11
and also also relocated the firmware address to 0x08000000 since I have decided not to use the dfu.

Code: Select all

LDFLAGS = $(LDFLAGS_BOOT) -Wl,-Ttext=0x8000000
I have flashed it to the board and I am getting both Comm ports and when I use gdb, i was able to connect as well. But wiring to it via SWD to another Blue pill board and issuing "target extended remote /dev/ttyACM0" and followed by "monitor swdp_scan", I am getting a scan failure. Have I missed anything?

User avatar
RogerClark
Posts: 7690
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Conversion of Not so good value STM32F103C8T6 Board to BMP

Post by RogerClark » Mon Sep 25, 2017 2:58 am

I think you may be making life difficult for yourself

If you select the "generic stm32f103c" board in the Arduino IDE, then select STLink upload it will upload via STLink

There is also an option to use the Blackmagic probe if you have one of those.

There is however a difference in how the board will work, depending on which upload method you choose.

If you choose STLink upload, USB Serial will be enabled as the STLink dongles don't have a virtual serial port

If you choose Blackmagic probe (aka BMP) upload, USB serial does not get enabled because the BMP has its on virtual serial port.

User avatar
Rick Kimball
Posts: 1078
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Conversion of Not so good value STM32F103C8T6 Board to BMP

Post by Rick Kimball » Mon Sep 25, 2017 3:15 am

Have you connected DIO,CLK,GND? between each board? Powering bluepill with Usb?

Did you try setting boot0 high on the blupill, press reset and then try to connect?

Does 'monitor help' work?
-rick

flodejr
Posts: 37
Joined: Sat Sep 16, 2017 2:46 pm

Re: Conversion of Not so good value STM32F103C8T6 Board to BMP

Post by flodejr » Mon Sep 25, 2017 3:18 am

Hi Roger,

My questions are not related to how to flash the stm32 board, I know almost all the methods of flashing firmware. What I am trying to do is to make a Black Magic Probe out of a defunct USB to I2c/SPI/Uart board that I have purchased and due to the limited broken out pins, I have to remap the pins.

What I have achieved so far is to modify the BMP firmware so that it maps to the pins that are broken out on the board and am able to flash it with USB devices detected in my linux machine, but I am not getting correct responses from the BMP that I am making. Thus the questions if there are other pins that I need to take note of.

flodejr
Posts: 37
Joined: Sat Sep 16, 2017 2:46 pm

Re: Conversion of Not so good value STM32F103C8T6 Board to BMP

Post by flodejr » Mon Sep 25, 2017 3:32 am

Rick Kimball wrote:
Mon Sep 25, 2017 3:15 am
Have you connected DIO,CLK,GND? between each board? Powering bluepill with Usb?

Did you try setting boot0 high on the blupill, press reset and then try to connect?

Does 'monitor help' work?
I have connected SWDIO to pin B7, SWCLK to pin B6 (as per my modification in the BMP firmware), 3.3V and GND and Monitor helps works as well. I have also defined the LED PORT B11 as UART indicator and it flashes each time I issue a command. But "monitor swdp_scan" failed. I also enabled debug mode, but "monitor swdp_scan" is not issuing any debug messages on the UART, but if I issue a "monitor jtag_scan" I can see some messages on the debug terminal but my jtag is not connected to anything.

User avatar
Rick Kimball
Posts: 1078
Joined: Tue Apr 28, 2015 1:26 am
Location: Eastern NC, US
Contact:

Re: Conversion of Not so good value STM32F103C8T6 Board to BMP

Post by Rick Kimball » Mon Sep 25, 2017 3:36 am

Are there pull up resistors on those pins, as they were marked i2c? if so,maybe try other pins
-rick

Post Reply