|
| 1 | +--- |
| 2 | +title: Getting Started with an embedded board (WIP) |
| 3 | +permalink: /docs/tutorials/getting_started_embedded/ |
| 4 | +redirect_from: /getting_started/ |
| 5 | +--- |
| 6 | + |
| 7 | +Table of contents |
| 8 | + |
| 9 | +* [Running micro-ROS example at an embedded board](#running-micro-ROS-example) |
| 10 | +* [Running Micro XRCE-DDS example at an embedded board](#running-Micro-XRCE-DDS-example) |
| 11 | + |
| 12 | +## Introduction |
| 13 | + |
| 14 | +The aim of this section is to be able of running micro-ROS architecture examples using Docker files at one of the supported embedded boards. |
| 15 | + |
| 16 | +For that purpose, we are going to use a Olimex STM32-E407 board, that contains and Cortex-M4F microcontroller. |
| 17 | + |
| 18 | + |
| 19 | +## Running micro-ROS example |
| 20 | + |
| 21 | +At this example, we are going to flash the board with a binary that contains a NuttX App. This NuttX App is a micro-ROS client. This client will try to connect to the micro-ROS Agent running at your computer and exchange data using Micro XRCE-DDS. |
| 22 | + |
| 23 | +For that purpose, firs install [this](https://github.com/microROS/docker/tree/master/Embedded/NuttX/precompiled/micro-XRCE-DDS/olimex-stm32-e407) container at your Linux machine. |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +Build the container and compile ready to work `micro XRCE-DDS` with a subscriber and a publisher for the `OLIMEX STM32-E407` board: |
| 28 | +```bash |
| 29 | +docker build -t microros_uxdf4 . |
| 30 | +``` |
| 31 | +Access the container with privileges so that we can flash the board from within: |
| 32 | +```bash |
| 33 | +docker run -it -v /dev/bus/usb:/dev/bus/usb --privileged microros_uxdf4 /bin/bash |
| 34 | +``` |
| 35 | +Flash the board: |
| 36 | +```bash |
| 37 | +# inside the docker container |
| 38 | +cd nuttx |
| 39 | +./scripts/flash.sh olimex-stm32-e407 |
| 40 | +``` |
| 41 | +if successful, you should see something like this: |
| 42 | + |
| 43 | + |
| 44 | +``` |
| 45 | +cortex_m reset_config sysresetreq |
| 46 | +Info : clock speed 2000 kHz |
| 47 | +Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4) |
| 48 | +Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020 (STMicroelectronics), part: 0x6413, ver: 0x0) |
| 49 | +Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints |
| 50 | +adapter speed: 2000 kHz |
| 51 | +Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x4) |
| 52 | +Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020 (STMicroelectronics), part: 0x6413, ver: 0x0) |
| 53 | +target halted due to debug-request, current mode: Thread |
| 54 | +xPSR: 0x01000000 pc: 0x08000188 msp: 0x20006a70 |
| 55 | +auto erase enabled |
| 56 | +Info : device id = 0x10076413 |
| 57 | +Info : flash size = 1024kbytes |
| 58 | +wrote 131072 bytes from file nuttx.bin in 3.916489s (32.682 KiB/s) |
| 59 | +``` |
| 60 | + |
| 61 | +_Need to complete the tutorial!_ |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +## Running Micro XRCE-DDS example |
| 66 | + |
| 67 | +In this case, instead of running the complete micro-ROS stuck, we will run a DDS level example. For that purpose, the embedded board will execute a Micro XRCE-DDS example that will communicate with an Agent that is running in your Linux machine. |
| 68 | + |
| 69 | +First of all, downlod the [Docker machine](https://github.com/microROS/docker/blob/master/Embedded/NuttX/precompiled/micro-ROS/olimex_stm32-e407/Dockerfile) containing all the tools. Along with all the dependencies, this image contains micro-ROS publish/subscribe pre-built examples ready to flash and run on the board. |
| 70 | + |
| 71 | +## Build |
| 72 | + |
| 73 | +There are two options to get the image. |
| 74 | + |
| 75 | +1. Build your own the image using the docker file: |
| 76 | + |
| 77 | + ```bash |
| 78 | + docker build -t microros_stm32f4 . |
| 79 | + ``` |
| 80 | + |
| 81 | +1. Pull the image from DockerHub. |
| 82 | + ```bash |
| 83 | + docker pull microros/stm32-e407 |
| 84 | + ``` |
| 85 | + |
| 86 | +## Run |
| 87 | + |
| 88 | +Access the container with privileges so that we can flash the board from within: |
| 89 | + |
| 90 | +```bash |
| 91 | +docker run -it -v /dev/bus/usb:/dev/bus/usb --privileged microros/stm32-e407 /bin/bash |
| 92 | +``` |
| 93 | + |
| 94 | + Flash the board: |
| 95 | + |
| 96 | +```bash |
| 97 | +# inside the docker container |
| 98 | +cd nuttx |
| 99 | +openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/stm32f4x.cfg -c init -c "reset halt" -c "flash write_image erase nuttx.bin 0x08000000" |
| 100 | +``` |
| 101 | + |
| 102 | +if successful, you should see something like this: |
| 103 | + |
| 104 | +```bash |
| 105 | +. |
| 106 | +. |
| 107 | +. |
| 108 | +Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020, part: 0x6413, ver: 0x0) |
| 109 | +Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints |
| 110 | +Info : JTAG tap: stm32f4x.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4) |
| 111 | +Info : JTAG tap: stm32f4x.bs tap/device found: 0x06413041 (mfg: 0x020, part: 0x6413, ver: 0x0) |
| 112 | +target state: halted |
| 113 | +target halted due to debug-request, current mode: Thread |
| 114 | +xPSR: 0x01000000 pc: 0x080004b4 msp: 0x20000de4 |
| 115 | +auto erase enabled |
| 116 | +Info : device id = 0x10076413 |
| 117 | +Info : flash size = 1024kbytes |
| 118 | +wrote 65536 bytes from file nuttx.bin in 2.157869s (29.659 KiB/s) |
| 119 | +
|
| 120 | +``` |
| 121 | + |
| 122 | +At this point, you should have your board flashed with NuttX image containing an `nsh` application and a publisher and a subscriber using Micro XRCE-DDS. |
| 123 | + |
| 124 | +_To be completed!_ |
| 125 | + |
| 126 | + |
0 commit comments