You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/blog/2024/11/using-wokwi-with-nuttx/index.md
+32-7Lines changed: 32 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,7 @@ The result will look something like this:
84
84
85
85

86
86
87
+
In addition to the debugging capability, it is recommended to enable merge bin option to have one binary in case of different bootloader usage such as MCUBoot. To enable that option select `Merge raw binary files into a single file` option under the `Board Selection` menu. The rest of this article assumes that this option is enabled.
87
88
88
89
After configuration and setup, we can use the following command to compile:
89
90
@@ -97,6 +98,7 @@ We should see the following output:
97
98
LD: nuttx
98
99
CP: nuttx.hex
99
100
CP: nuttx.bin
101
+
Generated: nuttx.merged.bin
100
102
```
101
103
102
104
After the compilation process is successfully completed, we need the `nuttx` file for the simulation.
@@ -115,7 +117,7 @@ For details about Wokwi configuration files, see [here](https://docs.wokwi.com/v
115
117
116
118
If we go back to the Simulation section after these definitions, we need to do two things:
117
119
118
-
- Add the `nuttx` file path to the `wokwi.toml` file
120
+
- Add the `nuttx`and `nuttx.merged.bin`file paths to the `wokwi.toml` file
119
121
- Add the circuit diagram in the `diagram.json` file to use in simulation
120
122
121
123
The file contents we need in this example project will be as follows:
@@ -124,7 +126,7 @@ The file contents we need in this example project will be as follows:
*Note: If merge bin option is not enabled, `firmware` variable in `wokwi.toml` file will be set to `nuttx.bin`, and `firmwareOffset` variable in the `diagram.json` file will be `0x1000`*
155
+
148
156
After creating the necessary files, we can start the simulation by pressing `F1` and selecting the `Wokwi: Start Simulator` option:
149
157
150
158

@@ -173,12 +181,31 @@ As a result of the process, the `wokwi.toml` file will look like this for this e
173
181
```toml
174
182
[wokwi]
175
183
version = 1
176
-
firmware = 'nuttx'
184
+
firmware = 'nuttx.merged.bin'
177
185
elf = 'nuttx'
178
186
gdbServerPort=3333
179
187
```
180
188
181
-
Also you need to create a launch configuration file for Visual Studio Code. You can create the file at `.vscode/launch.json` path or you can use `Open user settings (JSON)` option with pressing `F1` key.
189
+
After that, press `F1` and select `Wokwi: Start Simulator and Wait for Debugger` to start the simulator. Wokwi will then go into standby mode to allow the debugger to connect. In a separate terminal tab you can run GDB with `xtensa-esp32-elf-gdb` or similar commands for Xtensa devices or `riscv-none-elf-gdb` for RISC-V devices. To establish a proper connection with Wokwi, the following commands need to be applied:
190
+
191
+
```text
192
+
target remote :3333
193
+
set remote hardware-watchpoint-limit 2
194
+
mon reset halt
195
+
symbol-file nuttx
196
+
flushregs
197
+
c
198
+
```
199
+
200
+
These commands can be entered manually after starting the debugger, or they can be provided as a script file. For example, if the commands are saved in a file named `gdbinit`, you can run GDB with this command:
201
+
202
+
```bash
203
+
xtensa-esp32-elf-gdb -x gdbinit
204
+
```
205
+
206
+
After running the debugger, you can start to debug with Wokwi using the `F5` key in simulator.
207
+
208
+
If you want to avoid using the terminal-based debugger you can create a launch configuration file for Visual Studio Code. You can create the file at `.vscode/launch.json` path or you can use `Open user settings (JSON)` option with pressing `F1` key. This launch file is optional, does not necessary to enable debugging.
182
209
183
210

184
211
@@ -202,8 +229,6 @@ Here's a template you can use:
202
229
}
203
230
```
204
231
205
-
After that, press `F1` and select `Wokwi: Start Simulator and Wait for Debugger` to start the simulator. Wokwi will then go into standby mode to allow the debugger to connect. In a separate terminal tab you can run GDB with `xtensa-esp32-elf-gdb` or similar commands for Xtensa devices or `riscv-none-elf-gdb` for RISC-V devices. After running the debugger, you can start to debug with Wokwi using the `F5` key in simulator.
206
-
207
232
For more detailed information about the debugging, you can visit [this link](https://docs.wokwi.com/guides/debugger).
208
233
209
234
Of course, our hope is that you will not need this process :)
0 commit comments