Respect FNET MDNS defines in Teensy NativeEthernet

danielkr

Member
Hi Paul,

I am working on a private Teensy project (controlling my model rail way, German forum post here) where I sometimes exceed the Teensy 4.1 RAM1 or flash limits (especially with the debug build).
To avoid this, I disable some FNET configs in fnet_user_config.h (no TLS + delete mbedtls source, disable MDNS for example).
In the NativeEthernet libraries supplied by you, the FNET configs are not respected.
Could you please add #if FNET_CFG_MDNS ... #endif to NativeMdns.cpp (#21...82) and NativeEthernet.h (#379...400)?

Thanks
Daniel
 
Do you feel like giving the QNEthernet library a try? It should be just about a drop-in replacement. You can selectively disable all the features.
 
Hi shawn,
I tried your library and it is a very nice drop-in replacement. Very good work and good features. At the moment however, it is too big for my code setup. I definitely have it on my list for later optimizations and to see which library I like more.
Best Regards
Daniel
 
I’m curious, in the interests of reducing size, what is too big? For example, how much bigger is your compiled code size (including FLASH and RAM1 usage) when comparing both builds? I’ve seen people accidentally include both libraries when switching.
 
Hi shawn,
here is the current output of QNEthernet vs NativeEthernet:
Code:
nativeethernet:
teensy_size:   FLASH: code:1487336, data:70688, headers:9176   free for files:6559264
teensy_size:    RAM1: variables:79972, code:395372, padding:30612   free for local variables:18332
teensy_size:    RAM2: variables:24768  free for malloc/new:499520

qnethernet:
teensy_size:   FLASH: code:1525680, data:80928, headers:8236   free for files:6511620
teensy_size:    RAM1*: variables:91168, code:431644, padding:27108   free for local variables:-25632
teensy_size:    RAM2: variables:67904  free for malloc/new:456384

I did not modify any settings/defines for QNEthernet.
Also see our discussion a while ago here.

Best Regards
Daniel
 
So we’re still at about 43k bigger in RAM1…

Some thoughts and questions:
* Which version of QNEthernet are you using?
* How do they compare when compiling with the “smallest size” option?
* In lwipopts.h, what happens when you reduce MEMP_NUM_UDP_PCB, MEMP_NUM_TCP_PCB, and MEMP_NUM_TCP_PCB_LISTEN to the values you need? (Leaving at least one UDP for mDNS.)
* I’m curious to see also what happens when you disable mDNS. To do this, follow the steps at line 549 of lwipopts.h. (Including setting LWIP_MDNS_RESPONDER to zero.)
 
Hi shawn,
please find the statistics below:
NativeEthernet:
Code:
-Og -g
teensy_size:   FLASH: code:1487336, data:70688, headers:9176   free for files:6559264
teensy_size:    RAM1: variables:79972, code:395372, padding:30612   free for local variables:18332
teensy_size:    RAM2: variables:24768  free for malloc/new:499520

-Os -g
teensy_size:   FLASH: code:1308328, data:61464, headers:8992   free for files:6747680
teensy_size:    RAM1: variables:70180, code:217272, padding:12104   free for local variables:224732
teensy_size:    RAM2: variables:24768  free for malloc/new:499520
QNethernet:
Code:
-Og -g
teensy_size:   FLASH: code:1525680, data:80928, headers:8236   free for files:6511620
teensy_size:    RAM1*: variables:91168, code:431644, padding:27108   free for local variables:-25632
teensy_size:    RAM2: variables:67904  free for malloc/new:456384

-Os -g
teensy_size:   FLASH: code:1330144, data:70680, headers:8196   free for files:6717444
teensy_size:    RAM1: variables:80288, code:237144, padding:25000   free for local variables:181856
teensy_size:    RAM2: variables:67904  free for malloc/new:456384

-Og -g without MDNS as instructed by lwipopts.h:549
teensy_size:   FLASH: code:1518660, data:80928, headers:9112   free for files:6517764
teensy_size:    RAM1: variables:90912, code:424780, padding:1204   free for local variables:7392
teensy_size:    RAM2: variables:67712  free for malloc/new:456576

-Os -g without MDNS as instructed by lwipopts.h:549
teensy_size:   FLASH: code:1323516, data:69656, headers:8680   free for files:6724612
teensy_size:    RAM1: variables:79008, code:230664, padding:31480   free for local variables:183136
teensy_size:    RAM2: variables:67712  free for malloc/new:456576

The -g comes from the build.txt of teensy and is always present.
-Os definitely helps and will be my option for later use, when standard tricks no longer help ;)

Thanks
Daniel
 
Last edited:
I see you have line 519. That’s supposed to be 549. Also, did you try lowering those PCB values? I’m interested in helping reduce the size.
 
That was a typo in this post, I edited the correct values.
Reducing the PCB for TCP and UDP to 4 (from 8), now gives:
Code:
-Og -g
teensy_size:   FLASH: code:1526256, data:81952, headers:8684   free for files:6509572
   RAM1*: variables:92192, code:432220, padding:26532   free for local variables:-26656
teensy_size:    RAM2: variables:67136  free for malloc/new:457152
 
Last edited:
Back
Top