preenfm Forum

PreenFM => preenfm2 and preenfm3 => Topic started by: solipsvs on November 04, 2020, 12:30:43 AM

Title: The preenfm bootloader and how to flash it
Post by: solipsvs on November 04, 2020, 12:30:43 AM
Xavier's note

Split from an other thread.
Try to use this thread if you have any questions realated to flashing the bootloader

Original message

ok i took thumb drive out again and put p2_boot_1.13.bin in the pfm2 folder, booted into flash mode, flashed and it now says it has bootloader 1.12 installed and still wont allow usb access to thumb drive.

i realize i flashed bootloader to os so i reflashed 2.20
Title: Re: Flash bootloader
Post by: Xavier on November 04, 2020, 09:27:58 AM
Stm32  (https://www.st.com/en/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus.html)(preenfm MCU) flash memory starts at 0x8000000.

This is where the preenfm bootloader is installed.
It's executed first, then jumps to the firmware (flashed at 0x8040000) if no button is pressed.

The preenfm2 bootloader that you access while pressing a key at startup can only flash to 0x8040000.
So it cannot flash itself.

To flash the preenfm bootloader you have to use the system bootloader (https://www.st.com/resource/en/application_note/cd00167594-stm32-microcontroller-system-memory-boot-mode-stmicroelectronics.pdf) integrated into the STM32.
This other bootloader allows you to flash any binary at any adresss (It doesn't have any UI as it does not know anything about the preenfm2 hardware).
It can be run using one of the 2 following methods:
This will put your STM32 into DFU mode (http://wiki.openmoko.org/wiki/USB_DFU_-_The_USB_Device_Firmware_Upgrade_standard).

In dfu mode, you have many solutions/tools to flash any binaries to any adressses :
2 of them are :


External links :

preenfm2 binaries (https://github.com/Ixox/preenfm2/releases)
preenfm2 flash information (https://github.com/Ixox/preenfm2/tree/master/flash)

preenfm3 binaries (https://github.com/Ixox/preenfm3/releases)
preenfm3 flash information (https://github.com/Ixox/preenfm3/wiki/Flash)

Need help ? post here  :)

Xavier
Title: Re: The preenfm bootloader and how to flash it
Post by: solipsvs on November 04, 2020, 06:40:50 PM
right.  so, wouldnt you know it, its not working for me. pfm2 doesnt even show in available dfu devices.  what now?  i bought this pre assembled so i wouldnt need to go through this.  also the cmd file in the zip doesnt do anything.  how do i even know anything is happening on the pfm2with no lights or screen?
Title: Re: The preenfm bootloader and how to flash it
Post by: solipsvs on November 04, 2020, 06:54:40 PM
my win10 device doesnt find it.  my win7 laptop found it.  trying a flash now
Title: Re: The preenfm bootloader and how to flash it
Post by: solipsvs on November 04, 2020, 07:02:56 PM
ok...  is there supposed to be a dfu file in the release?  there isnt one, only cmd and bin files.
Title: Re: The preenfm bootloader and how to flash it
Post by: solipsvs on November 04, 2020, 07:11:15 PM
so as much as my dumb ass can figure, there is supposed to be a dfu file for 1.13 on github but i sure cant find it.  bro, please provide the necessary files so i can attempt this simple operation once again.
Title: Re: The preenfm bootloader and how to flash it
Post by: Xavier on November 04, 2020, 09:07:06 PM

OK, i've just added the pfm2_2_20.dfu
with bootlodaer 1.13 and firmware 2.20

https://github.com/Ixox/preenfm2/releases/tag/2.20
Let me know whether it works, i cannot try it tonight.
Title: Re: The preenfm bootloader and how to flash it
Post by: solipsvs on November 04, 2020, 10:34:32 PM
so should the bootloader show 1.12 when complete?  it took only 1.5 seconds to flash the dfu file.  is this normal?
Title: Re: The preenfm bootloader and how to flash it
Post by: Xavier on November 05, 2020, 09:03:43 AM
so should the bootloader show 1.12 when complete?  it took only 1.5 seconds to flash the dfu file.  is this normal?

No that's not normal.
It should take something like 1 minute with the progress bar slowly moving.
I could try this morning the 2.20 dfu file and it works fine.

I searched the Web and many people have DfuSe not working.
Windows and USB drivers can be a real pain.

Here is an other solution if the DFU item dees not show in DfuSe
I think it will work on computer that does not see any device in DfuSe list.

Use Chrome and follow this link :
https://devanlai.github.io/webdfu/dfu-util/

When your preenfm2 is in DFU mode and plugged to your compuer throught USB.


Once finished reboot while holding down a key.
You should see "- Bootloader 1.13 -" at the top of the preenfm2 screen.
Title: Re: The preenfm bootloader and how to flash it
Post by: solipsvs on November 07, 2020, 03:17:41 AM
there is no "STM32 Bootloader" in the list. (on win7)
Title: Re: The preenfm bootloader and how to flash it
Post by: solipsvs on November 07, 2020, 04:51:04 AM
ok its working on win 10.

i got bootloader 1.13 on and then wrote to the internal thumb drive then flashed from bootloader.  its working.  thanks!
Title: Re: The preenfm bootloader and how to flash it
Post by: solipsvs on November 07, 2020, 05:23:17 AM
also flashed my other r6 and the screen works and everything now
Title: Re: The preenfm bootloader and how to flash it
Post by: Xavier on November 07, 2020, 07:13:33 AM
ok its working on win 10.
i got bootloader 1.13 on and then wrote to the internal thumb drive then flashed from bootloader.  its working.  thanks!

Great news!

also flashed my other r6 and the screen works and everything now

Awesome...
Thanks for the update.