Maple Mini pins mapping into SWD

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.


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
Thu Dec 08, 2016 10:04 am
OK, here’s the pin mapping.

D21 – PA14 – SWCLK
D22 – PA13 – SWDIO


michael_l
Thu Dec 08, 2016 8:52 pm
For some reason I can’t connect to my Maple Mini using BMP.

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


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


RogerClark
Thu Dec 08, 2016 10:06 pm
Sorry. I was logged in as admin when I posted the stuff above ;-)

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

mrburnette
Sun Dec 11, 2016 2:58 pm
? Would it not be better to create a variant for Maple Mini, Blue, and Red … The variants could just be titled Maple Mini (SWD), etc.

Done once and done forever. The WiKi can explain the mapping and any mumbo-jumbo manual steps…

Ray


RogerClark
Sun Dec 11, 2016 7:48 pm
i think the problem is many fold with board types

1. Very few of the boards have useful names or even model numbers on them
2. The IDE and boards menu is not well suited to multiple boards

We already have 14 variant folders, and some of these variants have 4 sub types, selected via the menus

I think people have to realise that sometimes they are in a very small minority, and they will need to customise their installation to match their specific needs.
Note. I often get requests to make changes which one person wants, but which would mess up thinks for 99% of users, e.g. someone wanted me to remove USB support by default ( for everyone) because it interfered with something they were doing ( I think they wanted to use the USB pins for GPIO and the code doesnt really support that)

So perhaps the solution is a wiki page describing how to change the settings in boards.txt


ahull
Sun Dec 11, 2016 9:03 pm
mrburnette wrote:The WiKi can explain the mapping and any mumbo-jumbo manual steps…

mrburnette
Mon Dec 12, 2016 1:40 am
RogerClark wrote:
<…>
I think people have to realise that sometimes they are in a very small minority, and they will need to customise their installation to match their specific needs.
<…>

RogerClark
Mon Dec 12, 2016 2:19 am
Hi Ray

Its nice to have your voice of sanity back on the forum ;-)


mrburnette
Mon Dec 12, 2016 2:30 am
RogerClark wrote:Hi Ray

Its nice to have your voice of sanity back on the forum ;-)


Leave a Reply

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