MicroPython NES Emulator on a RISC-V 64 Processor

micropython-nes-emulator-maixpy.jpg

The guys at Sipeed have released a new beta of their MicroPython port for their range of boards based on the Kendryte K210 processor and this one features an emulator for the NES.

You need a NES rom (you can test with this open-source game binary – Nova The Squirrel) and at least version beta_0.2.1 of MaixPy.

The following is working for me on the Maix M1w Dock that I bought from an Indiegogo campaign. They are now available on Seeed and Banggood.

  • Insert a MicroSD card with your NES ROMs (you could upload to Flash as well)
  • Connect your device to USB
  • In Windows, download K-Flash from https://kendryte.com/downloads/ , unzip and run K-Flash.exe
  • In K-Flash select the device’s port
  • Navigate to the MaixPy binary ( beta_0.2.1 available here or Github releases here)
  • Click Flash to upload

I use Putty for the serial monitor. Connect using the settings below (change the port number if needed). If the connection fails, try pressing reset on the board.

Putty

Copy and then paste all the code below into Putty at the >>> prompt and press enter twice and the emulator will start up.

import nes
nes.init(0)
nes.run("/sd/name-of-your-game.nes")

When Putty is the active window (ie you’ve not clicked outside the window) you can control the game using your keyboard. Keys W, A, S and D are the D-pad direction keys. N is select, M start with J and K being the action buttons. This works to a point but there are problems when pressing more than one key.

MicroPython NES Emulator Nova Squirrel

Connecting a PS2 Controller over SPI

It’s also possible to wire up a PS2 Controller using the SPI interface. To quickly test this I’ve used Dupont connectors, removing the plastic part and enlarging the gap a little so I could push them onto the plugs inside the connector. You could cut the cables and solder them or for a more long term solution buy a USB adaptor, open it and solder connections to this.

PS2 Controller SPI Wires

You don’t need to open the controller connector. I just want to use the same colours for the Dupont connectors

PS2 Controller PSI Wiring Diagram

Paste the following code at the >>>> prompt if you are using a PS2 controller:

import nes
from Maix import GPIO
fm.register(8, fm.fpioa.GPIO0)
wifi_en=GPIO(GPIO.GPIO0,GPIO.OUT)
wifi_en.value(0)
nes.init(1)
nes.run("/sd/name-of-your-game.nes")

References

Installing MaixPy from source in Windows 10: https://robotzero.one/sipeed-maix-micropython/
MaixPy on Github: https://github.com/sipeed/MaixPy
Sipeed homepage: https://sipeed.com/#/
Releases including binary: https://github.com/sipeed/MaixPy/releases
Nova The Squirrel NES game: https://github.com/NovaSquirrel/NovaTheSquirrel

3 Replies to “MicroPython NES Emulator on a RISC-V 64 Processor”

  1. Salman says:

    I bought the smaller board. Is this modifiable to connect a display and use the NES emulator?

    https://www.seeedstudio.com/Sipeed-MAix-BiT-for-RISC-V-AI-IoT-p-2872.html

    1. WordBot says:

      Do you want to connect a monitor/TV or an LCD? There’s an LCD in the kit https://www.seeedstudio.com/Sipeed-MAix-BiT-for-RISC-V-AI-IoT-1-p-2873.html but I don’t know where you can buy it. You could connect an LCD to the pins but I don’t know if there’s code or drivers for this yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

scroll to top