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

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:

/* 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


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).

flodejr
Sun Sep 24, 2017 4:02 pm
[Pito – 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.


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.


flodejr
Mon Sep 25, 2017 2:19 am
I have mapped the pins as such :
/* 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


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.


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?


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
Mon Sep 25, 2017 3:32 am
[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?

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.


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 Kimball
Mon Sep 25, 2017 3:42 am
you have both 3v3 and usb connected? It should be one or the other but not both.

flodejr
Mon Sep 25, 2017 3:57 am
[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

you have both 3v3 and usb connected? It should be one or the other but not both.

I have tested, the two i2c pins does not have pull up resistors on them and I am only using the USB power, no external power supply. I have tried mapping to the SPI pins as well and I get the same results. There must be some hardcoded pins in the firmware somewhere and I am trying to search for them. so far I have found like PC14, PC15 and PC13 for version verifications and also PA15 for some reset function.


Rick Kimball
Mon Sep 25, 2017 4:00 am
If you flash a bluepill with this blackmagic.bin you have created does it work?

RogerClark
Mon Sep 25, 2017 5:12 am
@flodejr

Sorry. I miss-read the title.

I think you’d be better off going onto the BMP chat room on Gitter

https://gitter.im/blacksphere/blackmagic

Those guys know a lot more about building the BMP etc


flodejr
Mon Sep 25, 2017 5:51 am
Hi Rick,

Thanks for your help. Very much appreciated. I got it working, it was the target after all. I had to press and hold the reset while scanning and then attach and release the reset together. I wonder why the OpenOCD software on the PC is able to do the reset through software and not the OpenCD software on the BMP (I believe it is OCD server running on the BMP right?)


Rick Kimball
Mon Sep 25, 2017 12:46 pm
BMP implements a gdb remote server protocol server, as does openocd and the texanne st-util code. Here are some links that explain what GDB RSP is all about:
http://www.embecosm.com/appnotes/ean4/e … sue-2.html
http://neptune.billgatliff.com/debugger.html

Openocd and the Texanne code are desktop programs that provides a gdb proxy between a network socket (arm-none-eabi-gdb connects to the socket) and the stlink hardware connected via USB. Both programs talk directly to the USB interface of STLINK device using an ST proprietary API. They take the GDB RSP commands and turn them into USB commands that are handled by the STLINK device.

BMP provides access via the serial port on the “Not so good value” stm32f103 device. In this case, the arm-none-eabi-gdb connects to the serial port instead of a socket. The BMP firmware takes the GDB RSP commands and toggles the SWD_DIO/SWD_CLK pins on your “Not so good value” board to implement the SWD Protocol embedded on your target chip.

I’m wondering which board and upload options you have selected. Those choices affect how the swd/jtag pins are configured in libmaple. The define CONFIG_MAPLE_MINI_NO_DISABLE_DEBUG is what controls this and often gets in the way of smooth debugging. I’ve certainly got a target board in a mode where I could not debug it even using an stlink dongle. However you can always get access, even if you have disabled the pins, by setting the BOOT1 pin HIGH and pressing reset. That puts it into system boot mode, which does allow use of the SWD/JTAG pins.

The maple boards are configured to turn off the debug pins so all of the pins can be used. The generic boards, depending on how you compile, may or may not do the same thing. It depends on which uploads option you select when compiling.


Leave a Reply

Your email address will not be published. Required fields are marked *