[SOLVED]Interesting problem

Post here all questions related to LibMaple core if you can't find a relevant section!
miki
Posts: 26
Joined: Mon Jan 27, 2020 3:39 pm

Re: Interesting problem

Post by miki »

Thanks for info.
About BOOT0.The problem is that, If I don't use BOOT0 pin I get refuse to connect with the target message.So no re-flashing would be possible.With BOOT0 high i connect and flash every time with STlink V2.I know that is used in serial uploading but It is used with SWD pins too.I am the living proof for that.If you have one home you can test that with blue pill.I think that info is on the net too somewhere.
User avatar
Bakisha
Posts: 140
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 5
Contact:

Re: Interesting problem

Post by Bakisha »

-Set BOOT0 to 1
-Power up your board
-Open "Flash Loader Demonstrator"
-click "Next" 3 times
-choose first option: "Erase All"
-click "Next"
-close "Flash Loader Demonstrator"
-disconnect power from your board
-set BOOT0 to 0
-connect st-link v2 to your board
-power up your board if you don't use 3.3V from st-link
-open "STM32 ST-LINK Utility"
-click "connect"

That should work 100%.

If you can't connect at this point, then check your board for shorts or open traces between pins SWDIO, SWCLK, 3.3V and GND . Check alos between pins and power lines.

If you can connect, click "disconnect", close "STM32 ST-LINK Utility", open Arduino IDE, choose st-link as upload method, compile your code and upload.
miki
Posts: 26
Joined: Mon Jan 27, 2020 3:39 pm

Re: Interesting problem

Post by miki »

Yes it works but after I flash the program this method don’t work anymore with stlink.i cannot change to serial back and forth every time i want flash the program.after I flash one time I cannot connect anymore with stlink without boot0 or reset pin.probably the program take swd pins as in use.but they are not.
fredbox
Posts: 125
Joined: Thu Dec 19, 2019 3:05 am
Answers: 2

Re: Interesting problem

Post by fredbox »

You might want to try the STM32 Cube programmer for your stlink.
Test setup - STLink connected to SWD and power pins on blue pill. Both boot jumpers = 0. USB not connected.

Code: Select all

./stm32CubeProg.sh 10 /tmp/arduino_build_151098/sketch_jan25a.ino.bin -s
      -------------------------------------------------------------------
                        STM32CubeProgrammer v2.1.0                  
      -------------------------------------------------------------------
ST-LINK SN  : 51FF69064983515048160987
ST-LINK FW  : V2J32S7
Voltage     : 3.29V
SWD freq    : 4000 KHz
Connect mode: Under Reset
Reset mode  : Hardware reset
Device ID   : 0x410
Device name : STM32F101/F102/F103 Medium-density
Flash size  : 64 KBytes
Device type : MCU
Device CPU  : Cortex-M3
Mass erase ... 
Mass erase successfully achieved
Memory Programming ...
Opening and parsing file: sketch_jan25a.ino.bin
  File          : sketch_jan25a.ino.bin
  Size          : 11088 Bytes
  Address       : 0x08000000 
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 10]
Download in Progress:
File download complete
Time elapsed during download operation: 00:00:01.262
RUNNING Program ... 
  Address:      : 0x8000000
Application is running
Start operation achieved successfully
I'm using Linux, but I expect the Windows version should operate mostly the same way.
fredbox
Posts: 125
Joined: Thu Dec 19, 2019 3:05 am
Answers: 2

Re: Interesting problem

Post by fredbox »

If using libmaple, you may need enableDebugPorts(). See https://github.com/rogerclarkmelbourne/ ... sh_debug.h
User avatar
Bakisha
Posts: 140
Joined: Fri Dec 20, 2019 6:50 pm
Answers: 5
Contact:

Re: Interesting problem

Post by Bakisha »

Well, your board works ok, it's software issue that you can't connect. Only way to make it work without software modification is to press "connect" in same time you power on your board (if possible).
Maybe, if you can, get blue pill dev board, so, untill you find solution, experiment on board that you can easy reset/set BOOT0.
ag123
Posts: 1656
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Interesting problem

Post by ag123 »

miki wrote: Tue Jan 28, 2020 8:44 pm Thanks for info.
About BOOT0.The problem is that, If I don't use BOOT0 pin I get refuse to connect with the target message.So no re-flashing would be possible.With BOOT0 high i connect and flash every time with STlink V2.I know that is used in serial uploading but It is used with SWD pins too.I am the living proof for that.If you have one home you can test that with blue pill.I think that info is on the net too somewhere.
like fredbox pointed up a couple of comments above, you need to

Code: Select all

enableDebugPorts()
if you are using the ide there is this macro CONFIG_MAPLE_MINI_NO_DISABLE_DEBUG, define that, build and install the firmware.
or you can simply call enableDebugPorts()

if you are using open ocd there is this method to define in the cfg file.

Code: Select all

# connect under reset
reset_config srst_only srst_nogate
with this you would either need to connect the reset pin from st-link v2 to the reset pin on the pill board or manually press reset while you attempt to connect. this would allow you go get around disabled debug ports when flashing the firmware.

if BOOT0 is set, it will always jump to the internal boot loader after reset, it will never run your sketch
and BOOT0 has nothing to do with SWD it is used by the internal rom to start the boot loader
uart boot loader works just as well as SWD as far as installing firmware is concerned
https://medium.com/@paramaggarwal/progr ... 3cec0dbc86
the only issue is for uart boot loader, it is necessary to set boot0 (normally setting the jumpers manually) if you want to get there from a reset
the common work around with usb-uart dongles is to use the dtr/rts signals for that purpose to control the boot0 pins and reset pins
that makes it easier as it isn't necessary to meddle with the boot0 jumpers and resets

if your sketch / firmware has a custom boot loader payload, one of those designs is to install that boot loader payload 'high' up in flash.
so that when you want to install new firmwire, the sketch can jump to the boot loader and you can implement your own protocol to flash the firmware at 0x8000000.
miki
Posts: 26
Joined: Mon Jan 27, 2020 3:39 pm

Re: Interesting problem

Post by miki »

Ahhh I may have an older version of the core?!
In my boards.txt

Code: Select all

genericSTM32F103C.menu.upload_method.serialMethod=Serial
genericSTM32F103C.menu.upload_method.serialMethod.upload.protocol=maple_serial
genericSTM32F103C.menu.upload_method.serialMethod.upload.tool=serial_upload

I thing stevestrong suggested something similar but I thought there is already in.
genericSTM32F103C.menu.upload_method.serialMethod.build.upload_flags=-DCONFIG_MAPLE_MINI_NO_DISABLE_DEBUG

Thanks I will test that.
miki
Posts: 26
Joined: Mon Jan 27, 2020 3:39 pm

Re: Interesting problem

Post by miki »

Tested with
enableDebugPorts();
Working like a charm.
Thank you guys.
Best community here.
miki
Posts: 26
Joined: Mon Jan 27, 2020 3:39 pm

Re: [SOLVED]Interesting problem

Post by miki »

Another issue,
While I can connect with STlink with
enableDebugPorts()
It is not very useful because I have JTAG pins in use while SWD pins are not used.
I tried
afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY); but I get "Cannot connect to the target" message.

Is there some work around, to use with STlink only with SWDIO pins
Post Reply

Return to “General discussion”