Not so beginner question about the compiler
Anyone know how I would get the SDK to compile a single function? I want to be able to send code over the network to the ESP and have it run the function already compiled
Ie. void SetupData(char* pData, uint32 Frame) This would populate data based on frame, but I want to be able to upload this into ram at RUNTIME, not just compile it into a function that would eat up space
Posted Jun 2, 2015, 9:29 AM UTC
55
I've no idea about the SDK, but if it's using a gcc-based toolchain, this is what I'd do:
make what's already on the esp into a library archive, then put your function in a C file and link against the library. tell the linker to resolve all symbols, then spit out a binary blob to send to the chip and execute from memory.
Note that you probably want to use -fPIC or similar if you want a function that doesn't need to be in a specific memory location.
Would I still need to link against the software, if the function doesn't need access to anything outside of the variables it has been given? Just needs to be able to read/write into the array, the external code would handle the actual IO based on the output.
if you're not calling any external functions or referencing any global variables, you should be able to do it with just the headers for the data structures without linking the existing code, yes.
Excellant thanks. Now to figure out if the toolchain actually supports position independant code.
Once thats done though, Can i just send the entire .o (or similar) file and cast it to a function, or do I have to do some parsing?
the object file (.o) contains a bunch of metadata that you don't really need for this application, use objdump to get a binary dump of the function's code alone.
Having said that, it shouldn't be too hard to parse the ELF file format, there's plenty of documentation around for it.