Debugging oneos Lite IOT operating system based on renode

Time:2021-12-8

preface

We have used renode simulation to develop oneos Lite IOT operating system, and used the simulated serial port to outputHello OneOS-Lite。 If you want to have a deeper understanding of the execution process of the system or solve program bugs, it is essential to have the means of debugging!

From the perspective of debugging, this article will use GDB to debug oneos Lite IOT operating system based on renode. By debugging oneos Lite, you can also get to know her more directly.

Renode debugging support

Renode supports debugging applications running on emulated machines using GDB.

It uses the GDB remote protocol and supports the use of the most common GDB functions, such as breakpoints, observation points, single steps, memory access, etc.

The most important difference between debugging on real hardware is that when the simulated CPU stops, the virtual time will not progress. This makes the debugging process transparent to the simulation machine.

Compiler

First, of course, the compiler. Here we use the stm32f407vg renode project under oneos Lite. Enter the project and compile to generate elf files.
It is recommended to clone the source code warehousehttps://gitee.com/cmcc-oneos/OneOS-Lite, experience and try.

Debugging oneos Lite IOT operating system based on renode

Create simulation

In the article “using renode simulation to develop oneos Lite Internet of things operating system”, we have actually operated the whole process of how to simulate. In order to simplify the operation, we have written the steps into a script filestm32f4_discovery.resc, put onSTM32F407VG-renodeIn the project.

Use the following command:

include @D:\gitee\OneOS-Lite\projects\STM32F407VG-renode\stm32f4_discovery.resc

Debugging oneos Lite IOT operating system based on renode

Connect GDB

By running the following command in the renode monitor, we can start the GDB server on port 3333:

(machine-0) machine StartGdbServer 3333

Debugging oneos Lite IOT operating system based on renode

We can choose the appropriate tool chain to start GDB and connect to the remote target (here we choose the GDB debugger provided by the cube tool):

$ arm-none-eabi-gdb /path/to/application.elf
(gdb) target remote :3333

Execute the above command in the elf program directory (this can avoid the trouble of path):

Debugging oneos Lite IOT operating system based on renode

Start debugging

After GDB is connected to renode, the simulation can start. Just telling GDB to continue is not enough to start the program. We have to tell renode monitor to continue debugging.

(gdb) monitor start
(gdb) continue

After that, we can step, breakpoint, view stack hierarchy and so on as we normally use GDB debugger.
Debugging oneos Lite IOT operating system based on renode

Follow & & contact

gitee: https://gitee.com/cmcc-oneos/OneOS-Lite

docs: https://oneos-lite.com/

Official account:CMCC-OneOS

Recommended Today

Heavyweight Tencent cloud open source industry’s first etcd one-stop governance platform kstone

​ Kstone open source At the kubecon China Conference held by CNCF cloud native foundation on December 9, 2021,Tencent cloud container tke team released the open source project of kstone etcd governance platform. KstoneIt was initiated by the TKE team of Tencent cloud containerCloud native one-stop etcd governance project based on kubernetes。 The project originates […]