Hello,
I am making this thread to track my attempts at running a C++ program on the second core and interacting with it thru Micropython.
In this case I am going to be trying to have https://github.com/bitluni/ESP32CompositeVideo running on the second core as a very basic Composite Video Text display. (Maybe something cooler in the future.)
I am going to assume I can just find the main function for micropython and shoe horn in the calls to set up a thread on the other processor. (I might switch which processor Micropython is on as I know the Video code needs to not be on the Core WIFI is on.) Then the rest of the issues will be setting up the thread safe interface between the two and having Micropython callable function to interact with it.
Before I do any of this I have to first get Micropython compiling on my server again so the next update may take some time.
Running C++ code on the second core.
Re: Running C++ code on the second core.
I am now able to built micropython again. I will be doing some tests with running stuff on the other core from C.
One thing I have to figure out is how to use C++ code in a c module in Micropython.
One thing I have to figure out is how to use C++ code in a c module in Micropython.
Re: Running C++ code on the second core.
So I found out how to make a cpp module in micropython but I have found that not even the example will compile for ESP32.
https://gist.github.com/wgaylord/55a4ea ... 115101decc
https://gist.github.com/wgaylord/55a4ea ... 115101decc
Re: Running C++ code on the second core.
Tell the compiler where mpconfigboard.h is, I've used this in the module's micropython.mk:
not sure if you need the last 2 flags, depends on your code.
Code: Select all
CXXFLAGS_USERMOD += -I$(BOARD_DIR) -Wno-error=cpp -Wno-error=sign-compare
Re: Running C++ code on the second core.
That seems to have worked.
Re: Running C++ code on the second core.
So I am running into issues with StoreProhibited Errors. Any idea how to track down what exactly is causing this? Like I have the ESP Stack Trace but I am not sure how to use that from a Micropython standpoint.
Re: Running C++ code on the second core.
If you have the esp stack trace then you can either cross-reference the addresses from firmware.map or use xtensa-esp32-elf-objdump with firmware.elf.
Re: Running C++ code on the second core.
Okay. Also figured out my issue. Turns out it really helps to be compiling for the GENERIC-SPIRAM if your going to be doing something that requires that extra ram.
Re: Running C++ code on the second core.
So I have made progress although I ran into an issue where the library I am trying to write an usermodule for uses C++ templating which when its included into the c shim causes the compiler to throw errors about the templating.
Also for some reason sometimes the C++ code can't see malloc and other functions that I know exist.
I was originally trying to port https://github.com/bitluni/ESP32CompositeVideo to be a usermodule but now I have moved to https://github.com/bitluni/ESP32Lib (Specifically the video parts) because the former has timing issues when the program is compiled with the cache-fix enabled causing the video to scroll down the screen.
Really hoping that in the future I could write this as a natmod if a way to access the IDF ever gets implmented.
Also for some reason sometimes the C++ code can't see malloc and other functions that I know exist.
I was originally trying to port https://github.com/bitluni/ESP32CompositeVideo to be a usermodule but now I have moved to https://github.com/bitluni/ESP32Lib (Specifically the video parts) because the former has timing issues when the program is compiled with the cache-fix enabled causing the video to scroll down the screen.
Really hoping that in the future I could write this as a natmod if a way to access the IDF ever gets implmented.