Author Topic: The preenfm bootloader and how to flash it  (Read 5341 times)

solipsvs

  • Team Member
  • ***
  • Posts: 222
    • View Profile
The preenfm bootloader and how to flash it
« 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
« Last Edit: November 04, 2020, 09:29:03 AM by Xavier »

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2257
    • View Profile
Re: Flash bootloader
« Reply #1 on: November 04, 2020, 09:27:58 AM »
Stm32 (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 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:
  • Short the Boot0 Jumper on the PCB and turn on the preenfm. (Don't forget to unshort ot once flash is finished).
  • if you already have a preenfm bootloader then there is an option to jump to the system one.
This will put your STM32 into DFU mode.

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

  • downloading a zip file from the release folder and use the *.cmd file from the zip.
    Or download this zip which contains detailed explanation in its README.
  • download a dfu file from the release folder and flash it using DfuSe as explained here.
    The Dfu file contains both preenfm bootloader and the preenfm firmware with the adress where to flash them.
    So it shoud be an easier solution. But it has been reported that it often shows an empty list of available device, seems to be a win32 STM driver problem.
    Please let me know here if that's the case.

External links :

preenfm2 binaries
preenfm2 flash information

preenfm3 binaries
preenfm3 flash information

Need help ? post here  :)

Xavier
« Last Edit: November 04, 2020, 09:50:42 PM by Xavier »

solipsvs

  • Team Member
  • ***
  • Posts: 222
    • View Profile
Re: The preenfm bootloader and how to flash it
« Reply #2 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?

solipsvs

  • Team Member
  • ***
  • Posts: 222
    • View Profile
Re: The preenfm bootloader and how to flash it
« Reply #3 on: November 04, 2020, 06:54:40 PM »
my win10 device doesnt find it.  my win7 laptop found it.  trying a flash now

solipsvs

  • Team Member
  • ***
  • Posts: 222
    • View Profile
Re: The preenfm bootloader and how to flash it
« Reply #4 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.

solipsvs

  • Team Member
  • ***
  • Posts: 222
    • View Profile
Re: The preenfm bootloader and how to flash it
« Reply #5 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.

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2257
    • View Profile
Re: The preenfm bootloader and how to flash it
« Reply #6 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.

solipsvs

  • Team Member
  • ***
  • Posts: 222
    • View Profile
Re: The preenfm bootloader and how to flash it
« Reply #7 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?

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2257
    • View Profile
Re: The preenfm bootloader and how to flash it
« Reply #8 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.

  • Click Connect button : select "STM32 Bootloader"
  • Then select the first interface of the list "DFU: cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg"
  • Keep default values and go to "Firmware Download". Click "Choose file" and select your "p2_boot_1.13.bin" from your computer.
  • Verify your screen with the attached screenshot.
  • Click Download

Once finished reboot while holding down a key.
You should see "- Bootloader 1.13 -" at the top of the preenfm2 screen.
« Last Edit: November 05, 2020, 04:42:38 PM by Xavier »

solipsvs

  • Team Member
  • ***
  • Posts: 222
    • View Profile
Re: The preenfm bootloader and how to flash it
« Reply #9 on: November 07, 2020, 03:17:41 AM »
there is no "STM32 Bootloader" in the list. (on win7)
« Last Edit: November 07, 2020, 04:52:40 AM by solipsvs »

solipsvs

  • Team Member
  • ***
  • Posts: 222
    • View Profile
Re: The preenfm bootloader and how to flash it
« Reply #10 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!
« Last Edit: November 07, 2020, 05:15:49 AM by solipsvs »

solipsvs

  • Team Member
  • ***
  • Posts: 222
    • View Profile
Re: The preenfm bootloader and how to flash it
« Reply #11 on: November 07, 2020, 05:23:17 AM »
also flashed my other r6 and the screen works and everything now

Xavier

  • Administrator
  • Hero Member
  • *
  • Posts: 2257
    • View Profile
Re: The preenfm bootloader and how to flash it
« Reply #12 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.