Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
43a039c
Adding NSH USB and NSH UART tutorial
Mar 20, 2020
dfbc8b3
Adding UDP echo tutorial
Mar 20, 2020
98e75ad
Little rework of the tutorials
Mar 20, 2020
ce0fa58
Text fix
Mar 20, 2020
b319f60
Text Fix on UDP echo tutorial
Mar 20, 2020
ad46100
Adding tcp echo tutorial
Mar 20, 2020
983a128
Adding tcp echo tutorial
Mar 20, 2020
1e3dbae
Adding little rework
Mar 20, 2020
06c9b25
Little rework on the 6lowpan tutorial
Mar 20, 2020
a340a52
More rework on 6lowpan tutorial
Mar 20, 2020
822d174
Resolving conflict with master branch
Mar 20, 2020
052618e
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
d6b98b5
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
01cd977
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
e8a743c
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
957af84
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
15ee97c
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
a884f8e
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
89ef9e2
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
b7c8c9f
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
4792cc9
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
6770b12
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
e7b26db
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
fc2ff6c
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
9b91636
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
00a3496
Update _docs/tutorials/advanced/nuttx/nsh_uart/index.md
Apr 7, 2020
48e6415
Update _docs/tutorials/advanced/nuttx/nsh_uart/index.md
Apr 7, 2020
a9a26b5
Update _docs/tutorials/advanced/nuttx/nsh_uart/index.md
Apr 7, 2020
ae38aa9
Update _docs/tutorials/advanced/nuttx/nsh_uart/index.md
Apr 7, 2020
b033cbc
Update _docs/tutorials/advanced/nuttx/nsh_uart/index.md
Apr 7, 2020
0891d7c
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
a5eaed8
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
2a04e6e
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
5fb3c95
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
1c1d9b4
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
2870f14
Update _docs/tutorials/advanced/nuttx/nsh_uart/index.md
Apr 7, 2020
f34cf7a
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
bdef036
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
6f81537
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
1974d3b
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
cc2901b
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
1655950
Update _docs/tutorials/advanced/nuttx/6lowpan_config/index.md
Apr 7, 2020
a4fcc8d
Update _docs/tutorials/advanced/nuttx/nsh_uart/index.md
Apr 7, 2020
ad56162
Update _docs/tutorials/advanced/nuttx/nsh_usb/index.md
Apr 7, 2020
8353328
Update _docs/tutorials/advanced/nuttx/nsh_usb/index.md
Apr 7, 2020
ad04e62
Update _docs/tutorials/advanced/nuttx/nsh_usb/index.md
Apr 7, 2020
4dfdf1a
Update _docs/tutorials/advanced/nuttx/nsh_usb/index.md
Apr 7, 2020
9cbfde2
Update _docs/tutorials/advanced/nuttx/nsh_usb/index.md
Apr 7, 2020
7e58797
Update _docs/tutorials/advanced/nuttx/nsh_usb/index.md
Apr 7, 2020
181a97e
Update _docs/tutorials/advanced/nuttx/nsh_usb/index.md
Apr 7, 2020
a76aa1b
Update _docs/tutorials/advanced/nuttx/nsh_usb/index.md
Apr 7, 2020
8287dfb
Update _docs/tutorials/advanced/nuttx/nsh_usb/index.md
Apr 7, 2020
e4e4f86
Update _docs/tutorials/advanced/nuttx/nsh_usb/index.md
Apr 7, 2020
4f916d1
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
5e78b87
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
60acdd0
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
aaa6013
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
1df2bcc
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
db659ed
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
c7081d6
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
0ac008e
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
b90de09
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
d475832
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
d855b5c
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
2cd10f3
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
47881a4
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
0973818
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
af5f75b
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
3c8125c
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
1d5d375
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
7ae02e6
Update _docs/tutorials/advanced/nuttx/tcp_echo/index.md
Apr 7, 2020
074334f
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
f469879
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
5c410a3
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
26e483b
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
0ae695d
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
b0b3ee4
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
779d32d
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
0f1fd14
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
e921d51
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
f613cee
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
b7b502e
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
005f4af
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
85c063c
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
195a84c
Update _docs/tutorials/advanced/nuttx/udp_echo/index.md
Apr 7, 2020
5919606
Merge branch 'master' into feature/advance_nuttx/nuttx_split
Apr 8, 2020
18f5090
Deleting previous version of NuttX getting started
Apr 8, 2020
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
7 changes: 5 additions & 2 deletions _data/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@
- title: Advanced Tutorials with Nuttx
docs:
- tutorials/advanced/nuttx/nuttx_getting_started
- tutorials/advanced/nuttx/add_a_microros_application
- tutorials/advanced/nuttx/nsh_usb
- tutorials/advanced/nuttx/nsh_uart
- tutorials/advanced/nuttx/udp_echo
- tutorials/advanced/nuttx/tcp_echo
- tutorials/advanced/nuttx/6lowpan_config
- tutorials/advanced/nuttx/debugging_gdb_openocd
- tutorials/advanced/nuttx/debugging_vscode
- tutorials/advanced/nuttx/6lowpan_nuttx_rpi
- tutorials/advanced/nuttx/microros_nuttx_bsp
- tutorials/advanced/nuttx/microros_6lowpan_tutorial

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
---
title: 6LOWPAN communications between NuttX and a Raspberry Pi
permalink: /docs/tutorials/advanced/nuttx/6lowpan_nuttx_rpi/
title: Configure 6LoWPAN communications
permalink: /docs/tutorials/advanced/nuttx/6lowpan_config/
---

| RTOS | Board Compatible |
|:-----:|:-----------------:|
| NuttX | Olimex-STM32-E407 |

This guide will show how to set-up a Raspberry Pi 3 (RPI) running Raspbian and an Olimex STM32 E407 board running NuttX to have 6lowpan communication between them.

## What do we need?

**Disclaimer**: This tutorial doesn't use micro-ROS, it is just a proof of concept of the 6LoWPAN communication.

## Hardware requirements:

- Raspberry Pi 3
Comment thread
jfm92 marked this conversation as resolved.
- micro-SD card (almost 16gb) with Raspbian lite already installed.
- Olimex-STM32-E407 board.
- Two PMODRF2 module which are base on the MRF24J40 module.
- Two PMODRF2 modules which are based on the MRF24J40 module.
- PC with Ubuntu (It works fine with Ubuntu 16.04)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and higher? (maybe specify)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't get what do you mean with "higher".

- NuttX source code, you can find a Docker file with all the tools [here](https://github.com/micro-ROS/docker/tree/pre_refactor/Embedded/NuttX/development/stm32-e407).
## How to set-up 6lowpan RPI?

First, we need to connect the PMODRF2 module to the RPI, so we need to set the next connections:
## Set-up 6LoWPAN communications on the Raspberry PI

First, we need to connect the PMODRF2 module to the RPI, so we need to set the following connections:

| | RPI | PMODRF2 |
| -- | -- | -- |
Expand All @@ -34,10 +41,10 @@ In the next links you can see the pinout of each board:
- [PMODRF2 pionut.](https://reference.digilentinc.com/reference/pmod/pmodrf2/start)

Once you've set all the wires, power-on the RPI and download the next repository inside the RPI:
- https://github.com/micro-ROS/micro-ROS-bridge_RPI
- https://github.com/micro-ROS/micro-ROS-bridge_RPI/

Execute the next command:
```sudo ./micro-ROS-bridge_RPI/RPI_6lowpan/script.sh```
Execute the command:
```sudo ./micro-ROS-bridge_RPI/micro-ROS-HB.sh```

If everything goes fine, at the end of the script, the board should restart. After the start-up, type the next command to see if the configuration and the connections are fine:
```dmesg | grep mrf24j40```
Expand All @@ -51,7 +58,6 @@ The last point is to set-up the network.

- Set the PAN ID: ``sudo iwpan dev wpan0 set pan_id 0xabcd``
- Set the page and channel: ``sudo iwpan phy phy0 set channel 0 26``
- Set the short address: ``sudo iwpan dev wpan0 set short_addr 0x4204`` (Each board must a different one)
- Attach the phy layer to the lowpan: ``sudo ip link add link wpan0 name lowpan0 type lowpan``
- Bring up the WPAN0 interface: ``sudo ip link set wpan0 up``
- Bring up the RPI lowpan: ``sudo ip link set lowpan0 up``
Expand All @@ -60,7 +66,7 @@ The last point is to set-up the network.
Now the RPI is ready to send and receive messages from a NuttX board or another RPI.


## How to set-up 6lowpan in NuttX?
## Set-Up 6LoWPAN communications on NuttX

First, we need to do the connections between the [Olimex board](/docs/overview/hardware) and the PMODRF2 module.

Expand All @@ -70,39 +76,46 @@ First, we need to do the connections between the [Olimex board](/docs/overview/h
- `Board D10` -> `MRF24J40 CS`
- `Board D8` -> `MRF24J40 INT`

Once the wiring is finished, we need to compile and upload the firmware. Type the next commands:

Go to the main folder of NuttX and type the command to configure the board:
`./scripts/configure.sh olimex-stm32-e407 mrf24j40-6lowpan`

Compile:
`make`
### Create firmware

Upload:
`./scripts/flash.sh olimex-stm32-e407`

It should return somenthing like this:

- Configuration:
```
Copy files
Refreshing...
For this tutorial we're going to execute the configuration below in the Micro-ROS build system:
```bash
ros2 run micro_ros_setup create_firmware_ws.sh nuttx olimex-stm32-e407
ros2 run micro_ros_setup configure_firmware.sh mrf24j40-6lowpan
```
- Compilation:

Once the board is configured, we need to build it by typing the command:
```bash
ros2 run micro_ros_setup build_firmware.sh
```

If the compilation succeds, it should return the following output:
```bash
CP: nuttx.hex
CP: nuttx.bin
```
- Upload the firmware

### Flash the firmware
Once the firmware is ready, you need to do the following connections:
- Connect the JTAG flasher device to the JTAG port.
- Connect the mini-USB port to the USB-OTG2 port.
- Check if the radio connections are fine.

Now flash the board by typing the command:
```bash
ros2 run micro_ros_setup flash_firmware.sh
```
wrote 131072 bytes from file nuttx.bin in 3.763846s (34.008 KiB/s)

This should return this output once the process is finished:
```bash
wrote 49152 bytes from file nuttx.bin in 6.279262s (7.644 KiB/s)
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
```
(The number of written bytes could be different in each board)

## NuttX network configuration

Finally, connect the mini USB cable to the USB OTG2, and the console should return the next:
Push the reset button and type Enter two times. Now the NSH console should be output through the terminal. Type ``?`` to check if every application is flashed. The following output should appear.

```bash
nsh> ?
Expand Down Expand Up @@ -161,10 +174,6 @@ Available commands

```

**At this point the network is ready to work!**

Finally type ``quit`` two times to close the app and come back to the main menu.

## Sending a message from NuttX to Raspbian:

### Raspberry Part:
Expand Down Expand Up @@ -228,18 +237,18 @@ lowpan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1280
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
```

As you can see there is two IP in this network interface. But you need to remember the second one. We will use later with NuttX.
As you can see, there are two IPs in this network interface, but we are interested only in the second one. Save it because we will use it later with NuttX.
`fe80::9c6e:87a5:eb60:84d0``

Go to the place where lives the repo that you downloaded previously. Go to ``micro-ROS-bridge_RPI/RPI_6lowpan/Examples/6lowpan_recv``
Finally, execute `recv_demo` telling to open the `61616` port. Type this command: ``./recv_demo 61616``
Go to the place where you previously downloaded the repo. From there, go to ``micro-ROS-bridge_RPI/6LowPAN_Tests/6lowpan_recv``
Finally, execute `recv_demo`, specifying to open the `61616` port. To do so, type this command: ``./recv_demo 61616``

At this point, the RPI is ready to receive incoming packages.

### NuttX part:
### NuttX side

Execute ``udp_6lowpan`` application.
This will ask you if you want to configure the network. Type N, because is already configured.
This will ask you if you want to configure the network. Type N, because it is already configured.
Now you're in the main menu of the App. Type ``write`` to start the sending mode and will ask for the next data:
- The destination IP: This is the IP of the RPI which we saved previously.
- The destination port: For this specific example is 61617.
Expand Down Expand Up @@ -282,24 +291,22 @@ The Linux 6lowpan utility needs to have a ping response before sending a data pa

If this does not work, do as follow:

Check if the Nuttx address is part within the Linux/Raspbian neighborhood table.
Check if the Nuttx address is part of the Linux/Raspbian neighborhood table.
If it is saved there, remove it:
```bash
$ ip neigh # a bunch of address shall appear including yours (if you send a
message already)
$ ip neigh
fe80::2be:adde:de:fa00 dev lowpan0 FAILED
$ sudo ip neigh delete fe80::2be:adde:de:fa00 dev lowpan0 # Remove it.
```

Then, once deleted, add the Nuttx device it permanently (until reboot):
Then, once deleted, add the Nuttx device permanently (until reboot):

```bash
$ sudo ip neigh add fe80::2be:adde:de:fa00 dev lowpan0 00:be:ad:de:00:de:fa:00 # Add it with the
corret Hardware address.
$ sudo ip neigh add fe80::2be:adde:de:fa00 dev lowpan0 00:be:ad:de:00:de:fa:00
```

### NuttX part:
First, we need the ip of the board, so type ``ifconfig`` in the main menu. This should return somenthing like this:
### NuttX side
First, we need the IP of the board, so type ``ifconfig`` in the main menu. This should return something like this:
```bash
wpan0 Link encap:6LoWPAN HWaddr 00:be:ad:de:00:de:fa:00 at UP
inet6 addr: fe80::2be:adde:de:fa00/64
Expand Down Expand Up @@ -339,12 +346,12 @@ Introduce the reception port
Listening on 61616 for input packets
```

### Raspbian Part:
### Raspbian side

Go to the places that lives the previous download repo. Then go to this folder: ``/micro-ROS-bridge_RPI/RPI_6lowpan/Examples/6lowpan_send``
Go to the place where you previously downloaded the repo. Then go to this folder: ``/micro-ROS-bridge_RPI/6LowPAN_Tests/6lowpan_send``.

And execute with root privileges the next app: ``send_demo``.
These demos have two arguments: The first is the port to open in the destination and the second is the destination IP. An example of this specific demo could be:
Now execute with root privileges the next app: ``send_demo``.
These demos have two arguments: The first is the port to open in the destination and the second is the destination IP. A specific example for this demo could be:
``sudo send_demo 61616 fe80::2be:adde:de:fa00``

This app returns any data.
Expand Down
Loading