-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MPPT 2420 LC Improvements Required #125
Comments
Good point. Memory optimization is a long-standing issue on my ToDo list :) If you didn't see yet, Zephyr provides an easy way to see the memory consumption in the different areas of the firmware, just run Probably the best way to gain large amounts of RAM is to use only two (mutex-protected) buffers for all ThingSet operations. Currently we have 5 different buffers of something between 512 and 1024 bytes each: RX and TX for the CAN, RX and TX for the serial and one buffer for data storage. As a short term solution I think reducing the ISR stack size as you suggested is definitely fine. For some of the other stacks I'm a bit more afraid and we'd probably have to run a careful analysis with different firmware options. Zephyr's Thread Analyzer can help with this. We could apply some settings only for the MPPT 2420 LC in its |
Indeed, as I am new to the Zephyr eco system, I did not knew the ram&rom report. I am used to read the GCC linker map files (which I did when there was still platformio support). Reducing memory footprint by combining buffers now used for different purpose in different threads can help but is a challenge on its own because using mutexes to gain exclusive access to shared resources may lead to serious priority inversion problems. Imaging the serial code using the TX buffer and the CAN thread wants to sent something. It has to wait until the serial code has sent all the bits. E.g. if the message is 500 bytes at 115200 bits per second, this takes about 40ms. Side topic: I struggle to understand how I can easily debug ZephyrCode with a debug probe like the STLINK. It was easy using Platformio, just start the debug build/flash and I could easily set breakpoints and inspect variables WITHOUT having to resort to command line GDB or similar things. What is the recommended approach for Zephyr/west ? The documentation here https://docs.zephyrproject.org/latest/guides/flash_debug/host-tools.html#flash-debug-host-tools was not helpful for me. |
Yes, true, it might become tricky to use only one common "ThingSet database" with a single set of buffers.
As far as I understand, |
TL;DR It is impossible without workarounds to enabled OLED on the MPPT 2420 LC due to insufficient RAM. Question is if and how to integrate these workarounds into the official setup
When updating my MPPT 2420 LC to the new v21 line based on Zephyr, I noticed that it was impossible to compile my (previously working) configuration from the mbed times. I.e. when selecting CAN and Serial plus OLED, it would not fit the content in the RAM.
Reason is the meager 16k of RAM of the STM32F072 in combination with the additional requirements of multi threaded operation (mostly stack sizes).
Even my actually required configuration of OLED and Serial Thingset doesn't fit. With some adjustments, a bit of code analysis and some trial and error, it turns out that it is safe to reduce the ISR stack allocation to 1KB, and to reduce the TX buffer by half to 512. Since I don't need CAN anymore (switched to ESP32 comm) I wanted to get rid of CAN as well. Just turning of the thingset CAN part unfortunately does not turn off the Zephyr CAN driver which eats valuable RAM without any benefit.
It is now easy to solve this by adding the appropriate settings to prj.conf:
Question now is, how to make this easier for others to use this knowledge. We can't just put this in prj.conf (maybe we could with the commented out, was it is already done for other settings. Most of this applies only to MPPT 2420 with its low RAM, but on the other hand, turning of the CAN driver if not being by ThingSet used makes sense for all. And reducing the default ISR stack size should be done only if necessary as it may unexpected problems e.g. if additional drivers would require more ISR stack.
My knowledge of the Zephyr eco system is not good enough to see how to accomplish this, but I guess it is possible. This would allow users of the "old" MPPT 2420 like me to upgrade more easily.
The text was updated successfully, but these errors were encountered: