Skip to content

Conversation

@Teufelchen1
Copy link
Contributor

@Teufelchen1 Teufelchen1 commented Nov 21, 2025

Contribution description

Hey hey 🦭

This refactors the current slipdev driver heavily and also renames it to slipmux.

The networking aspect (plain slip) is no longer the default but a submodule: slipmux_net.
The "configuration" aspect (coap via uart) is no longer called slipdev_config but slipmux_coap. That moves it further from the slipmux draft but (I hope) closer to the average developer and sets the expectations clearer.
Same for diagnostic but there it was already called _stdio which was retained.

There is a new "overall" module called slipmux which enables all three modes (slipmux_stdio, _coap and _net) for full slipmux functionality.

The parser behavior got a slight change and differentiates between unknown frame types and IPv4/6 frames now. This should make it more robust when interfacing slipmux instead of slip. (Worry not, our slip tools still work as expected)

In addition, the coap handling got reworked to be ready for plug & play action with unicoap once #21582 is merged.

Testing procedure

Pick one of our examples that offer slip e.g. examples/networking/gnrc/border_router/ and see that it still behaves as advertised in the README. tl;dr:

cd examples/networking/gnrc/border_router/
BOARD=nrf52840dk UPLINK=slip make all flash -j9 term
Building application "gnrc_border_router" for "nrf52840dk" with CPU "nrf52".
[...]
> 
> ifconfig
Iface  2 
          MTU:65535  HL:64  RTR  
          
          Link type: wired
          inet6 addr: fe80::2  scope: link  VAL
          inet6 group: ff02::1:ff00:2
          
Iface  6  HWaddr: 35:3F  Channel: 26  NID: 0x23  PHY: O-QPSK 
         [...]
          inet6 group: ff02::1:ff22:b53f
          
ps
> ps
	pid | name                 | state    Q | pri | stack  ( used) ( free) | base addr  | current     
	  - | isr_stack            | -        - |   - |    512 (  224) (  288) | 0x20000000 | 0x200001c8
	  1 | main                 | running  Q |   7 |   1536 (  904) (  632) | 0x200002f0 | 0x2000062c 
	  2 | slipdev              | bl anyfl _ |   2 |    896 (  284) (  612) | 0x20004af4 | 0x20004db4 
	 [...]
	  7 | uhcp                 | bl mutex _ |   6 |   1536 (  944) (  592) | 0x200040bc | 0x200044d4 
	    | SUM                  |            |     |   7744 ( 3388) ( 4356)

See the slipdev thread running (pid 2) and then try to ping the border router from your linux console:

 ~> ping fe80::2%sl0
PING fe80::2%sl0 (fe80::2%sl0) 56 data bytes
64 bytes from fe80::2%sl0: icmp_seq=1 ttl=64 time=20.1 ms
64 bytes from fe80::2%sl0: icmp_seq=2 ttl=64 time=20.5 ms
^C
--- fe80::2%sl0 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 20.108/20.287/20.466/0.179 ms

@github-actions github-actions bot added Area: network Area: Networking Area: build system Area: Build system Area: pkg Area: External package ports Area: drivers Area: Device drivers Area: tools Area: Supplementary tools Area: boards Area: Board ports Area: sys Area: System Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration labels Nov 21, 2025
Comment on lines +88 to +109
while (1) {
event_t *event = event_wait(&queue);
event->handler(event);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole event queue contraption is rather odd but it will fit nicely with unicoap, trust me bro.

@crasbe crasbe added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Nov 21, 2025
@riot-ci
Copy link

riot-ci commented Nov 21, 2025

Murdock results

FAILED

376fd64 move module ifdef/is_used into helper functions

Build failures (14)
Application Target Toolchain Runtime (s) Worker
tests/net/slip native32 llvm 0.67 alien
tests/net/slip native32 gnu 1.24 mobi6
tests/net/slip msba2 gnu 2.30 alien
tests/net/slip native64 llvm 0.61 alien
tests/net/slip native64 gnu 1.35 mobi6
tests/net/slip qn9080dk gnu 1.17 tatooine
tests/net/slip msb-430 gnu 3.53 mobi6
tests/net/slip stm32f429i-disc1 gnu 2.22 mobi7
tests/net/slip adafruit-itsybitsy-m4 gnu 6.57 mobi6
tests/net/slip samr21-xpro gnu 2.02 mobi6
tests/net/slip frdm-k64f gnu 1.57 mobi7
tests/net/slip nrf52840dk gnu 2.21 mobi6
tests/net/slip stk3200 gnu 3.54 mobi6
tests/net/slip samr21-xpro llvm 6.06 skyleaf
Test failures (1)
Application Target Toolchain Runtime (s) Worker
tests/sys/event_wait_timeout_ztimer native64 llvm 0.00 alien

Artifacts

Copy link
Contributor

@crasbe crasbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some basic style and nitpick comments for now.

Also the static test has some ideas and you sometimes added yourself in the Copyright and sometimes in the Doxygen authorship, but not really consistently yet 🤔

Comment on lines -456 to -458
PSEUDOMODULES += slipdev_stdio
PSEUDOMODULES += slipdev_config
PSEUDOMODULES += slipdev_l2addr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need these modules as slipmux_ PSEUDOMODULES anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still do! And this actually one of the major reasons for this rewrite/refactoring: The ability to select _stdio or _coap (used to be _config) without having to use _net (used to not exist and was always included in the base slipdev)

The definitions moved into Makefile.include. I can't remember why I decided to move them out of the global pseudomodules.inc.mk. Either a mistake or some deeper reasoning? Will see in a bit.

@Teufelchen1
Copy link
Contributor Author

Just some basic style and nitpick comments for now.

Way too early :p but thanks anyways, I adopted the fixes.

Also the static test has some ideas

Probably. I wasn't done-enough yet, to look at them.

[..] and you sometimes added yourself in the Copyright and sometimes in the Doxygen authorship, but not really consistently yet 🤔

No care was given to that yet.

@crasbe crasbe added the CI: no fast fail don't abort PR build after first error label Nov 24, 2025
@github-actions github-actions bot added Area: doc Area: Documentation Area: tests Area: tests and testing framework labels Nov 24, 2025
@Teufelchen1 Teufelchen1 force-pushed the slipmux_event_based branch 2 times, most recently from 9e542dd to 33e529a Compare November 24, 2025 15:07
@Teufelchen1 Teufelchen1 changed the title DRAFT: Rework SLIPDEV driver in preparation for Unicoap Rework SLIPDEV driver in preparation for Unicoap Nov 24, 2025
@Teufelchen1
Copy link
Contributor Author

I think this is ready for actual review now. I would appreciate feedback specifically on the mutex handling. I am not super proud of it.

@crasbe
Copy link
Contributor

crasbe commented Nov 24, 2025

If you want to, you can squash before the reviews start pouring in 🤔

Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! ❤️ Unfortunately it was a bit hard to review since Github didn't properly display the file renames (separate commit would have helped).

I've got mostly nitpicky things and haven't tested this yet.

Also Murdock fails because you probably have to change the Kconfig include from slipdev to slipmux somewhere.

Comment on lines +187 to +192
#if IS_USED(MODULE_SLIPMUX_NET_L2ADDR)
case NETOPT_ADDRESS_LONG:
assert(max_len == sizeof(eui64_t));
netdev_eui64_get(netdev, value);
return sizeof(eui64_t);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this is slipmux-specific? why not use a generic l2addr module? I have the feeling there was some, maybe I'm wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea, I honestly didn't question it. It works tho! Tested it! :P

Comment on lines 85 to 86
/drivers/si70xx/ @basilfx
/drivers/slipdev/ @miri64
/drivers/sx127x/ @aabadie @jia200x
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/drivers/si70xx/ @basilfx
/drivers/slipdev/ @miri64
/drivers/sx127x/ @aabadie @jia200x
/drivers/si70xx/ @basilfx
/drivers/slipmux/ @Teufelchen1
/drivers/sx127x/ @aabadie @jia200x

:P

Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot the most important file :P

Comment on lines +80 to +81
if (len <= 0) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some DEBUG messages wouldn't harm :)

@mguetschow mguetschow changed the title Rework SLIPDEV driver in preparation for Unicoap drivers/slipmux: Rework SLIPDEV driver in preparation for Unicoap Nov 26, 2025
@mguetschow
Copy link
Contributor

Btw, while editing the title I was thinking: does this really belong to drivers and not rather sys/net?

@Teufelchen1
Copy link
Contributor Author

Great stuff! ❤️

Thanks!

Unfortunately it was a bit hard to review since Github didn't properly display the file renames (separate commit would have helped).

Yes, I realized too late that this approach was shit (sorry!).

does this really belong to drivers and not rather sys/net?

I don't know. 🙈

@Teufelchen1
Copy link
Contributor Author

@mguetschow you are going to hate me 🙈

Unfortunately it was a bit hard to review since Github didn't properly display the file renames (separate commit would have helped).

I did it again! (sort of)
I renamed the driver to slipmux_dev. This was necessary to clean up the makefile stuff around pseudomodules and dependency resolution. This allows to have the slipmux pseudomodule (which conflicted with the drivers name before hand) that enables all submodules automatically. It also makes it much much cleaner, when a submodule, say slipmux_net pulls in slipmux_dev (used to be slipmux). The old way was super confusing as having the slipmux module in you make info-modules list did not guarantee that all slipmux submodules were enabled. This is now the case. Bonus points because I can now issue a warning to the user when when selecting slipmux together with either slipmux_ submodule: The user will otherwise be surprised that all submodules are enabled.

Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure I'm happy with slipmux being an alias for all of the submodules. Is that common practice in RIOT? e.g. gnrc uses gnrc_default for such default configurations. But I won't die on that hill either.

case SLIPMUX_STATE_SLEEP:
/* do nothing if we are supposed to sleep */
/* and we should usually not be able to hit this case anyways */
assert(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really something we cannot recover from? Can it really only happen by programmer mistake?

Comment on lines +166 to +167
if (byte == SLIPMUX_END) {
dev->state = SLIPMUX_STATE_NONE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be that we need to handle escape end here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. There is no need to handle escaping in data that we are not storing or processing in anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, but then an escaped END could be mistaken for a real one. But I guess we are in a bad situation anyway in this case, and might just hope for the best when encountering the first END?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An escaped END(0xdb 0xdc) is not an END (0xC0)! It will not match / be mistaken.

# enable stdout buffering for modules that benefit from sending out buffers in larger chunks
ifneq (,$(filter picolibc,$(USEMODULE)))
ifneq (,$(filter stdio_cdc_acm stdio_ethos slipmux_stdio stdio_semihosting stdio_tinyusb_cdc_acm,$(USEMODULE)))
ifneq (,$(filter stdio_cdc_acm stdio_ethos slipmux slipmux_stdio stdio_semihosting stdio_tinyusb_cdc_acm,$(USEMODULE)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, it's a bit unfortunate to add slipmux here, next to slipmux_stdio. Why would slipmux not just enable all three?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line does not enable modules but check which modules are enabled? I am a bit confused what your comment means.

Why would slipmux not just enable all three?

It does? Just not in this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would slipmux not just enable all three?

It does? Just not in this file.

Okay, sorry for the confusing comment. Let me rephrase: If slipmux enables all other three slipmux_* and in particular slipmux_stdio, why is it not enough to test for slipmux_stdio here and you have to explicitly test for slipmux?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because that expansion of slipmux into _net _coap _stdio happens in the drivers folder. Which is after stdio.inc.mk got evaluated. So you don't have access to that expansion yet. This means you have to check for both options that use the stdio eventually.

cc @benpicco
This is also why I did not fix the stupid name issue: Stdio modules usually are named stdio_%, only slipdev/slipmux disregard that. Having stdio_slipmux, slipmux_net and slipmux_coap makes little sense either. But i can not just set an alias because the alias would be evaluated too late as well.

To fix that, I would have to escalate this and handle the dependency resolution / name aliasing in RIOT/Makefile.dep . Possible, but also something that I try to avoid, touching the "master" files is a last resort. Personally I think the draw back in stdio.inc.mk is a fair trade for having the entire rest of "slipmux-dependency-logic" inside the slipmux module.

Comment on lines -112 to -115
if (IS_USED(MODULE_SLIPDEV)) {
extern void auto_init_slipdev(void);
auto_init_slipdev();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why could you remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not in use and hence got removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, and slipmux is now initialized via AUTO_INIT(slipmux_init, 0); in drivers/slipmux_dev/slipmux.c? And that is sufficient for GNRC, just LWIP sill needs an explicit slipmux initialization in pkg/lwip/init_devs/auto_init_slipmux.c?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Thats also why the priority is 0. So slipmux is done with the setup once lwip comes around and wants to do stuff with it.

dev->state = SLIPMUX_STATE_NONE;
break;
default:
#if IS_USED(MODULE_SLIPMUX_STDIO)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I actually like this approach, makes the FSM code more readible as a side-effect :)

Comment on lines +29 to +32
#define SLIPDEV_STACKSIZE (THREAD_STACKSIZE_DEFAULT - 128)
#ifndef SLIPDEV_PRIO
# define SLIPDEV_PRIO (GNRC_NETIF_PRIO)
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is still open?

Comment on lines +17 to +18
$(info $(_give_space) You selected the submodule(s) `$(_SUBMODS)` manually in USEMODULE together with the module `slipmux`.)
$(info $(_give_space) The module `slipmux` enables all submodules by default.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this warning? slipmux is a new module name, right? So I would say it is sufficient to explicitly mention that fact in the documentation and rely on the user reading that (if they don't, well, their fault).

This would remove the rather complex-looking if cascade here :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this warning?

No, it is a warning hence it is not strictly needed. But that is true for all warnings.

So I would say it is sufficient to explicitly mention that fact in the documentation and rely on the user reading that (if they don't, well, their fault).

Hm not sure. This module is indeed a bit odd and having a warning is rather cheap.

This would remove the rather complex-looking if cascade here :P

Hey, at least it is well documented and it's only complex-looking, not actually complex. :p

@Teufelchen1
Copy link
Contributor Author

I'm not 100% sure I'm happy with slipmux being an alias for all of the submodules. Is that common practice in RIOT? e.g. gnrc uses gnrc_default for such default configurations. But I won't die on that hill either.

Yes I am also not 100% happy. I could go and rename the driver back to slipmux and have slipmux_default to be inline with gnrc but that would also be wrong'ish? Enabling slipmux raises the expectation that RIOT is now slipmux-draft compatible, which it wouldn't be. Plus, unlike other modules where the "base" module already provides value, the slipmux base module would provide zero value.
That is why I reasoned: Let's have the draft name equal a draft compliant driver. But because it is a hard requirement to be able to only use a sub-set of the slipmux frame types (e.g. SLIP / Networking only), we have to have a sub-module that reflects that. I chose slipmux_net but that is arbitrary. Now we have to solve the problem that slipmux_net needs to enable some kind of base module which must not be slipmux as this is already saying "enable everything". For that I chose slipmux_dev.

@@ -1,5 +1,6 @@
STDIO_MODULES = \
slipdev_stdio \
slipmux_stdio \
Copy link
Contributor

@benpicco benpicco Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do cause an API break here, you might as well make it consistent with the other stdio_% modules.

How about adding a

ifneq (,$(filter slipdev_stdio,$(USEMODULE)))
  USEMODULE += stdio_slipmux
endif

so you don't silently break applications that use that?

@benpicco
Copy link
Contributor

benpicco commented Dec 8, 2025

Enabling slipmux raises the expectation that RIOT is now slipmux-draft compatible, which it wouldn't be. Plus, unlike other modules where the "base" module already provides value, the slipmux base module would provide zero value.

Our main use case for the slipdev driver is a simple point to point IP connection between two MCUs, so no stdio, no CoAP.

So if slipdev were an alias for slipmux_net, I'd be happy.

(Arg, but then you'd also have to provide SLIPDEV_PARAM_UART -> SLIPMUX_PARAM_UART compat defines - is the slipdev name really causeing so much pain that the rename is worth the hassle?)

Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do wonder a bit if we will see CoAP over USB next since a lot of the newer dev boards use stdio_cdc_acm 🤔


# select default stdio provider if no other is selected
ifeq (,$(filter stdio_% slipdev_stdio,$(USEMODULE)))
ifeq (,$(filter stdio_% slipmux_stdio slipmux,$(USEMODULE)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why separately test for slipmux?

netdev_register(&dev->netdev, NETDEV_SLIPDEV, index);

#if IS_USED(MODULE_GNRC)
gnrc_netif_raw_create(&_netif[index], _slipdev_stacks[index], SLIPDEV_STACKSIZE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this happening here now?
We used to keep networking stack specific code out of the drivers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: boards Area: Board ports Area: build system Area: Build system Area: doc Area: Documentation Area: drivers Area: Device drivers Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration Area: network Area: Networking Area: pkg Area: External package ports Area: sys Area: System Area: tests Area: tests and testing framework Area: tools Area: Supplementary tools CI: no fast fail don't abort PR build after first error CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants