Border Router OTA using WiFi


I am very new to RIOT and I am trying to establish the following setup for Wireless OTA firmware updates:

  • An ESP32 running a border router
  • A Nucleo-F767ZI board running a few processes
  • A wired UART connection between the border router and the Nucleo board

I tried the gnrc border router example using Ethos and DHCPv6, which works fine and I’m able to ping the border router from Linux host. But the WiFi uplink doesn’t work and it doesn’t get a prefix. I have found that when Ethos is used, it creates its own instance of a Kea DHCPv6 server and requests a prefix, but I am unable to find out how to do the same using WiFi. I have an instance of the Kea server running, but I’m unable to figure out if the border router is running the DHCP client or not.

I would really appreciate if I can get a few pointers on this.

I would also like to know how to connect the border router and the Nucleo board using UART and forward packets to the board.

I think your problem is that you don’t actually need a border router since both of your interfaces are proper IPv6 interfaces, there is no 6LoWPAN involved.

The gnrc_border_router example has some auto-magic to automatically detect the (6lo) downstream interface, so to turn this into an WiFi <-> Ethernet (ethos) router, you have to make some changes:

  • manually select the upstream interface, in this case esp_wifi:

  • drop the 6lo specific functionality:

--- a/examples/gnrc_border_router/Makefile
+++ b/examples/gnrc_border_router/Makefile
@@ -24,7 +24,7 @@ WIFI_PASS ?= "Your_secure_password"
 USEMODULE += netdev_default
 USEMODULE += auto_init_gnrc_netif
 # Specify the mandatory networking modules for 6LoWPAN border router
-USEMODULE += gnrc_sixlowpan_border_router_default
+USEMODULE += gnrc_ipv6_router_default
 # Additional networking modules that can be dropped if not needed
 USEMODULE += gnrc_icmpv6_echo
 # Add also the shell, some shell commands
@@ -56,7 +56,7 @@ endif
 ifeq (dhcpv6,$(PREFIX_CONF))
   # include DHCPv6 client for 6LoWPAN border router
-  USEMODULE += gnrc_dhcpv6_client_6lbr
+  USEMODULE += gnrc_dhcpv6_client_simple_pd
 else ifeq (uhcp,$(PREFIX_CONF))
   # include UHCP client
   USEMODULE += gnrc_uhcpc

Now if you compile the app with UPLINK=wifi and have the ethos or slip interface configured for the esp32 (you need to select the module) you shoould get a WiFi <-> Ethos router.

Moderator’s note: Edited post to fit amendment in Border Router OTA using WiFi - #5 by benpicco.

The answer from Ben is probably spot on, but I was going to ask for a diagram first.

Thank you for your reply @benpicco I was not expecting such a quick response :grinning: I’ve made the suggested changes to the Makefile. There is a compile error, can you take a quick look?

@mcr What sort of diagram are you looking for? Sorry if these are very trivial questions. I’ve tried adding this line

USEMODULE += gnrc_sock

but it did not work

Ops, my bad - it’s gnrc_ipv6_router_default, not gnrc_router_default

@benpicco That solved the compile error :slightly_smiling_face:

It still did not result in what I was looking for. I can give you a little more information.

This is the output that I got when I flashed the ESP board with the default gnrc border router example using dhcpv6

$ BOARD=esp32-wroom-32 UPLINK=ethos PREFIX_CONF=dhcpv6 make -C examples/gnrc_border_router flash term

The ‘ifconfig’ command shows that there is a global ipv6 address, with the prefix “2001:db8::”.

This is the output when I flashed the ESP32 board using the WiFi uplink with the modified Makefile as you suggested

$ BOARD=esp32-wroom-32 UPLINK=wifi PREFIX_CONF=dhcpv6 make -C examples/gnrc_border_router flash term

I wanted a global ipv6 address but it doesn’t receive one in this case.

What else can I do to get the same output as the ethos uplink using the wifi uplink?

It looks like you are using esp_now as the downlink, not ethos.

In Makefile.board.dep replace the USEMODULE += esp_now with USEMODULE += ethos and maybe set CFLAGS += '-DETHOS_UART=UART_DEV(your_uart)' if you don’t have this set in your board.h.

To get the prefix on the downstream interface you need a DHCPv6 server with IA_PD enabled. Not all routers support this, on the Fritz!Box family you can enable it in IPv6 settings, OpenWRT might enable it by default.

Hi, I’m sorry for the late update. I have been busy and I was unable to work on this for a while.

I have changed the IPv6 settings on my WiFi router to enable prefix delegation, but it still does not work.

I was trying to debug and found out a potential issue that might be a Linux problem not necessarily related to RIOT. I found that the TAP interface connected to the DHCPv6 server is not in RUNNING state, can this be why it does not give a prefix? Is there any way I can force it into RUNNING state?

I’m confused, how does Linux come into play here? AFAIK you wanted to use the ESP32 as a router for the Nucleo-F767ZI - so no Linux machine / tap interface is involved here.

What happens when you run examples/gnrc_border_router with UPLINK=wifi on the esp32? (this will use esp_now instead of SLIP for the downlink, but at least you can verify that your network setup works).

You need to tell us more about what you did here. I understand you want to delegate the prefix to the ESP32, which is going to route to the F767ZI. You probably should just statically route a prefix to it for now instead of trying to debug your router. If you really want to do that, then an OpenWRT router, on your LAN ought to be able to get a prefix from your home router. I personally have never gotten an OpenWRT router to do DHCPv6-PD downstream, and I have an kea6 installation specifically do that I can test OpenWRT as a downstream device.

I’m sorry for the confusion. Following the tutorial from RIOT documentation for WiFi uplink for the gnrc_border_router example, in the configuration file of the Kea DHCPv6 server running on my Linux system, I found a field called “interfaces” where I listed my TAP interfaces, so I assumed that is how the DHCP client communicates with the server.

After making the changes you previously mentioned in the border router example Makefile, this is the output when I run “UPLINK=wifi BOARD=esp32-wroom-32 make -C examples/gnrc_border_router flash term”

I have the DHCPv6 server running, which I verified here

And the log files of the server also show that the server is indeed active

There is no “lease advert” in the logs, so I’m assuming there has been no activity between the client and the server. The “gnrc_dhcpv6_client_simple_pd” module which you asked me to add in the Makefile seems to be executing all its functions, since I’ve tried to debug the code and did not run into any error messages. I’m not able to figure out where the issue is.

You need to tell us more about what you did here.

I haven’t done much, I have a TP-LINK WiFi router at home and just went into the router login page , selected an option that said “Get IPv6 prefix delegation”.

I’m currently testing at home, but the final setup is in my university, so it would be great if I don’t need to change any router settings. Can you provide a brief tutorial on static routing? I’m not very familiar with the process.

I’m also interested in testing with the OpenWRT router, since I believe I have one with me. How can I use it to get a prefix?

Ah you don’t have to run the DHCPv6 server on your PC, this is only for development / when using ethos (I agree that the border router readme file is very large and confusing).

But when you are connected to your router you should get a router advertisement and a prefix via DHCPv6 from that - but I don’t see that in your output.

Do you have a working IPv6 uplink on your router?

1 Like

I am not sure. How do I check if there is a working IPv6 uplink?

Does your Router / your PC get a global IPv6 address? Can you ping 2600:: on your machine?

Not currently. So is this the cause for this issue? I will be able to acquire an OpenWRT router later, maybe I can give an update here after I test with it.

Unless you actively disabled IPv6 on your TP-Link router, I don’t think OpenWRT will make a difference here. Does your ISP not provide IPv6?

Not for home network. But I can test the router in my university, I’m sure there is provision for IPv6 there.

AFAIK, OpenWRT does not have a southbound (LAN facing) DHCPv6-PD server. This “Get IPv6 prefix delegation” is about the northbound (DHCPv6-PD client) communications. (I would very much like a DHCPv6-PD server) I doubt that your university offers DHCPv6-PD service on it’s LAN, as it is atypically a thing. However, there is work in the IETF 6man/v6ops to make this more of a thing, and there is also the SNAC WG, which aims to deal with the very problem you have having :slight_smile:

I’m pretty sure odhcpd supports prefix delegation. But that requires you to get a sufficiently large prefix from your ISP in the first place.