NES emulator on an ESP32

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

NES emulator on an ESP32

Postby ESP_Sprite » Mon Oct 10, 2016 4:35 pm

Here's a new thing: a NES emulator for the ESP32. It's a proof of concept, does not have sound and the display driver is kinda hackish leading to a frame rate that is slightly sub-par, but it actually is playable. Video demonstrating it and some of the reasoning around it is here: https://youtu.be/ympmRydFMmE

The source code of the emu is here: https://github.com/espressif/esp32-nesemu Keep in mind that it is more of a proof-of-concept than a product, and while push requests generally will be honoured, we won't be doing much more work on it.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: NES emulator on an ESP32

Postby WiFive » Tue Oct 11, 2016 2:25 am

Nice project. No homemade cap touch control pad? ;)

Look forward to SD card drivers. Will you post schematic of devkitJ?

User avatar
rudi ;-)
Posts: 1727
Joined: Fri Nov 13, 2015 3:25 pm

Re: NES emulator on an ESP32

Postby rudi ;-) » Tue Oct 11, 2016 9:40 pm

WiFive wrote: Look forward to SD card drivers. Will you post schematic of devkitJ?
+1

well done, nice helpfull founds [Move LCD driver to 2nd CPU] in your code how you have done it.
thank you for share!

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1727
Joined: Fri Nov 13, 2015 3:25 pm

Re: NES emulator on an ESP32

Postby rudi ;-) » Fri Jan 06, 2017 11:51 pm

hi

cause tested with ESP32 WROVER KIT V2 ( black )
found out, that we must change a small thing.

https://github.com/espressif/esp32-nese ... _lcd.c#L53

Code: Select all

/*orig WROVER KIT 1 ( red ) Backlight active high! */
// #define LCD_BKG_ON()    GPIO.out_w1ts = (1 << PIN_NUM_BCKL) // Backlight ON
// #define LCD_BKG_OFF()   GPIO.out_w1tc = (1 << PIN_NUM_BCKL) //Backlight OFF

/*rudi mod 06 jan 2017 on WROVER KIT V2 ( black ) Backlight active low! */
#define LCD_BKG_OFF()    GPIO.out_w1ts = (1 << PIN_NUM_BCKL) // Backlight OFF
#define LCD_BKG_ON()     GPIO.out_w1tc = (1 << PIN_NUM_BCKL) //Backlight ON

txs for your great work Jeroen!
now i need a PS1/PS2 Controller :mrgreen:
i usually do not play ;-) so sorry for this i have not PS1/PS2 controller here :oops:

IMG_5832_s.jpg
IMG_5832_s.jpg (134.27 KiB) Viewed 33106 times
see a sequenze on twitter

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi ;-)
Posts: 1727
Joined: Fri Nov 13, 2015 3:25 pm

Re: NES emulator on an ESP32

Postby rudi ;-) » Mon Jan 09, 2017 7:30 pm

hi
Add SPI Master driver was done before few days,
and with this few changes
if you get a compile error cause VSPICLK_OUT_MUX_IDX, have a note to this

best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

a2retro
Posts: 56
Joined: Tue Dec 01, 2015 3:09 am

Re: NES emulator on an ESP32

Postby a2retro » Tue Jan 10, 2017 3:39 am

Hi Rudi, The ESP32-WROVER-KIT V2 will upload the latest code

Code: Select all

Glenn@playpen MSYS ~/src/projects/esp32-nesemu
$ make flash
/home/Glenn/src/esp-idf/make/component_common.mk:1: Deprecated feature: No longer necessary to include component_common.mk from /home/Glenn/src/projects/esp32-nesemu/main/component.mk
Flashing binaries to serial port COM8 (app at offset 0x10000)...
esptool.py v2.0-dev
Connecting...
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Attaching SPI flash...
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 350976 bytes to 140590...
Wrote 350976 bytes (140590 compressed) at 0x00010000 in 3.0 seconds (effective 928.8 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 99...
Wrote 3072 bytes (99 compressed) at 0x00008000 in 0.0 seconds (effective 1641.4 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...
and a ROM

Code: Select all

Glenn@playpen MSYS ~/src/projects/esp32-nesemu
$ esptool.py --chip esp32 --port "COM8" --baud $((230400*4)) write_flash -fs 4MB 0x00100000 MarioBros.nes
esptool.py v2.0-dev
Connecting...
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Attaching SPI flash...
Configuring flash size...
Wrote 32768 bytes at 0x00100000 in 0.5 seconds (547.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...
but when it starts i get

Code: Select all

Couldn't map rom part!
Initialized. ROM@0x20000000
Malloc: 4140 at C:/msys32/home/Glenn/src/projects/esp32-nesemu/components/nofrendo/nes/nes_rom.c:444
Head: 0x20000000 (0 c0 7e 66)
GUI:  is not a valid ROM image
GUI: ROM freed
GUI: ROM not loaded
NoFrendo died? WtF?
Did I miss a step?

Glenn

a2retro
Posts: 56
Joined: Tue Dec 01, 2015 3:09 am

Re: NES emulator on an ESP32

Postby a2retro » Tue Jan 10, 2017 5:40 am

Code: Select all

[23:00] <a2retro> Couldn't map rom part! err=> 258
[23:03] <Sprite_tm> That's ESP_ERR_INVALID_ARG
[00:17] <a2retro> Part => 300000
[00:17] <a2retro> Src_addr plus size greater then g_rom_flashchip.chip_size
[00:17] <a2retro> Couldn't map rom part! err=> 102
[00:18] <a2retro> 300000 is part.size
[00:19] <a2retro> ESP_ERR_INVALID_ARG returned from flash_mmap.c lines 91-92
[00:24] <a2retro> Part => 300000
[00:24] <a2retro> Src_addr 0x00100000 plus size 0x00300000 greater then g_rom_flashchip.chip_size 0x00200000
[00:24] <a2retro> Couldn't map rom part! err=> 102
[00:24] <a2retro> thats as far as i can take it for now
[00:27] <a2retro> perhaps my sdkconfig file is messed up?
[00:29] <a2retro> $ cat partitions.csv
[00:29] <a2retro> # Name,   Type, SubType, Offset,  Size
[00:29] <a2retro> # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
[00:29] <a2retro> nvs,      data, nvs,     0x9000,  0x6000
[00:29] <a2retro> phy_init, data, phy,     0xf000,  0x1000
[00:29] <a2retro> factory,  app,  factory, 0x10000, 0x0E0000
[00:29] <a2retro> nesgame,  0x40, 0x01,    0x100000, 0x300000
[00:36] <a2retro> sdkconfig has 4MB for flash size

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: NES emulator on an ESP32

Postby ESP_Sprite » Tue Jan 10, 2017 6:12 am

Maybe your flash size is set incorrectly? It's in make menuconfig, under 'serial flasher config'.

a2retro
Posts: 56
Joined: Tue Dec 01, 2015 3:09 am

Re: NES emulator on an ESP32

Postby a2retro » Tue Jan 10, 2017 2:14 pm

Hi it is set for 4MB. I also tried a make clean and then a rebuild but no joy so far.

a2retro
Posts: 56
Joined: Tue Dec 01, 2015 3:09 am

Re: NES emulator on an ESP32

Postby a2retro » Tue Jan 10, 2017 2:44 pm

So after some googling i found and old workaround from ESP_igrr that forces the flash to be setup for 4MB.

SPIParamCfg(0x1540ef, 4*1024*1024, 64*1024, 4096, 256, 0xffff);

The game finally starts now but the back-light will not come on. When I press the enable button the back-light comes on momentarily, I can see the game screen and then it resets the game.

Who is online

Users browsing this forum: No registered users and 15 guests