Game ROM on SD card

nezvers
Posts: 8
Joined: Sat Nov 21, 2020 1:39 pm

Re: Game ROM on SD card

Postby nezvers » Wed Nov 25, 2020 11:16 am

@Radu79 Being able to put login on SD card or not will mean that this project will be interesting for others or just me. My goal is to have a Gameboy-like behavior - keep a game on the card, if possible several games, and just change the game without the need to hook the device to the computer. THAT'S IT! Everything I mentioned is the things I have found or considered.

@ESP_Sprite, you understood correctly! I don't mind going Odroid-Go way but I only found information about burning data on the flash not how to do the binary and booting from it. Can you please give good info on how to do that?

Radu79
Posts: 29
Joined: Tue Nov 17, 2020 9:50 pm

Re: Game ROM on SD card

Postby Radu79 » Wed Nov 25, 2020 12:14 pm

ESP_Sprite wrote:
Wed Nov 25, 2020 3:19 am
Radu: I think you're reading too much into this. As far as I understand, Nezvers' goal is to have a game console like device where the end user can plunk a game as a single file onto an SD-card, insert it into the console and play it. The single file contains both assets (images, sprites, sounds, whatnot) as well as the game logic. This is the end goal; development of the game is a separate issue.
Which is why I suggested zlib. You can have all your files in a zip archive and use it to extract the files you need. If he wants to keep the game logic too on the card, then the best way is to implement it as a scripting language. I would suggest Pawn, as it can load precompiled scripts so there is no need to waste time parsing the script.

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

Re: Game ROM on SD card

Postby ESP_Sprite » Thu Nov 26, 2020 1:48 am

nezvers wrote:
Wed Nov 25, 2020 11:16 am
@Radu79 Being able to put login on SD card or not will mean that this project will be interesting for others or just me. My goal is to have a Gameboy-like behavior - keep a game on the card, if possible several games, and just change the game without the need to hook the device to the computer. THAT'S IT! Everything I mentioned is the things I have found or considered.

@ESP_Sprite, you understood correctly! I don't mind going Odroid-Go way but I only found information about burning data on the flash not how to do the binary and booting from it. Can you please give good info on how to do that?

I think the Odroid code has some logic on how to do that. Alternatively, you may be able to use the ESP-IDF OTA code, perhaps the Arduino OTA subsystem is also compatible. Only issue I can spot is that getting the ESP32 to boot into an alternative binary on demand may need a modification of the bootloader - although I know you can get the ESP-IDF OTA logic to only boot once into a new binary by indicating the binary 'doesn't work' - the bootloader will revert to the old code then. That probably already gives you the behaviour you want.

If you're okay going the ESP-IDF OTA route, you can read through here - keep in mind you would load the 'update' data from the big game blob on your SD-card instead of over the air (by calling ota_begin/ota_write/ota_end), and that you use the 'application rollback' feature to go back to your main app after you exit the game.

nezvers
Posts: 8
Joined: Sat Nov 21, 2020 1:39 pm

Re: Game ROM on SD card

Postby nezvers » Thu Nov 26, 2020 12:02 pm

Am I understanding the idea right? Need to have 2 partitions - one active firmware with OTA code and the second as a buffer for changed firmware and esp32 will send the new update itself to that buffer. If so it seems like a super perfect solution.

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

Re: Game ROM on SD card

Postby ESP_Sprite » Fri Nov 27, 2020 4:39 am

Yep, that's more-or-less how it works.

nezvers
Posts: 8
Joined: Sat Nov 21, 2020 1:39 pm

Re: Game ROM on SD card

Postby nezvers » Fri Nov 27, 2020 7:15 am

I found how I can set up partitions from Arduino IDE and how to send a new program through OTA.
But I can't find how esp32 can do it to itself.

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

Re: Game ROM on SD card

Postby ESP_Sprite » Fri Nov 27, 2020 8:27 am

So that's where the ESP-IDF functions esp_ota_begin/esp_ota_write/esp_ota_end come in - you can start an update by using esp_ota_begin, then feed any data to esp_ota_write, and finally end with esp_ota_end. So in your case, you could open the game 'ROM' file using the standard fopen calls and read data using fread (or whatever the Arduino equivalent is) and feed that to esp_ota_write manually. Close with esp_ota_end and you should be good. (One disclaimer: I'm not actually 100% sure Arduino and ESP-IDF OTA is entirely compatible; if you run into issues, that may be something to look into.)

nezvers
Posts: 8
Joined: Sat Nov 21, 2020 1:39 pm

Re: Game ROM on SD card

Postby nezvers » Fri Nov 27, 2020 1:09 pm

Oh, that sounds pretty simple. Now I know where to look.
I think I will be using Visual Code for IDF.

fschuetz
Posts: 5
Joined: Thu Sep 17, 2020 10:37 pm

Re: Game ROM on SD card

Postby fschuetz » Sat Oct 02, 2021 7:55 am

@nezvers did you make any progress on this and can you share some results? I would be interested in how you solved this.

Who is online

Users browsing this forum: Baidu [Spider] and 74 guests