Is it possible to program Maple Mini with serial/FTDI?

343GuiltySpark
Tue Jul 24, 2018 8:47 pm
I’ve gotten a Maple Mini clone to program a sketch from Arduino using the mini-USB port after installing the 2.0-version bootloader and installing the drivers outlined by the “Installation” wiki page for STM32duino. However, my real goal is to program it using a serial method, whether using an FTDI USB-to-serial converter in 3.3v mode or an STlink/v2 clone in 4-wire SWD configuration.

When I try uploading a program in Arduino in either case, I get this message:
maple_loader v0.1
Resetting to bootloader via DTR pulse
Searching for DFU device [1EAF:0003]...
dfu-util - (C) 2007-2008 by OpenMoko Inc.
Couldn't find the DFU device: [1EAF:0003] This program is Free Software and has ABSOLUTELY NO WARRANTY


stevestrong
Tue Jul 24, 2018 8:51 pm
Read carefully: Upload via Serial
I think you forgot to select the corresponding upload method in Arduino IDE.

343GuiltySpark
Tue Jul 24, 2018 9:06 pm
@stevestrong, I did see that note in the Upload via Serial instructions but could not apply it as I didn’t see such an option in the Arduino IDE. I figured it was an old option that the programmer option “Arduino as ISP” would just take care of. See below:

Image

Image


Rick Kimball
Tue Jul 24, 2018 9:32 pm
The only way to upload on the maple mini is to use the Bootloader. Any other method will require you to use command line utilities. Also, those other methods will wipeout the bootloader, effectively bricking it as far as the Arduino IDE is concerned.

Do you really have a Maple Mini ? Please provide a link where you purchased this. The fact that you had to upload a bootloader indicates to me that you probably have a bluepill / red pill or / black pill.


343GuiltySpark
Wed Jul 25, 2018 12:54 pm
It’s a Maple Mini clone, so not brand-name but it is in fact not a blue pill. Here is the Amazon link for the Maple Mini clones I got. I also have an assortment of Blue Pill boards from various sources that I initially started working with, but after having no luck with them I deliberately opted for a Maple Mini to see if that would help alleviate the trouble I was having, which it did up to a point (I can program over USB, but not using other means). At one point I did manage to load code onto a blue pill using the FTDI converter, but the connection would cut itself more often than not and I was unable to consistently load programs. My end-goal is to load programs onto my own STM32 board, and using STM32duino seems like the most user-friendly solution for me since I have years of experience with Arduino IDE, so while I could add my own USB board and just mimic the Maple’s schematic, I’d rather understand if/how I can program using the RX/TX or SWDIO/SWCLK pins. I know the STM32 itself can be programmed that way, but I don’t enough enough bootloaders (particularly this specific bootloader) to know if that’s possible with the STM32duino bootloader.

Rick Kimball
Wed Jul 25, 2018 1:17 pm
I would suggest you leave the maple mini as it is sold and use it with the bootloader.

The Maple Mini is meant to be used with its preinstalled leaflabs/roger’s bootloader. To use a Maple Mini with the FTDI USB Serial and the ROM bootloader or an STLink SWD programmer requires you to hack up your boards.txt file for it to work. Alternatively you could completely avoid using the Arduino IDE and switch to something like Atollic TrueStudio.

I would suggest you focus on using the bluepill with SWD and FTDI Serial and avoid using the bootloader if your goal is to use an STlink.

The Bluepills are a much better choice if you want to use Serial or SWD. The Boot pins and SWD pins are readily accessible. The biggest stumbling block to using SWD with any board is usually caused when you load a bootloader. The bootloader compile turns on the “kill SWD JTAG debugging feature” which prevents you from using SWD after you have used the bootloader. You can get around this using the BOOT0 jumper which has issues on the Maple Mini (you need to make sure PB2/BOOT1 is grounded and isn’t floating.

There are many posts talking about SWD failure after loading a bootloader on this site.

viewtopic.php?t=27
viewtopic.php?f=28&t=3120
viewtopic.php?t=1620#p21450
viewtopic.php?f=37&t=1221&start=10


343GuiltySpark
Wed Jul 25, 2018 1:50 pm
Thanks for the explanation! That’s what I suspected but was also hoping wasn’t the case.

For kicks and giggles, I tried throwing code onto my second (untouched) Maple Mini clone without doing any bootloader shenanigans (just take out of packing bag, plug in via USB, and upload from Arduino) and was surprised to find it to program perfectly. Am I correct in understanding that this means the board was shipped with the bootloader already installed? I was not expecting that to be the case since it’s just a clone.

For the blue pills, would I need to make sure they have no bootloader on them in order to program code, then? I’m familiar with the use of boot0/boot1 pins to put the device into bootloader mode but haven’t had success with that when trying to program over Arduino IDE. I also am familiar with the Maple Mini (clone) issues with floating boot pins, so I made sure to tie potentially floating boot1 pin down to ground with a wire jumper but this didn’t change my scenario at all. The Arduino IDE still keeps looking for “1EAF:0003” and it seems like the only possible case I can get an STM32 to program with Arduino IDE is if I plug in a Maple Mini (clone) via USB port. I was previously under the impression that STM32duino could handle many more cases like the blue pill and such, but have had no success with that yet.

I did manage to get a blue pill to program using STM32CubeMX and Keil, but my objective to is to Arduino IDE so if I can get STM32duino to handle blue pills then I will be ecstatic!


Rick Kimball
Wed Jul 25, 2018 2:17 pm
[343GuiltySpark – Wed Jul 25, 2018 1:50 pm] –
Am I correct in understanding that this means the board was shipped with the bootloader already installed? I was not expecting that to be the case since it’s just a clone.

Yes, it wouldn’t be a maple mini if it didn’t have a bootloader.


stevestrong
Wed Jul 25, 2018 2:20 pm
Having a quick look into boards.txt you will figure out that the only upload method designed for MM is over DFU USB (USB bootloader, which yes, comes pre-flashed in the devices).

For blue pill there are 4 different upload methods available, including serial (using USB->serial adapter).


Rick Kimball
Wed Jul 25, 2018 2:31 pm
[343GuiltySpark – Wed Jul 25, 2018 1:50 pm] –
The Arduino IDE still keeps looking for “1EAF:0003” and it seems like the only possible case I can get an STM32 to program with Arduino IDE is if I plug in a Maple Mini (clone) via USB port. I was previously under the impression that STM32duino could handle many more cases like the blue pill and such, but have had no success with that yet.

When using the bluepill, you do select the proper board right?

Image


ag123
Wed Jul 25, 2018 3:58 pm
if your maple mini (clone?) has an existing bootloader pre-installed i.e. that you can install a sketch and they run

i’ve posted this thread “usb-serial dongle with maple mini or bluepill – for flashing bootloader” in code snippets section
viewtopic.php?f=18&t=2752

using the sketch i turn a maple mini (clone) into a usb-serial dongle and used that to flash a recent stm32duino bootloader into another maple mini (clone)
details in the thread

my thoughts are using serial/FTDI would be pretty similar to this
https://medium.com/@paramaggarwal/progr … 3cec0dbc86
it is mostly via various command line utilities than doing so within the arduino ide for this

the stm32duino bootloader or maple (mini) bootloader provides usb DFU as a sketch install means
and the arduino IDE uses that (DFU) (actually it uses the command line utility dfu-util during the sketch install on the pc)
that does away with a needing separate serial/FTDI or serial-usb device for sketch installs. i.e. you simply need the usb cable and maple mini (clone) with the bootloader installed to install a new sketch

;)


Rick Kimball
Wed Jul 25, 2018 4:49 pm
I have take exception to this:

[Rick Kimball – Wed Jul 25, 2018 2:31 pm] –
.. that does away with a needing separate serial/FTDI ..

There is the bootloader crowd and there is the stlink crowd. Each thinks they have the answer :)

I definitely fall into the no bootloader crowd. Give me a Serial dongle, an STLink device or best of all a Black Magic Probe. I find the bootloaders a constant source of pleas for help on this forum. It also doesn’t help that the default pull up resistor on the popular bluepill is wrong.

All I know is that you can’t do hardware level breakpoints using the bootloader. Although to be fair, you can’t do hardware debugging with an FTDI serial dongle either.

You will have a hard time using any other terminal program except the Arduino Serial Monitor with a board that is using the bootloader for its serial. Each time a board with a bootloader resets, it re-enumerates the USB connection. On linux, If a terminal program has the /dev/ttyACM0 open and you reset, linux will automatically assign it the next device number /dev/ttyACM1. You have to exit putty and connect to the new tty. In addition, unless you wait for the native usb serial to enumerate, you will often miss the initial Serial.print() statements. If you wait that means you must add your own time out code so the device actually runs without being connected to USB.

Your stated your goal was to build your own board. You have to decide how you are going to load programs.

If you use an FTDI serial dongle the user will have to mess with the Boot0 pin and the reset button to upload. However, you can make the loading seamlessly in Arduino if your USB dongle has DTR/RTS pins and you use those to toggle reset and boot0. Using this method, you can start with a bare chip and use the Serial method to upload. It will however require some hacking on the Serial upload script. A bonus for the bluepill crowd with this approach is that they don’t need to fix the pull up resistor. Although purchasing the RobotDyn board with the correct resistor is the best option. You can even get it pre with Roger’s bootloader if you want..

If you decide to use a bootloader, you will have to load it on there some way. You also lose 8k of flash to the bootloader. However once loaded, you can use it with the Arduino IDE and the core without any changes.

If you decide to use 2 stm32f103c8 chips on your board. One could be loaded with the Black Magic Probe software. That would provide a virtual terminal in addition to a hardware gdb server. You would be able to both debug and use FTDI style serial. This is also already baked into the Ardunio IDE and Roger’s core.

Another option with 2 stm32f103c8 chips is to load one chip with the CMIS-DAP firmware and on your host use openocd as the gdb proxy. This isn’t supported by the Arduino IDE however it is the approach used by many vendors, Atmel has a CMSIS-DAP programmer, as does NXP, Texas Instruments. You can find a bunch of ports to the STM32F103. Check this discussion: https://www.stm32duino.com/viewtopic.ph … =10#p13989

First you need to understand how all this works and that seems to be your biggest confusion keeping you from moving forward.


ag123
Wed Jul 25, 2018 5:18 pm
hi rick,

thanks, i think you have a point there. using a 3rd device e.g. st-link, serial-dongle (e.g. FTDI-serial), CMSIS-DAP has lots of advantages.
in particular using a proper SWD link would allow one to debug rather than simply ‘flashing’ firmware (sketches)

i’d guess many people who started with leaflabs maple (and today stm32duino) simply started with that
the arduino ide – dfu – bootloader – stm32f1

in a way leaflabs invented this framework and it become a de-facto ‘standard’
the beginners goofs with maple mini etc remains just that, many people stumble over it (and maple mini with the various tricks about the button presses to put it in ‘perpetual bootloader mode’, don’t literally help as many beginners struggle with the buttons as well literally. then for those who started with a blue pill, they run into the ‘chicken and egg’ problem of not having the bootloader pre-installed in the first place
this partially is the beginner’s learning curve and partially is that there is the ST’s own set of ‘framework’ e.g. the uart bootloader, etc and that leaflabs invented the ‘dfu bootloader’ on top of that, that to some extent would confuse beginners trying to learn the ropes getting into stm32
some of whom may even find needing a usb-serial (uart) dongle to install firmware a rather foreign concept for the uninitiated.

nevertheless leaflabs invented dfu – bootloader concepts has its technical merits. for one, it do a away with needing a separate device to upload firmware / install sketch. this is a big win in 2 ways:
1) it does away with a separate ‘firmware installer’ device (e.g. usb-uart dongle)
2) technically it makes maple mini, blue pill etc a *generic usb device* in which one could literally flash a firmware and change its role
the convenience of the bootloader do play a part in making this feasible

other than the black magic probe, i’m also trying to flash a CMSIS-DAP on a bp/mm, it seemed there are several implementations ‘out there’ on github. the benefit in this case is that Openocd works with CMSIS-DAP as a JTAG/SWD debugger. that’d to some extent play a similar role to the st-link dongle.

on another note, it would seem rather useful to hack an alternative usb-serial ( e.g. FTDI-uart ) setup for arduino ide e.g. in platform.txt, boards.txt , but it seem it may involve significant effort to rework as various addresses, ld-scripts, platform.txt, boards.txt etc may need to be patched or reworked edit: as suggested by rick one could edit boards.txt for the alternative upload methods / devices viewtopic.php?f=3&t=3907#p47549


Rick Kimball
Wed Jul 25, 2018 6:37 pm
[ag123 – Wed Jul 25, 2018 5:18 pm] –
nevertheless leaflabs invented dfu – bootloader concepts has its technical merits. for one, it do a away with needing a separate device to upload

DFU is a USB org thing from 2004
http://www.usb.org/developers/docs/devc … FU_1.1.pdf

ST has had hardware implemented DFU since at least 2009. Unfortunately, not in the stm32f103.
https://www.st.com/content/ccc/resource … 264379.pdf

STM32F0 Series:
– STM32F04xxx, STM32F07xxx
STM32F1 Series:
– STM32F105xx, STM32F107xx
STM32F2 Series
STM32F3 Series:
– STM32F301xx, STM32F302xx, STM32F303xB, STM32F303xC,
STM32F303xD, STM32F303xE, STM32F373xx
STM32F4 Series:
– STM32F401xx, STM32F405xx, STM32F407xx, STM32F411xx, STM32F412xx,
STM32F415xx, STM32F417xx, STM32F427xx, STM32F429xx, STM32F437xx,
STM32F439xx, STM32F446xx, STM32F469xx, STM32F479xx
STM32F7 Series:
– STM32F722xx, STM32F723xx, STM32F732xx, STM32F733xx, STM32F745xx,
STM32F746xx, STM32F756xx, STM32F765xx, STM32F767xx, STM32F769xx,
STM32F777xx, STM32F779xx
STM32L0 Series:
– STM32L07xxx, STM32L08xxx
STM32L1 Series:
– STM32L1xxxC, STM32L1xxxD, STM32L1xxxE
STM32L4 Series:
– STM32L431xx, STM32L432xx, STM32L433xx, STM32L442xx, STM32L443xx,
STM32L471xx, STM32L475xx, STM32L476xx, STM32L486xx, STM32L496xx,
STM32L4A6

Rick Kimball
Wed Jul 25, 2018 6:39 pm
[ag123 – Wed Jul 25, 2018 5:18 pm] –
on another note, it would seem rather useful to hack an alternative usb-serial ( e.g. FTDI-uart ) setup for arduino ide e.g. in platform.txt, boards.txt , but it seem it may involve significant effort to rework as various addresses, ld-scripts, platform.txt, boards.txt etc may need to be patched or reworked

Are you talking about for the Maple Mini? I provided a link earlier to my hack to use the Maple Mini with Serial as well as STLink and BMP.
http://stm32duino.com/viewtopic.php?t=1741

If you are talking about the BluePill (genericSTM32F103C) it already has Serial/STlink/BMP/Jlink


ag123
Thu Jul 26, 2018 6:54 am
[Rick Kimball – Wed Jul 25, 2018 6:37 pm] –

[ag123 – Wed Jul 25, 2018 5:18 pm] –
nevertheless leaflabs invented dfu – bootloader concepts has its technical merits. for one, it do a away with needing a separate device to upload

DFU is a USB org thing from 2004
http://www.usb.org/developers/docs/devc … FU_1.1.pdf

ST has had hardware implemented DFU since at least 2009. Unfortunately, not in the stm32f103.
https://www.st.com/content/ccc/resource … 264379.pdf

thanks rick, i should have qualified my statement, leaflabs is probably among the pioneers who designed an arduino sketch uploads using dfu on maple, maple mini. i’d think back then arduinos with atmega 328 and a separate ft232r for sketch uploads etc is a more common setup.

i’ve been using ST’s hardware implemented DFU on stm32f407 boards bought on ebay, they worked well with a slight inconvenience of needing to set the boot pins, and changing it again to boot the firmware. actually the use of the boot pins while inconvenient makes things more deterministic at run time, possibly giving less issues related to drivers on the host/pc side as compared to the implementation on maple (mini).

that inconvenience can be done away with if one use a SWD dongle (e.g. st-link) which would allow one to quickly re-program and reset the board each time without having to meddle with the boot pins.


flyboy74
Thu Jul 26, 2018 9:23 am
Since this thread has been a little hijacked from the original question. I will ask a related question.

When using Ardunio IDE serial.print() can output to a serial monitor in the Ardunio IDE via a serial to USB converter.

If using a DFU via USB can print be output to a console in the Ardunio IDE via the USB connection??

When using ST-Link in other IDEs you can output printf() to the IDE via the SWO/TD0 pin on the ST-Link, can you output print to Ardunio IDE via the ST-Link??


stevestrong
Thu Jul 26, 2018 9:58 am
[flyboy74 – Thu Jul 26, 2018 9:23 am] –
If using a DFU via USB can print be output to a console in the Ardunio IDE via the USB connection??

Of course, using Roger’s (libmaple) core, if you define the USB serial, Serial.print goes to Arduino serial monitor. Serial1 goes to USART1.

[flyboy74 – Thu Jul 26, 2018 9:23 am] –
When using ST-Link in other IDEs you can output printf() to the IDE via the SWO/TD0 pin on the ST-Link, can you output print to Ardunio IDE via the ST-Link??

Which other IDE you mean? I see no difference between IDEs when it comes to monitoring the serial port.
Are you talking about STLink V2.1? Because STLink V2.0 does not support this.


flyboy74
Thu Jul 26, 2018 10:27 am
Are you talking about STLink V2.1? Because STLink V2.0 does not support this.

I have only used the STLink V2.1.

The Cheap aluminum ST-Links don’t have the SWO pin connected but there is hacks out there on the net that show how to add the extra wire. The larger white plastic st-links that are a clone of ones made by ST do have the SWO pin broken out. It makes use the ITM http://infocenter.arm.com/help/index.js … CCDFD.html to output to SWO (serial wire output).

As far as I am aware this is the most common way of printing debug info to a console with keil, IAR and eclipse IDEs as most people using these IDEs are flashing via ST-Link.


ag123
Thu Jul 26, 2018 12:33 pm
serial.print() is implemented via the usb-serial component driver in the core. hence, the messages goes back to the host pc via usb-serial (Communications Device Class) protocol.
http://www.usb.org/developers/docs/devclass_docs/
currently DFU only runs in the bootloader at the beginning and the feature implemented is basically to install a sketch
http://www.usb.org/developers/docs/devc … FU_1.1.pdf
when the sketch runs, actually only usb-serial is the main communication channel to the host pc hence basically usb-serial is available.

i did a google search and stumbled into this thread
PrintF via SWO
viewtopic.php?t=1448

i’m not too sure if this is already part of the core (one can browse the codes), but i’d guess if one add the codes to handle SWO, you may be able to use SWO for printf to the host.
i think SWO is part of the JTAG/SWD standard and things like ST-link, JTAG/SWD dongles,CMSIS-DAP based jtag/swd dongles with SWO support can be used with that.
but on the host side you would need an app that can talk to the JTAG/SWD dongle, e.g. OpenOCD, and this normally is separate and not part of the Arduino IDE.


Leave a Reply

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