Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## Unreleased

- Add Renode device support.

## 0.0.3

- Add GDB and coredump debugging tools.
Expand Down
1 change: 1 addition & 0 deletions Documentation/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Device Interface
ntfc.device.host
ntfc.device.nuttx
ntfc.device.qemu
ntfc.device.renode
ntfc.device.serial
ntfc.device.sim

Expand Down
26 changes: 22 additions & 4 deletions Documentation/config-yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ This file defines device-under-test (DUT) setup and global configuration.
cores: # List of product cores
core0: # Core0 entry
name: 'core0-name'
device: 'sim|qemu|serial'
device: 'sim|qemu|renode|serial'
# Device-specific configuration

core1: # Core1 entry
name: 'core1-name'
device: 'sim|qemu|serial'
device: 'sim|qemu|renode|serial'
# Device-specific configuration


Expand All @@ -37,15 +37,15 @@ This file defines device-under-test (DUT) setup and global configuration.
cores:
core0:
name: 'core-name'
device: 'sim|qemu|serial'
device: 'sim|qemu|renode|serial'
# Device-specific configuration

product1:
name: "product1-name" # Product 1 identifier
cores:
core0:
name: 'core-name'
device: 'sim|qemu|serial'
device: 'sim|qemu|renode|serial'
# Device-specific configuration


Expand Down Expand Up @@ -228,6 +228,24 @@ At default NTFC automatically add the ``-kernel path_to_elf_image`` option
to ``exec_args``. You can also add your custom boot parameter with
``$IMAGE_ELF``, where ``$IMAGE_ELF`` will be replaced with the path to the ELF.

Renode
------

This device type is implemented in :class:`ntfc.device.renode.DeviceRenode`.

.. code-block:: yaml

cores:
core0:
name: 'main'
device: 'renode'
exec_path: 'renode'
exec_args: '-e "include @config/renode/board.resc"'

NTFC sets ``$bin`` to the ELF and creates a socket terminal named ``ntfc``
before ``exec_args`` runs. The script must load ``$bin`` and connect its
console UART with ``connector Connect <uart> ntfc``. See ``config/renode/``.

Serial Device
-------------

Expand Down
8 changes: 6 additions & 2 deletions Documentation/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ product: # many products can be supported in tests (pro
cores: # Cores configuration
core0: # Main core (core 0)
name: '' # Core name
device: '' # Choose a device: sim, qemu
device: '' # Choose a device: sim, qemu, renode, serial
exec_path: '' # Path of emulator execution for QEMU targets eg: `qemu-system-x86_64`
# Renode launcher for renode targets, eg: `renode`
# Path of serial port for serial targets, eg: `/dev/ttyACM0`
# Empty for simulator.
exec_args: '' # Args for emulator execution for QEMU tragets.
# Renode args for renode targets, eg '-e "include @board.resc"'.
# The script loads $bin and connects the console UART to
# the `ntfc` terminal, see config/renode/.
# Serial port configuration for serial targets, eg '9600,n,8,1'
# Empty for simulator.
exec_cwd: '' # (optional) working directory for the spawned sim/qemu process.
exec_cwd: '' # (optional) working directory for the spawned sim/qemu/renode process.
# Kernel-mode hostfs mounts resolve relative to this directory.
# Defaults to the core build directory for kernel-mode builds.
boot_timeout: 5 # (optional) seconds to wait for the first shell prompt. Defaults to 5
Expand Down
2 changes: 1 addition & 1 deletion Documentation/debug/gdb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ and connects to it one of two ways:
* **Remote target** (``debug.gdb.target``) - for QEMU or real hardware
with a debug probe. Set it to the ``host:port`` (or Unix socket path)
of a GDB stub. For QEMU, add ``-s`` to ``exec_args`` to get a stub on
``localhost:1234``.
``localhost:1234``. For Renode, add ``-e "machine StartGdbServer 3333"``.

* **Simulator PID-attach** (``debug.gdb.attach: true``) - for the
host-based NuttX simulator, where there's no remote stub, just a
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ versions of Python.

## Features

- NuttX simulator, QEMU and devices with serial port are supported
- NuttX simulator, QEMU, Renode and devices with serial port are supported

- Run the command from NSH and compare with the expected output

Expand Down
16 changes: 16 additions & 0 deletions config/nuttx-renode-nrf52840-dk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
config:
cwd: './external'
build_dir: './build'

product:

name: "ntfc-renode-nrf52840-dk"
cores:
core0:
name: 'main'
device: 'renode'
exec_path: 'renode'
exec_args: '-e "include @config/renode/nrf52840-dk.resc"'
defconfig: 'boards/arm/nrf52/nrf52840-dk/configs/ntfc'
boot_timeout: 30
flash: ''
18 changes: 18 additions & 0 deletions config/nuttx-renode-nucleo-h743zi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
config:
cwd: './external'
build_dir: './build'

product:

name: "ntfc-renode-nucleo-h743zi"
cores:
core0:
name: 'main'
device: 'renode'
exec_path: 'renode'
exec_args: '-e "include @config/renode/nucleo-h743zi.resc"'
defconfig: 'boards/arm/stm32h7/nucleo-h743zi/configs/ntfc'
boot_timeout: 30
flash: ''
kv:
CONFIG_STM32_PWR_IGNORE_ACTVOSRDY: "y"
17 changes: 17 additions & 0 deletions config/nuttx-renode-stm32f4discovery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# No CCM in Renode: single 112 KiB heap.
config:
cwd: './external'
build_dir: './build'

product:

name: "ntfc-renode-stm32f4discovery"
cores:
core0:
name: 'main'
device: 'renode'
exec_path: 'renode'
exec_args: '-e "include @config/renode/stm32f4discovery.resc"'
defconfig: 'boards/arm/stm32f4/stm32f4discovery/configs/ntfc'
boot_timeout: 30
flash: ''
16 changes: 16 additions & 0 deletions config/nuttx-renode-stm32f746g-disco.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
config:
cwd: './external'
build_dir: './build'

product:

name: "ntfc-renode-stm32f746g-disco"
cores:
core0:
name: 'main'
device: 'renode'
exec_path: 'renode'
exec_args: '-e "include @config/renode/stm32f746g-disco.resc"'
defconfig: 'boards/arm/stm32f7/stm32f746g-disco/configs/ntfc'
boot_timeout: 30
flash: ''
6 changes: 6 additions & 0 deletions config/renode/nrf52840-dk.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// nrf52840-dk for NuttX: the NuttX nRF52 serial driver uses the legacy
// (non-EasyDMA) UART registers, while Renode defaults to UARTE.
using "platforms/cpus/nrf52840.repl"

uart0:
easyDMA: false
17 changes: 17 additions & 0 deletions config/renode/nrf52840-dk.resc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
:name: nrf52840-dk
:description: NuttX on the nrf52840-dk. Console on sysbus.uart0, connected to the NTFC terminal.

using sysbus
mach create "nrf52840-dk"
machine LoadPlatformDescription $ORIGIN/nrf52840-dk.repl

$bin?=@nuttx

macro reset
"""
sysbus LoadELF $bin
"""

runMacro $reset

connector Connect sysbus.uart0 ntfc
17 changes: 17 additions & 0 deletions config/renode/nucleo-h743zi.resc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
:name: nucleo-h743zi
:description: NuttX on the nucleo-h743zi. Console on sysbus.usart3, connected to the NTFC terminal.

using sysbus
mach create "nucleo-h743zi"
machine LoadPlatformDescription @platforms/boards/nucleo_h753zi.repl

$bin?=@nuttx

macro reset
"""
sysbus LoadELF $bin
"""

runMacro $reset

connector Connect sysbus.usart3 ntfc
19 changes: 19 additions & 0 deletions config/renode/stm32f4discovery.resc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
:name: stm32f4discovery
:description: NuttX on the stm32f4discovery. Console on sysbus.usart2, connected to the NTFC terminal.

using sysbus
mach create "stm32f4discovery"
machine LoadPlatformDescription @platforms/boards/stm32f4_discovery-kit.repl

cpu PerformanceInMips 125

$bin?=@nuttx

macro reset
"""
sysbus LoadELF $bin
"""

runMacro $reset

connector Connect sysbus.usart2 ntfc
17 changes: 17 additions & 0 deletions config/renode/stm32f746g-disco.resc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
:name: stm32f746g-disco
:description: NuttX on the stm32f746g-disco. Console on sysbus.usart1, connected to the NTFC terminal.

using sysbus
mach create "stm32f746g-disco"
machine LoadPlatformDescription @platforms/boards/stm32f7_discovery-bb.repl

$bin?=@nuttx

macro reset
"""
sysbus LoadELF $bin
"""

runMacro $reset

connector Connect sysbus.usart1 ntfc
2 changes: 2 additions & 0 deletions src/ntfc/device/getdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from typing import TYPE_CHECKING, Callable, Dict

from .qemu import DeviceQemu
from .renode import DeviceRenode
from .serial import DeviceSerial
from .sim import DeviceSim

Expand All @@ -36,6 +37,7 @@
"sim": DeviceSim,
"qemu": DeviceQemu,
"serial": DeviceSerial,
"renode": DeviceRenode,
}

###############################################################################
Expand Down
9 changes: 9 additions & 0 deletions src/ntfc/device/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,21 @@ def host_open(self, cmd: List[str], uptime: int = 0) -> pexpect.spawn:

time.sleep(uptime)

self._post_spawn()

ret = self._wait_for_boot(self._conf.boot_timeout)
if ret is False: # pragma: no cover
raise TimeoutError("device boot timeout")

return self._child

def _post_spawn(self) -> None:
"""Run after the child is spawned and before the boot wait.

Transports that do not talk to the child's pty (e.g. a socket
opened by the emulator) attach here. Runs on every reopen.
"""

def _stop_impl(self) -> None:
"""Stop host device and kill the underlying process."""
if not self._child:
Expand Down
Loading