Serial-only USB boot loader

Bootloader for boards that don't have the addition hardware found on the Maple mini, which resets the USB
jcw
Posts: 170
Joined: Mon Oct 26, 2015 8:16 am

Re: Serial-only USB boot loader

Postby jcw » Fri Nov 27, 2015 2:46 pm

Here's an update from the USB serial loader front.

The "usbserup" loader now resides at the end of flash memory. This means that the same sketches should run regardless of how they are uploaded (serial, usb serial, or BMP), because they can all be compiled the same way: loaded at the normal 0x08000000 flash base address.

There's some trickery involved to make this work, see https://github.com/jeelabs/embello/tree ... s/usbserup

The other piece of the puzzle is that you need a way to get usbserup installed properly. I've written a small sketch which does this, see https://github.com/jeelabs/embello/tree ... nstallboot - you can use whatever upload method you currently have at your disposal.

In a nutshell: with this version of usbserup, you can press RESET and upload your sketch over USB using the "serial" method.

This is far from done. Heck, it's almost untested, even. Having to press RESET is a step back w.r.t. the Maple loader, so there is no point using this boot loader if that works for you. Next on the list, is to allow triggering a reset via USB (I'm aiming for detection of the DTR-low edge, just as with AVR type Arduino boards).

Would love to hear from someone trying this out (please do keep in mind that usbserup will replace whatever boot loader you had!).

zmemw16
Posts: 979
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Serial-only USB boot loader

Postby zmemw16 » Fri Nov 27, 2015 5:52 pm

i can find one each of baite mini, red pill and blue pill, no pins fitted ie not soldered as yet.
also the same again, but soldered, contents unknown.
i also may have a couple of rbt/rct, vet and zet boards.

i normally use sw-link for programming

is blinky enough of a sketch or is there anything else needed as well?

what would be your expectations as to results?

stephen

jcw
Posts: 170
Joined: Mon Oct 26, 2015 8:16 am

Re: Serial-only USB boot loader

Postby jcw » Fri Nov 27, 2015 6:17 pm

Yes, blinky should be fine as test.

Please hold off a bit though - it's not quite working as I thought. Also, the current boot loader config is for a 128 KB flash, and since it lives "up there", flash size does matter for the current code & setup. Hm, I suppose I could just hardwire for 64 KB instead, then it'd work on both.

Thanks for the offer - I'll follow up as soon as things have a slightly better chance of actually working...

Result I'm hoping for: get through the install unharmed, press reset, upload from IDE over serial pointed at the USB port, blink!

jcw
Posts: 170
Joined: Mon Oct 26, 2015 8:16 am

Re: Serial-only USB boot loader

Postby jcw » Fri Nov 27, 2015 6:58 pm

Ok, the test should work the same for both 64K and 128K F103-MD's now (latest commit).

Something still bad. The protocol worked in low-flash, but now seems to fail:

Code: Select all

$ stm32loader.py -p /dev/cu.usbmodem421 -b 115200 -ew fader.bin
Reading data from fader.bin
Bootloader version 0x22
Chip id 0x410, STM32F1, performance, medium-density
Writing 6268 bytes to start address 0x8000000
Write 256 bytes at 0x8000000
    WRITE FAIL - try and recover
    WRITE FAIL - wait
    WRITE FAIL - retry
Traceback (most recent call last):

With stm32flash as well:

Code: Select all

$ stm32flash -g 0x8000000 -b 115200 -w fader.bin /dev/cu.usbmodem421
stm32flash Arduino_STM32_0.9

http://github.com/rogerclarkmelbourne/arduino_stm32

Using Parser : Raw BINARY
Interface serial_posix: 115200 8E1
Version      : 0x22
Option 1     : 0x00
Option 2     : 0x00
Device ID    : 0x0410 (Medium-density)
- RAM        : 20KiB  (512b reserved by bootloader)
- Flash      : 128KiB (sector size: 4x1024)
- Option RAM : 16b
- System RAM : 2KiB
Write to memory
Erasing memory
Failed to read ACK byte
Failed to write memory at address 0x08000000

Odd. The first few packet exchanges appear to be OK: boot version and chip info.

Looks like I'm going to have to fire up the logic analyser after all. Drat... was hoping to avoid this.

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

Re: Serial-only USB boot loader

Postby RogerClark » Fri Nov 27, 2015 7:54 pm

@jcw

We have found that all STM32F103C8 board have 128k flash memory even though they should only have 64k

So I think everyone should be able to test this.

However in the long term you would need to do a 64k version as well, in case STM changes their manufacturing processes and C8 devices become 64k

(BTW. GD32F103C8 is only 64k as it is a completely different device)


Return to “Generic bootloader”

Who is online

Users browsing this forum: No registered users and 1 guest