Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
96ac537
adding net_ppp
elcritch Sep 1, 2025
f50e62d
adding net_ppp
elcritch Sep 1, 2025
36616c3
adding net_ppp
elcritch Sep 1, 2025
62d17a3
adding net_ppp
elcritch Sep 1, 2025
7f386c3
adding net_ppp
elcritch Sep 1, 2025
f172a88
Merge branch 'devel' into net_ppp
elcritch Sep 1, 2025
1fce3f4
update defaults
elcritch Sep 1, 2025
8babdad
update defaults
elcritch Sep 1, 2025
673c965
update defaults
elcritch Sep 1, 2025
ced706e
ppp connect example
elcritch Sep 1, 2025
53d2a00
ppp
elcritch Sep 1, 2025
16ec258
usb
elcritch Sep 1, 2025
450cc85
tests
elcritch Sep 1, 2025
b8278ba
usb
elcritch Sep 1, 2025
e8250d0
usb
elcritch Sep 1, 2025
1d1b929
usb
elcritch Sep 1, 2025
e20e127
usb
elcritch Sep 1, 2025
57aca90
usb
elcritch Sep 1, 2025
b2266cf
usb
elcritch Sep 1, 2025
d76837a
usb
elcritch Sep 1, 2025
d9a86cb
usb
elcritch Sep 1, 2025
ae67898
usb
elcritch Sep 1, 2025
bcf58e8
usb
elcritch Sep 1, 2025
a64b3d7
usb
elcritch Sep 1, 2025
7909623
usb
elcritch Sep 1, 2025
ddc8896
usb
elcritch Sep 1, 2025
b7cd1ad
usb
elcritch Sep 1, 2025
dd53790
usb
elcritch Sep 1, 2025
ffce0fb
usb
elcritch Sep 1, 2025
6d264df
usb
elcritch Sep 1, 2025
036be98
usb
elcritch Sep 1, 2025
bf8548c
usb
elcritch Sep 1, 2025
3861b44
usb
elcritch Sep 1, 2025
4719dce
usb
elcritch Sep 1, 2025
696f09b
usb
elcritch Sep 2, 2025
a999d85
usb
elcritch Sep 2, 2025
a1f3b70
usb
elcritch Sep 2, 2025
4e85848
usb
elcritch Sep 2, 2025
40d4231
usb
elcritch Sep 2, 2025
6cd737d
usb
elcritch Sep 2, 2025
f0a9c74
usb
elcritch Sep 2, 2025
2399083
usb
elcritch Sep 2, 2025
c7aa196
fixups
elcritch Sep 2, 2025
382d2e8
fixups
elcritch Sep 2, 2025
84c335e
fixups
elcritch Sep 2, 2025
14fe6e5
fixups
elcritch Sep 2, 2025
07ab549
fixups
elcritch Sep 2, 2025
7222828
fixups
elcritch Sep 2, 2025
7d68fd9
fixups
elcritch Sep 2, 2025
0ff5d18
add disclean
elcritch Sep 2, 2025
01814c4
fixups
elcritch Sep 2, 2025
7f0a4d3
fixups
elcritch Sep 2, 2025
c810eae
fixups
elcritch Sep 2, 2025
75737ac
fixups
elcritch Sep 2, 2025
c6360b3
fixups
elcritch Sep 2, 2025
025bf19
fixups
elcritch Sep 2, 2025
268aae3
fixups
elcritch Sep 2, 2025
a40b553
fixups
elcritch Sep 2, 2025
8de2d57
fixups
elcritch Sep 2, 2025
b4cc155
cleanups
elcritch Sep 2, 2025
c7a80df
cleanups
elcritch Sep 2, 2025
8f5b99e
set ula address
elcritch Sep 2, 2025
d67341c
set ula address
elcritch Sep 2, 2025
e12f29f
try mummy
elcritch Sep 2, 2025
62cb505
try mummy
elcritch Sep 2, 2025
a7df965
try mummy
elcritch Sep 2, 2025
c0dcf3b
cleanup
elcritch Sep 3, 2025
c36ea89
cleanup
elcritch Sep 3, 2025
c9c7c5f
cleanup
elcritch Sep 3, 2025
9e42a50
build on host
elcritch Sep 3, 2025
8813e3b
build on host
elcritch Sep 3, 2025
d683c2a
fix ip family affinity
elcritch Sep 3, 2025
7afd0ef
fix ip family affinity
elcritch Sep 3, 2025
5fa14f2
fix ip family affinity
elcritch Sep 3, 2025
2080eb4
fix ip family affinity
elcritch Sep 3, 2025
d4b2fe6
fix ip family affinity
elcritch Sep 3, 2025
8d83e0e
fix ip family affinity
elcritch Sep 3, 2025
6b4347a
tcp echo
elcritch Sep 3, 2025
7956141
tcp echo
elcritch Sep 3, 2025
684e04a
tcp echo
elcritch Sep 3, 2025
2e5c402
tcp echo
elcritch Sep 3, 2025
2078b94
tcp echo
elcritch Sep 3, 2025
fccd505
tcp echo
elcritch Sep 3, 2025
9315100
tcp echo
elcritch Sep 3, 2025
0afb1fb
tcp echo
elcritch Sep 3, 2025
74324cd
tcp echo
elcritch Sep 3, 2025
015817c
udp echo
elcritch Sep 3, 2025
8847b67
udp echo
elcritch Sep 3, 2025
fe711ec
udp echo
elcritch Sep 3, 2025
e613991
bump version
elcritch Sep 4, 2025
cf89a01
cleanup
elcritch Sep 4, 2025
64eff9f
fastrpc
elcritch Sep 4, 2025
2a92066
fastrpc
elcritch Sep 4, 2025
9ef850c
fastrpc
elcritch Sep 4, 2025
a277922
nimNetSocketExtras note
elcritch Sep 4, 2025
befa3ff
nimNetSocketExtras note
elcritch Sep 4, 2025
b3a0839
nimIoselectorEventfd
elcritch Sep 4, 2025
2aaa726
nimIoselectorEventfd
elcritch Sep 4, 2025
5cca937
old logs
elcritch Sep 4, 2025
39cba21
old logs
elcritch Sep 4, 2025
672ba51
old logs
elcritch Sep 4, 2025
42afe45
old logs
elcritch Sep 4, 2025
3a37345
old logs
elcritch Sep 4, 2025
d03cb93
update esp_events
elcritch Sep 5, 2025
e6f5994
esp events
elcritch Sep 5, 2025
3f444ba
update espevents
elcritch Sep 5, 2025
fd8bc33
updates
elcritch Sep 5, 2025
93f3564
updates
elcritch Sep 5, 2025
c2b33b7
updates
elcritch Sep 5, 2025
cd38f55
updates
elcritch Sep 5, 2025
8035992
updating wifi example
elcritch Sep 5, 2025
9d27198
fixing types
elcritch Sep 5, 2025
60519a1
fixing types
elcritch Sep 5, 2025
a474e53
update wifi example
elcritch Sep 5, 2025
870bf46
update wifi example
elcritch Sep 5, 2025
0a605a1
update wifi example
elcritch Sep 5, 2025
2b10b78
update wifi example
elcritch Sep 5, 2025
e603be6
update wifi example
elcritch Sep 5, 2025
91d2f20
update wifi example
elcritch Sep 5, 2025
023a787
update wifi example
elcritch Sep 5, 2025
c7a723f
update wifi example
elcritch Sep 5, 2025
01181ba
update wifi example
elcritch Sep 5, 2025
2f20936
update wifi example
elcritch Sep 5, 2025
7ca187a
update wifi example
elcritch Sep 5, 2025
7189f41
update wifi example
elcritch Sep 5, 2025
6328a17
update wifi example
elcritch Sep 5, 2025
5ed0cb3
update wifi example
elcritch Sep 5, 2025
7fd516f
going back to callback style rpc methods
elcritch Sep 5, 2025
ccaa352
going back to callback style rpc methods
elcritch Sep 5, 2025
fff0895
exports
elcritch Sep 5, 2025
0e88923
exports
elcritch Sep 5, 2025
687e8c9
exports
elcritch Sep 5, 2025
6fc687d
exports
elcritch Sep 5, 2025
91b5da4
cleanup
elcritch Sep 9, 2025
b943d93
cleanup
elcritch Sep 9, 2025
eeb37c5
cleanup
elcritch Sep 9, 2025
3f1d60e
cleanup
elcritch Sep 9, 2025
b1c093a
init ledc module
elcritch Sep 15, 2025
cb91d68
updates
elcritch Sep 25, 2025
1f9b671
updates
elcritch Sep 25, 2025
c9a3c3b
updates
elcritch Sep 25, 2025
86e4264
updates
elcritch Sep 25, 2025
6750130
updates
elcritch Sep 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions esp-idf-examples/net_pppos_usb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
nim.cfg
main/nimcache
*.out
.DS_Store

.tool-versions
*.dSYM/
/*.png
nimble.develop
nimble.paths
deps
sdkconfig
build/
sdkconfig.old
.cache/
managed_components/
41 changes: 41 additions & 0 deletions esp-idf-examples/net_pppos_usb/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Repository Guidelines

## Project Structure & Module Organization
- main/: Nim sources and component config. Entrypoint: main/main.nim. Generated C lives in main/nimcache/.
- deps/: Vendored Nim dependencies (nesper, unittest2, etc.). Managed by Nimble/Atlas.
- build/: ESP‑IDF CMake/Ninja outputs and flash args. Not for commits.
- CMakeLists.txt: Top‑level ESP‑IDF project file.
- config.nims, nim.cfg: Nim/nesper build configuration and include paths.
- sdkconfig, sdkconfig.defaults, partitions.csv: ESP‑IDF configuration and partition table.

## Build, Test, and Development Commands
- nim espBuild: Compile Nim and build the ESP‑IDF project (preferred dev loop).
- nim espCompile: Compile Nim to C into main/nimcache/ (no ESP‑IDF build).
- idf.py set-target esp32s3: Ensure target matches config.nims.
- idf.py -p /dev/ttyUSB0 flash monitor: Flash and open serial monitor (adjust port).
- idf.py build: Rebuild from generated C when Nim hasn’t changed.
- Clean: idf.py fullclean && rm -rf main/nimcache

Environment: export IDF_PATH and source "$IDF_PATH/export.sh" before building.

## Coding Style & Naming Conventions
- Indentation: 2 spaces; keep lines concise.
- Nim style: camelCase procs, PascalCase types, UPPER_SNAKE constants. Exported symbols end with *.
- Modules: lower_snake filenames (e.g., ppp_client.nim).
- Formatting: nimpretty --indent:2 main/*.nim
- Use nesper APIs where possible; isolate raw ESP‑IDF calls behind small Nim wrappers.

## Testing Guidelines
- Current repo has no tests. Add Nim tests under tests/ using unittest2 (deps/unittest2).
- Naming: tests/test_*.nim (e.g., tests/test_ppp.nim).
- Run: nim c -r tests/test_ppp.nim. Consider a nimble test task for CI later.

## Commit & Pull Request Guidelines
- Commits: short, imperative summaries (e.g., "ppp: add link setup").
- PRs: include purpose, build/flash steps, linked issues, and serial logs/screenshots for hardware changes.
- Scope: keep changes focused; avoid committing build/ outputs or local sdkconfig changes unless intentional.

## Security & Configuration Tips
- Do not commit credentials or secrets in sdkconfig or sources.
- Match target to hardware (esp32s3 by default in config.nims); update if using another SoC.
- Document required pins/peripherals in PRs when relevant.
6 changes: 6 additions & 0 deletions esp-idf-examples/net_pppos_usb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(net_pppos_usb)
32 changes: 32 additions & 0 deletions esp-idf-examples/net_pppos_usb/README-pppos-dualcdc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
PPPoS over USB CDC (dual CDC)

Overview
- CDC ACM 0: PPP data channel feeding `esp_netif` (PPPoS)
- CDC ACM 1: TinyUSB console for ESP logs and stdio

Files
- `ppp_connect_usb_dualcdc.c`: C example setting up two CDC interfaces, PPP + console.
- `ppp_connect_usb_dualcdc.nim`: Nim example with equivalent behavior.

Key Config (menuconfig)
- Component config → TinyUSB → Device
- Enable TinyUSB device stack
- Enable CDC and set `CDC count` to `2` or more
- Adjust CDC RX/TX buffer sizes as needed
- Component config → LWIP
- Enable PPP support (esp-netif PPP)

Usage Notes
- PPP frames are read from CDC0 and passed to `esp_netif_receive`; TCP/IP replies transmit via CDC0.
- Console/log output is redirected to CDC1 using `esp_tusb_init_console(TINYUSB_CDC_ACM_1)`.
- On the host, two serial devices will appear; attach your PPP dialer to the first, and a terminal to the second for logs.

API Entrypoints
- C: `example_ppp_connect_dualcdc()` / `example_ppp_shutdown_dualcdc()`
- Nim: `examplePppConnectDualCdc()` / `examplePppShutdownDualCdc()`

References
- `ppp_connect_usb.c`: single-CDC PPPoS reference (upstream ESP-IDF example)
- `tests/c_headers/idf-usb/device/tusb_console/main/tusb_console_main.c`: TinyUSB console redirection
- `tusb_composite_msc_serialdevice.nim`: example TinyUSB CDC usage from Nim

53 changes: 53 additions & 0 deletions esp-idf-examples/net_pppos_usb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
USB Networking Modes (PPP and NCM)

Overview
- PPPoS dual-CDC (default):
- CDC0 = PPP data channel for `esp_netif`.
- CDC1 = USB console/log output via TinyUSB console.
- Files: `ppp_connect_usb_dualcdc.nim`, `ppp_connect_usb_dualcdc.c`.

- NCM-as-Ethernet dual-CDC:
- Networking over TinyUSB NCM bound to an Ethernet-like `esp_netif`.
- CDC1 = USB console/log output via TinyUSB console.
- File: `tusb_ncm_eth_dualcdc.nim`.

Alternate (bridge) example
- `tusb_ncm.nim`: Bridges USB NCM <-> WiFi STA (packets forward both ways). Not used by `main.nim` by default.

Selecting Mode
- Default (PPPoS + CDC console): build as-is.
- NCM-as-Ethernet + CDC console: pass `-d:RUN_NCM` to Nim build (e.g., in your Atlas task or Nim command).
- `main.nim` imports and runs `usb/tusb_ncm_eth_dualcdc.runUsbNcmEthWithConsole()` when `RUN_NCM` is defined.

Kconfig Requirements
- Common:
- Enable TinyUSB device stack.
- Enable CDC class; set CDC count accordingly (2 for dual console + data).
- PPP mode:
- LWIP → Enable PPP support.
- NCM-as-Ethernet mode:
- TinyUSB → Enable NET (NCM) device class.
- DHCP client runs on the device (default ETH netif config). Ensure host provides DHCP or set static IP as needed.

Endpoint-safe defaults
- PPP mode (default): `sdkconfig.defaults` (or `sdkconfig.defaults.ppp`) sets CDC count = 2 and disables NCM.
- NCM mode: use `sdkconfig.defaults.ncm` to enable NCM and set CDC count = 1 (console only).
- Having both NCM and two CDCs may exceed endpoint limits on some targets.

Host Expectations
- PPPoS:
- Host sees two serial ports. Attach PPP dialer to CDC0; logs on CDC1.
- NCM-as-Ethernet:
- Host enumerates a USB network interface. Device requests IP via DHCP; logs on CDC1.

Useful Tweaks
- CDC RX/TX buffer size: TinyUSB → CDC → adjust `CONFIG_TINYUSB_CDC_RX_BUFSIZE`/`TX_BUFSIZE`.
- Console over USB: handled via `esp_tusb_init_console(TINYUSB_CDC_ACM_1)` in the dual-CDC samples.

Entrypoints
- PPP: `examplePppConnectDualCdc()` / `examplePppShutdownDualCdc()`.
- NCM ETH: `runUsbNcmEthWithConsole()` / `stopUsbNcmEthWithConsole()`.

Switching modes
- PPP (default): build normally.
- NCM: either pass `-d:RUN_NCM` at build time or temporarily copy `sdkconfig.defaults.ncm` to `sdkconfig.defaults` and reconfigure.
16 changes: 16 additions & 0 deletions esp-idf-examples/net_pppos_usb/config.nims
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
switch("define", "ESP_IDF_VERSION=5.5")
switch("define", "esp32s3") # or other variants
switch("define", "nimNetSocketExtras")
switch("define", "nimIoselectorEventfd")
# switch("define", "TcpEchoServer")
# switch("define", "UdpEchoServer")
switch("define", "FastRpcServer")

switch("define", "McuUtilsLoggingLevel:lvlInfo")
# switch("define", "RUN_NCM")

patchFile("stdlib", "ioselectors_select", "../../src/nesper/networking/ioselectors_select_patch.nim")

patchFile("stdlib", "cpuinfo", "main/cpuinfo.nim")

include nesper/build_utils/builds
39 changes: 39 additions & 0 deletions esp-idf-examples/net_pppos_usb/dependencies.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
dependencies:
espressif/esp_tinyusb:
component_hash: 96d232ced7afe1976119b62f7fbf1944a2a78b36228ff6f7b9318394ac1153cc
dependencies:
- name: idf
require: private
version: '>=5.0'
- name: espressif/tinyusb
registry_url: https://components.espressif.com
require: public
version: '>=0.14.2'
source:
registry_url: https://components.espressif.com/
type: service
version: 1.7.6~1
espressif/tinyusb:
component_hash: aa65639878f27a44d349044afd9c3fc134a92bd560874fdac1d836019b5c07ca
dependencies:
- name: idf
require: private
version: '>=5.0'
source:
registry_url: https://components.espressif.com
type: service
targets:
- esp32s2
- esp32s3
- esp32p4
version: 0.18.0~4
idf:
source:
type: idf
version: 5.5.0
direct_dependencies:
- espressif/esp_tinyusb
- idf
manifest_hash: 48b4bc7b2d1d1a86ac200b84fcb27696d651413d6f3c9dda6ae42be38b4b1ee3
target: esp32s3
version: 2.0.0
16 changes: 16 additions & 0 deletions esp-idf-examples/net_pppos_usb/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
idf_component_register(SRC_DIRS "./nimcache"
INCLUDE_DIRS ""
)

idf_build_set_property(C_COMPILE_OPTIONS -Wno-unused-label APPEND)
idf_build_set_property(C_COMPILE_OPTIONS -Wno-discarded-qualifiers APPEND)
idf_build_set_property(C_COMPILE_OPTIONS -Wno-ignored-qualifiers APPEND)
idf_build_set_property(C_COMPILE_OPTIONS -Wno-error=unused-label APPEND)
idf_build_set_property(C_COMPILE_OPTIONS -Wno-error=parentheses APPEND)
idf_build_set_property(C_COMPILE_OPTIONS -Wno-error=implicit-function-declaration APPEND)
idf_build_set_property(C_COMPILE_OPTIONS -Wno-error=maybe-uninitialized APPEND)
idf_build_set_property(C_COMPILE_OPTIONS -Wno-error=nonnull APPEND)
idf_build_set_property(C_COMPILE_OPTIONS -Wno-error=address APPEND)
idf_build_set_property(C_COMPILE_OPTIONS -Wno-unused-but-set-variable APPEND)
idf_build_set_property(C_COMPILE_OPTIONS -Wno-maybe-uninitialized APPEND)
idf_build_set_property(C_COMPILE_OPTIONS -Wno-incompatible-pointer-types APPEND)
14 changes: 14 additions & 0 deletions esp-idf-examples/net_pppos_usb/main/config.nims
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--nomain
--compileOnly
# --define:debug
--define:NimAppMain
--nimcache:nimcache

--gc:arc
--os:freertos
--cpu:arm
--define:useMalloc
--define:noSignalHandler
# --debugger:native
--threads:on
--tls_emulation:off
2 changes: 2 additions & 0 deletions esp-idf-examples/net_pppos_usb/main/cpuinfo.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

proc countProcessors*(): int = 1
17 changes: 17 additions & 0 deletions esp-idf-examples/net_pppos_usb/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## IDF Component Manager Manifest File
dependencies:
## Required IDF version
idf:
version: '>=4.1.0'
# # Put list of dependencies here
# # For components maintained by Espressif:
# component: "~1.0.0"
# # For 3rd party components:
# username/component: ">=1.0.0,<2.0.0"
# username2/component2:
# version: "~1.0.0"
# # For transient dependencies `public` flag can be set.
# # `public` flag doesn't have an effect dependencies of the `main` component.
# # All dependencies of `main` are public by default.
# public: true
espressif/esp_tinyusb: ^1.7.6~1
Loading