SiliconTwin.RP2350.MicroPython
1.3.2
See the version list below for details.
dotnet add package SiliconTwin.RP2350.MicroPython --version 1.3.2
NuGet\Install-Package SiliconTwin.RP2350.MicroPython -Version 1.3.2
<PackageReference Include="SiliconTwin.RP2350.MicroPython" Version="1.3.2" />
<PackageVersion Include="SiliconTwin.RP2350.MicroPython" Version="1.3.2" />
<PackageReference Include="SiliconTwin.RP2350.MicroPython" />
paket add SiliconTwin.RP2350.MicroPython --version 1.3.2
#r "nuget: SiliconTwin.RP2350.MicroPython, 1.3.2"
#:package SiliconTwin.RP2350.MicroPython@1.3.2
#addin nuget:?package=SiliconTwin.RP2350.MicroPython&version=1.3.2
#tool nuget:?package=SiliconTwin.RP2350.MicroPython&version=1.3.2
RP2350Sharp
RP2350Sharp is a register-accurate emulator for the Raspberry Pi RP2350 (Raspberry Pi Pico 2) microcontroller, written entirely in modern C# (.NET 10). It models the dual-architecture core — Arm Cortex-M33 and the Hazard3 RISC-V cores — along with the BusInterconnect and peripherals, and runs real RP2350 firmware (including MicroPython) without modification. The Arm core runs a per-instruction cycle model calibrated against real silicon (branch, wide-fetch and flash-wait penalties), so Cycles, the timers and DWT CYCCNT share one clk_sys clock; it is not cycle-exact — see LIMITATIONS.md.
It is the RP2350 sibling of RP2040Sharp, sharing its design lineage from the excellent rp2040js project by Uri Shaked.
Packages
| Package | Description | License |
|---|---|---|
RP2350Sharp |
The emulator engine: dual Cortex-M33 / Hazard3 CPU, BusInterconnect, peripherals, and the SiliconTwin.Abstractions adapter (RP2350Mcu). AOT-compatible. |
BUSL-1.1 |
RP2350Sharp.Wireless |
CYW43439 host-interface (gSPI) protocol translation for the Pico 2 W: gSPI, backplane, SDPCM/WLC and the BT HCI shared bus into a virtual network (the radio firmware is parked, never executed; no RF). | BUSL-1.1 |
SiliconTwin.RP2350 |
Fluent, deterministic firmware test harness (UART capture/inject, GPIO logic analyzer + VCD, timing, FluentAssertions). | BUSL-1.1 |
SiliconTwin.RP2350.MicroPython |
MicroPython VM introspection (decode mp_obj_t, resolve QSTRs, walk mp_state_ctx). |
BUSL-1.1 |
SiliconTwin.RP2350.GdbHost |
GDB server + inspection CLI (rp2350-gdb) for the emulator. |
BUSL-1.1 |
SiliconTwin.RP2350.DebugAdapter |
Mixed managed↔native DAP server (rp2350-dap) for nanoFramework in Rider / VS Code. |
BUSL-1.1 |
SiliconTwin.RP2350.Native |
The core as a NativeAOT shared library with a stable C ABI, for C / C++ hosts (.vcxproj) with no .NET installed. Built and packed by native.yml. |
BUSL-1.1 |
SiliconTwin.Abstractions
RP2350Sharp implements SiliconTwin.Abstractions (MIT, dependency-free, AOT-safe), the contracts shared by every Silicon Twin core, so a host — a circuit simulator, a test kit, a C ABI, a UI — drives the RP2350 through the same API it uses for an AVR or an STM32. RP2350Mcu wraps the machine and implements IMcu plus IGpio (one bank with the bonded pads of the package), IPwmSource, IAdcInput and IPeripheralMap (UART0/1, SPI0/1, I2C0/1 at byte level).
using RP2350.Embedding;
using RP2350.Peripherals;
using SiliconTwin.Abstractions;
using IMcu mcu = new RP2350Mcu(new RP2350MachineOptions { PinLevelBuses = PinLevelBus.I2c }); // owns the machine
mcu.Load(FirmwareImage.FromUf2(File.ReadAllBytes("firmware.uf2")));
mcu.Reset(ResetKind.Power);
var bank = ((IGpio)mcu).Banks[0];
bank.WatchMask = 1UL << 15; // only GP15
bank.PinChanged += (in PinChange e) => // fires inside Run, stamped with the exact cycle
Console.WriteLine($"GP15 -> {(e.IsHigh(15) ? "HIGH" : "LOW")} at {CycleBudget.ToSeconds(e.Cycle, mcu.ClockHz) * 1e3:F3} ms");
bank.SetInputs(1UL << 14, 0); // the circuit pulls the button pin low
double carry = 0;
for (var frame = 0; frame < 1000; frame++) // one simulated second, 1 ms frames
{
var budget = CycleBudget.Next(ref carry, mcu.ClockHz, 0.001);
CycleBudget.Settle(ref carry, budget, mcu.Run(budget)); // Run returns the cycles actually consumed
}
mcu.ClockHz is the live clk_sys (≈6.5 MHz out of reset, 150 MHz after clock_init) and ClockChanged fires when firmware reprograms it. Run maps cycle budgets onto the machine's per-core instruction slices; PinChange.Cycle is exact to the instruction for SIO-driven pads and to the clk_sys cycle for the pin-level serial engines, PWM and PIO. Nothing is hooked into the machine until the first PinChanged subscriber arrives. Loading takes UF2 and raw .bin (not ELF or Intel HEX). RP2350Mcu.Wrap(machine) adopts a machine you built yourself. See RP2350Mcu's XML docs for the cycle budget, dual-core and pin-level semantics, and LIMITATIONS.md for what the contract cannot express yet.
Native library (C / C++)
The core ships as a NativeAOT shared library (silicontwin_rp2350.dll / .dylib / .so) behind a flat C ABI, so a C or C++ host (a Proteus VSM model, an iCircuit-like app, a Visual Studio .vcxproj) embeds it without .NET. There are two layers in the one library:
st_mcu_*, the generic ABI (silicontwin.h). One connector for every Silicon Twin chip: it is implemented only againstSiliconTwin.Abstractions(IMcu,IGpio/IPinBank,IPeripheralMap,IAdcInput,IPwmSource) insrc/SiliconTwin.Native.Exports, a project written to be extracted and shared. A native library for a chip references it and registers one factory ("rp2350"→RP2350Mcu, insrc/RP2350Sharp.Native/Rp2350Chip.cs); a host written against this header does not change when the chip does. The chip is picked by id and options at run time:st_mcu_create("rp2350", "arch=riscv;buses=i2c+spi").st_rp2350_*, the compatibility ABI (silicontwin_rp2350.h). The RP2350-specific C ABI of the Labcenter demo, unchanged (instruction-countrun,run_until_edge, USB CDC channel, pad pulls). It callsRP2350Machinedirectly. WithST_RP2350_CYW43(Pico 2 W) it also has a virtual Wi-Fi access point with DHCP and the link status (st_rp2350_wifi_*,docs/wireless.md). For CircuitPython it copies files onto the CIRCUITPY drive the way a PC does, into the FAT volume in flash, then reboots the chip (st_rp2350_fs_status/_fs_put/_fs_commit,docs/circuitpy-files.md).
Both keep the same error model: handles are opaque tokens validated on every call, bad arguments are rejected with a reason in *_last_error, and no input or internal error terminates the host: a bug in the core leaves the chip in a sticky faulted state that *_status reports.
st_mcu *chip = st_mcu_create("rp2350", NULL); /* options: NULL = defaults */
st_mcu_load(chip, ST_FW_UF2, image, image_len, 0);
st_mcu_reset(chip, ST_RESET_SOFT);
st_mcu_set_pin_callback(chip, on_pins, NULL); /* batches of changes with cycle stamps */
for (;;) { /* the host owns time */
st_mcu_run(chip, (int64_t)(st_mcu_clock_hz(chip) * 10e-6)); /* a 10 us step */
if (st_mcu_status(chip) != ST_MCU_OK) { puts(st_mcu_last_error(chip)); break; }
uint64_t driven = st_mcu_bank_output_enable(chip, 0), levels = st_mcu_bank_output_levels(chip, 0);
}
st_mcu_destroy(chip);
The RP2350 factory options are arch=arm|riscv, variant=rp2350a|rp2350b|rp2354a|rp2354b, flash=BYTES, buses=all|none|i2c+spi+uart (pin-level buses, on by default because a host that only sees pads needs them), usb=cdc|none (the USB CDC port, the MicroPython REPL, is UART 2) and slice=INSTRUCTIONS. Pin names (GP0) come from the chip registration: Abstractions 0.1 has none.
Build and test it locally (macOS / Linux): scripts/native-abi-test.sh publishes the library for the current RID into artifacts/native/<rid>/, compiles tests/RP2350Sharp.Native.Tests/abi_selftest.c (the st_rp2350_* hostile-use checks) and mcu_selftest.c (the same for st_mcu_*, plus pico-sdk firmware and a MicroPython LED + button program driven through st_mcu_* only) against it and runs both. Add --hooks to build the library with -p:StTestHooks=true, which exports the test-only st_*_test_inject_fault functions and adds the injected-fault checks; that build is for tests and never goes into a package. With --firmware RPI_PICO2-*.uf2 (or a git-ignored firmware/ folder) the MicroPython scenarios run too. On Windows, scripts/native-abi-test.ps1 does the same with MSVC. bench/RP2350.NativeBench measures what each layer costs a host.
NuGet package for C++ projects. SiliconTwin.RP2350.Native is assembled by native.yml from one NativeAOT publish per RID (NativeAOT does not cross-compile across operating systems, so Windows, macOS and Linux each build their own) and uploaded as a workflow artifact; nothing is pushed to nuget.org.
runtimes/<rid>/native/silicontwin_rp2350.{dll,lib,dylib,so} win-x64, win-x86, osx-arm64, linux-x64
build/native/include/silicontwin.h silicontwin_rp2350.h
build/native/SiliconTwin.RP2350.Native.targets
In a .vcxproj the targets add the include directory, link the import library of the active platform (x64 → win-x64, Win32 → win-x86) and copy silicontwin_rp2350.dll to the output directory (opt out with <SiliconTwinRP2350CopyDll>false</SiliconTwinRP2350CopyDll>). samples/vcxproj-consumer is a complete console solution (RP2350Consumer.sln) that consumes the package through packages.config and uses only st_mcu_*:
nuget restore samples\vcxproj-consumer\RP2350Consumer.sln -PackagesDirectory samples\vcxproj-consumer\packages -ConfigFile samples\vcxproj-consumer\nuget.config
msbuild samples\vcxproj-consumer\RP2350Consumer.sln /p:Configuration=Release /p:Platform=x64
samples\vcxproj-consumer\src\RP2350Consumer\bin\x64\Release\RP2350Consumer.exe [firmware.uf2] [options]
Put a downloaded SiliconTwin.RP2350.Native.<version>.nupkg in artifacts\nupkg (the sample's nuget.config looks there) and set the version in packages.config and SiliconTwinRP2350NativeVersion. Machine-local settings go in a git-ignored Directory.Build.user.props (copy Directory.Build.user.props.example): a Proteus model also needs the Labcenter SDK headers, whose folder is LabcenterSdkDir (or the LABCENTER_SDK_DIR environment variable); no SDK file lives in this repository. For other platforms (ARM64, Linux, macOS, CMake) take the binary from runtimes/<rid>/native/ and the headers from build/native/include/. Threading: one chip per handle, single-threaded; callbacks fire synchronously inside st_mcu_run.
Licensing
The entire project — the emulator core and the tooling (TestKit, Micropython.TestKit, Wireless) alike — is licensed under the Business Source License 1.1, which automatically converts to the MIT License (the Change License) on the Change Date (2030-07-11).
Use for personal, hobby, educational, academic-research, evaluation, or open-source purposes is always free of charge. Commercial Use — as defined in LICENSE-BUSL.txt — requires a separate commercial license. See LICENSE and LICENSE-BUSL.txt.
In one line: free to write, run, debug and profile with — on any machine, at any company — and free in the CI of public repositories. Shipping it inside a product you sell needs a commercial licence. Running it in a private CI needs an entitlement, which is a service governed by its own terms, not by this licence.
Parts of RP2350Sharp are derived from rp2040js by Uri Shaked, under the MIT License, and parts were carried over from RP2040Sharp while it was MIT-licensed, including contributions by Sergio Domínguez Rojas whose copyright notice is retained. RP2350Sharp also redistributes the RP2350 boot ROM binary (© Raspberry Pi Ltd, BSD-3-Clause), which embeds sweet-b (© Western Digital Corporation, BSD-3-Clause). See NOTICE.txt for the complete third-party notices — it must accompany every redistribution.
Build options
Two MSBuild properties change what goes into the build, both off by default: StSwitchWideDispatch (the all-switch
instruction decoder, for iOS / WASM where indirect calls are expensive) and StTestHooks (fault injection for the C
ABI self-tests). See docs/build-options.md for what they cost and how to verify them.
Slow tests. CI and publish skip the exhaustive guard/config matrices (Category=Slow); run them locally before a release with dotnet test tests/RP2350Sharp.Tests -c Release --filter "Category=Slow".
Status
Beta. See the releases for the changelog.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- RP2350Sharp (>= 1.3.2)
- SiliconTwin.RP2350 (>= 1.3.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.