Spark Logic

what if we make a custom programmer for STM32 using an AVR arduino?

STM32F103C8T6 LQFP48 Pinout

I’m sure many of you thought it before, but I didnt see it posted (yet i have to read the community board thread, it may have been posted there as suggestion).

Well, Arduinos can be used to program other arduinos when you load the right firmware, you can even find firmwares to program other devices (in example, the “JTag whisperer” project uses an arduino as XSVF player to program some xilinx devices).

With the same idea in mind, but (I think) less complicated than emulating a jtag, we could program a generic STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog board without messing with the boot jumpers or the reset button (that could be managed by the firmware in the AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog arduino) and making use of hardware you might have already.

If I get it correctly, when you compile the sketch and load it to an AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog arduino with onboard USB to TTL chip (a simple com port for the SO), a control signal is triggered on that chip, allowing to reset the MCU and OR put it in program mode (not sure if only reset and the bootloader works with timing or other signal is involved). So, there should be an usable flag in the upload script to diferentiate between normal serial comunication and programming.

If the firmware on the AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog arduino can detect and use that flag to tie Boot0 to high and then send a short pulse to reset to make the STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog enter in the program mode using the embedded serial bootloader, upload the program using simple serial communication, ans when the upload finish turn back Boot0 to low and send another short pulse to reset to put the STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog back in normal operation mode.

That way we would not mess with changing jumpers, reseting the MCU, or attaching/detaching the programmer. Is really annoying to have to do that things when we only correct little pieces of code and want to try fast the result.

The main advantages might be:

  1. dont have to mess with Boot jumpers
  2. dont have to mess with the reset button
  3. use hardware you might already have
  4. dont have to detach/attach the programmer after each upload

Disvantages:

  1. need voltage level adaptation
  2. capable of only basic debug using the same serial
  3. may need other power source for the MCU at least for operation mode

For me it looks well even with the disvantages. Maybe someone with the stlink v2 (clone or not) can help me to make a comparison table between the 3 options, as for now I only have accesss to try the USB to serial TLL.

Replies14

Tue May 05, 2015 8:46 pm

When you use an stlink programmer you get all those benefits.

Tue May 05, 2015 9:31 pm

Ok, Rick was faster, this was also my first thought: ST-LINKST-LINKModules, instruments and finished devices…ot add the serial usb device… suspect flashing failed…. Do I need to debrick it with st-link ? (which I don’t have lol) BennehBoy Mon Jan 23, 2017 8:11 pm NM managed to rescue it…View in hardware catalog clones are about 3 USD, so there is no need for soldering something.

Tue May 05, 2015 10:47 pm

Rick Kimball wrote:When you use an stlink programmer you get all those benefits.

Tue May 05, 2015 10:56 pm

Luc_Exe wrote:Is that only with an original STLink or applicable to the chinese STLink V2 clones?

Tue May 05, 2015 11:06 pm

Rick Kimball wrote:
You don’t actually power the device with the stlink device. The vcc pin on the programmer is an input to the stlink device so it knows what voltage you are providing to your board. I just leave the usb cable plugged into my STM32F103C8T6STM32F103C8T6Microcontrollers and processors…e Sep 27, 2016 10:28 pm I know this is an old topic, but… I’m using blue pill board ( STM32F103C8T6 , version 3). With the current (modified) Adafruit library 0.96″ OLED display w…View in hardware catalog to power it.

Tue May 05, 2015 11:20 pm

ahull wrote:I’m not sure you are correct, on my ST-LINKST-LINKModules, instruments and finished devices…ot add the serial usb device… suspect flashing failed…. Do I need to debrick it with st-link ? (which I don’t have lol) BennehBoy Mon Jan 23, 2017 8:11 pm NM managed to rescue it…View in hardware catalog V2 clone, I can power my STM32F103CXXX board from the 3v3 line. I actually disconnect the 3v3 line when I have the board connected to the USB port just in case. There may be different versions of the programmer with different pinouts, so check on the particular version you have to see if the 3v3 and 5v pins are putting out those voltages or not.

Thu May 07, 2015 1:13 am

Guys,

I’m not sure about SWD, but I took a quick look at just writing a sketch using Software Serial to pass through the data to the board

unfortunately it doesn’t seem to work.

But I still think Serial is best option

I have seen code for SWD, but things then get a whole load more complicated, as the host PC needs some form of protocol that communicates with the AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog Arduino

Mon Dec 21, 2015 5:26 pm

U don’t need voltage shifter because of 5V – tolerant pins of JTAg SWD And Serial (more FT at documentation of ur STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog )

Mon Dec 21, 2015 8:59 pm

Good point about those pins being 5V tollerent.

Interestingly UART 1 is 5V tollerent but UART 2 is not.

But as this uses UART 1, it should be fine using a Uno which has been held in reset.

I must try it some time.

Tue Dec 22, 2015 7:38 am

RogerClark wrote:

I have seen code for SWD, but things then get a whole load more complicated, as the host PC needs some form of protocol that communicates with the AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog Arduino

Tue Dec 22, 2015 8:45 pm

@stevech

This thread is about using an AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog Arduino as a programmer.

Its not about using an STLink

Wed Dec 23, 2015 12:46 am

Since there exists a $20 ST-LINKST-LINKModules, instruments and finished devices…ot add the serial usb device… suspect flashing failed…. Do I need to debrick it with st-link ? (which I don’t have lol) BennehBoy Mon Jan 23, 2017 8:11 pm NM managed to rescue it…View in hardware catalog , what’s the benefit of a DIY AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog microprocessor-as-programmer?
Must be something I can learn from such a goal!

Wed Dec 23, 2015 1:01 am

stevech wrote:Since there exists a $20 ST-LINKST-LINKModules, instruments and finished devices…ot add the serial usb device… suspect flashing failed…. Do I need to debrick it with st-link ? (which I don’t have lol) BennehBoy Mon Jan 23, 2017 8:11 pm NM managed to rescue it…View in hardware catalog , what’s the benefit of a DIY AVRAVRMicrocontrollers and processors…Arduino\libraries\U8glib\U8glib.cpp, C:\Program Files (x86)\Arduino\hardware\arduino\ avr \cores\arduino\HardwareSerial.h, C:\Program Files (x86)\Arduino/Blink3.ino, D:\Users\me\A…View in hardware catalog microprocessor-as-programmer?
Must be something I can learn from such a goal!

Wed Dec 23, 2015 5:02 am

I guess its for people who have a STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog board but forgot to get a USB to serial and can’t easily / quickly get hold of one.

Post a reply

Optional · up to 10 MiB