• AVR Freaks

PIC32 field updating with a bootloader using compression

Author
jlehman
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2015/01/05 08:11:01
  • Location: 0
  • Status: offline
2017/11/01 06:20:15 (permalink)
3 (1)

PIC32 field updating with a bootloader using compression

I am looking for a way to compress a .hex file on a PC and then decompress it in the bootloader during programming. My application is in a PIC32 and uses several 100K of memory. Once converted to intel hex it is almost 3 times the size. This is a cell based IOT device so byte count is important.
 
I see in the CRYPTO library there is a decompression function but it looks to be only single call and not designed for a multi call stream. I also do not see a host side application defined to work with this compression for compressing the .hex file.  
 
Anyone have recommendations?
 
Thanks
#1
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
Re: PIC32 field updating with a bootloader using compression 2017/11/01 06:37:25 (permalink)
0
Some huffman compression might work... I worked with it time ago when compressing images, and should be within a PIC32 bootloader size/power.

GENOVA :D :D ! GODO
#2
NKurzman
A Guy on the Net
  • Total Posts : 17918
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: PIC32 field updating with a bootloader using compression 2017/11/01 08:23:24 (permalink)
3 (1)
A hex file is plain text. You can convert it to a binary file and use that.
#3
Michael.W.Mann
Super Member
  • Total Posts : 324
  • Reward points : 0
  • Joined: 2011/01/24 09:58:24
  • Location: Chandler, Arizona
  • Status: offline
Re: PIC32 field updating with a bootloader using compression 2017/11/01 09:31:47 (permalink)
0
You can do two things to make the .hex file format more efficient.
 
1) As previously stated, convert from ASCII plain text, where you use two characters per data byte, to binary so that you only use one byte per byte.
 
2) If you examine the format of the .hex files, you will see that the data portion is very short and most commands are just a continuation of the previous one.  Combine sequential commands into a larger one.  This will reduce the overhead of the format.
 

Michael W. Mann
Principal Applications Engineer
MCU32 Applications, Microchip
#4
Michael.W.Mann
Super Member
  • Total Posts : 324
  • Reward points : 0
  • Joined: 2011/01/24 09:58:24
  • Location: Chandler, Arizona
  • Status: offline
Re: PIC32 field updating with a bootloader using compression 2017/11/01 11:25:30 (permalink)
0
Also,
 
Under the Building configuration tab, enable "Normalize hex file" to sort the .hex commands by address.  This will maximize the efficiency of compressing commands into longer data streams.

Michael W. Mann
Principal Applications Engineer
MCU32 Applications, Microchip
#5
jlehman
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2015/01/05 08:11:01
  • Location: 0
  • Status: offline
Re: PIC32 field updating with a bootloader using compression 2017/11/01 12:09:50 (permalink)
0
Thank you all for the replies.  I do use hexmate with the switch -FORMAT=INHX32,48 to pack 48 data bytes to a record.  We are in the process of switching from ASCII to binary but there are still a lot of FF and 00 runs that would compress.  I was hoping someone else had used the Harmony or another real compression method to further reduce the distributed file.  When you have processors like the PIC32MZ1024 & PIC32MZ2048 with 1 or 2 meg bytes of memory the file can approach or exceed 1MB. With 10,000s  of units over cell, this volume of bytes adds up.
 
Thanks
#6
SERGOSV
Starting Member
  • Total Posts : 35
  • Reward points : 0
  • Joined: 2017/11/01 11:47:58
  • Location: 0
  • Status: offline
Re: PIC32 field updating with a bootloader using compression 2017/11/01 12:19:26 (permalink)
3 (1)

A very good utility for converting hex to bin - https://sourceforge.net/projects/srecord/files/srecord-win32/
And a simple option for decompressing files compressed, for example, 7-zip, with the extension .gz -http://dfrank.ru/prog/c/tinf
Sorry for my English )))
#7
malaugh
Super Member
  • Total Posts : 400
  • Reward points : 0
  • Joined: 2011/03/31 14:04:42
  • Location: San Diego
  • Status: offline
Re: PIC32 field updating with a bootloader using compression 2017/11/01 13:19:30 (permalink)
3 (1)
We use LZF compression on one of our projects.  We start with a binary image, and run it through the compressor. the compressed file is send to the target device, and the bootloader in the target decompresses it.  There are a bunch of open source embedded libraries in the web. the one we use is old and unsupported, but it very compact and does not seem to have any bugs   https://code.google.com/archive/p/lzfx/
 
#8
Jump to:
© 2019 APG vNext Commercial Version 4.5