Maple Mini pins mapping into SWD

Maple Mini, Maple Rev3, Maple Rev 5 and Maple Ret 6, iTead Maple etc
michael_l
Posts: 337
Joined: Mon Aug 24, 2015 6:11 pm

Maple Mini pins mapping into SWD

Post by michael_l » Thu Dec 08, 2016 8:55 am

I came across this discussion on leaflabs site: http://forums.leaflabs.com/forums.leafl ... l?id=74300

Would it be possible to change pin mapping so that pins available in the headers would be changed into SWD pins. So it would be possible to do debugging via SWD pins on Maple Mini and that would be kind of awesome. Thanks.

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

Re: Maple Mini pins mapping into SWD

Post by RogerClark » Thu Dec 08, 2016 9:04 am

SWD pins are disabled on the Maple mini to make them usable for GPIO

If we enable them as SWD we loose them as GPIO.

But you can change the settings in boards.txt for your local installation

e.g.
Look at line 207

genericSTM32F103C.menu.upload_method.STLinkMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 -DSERIAL_USB -DGENERIC_BOOTLOADER


You could add that define to your maple mini build

michael_l
Posts: 337
Joined: Mon Aug 24, 2015 6:11 pm

Re: Maple Mini pins mapping into SWD

Post by michael_l » Thu Dec 08, 2016 10:04 am

OK, here's the pin mapping.

D21 - PA14 - SWCLK
D22 - PA13 - SWDIO

michael_l
Posts: 337
Joined: Mon Aug 24, 2015 6:11 pm

Re: Maple Mini pins mapping into SWD

Post by michael_l » Thu Dec 08, 2016 8:52 pm

For some reason I can't connect to my Maple Mini using BMP.

Code: Select all

(gdb)arm-none-eabi-gdb.exe -b 115200
GNU gdb (GNU Tools for ARM Embedded Processors) 7.6.0.20140731-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-w64-mingw32 --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) target extended-remote  \\.\COM25
Remote debugging using \\.\COM25
(gdb) monitor swdp_scan
Target voltage: Not Implemented!
SW-DP scan failed!
(gdb)
I did the change in boards.txt and I can see from Arduino IDE's verbose output that -DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG=1 gets applied for g++ and gcc compiler. I'm using pins 21,22 on the Maple Mini for SWD and PA4, PA5 in bluepill.

I'm powering both from USB, is that OK ? they should get common ground at least.

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

Re: Maple Mini pins mapping into SWD

Post by RogerClark » Thu Dec 08, 2016 8:57 pm

SWD pins will be disabled by your current sketch (if you let it run)

Just lock it in its internal bootloader mode, by pressing and holding the "Button" and press and release Reset

After you upload 1 sketch using BMP you will not need to do that again, as the sketch will no longer disable the SWD Pins

michael_l
Posts: 337
Joined: Mon Aug 24, 2015 6:11 pm

Re: Maple Mini pins mapping into SWD

Post by michael_l » Thu Dec 08, 2016 9:18 pm

Sorry, I don't understand :)

So I did the change you said and could see that g++/gcc got the new flag to enable SWD pins. When that sketch is uploaded and run shouldn't the SWD be enabled in pins 21,22 ?

EDIT: I think I got it now what you meant :) Are SWD pins (21,22) always enabled in 'Internal Bootloader' mode ?

admin
Site Admin
Posts: 11
Joined: Mon Apr 27, 2015 4:15 am

Re: Maple Mini pins mapping into SWD

Post by admin » Thu Dec 08, 2016 9:44 pm

Bootloader doesnt touch those pins but the sketch code does

If you upload a sketch via the bootloader, the sketch compile options cause the init code in the core to disable the SWD pins so that they are usable as GPIO

So. Normally this problem comes about when people upload a sketch via the bootloader then try to upload via STLInk or BMP, in which case as the sketch will be running a few secs after the board is powered up, the pins will be disabled, so you won't be able to upload

Hence, just for the first STLInk or BMP upload, the easiest option is to put the MCU into its own internal (hardware) serial bootloader by pulling Boot0 high as in this mode SWD is also enabled.

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

Re: Maple Mini pins mapping into SWD

Post by RogerClark » Thu Dec 08, 2016 10:06 pm

Sorry. I was logged in as admin when I posted the stuff above ;-)

michael_l
Posts: 337
Joined: Mon Aug 24, 2015 6:11 pm

Re: Maple Mini pins mapping into SWD

Post by michael_l » Thu Dec 08, 2016 10:45 pm

Yeah, I saw that :)

Ok, I got it working but only if I power mini from e.g Vin pin. If I power it from USB then it doesn't work. Seems strange? Well I tried that in a bit of a hurry so I'll have to verify that later.

michael_l
Posts: 337
Joined: Mon Aug 24, 2015 6:11 pm

Re: Maple Mini pins mapping into SWD

Post by michael_l » Fri Dec 09, 2016 8:35 am

Just tried.. debugging does not seem to work if I power mini from USB - when I powered mini from Vin pin BMP found it.

Post Reply