Skip to main content
Topic: BP3 firmware update problem (Read 10480 times) previous topic - next topic

Re: BP3 firmware update problem

Reply #15
I can confirm that disabling the bootloader option preserve flags solves the problem of the verify errors. It is save (I think!) to leave it off because every .hex file I generated and downloaded for the buspirate has the config fuses in it. The only problem could be when the program grows bigger then the location of the fuses (why are the fuses in mid-flash range anyway??)

After disabling the protect fuse, I got no error, but the fuses are correct:

Code: [Select]
HiZ>+
CFG1:0xF9DF CFG2:0x3F7F
  _   _     _       ____   _  __     __  __  U _____ u
 |'| |'|U  /"  uU /"___| |"|/ /   U|' / '|u| ___"|/
/| |_| |\/ _ / | | u   | ' /    | |/| |/ |  _|"
U|  _  |u/ ___   | |/__U/| . \u   | |  | |  | |___
 |_| |_|/_/   _  ____| |_|_    |_|  |_|  |_____|
 //   \ \    >> _// \,-,>> \,-.<<,-,,-.   <<   >>
(_") ("_)__)  (__)__)(__).)   (_/  (./  .) (__) (__)
HiZ>i
Bus Pirate v3
Firmware v3.2
DEVID:0x0447 REVID:0x3043 (B5)
http://dangerousprototypes.com


BTW generating a .hex without optimize settings (the nigtly built for example) hits the a800 boundry!

Re: BP3 firmware update problem

Reply #16
@sjaak - thanks for the confirmation. What version/language/compiler are you using to compile the nightly? When I compiled v3/english yesterday (no opts) it was well below the 0xa800 boundary.

I'll do some testing with erasing the configuration bits, I worry that a chip without config bits won't have the wherewithal to get loaded again. How is the chip supposed to know what clock source to use with the bootloader if the config bits are erased? There may be some mechanism to address this, but I'd like to know for sure before recommending that everyone do it.
Got a question? Please ask in the forum for the fastest answers.

Re: BP3 firmware update problem

Reply #17
I've done some testing, and PLEASE NOTE: if you uncheck 'preserve flash configuration words on erase', and fail to complete the upgrade, the bootloader will not connect again!
Got a question? Please ask in the forum for the fastest answers.

Re: BP3 firmware update problem

Reply #18
I compiled the vanilla 170 and applied some of my patches (other topic). I noticed it when I was testing the VDM function. The used language is english, because my italian and spanisch suck big time ;)

I think you shouldn't worry about the fuses as each .hex set it again (it is on one of the last lines in the .hex) It is important to follow the compile howto exactly (check the fuses box in the export step).

Perhaps I can make a .hex that just programs the fuses. So the upgrade steps become:

- connect device
- clear device (uncheck the preservce fuses)
- program fuses.hex (after this step you're save I think)
- program the new firmware.

Alternative is to rewrite the bootloader to just clear the upper range and program the fuse directly afterwards..

Re: BP3 firmware update problem

Reply #19
To me it seems pretty risky. The upper page seems to program OK, even if it's not erased (I need to set some values and test to be sure). The only problem seems to be a few !=0xfffff errors, which are also seen in the bootloader region. Until there is a compelling reason to recommend that option, I don't want to risk bricking a bunch of Bus Pirates over a cosmetic error (that shouldn't even be present with the main firmware release...yet). If you have a PIC programmer it's no problem to unbrick the bootloader, but most users don't have one.
Got a question? Please ask in the forum for the fastest answers.

Re: BP3 firmware update problem

Reply #20
Also if the fuses are allready set why do we export them with the .hex?

if you dont export them does the verify error still occur?

Re: BP3 firmware update problem

Reply #21
When you erase the page where the fuses are stored, the whole page contains all 1's (or 0xFFFFFF) The result is that both fuses are set to 0xFFFF. This would disable the bootloader (see post of Ian). Hence I would program the fuses before anything else (the fuses.hex).

I'll run some tests myself tonight to be sure (lets hope I don't brick anything, because I don't have a pic programmer)

Is there BTW a lowcost pic24F programmer? Just for my peace of mind ;P

Re: BP3 firmware update problem

Reply #22
PICkit and the clones are the cheapest PIC24 programmers (around $30) I know of. I hope for the Bus Pirate to program 3.3volt pics soon, too :)

I understand your logic of writing the fuses first to spend as little time as possible without the fuses burned (I'm guessing).

I'm going to do some tests now with variables located at 0xa800 and see if I can overwrite them correctly with the bootloader. As long as everything keeps working, then I have no problem with the extra errors.

I believe the bootloader would have to be updated to fix this to my satisfaction. I'd rather use the ds30 Loader from the web platform than change the PIC24 loader. Either way, there's no easy way to deploy the fix (or I'd have to maintain multiple compiles for the different bootloaders).

If anyone is up for a real challenge: develop a bootloadable firmware for the P24QP bootloader that installs the ds30Loader and erases the P24QP bootloader on the first run (light the MODE LED to show success). When I think about doing this I understand why PC hardware bios is such a mess :) I can port the ds30loader to PIC24 if anyone is interested in trying to deploy an bootloadable installer for it. I'll give you a preview of the next Bus Pirate hardware (if/when it becomes available).
Got a question? Please ask in the forum for the fastest answers.

Re: BP3 firmware update problem

Reply #23
>why are the fuses in mid-flash range anyway??

The config fuses are actually at the very end of program flash range. The PIC has (as I understand) a single address system for all registers, the additional addresses don't really exist, or address other memory or peripherals.
Got a question? Please ask in the forum for the fastest answers.

Re: BP3 firmware update problem

Reply #24
I would look into the manner of upgrading the bootloader but I got two problems:

- My mode led is broken
- no PIC programmer

I could whip something up for someone else to try. (Someone with a programmer that is :)) Finally some old hacking skills will come in handy :D

Your guess is right about the fuses. Writing beyond a800 will give lots of troubles if that data is not static. with flash you can 'program' a '1' to '0' but you can't do the other way. The other way is clearing a page (setting all bits to '1') and reprogram it.

The datasheet mentions something about 64Kb (0xFFFF) that's why I think it is in the middle. I should read it sometimes more indept ;P

Re: BP3 firmware update problem

Reply #25
The 64KB is divided into 16 or 24bit words, so the address range is much lower than expected. That threw me off big time when I was first getting the bootloader going.

If you're up for it, I'll test any code you put together. I can also help write it (we can keep a copy in SVN).

I think there are several ways to do it. Maybe easy: the ds30 loader actually lives in the last page of flash, whereas the current bootloader sits just after the interrupt vectors at the beginning*. Maybe it would be possible to bootload a firmware that includes the ds30loader in the last page, and a small utility in the beginning part that erases the old bootloader and overwrites the jump vector with a new one for the ds30Loader. That might only be a few lines of code.

*This is annoying because if I want to update the interrupt vectors I have to export the beginning of the flash and then there are all those bootloader verify errors to 0x800.
Got a question? Please ask in the forum for the fastest answers.

Re: BP3 firmware update problem

Reply #26
Ha, I think it will be even easier. I'm porting the ds30loader now, will just try to bootload it, then connect with the ds30loader and erase the old one. We'll see :)
Got a question? Please ask in the forum for the fastest answers.

 

Re: BP3 firmware update problem

Reply #27
I split this topic off to the new development board:
http://whereisian.com/forum/index.php?topic=236.0
Got a question? Please ask in the forum for the fastest answers.