HIDBootFlash error, cannot reflash bootflash, help!

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
Nitz76
Rank 1
Rank 1
Posts: 26
Joined: Fri Dec 14, 2012 5:51 pm

HIDBootFlash error, cannot reflash bootflash, help!

Post by Nitz76 » Wed Dec 26, 2012 9:05 pm

Hello,

I did a simple implementation of the HIDBoot on a Atmega8. For a wierd reason, it can reflash everything except the bootflash itself.
Here is the output of bootflashHID.exe:

Code: Select all

D:\>bootloadhid -r main.hex
Page size   = 64 (0x40)
Device size = 8192 (0x2000); 6144 bytes remaining
Data (7874 bytes) exceeds remaining flash size!

D:\>


But when I relfash the device code, everything go well:

Code: Select all

D:\>bootloadhid -r device.hex
Page size   = 64 (0x40)
Device size = 8192 (0x2000); 6144 bytes remaining
Uploading 2816 (0xb00) bytes starting at 0 (0x0)
0x00a80 ... 0x00b00

D:\>


Something is wrong, but what... :?: Help! :!:

Nitz76
Rank 1
Rank 1
Posts: 26
Joined: Fri Dec 14, 2012 5:51 pm

Re: HIDBootFlash error, cannot reflash bootflash, help!

Post by Nitz76 » Wed Dec 26, 2012 9:11 pm

Oh and BTW, AVR studio is pushing the same HEX without issue.

Another test is conclusive; it switch between the device and the HIDBoot when the jumper is on.

xiangrui
Rank 1
Rank 1
Posts: 30
Joined: Sun Jan 01, 2012 5:19 am

Re: HIDBootFlash error, cannot reflash bootflash, help!

Post by xiangrui » Thu Dec 27, 2012 12:14 am

I thought it can't write itself, but I may be wrong.

From the error message, it seems it is writing to the application section, since it says "6144 bytes remaining", which is the size after reserving 2K boot section.

-Xiangrui

Nitz76
Rank 1
Rank 1
Posts: 26
Joined: Fri Dec 14, 2012 5:51 pm

Re: HIDBootFlash error, cannot reflash bootflash, help!

Post by Nitz76 » Thu Dec 27, 2012 2:56 am

Okay... So you have to lock the bootsection with the lockbits and then it will protect it when you reflash the device?
Then you can only reflash the application section... I see.

I just tried and it works. I'll re-read the spec sheet.

:oops: sorry, I think I look dumb now!

Nitz76
Rank 1
Rank 1
Posts: 26
Joined: Fri Dec 14, 2012 5:51 pm

Re: HIDBootFlash error, cannot reflash bootflash, help!

Post by Nitz76 » Thu Dec 27, 2012 3:05 am

:idea: Hum... just re-read the Atmega8 specifications.
Looks like it's possible but in a different manner:

The Boot Loader Support provides a real Read-While-Write Self-Programming mechanism for
downloading and uploading program code by the MCU itself. This feature allows flexible application
software updates controlled by the MCU using a Flash-resident Boot Loader program. The
Boot Loader program can use any available data interface and associated protocol to read code
and write (program) that code into the Flash memory, or read the code from the Program memory.
The program code within the Boot Loader section has the capability to write into the entire
Flash, including the Boot Loader Memory. The Boot Loader can thus even modify itself,
and it
can also erase itself from the code if the feature is not needed anymore. The size of the Boot
Loader Memory is configurable with fuses and the Boot Loader has two separate sets of Boot
Lock Bits which can be set independently. This gives the user a unique flexibility to select different
levels of protection.


So, there is a caveat about the HIDbootflash code that does not permit self programming in the boot section.

Any other opinion, suggestion? :?:

Nitz76
Rank 1
Rank 1
Posts: 26
Joined: Fri Dec 14, 2012 5:51 pm

Re: HIDBootFlash error, cannot reflash bootflash, help!

Post by Nitz76 » Fri Dec 28, 2012 12:13 am

Hum... Looks like the latest version of the HID boot firmware is able to reprogram itself.
Important note, it's very important to keep everything "static" because it's running in RAM only during the Bootflash RWW phase.

Case closed!

Post Reply