Hi, I developed a big sketch with a Arduino UNO including Adafruit CC3000 and NEOPixels. It is compiling and running well for the uno using the IDE. But as soon as I select the MICRO as a board, the sketch becomes bigger and does not fit anymore. I thought the chips are the same, so I wonder what's wrong?
The chips are not the same.
The Leonardo - or Micro - uses a different chip with almost the same amount of memory (slightly different, in fact more RAM), but due to the built-in USB interface, the bootloader occupies 4k instead of 0.5k, so yes, your bloated sketch will not fit.
How much bigger does the sketch get? As Paul said, the usual problem is that there is less room, not that the sketch gets too much larger. (that said, a leonardo sketch has a USB driver in each sketch that uses "serial", IN ADDITION to the one in the bootloader. About 3K extra in each one.)
Thank you for the explanation. Yes it is roughly 3K more when I select the Micro. So I guess I have to find more things I can shorten. In the end I might have to use a RTC instead of WLAN with NTP. The RTC library seems to be much smaller…
Larger bootloader is one thing, another is the USB support which uses a lot of program memory.
How much short are you on flash space? For interfacing with CC3000 I am disabling usb hid:
#define CDC_ENABLED //#define HID_ENABLED <- this was commented out
If you don’t need USB Serial, you can comment out CDC_ENABLED too, this will make the program even smaller.
You can also remove some of the parts in the CC3000 driver - for example I never use open networks so I removed the reference to connectOpen.
However, the Adafruit CC3000 driver is quite bloated, anything non-trivial and you run out of flash space. I ended up rewriting the whole application (and driver) from scratch in C.
Feel like sharing your smaller driver?
It’s depressing that so many of the libraries for dealing with “intelligent” chipsets (CC3000, Wiznet) end up being close to the size of full TCP stacks.
Nice hints, will try this at the weekend. I would be interested in the smaller version you build as well.! =)
I tried some stuff on the weekend. Disabling USB brought me a few KBs but it is still hard on the limit. So that is probably why everything runs unstable on the Micro but perfectly on the UNO...
I think I'll check if I can remove some stuff in the NEO LED libs but would still be happy to check your CC3000 library! =)