STM32F10x light HID driverless bootloader supporting HD devices

What are you developing?
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: STM32F10x light HID driverless bootloader supporting HD devices

Post by stevestrong »

TheKikGen wrote: Sun May 03, 2020 11:07 am My first approach was quite similar with HID, but you must first shutdown USB,...
That happens fast.
TheKikGen wrote: Sun May 03, 2020 11:07 am ... wait more or less 4 seconds
Nop. Why to wait?
In my approach I simply toggle the USB_DP line from 1->0->1. That is enough to signalize the host USB that a change occurred on the line.
The re-enumeration is performed within less than one second from both directions (user app-> bootloader -> user app).
For that the user app (core) should also have the same toggling method.
TheKikGen
Posts: 16
Joined: Tue Mar 03, 2020 11:13 am

Re: STM32F10x light HID driverless bootloader supporting HD devices

Post by TheKikGen »

Thanks Steve. I will give a try to that...

Other subject :
I have added a new "page offset" option in TKG-Flash CLI. This allows to flash a bin firmware file from any bootloader at the right address.
The stm32duino bootloader flash at FLASH BASE+ 0x2000, last version of HID bootloader flash at +0x800, older version of HID booloader flash at 0x1000, etc... When you need to upload a bin file compiled and linked to a specific address with a different bootloader, most of the time, you will recompile the firmware. Not this time maybe ?

With that "-o" option, you add some pages to the usual start page (@FLASH BASE + 0x1000 also for a 4k bootloader size) to match the bin file original address. The booloader will flash at the offset required, but will also write the MSP / Reset handler in its first "user" page, so the vector table will be valid.
Ex : myfirmware.bin was compiled to be uploaded with the stm32duino bootloader, at @FLASH BASE + 0x2000 but my bootloader flash at 0x1000.
With a medium density Bluepill, the page size is 0x400 bytes. So I need to offset (0x2000- 0x1000) / 0x400 pages=> 4 pages.

Code: Select all

$tkg-flash myfirmare.bin -o=4
Will do the adjustment, and will launch the firmware at the right address.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: STM32F10x light HID driverless bootloader supporting HD devices

Post by stevestrong »

Btw, how do you do the progress bar for upload?
It seems that Arduino IDE message window only shows all printf-s from the flasher std output in one piece after the whole upload is done.
Don't you have the same problem?
Do you know a way to force the message window to be updated after each printf ?
TheKikGen
Posts: 16
Joined: Tue Mar 03, 2020 11:13 am

Re: STM32F10x light HID driverless bootloader supporting HD devices

Post by TheKikGen »

Hi Steve. The IDE pseudo compilation console doesn't display correctly (as the IDE Terminal) most of C escape characters (e.g. \r).
So not possible to show a nice progression bar. The "-ide" option of tkg-flash shows consecutive characters on the same line instead.

Command line :

Code: Select all

+-----------------------------------------------------------------------+
|            TKG-Flash v2.3 STM32F103 HID Bootloader Flash Tool         |
|                     High density device support.                      |
|       (c) 2020 - The KikGen Labs     https://github.com/TheKikGen     |
+-----------------------------------------------------------------------+

> Firmware file size is 49796 bytes.
> Searching for [1209:BEBA] HID device...|
> [1209:BEBA] HID device found !
> Flashing firmware (SIMULATION) (INFO) :
  INFO - Informations reported by the MCU :
      Flash memory size  : 128 K (medium density device)
      Page size          : 1024 bytes 	
      Flash base address : 0x8001000

  [--------------------------------------------->       ]   50176 bytes sent.

> Firmware flashing done !
  49 sectors written (SIMULATION).
> End of firmware update.
in the IDE with the -ide option :

Code: Select all

$ ./tkg-flash umk-103c8-small-1000.bin -p=COM8 -sim -info  -ide
+-----------------------------------------------------------------------+
|            TKG-Flash v2.3 STM32F103 HID Bootloader Flash Tool         |
|                     High density device support.                      |
|       (c) 2020 - The KikGen Labs     https://github.com/TheKikGen     |
+-----------------------------------------------------------------------+

> Firmware file size is 49796 bytes.
> Searching for [1209:BEBA] HID device...|
> [1209:BEBA] HID device found !
> Flashing firmware (SIMULATION) (INFO) :
  INFO - Informations reported by the MCU :
      Flash memory size  : 128 K (medium density device)
      Page size          : 1024 bytes
      Flash base address : 0x8001000
      
-------------------------------------------------

> Firmware flashing done !
  49 sectors written (SIMULATION).
  50176 bytes sent.
> End of firmware update.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: STM32F10x light HID driverless bootloader supporting HD devices

Post by stevestrong »

Well, actually it is possible to display a progression bar, and \n is also shown correctly by Arduino IDE message window.

All I had to do is insert the line

Code: Select all

setbuf(stdout, NULL);
before the first printf() and it did the job (see viewtopic.php?p=2622#p2622).
TheKikGen
Posts: 16
Joined: Tue Mar 03, 2020 11:13 am

Re: STM32F10x light HID driverless bootloader supporting HD devices

Post by TheKikGen »

I already have this in my code. The \r is not usable at all.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: STM32F10x light HID driverless bootloader supporting HD devices

Post by stevestrong »

True, but why would you use \r at all?
TheKikGen
Posts: 16
Joined: Tue Mar 03, 2020 11:13 am

Re: STM32F10x light HID driverless bootloader supporting HD devices

Post by TheKikGen »

I use \r to animate the progression bar.

I just published the first release with binaries for Windows and Linux ready to use here :
https://github.com/TheKikGen/stm32-tkg- ... s/tag/V2.3

If anyone want to test it !
Post Reply

Return to “Projects”