cc23-renode/talk.md

231 lines
5.5 KiB
Markdown
Raw Permalink Normal View History

- [Emulating the Badge under Renode (Eventually)](#emulating-the-badge-under-renode-eventually)
- [Talk Outline](#talk-outline)
- [About Me](#about-me)
- [What is Renode?](#what-is-renode)
- [Target Platforms](#target-platforms)
- [Whole-system Emulator](#whole-system-emulator)
- [CPU Cores](#cpu-cores)
- [Peripherals](#peripherals)
- [Peripherals Are Just Memory Addresses That Are Special](#peripherals-are-just-memory-addresses-that-are-special)
- [10% of the Functionality Gets You 90% of the Way There](#10-of-the-functionality-gets-you-90-of-the-way-there)
- [SVD files are your friend](#svd-files-are-your-friend)
- [Existing Peripherals in Renode](#existing-peripherals-in-renode)
- [Creating Peripherals](#creating-peripherals)
- [Networks in Renode](#networks-in-renode)
- [Other Goodies](#other-goodies)
- [Shortcomings](#shortcomings)
- [Extending Renode](#extending-renode)
- [First, Betrusted](#first-betrusted)
- [Emulating it under Renode](#emulating-it-under-renode)
- [ENGINE bug](#engine-bug)
- [Getting Started with Renode](#getting-started-with-renode)
- [Example project repl](#example-project-repl)
- [Example project resc](#example-project-resc)
- [Running it](#running-it)
- [How to Extend Renode](#how-to-extend-renode)
- [Demonstration!](#demonstration)
- [Running Badge Software in Renode](#running-badge-software-in-renode)
- [It Doesn't](#it-doesnt)
- [Xtensa is a New Architecture](#xtensa-is-a-new-architecture)
- [Extensive use of Boot ROM](#extensive-use-of-boot-rom)
- [Add a serial port](#add-a-serial-port)
- [Load SVD file](#load-svd-file)
- [Add Peripherals](#add-peripherals)
- [Slowly Advance](#slowly-advance)
- [What's Left](#whats-left)
- [Getting involved!](#getting-involved)
- [Thank you!](#thank-you)
# Emulating the Badge under Renode (Eventually)
# Talk Outline
- What is Renode?
- How is it extensible?
- What is the state of the badge?
# About Me
# What is Renode?
## Target Platforms
- Windows
- Mac
- Linux
- CI
## Whole-system Emulator
- Emulates CPU cores
- Emulates peripherals
- Emulates interconnects
## CPU Cores
- x86
- arm
- arm64
- ppc
- riscv
- sparc
- xtensa
## Peripherals
[Image of a CPU chart]
## Peripherals Are Just Memory Addresses That Are Special
- In a MMIO system, writing to a memory address does a thing
- Reading from an address gets a result
- Interrupts are just GPIOs
## 10% of the Functionality Gets You 90% of the Way There
- E.g. in a serial device, baudrate, timers, and parity/stop can be ignored
- Just "Tx", "Rx", and interrupt setup
- Most software works just fine if you return zeroes for invalid addresses
## SVD files are your friend
- Your chip probably comes with a SVD file
- This gives a map of RAM and peripherals
- Renode can parse this and use it for logging / defaults
## Existing Peripherals in Renode
- Built-in peripherals for a number of devices
- STM32
- NRF52
- IMXRT
- LiteX
- See https://github.com/renode/renode-infrastructure/tree/master/src/Emulator/Peripherals/Peripherals for more
## Creating Peripherals
- Renode is written in C#
- Like Java, C# has an `eval()` function
- Peripherals can be written and loaded at runtime
## Networks in Renode
- Built-in support for CAN, Ethernet, and Wireless
- Also possible to add networks at runtime
- No latency, just packets of data
- Different devices run at different speeds
## Other Goodies
- LCD monitor with touchscreen support
- Python interpreter for quick hacks
- Attach GDB to any CPU core
- Attach a serial port to a network connection
- Scriptable with Robot framework
- Log function calls
## Shortcomings
- Unable to unload modules
- Need to restart Renode when you change a file
- No real audio support
- Support for verifying I2S, but can't play it
- Only x64 hosts
- Runs under Rosetta on Mac
- Documentation needs work
- Use the source!
# Extending Renode
## First, Betrusted
- FPGA with VexRiscv
- 2nd FPGA with smaller VexRiscv
- 16-bit COM bus between them
- AES extensions
- x25519 "ENGINE" accelerator
- SHA accelerator
- Battery charger and manager
- Custom lcd, timers, and USB
## Emulating it under Renode
- Good enough to catch bugs!
## ENGINE bug
1. Added test vectors to the OS
2. Ran test vectors on physical device
3. Got test vectors passing in Renode
- Yay!
4. Someone (without a device!) decided to add more vectors
5. Tested in Renode
6. Passed
7. Failed on hardware
8. Bug in detecting overflow condition for normalization in hardware
9. https://github.com/betrusted-io/gateware/commit/817e284a3d92037b8cb0686735578d2bb60853e9
## Getting Started with Renode
1. Renode Platform Definition (`.repl`)
2. Renode Script (`.resc`)
## Example project repl
## Example project resc
## Running it
## How to Extend Renode
1. Find a peripheral that does what you want
- You might even find a compatible peripheral!
2. Copy it to your project
3. Change the constructor
4. Change the register set
5. Import the `.cs` file into Renode
6. Add it to your platform file
# Demonstration!
# Running Badge Software in Renode
## It Doesn't
## Xtensa is a New Architecture
- Added support for ESP32 family
- Merged quickly
- Few others use Xtensa
## Extensive use of Boot ROM
- Pulled ROM off device with esptool
- Load into RAM
- Set entrypoint
## Add a serial port
- Immediately get output
- Breaks immediately
## Load SVD file
## Add Peripherals
## Slowly Advance
## What's Left
- SPI Controller
- Interrupt Controller
# Getting involved!
- Try Renode for your projects!
- Add CI tests for your firmware!
- Explore binaries for unknown targets!
# Thank you!