lwIP, linker error with PPP enabled #2272

Closed
opened 2025-02-16 04:27:31 -06:00 by TheRealZago · 4 comments
TheRealZago commented 2025-02-16 04:27:31 -06:00 (Migrated from github.com)

When compiling a basic application with PPP enabled and support for authentication (PAP, CHAP and friends), the linker fails with the following error:

/Applications/ArmGNUToolchain/13.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld: CMakeFiles/PicoModem.dir/Users/zago/repo/pico-sdk/lib/lwip/src/netif/ppp/magic.c.o: in function `magic_churnrand':
[build] /Users/zago/repo/pico-sdk/lib/lwip/src/netif/ppp/magic.c:118:(.text.magic_churnrand+0x30): undefined reference to `sys_jiffies'

My lwipopts.h is loosely based on the file provided by the pico_w examples, with just a few additions:

#define NO_SYS 1
// ... omissis ...
#define PPP_SUPPORT 1
#define PAP_SUPPORT 1
#define CHAP_SUPPORT 1
#define MSCHAP_SUPPORT 1
#define PPP_SERVER 1

"HAL" is being provided by linking against pico_lwip_nosys.

Workaround

I've noticed pico_lwip_nosys already defines sys_now(), so I've exteded its job by adding my own library hook function in a dedicated source file.

// @file libhooks.c

#include "lwip/sys.h"
#include "hardware/timer.h"

u32_t sys_jiffies(void)
{
    return time_us_32();
}

Should I open a pull request with a cleaner SDK-side correction?

When compiling a basic application with PPP enabled and support for authentication (PAP, CHAP and friends), the linker fails with the following error: ``` /Applications/ArmGNUToolchain/13.3.rel1/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld: CMakeFiles/PicoModem.dir/Users/zago/repo/pico-sdk/lib/lwip/src/netif/ppp/magic.c.o: in function `magic_churnrand': [build] /Users/zago/repo/pico-sdk/lib/lwip/src/netif/ppp/magic.c:118:(.text.magic_churnrand+0x30): undefined reference to `sys_jiffies' ``` My `lwipopts.h` is loosely based on the file provided by the [pico_w examples](https://github.com/raspberrypi/pico-examples/blob/b6ac07f1946271de2817f94d8ffc0425ecb7c2a9/pico_w/wifi/lwipopts_examples_common.h), with just a few additions: ```c #define NO_SYS 1 // ... omissis ... #define PPP_SUPPORT 1 #define PAP_SUPPORT 1 #define CHAP_SUPPORT 1 #define MSCHAP_SUPPORT 1 #define PPP_SERVER 1 ``` "HAL" is being provided by linking against `pico_lwip_nosys`. # Workaround I've noticed `pico_lwip_nosys` already defines `sys_now()`, so I've exteded its job by adding my own library hook function in a dedicated source file. ```c // @file libhooks.c #include "lwip/sys.h" #include "hardware/timer.h" u32_t sys_jiffies(void) { return time_us_32(); } ``` Should I open a pull request with a cleaner SDK-side correction?
kilograham commented 2025-02-16 10:41:54 -06:00 (Migrated from github.com)

sounds good

sounds good
peterharperuk commented 2025-02-16 10:51:33 -06:00 (Migrated from github.com)

You might have to wrap it with #if NO_SYS as sys_jiffies is defined for free rtos? And maybe have another way of disabling it in case someone has their own implementation.

You might have to wrap it with #if NO_SYS as sys_jiffies is defined for free rtos? And maybe have another way of disabling it in case someone has their own implementation.
kilograham commented 2025-02-16 12:21:21 -06:00 (Migrated from github.com)

I think you can just put __weak on it; chances are that no one else has implemented it but still. this would go in already guarded code in lwip_nosys.c so should be fine

I think you can just put `__weak` on it; chances are that no one else has implemented it but still. this would go in already guarded code in lwip_nosys.c so should be fine
kilograham commented 2025-02-17 11:25:34 -06:00 (Migrated from github.com)

fix merged into develop

fix merged into develop
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#2272
No description provided.