Sketch size when CC3000 library is used

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
emmander
 
Posts: 4
Joined: Fri Feb 21, 2014 7:04 am

Sketch size when CC3000 library is used

Post by emmander »

Hi there!

Anyone of you ever experienced having your sketch code blowing up from 18 or so kb to about 30 kb when you include the CC3000 library?

I am currently working on a handful of Adafruit devices in one project (LCD - I2C, Motor Shield v2.0 and CC3000 Shield). I know! It's a mess. Apart from these shields I also have some devices connected to the Arduino (pH Probe, ACS758, Flow Sensor, and a DS1820). Pretty much the codes for the peripherals and the Motor and LCD Shields are done. This brought me to about 18kb of sketch code. From here, everything works out just fine. However, when I include the CC3000 library, my sketch blows to about 30kb and the board goes into an "infinite loop" where it gets stuck just within the "setup() block".

Now, I'm not sure if the library has something to do with it or not, but it only happens when I start using the CC3000. Without it, everything seemed to work really well. On it's own, the CC3000 works fine as well, apart from the really disturbing sketch size (even to itself, sketch size is about 16kb with a few lines of code just to initialise and connect to a network).

I'd really appreciate any comment/reply from Adafruit regarding this topic and of course, from other learned people too!

Thanks.

Eman

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Sketch size when CC3000 library is used

Post by adafruit_support_rick »

The CC3000 library is necessarily a good size, but 30k of code won't cause your code to explode. Instead, you are probably running out of SRAM. Please see our tutorial on memory usage for some tips on solving this problem:
https://learn.adafruit.com/memories-of-an-arduino

User avatar
emmander
 
Posts: 4
Joined: Fri Feb 21, 2014 7:04 am

Re: Sketch size when CC3000 library is used

Post by emmander »

I have moved all my strings to pgmspace. Before this, I still have some strings located in SRAM but I still have 693 bytes of RAM available. So, as suggested by your tutorial, I moved all my strings to pgmspace thereby leaving me with 873 bytes of RAM space.

I uploaded the new sketch to my Arduino and still the same thing. The Arduino loops the setup() block. After one loop, it freezes. And then when I remove the code for the CC3000, it works just fine.

User avatar
emmander
 
Posts: 4
Joined: Fri Feb 21, 2014 7:04 am

Re: Sketch size when CC3000 library is used

Post by emmander »

Just an FYI, here are some of the code sizes on the CC3000 library (sizes according to Arduino IDE during compile):

.begin() -- 2198b
.deleteProfiles -- 134b
.connectToAP -- 2186b
.checkDHCP -- 38b

I have one instance of each function in my code. I commented them one by one to get the size differences after compiling.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Sketch size when CC3000 library is used

Post by adafruit_support_rick »

emanA wrote:I uploaded the new sketch to my Arduino and still the same thing. The Arduino loops the setup() block. After one loop, it freezes. And then when I remove the code for the CC3000, it works just fine.
Hmmm. If you post your code, I'll see if I can spot anything that would cause it to crash.

User avatar
wcbuerste
 
Posts: 1
Joined: Fri Aug 29, 2014 3:42 pm

Re: Sketch size when CC3000 library is used

Post by wcbuerste »

Hi,
I´m also experiencing Problems with the size of the library. It really seems to be preety big and I´m running quickly out of space with some projects. Are you planning to build a smaller and more basic one or is there any development going on at the moment? Lastest changes are a few month old now...

Thank you for all the efford you guys put in your work!

Keep on going and greetings from Hamburg / Germany,

David

User avatar
tdicola
 
Posts: 1074
Joined: Thu Oct 17, 2013 9:11 pm

Re: Sketch size when CC3000 library is used

Post by tdicola »

Unfortunately the CC3000 library is pretty complex and based on the host driver code that TI publishes for the chip. It's tough to build a smaller driver because the protocol TI uses isn't well documented, the host driver code is effectively the documentation for better or worse. Although it might be possible to write a minimal CC3000 driver it's going to be difficult to maintain and integrate changes from TI.

However one thing you can check out to get a little more space is the latest beta version of the Arduino IDE 1.5.7. This version switches to a much more recent compiler (version 4.8 instead of the current Arduino's version 4.3 AVR-GCC compiler) which has much smaller code generation. I noticed with CC3000 sketches you can save at least a couple kilobytes just switching to the newer compiler. In my simple testing it seems to work well, but be aware it's still a beta and might have issues. If you want to try it, check it out here: http://arduino.cc/en/Main/Software#toc3

For emanA's issue where the loop function doesn't work with so many devices attached, one thing to be careful of is if any device needs to disable or change interrupts. The CC3000 needs interrupts to be enabled so it can be sure it gets notifications when the chip has new data available. You might try disabling some of the sensors one by one to see if they are causing conflicts with the CC3000.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”