Armulet allows Raspberry Pi to run Arm code on RISC-V

ARMULET is a C ARMv6M / ARMv8M-baseline emulator by Raspberry Pi. Raspberry Pi is using Armulet to run Arm code on RISC-V in the RP2350 bootrom. The effort could be augmented to run legacy Arm code on a RISC-V only architecture.

VARMULET is a ARMv6M / ARMv8M-baseline ARMv6M emulator

The goals of VARMULET:

  • small code size (currently 3K) and it can be placed in ROM
  • ? fast enough to run USB boot code under RISC-V (which will also be a non-secure ARMv6M binary under ARM). VARMULET seems to be about 3x faster than ARMULET on RISC-V for now for one particular use case which is printf heavy. We will need to test with the boot code (and also SVC calls for things like memcpy, memset)
  • TODO extensible by non ROM code, with no ROM specific functionality baked in (e.g. handling of priv mode, IRQ, breakpoints, SVC etc). It should basically be possible to use the emulator on Amy RISC-V programs, and also to extend it to support other 32 bit instructions for example

Per the RP2350 bootrom details:

“Because of limited space, we cannot duplicate a lot of code in RISC-V, so ARM code is emulated (varmulet) on RISC-V. We emulate (roughly) Arm8-M Baseline not Arm8-M Mainline as it has many fewer less complex instructions (Arm8-M Baseline adds a small number of, but very handy instructions over m0-plus)

  • ‘a lot of’ is perhaps an understatement… pretty much everything is emulated now, including the main boot path, and API functions.
  • there are a huge number of “asm hacks” where we drop into assembly, and a bunch of other tricks we use to save instruction/data space.
  • Other than glue code, the only RISC-V code is really for RISC-V only APIs/setup, and stuff that needs to be optimized for speed.
  • Unused ARM hardware hint instructions (and/or RCP instructions) are used to make code behave differently under real ARM or emulation.
  • ARM only code is compiled for Arm8-M Mainline (m33).
  • Emulatable code is compiled for Arm8-M Baseline (m23), though emulation of UDIV and SDIV is not included in the bootrom, since they are unused by emulated code. The actual instructions included are (over Arm6m0-plus)
    1. b.w, cbz, cbnz, movw, movt from Arm8-M Baseline.
    2. RCP instructions (they are NOPs).
    3. Special cases of mov.w. This is a Arm8-M Mainline instruction, but we want efficient loads of constants 0xmm00mm00, 0x00nn00nn and 0xpppppppp which are used by the RCP
    4. MSPLIM (also Arm8-M Mainline)
    5. SG (Arm8-M Mainline) we can redirect Arm NS->S calls to different code on RISC-V.”

See more on the Armulet GitHub.


Halloween season is here!
Halloween season is here! Check out all the posts, gift guides, and more!

Adafruit publishes a wide range of writing and video content, including interviews and reporting on the maker market and the wider technology world. Our standards page is intended as a guide to best practices that Adafruit uses, as well as an outline of the ethical standards Adafruit aspires to. While Adafruit is not an independent journalistic institution, Adafruit strives to be a fair, informative, and positive voice within the community – check it out here: adafruit.com/editorialstandards

Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.

Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat and our Discord!

Join us every Wednesday night at 8pm ET for Ask an Engineer!

Join over 38,000+ makers on Adafruit’s Discord channels and be part of the community! http://adafru.it/discord

CircuitPython – The easiest way to program microcontrollers – CircuitPython.org


New Products – Adafruit Industries – Makers, hackers, artists, designers and engineers! — NewProducts Featuring Adafruit RP2350 22-pin FPC HSTX to DVI Adapter for HDMI Displays!

Python for Microcontrollers – Adafruit Daily — Python on Microcontrollers Newsletter: New Python Releases, an ESP32+MicroPython IDE and Much More! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi

EYE on NPI – Adafruit Daily — EYE on NPI Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey

Adafruit IoT Monthly — Garden Lights, Bluetooth 6.0, and more!

Maker Business – Adafruit Daily — A look at Boeing’s supply chain and manufacturing process

Electronics – Adafruit Daily — When do I use X10?

Get the only spam-free daily newsletter about wearables, running a "maker business", electronic tips and more! Subscribe at AdafruitDaily.com !



No Comments

No comments yet.

Sorry, the comment form is closed at this time.