A free Gamebuino if you compile the SD card bootloader !

Libraries, utilities, bootloaders...

Re: A free Gamebuino if you compile the SD card bootloader

Postby Myndale » Fri Mar 14, 2014 2:38 am

Also just so you know I've tested this without a USB connection and it works fine. The build where you saw that bug had debugging info being streamed out to the UART in order to track down the SD card problem, I suspect that disconnecting the USB cable was causing the TX code to lock up.
Myndale
 
Posts: 507
Joined: Sat Mar 01, 2014 1:25 am

Re: A free Gamebuino if you compile the SD card bootloader

Postby rodot » Fri Mar 14, 2014 7:45 am

Sounds good, thank you for your hard work! :D
I'm not home right now, I'll try that in few hours.
About the stated spec, you now, if you want to suggest something more efficient or convenient, it's welcome !
Concerning the LOADER, I'll program it with the EEPROM backup, GUI and all, don't worry ! I was wondering, would it be possible to place games in sub-folders ? I guess that the bootloader will become too large if we do so ? I'm just afraid that it's going to be messy if you have 50 games on your SD card, and it's going to be tedious to navigate through files (this aspect will depend on my ability to make a badass GUI hahaha).
Really cool that we don't even have to restart the Gamebuino after launching the LOADER, well done :)
You really take the Gamebuino a step further, I'll never thank you enough hahaha
Rodot.

PS: I say LOADER, but if we have to choose a better name we should do it right now... any suggestion ?
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: A free Gamebuino if you compile the SD card bootloader

Postby Myndale » Fri Mar 14, 2014 8:40 am

My many years of working in the game industry taught me one thing: interfaces need to be as simple and as intuitive as possible. Nintendo in particular are masters at this. The problem I see with holding the C button down during a reboot is that it's not obvious to a new user...somebody who has never used a Gambuino before or read the manual will pick it up and not realize there are more games available to play. On the other hand, if you pop up a little logo or something with a message like "Press C for Menu" and hold it there for 2 or 3 seconds before launching the game then everyone will get that instantly.

With regards to subfolders the 2boots FAT code only loads from the root folder in order to keep the size of the code to a minimum. The regular Arduino SD library handles subfolders easily though so you could always copy the selected game to a temp file in the root folder and load that instead.

Any additional boot loader functionality is your call with respect to how much Flash space you're willing to sacrifice. The boot loader as it is now will fit in 2KB, a 4KB boot loader will probably allow it to also contain the Loader application as well but then that's 2KB of valuable Flash that your programmers won't have access to.

One feature I do think might be worth adding is a flag to the "load_game" function to indicate whether or not the Gamebuino should be rebooted after Flashing or whether it should return to the calling app. This would immediately open up the door for hot-swappable code and effectively eliminate any restrictions on code size. It's not exactly a topic for beginners but it would be simple enough to do so if it's something you're interested in seeing then let me know and I'll put together a demo showing it in action.
Myndale
 
Posts: 507
Joined: Sat Mar 01, 2014 1:25 am

Re: A free Gamebuino if you compile the SD card bootloader

Postby rodot » Fri Mar 14, 2014 10:31 am

I agree, that's far from being obvious to hold down C during start up...
During the Gamebuino start-up screen with the logo, we could display something like "Hold 'C' to change game". Then it would write "LOADER" in the EEPROM (it will simplify the bootloader too) an restart. This way it will be in the library, and it will allow us to re-use the GUI function without having to include the screen library in the bootloader. That would be cool to fit the bootloader in 2KB.

By the way, do you think we can increase the upload speed through the USB port, or would that create to much errors ? With the default settings of the arduino UNO, it takes more than 15s to upload a ~23KB game, which is pretty frustrating when you're doing a lot of uploads during game development.

I don't understand how the Gamebuino could return to the calling app after flashing, as the calling application has been overwritten during the flash operation ?

I already thought about the ability to split games into several programs to overcome the memory limitation, but you will probably to that way better than I would :) Gamebuino is no only for beginners, so I think that you should do it. Moreover, it will benefit the whole Arduino community, as nothing like that has been done before (even the SD bootloader is a new thing).

I'm going to start working on the LOADER. Do you have any experience with github ? I've put all the Gamebuino library online, but I don't really know how it works when it comes to forks and stuff like that, as we are going to work both on the same thing.

This bootloader is progressing damn fast, that's awesome !
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: A free Gamebuino if you compile the SD card bootloader

Postby Myndale » Fri Mar 14, 2014 12:12 pm

I haven't had much experience with Github unfortunately, most of the work I do is proprietary.

Regarding hot-swapping: a .HEX file is simply a list a of memory addresses and an array of bytes to write into those addresses. Avrdude, which the official Arduino IDE uses to flash memory, erases all memory first by default, but our boot loader doesn't. If you want to hot-swap code then the trick is to set up the makefile so that it pokes the new code into a reserved section of memory but leaves the main program itself intact. As a developer of security software I go to lengths to prevent features like this being exploited by hackers but in this case it would be very useful and IMHO wouldn't be too difficult for programmers to support.
Myndale
 
Posts: 507
Joined: Sat Mar 01, 2014 1:25 am

Re: A free Gamebuino if you compile the SD card bootloader

Postby rodot » Fri Mar 14, 2014 3:10 pm

Sound good, how would you define which part of the code should stay and which part should be overwritten ? Could you define this by function, by class ?

I'm progressing slowly on the loader GUI, I'll show you when I'll have something working.

You work in security software ? I'm curious to know more about you, where are you from? How old are you? What's your work ? You can PM me if you don't want to post that here ;)
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: A free Gamebuino if you compile the SD card bootloader

Postby rodot » Fri Mar 14, 2014 4:57 pm

I have a SD card browser GUI, and it took me the whole afternoon because I had some really, really weird bugs... because the atmega328 runs out of RAM when it runs both the SD and Gamebuino Library. It's really frustrating that there is no "out of RAM" flag or something to avoid debugging something that's acting randomly without any sense.
I also think that the Gamebuino Library needs some serious RAM usage optimization.

Edit: I would like to be able to put preprocessor directives in the arduino sketches to change what happens in the library. For example, with #DEFINE NOSOUND 1 I could totally disable the sound part of the library, this way it wouldn't take any ROM/RAM. I tried, but it doesn't seem to be possible :( For now, all these kind of settings are in a file named settings.c in the library folder. The problem is, you have to keep changing these settings depending on the game your are compiling. Any suggestion?
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: A free Gamebuino if you compile the SD card bootloader

Postby Myndale » Fri Mar 14, 2014 10:52 pm

This is one of the reason I prefer to use makefiles instead of the IDE. There are workarounds for what you're trying to do, one trick is to move your implementation code into your header files and use the pre-processor to prevent it being included multiple times:

Code: Select all
// Filename: SOUND.H

#ifndef SOUND_LIB
#define SOUND_LIB

class Sound
{
  public:
    void play_sound()
    {
      // etc
    }
 
  private:
    static char sound_buffer[256];
};

static Sound sound; // global instance


#endif // #ifndef SOUND_LIB


And then in your main library header file use another macro to decide whether or not to include this component:

Code: Select all
#ifndef NO_SOUND
#include "sound.h"
#endif


Now if anyone does a "#define NO_SOUND" before including your library header file then all the sound code will be stripped.
Myndale
 
Posts: 507
Joined: Sat Mar 01, 2014 1:25 am

Re: A free Gamebuino if you compile the SD card bootloader

Postby martinsustek » Sat Mar 15, 2014 1:22 am

These little devices have very limited resources. Every byte counts. And problems you describe are probably because stack overflows into statically allocated variables. You can see size of statically allocated memory during compile (if using avr-gcc, not sure about arduino ide) but you can hardly estimate maximum stack size at compile time (especially when using complex function calling and recursion).

About memory optimization - as I browsed your sources on github, I noticed, that you are allocating video buffer in AVR's RAM. But 5110 display controller has its own video ram. So if you can read from it, you do not need the second buffer in AVR. This could save around 1/4 of AVR's memory. Working with this memory will be more time expensive, but you can save some time because you do not need to copy all pixels to display at each frame. So updates will be slower, but when you will not update display, you will have more time for other computations.

If this optimization is not possible, there is one another approach. Using something like text video mode. Video ram will not consist of 84 x 48 pixels but 14 x 6 (or less) characters (6x8 pixel each). Video RAM will have 84 bytes instead of 504. Drawing routine will then be responsible for converting ASCII codes to graphical glyphs according to font stored in FLASH - that is easy task. It just will not be so fancy.

We can develop multiple different graphics modes and developer of each game will have option to use graphical (slow or fast) or text mode (with different font/tile size) in config file. It is concept derived from Uzebox (http://uzebox.org).

The same goes to sound - you can have one mode with complex background music capability and another with just basic blocking beep but with lower memory requirements.

But I think this is off topic now. Community will probably invent many options.

About config files - I have no experience with Arduino but I think that each project (game) should have own configuration file which can overwrite the default (library) settings. So when you compile game, appropriate settings will be included. But maybe I am wrong.
martinsustek
 
Posts: 19
Joined: Wed Mar 12, 2014 7:30 pm

Re: A free Gamebuino if you compile the SD card bootloader

Postby rodot » Sat Mar 15, 2014 9:17 am

You're righ, the display buffer takes 1/4 of the RAM... but it allows to refresh the whole screen in one time for a better image stability and programming convenience. I also agree that we should enable different screen modes, but I guess it will come after project launch! I you want to talk more about that, I suggest that you start a topic about perf optimization.

Being able to override the default settings in sketches is really my goal, but it doesn't seem to be possible. I tried what Myndale suggested without any success. It seems that the sketch and library are compiled apart from each other and can't alter the other one compilation through preprocessor directives (I asked on Arduino forum: http://forum.arduino.cc/index.php?topic=225882).

Right now for the sound you can change the number of channel from 0 (sound disabled) to 4, because it eats fair amount of ROM and RAM, I have to totally disable it for the LOADER for example.

By the way, now that I removed the sound, the LOADER GUI is performing well, you can browse you SD card. Now I have to clean the code and write the selected file's name in the EEPROM. Should be operational soon!

PS: The funding is now above 1400€, that's really cool, but it massively slowed down. I invite you to contact your favorite tech news website to tip them about Gamebuino if you want the project to become a reality! Thanks folks!
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

PreviousNext

Return to Software Development

Who is online

Users browsing this forum: No registered users and 23 guests

cron