[COMPLETED] Combining Blink & Count to the bootloader

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

[COMPLETED] Combining Blink & Count to the bootloader

Post by RogerClark » Mon Jun 19, 2017 1:52 am

[Update by admin]

This proposal has now been made to the bootloader, except the sketch does not blink as this would require a different sketch binary for every bootloader / board. So instead it prints a message to Serial






Guys

A problem that we get over and over again, is people expecting to get the Serial device when they first load the bootloader
I don't propose to add even a fake serial device to the bootloader, as composite devices are problematic on Windows.

But, combining a Blink & Count sketch to the bootloader binary, so that when new users load the bootloader, the board appears and has a com port that the IDE can see, seems like a possible solution to this.

I did consider adding some other form of demo sketch to the bootloader, but it would need to be purely text based, or just involve blinking or fading the LED.


Does anyone have any thoughts on this one.

Also... I don't know an easy way of merging binaries or hex files. I have a tool called mergehex (from Nordic Semi) but it doesn't seem to work for this (possibly it only works on specific address ranges)

User avatar
zoomx
Posts: 525
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Combining Blink & Count to the bootloader

Post by zoomx » Mon Jun 19, 2017 6:06 am

An hex editor maybe?

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

Re: Combining Blink & Count to the bootloader

Post by RogerClark » Mon Jun 19, 2017 7:18 am

I can do it using the Jlink JFlash tool as it has a merge feature but its a pain to do it manually for all the files.

I will try again to see if I can make Nordic's MergeHex utility work

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: Combining Blink & Count to the bootloader

Post by danieleff » Mon Jun 19, 2017 7:54 am

But isn't it just appending one to the other? I know you use Windows, but:

Code: Select all

cat bootloader.bin > bootloader_plus_blink.bin
truncate -s8192 bootloader_plus_blink.bin
cat blink.bin >> bootloader_plus_blink.bin

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

Re: Combining Blink & Count to the bootloader

Post by stevestrong » Mon Jun 19, 2017 9:15 am

I am using HxD: https://mh-nexus.de/en/hxd/
It supports, among many interesting features, splitting or concatenating of files, too.

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

Re: Combining Blink & Count to the bootloader

Post by RogerClark » Mon Jun 19, 2017 10:35 am

danieleff wrote:
Mon Jun 19, 2017 7:54 am
But isn't it just appending one to the other? I know you use Windows, but:

Code: Select all

cat bootloader.bin > bootloader_plus_blink.bin
truncate -s8192 bootloader_plus_blink.bin
cat blink.bin >> bootloader_plus_blink.bin

Does that work.

The bootloader bin size is not 8192 it is smaller, and is likely to change if we modify it.

Also the sketch bin file does not have 0x00 in the first 0x2000 bytes.

I think its going to be easier for me to just write a windows command line tool to do this using fread and fwrite

All I need to know is the size of the Blink bin

So in pseudo code

Code: Select all

Open Blink
get size of blink binary
Malloc size of blink binary + 0x2000
Read blink into 0x2000
read bootloader in 0x0000
Write whole of malloced area to disk

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

Re: Combining Blink & Count to the bootloader

Post by RogerClark » Mon Jun 19, 2017 10:36 am

stevestrong wrote:
Mon Jun 19, 2017 9:15 am
I am using HxD: https://mh-nexus.de/en/hxd/
It supports, among many interesting features, splitting or concatenating of files, too.
Thanks

I was hoping to find something which I could run from a windows bat file

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: Combining Blink & Count to the bootloader

Post by danieleff » Mon Jun 19, 2017 10:39 am

RogerClark wrote:
Mon Jun 19, 2017 10:35 am
danieleff wrote:
Mon Jun 19, 2017 7:54 am
But isn't it just appending one to the other? I know you use Windows, but:

Code: Select all

cat bootloader.bin > bootloader_plus_blink.bin
truncate -s8192 bootloader_plus_blink.bin
cat blink.bin >> bootloader_plus_blink.bin
Does that work.

The bootloader bin size is not 8192 it is smaller, and is likely to change if we modify it.
`truncate -s8192 bootloader_plus_blink.bin` extends the file to be 8192 bytes. I guess there is similar in windows, maybe in powershell, or some util file.

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

Re: Combining Blink & Count to the bootloader

Post by RogerClark » Mon Jun 19, 2017 10:41 am

danieleff wrote:
Mon Jun 19, 2017 10:39 am
RogerClark wrote:
Mon Jun 19, 2017 10:35 am
danieleff wrote:
Mon Jun 19, 2017 7:54 am
But isn't it just appending one to the other? I know you use Windows, but:

Code: Select all

cat bootloader.bin > bootloader_plus_blink.bin
truncate -s8192 bootloader_plus_blink.bin
cat blink.bin >> bootloader_plus_blink.bin
Does that work.

The bootloader bin size is not 8192 it is smaller, and is likely to change if we modify it.
`truncate -s8192 bootloader_plus_blink.bin` extends the file to be 8192 bytes. I guess there is similar in windows, maybe in powershell, or some util file.

Ah OK
Thanks

I'll see if windows powershell has this

Edit.

No. It does not have that command.

I'm going to write a windows command line tool.

It should be easy, I have CodeBlocks installed. I also have MS Visual Studio but it tends to include loads of extra libs that are a problem e.g. MS VC libs just for simple exe's

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

Re: Combining Blink & Count to the bootloader

Post by stevestrong » Mon Jun 19, 2017 11:42 am

For your orientation, here is a command line hex editor, with source code:
https://sourceforge.net/projects/hexciting/

Post Reply