STM32F103C8T6 need help with drivers

STM32duino bootloader aka Maple bootloader
User avatar
RogerClark
Posts: 6669
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: STM32F103C8T6 need help with drivers

Post by RogerClark » Thu Nov 10, 2016 12:06 am

petronel wrote:Probably I was expecting Download from and Upload to .. it makes more sense to me.

I have 2 other questions now:

1. After a sketch is uploaded and the STM32 is resetting, the Serial connection drop for a second, and I have to close/open the Serial Monitor. Is that normal ?

2. Uploading a sketch that compile ok but crash when running (like my test with RFID) make the DFU / com disappear and getting again "Unknown device". I can still reset the STM32 and upload an working sketch.
1. Yes this is normal. The Bootloader only does uploading it doesnt handle the Serial USB (thats handled inside the sketch binary)

2. If you crash the sketch it will crash the USB serial, (see item 1)

petronel
Posts: 17
Joined: Mon Aug 22, 2016 12:21 pm

Re: STM32F103C8T6 need help with drivers

Post by petronel » Thu Nov 10, 2016 12:31 am

Is there any way to figure out what is crashing my sketch ?

Trying to use the RFID RC522 with my STM32F103.

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

Re: STM32F103C8T6 need help with drivers

Post by RogerClark » Thu Nov 10, 2016 12:49 am

If you have SWD debugger hardware you can get GDB to tell you where its crashed, otherwise you'll need to just need to add code in line by line and keep trying things, and see which think you add in or which function you call that makes it crash.

petronel
Posts: 17
Joined: Mon Aug 22, 2016 12:21 pm

Re: STM32F103C8T6 need help with drivers

Post by petronel » Thu Nov 10, 2016 6:41 am

I don't have a SWD debugger. Maybe I should get one. Any recommendations?

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

Re: STM32F103C8T6 need help with drivers

Post by RogerClark » Thu Nov 10, 2016 8:35 am

You can make one from another Blue Pill, by Flashing the Blackmagic probe to it (see the Blackmagic probe thread)

You can also get STLink clones really cheaply, but I think you'd need to use OpenOCD to use them

Either way, using GDB from the command line takes a bit of getting used to.

Otherwise you'd need to use Eclipse + the Arduino plugin, to get a nice UI for debugging.

Its probably easier just to comment out code and use Serial.print to work out whats going wrong

racemaniac
Posts: 432
Joined: Sat Nov 07, 2015 9:09 am

Re: STM32F103C8T6 need help with drivers

Post by racemaniac » Thu Nov 10, 2016 9:19 am

RogerClark wrote:You can make one from another Blue Pill, by Flashing the Blackmagic probe to it (see the Blackmagic probe thread)

You can also get STLink clones really cheaply, but I think you'd need to use OpenOCD to use them

Either way, using GDB from the command line takes a bit of getting used to.

Otherwise you'd need to use Eclipse + the Arduino plugin, to get a nice UI for debugging.

Its probably easier just to comment out code and use Serial.print to work out whats going wrong
I recently made a Black magic probe, and was wondering: isn't it time to consolidate the info about it on a wiki page?
There is the blackmagic probe thread, but for the nrf51822 you published some other binaries on your github with extra support, are those better than what can be found in the thread on this forum? Also you had bin files for a maple mini, a bluepill (and also a generic version i think?)
And the st link part was also annoying >_<. I had an st link with outdated firmware, so figuring out how to get it up to date, and which tool i had to use to get the black magic probe file loaded on my maple mini also took some time >_<.

petronel
Posts: 17
Joined: Mon Aug 22, 2016 12:21 pm

Re: STM32F103C8T6 need help with drivers

Post by petronel » Thu Nov 10, 2016 9:40 am

RogerClark wrote: Its probably easier just to comment out code and use Serial.print to work out whats going wrong
This is what I'm doing.
It seems that my sketch crash at

Code: Select all

	SPI.beginTransaction(SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0));	// Set the settings to work with SPI bus
What could be the problem there? SPI_CLOCK_DIV4 ?
How we tell STM32 to use either SPI1 or SPI2 ?

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

Re: STM32F103C8T6 need help with drivers

Post by RogerClark » Thu Nov 10, 2016 9:45 am

@racemaniac

I think the master Blackmagic probe repo now has good support for the nRF51 but I think when Rick took his original fork of the BMP the nRF51 support was minimal

Although I still have my modified fork of the BMP based on Ricks fork + my changes for nRF51, I'm now trying to migrate back to the official master repo by Blacksphere as its loads of commits and bug fixes ahead of my fork (and also ahead of Ricks fork)

The problem is that I can't simply merge from the Blacksphere master as the API structure of the "platform" code has changed.

So my long term plan is to remake Rick's version for the BluePill and send a PR to add it to the Blacksphere master repo

However, I've been too busy recently with the official STM32 core, and also some urgent commercial work that I had to get to grips with.

We could add a wiki page for the current state of play, mainly linking to Rick's repo for use on the STM32, we can always update it when I finally get around to re-making the BluePill platform version etc

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

Re: STM32F103C8T6 need help with drivers

Post by RogerClark » Thu Nov 10, 2016 9:49 am

petronel wrote:
RogerClark wrote: Its probably easier just to comment out code and use Serial.print to work out whats going wrong
This is what I'm doing.
It seems that my sketch crash at

Code: Select all

	SPI.beginTransaction(SPISettings(SPI_CLOCK_DIV4, MSBFIRST, SPI_MODE0));	// Set the settings to work with SPI bus
What could be the problem there? SPI_CLOCK_DIV4 ?
How we tell STM32 to use either SPI1 or SPI2 ?
Divider wont be the issue, its not likely to make the code crash

Re: SPI1 and SPI2

By default the SPI object is SPI1, but we added a function called setModule(int spiChannelNumber)

So you can call spi.setModule(2) , so that the SPI object now uses the STM32's SPI channel 2 (and its SPI2 pins etc)

You can of course instantiate another instance of SPI eg. SPIClass SPI2(2);

But its wasteful as SPI sill exists in ram so thats only useful if you want to run SPI1 and SPI2

And the problem is most libraries are not written to handle more than one SPI, but setModule() gets around this.

stevestrong
Posts: 1501
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: STM32F103C8T6 need help with drivers

Post by stevestrong » Thu Nov 10, 2016 1:19 pm

@petronel,
where is the SPI.beginTransaction() called? Within the MFRC522::PCD_Init()? I cannot see where. Or do you call it separately?

Did you set the appropriate mode for all the used pins?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest