Follow along at https://p.xobs.io/fa22
I find it useful. Maybe you will, too!
Emulation is a lie
flash: Memory.MappedMemory @ sysbus 0x10040000
size: 0x00008000
sram: Memory.MappedMemory @ sysbus 0x20000000
size: 0x00001000
cpu: CPU.CortexM @ sysbus
cpuType: "cortex-m0+"
PerformanceInMips: 24
nvic: nvic
nvic: IRQControllers.NVIC @ sysbus 0xE000E000
IRQ -> cpu@0
bluenrg-1.repl
Firmware is a series of instructions executed by the CPU in order to accomplish a task
Firmware is Memory
sysbus LoadELF @firmware.elf
sysbus LoadBinary @flas.bin 0x10040000
LoadBinary
!
flash: Memory.MappedMemory @ sysbus 0x10040000
size: 0x00008000
sram: Memory.MappedMemory @ sysbus 0x20000000
size: 0x00001000
nvic: IRQControllers.NVIC @ sysbus 0xE000E000
IRQ -> cpu@0
// 👇 Add a UART with IRQ #10 at address 0x40300000
uart: UART.PL011 @ sysbus 0x40300000
-> nvic@10
cpu: CPU.CortexM @ sysbus
nvic: nvic
cpuType: "cortex-m0+"
PerformanceInMips: 24
bluenrg-1.repl
machine LoadPlatformDescription @bluenrg-1.repl
sysbus LoadBinary @BLE_Chat_Server.bin 0x10040000
cpu VectorTableOffset 0x10040000
cpu SP `sysbus ReadDoubleWord 0x10040000`
cpu PC `sysbus ReadDoubleWord 0x10040004`
start
BlueNRG-1.resc
Hackaday Supercon 2019
Betrusted ENGINE
*** Settings ***
Suite Setup Setup
Suite Teardown Teardown
Test Setup Reset Emulation
Test Teardown Test Teardown
Resource ${RENODEKEYWORDS}
*** Variables ***
${UART} sysbus.uart0
${URI} @https://dl.antmicro.com/projects/renode
${LIS2DS12}= SEPARATOR=
... """ ${\n}
... using "platforms/cpus/nrf52840.repl" ${\n}
... ${\n}
... lis2ds12: Sensors.LIS2DS12 @ twi1 0x1c ${\n}
... ${SPACE*4}IRQ -> gpio0@28 ${\n}
... """
*** Keywords ***
Create Machine
Execute Command mach create
Execute Command machine
... LoadPlatformDescriptionFromString ${LIS2DS12}
Execute Command sysbus LoadELF
... ${URI}/nrf52840--zephyr_lis2dh.elf
*** Test Cases ***
Should Read Acceleration
Create Machine
Create Terminal Tester ${UART}
Execute Command sysbus.twi1.lis2ds12 AccelerationX 10
Execute Command sysbus.twi1.lis2ds12 AccelerationY 5
Execute Command sysbus.twi1.lis2ds12 AccelerationZ -5
Start Emulation
Wait For Line On Uart
... x 9.997213 , y 4.997410 , z -4.999803
LIS2DS12.robot
BlueNRG2.svd
sysbus ApplySVD @BlueNRG2.svd
i @peripherals/trng_server.cs
private enum Registers
{
STATUS = 0x0,
DATA = 0x4,
URANDOM = 0x8,
URANDOM_VALID = 0xc,
EV_STATUS = 0x10,
EV_PENDING = 0x14,
EV_ENABLE = 0x18,
}
private void DefineRegisters()
{
Registers.STATUS.Define(this) // RDY is set on reset
.WithFlag(0, name: "ready",
valueProviderCallback: _ => true)
.WithFlag(1, name: "avail",
valueProviderCallback: _ => true)
;
Registers.DATA.Define(this)
.WithValueField(0, 32, FieldMode.Read,
valueProviderCallback: _ =>
{
return (uint)rng.Next();
},
name: "DATA"
);
}
From trng_server.cs
Auto-complete and contextual popups
emulation CreateSwitch "switch"
emulation CreateTap "renodetap" "tap"
connector Connect host.tap switch
connector Connect sysbus.wifi.wf200 switch
SoC → COM-SOC → COM → COM-EC → EC → EC-WIFI → WF200 → Tap → Internet