Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using more PIC32 flash space - howto
31-01-2014, 04:44 PM, (This post was last modified: 31-01-2014, 04:47 PM by pingotg.)
Using more PIC32 flash space - howto
The smaller PIC32 chips such as the MX220 only have 3KB for the bootloader and as a result the USB HID bootloader takes some of the main program flash.

As now arranged, there's some free space that can be used with a simple change.

I've tested this on the Olimex board with a PIC32MX220F032D but it should work on other boards.

It frees up about another 3KB straight away. (Some more can be used but not so easily - see the comments in the procdefs.ld attached.)

The actual free space for a Pinguino program (PDE) goes from about 13.5KB to 16.5KB and allows CDC.printf to fit Smile

I've had to rename the procdefs.ld but just rename it to that. You can then put it where the IDE looks for it. Have a look at the path in the Makefile but it's along the lines of
pinguino/p32/lkr/board/ (where "board" is such as PIC32_PINGUINO_220).


Attached Files
.txt   procdefs.txt (Size: 3.1 KB / Downloads: 17)
31-01-2014, 07:27 PM,
RE: Using more PIC32 flash space - howto
Great ! Thank you.
However, just a remark. I know it's the same in the old version of this linker script and Pinguino doesn't use them but I think these addresses are wrong :
debug_exec_mem : ORIGIN = 0xBFC02000, LENGTH = 0 /* JMS 0xFF0 */
config3 : ORIGIN = 0xBFC02FF0, LENGTH = 0x4
config2 : ORIGIN = 0xBFC02FF4, LENGTH = 0x4
config1 : ORIGIN = 0xBFC02FF8, LENGTH = 0x4
config0 : ORIGIN = 0xBFC02FFC, LENGTH = 0x4

Device configuration registers start at 0xBFC00BF0 on PIC32MX1xx and PIC32MX2xx families so :
config3 : ORIGIN = 0xBFC00BF0, LENGTH = 0x4
config2 : ORIGIN = 0xBFC00BF4, LENGTH = 0x4
config1 : ORIGIN = 0xBFC00BF8, LENGTH = 0x4
config0 : ORIGIN = 0xBFC00BFC, LENGTH = 0x4

Boot flash is between 0xBFC00000 and 0xBFC00BEF so debug_exec_mem can not be at 0xBFC02000 and must be placed somewhere in the program flash.
It is easier to complain than it is to do, but it is better to do than it is to complain.
31-01-2014, 07:51 PM, (This post was last modified: 31-01-2014, 07:53 PM by pingotg.)
RE: Using more PIC32 flash space - howto
You're right but they're not used. They should probably be deleted. I left them in because I wasn't sure if things would work if I deleted them and they can't cause any damage as they are.

They're used when creating the bootloader itself (and yes need to be changed) but not meant to be used when the IDE is linking a Pinguino app.

Note that I made the debug_exec_mem length 0 so it cannot be used by accident. There isn't space and anyway you'd not be in the IDE you'd be in MPLAB or the like.

31-01-2014, 10:49 PM,
RE: Using more PIC32 flash space - howto
There is Microchip document about storing stuff in bootflash using __attribute__ ((section ...)). As to my knowledge all space of bootflash can be used to store bootloader/application variables or functions. Sections like debug can be deleted, but then there is no compatibility with MPLAB that might use it wich is irrelevant for Pinguino.
Dreaming in Code...
31-01-2014, 11:09 PM, (This post was last modified: 31-01-2014, 11:12 PM by pingotg.)
RE: Using more PIC32 flash space - howto
I have deleted that and am using that.

There's about another 2KB or with rewrite maybe 4KB. See other thread - I suspect it's just not worth it.

I made these changes mainly out of curiosity. I had my MX220 board gathering dust because I moved to a cheaper series of boards (not from Microchip) - one at less than half the price has more than double the flash & RAM. Faster, too.

31-01-2014, 11:17 PM, (This post was last modified: 31-01-2014, 11:23 PM by agolac.)
RE: Using more PIC32 flash space - howto

And here is the Microchip file for those who would like to read, but one has to log in to download PDF.

Use PIC32 Boot Flash to Expand Program Memory

Its then maybe time we push start Pinguino to that cheaper boards too Big Grin
More alternative to continue its existance, expansion and in case Microchip destroys all of their customers will to buy their chips
Dreaming in Code...
01-02-2014, 01:01 AM,
RE: Using more PIC32 flash space - howto
The various DIY boards seem to be 128KB chips - plenty Smile


Forum Jump:

Users browsing this thread: 1 Guest(s)