Creating a Bootloader for generic boards

STM32duino bootloader aka Maple bootloader
User avatar
RogerClark
Posts: 6694
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Creating a Bootloader for generic boards

Post by RogerClark » Tue Oct 25, 2016 6:05 am

Old GCC ARM are available, but really if there is a bug it should be fixed.

I just don't have time to do this at the moment, especially as there is no pressing need to do this, unless its impossible to download gcc 4.8.3 (which I think will be available for a few years yet)

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

Re: Creating a Bootloader for generic boards

Post by stevestrong » Tue Oct 25, 2016 8:43 am

Anyone tried the 5.1.x or 4.9.y GCC using optimize "-O2" to see if it generates good code?

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

Re: Creating a Bootloader for generic boards

Post by RogerClark » Tue Oct 25, 2016 9:25 am

No. But I'll give it a try.

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

Re: Creating a Bootloader for generic boards

Post by RogerClark » Tue Oct 25, 2016 10:29 am

No.

-O2 with 4.9.3 doesnt work

It does initially enumerate as a LibUSB device, but it wont upload.

If I reset it just as the IDE is about to upload, then it does upload, but doesn'r seem to jump to the sketch code

Also, the code size using -O2 is 500 bytes more. This would be OK if it works, as we have almost 1k free, but since it doesnt work, there is no point in using this option, and the code really needs to be debugged to find the issue (probably vars or registers need to be as volatile

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

Re: Creating a Bootloader for generic boards

Post by stevestrong » Tue Oct 25, 2016 12:07 pm

Just an idea...
Would it be possible to compile the "usb_lib" sources into a LIB with 4.8.3 and then use this pre-compiled lib with the other sources to generate a new bootloader code with 4.9.x (or newer)?
This way one could determine whether the new compiler caused bug is in the LIB or other code parts.

P.S. Now that I was lately involved in the usb core related issue, I can see a couple of places where one could optimize/improve the code.

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

Re: Creating a Bootloader for generic boards

Post by RogerClark » Tue Oct 25, 2016 8:23 pm

Running 2 different versions of compiler in the same makefile would make it a lot more complex, as you would need to specify paths to each of them

Really, the solution is just to fix the bug.


BTW.

As 4.9.3 breaks the bootloader, I suspect it cold break a lot if other code, e.g. sketches and possibly parts of the Core etc

I tried upgrading my main Arduino compiler to 5.x ( as part of some nRF51 stuff I was doing) but I recall the core would not even compile.

I suspect Arduino.cc would possibly have similar problems with their Arduino ARM boards, so they may not want to update the compiler either

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

Re: Creating a Bootloader for generic boards

Post by RogerClark » Tue Oct 25, 2016 10:13 pm

One other thought.

The LibUSB that the bootloader uses, is dated 2008.

I know there are more recent versions of this, which may have bug fixes, but I've not found a complete set of libusb files for the STM32F103

Perhaps someone knows where there is a copy of the files that I could download and try ?

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

Re: Creating a Bootloader for generic boards

Post by stevestrong » Wed Oct 26, 2016 1:08 pm

I think in this package there is a DFU class device library, dated November 2015.
I don't know how complete it is.

EDIT
I also found here FS device lib 4.0.0 which is the closest to the bootloader core files. I did a quick compare, beside typedefs there are minor changes, which I don't know how they can influence the functionality.
And, btw, they still don't have the little endian stuff in their code, dated January 2013.

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

Re: Creating a Bootloader for generic boards

Post by RogerClark » Thu Nov 10, 2016 11:28 pm

The issue has now been fixed by Philippe LUC

However the new code seems to have a delay between upload and jumping to the user code which I wasnt originally aware of, so still needs some slight modificaton


BTW.

Can anyone remember who wrote a modified version of the bootloader which used NVRAM to determine whether the bootloader was being started in response to an upload command from the IDE or booted from cold ?

I think it would be good to implement this change into the bootloader, but I can't remember who wrote it (I'll check the forks in case someone forked and modified it)

jrie
Posts: 1
Joined: Thu Jan 12, 2017 1:21 am

clean fix for -Os build with GCC 4.9(+)

Post by jrie » Thu Jan 12, 2017 1:26 am


Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests