Using the CORE with OR without BOOTLOADER: problems

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
mauriziostm32
Posts: 23
Joined: Sat Mar 21, 2020 3:18 pm
Answers: 1

Using the CORE with OR without BOOTLOADER: problems

Post by mauriziostm32 »

Hi Guys

Maybe there are some problems using Roger's CORE if not in conjunction with the USB bootloader?
(https://github.com/rogerclarkmelbourne/Arduino_STM32) I use Arduino IDE 1.8.5

Here is my problem: simple code
in the SETUP pinmode (PB4, INPUT_PULLDOWN)

digital.Read(PB4)

It works if I upload the sketch by USB bootloader... BUT

when I get rid of the bootloader and I use the ST-LINK V2 dongle, it doesn't work...
digital.Read(PB4) is always high... and in fact PB4 output 3.3 V

Is there some configuration of the GPIO registers in the bootloader that the core doesn't take care of ?
I tried on different Bluepills and Blackpills …

if I use normal INPUT and external resistor it works also without bootloader...
------------------------------

Ok let me try with another pin, PB5...

well it works with and without bootloader :shock: :shock: :shock:

Usually I use external Pull-up or down resistor, but now I want to save some space an components...

Is there a known reason why some pins they work without bootloader and others don't?

Thanks
by stevestrong » Fri Apr 03, 2020 10:07 am
mauriziostm32 wrote: Fri Apr 03, 2020 10:00 am Normally PA15 - PB3 - PB4 are reserved for SWD debug (ST-LINK...)
No, they are used by JTAG interface, SWD only needs PA13/14.
mauriziostm32 wrote: Fri Apr 03, 2020 10:00 am So if I want to keep using the ST-LINK I have 2 solutions: change pins... or give a try to the STM32 STM official core...

Is that right?
No.
As I wrote, you can call

Code: Select all

enableDebugPorts();
in you setup, this will free up PA15, PB3,4 as being used for debug, as they are only relevant for JTAG, but not for SWD. This function will enable only the SWD port, so those pins will be freed up.
Eventually, it may be needed to use this sequence:

Code: Select all

disableDebugPorts(); // disable all debug pins to be used for debug. All debug pins are free to be used as IO
enableDebugPorts(); // this enables the SWD interface only: PA13,14 reserved for SWD, PA15, PB3,4 can be used as IO
Go to full post
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Using the CORE with OR without BOOTLOADER: problems

Post by stevestrong »

Short answer:
include early in your setup

Code: Select all

enableDebugPorts();
Long info:
check this: https://github.com/rogerclarkmelbourne/ ... t-38078911
mauriziostm32
Posts: 23
Joined: Sat Mar 21, 2020 3:18 pm
Answers: 1

Re: Using the CORE with OR without BOOTLOADER: problems

Post by mauriziostm32 »

stevestrong wrote: Fri Apr 03, 2020 8:03 am Short answer:
include early in your setup

Code: Select all

enableDebugPorts();
Long info:
check this: https://github.com/rogerclarkmelbourne/ ... t-38078911

Hi Steve

Thanks for the fast answer, I think I understood, but to be sure I summarize:

Normally PA15 - PB3 - PB4 are reserved for SWD debug (ST-LINK...) . Happens that these pins work with the bootloader because Roger disabled the SWD on these pins when the upload method is DFU (usb bootloader) , make sense.. you are using USB...

I suppose I cannot disable SWD debug when the upload method is ST-LINK … doing this the stlink won't be able to upload... right?

So if I want to keep using the ST-LINK I have 2 solutions: change pins... or give a try to the STM32 STM official core...

Is that right?


Thanks

Maurizio
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Using the CORE with OR without BOOTLOADER: problems

Post by stevestrong »

mauriziostm32 wrote: Fri Apr 03, 2020 10:00 am Normally PA15 - PB3 - PB4 are reserved for SWD debug (ST-LINK...)
No, they are used by JTAG interface, SWD only needs PA13/14.
mauriziostm32 wrote: Fri Apr 03, 2020 10:00 am So if I want to keep using the ST-LINK I have 2 solutions: change pins... or give a try to the STM32 STM official core...

Is that right?
No.
As I wrote, you can call

Code: Select all

enableDebugPorts();
in you setup, this will free up PA15, PB3,4 as being used for debug, as they are only relevant for JTAG, but not for SWD. This function will enable only the SWD port, so those pins will be freed up.
Eventually, it may be needed to use this sequence:

Code: Select all

disableDebugPorts(); // disable all debug pins to be used for debug. All debug pins are free to be used as IO
enableDebugPorts(); // this enables the SWD interface only: PA13,14 reserved for SWD, PA15, PB3,4 can be used as IO
mauriziostm32
Posts: 23
Joined: Sat Mar 21, 2020 3:18 pm
Answers: 1

Re: Using the CORE with OR without BOOTLOADER: problems

Post by mauriziostm32 »

Hi Steve


;) Ok it seems to work. Thanks

But I have 2 different results depending if I upload the code on a bluepill or on my circuit based on an stm32f103c8t6
this sequence enable the pins to work … and further uploads are successful on the bluepill...

Code: Select all

disableDebugPorts(); 
delay(100);
enableDebugPorts();  


on my circuit this sequence enable the pins to work, but the target after this is no longer visible to the STLINK...so I cannot upload anymore... I need to make some bridges to put boot0 and boot1 to 3.3 , in this way the board is visible to st-link, then I erase the chip with ST-LINK utility

But if I use only

Code: Select all

 enableDebugPorts();  
all work in my circuit: the pins are working… and further uploads are successful...

In the BluePills I'm just testing PULL_UP and DOWN on those pins... while in my circuit many things are happening simultaneously uart2, SPI and I2c are running to read a sensor sending info to another Micro and displaying value on an LCD

I don't want to investigate the magic behind... I'm not a super expert, so as long as it is working... Steve solved. I go on with the project

Thanks Steve
Post Reply

Return to “General discussion”