chipKIT® Development Platform

Inspired by Arduino™

max32 firmware update from eeprom with spi

Created Thu, 07 Apr 2016 09:16:53 +0000 by MoTronic


MoTronic

Thu, 07 Apr 2016 09:16:53 +0000

Hi evrybody im going to update the firmware of my device (chipkit max32) and i should do it with spi or reading the program from a memory like eeprom the standard bootloader doesnt do it does anybody know a solution? and i should also change the start adresse of the user programm code does anybody has the original bootloader for max32?(the hex file)


majenko

Thu, 07 Apr 2016 10:42:04 +0000

The original bootloader, as well as a tutorial on how to program the bootloader into the board can be found here:

  • [url]https://reference.digilentinc.com/chipkit_max32:chipkit_max32[/url]

Programming the bootloader usually requires a hardware programmer (PICkit3, chipKIT PGM, etc), although there are convoluted (and risky) methods you can use to reprogram program a working board with a new bootloader from a sketch. You can find an example of that here:

  • [url]https://github.com/chipKIT32/PIC32-avrdude-bootloader/tree/master/update-sketches/UpdBlMax32[/url]

MoTronic

Thu, 07 Apr 2016 13:06:19 +0000

thanks the code of original bootloader is also open source? i think i should modify the bootloader in order to reprogram my device from eepram


majenko

Thu, 07 Apr 2016 18:33:27 +0000

Yes, it's in the same repo as the example reprogramming sketch: https://github.com/chipKIT32/PIC32-avrdude-bootloader


MoTronic

Tue, 12 Apr 2016 09:29:45 +0000

Hi my problem is not solved and i need help or idea i describe the problem clearly i have a chipkit Uno32 and it is another side of the world :lol: ***i should be able to update the firmware of it from hier 4000km away and without an external hardware (programmer or another hardware) ***overthere i have spi conection between Uno32 and a second hardware over modbus <<https://en.wikipedia.org/wiki/Modbus>> ***i can read and write variables from this second hardware ***i have a connection to second hardware from hier

what im going to do is this 1- send the hex code of the program to the second hardware anotherside of the world 2- the second hardware send the hex code of the new program to the Uno32 3- Uno32 saves the new hex file into a permanent memory (eeprom , sd card or ....) 4- each time after restart it hold the hex code of the program from the permanent memory and it process it (like a fpga that save its cofiguration on a eepram)

i have the connection to second hardware and everything is ok what i really need is a bootloader that read the program after restart from permanent memory and i havent found any good solution :?:


majenko

Tue, 12 Apr 2016 09:36:22 +0000

Does it have to be an Uno32? It sounds like you might be better off experimenting with a Max32 and RetroBSD, or an MZ based board and LiteBSD.

That gives you a full-blown operating system on a PIC32 which executes its programs from an SD card.


MoTronic

Tue, 12 Apr 2016 10:39:10 +0000

Max32 is ok but which operationsystem should i use and can i update my hex code with it?


majenko

Tue, 12 Apr 2016 12:39:36 +0000

With the MAX32 you can run RetroBSD - a port of 2.11BSD to the PIC32. It executes a.out binaries from SD card, so you would just need to place a new binary on to the SD card through whatever means you like (you could have an application on there which downloads the binary from your other unit for instance).

Programming it is very different. You're working with an operating system, not a microcontroller, so it is much more like programming Linux than a PIC32. Your existing code would need considerable changes in order to make it work.

There is a performance hit though of course with the overhead of the operating system and the poor process switching performance. LiteBSD on the PIC32MZ is far superior in that respect because of the MMU and extra memory that the PIC32MX doesn't have.

You should head over to retrobsd.org and take a look at it. Have a play and see what you think.


MoTronic

Thu, 21 Apr 2016 14:50:12 +0000

Hi i havent found any solution jet and i should update my firmware without a operation system im looking for the original source code of chipkit boot loader to manipulate it does anybody know how i can find it? is there any repository ? thanks


majenko

Thu, 21 Apr 2016 16:27:51 +0000

Scroll up to the top. I told you where the bootloader repository is before.


MoTronic

Wed, 04 May 2016 15:45:27 +0000

Hi i havnt found the solution i describe the problem and in the case that someone can write it i can pay for it. the Problem: i need a bootloader that chack if there is a new program on an external EEPROM
and if the Program is new it should load the program into the pic32


majenko

Wed, 04 May 2016 16:04:08 +0000

I would be inclined to tackle it slightly differently.

  1. Keep the existing bootloader, since it is very convenient for uploading code from the PC.
  2. Divide the main flash up into two sections using a custom linker script - lower section (small) for your own loader program, and upper section (large) for your loaded program.
  3. Write a small sketch (as small and efficient as you can) that will fit in the new "low" section of flash which looks at the EEPROM and checks to see if it's a new program or not (maybe with a checksum or version number stored in there somewhere?) then erases the "upper" section of flash and copies the data from the EEPROM into it.
  4. Jump to the new start location

Your EEPROM-based program would of course have to be linked to reside at the right address in the upper block, which means linking it with the right custom linker script.

This has several advantages:

  1. You can experiment with the EEPROM code (reading the data etc) without needing to make any changes to the board
  2. You have the existing bootloader available to get your code on there in the first place
  3. You can use the Arduino API and libraries to make your programming easier.
  4. It's very easy to upgrade your loader program to a new version

There are a couple of disadvantages though:

  1. You need to make a suitable pair of linker scripts
  2. You have slightly less space for your main executable code.

But they're minor compared to the benefits of doing it this way.

By the way, this is commonly referred to as a "second stage" bootloader.


MoTronic

Tue, 17 May 2016 07:27:38 +0000

Hi Majenkt the idea is good and i already also worked on it but i had a problem with linker the script is ok but i get an error for the gcc library but its installed and works currectly i have the object file and the linker script is there a gui to do the linking process easier?


majenko

Tue, 17 May 2016 09:04:09 +0000

No, no gui other than the IDE.

Once you have a linker script is is best to make new board definitions (one for programming the second stage bootloader and one for your main sketch) which use your new linker scripts.

Making linker scripts is very much a black art. I have barely scratched the surface with them and already I am confused by them ;)


kenedy

Wed, 29 Jun 2016 22:15:32 +0000

I am terribly sorry for not having the original bootloader for max32 :!: