Setup of STM32F103CBT6 (Maple Mini) board

Generic boards that are not Maple or Maple mini clones, and don't contain the additional USB reset hardware
victor_pv
Posts: 1270
Joined: Mon Apr 27, 2015 12:12 pm

Re: Setup of STM32F103CBT6 (Maple Mini) board

Post by victor_pv » Mon Jan 23, 2017 12:37 am

Phil333 wrote:So I will set write protection for page 0-15 (1K each = 16K).

EDIT:

So I have done that and flashed the original bootloader to it.
I verified its is the original one by flashing the Arduino blink example to it an chose the original bootloader.

I uploaded the sketch of you @viktor but only get this massege again:
**************************************************************************************************
*** This sketch will update the bootloader in the Maple Mini to the STM32duino bootloader ****
*** With this you can use up to 120KB of Flash and 20KB of RAM for a Sketch ****
*** Uploading is also considerably faster on OSX (and possibly faster on Linux) ****
*** ****
*** Only use with Maple mini boards ****
*** ****
*** WARNING. If the update fails your Maple mini may not have a functional bootloder. ****
*** ****
*** YOU UPDATE AT YOUR OWN RISK ****
*** ****
*** ****
*** ****
*** ****
**************************************************************************************************
*** ****
*** ****
*** To confirm and proceed, enter Y ****
*** ****
*** ****

*** WARNING, Update Failed!! It is possible that the flash memory is Write-protected. ****
*** ****
*** We can try clearing the option bytes. ****
*** After that, you will need to do a reset and try again ****
*** ****
**************************************************************************************************
*** ****
*** ****
*** To confirm and proceed, enter Y, to cancel power down now. ****
*** ****
*** The option bytes have been cleared, reboot now and try to update again ****

If I now just reset the board via its button, I cant communicate with it via the serial monitor.
If I unplug and replug the device completely, then I can communicate but it starts from the same point and gives the same messages via the serial monitor...
Phil, this time it's working every time. I have tested setting write protection a few times and updating, and works as expected. In the first pass will fail, and give the option to clear the option bytes. After accepting that, it clears write protection without setting read protection, which is what was failing before.

If you don't mind, could you test it in a maple mini, since I only had an RCT board to test it on?

Phil333
Posts: 23
Joined: Mon Jan 16, 2017 3:26 pm

Re: Setup of STM32F103CBT6 (Maple Mini) board

Post by Phil333 » Mon Jan 23, 2017 7:05 am

This gave me

Code: Select all

**************************************************************************************************
*** This sketch will update the bootloader in the Maple Mini to the STM32duino bootloader     ****
*** With this you can use up to 120KB of Flash and 20KB of RAM for a Sketch                   ****
*** Uploading is also considerably faster on OSX (and possibly faster on Linux)               ****
***                                                                                           ****
***                      Only use with Maple mini boards                                      ****
***                                                                                           ****
*** WARNING. If the update fails your Maple mini may not have a functional bootloder.         ****
***                                                                                           ****
***                            YOU UPDATE AT YOUR OWN RISK                                    ****
***                                                                                           ****
***                                                                                           ****
***                                                                                           ****
***                                                                                           ****
**************************************************************************************************
***                                                                                           ****
***                                                                                           ****
***                         To confirm and proceed, enter Y                                   ****
***                                                                                           ****
***                                                                                           ****

***      WARNING, Update Failed!! It is possible that the flash memory is Write-protected.    ****
***                                                                                           ****
***      We can try clearing the option bytes.                                                ****
***      After that, you will need to do a reset and try again.                               ****
***      If it still can not update after Read Protection may be enabled.                     ****
***                                                                                           ****
**************************************************************************************************
***                                                                                           ****
***                                                                                           ****
***              To confirm and proceed, enter Y, to cancel power down now.                   ****
***                                                                                           ****
After this nothing happens.
The board is also not able to be upload another sketch to it or to communicate with.

I get this error from the Arduino IDE:

Code: Select all

maple_loader v0.1
Resetting to bootloader via DTR pulse
Reset via USB Serial Failed! Did you select the right serial port?
Searching for DFU device [1EAF:0003]...
Assuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...

dfu-util - (C) 2007-2008 by OpenMoko Inc.
Couldn't find the DFU device: [1EAF:0003]
This program is Free Software and has ABSOLUTELY NO WARRANTY
What should I do now?
Reflash the original bootloader via the STM-Tool, set write protection again and wait for your next ideas @viktor ?
:D

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

Re: Setup of STM32F103CBT6 (Maple Mini) board

Post by RogerClark » Mon Jan 23, 2017 10:16 pm

Sounds like the entire flash has been read protected.

You have no option but to erase and reflash using a USB to Serial adaptor or a STLink.

The vendor must have bought a blank Maple Mini and flashed and read protected it. (Strange thing to do)

I notice that the aliexpress listing is "no longer available"


@victor

Can the updater check for read protection ?

It seems a bit odd that it was initially possible to upload the updater sketch, but impossible now to overwrite it.

Perhaps the STM32 knows whether a flash page is blank and allows one upload even if read protection is set.
But that sounds like a bit security loophole, as you could upload code to read out the flash into a blank flash page, and then somehow trick the code into running that code.

On a similar subject.
The nRF51 has a bug in its silicon, which allows some GDB functions to work on read protected devices.
In that you can still read and set the contents of registers including the PC.

So you can change the PC and get the code in flash to run any part of the flash, and people have exploited this loophole to find and single step instructions to and managed to read the contents of the protected flash.

I briefly looked at this, but the STM32 does not seem to have that bug.
So I'd be surprised if you could flash a blank page if the device is read protected

Phil333
Posts: 23
Joined: Mon Jan 16, 2017 3:26 pm

Re: Setup of STM32F103CBT6 (Maple Mini) board

Post by Phil333 » Tue Jan 24, 2017 6:58 am

Well as I had set the write protection on page 0-15 and had seen, that there was no read protection on any page.

I will now go to flash the bootloader 2.0 via the STM-Tool again as viktor seems busy now ;)

victor_pv
Posts: 1270
Joined: Mon Apr 27, 2015 12:12 pm

Re: Setup of STM32F103CBT6 (Maple Mini) board

Post by victor_pv » Tue Jan 24, 2017 5:16 pm

Phil333 wrote:Well as I had set the write protection on page 0-15 and had seen, that there was no read protection on any page.

I will now go to flash the bootloader 2.0 via the STM-Tool again as viktor seems busy now ;)
Phil, after you load the original bootloader, then set write protection to pages 0-15 (no read protection), and then you try to update with the loader sketch, that's when the board stop responding, is that right?

Also, you downloaded the whole sketch from page 2, correct? this last time I did a few more changes, added some defines, etc.

@Roger, it is possible to check whether read or write protection are enabled.

There are several possible cause of errors:
1.- Write protection enabled, read protection disabled: The sketch will try to clear write protection, and in the next reboot should update. It works in my RCT board, but fails on Phil's mini.
2.- Read protection enabled, write protection disabled: bootloader update fails, I suspect because it can not read back to verify the writes. Clearing read protection would wipe the flash, so we can't do it unless we run the sketch from RAM, but I think the flash is actually cleared on reboot afterwards, so the bootloader would still be wiped.
3.- Read protection enabled, write protection enabled: The uploader will clear the write protection, but will not touch the read protection cause that would wipe the flash, same as point 2.

Currently the sketch checks if read protection is enabled, in which case it leaves it enabled to not clear the flash. We could print in serial if it finds Read protection enabled and advice to use the serial bootloader in that case.

Phil333
Posts: 23
Joined: Mon Jan 16, 2017 3:26 pm

Re: Setup of STM32F103CBT6 (Maple Mini) board

Post by Phil333 » Wed Jan 25, 2017 8:53 am

victor_pv wrote:
Phil333 wrote:Well as I had set the write protection on page 0-15 and had seen, that there was no read protection on any page.

I will now go to flash the bootloader 2.0 via the STM-Tool again as viktor seems busy now ;)
Phil, after you load the original bootloader, then set write protection to pages 0-15 (no read protection), and then you try to update with the loader sketch, that's when the board stop responding, is that right?

Also, you downloaded the whole sketch from page 2, correct? this last time I did a few more changes, added some defines, etc.
That is right!
Yes it was the latest sketch from page 2 as I wrote my last post.

I will reflash the original bootloader, set write protection again (and a gain no read protection) fro pages 0-15 and try your sketch from page 2 again to verify it.

EDIT: @viktor have you changed anything in your sketch of page 2 since my last post?
It is working now.

I also made a video of the whole process.

Video 1:
Set the default protection and original bootloader

Video 2:
Unlock write protection and flash bootloader v2.0

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

Re: Setup of STM32F103CBT6 (Maple Mini) board

Post by stevestrong » Wed Jan 25, 2017 9:51 am

This info should be recorded in wiki.

User avatar
BennehBoy
Posts: 418
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Setup of STM32F103CBT6 (Maple Mini) board

Post by BennehBoy » Wed Jan 25, 2017 1:50 pm

stevestrong wrote:This info should be recorded in wiki.
What wiki? On the github? Linky?
-------------------------------------
https://github.com/BennehBoy

victor_pv
Posts: 1270
Joined: Mon Apr 27, 2015 12:12 pm

Re: Setup of STM32F103CBT6 (Maple Mini) board

Post by victor_pv » Wed Jan 25, 2017 2:22 pm

Phil333 wrote:
victor_pv wrote:
Phil333 wrote:Well as I had set the write protection on page 0-15 and had seen, that there was no read protection on any page.

I will now go to flash the bootloader 2.0 via the STM-Tool again as viktor seems busy now ;)
Phil, after you load the original bootloader, then set write protection to pages 0-15 (no read protection), and then you try to update with the loader sketch, that's when the board stop responding, is that right?

Also, you downloaded the whole sketch from page 2, correct? this last time I did a few more changes, added some defines, etc.
That is right!
Yes it was the latest sketch from page 2 as I wrote my last post.

I will reflash the original bootloader, set write protection again (and a gain no read protection) fro pages 0-15 and try your sketch from page 2 again to verify it.

EDIT: @viktor have you changed anything in your sketch of page 2 since my last post?
It is working now.

I also made a video of the whole process.

Video 1:
Set the default protection and original bootloader

Video 2:
Unlock write protection and flash bootloader v2.0
I originally posted it exactly as I use it in my RCT board, and that MCU uses a 2KB flash page size, while the CBT in the maple mini has a 1KB flash page size. I corrected it like 1 or 2 hours later when I remembered of that, so it's possible you copied right before I corrected it.
Sorry for the confusion, I thought I had corrected it before you had a chance to run it.

User avatar
ahull
Posts: 1518
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: Setup of STM32F103CBT6 (Maple Mini) board

Post by ahull » Wed Jan 25, 2017 3:53 pm

BennehBoy wrote:
stevestrong wrote:This info should be recorded in wiki.
What wiki? On the github? Linky?
===> http://wiki.stm32duino.com/index.php?title=Main_Page <=== This Wiki
- Andy Hull -

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest