$npx -y skills add easyzoom/aix-skills --skill lwip-integrationUse when integrating, porting, configuring, or debugging lwIP TCP/IP stack, netif drivers, memory pools, sys_arch, DHCP, TCP, UDP, or embedded networking issues
| 1 | # lwIP Integration |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Use this skill to integrate lwIP by separating hardware Ethernet/Wi-Fi drivers, `netif` glue, memory pools, threading model, and protocol configuration. A successful port proves link, IP configuration, packet RX/TX, and resource stability under load. |
| 6 | |
| 7 | ## When To Use |
| 8 | |
| 9 | Use this skill when: |
| 10 | |
| 11 | - The user wants to add or debug lwIP on bare metal, FreeRTOS, RT-Thread, Zephyr, vendor SDKs, or custom network drivers. |
| 12 | - The issue involves `lwipopts.h`, `sys_arch`, `netif`, DHCP, TCP/UDP, pbufs, memory pools, packet loss, or hard faults in networking. |
| 13 | - The target uses Ethernet, Wi-Fi, PPP, SLIP, or a vendor network interface. |
| 14 | |
| 15 | Do not use this skill when the physical link or board interface is not proven. Use `hardware-interface-debug` first for PHY, RMII/MII, clocks, or wiring issues. For FreeRTOS-native TCP/IP, use `freertos-plus-tcp-integration`. For MQTT over lwIP, use `mqtt-embedded-integration` after basic connectivity works. |
| 16 | |
| 17 | ## First Questions |
| 18 | |
| 19 | Ask for: |
| 20 | |
| 21 | - MCU/SoC, network interface, PHY/module, RTOS, and lwIP version. |
| 22 | - Driver source: vendor SDK, custom MAC driver, Wi-Fi module, or simulator. |
| 23 | - Threading model: NO_SYS raw API, tcpip_thread, socket/netconn API, or RTOS integration. |
| 24 | - `lwipopts.h`, memory sizes, pbuf pool settings, and enabled protocols. |
| 25 | - Current symptom: no link, no IP, DHCP timeout, ping fails, TCP stalls, memory exhaustion, or crash. |
| 26 | - Packet/log evidence: link status, IP address, ARP, ping, Wireshark, counters, or asserts. |
| 27 | |
| 28 | ## Integration Checklist |
| 29 | |
| 30 | 1. Confirm link before IP. |
| 31 | Verify PHY/module link, MAC address, link callbacks, and carrier status before debugging DHCP or TCP. |
| 32 | |
| 33 | 1. Confirm `netif` glue. |
| 34 | `netif_add`, input path, output path, MTU, flags, hostname, and link/status callbacks must match the driver. |
| 35 | |
| 36 | 1. Match threading model. |
| 37 | Do not call raw API from arbitrary threads. Use tcpip callbacks or socket/netconn APIs according to configuration. |
| 38 | |
| 39 | 1. Size memory deliberately. |
| 40 | Check `MEM_SIZE`, `MEMP_NUM_*`, `PBUF_POOL_SIZE`, TCP windows, mailbox sizes, and stack sizes. |
| 41 | |
| 42 | 1. Implement OS abstraction if needed. |
| 43 | For RTOS ports, `sys_arch` must provide semaphores, mutexes, mailboxes, timeouts, and critical sections. |
| 44 | |
| 45 | 1. Verify with layered tests. |
| 46 | Link, static IP, ARP, ping, UDP echo, TCP connect, sustained transfer, and reconnect. |
| 47 | |
| 48 | ## Common Failures |
| 49 | |
| 50 | - DHCP fails because link callback never reports up. |
| 51 | - Ping fails because ARP output path or MAC address is wrong. |
| 52 | - TCP stalls because pbufs or mailboxes are exhausted. |
| 53 | - Random crashes from raw API calls outside tcpip_thread. |
| 54 | - Cache/DMA incoherency corrupts RX/TX buffers. |
| 55 | - Stack overflow in tcpip_thread or network driver task. |
| 56 | |
| 57 | ## Verification |
| 58 | |
| 59 | Before claiming lwIP works: |
| 60 | |
| 61 | - State interface, RTOS mode, API style, and IP configuration. |
| 62 | - Confirm link status, MAC address, IP address, gateway, and netmask. |
| 63 | - Confirm ping or UDP/TCP test with counters. |
| 64 | - Report memory pool usage or at least configured pool sizes. |
| 65 | - If DMA/cache is involved, state cache maintenance policy. |
| 66 | |
| 67 | ## Example |
| 68 | |
| 69 | User: |
| 70 | |
| 71 | ```text |
| 72 | lwIP DHCP 一直拿不到 IP。 |
| 73 | ``` |
| 74 | |
| 75 | Agent: |
| 76 | |
| 77 | 1. Asks for PHY link status, `netif` setup, `lwipopts.h`, RTOS mode, and DHCP logs. |
| 78 | 1. Confirms link callback and RX path before changing DHCP settings. |
| 79 | 1. Tests static IP ping to separate driver/link problems from DHCP problems. |