chipKIT® Development Platform

Inspired by Arduino™

Limit in code space

Created Sun, 17 Mar 2013 22:20:45 +0000 by PICedh


PICedh

Sun, 17 Mar 2013 22:20:45 +0000

Hello,

I have added the WIFI and TCP/IP lib to my own robot lib and now I reach the limit of 128K when I try to build my sketch on UNO32.

Is it possible to increase the flash memory of the UNO23 or to reduce the size of the WIFI and TCP/IP libs (currently about 70 K)

Thanks


majenko

Sun, 17 Mar 2013 23:26:46 +0000

Hello, I have added the WIFI and TCP/IP lib to my own robot lib and now I reach the limit of 128K when I try to build my sketch on UNO32. Is it possible to increase the flash memory of the UNO23 or to reduce the size of the WIFI and TCP/IP libs (currently about 70 K) Thanks

You can increase the flash memory by replacing the PIC32 chip on the board with a more meaty one, like a pic32mx695f512h, but that's rather a tricky operation. Personally I'd upgrade your board to one with a more meaty PIC32 on it, like the MAX32.

As for shrinking the code... It would probably be easier to shrink your code, since you know what it's doing. There are possibly bits of the WiFi code that are irrelevant to your code, but unused code should be optimized out by the compiler anyway, so would make little or no difference if you removed it.

Maybe you should re-evaluate what you are doing and how you are doing it, and make the whole thing more efficient...


PICedh

Fri, 05 Apr 2013 12:08:57 +0000

I have bought a MAX32 so now I can continue...

Thanks for your advice


rasmadrak

Fri, 05 Apr 2013 20:58:48 +0000

It is also possible to set the compiler flags to optimize for size. The default level is a sweetspot between speed and size, but can be tilted in both directions.

Unfortunately, I don't remember how to do this exactly but I found the answer previously in this forum... :)


majenko

Fri, 05 Apr 2013 22:30:09 +0000

You can edit the boards.txt file (in hardware/pic32) and tweak the *.compiler.c and *.compiler.cpp entries for your board. Currently it defaults to -O2, which is:

-O2 Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. As compared to -O, this option increases both compilation time and the performance of the generated code.

The options you can use are:

-O -O1 Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function. -O2 Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. As compared to -O, this option increases both compilation time and the performance of the generated code. -O3 Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the -finline-functions, -funswitch-loops, -fpredictive-commoning, -fgcse-after-reload, -ftree-vectorize and -fipa-cp-clone options. -O0 Reduce compilation time and make debugging produce the expected results. This is the default. -Os Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size. -Ofast Disregard strict standards compliance. -Ofast enables all -O3 optimizations. It also enables optimizations that are not valid for all standard compliant programs. It turns on -ffast-math. If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.


Jacob Christ

Sat, 06 Apr 2013 19:57:29 +0000

The Digilent uC32 has more program space as well if you need the UNO32 form factor.

Jacob