Page 1 of 1

HIDBootFlash error, cannot reflash bootflash, help!

Posted: Wed Dec 26, 2012 9:05 pm
by Nitz76
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! :!:

Re: HIDBootFlash error, cannot reflash bootflash, help!

Posted: Wed Dec 26, 2012 9:11 pm
by Nitz76
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.

Re: HIDBootFlash error, cannot reflash bootflash, help!

Posted: Thu Dec 27, 2012 12:14 am
by xiangrui
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

Re: HIDBootFlash error, cannot reflash bootflash, help!

Posted: Thu Dec 27, 2012 2:56 am
by Nitz76
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!

Re: HIDBootFlash error, cannot reflash bootflash, help!

Posted: Thu Dec 27, 2012 3:05 am
by Nitz76
: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? :?:

Re: HIDBootFlash error, cannot reflash bootflash, help!

Posted: Fri Dec 28, 2012 12:13 am
by Nitz76
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!