You build using the command line, and add SPARK_CLOUD=n. This will reduce the binary size by some 40k. Please keep in mind that this is experimental, and the branch might not be around forever, but might help you solve your size problem in the short term, or until the Photon is available!
I also have that size problem and tried to use the above hal-no-cloud version.
I can compile it, but it has a totally different design, so now I have to learn anew how to use libraries and how to add my own application.
In my old build environment (I donāt know which version it was, where can I see it?), I could add āAPP=Helloā to show the build which application to build. This seems to be not working with this build.
I even donāt know where is the actual application.cpp and which makefile is the right one to use? Is it the one in the root dir, or the one in the main dir (i think that).
Or maybe the SPARK_CLOUD=n switch is even in the main version now? I am lost, I donāt know what to use.
@Bluescreen, your app needs to go under the āmainā directory and can be compiled with āAPP=appnameā. Look at the way the tinker application is done to give you some guidance. The SPARK_CLOUD=n switch only exists in this branch of the master.
I get the adresses in the wrong order. If my IP is 192.168.42.53 I get this output:
IP Address: 53.42.168.192
Subnetmask: 0.255.255.255
Gateway : 1.42.168.192
If I compile using the standard master branch everything is ok. It has nothing to with the SPARC_CLOUD=n setting, itās wrong if I use either setting. Maybe itās some thing with the platform stuff and itās endian settings.
@peekay123 Avoiding sprintf() will save 20KB of code? Well, I did a quick test. I compiled the āled_blinkā example in the Particle IDE. The output BIN file size: 77,360 bytes. I added the following lines (grabbed from an example):
char publishString[100];
sprintf(publishString,"{āmVā: %i}",12456);
After rebuilding the project (yes, I saved the INO file first ;-)), the BIN file size is 77,456 bytes, or only 96 bytes more. Is there really a way to save 20KB by not referencing sprintf? Or is the entire sprintf library getting automatically included in the build, and not optimized out?
@kennethlimcp : Not meaning to hijack this thread at all, but where is that compiler output displayed ? Iāve been using the Web IDE and before the change from spark to particle it was displaying every time - these days it seems to have vanished.
OK, now Iām confused. As far as I know (and have done a couple of times), the .BIN file is what you flash with dfu-util, and it sends every byte of the file over. From my experience with the arm-none-eabi toolchain (a la DevKitPro, for programming the Nintendo GameBoy Advanceāitās a really handy little machine!), the output BIN is exactly what goes on to the GameBoy.
Admittedly, in every single past project (microprocessor or GameBoy Color/Advance), Iāve always ended up getting so frustrated with the compiler that I ended up programming the entire project in Assembler. Most compilers/IDEs tend to pack an incredible amount of ābaggageā onto an empty project, generally 60K+. . .C/C++ and I are not the best of friends.
I actually wrote my largest GBA project in pure ARM7TDMI assembler: 718KB of source code (15,541 lines) plus a 10KB compressed helpfile resulting in a 47K output BIN. (And yes, I do heavily comment ASM code!) That was a complete BASIC/ASM IDE on the little GBA, making it a pretty handy little debug terminal. (The link port on the back can serve as RS-232, shift-clock, or 4 GPIOs.)
@WebDust21, are you building for the Photon? According to this post by @mdma, sprintf has been moved to the system firmware for the develop branch, so itās possible (Iām not sure what firmware the cloud/ide is building against) that sprintf is already included, so adding that line doesnāt change the user-part.bin at all.
No, Iām building for the Core. (I will be building for the Photon in the future.) I also am not including <string.h> in the project. If Iām not using x=String(); or the typedef āString var;āā¦theoretically that library shouldnāt be included, either? FWIW I donāt get an error for not including <string.h> in a project referencing it.
@mdma sprintf has been moved to system firmware? I seem to recall reading another post last night saying that sprintf(); was being deprecated for 0.4.0 to save the 20KB of firmware space. Unfortunately, I canāt find that post, eitherā¦
Or are all libraries (including the non-used I2C, SPI, etc.) now being included no matter what? Does this mean that I need to figure out how to compile the Core firmware myself in order to manually exclude the unused libraries?
P.S. I donāt think Iām going to go the ASM route on this one. Itās not worth reinventing the wheel, inner tube, tire, valve stem, Schrater valveā¦AND the air to inflate the tire
But do we yet have a solution for unnecessarily large firmware due to unused libraries? Iām aware that the Particle IDE builds the project in the , meaning that I canāt just rename some firmware header files on my local system to exclude them from the build. Perhaps Particle IDE just needs an #exclude directive!
@WebDust21, oops . FWIW, itās pretty straightforward to setup a local build environment, especially for the Core. For one of my projects, I had to do that and strip out a lot of things, even including the whole serial port interface (which made debugging a bit tricky at times, I must admit). See here for the toolchain.
I wasnāt referring to you on the post by mdmaā¦I was referring to my former post about misunderstanding sprintf support as being deprecated in 0.4.0. Nothing personal .
Iām glad to hear that itās pretty straightforward to setup a local build environment. devKitPro was the very first toolchain that I was successfully able to install and use. If I start running out of memory, I guess thatāll be my first stop. I donāt think I could get away with removing serial port supportāyouāre a brave programmer to do that! Thanks for the link.
@kennethlimcp Iām looking inside a compiled BIN file, and thereās 537 bytes consumed with the following plain-text message:
** Even though the CC3000 supposedly supports WEP,
** we at Spark have never seen it work.
** If you control the network, we recommend changing it to WPA2.
Thanks! Wait about 7 seconds while I save those credentialsā¦
Awesome. Now weāll connect!
If you see a pulsing cyan light, your Spark Core
has connected to the Cloud and is ready to go!
Did someoneās code comments somehow get included into the project? As far as I know, thereās no way the Core/Photon could tell you any of the above if it wasnāt connected to the network, or was having problems. What in the world is this?
Everyone: you can check your BIN files in a plain-text editor. Turn word-wrap on, and down at the bottom of the file, youāll see the above text.
Well, this is what the serial terminal says when you input the Wifi credentials manually. So Iām guessing thatās what it is? Unless Iām misunderstanding youā¦
OK, I forgot about thatā¦
ā¦but Iām watching the āspace remainingā gauge count down, and was eying what looked to be some potential optimization!