Simulating ultra-low-power MSP430 MCUs in Renode

Published:

Topics: Open source tools, Open simulation

The Texas Instruments MSP430 is a family of MCUs with its own custom ISA that enables ultra-low-power use cases. With a long history of supporting a breadth of products, including devices deployed in space, the most popular applications include performing highly reliable analog measurement functions, building automation and battery-management solutions as well as highly reliable IoT installations, and at Antmicro, we work with the MCU when developing power-constrained devices for our customers.

For all of those scenarios, Renode’s multi-node simulation capabilities can be used to develop advanced products and systems that include either multiple MSP430s or a heterogeneous mix of MCUs. The popularity of the MSP430 family has led to a variety of revisions catering for different use cases, which is ideal for a configurable framework like Renode that lets you reuse SoC blocks in various configurations using a text-based configuration format.

In this article, we will talk about how we added support in Renode for the MSP430 core and its ISA, which is the first 16-bit architecture with a 20-bit word length enabled in our simulation framework. We will also describe how to start with MSP430 simulation in Renode along with a demo of the Contiki-NG RTOS running on the MSP430-based Zolertia Z1 platform.

A representation of the MSP430 chip showing the supported peripherals

Renode support for the MSP430 ISA

Typically in Renode, guest software targeting architectures such as ARM or RISC-V is JIT compiled, meaning that it is transpiled from the guest architecture to the host architecture during execution. In comparison, the MSP430 ISA is simple enough and as such was an ideal candidate to prepare Renode’s first interpreted ISA implementation.

As the MSP430 Renode core is written in C#, it is easy to modify the core to create custom derivatives of the ISA implementations, which helps us cover the variety of available MSP430 versions.

Besides the ISA, individual platforms can also be customized in Renode by using the standard flow of updating Renode Platform (.repl) files, which allows for precise parameterization of components, further improving our capacity of supporting the 2000+ MSP430 variants.

Simulating MSP430 in Renode

To run the MSP430 in simulation, first pull the latest version of Renode which is updated nightly:

mkdir renode_portable
wget https://builds.renode.io/renode-latest.linux-portable.tar.gz
tar xf  renode-latest.linux-portable.tar.gz -C renode_portable --strip-components=1

Then, launch the bundled bare-metal MSP430 sample:

$ renode scripts/single-node/msp430f2619.resc

This will show you the Renode Monitor window, where you can enter start to run the Hello World demo using basic MSP430 peripherals such as Timer and USCI, with the output visible in UART window:

Hello, World after 0 seconds has passed!
Hello, World after 1 seconds has passed!
Hello, World after 2 seconds has passed!
Hello, World after 3 seconds has passed!
Hello, World after 4 seconds has passed!
Hello, World after 5 seconds has passed!
Hello, World after 6 seconds has passed!

Running Contiki-NG on MSP430-based Zolertia Z1

Renode can run a multitude of operating systems used in embedded hardware such as Linux, Zephyr and Contiki-NG. Commonly used in resource-constrained devices, the latter has a tiny footprint and minimal memory use, and offers low-power communications and standardized protocols, making it ideal for demonstrating the use of the MSP430.

To quickly evaluate the use of Contiki-NG, we have created a demo that runs Contiki-NG’s Hello World sample on the Zolertia Z1 platform in Renode. To run the demo, first follow the instructions above for downloading the Renode portable package, then issue the following command:

$ renode scripts/single-node/zoletria-z1.resc

The next step is to start the simulation – issue a start command in the Renode Monitor window that popped up.

(Zolertia Z1) start

In the UART window, the following output from the serial can be observed:

[INFO:  	Main] Starting Contiki-NG-release/v4.9
[INFO:  	Main] - Routing: nullrouting
[INFO:  	Main] - Net: nullnet
[INFO:  	Main] - MAC: nullmac
[INFO:  	Main] - 802.15.4 PANID: 0xabcd
[INFO:  	Main] - 802.15.4 Default channel: 26
[INFO:  	Main] Node ID: 3265
[INFO:  	Main] Link-layer address: 00.00.00.cc1
[INFO:    	Z1] CC2420 CCA threshold 45
Hello, world
[tERR: 	tStack] Check in inconsistent state: pX vs. p6

As Renode is software agnostic, it can be easily used to test a wide range of software within its virtual and deterministic environment, without requiring physical hardware ‘on-hand’. Multiple variants of the MSP430 MCU can be tested in parallel or simulated in a CI environment, such as GitHub Actions, GitLab and others.

Develop MSP430-based devices for space with Renode

The MSP430 family, with its broad software portfolio, suitability for harsh environments and low power consumption, is a popular choice for space applications. Using Renode’s comprehensive simulation and testing capabilities, Antmicro can help you reduce iteration time and cost of development of your next MSP430-based device.

Beyond simulation, Antmicro offers comprehensive product development services, from initial concept to complete products including rapid prototyping and miniaturization which are often critical in space applications.

Get in touch at contact@antmicro.com to discuss Renode’s capabilities and find out how you can benefit from a scalable, deterministic and replicable simulation environment that you can easily integrate with your own workflows.

See Also: