Editing Photon Firmware

Hello,
I want to compile a program that is all written and ready to go, i just need to make an edit to a spark-core library (default buffer size for tcp). I am not sure i understand what this entails.

Can I just go to to the build directory of the respective repository folder, run “make clean all” in cmd terminal, then compile my code normally in particle dev and flash it to the photon?

I know particle dev compiles based on all the files i have in the current directory Im working in, i.e. my .ino, .cpps, .h etc. but what is the default it is doing to compile the rest, i.e. the photon firmware etc

Thanks,
Gary

My understanding of how it all works is as follows. User firmware (when using Dev or Build) is compiled against a dynamically linked library in the cloud (that is the system firmware) and a stand-alone binary is created and transferred to the Photon and written to the user firmware space in flash. If you are using Build, the cloud will also handle updating system firmware when an update is available.

To compile your own version of the system firmware, you have to use the CLI tools, as you noted. From there, however, you’d (if I understand this correctly) have to compile your user firmware using the CLI to compile against your system firmware. Although, the change you’re making may not really make a difference as you aren’t changing any APIs, so you can probably get away with compiling it normally.

I’m sure the Elites will correct any misunderstanding I may have bestowed. lol

Thanks for the reply, I’m not sure I understand “have to compile your user firmware using the CLI to compile against your system firmware.” but like you said maybe an elite will clear it up.

It would also be good to clarify one thing: do all .cpp files and the .ino go in core-firmware/src and all headers in core-firmware/inc ?

EDIT: I am now encountering problems with PIN_MODE i believe, trying to learn how to “make clean all” with develop branch, no luck yet

getting access denied errors etc trying to build develop firmware =(

no such file or directory
../build/arm-tlm.mk:15: *** "Unknown architecture ''".  Stop.
make[1]: Leaving directory `C:/PHOTON MASTER for CLI compiling/firmware-develop/
communication'
make: *** [clean_communication] Error 2

C:\PHOTON MASTER for CLI compiling\firmware-develop>make clean all PLATFORM=phot
on
Building firmware for Production Photon, platform ID: 6, product ID: 6
make -C ./communication clean
make[1]: Entering directory `C:/PHOTON MASTER for CLI compiling/firmware-develop
/communication'
../build/arm-tlm.mk:6: C:: Permission denied
../build/arm-tlm.mk:6: .: Permission denied
../build/arm-tlm.mk:6: .: Permission denied
../build/arm-tlm.mk:6: .: Permission denied
../build/arm-tlm.mk:6: compiling/firmware-develop/build/top-level-module.mk: No
such file or directory
../build/arm-tlm.mk:15: *** "Unknown architecture ''".  Stop.
make[1]: Leaving directory `C:/PHOTON MASTER for CLI compiling/firmware-develop/
communication'
make: *** [clean_communication] Error 2

C:\PHOTON MASTER for CLI compiling\firmware-develop>

If you are building the develop branch you need to be aware that this might be in an unstable state at any given time, hence you have to signal this understanding by setting the compiler flag PARTICLE_DEVELOP=1

The thing about building with CLI against private firmware is new to me. CLI currently always builds against latest, but if your private system is compatible, it could well work (as would the other way of building).

But could you not just alter the app code to use the “buffered” versions of client.read()/client.write() which act upon a user buffer?

im trying make all clean PARTICLE_DEVELOP=1 PLATFORM=photon

still getting same access denied errors.

i need to change

#define TCPCLIENT_BUF_MAX_SIZE 1024

in a header library, is there a more simple way than editing firmware?


(ScruffR: I edited your format, try edit to see how it’s done ;-))

Have you tried make from within the modules folder?

no I will try that, sorry about that crazzzy formatting XD

It might be “superstition” but even while blanks are allowed in directory/file names, I try to avoid them wherever possible :wink:
Some programs don’t wrap the path in double quotes and hence might see multiple parameters where it only is one “blank-broken” path.

when trying make clean all PARTICLE_DEVELOP=1 PLATFORM=photon , the command line paused a second, then started printing the line over and over that its trying to access the directory or whatever =*( . I tried both with the file named makefile as well as Makefile (which i thought it looked for)

ahhaah the spaces might have been it

Thanks a bundle, now wanna make sure what I was really tryign to do is correct if you dont mind:
I want to change something in the firmwares file spark_wiring_tcpclient.cpp , all i do is change it, put my .ino’s in src and .h’s in inc, and do a make clean all on the module folder and it should compile with my change?

Damn, also getting a nothing to be done for ‘all’ on compile
EDIT: Looks like this means nothing more than there were no changes if I am not mistaken http://stackoverflow.com/questions/32903139/why-is-make-printing-make-nothing-to-be-done-for-all

To build your own app, you’d need to put the ino and its dependencies into a users/applications/<yourapp> directory and add APP=<yourapp>

See here
https://github.com/spark/firmware/blob/develop/docs/build.md


You should not use .ino but proper .cpp files for your local build.
And you can alter any file you want on your local build :wink:

ok thanks,

its a bit confusing because i believe that (firmware-develop) is different than how firmware-current is done.

I was most concerned with whether or not my changes to the “straight from github” files would be changed i.e. spark default libraries

No worries, you won’t have write access to the Particle repos :wink: