Skip to content

Commit 4f6d78c

Browse files
author
Juan Flores
committed
Updating index
1 parent d1773e3 commit 4f6d78c

1 file changed

Lines changed: 0 additions & 351 deletions

File tree

  • _docs/tutorials/advanced/nuttx_getting_started

‎_docs/tutorials/advanced/nuttx_getting_started/index.md‎

Lines changed: 0 additions & 351 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ the defconfig files for NuttX, OFERA project has created.
1919
- [UDP echo server](#How-to-execute-UDPEcho-server-example)
2020
- [TCP echo server](#How-to-execute-TCP-Echo-server-example)
2121
- [MRF24J40-6LowPan through SPI](#How-to-use-MRF24j40-6LowPan)
22-
- [How to set 6lowpan communication between Raspbian and Nuttx.](#How-to-set-6lowpan-communication-between-Raspbian-and-Nuttx)
2322
- [ADC](#How-to-use-the-ADC-demo)
2423
- [Telemetry](#How-to-execute-telemetry-app)
2524
- [Power Manager](#How-to-execute-Power-Manager-example)
@@ -989,357 +988,7 @@ This version of the 6lowpan stack, have interoperability with 6lowpan stack of L
989988
990989
The ping between NuttX devices work properly, but with Linux, devices don't work properly and a final point to know is the dynamic association and multi-hop communication doesn't work properly. So, communications are only point-to-point.
991990
992-
## How to set 6lowpan communication between Raspbian and Nuttx.
993991
994-
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.
995-
996-
### What do we need?
997-
998-
- Raspberry Pi 3
999-
- micro-SD card (almost 16gb) with Raspbian lite already installed.
1000-
- Olimex-STM32-E407 board.
1001-
- Two PMODRF2 module which are base on the MRF24J40 module.
1002-
- PC with Ubuntu (It works fine with Ubuntu 16.04)
1003-
1004-
### How to set-up 6lowpan RPI?
1005-
1006-
First, we need to connect the PMODRF2 module to the RPI, so we need to set the next connections:
1007-
1008-
| | RPI | PMODRF2 |
1009-
| -- | -- | -- |
1010-
| VIN | 1 | 12 |
1011-
| GND | 20 | 11 |
1012-
| RESET | 17 | 8 |
1013-
| INT | 16 | 7 |
1014-
| SDI | 19 | 2 |
1015-
| SDO | 21 | 3 |
1016-
| SCK | 23 | 4 |
1017-
| CS | 26 | 1 |
1018-
1019-
In the next links you can see the pinout of each board:
1020-
[- Raspberry Pi 3 pinout.](https://i.pinimg.com/originals/84/46/ec/8446eca5728ebbfa85882e8e16af8507.png)
1021-
[- PMODRF2 pionut.](https://reference.digilentinc.com/reference/pmod/pmodrf2/start)
1022-
1023-
Once you've set all the wires, power-on the RPI and download the next repository inside the RPI.
1024-
https://github.com/micro-ROS/micro-ROS-bridge_RPI
1025-
1026-
Execute the next command:
1027-
```sudo ./micro-ROS-bridge_RPI/RPI_6lowpan/script.sh```
1028-
1029-
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 connection are fine:
1030-
```dmesg | grep mrf24j40```
1031-
1032-
And if everything is fine, it should return the next:
1033-
```bash
1034-
pi@raspberrypi:~ $ dmesg | grep mrf24j40
1035-
[ 4.075212] mrf24j40 spi0.0: probe(). IRQ: 169
1036-
```
1037-
The last point is to set-up the network.
1038-
1039-
- Set the PAN ID: ``sudo iwpan dev wpan0 set pan_id 0xabcd``
1040-
- Set the page and channel: ``sudo iwpan phy phy0 set channel 0 26``
1041-
- Set the short address: ``sudo iwpan dev wpan0 set short_addr 0x4204`` (Each board must a different one)
1042-
- Attach the phy layer to the lowpan: ``sudo ip link add link wpan0 name lowpan0 type lowpan``
1043-
- Bring up the WPAN0 interface: ``sudo ip link set wpan0 up``
1044-
- Bring up the RPI lowpan: ``sudo ip link set lowpan0 up``
1045-
1046-
1047-
Now the RPI is ready to send and receive messages from a NuttX board or another RPI.
1048-
1049-
1050-
### How to set-up 6lowpan NuttX?
1051-
1052-
First, we need to do the connections between the Olimex board and the PMODRF2 module.
1053-
1054-
- `Board D13` -> `MRF24J40 SCLK`
1055-
- `Board D12` -> `MRF24J40 MISO`
1056-
- `Board D11` -> `MRF24J40 MOSI`
1057-
- `Board D10` -> `MRF24J40 CS`
1058-
- `Board D8` -> `MRF24J40 INT`
1059-
1060-
Once the wiring is finished, we need to compile and upload the firmware. Type the next commands:
1061-
1062-
o to the main folder of NuttX and type the command to configure the board:
1063-
`./scripts/configure.sh olimex-stm32-e407 mrf24j40-6lowpan`
1064-
1065-
Compile:
1066-
`make`
1067-
1068-
Upload:
1069-
`./scripts/flash.sh olimex-stm32-e407`
1070-
1071-
It should return somenthing like this:
1072-
1073-
- Configuration:
1074-
```
1075-
Copy files
1076-
Refreshing...
1077-
```
1078-
- Compilation:
1079-
```
1080-
CP: nuttx.hex
1081-
CP: nuttx.bin
1082-
```
1083-
- Upload the firmware
1084-
```
1085-
wrote 131072 bytes from file nuttx.bin in 3.763846s (34.008 KiB/s)
1086-
Info : Listening on port 6666 for tcl connections
1087-
Info : Listening on port 4444 for telnet connections
1088-
```
1089-
(The number of written bytes could be different in each board)
1090-
1091-
1092-
Finally, connect the mini USB cable to the USB OTG2, and the console should return the next:
1093-
1094-
```bash
1095-
nsh> ?
1096-
help usage: help [-v] [<cmd>]
1097-
1098-
[ cd df help ls mw set true
1099-
? cp echo hexdump mb ps sh uname
1100-
addroute cmp exec ifconfig mkdir pwd sleep umount
1101-
basename dirname exit ifdown mh rm test unset
1102-
break dd false ifup mount rmdir telnetd usleep
1103-
cat delroute free kill mv route time xd
1104-
1105-
Builtin Apps:
1106-
udp_6lowpan ping6 i8sak
1107-
```
1108-
1109-
We're going to configure the network. Execute udp_6lowpan.
1110-
The program will ask you if you want to configure the network. Type **Y** to start the configuration process.
1111-
**Important note:** If you don't configure the network, the connection won't be possible with other boards.**
1112-
1113-
Then will ask you if you want to set this board as a coordinator or as a node.
1114-
The difference between a coordinator and a node is that the first one can work as a router, coordinating the network traffic of up to 8 nodes.
1115-
On the other hand, the node is an endpoint device which only sends and receive data, it doesn't coordinate the traffic of the other devices.
1116-
1117-
For this example, we will set ``coordinator``.
1118-
1119-
Finally will ask for an ID. This ID must be unique for each board. If everything goes fine, this should return the next:
1120-
1121-
```bash
1122-
Your hardware address is: i8sak set eaddr 00:fa:de:00:de:ad:be:00
1123-
1124-
i8sak: accepting all assoc requests
1125-
i8sak: daemon started
1126-
ifup wpan0...OK
1127-
Mounting proc file system
1128-
wpan0 Link encap:6LoWPAN HWaddr 00:be:ad:de:00:de:fa:00 at UP
1129-
inet6 addr: fe80::2be:adde:de:fa00/64
1130-
inet6 DRaddr: ::/64
1131-
1132-
RX: Received Fragment Errors
1133-
00000000 00000000 00000000
1134-
IPv6 Dropped
1135-
00000000 00000000
1136-
TX: Queued Sent Errors Timeouts
1137-
00000000 00000000 00000000 00000000
1138-
Total Errors: 00000000
1139-
1140-
1141-
1142-
1143-
Available commands
1144-
-To send a package type: write
1145-
-To receive a package type: read
1146-
-To exit type: quit
1147-
1148-
```
1149-
1150-
** At this point the network is ready to work!**
1151-
1152-
Finally type ``quit`` two times to close the app and come back to the main menu.
1153-
1154-
### Sending a message from NuttX to Raspbian:
1155-
1156-
#### Raspberry Part:
1157-
1158-
We need to check our IP, so type in the console: ```ifconfig```
1159-
This should return something like this:
1160-
1161-
```bash
1162-
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
1163-
inet 192.168.1.173 netmask 255.255.255.0 broadcast 192.168.1.255
1164-
inet6 fe80::47b1:3e6c:17fa:a06a prefixlen 64 scopeid 0x20<link>
1165-
ether b8:27:eb:69:5b:e7 txqueuelen 1000 (Ethernet)
1166-
RX packets 538496 bytes 394976364 (376.6 MiB)
1167-
RX errors 0 dropped 2416 overruns 0 frame 0
1168-
TX packets 358285 bytes 51814460 (49.4 MiB)
1169-
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
1170-
1171-
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
1172-
inet 127.0.0.1 netmask 255.0.0.0
1173-
inet6 ::1 prefixlen 128 scopeid 0x10<host>
1174-
loop txqueuelen 1000 (Local Loopback)
1175-
RX packets 48 bytes 7076 (6.9 KiB)
1176-
RX errors 0 dropped 0 overruns 0 frame 0
1177-
TX packets 48 bytes 7076 (6.9 KiB)
1178-
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
1179-
1180-
lowpan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1280
1181-
inet6 fe80::a9cd:ff:fe00:4204 prefixlen 64 scopeid 0x20<link>
1182-
inet6 fe80::9c6e:87a5:eb60:84d0 prefixlen 64 scopeid 0x20<link>
1183-
unspec 9E-6E-87-A5-EB-60-84-D0-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC)
1184-
RX packets 2 bytes 132 (132.0 B)
1185-
RX errors 0 dropped 0 overruns 0 frame 0
1186-
TX packets 95 bytes 9480 (9.2 KiB)
1187-
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
1188-
1189-
wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
1190-
ether b8:27:eb:3c:0e:b2 txqueuelen 1000 (Ethernet)
1191-
RX packets 0 bytes 0 (0.0 B)
1192-
RX errors 0 dropped 0 overruns 0 frame 0
1193-
TX packets 0 bytes 0 (0.0 B)
1194-
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
1195-
1196-
wpan0: flags=195<UP,BROADCAST,RUNNING,NOARP> mtu 123
1197-
unspec 9E-6E-87-A5-EB-60-84-D0-00-00-00-00-00-00-00-00 txqueuelen 300 (UNSPEC)
1198-
RX packets 61 bytes 4775 (4.6 KiB)
1199-
RX errors 0 dropped 0 overruns 0 frame 0
1200-
TX packets 107 bytes 8199 (8.0 KiB)
1201-
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
1202-
```
1203-
1204-
The part which is important for us, is the next fragment:
1205-
1206-
``` bash
1207-
lowpan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1280
1208-
inet6 fe80::a9cd:ff:fe00:4204 prefixlen 64 scopeid 0x20<link>
1209-
inet6 fe80::9c6e:87a5:eb60:84d0 prefixlen 64 scopeid 0x20<link>
1210-
unspec 9E-6E-87-A5-EB-60-84-D0-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC)
1211-
RX packets 2 bytes 132 (132.0 B)
1212-
RX errors 0 dropped 0 overruns 0 frame 0
1213-
TX packets 95 bytes 9480 (9.2 KiB)
1214-
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
1215-
```
1216-
1217-
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.
1218-
`fe80::9c6e:87a5:eb60:84d0``
1219-
1220-
Go to the place where lives the repo that you downloaded previously. Go to ``micro-ROS-bridge_RPI/RPI_6lowpan/Examples/6lowpan_recv``
1221-
Finally, execute recv_demo telling to open the 61616 port. Type this command: ``./recv_demo 61616``
1222-
1223-
At this point, the RPI is ready to receive incoming packages.
1224-
1225-
### NuttX part:
1226-
1227-
Execute ``udp_6lowpan`` application.
1228-
This will ask you if you want to configure the network. Type N, because is already configured.
1229-
Now you're in the main menu of the App. Type ``write`` to start the sending mode and will ask for the next data:
1230-
- The destination IP: This is the IP of the RPI which we saved previously.
1231-
- The destination port: For this specific example is 61617.
1232-
- The origin port: This is the port that we want to open to send the message, for example, we could use 61618.
1233-
1234-
At this point it should look like this:
1235-
1236-
``` bash
1237-
nsh> udp_6lowpan
1238-
Do you want to execute the automatic WPAN configuration? (y/n)
1239-
1240-
Available commands
1241-
-To send a package type: write
1242-
-To receive a package type: read
1243-
-To exit type: quit
1244-
Introduce the IVP6 Destination
1245-
Introduce the port destination
1246-
Introduce the port origin
1247-
Conection data:
1248-
-Dest_IP: fe80::857:adfe:5a82:c7ac
1249-
-Dest_Port: 61616
1250-
-Origin_Port: 61617
1251-
Introduce a message to send:
1252-
```
1253-
Now if you type somenthing and press enter NuttX should show the next:
1254-
```bash
1255-
Introduce a message to send:
1256-
Sending 5 characters: hello
1257-
```
1258-
1259-
And the RPI, should show the next message:
1260-
```bash
1261-
Received (from fe80::2be:adde:de:fa00): hello
1262-
```
1263-
1264-
### Sending a message from the Raspbian to NuttX:
1265-
1266-
**Very important note! :**
1267-
The Linux 6lowpan utility needs to have a ping response before sending a data package, but the ping implementation of NuttX is not compatible. So the solution for this problem is to send a message from NuttX to Linux, just to add the NuttX direction to the neighborhood table.
1268-
1269-
If this does not work, do as follow:
1270-
1271-
Check if the Nuttx address is part within the Linux/Raspbian neighborhood table.
1272-
If it is, remove it:
1273-
```bash
1274-
$ ip neigh # a bunch of address shall appear including yours (if you send a
1275-
message already)
1276-
fe80::2be:adde:de:fa00 dev lowpan0 FAILED
1277-
$ sudo ip neigh delete fe80::2be:adde:de:fa00 dev lowpan0 # Remove it.
1278-
```
1279-
1280-
Then once delete add the Nuttx device it permanently (until reboot):
1281-
1282-
```bash
1283-
$ sudo ip neigh add fe80::2be:adde:de:fa00 dev lowpan0 00:be:ad:de:00:de:fa:00 # Add it with the
1284-
corret Hardware address.
1285-
```
1286-
1287-
#### NuttX part:
1288-
First we need the ip of the board, so type ``ifconfig`` in the main menu. This should return somenthing like this:
1289-
```bash
1290-
wpan0 Link encap:6LoWPAN HWaddr 00:be:ad:de:00:de:fa:00 at UP
1291-
inet6 addr: fe80::2be:adde:de:fa00/64
1292-
inet6 DRaddr: ::/64
1293-
1294-
RX: Received Fragment Errors
1295-
00000000 00000000 00000000
1296-
IPv6 Dropped
1297-
00000000 00000000
1298-
TX: Queued Sent Errors Timeouts
1299-
00000000 00000000 00000000 00000000
1300-
Total Errors: 00000000
1301-
1302-
IPv6 TCP UDP ICMPv6
1303-
Received 0000 0000 0000 0000
1304-
Dropped 0000 0000 0000 0000
1305-
IPv6 VHL: 0000
1306-
Checksum ---- 0000 0000 ----
1307-
TCP ACK: 0000 SYN: 0000
1308-
RST: 0000 0000
1309-
Type 0000 ---- ---- 0000
1310-
Sent 0000 0000 0000 0000
1311-
Rexmit ---- 0000 ---- ----
1312-
```
1313-
1314-
For us is important to remember the **inet6_addr** which is: ``fe80::2be:adde:de:fa00``
1315-
1316-
Execute ``udp_6lowpan`` app, type ``N`` to the configuration request and finally type read, to start the receiving mode.
1317-
Type the port that you want to open, for example, the 61616. And it should look like this mean is waiting for the incoming message.
1318-
1319-
```bash
1320-
Available commands
1321-
-To send a package type: write
1322-
-To receive a package type: read
1323-
-To exit type: quit
1324-
Introduce the reception port
1325-
Listening on 61616 for input packets
1326-
```
1327-
1328-
#### Raspbian Part:
1329-
1330-
Go to the places that lives the previous download repo. Then go to this folder: ``/micro-ROS-bridge_RPI/RPI_6lowpan/Examples/66lowpan_send``
1331-
1332-
And execute with root privileges the next app: ``send_demo``.
1333-
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:
1334-
``sudo send_demo 61616 fe80::2be:adde:de:fa00``
1335-
1336-
This app returns any data.
1337-
1338-
On the other hand, in the NuttX board we will see the next:
1339-
```bash
1340-
Received 12 bytes from 80fe:0000:0000:0000:cda9:ff00:00fe:0442 port 39464
1341-
Received packet: Hola mundo !
1342-
```
1343992
1344993
## How to use the ADC demo
1345994

0 commit comments

Comments
 (0)