VS Arduino
Visual Micro >> Microchip Studio (Atmel Studio 7) >> <project>.with_bootloader.hex: bad file format
https://www.visualmicro.com/forums/YaBB.pl?num=1538351737

Message started by Martin Boissonneault on Sep 30th, 2018 at 11:55pm

Title: <project>.with_bootloader.hex: bad file format
Post by Martin Boissonneault on Sep 30th, 2018 at 11:55pm
Hi!
  I'm using an Adafruit Metro M0 Express, and the file <project>.with_bootloader.hex generated is just wrong. The first part is the project in normal Intel .hex format, but it looks like the end of the file is the bootloader in binary format. Of course, the result is a bad file.

  It's not a big problem for me, I can manually combine my bootloader with the good <project>.hex and use that instead, but is it a bug with Visual Micro?

Martin

Attached: The zipped BlinkWithoutDelay.with_bootloader.hex and the bootloader in both .bin and .hex.
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=BlinkWithoutDelay_with_bootloader_hex.zip ( 17 KB | 1 Download )
https://www.visualmicro.com/forums/YaBB.pl?action=downloadfile;file=bootloader-metro_m0-v2_0_0-adafruit_5.zip ( 15 KB | 1 Download )

Title: Re: <project>.with_bootloader.hex: bad file format
Post by Visual Micro on Oct 1st, 2018 at 4:22pm
Thanks for the post. It's an interesting issue that you might be able to help with.

The arduino ide does not produce a merged hex for the M0 Express so Visual Micro should not be attempting to create the file.

The checks as far as I can see boil down to the board having a bootloader.file=. In this case the bootloader.file= points to a file that is not a conventional bootloader. Therefore I guess this is why the arduino ide doesn't bother to produce any result.

Can you please shed any light on this issue. What do you do to create the file yourself?

Title: Re: <project>.with_bootloader.hex: bad file format
Post by Martin Boissonneault on Oct 1st, 2018 at 5:06pm
Hi!


Tim@Visual Micro wrote on Oct 1st, 2018 at 4:22pm:
The checks as far as I can see boil down to the board having a bootloader.file=. In this case the bootloader.file= points to a file that is not a conventional bootloader. Therefore I guess this is why the arduino ide doesn't bother to produce any result.

Can you please shed any light on this issue. What do you do to create the file yourself?

The boards.txt does have a bootloader.file= section pointing to a binary file:
Code (]adafruit_metro_m0.bootloader.file=metroM0/bootloader-metro_m0-v2.0.0-adafruit.5.bin[/code):


What I did to create the bootloader .hex file?
I have a J-Link EDU mini connected to the board. I used AS7 Tools>Device programming> Fuses/Memories.
  1. I cleared bootloader protection fuses,
  2. erased the entire flash chip,
  3. re-uploaded the .bin file and
  4. restored bootloader protection fuses.
  5. Then, I read back the flash in .hex format.
I might have edited the file to keep only the bootloader lines and delete those from memory 0x2000 and above.

Now, the .bin files (with .elf and .uf2) are provided with the Adafruit SAMD board package from the Arduino Manager.[code]https://adafruit.github.io/arduino-board-index/package_adafruit_index.json

There is a dependency on the Arduino SAMD package, install it first.

If you need more detail, just ask!
Thanks,
Martin
Edit: I may have misunderstood the question, clarification below:
The <project>.with_bootloader.hex file is auto-generated when I select to Build>Build Solution or Build Project in AS7.

Title: Re: <project>.with_bootloader.hex: bad file format
Post by Visual Micro on Oct 1st, 2018 at 5:20pm
Thanks very much.

I suspect that if it doesn't have a line ending with FF it should be ignored. I'll take a look at it but because the arduino ide doesn't use it I think visual micro won't be able to either.

Does the board support "burn bootloader". This is normally how the bootloader is uploaded.

Title: Re: <project>.with_bootloader.hex: bad file format
Post by Martin Boissonneault on Oct 1st, 2018 at 6:09pm

Tim@Visual Micro wrote on Oct 1st, 2018 at 5:20pm:
I suspect that if it doesn't have a line ending with FF it should be ignored. I'll take a look at it but because the arduino ide doesn't use it I think visual micro won't be able to either.

  I am not sure about what you mean by that, the bad .hex file is a (crude) cat between the compiled project in Intel .hex format (that is good, but without Intel .hex file end marker) with the unprocessed, raw binary bootloader code from the .bin file (not in Intel .hex format, BAD!). Since the .hex file is NOT ENTIRELY in Intel .hex format, it is unusable and rejected by the flash programmer.

It looks like something expects the binary bootloader to be in .hex format. I don't know if Visual micro is at fault or if Adafruit mistakenly feeds a binary instead of a .hex, but in the end, the file in the Release or Debug folder is messed up because some code expects .hex but does not check. Maybe a bug in AS7?


Tim@Visual Micro wrote on Oct 1st, 2018 at 5:20pm:

Does the board support "burn bootloader". This is normally how the bootloader is uploaded.


  Yes, the board has a Burn bootloader option in the Arduino IDE.

Anyway, this bug not a show stopper for me whatever who or what causes it. Visual Micro's upload mechanism works well.

Thanks!
Martin

Title: Re: <project>.with_bootloader.hex: bad file format
Post by Visual Micro on Oct 1st, 2018 at 6:30pm
Why can't you just use the standard output <project_name>.ino.hex or <project_name>.ino.bin.

The "with_bootloader" isn't supposed to be created.


Title: Re: <project>.with_bootloader.hex: bad file format
Post by Martin Boissonneault on Oct 1st, 2018 at 6:44pm
Even better: Don't erase the bootloader and use the normal mechanism!

But yeah, I changed the setting to erase the program only instead of Erase chip... I found the bug while trying all sorts of ways to get the Debug to work previously.

  Since, I learned how to erase, reload and protect my bootloader, and some ways to debug my project. I am still struggling at times, I started this whole adventure in Arduino programming in July! I had no knowledge in C/C++ programming then!

Now if I could figure this: (not in this thread!)
[code]:(.bss.radioArgvList+0x0): multiple definition of radioArgvList
:C:\Users\Martin\AppData\Local\arduino15\packages\adafruit\hardware\samd\1.2.3\cores\arduino\Print.h:62: first defined here
: error: ld returned 1 exit status[/code] :P

Martin

VS Arduino » Powered by YaBB 2.6.12!
YaBB Forum Software © 2000-2024. All Rights Reserved.