LWIP and Heap

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: LWIP and Heap

Postby Giovanni » Mon May 25, 2020 5:35 pm

Moving and waiting for comments.

My points:
1) Mailboxes also need allocation.
2) There is no need to pre-initialize the pool, it can feed from the core allocator.
3) Heap should be an implicit fallback.

Giovanni

mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 times

Re: LWIP and Heap

Postby mikeprotts » Mon May 25, 2020 6:56 pm

1) I used the LWIP memory pools for mailboxes as it's LWIP specific code, but this can be from another ChibiOS Memory Pool for consistency.


2) This would avoid pre-defining the number of entries, so is a nicer option. Should I use chCoreAllocAligned or chCoreAlignedI as the provider to chPoolObjectInitAligned? I can experiment with this.

Should I allocate a small number (e.g. zero or one) to start and let the pool grow on demand? I think there will always be at least one of each type.

Should I create a pool for individual thread work area sizes if there's not already one available (not a trivial task), or keep the single size restriction (keeps code simpler)?

Should I use LWIP settings for either TCPIP_THREAD_SIZE or DEFAULT_THREAD_SIZE (as I would always expect these to exist), or the larger of the two? The only cases I could find were for tcpip, slip and snmp (although the lwipopts.h file I have included ppp thread settings).


3) I left the default to use HEAP if ChibiOS configured for heap, therefore the default will not change for most use cases. Should there be an explicit setting to not use heap in lwipopts.h, e.g.
#define CH_LWIP_USE_MEM_POOLS TRUE

Where is the preferred place for this sort of define when it relates to external code?

Mike

mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 times

Re: LWIP and Heap

Postby mikeprotts » Tue May 26, 2020 1:08 pm

1) I've a version with mbox from Memory Pool now.

2) I've checked and I need chCoreAlignedI as the provider.

Allocating on demand works fine.

TCPIP_MBOX_SIZE gives the mbox requirement


====
While testing I discovered I need to increase LWIP_THREAD_STACK_SIZE to 1024 (set at 672 in os/various/bindings/lwipthread.h) when under heavy load. However that's started separately and these settings have no effect on the main lwip thread.

Mike

mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 times

Re: LWIP and Heap

Postby mikeprotts » Tue May 26, 2020 4:30 pm

I've produced another version based on the earlier suggestions. For now it includes lwipopts.h which would use the following to enable the change:
#define CH_LWIP_USE_MEM_POOLS TRUE

I've used the TCPIP size settings to save adding another define, and this means a potential small waste of RAM if pool sizes don't match.

Anyone using existing code should see no change. If you disable heap (#define CH_CFG_USE_HEAP FALSE), it will fail to build unless you enable the new code, but that's unchanged from the current scenario.

Mike
Attachments
sys_arch.c.gz
(2.84 KiB) Downloaded 156 times

mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 times

Re: LWIP and Heap

Postby mikeprotts » Wed May 27, 2020 3:45 pm

Now testing on:
ST_STM32F4-DISCOVERY with STM32F4DIS-BB (STM32F407)
Olimex STM32-E407_REV_D (STM32F407)
ST_NUCLEO144_F429ZI
ST_NUCLEO144_F746ZG
ST_NUCLEO144_F767ZI
Custom board with STM32F767

Mike

mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 times

Re: LWIP and Heap

Postby mikeprotts » Wed May 27, 2020 3:51 pm

Are there any specific tests for lwip/ChibiOS, or a ChibiOS Makefile for the standard lwip tests?

Mike

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: LWIP and Heap

Postby Giovanni » Wed May 27, 2020 5:10 pm

No tests, it is an external component, we just have demo applications for it.

Giovanni


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 5 guests