STM32F103R In application Programming

Generic boards that are not Maple or Maple mini clones, and don't contain the additional USB reset hardware
SankarB
Posts: 12
Joined: Thu Oct 04, 2018 7:56 am

Re: STM32F103R In application Programming

Post by SankarB » Wed Jan 16, 2019 10:07 am

stevestrong wrote:
Wed Jan 16, 2019 10:03 am
As far as I understood, you actually want to write a "bootloader" which starts from 0x800000 (CPU reset address), reads code from SD card and writes this code to flash starting from 0x8001000, is this correct?
Yes You are right.

SankarB
Posts: 12
Joined: Thu Oct 04, 2018 7:56 am

Re: STM32F103R In application Programming

Post by SankarB » Wed Jan 16, 2019 1:25 pm

stevestrong wrote:
Wed Jan 16, 2019 10:03 am
Have a look in at the stm32duino bootloader, as an example, how a jump to user code can be implemented: https://github.com/rogerclarkmelbourne/ ... are.c#L201
After looking into this bootloader jump function I need to add this function to my existing core Arduino_STM32. Is that right?
or else have write my code only using that bootloader library?

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

Re: STM32F103R In application Programming

Post by stevestrong » Wed Jan 16, 2019 2:01 pm

The pointed bootloader loads code to be programmed to the flash over the USB interface (DFU protocol).
You could rewrite the whole bootloader code to take the program to be flashed from SD card instead of USB interface.
Or just take parts of interest from it and add them to your existing code.
You must figure out yourself what parts you need.

Your main problem will be to configure Arduino IDE to generate and store your new code (to be programmed) on the SD card.

User avatar
mrburnette
Posts: 3001
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: STM32F103R In application Programming

Post by mrburnette » Wed Jan 16, 2019 3:12 pm

SankarB wrote:
Wed Jan 16, 2019 10:07 am
stevestrong wrote:
Wed Jan 16, 2019 10:03 am
As far as I understood, you actually want to write a "bootloader" which starts from 0x800000 (CPU reset address), reads code from SD card and writes this code to flash starting from 0x8001000, is this correct?
Yes You are right.
Is this a "school project" because I'm having a difficult time understanding how this is a stm32duino issue?
Writing a bootloader to read SD, load memory, then boot the code is not a simple task, but it has been done
Before: https://www.google.com/search?q=read+SD ... bootloader

Ray

SankarB
Posts: 12
Joined: Thu Oct 04, 2018 7:56 am

Re: STM32F103R In application Programming

Post by SankarB » Thu Jan 17, 2019 5:18 am

stevestrong wrote:
Wed Jan 16, 2019 2:01 pm
The pointed bootloader loads code to be programmed to the flash over the USB interface (DFU protocol).
You could rewrite the whole bootloader code to take the program to be flashed from SD card instead of USB interface.
Or just take parts of interest from it and add them to your existing code.
You must figure out yourself what parts you need.

Your main problem will be to configure Arduino IDE to generate and store your new code (to be programmed) on the SD card.
Thank you stevestrong I'll try as you said.

SankarB
Posts: 12
Joined: Thu Oct 04, 2018 7:56 am

Re: STM32F103R In application Programming

Post by SankarB » Thu Jan 17, 2019 5:33 am

mrburnette wrote:
Wed Jan 16, 2019 3:12 pm
Is this a "school project" because I'm having a difficult time understanding how this is a stm32duino issue?
Writing a bootloader to read SD, load memory, then boot the code is not a simple task, but it has been done
Before: https://www.google.com/search?q=read+SD ... bootloader

Ray
Hello mrburnette,
I am going to implement FOTA. through FTP im going to send the .bin file, that could be stored in SD/external Flash. then by using this IAP (bootloader) Im going to write the code in controller flash.

Every time this bootloader have to check there is new .bin file available or not. If available it should replace new code in controller flash. I think you can understand now.
In the given link none of the bootloader+SD done for stm32duino, I think their core different from this.

User avatar
mrburnette
Posts: 3001
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: STM32F103R In application Programming

Post by mrburnette » Thu Jan 17, 2019 5:53 am

SankarB wrote:
Thu Jan 17, 2019 5:33 am
...
I am going to implement FOTA. through FTP im going to send the .bin file, that could be stored in SD/external Flash. then by using this IAP (bootloader) Im going to write the code in controller flash.

Every time this bootloader have to check there is new .bin file available or not. If available it should replace new code in controller flash. I think you can understand now.
In the given link none of the bootloader+SD done for stm32duino, I think their core different from this.
I'm very rarely respond to an inquiry with a specific implementation; rather, I like to think above the implementation and exercise my neurons at the more abstract. In any event, the links showed several attack vectors.

F(irmware)OTA via FTP of the binary is a lots of work when the WiFi IOT groupies have already implemented OTA for the Espressif ESP8266 & ESP32. But suit yourself.

If STM32F103 is a hard requirement, I'd toss the bootloader and use a second uC to stage BT (or WiFi) serial directly to the STM32 on silicon serial loader.

Here in Atlanta, $5 will get a Raspberry Pi Zero-W which is a full Linux implementation and eats Blue Pills for dessert.


Ray

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

Re: STM32F103R In application Programming

Post by RogerClark » Thu Jan 17, 2019 6:57 am

I agree with Ray

I have some STM32 boards which are connected to a Raspberry Pi, (Note. These are not boards I designed they are boards I use) and the design of the board connects boot0 and reset to GPIO's on the RPi, as well as Serial UART1

Firmware updates are done using the internal bootloader in the STM32F103, by the RPi driving Boot0 high then toggling the reset pin, before sending the firmware via serial at 56k bps. And its remarkably reliable.

The serial firmware update protocol is well documented by ST and there are open source implementations e.g. STM32Flash, which I suspect would be easier to port to and ESP8266 or ESP32 etc, than to have the complex process you describe of FTP to SD and then SD to firmware in the STM32

I would not use your method to do this.

SankarB
Posts: 12
Joined: Thu Oct 04, 2018 7:56 am

Re: STM32F103R In application Programming

Post by SankarB » Fri Jan 18, 2019 11:08 am

Thank you Ray & Roger
After looking your posts I want to change my application to Update the firmware using "2 MCU's+USARTx". could you provide any path, How to start regarding that.

User avatar
mrburnette
Posts: 3001
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: STM32F103R In application Programming

Post by mrburnette » Fri Jan 18, 2019 8:20 pm

SankarB wrote:
Fri Jan 18, 2019 11:08 am
Thank you Ray & Roger
After looking your posts I want to change my application to Update the firmware using "2 MCU's+USARTx". could you provide any path, How to start regarding that.
Surely, several approaches have appeared on n this forum in the past. Maybe this one will get you started:
http://stm32duinoforum.com/forum/viewtopic.php?t=3003

I found the above by using a site search on google:
esp8266 upload OTA site:stm32duinoforum.com/forum
Ray

Post Reply