1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

makefiles: tools/renode: add support for Renode

This commit is contained in:
Piotr Zierhoffer 2017-11-07 17:14:41 +01:00 committed by Michael Gielda
parent 663bd8a71c
commit b424274a72
4 changed files with 118 additions and 0 deletions

View File

@ -409,6 +409,13 @@ debug-server:
exit 1; }
$(DEBUGSERVER) $(DEBUGSERVER_FLAGS)
emulate:
@command -v $(EMULATOR) >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'${COLOR_RED}Emulation program $(EMULATOR) not found. Aborting.${COLOR_RESET}'; \
exit 1; }
$(EMULATOR) $(EMULATOR_FLAGS)
reset:
@command -v $(RESET) >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \

25
dist/tools/renode/README.md vendored Normal file
View File

@ -0,0 +1,25 @@
# Emulation using Renode
## Introduction
[Renode](http://renode.io) is a virtual development tool for multinode embedded networks (both wired and wireless) enabling a scalable workflow for building effective, tested and secure IoT systems, created by [Antmicro](http://antmicro.com/blog/2017/08/renode-press-release/).
It can easily be used to run applications on a broad range of embedded platforms without any changes in the code itself, as if you were running on real hardware - but with more possibilities.
## Installation
### From package
Packages for macOS, deb-based and rpm-based systems, for Windows and for Arch Linux are available on [GitHub](https://github.com/renode/renode/releases/latest).
### From source
Follow the installation instructions on Renode's [GitHub](https://github.com/renode/renode#installation) page.
After compilation is successful, ensure that `renode` is available on your `PATH`. One way to do so, is via symlink: `sudo ln -s path/to/renode/repository/run.sh /usr/local/bin/renode`.
### Testing
After installation, verify if Renode is working using `renode --help`. You should be presented with a help screen.
## Usage
From within RIOT-OS, you can use `make emulate` to start emulation. It expects a board definition file in `boards/<BOARD>/dist/board.resc`.
The board definition file will tell Renode how to setup an emulation session. The application binary file (`*.elf`) is available using the variable `$image_file`.
For an example, refer to `boards/cc2538dk/dist/board.resc`.

84
dist/tools/renode/run-renode.sh vendored Executable file
View File

@ -0,0 +1,84 @@
#!/bin/sh
#
# Unified Renode script for RIOT
#
# This script is supposed to be called from RIOTs make system,
# as it depends on certain environment variables.
#
# It will start the Renode emulator, providing it with several environment
# variables:
# $image_file Full path to the image file (see $IMAGE_FILE below)
#
# Global environment variables used:
# RENODE: Renode command name, default: "renode"
# RENODE_CONFIG: Renode configuration file name,
# default: "${RIOTBOARD}/${BOARD}/dist/board.resc"
# RENODE_BIN_CONFIG: Renode intermediate configuration file name,
# default: "${BINDIR}/board.resc"
#
# @author Bas Stottelaar <basstottelaar@gmail.com>
# Default path to Renode configuration file
: ${RENODE_CONFIG:=${RIOTBOARD}/${BOARD}/dist/board.resc}
# Default path to Renode intermediate configuration file
: ${RENODE_BIN_CONFIG:=${BINDIR}/board.resc}
# Default Renode command
: ${RENODE:=renode}
# Image file used for emulation
# Default is to use $ELFFILE
: ${IMAGE_FILE:=${ELFFILE}}
#
# config test section.
#
test_config() {
if [ ! -f "${RENODE_CONFIG}" ]; then
echo "Error: Unable to locate Renode board file"
echo " (${RENODE_CONFIG})"
exit 1
fi
}
#
# helper section.
#
write_config() {
echo "\$image_file = '${IMAGE_FILE}'" > "${RENODE_BIN_CONFIG}"
echo "include @${RENODE_CONFIG}" >> "${RENODE_BIN_CONFIG}"
}
#
# now comes the actual actions
#
do_write() {
test_config
write_config
echo "Script written to '${RENODE_BIN_CONFIG}'"
}
do_start() {
test_config
write_config
sh -c "${RENODE} '${RENODE_BIN_CONFIG}'"
}
#
# parameter dispatching
#
ACTION="$1"
case "${ACTION}" in
write)
echo "### Writing emulation script ###"
do_write
;;
start)
echo "### Starting Renode ###"
do_start
;;
*)
echo "Usage: $0 {write|start}"
exit 2
;;
esac

View File

@ -0,0 +1,2 @@
export EMULATOR ?= $(RIOTBASE)/dist/tools/renode/run-renode.sh
export EMULATOR_FLAGS ?= start