Skip to content

Commit 3db2f28

Browse files
author
Julián Bermúdez Ortega
authored
Merge NSH over UART and NSH over USB tutorials. (#166)
1 parent c5d2d1f commit 3db2f28

5 files changed

Lines changed: 51 additions & 109 deletions

File tree

_data/docs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@
6464

6565
- title: Nuttx-specific Tutorials
6666
docs:
67-
- tutorials/advanced/nuttx/nsh_usb
68-
- tutorials/advanced/nuttx/nsh_uart
67+
- tutorials/advanced/nuttx/nsh
6968
- tutorials/advanced/nuttx/6lowpan
7069
- tutorials/advanced/nuttx/debugging
7170
- tutorials/advanced/nuttx/add_microros_config

_docs/tutorials/advanced/nuttx/nsh_usb/images/olimex_nsh_usb.jpg renamed to _docs/tutorials/advanced/nuttx/nsh/images/olimex_nsh_usb.jpg

File renamed without changes.

_docs/tutorials/advanced/nuttx/nsh_uart/images/olimex_uart.jpg renamed to _docs/tutorials/advanced/nuttx/nsh/images/olimex_uart.jpg

File renamed without changes.
Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,82 @@
11
---
2-
title: NSH console over UART
3-
permalink: /docs/tutorials/advanced/nuttx/nsh_uart/
2+
title: NSH console over UART & USB
3+
permalink: /docs/tutorials/advanced/nuttx/nsh/
44
---
55

6-
| RTOS | Board Compatible |
7-
|:-----:|:-----------------:|
6+
| RTOS | Board compatible |
7+
| :---: | :---------------: |
88
| NuttX | Olimex-STM32-E407 |
99

10-
NSH is a system console that can be used through different interfaces. In this tutorial, we will show how to use it over the UART peripheral. The UART (Universal Asynchronous Receiver-Transmitter) is a communication peripheral implemented on a micro-controller, which allows bidirectional serial communication.
10+
NSH is a system console that can be used through different interfaces.
11+
In this tutorial, we will show how to use it over the UART and USB peripherals.
1112

1213
## Hardware requirements:
14+
1315
- [Olimex-STM32-E407 board](https://www.olimex.com/Products/ARM/ST/STM32-E407/open-source-hardware)
1416
- [JTAG Flasher device](https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY/)
1517
- USB-TTL232 cable.
18+
- Mini USB cable.
1619

1720
## Create the firmware
1821

19-
For this tutorial we're going to execute the following configuration in the Micro-ROS build system:
22+
For this tutorial we are going to execute the following configuration in micro-ros-build:
23+
2024
```bash
2125
ros2 run micro_ros_setup create_firmware_ws.sh nuttx olimex-stm32-e407
26+
# For UART
2227
ros2 run micro_ros_setup configure_firmware.sh nsh_uart
28+
# For USB
29+
ros2 run micro_ros_setup configure_firmware.sh nsh
2330
```
2431

2532
Once the board is configured, we need to build it by typing the command:
33+
2634
```bash
2735
ros2 run micro_ros_setup build_firmware.sh
2836
```
2937

30-
If the compilation succeds, it should return this output:
38+
If the compilation succeeds, it should return this output:
3139
```bash
3240
CP: nuttx.hex
3341
CP: nuttx.bin
3442
```
35-
## Flash the firmware
3643

37-
The firmware is ready, it is just necessary to upload it. Now you need to do the following connection:
44+
# Flash the firmware
45+
46+
The firmware is ready, it is just necessary to upload it.
47+
Now you need to do the following connections:
3848
- Connect the JTAG flasher device.
39-
- Connect the USB TTL-232 with these pins out:
40-
- `USART3 TX` -> `TTL232 RX`
41-
- `USART3 RX` -> `TTL232 TX`
42-
- `GND Board` -> `TTL232 GND`
49+
- Connect the USB TTL-232 to the USART3 in case of UART communication:
50+
- `USART3 TX` -> `TTL232 RX`
51+
- `USART3 RX` -> `TTL232 TX`
52+
- `GND Board` -> `TTL232 GND`
4353

44-
It should look like this:
4554
![](images/olimex_uart.jpg)
55+
- Connect the mini USB to the OTG2 for USB communication.
4656

47-
Note: You can find multiple USB-TTL232 devices available. But, even though the Olimex board is 5V tolerant, we recommend to use a 3V3 USB-TTL232 cable. The [Olimex Official cable](https://www.olimex.com/Products/Components/Cables/USB-Serial-Cable/USB-Serial-Cable-F/) is our recommendation but any is compatible.
57+
![](images/olimex_nsh_usb.jpg)
4858

4959
Now flash the board by typing the next command:
5060
```bash
5161
ros2 run micro_ros_setup flash_firmware.sh
5262
```
5363

5464
This should return this output once the process is finished:
65+
5566
```bash
5667
wrote 49152 bytes from file nuttx.bin in 6.279262s (7.644 KiB/s)
5768
Info : Listening on port 6666 for tcl connections
5869
Info : Listening on port 4444 for telnet connections
5970
```
71+
6072
## Connect to the console
6173

62-
Finally, connect the USB cable to the PC and open a terminal. Type the command ``dmesg`` to know the direction of the device. It should return something like this:
74+
Finally, to use the NSH console you need to follow the steps listed below:
75+
- Push the reset button. The green LED will turn on to say that it is working properly.
76+
- Look for the device by typing `dmesg` on the console, this should return something like this:
77+
6378
```bash
79+
# For UART
6480
[17154.225244] usb 1-2: new full-speed USB device number 6 using xhci_hcd
6581
[17154.380060] usb 1-2: New USB device found, idVendor=0403, idProduct=6001, bcdDevice= 6.00
6682
[17154.380066] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
@@ -75,16 +91,30 @@ Finally, connect the USB cable to the PC and open a terminal. Type the command `
7591
[17154.402762] usb 1-2: Detected FT232RL
7692
[17154.403058] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0
7793

94+
# For USB
95+
[20614.570781] usb 1-2: new full-speed USB device number 7 using xhci_hcd
96+
[20614.724366] usb 1-2: New USB device found, idVendor=0525, idProduct=a4a7, bcdDevice= 1.01
97+
[20614.724372] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
98+
[20614.724375] usb 1-2: Product: CDC/ACM Serial
99+
[20614.724378] usb 1-2: Manufacturer: NuttX
100+
[20614.724381] usb 1-2: SerialNumber: 0
101+
[20614.745693] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
102+
[20614.746274] usbcore: registered new interface driver cdc_acm
103+
[20614.746277] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
78104
```
79-
80-
In this specific situation, the device is assigned to ``dev/ttyUSB0`` but it could be a different number.
105+
In this specific situation, the device is assigned to `dev/ttyUSB0` and `dev/ttyACM0` for UART and USB communication respectively. Note that the last number could be different.
81106

82107
Finally, execute the next command to open the NSH console:
83108
```
109+
# For UART
84110
sudo minicom -D /dev/ttyUSB0
111+
112+
# For USB
113+
sudo minicom -D /dev/ttyACM0
85114
```
86115

87-
Once the application is executed, push enter and it should return the next menu:
116+
Once the port is opened, **you need to push two times the Enter key** and it should show the next menu:
117+
88118
```bash
89119
nsh> ?
90120
help usage: help [-v] [<cmd>]
@@ -95,6 +125,4 @@ help usage: help [-v] [<cmd>]
95125

96126
Builtin Apps:
97127
nsh>
98-
```
99-
100-
Note: If you don't succeed with theses steps, check if you set a baud rate of 115200 bps and the configuration is set to 8N1 with no hardware and software flow control.
128+
```

_docs/tutorials/advanced/nuttx/nsh_usb/index.md

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)