This shows you the differences between two versions of the page.
iothings:laboratoare:2022:lab10 [2025/05/14 14:56] andreea.miu [Run as sudo] |
iothings:laboratoare:2022:lab10 [2025/05/14 15:12] (current) andreea.miu [Environment] |
||
---|---|---|---|
Line 10: | Line 10: | ||
=== Native Linux machine === | === Native Linux machine === | ||
- | You can go ahead to section [Run as sudo]. | + | You can go ahead to section **[Compiling NuttX]**. |
=== Windows setup === | === Windows setup === | ||
Line 85: | Line 85: | ||
Use the following commands to install the necessary Python modules and configure the compile options needed for the WROVER module. | Use the following commands to install the necessary Python modules and configure the compile options needed for the WROVER module. | ||
<code> | <code> | ||
- | pip3 install espt | + | pip3 install esptool |
pip3 install pyserial | pip3 install pyserial | ||
cd ~/nuttxspace/nuttx | cd ~/nuttxspace/nuttx | ||
Line 148: | Line 148: | ||
Additionally, another useful command to investigate the status of network interfaces is ''ifconfig'', similar to the one in Linux. | Additionally, another useful command to investigate the status of network interfaces is ''ifconfig'', similar to the one in Linux. | ||
+ | ==== Exercises ==== | ||
+ | To be able to run the exercises, you need to compile NuttX using ''esp32-devkitc:sta_softap'', for which you will need to manually enable a few other configs, listed below. In order to modify the initial configuration, use the ''make menuconfig'' command after configuring ESP32 as sta_softap, and before starting the compilation process. | ||
+ | <note tip> | ||
+ | You can navigate through the ''menuconfig'' interface using the search option (''/'' key). | ||
+ | </note> | ||
+ | * CONFIG_NET_ROUTE=y | ||
+ | * CONFIG_NET_IPFORWARD=y | ||
+ | * CONFIG_NET_NAT=y | ||
+ | * CONFIG_SYSTEM_IPTABLES=y | ||
+ | |||
+ | **1.** Connect the ESP32 to the university network and test with ''ping 8.8.8.8'' that you have internet access. Use the ''wlan0'' interface. | ||
+ | |||
+ | <note tip> | ||
+ | If you are unable to connect to the univerrsity network, you can use the hotspot on your mobile phone. This will allow you to test connecting to both an unsecured network and a secured one (via WPA2). | ||
+ | </note> | ||
+ | |||
+ | <note important> | ||
+ | NuttX does not handle the SIGINT signal by default, and running the ping will cause your nsh console to crash. You can avoid this problem by enabling CONFIG_TTY_SIGINT. | ||
+ | </note> | ||
+ | Run the ''route'' command and inspect its output. It will be relevant to exercise 3. | ||
+ | **2.** Configure the board to run in SoftAP mode and connect your laptop to the network to test. Use the ''wlan1'' interface. Run the ''route'' command again and notice how the routing table has changed. | ||
+ | **3.** After exercise 2, the laptop is connected to the ESP32, but has no internet access. You can test this from CMD (Windows)/terminal (Linux) using ''ping 8.8.8.8''. Next, follow the steps below to fix the internet access issue: | ||
+ | - From ESP32 run the command ''ping 8.8.8.8'' again. Notice that you have no internet access. Configuring wlan1 as a SoftAP has broken the routing table, as can be seen from the output of the ''route'' command. | ||
+ | - Set the default routing rule using the command ''addroute default 192.168.0.1 wlan0''. ESP32 is connected to the internet again, you can test using ''ping''. | ||
+ | - The last step involves adding a rule in iptables to apply NAT on each packet routed by ESP32: ''iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE''. | ||
+ | - Test from your personal laptop using ping, and from your browser connect to ''www.google.com''. | ||
==== References ==== | ==== References ==== | ||
Line 164: | Line 190: | ||
* [[https://nuttx.apache.org/docs/latest/platforms/xtensa/esp32/index.html | Official NuttX ESP32 build tutorial]] | * [[https://nuttx.apache.org/docs/latest/platforms/xtensa/esp32/index.html | Official NuttX ESP32 build tutorial]] | ||
* [[https://blog.espressif.com/getting-started-with-esp32-and-nuttx-fd3e1a3d182c | Sara Monteiro's tutorial]] | * [[https://blog.espressif.com/getting-started-with-esp32-and-nuttx-fd3e1a3d182c | Sara Monteiro's tutorial]] | ||
+ | * [[https://nuttx.incubator.apache.org/docs/12.3.0/applications/wapi/index.html| WAPI (Wireless API)]] | ||
+ | * [[https://eadalabs.com/esp32-nuttx-and-bridged-networking/|Esp32, NuttX and bridged networking]] | ||