If over half the payload is QNEthernet, have you explored reducing the feature set included with the underlying lwIP stack? For example, removing TCP or reducing the number of possible sockets (all protocols), or even reducing the memory size, etc. Some questions:
1. What is its current footprint?
2. Have you made any modifications that might increase its size?
3. Which has higher usage, RAM1 or RAM2? How much of each?
The footprint estimate is very crude. Starting from the build that produced the numbers in the first message I posted, I simply stubbed out the socket layer so all functions were empty, removed QNEthernet.h from all files where it appears and then fixed the few errors that showed up as a result. That then produced a total code size of around 380,000 so I was taking a first order approximation and calling 468K - 380K ~100K. I'm not striving for accuracy to the byte, just trying to get a read as to the order of magnitude involved.
All that said, the total code footprint is 194268, of which FLASHMEM keeps about 27k out of RAM1. RAM1 data usage is relatively lightweight at 32K and change leaving 294K available. RAM2 will be a bit bigger since I bumped from 8 to 16 TCP connections, but as shown by the build, about 80K RAM2 is used leaving 444K available. So that's just not a worry. Once I gert the rest of the code done, I may well stop trying to run from FLASHMEM, and just let the whole thing run from RAM1. I can't find it documentaed anywhere what sort of performance hit you take running from FLASHMEM, but I have noted another thread where someone had a routine that flat out crashed if run from FLASHMEM.
About the only modification I've made is bumping MEMP_NUM_TCP_PCB to 16, and to my understanding that mostly affects RAM2 usage for the buffers.
Higher usage is RAM1 by a factor of 3 to 1, but that's because of the code. Current build stats are:
Code:
1>------ Build started: Project: SmartHome, Configuration: Release x64 ------
1>Memory Usage on Teensy 4.1:
1> FLASH: code:194268, data:28620, headers:8532 free for files:7895044
1> RAM1: variables:32864, code:167396, padding:29212 free for local variables:294816
1> RAM2: variables:79488 free for malloc/new:444800
That doesn't include malloc / new, and using the various STL template classes that I am using will do a modest amount of allocation. Even so, I don't see RAM2 as being in any sort of danger.
As regards scaling back QNEthernet / Lwip, the only two things that I can obviously turn off are MDNS and IGMP. However attempts to do so have all resulted in the following error:
Code:
Build started...
1>------ Build started: Project: SmartHome, Configuration: Release x64 ------
1>F:\Dev\Arduino\libraries\QNEthernet\src\lwip\apps\mdns\mdns.c(73,2): error GE39423A9: #error "If you want to use MDNS with IPv4, you have to define LWIP_IGMP=1 in your lwipopts.h"
1> 73 | #error "If you want to use MDNS with IPv4, you have to define LWIP_IGMP=1 in your lwipopts.h"
etc. etc. So it looks like I have IGMP disabled, but haven't yet found the incantation required to disable MDNS.
#define LWIP_MDNS_RESPONDER 0
above the include of QNEthernet.h doesn't help.
Changing to:
#define LWIP_AUTOIP 0 /* 0 */
#define LWIP_DHCP_AUTOIP_COOP 0 /* 0 */
doesn't help, even though the comment above notes "Add both for mDNS". You'd think that setting both to zero as the comments suggest should do the trick, but apparently not. And lastly:
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0 /* 0 */
doesn't help. At this point I'm out of ideas for how to turn off mDNS.
As noted above, I'm not really stressing it at this point. If I can do it, great, if not, I don't think I'm anywhere near in trouble. Cutting
#include <sstream> and
#include <regex> significantly reduced the code size, they were something over half the entire code size between them when you compare the recent build stats above to my original post at the top of the thread.