Difference between revisions of "Bootloader"

From Gamebuino Wiki
Jump to: navigation, search
m (Download)
Line 51: Line 51:
 
=== Download ===
 
=== Download ===
  
The current alpha version of the boot loader can be downloaded from the files section.
+
The current alpha version of the boot loader will be available in the files section shortly.

Revision as of 2014-03-17T23:24:32

Overview

The Gamebuino uses the modified version of the Arduino's UNO bootloader (Optiboot). The changes allow the firmware to load and run the game selection sketch from SD card when the Gamebuild is reset with the C button held down; it also allows that software to load and launch other games on the SD card programatically. Other than these extra features the bootloader should run normally, meaning it is compatible with the Official software and will support IDE uploads and program verification.

Sources

  • [1]: The firmware used by the official Arduino IDE for flashing Uno boards.
  • 2boots, an SD-enabled bootloader source code, the Gamebuino bootloader uses it's FAT16 and flashing code.

Launching Loader

If the the C button is held down while the unit is powered-up then the bootloader will search for a compiled sketch on the SD card called "LOADER.HEX". Note that the SD must be formatted with FAT16 and the filename must be upper case characters.If no SD card is present, or if the LOADER.HEX file can't be found or loaded then the bootloader will execute whatever program is already flashed into memory.

Flashing the Gamebuino Bootloader

Under normal operation the Gamebuino is programmed via the USB virtual COM port with the device selected as "Arduino UNO". However, if you wish to program it or upload the bootloader using an external hardware programmer (e.g. another Arduino) then you must edit the boards.txt file in the Arduino package (typically loacted at C:\arduino-1.0.5\hardware\arduino\boards.txt) and add the following section:

	gamebuino.name=Gamebuino
	gamebuino.upload.protocol=arduino
	gamebuino.upload.maximum_size=32256
	gamebuino.upload.speed=115200
	gamebuino.bootloader.low_fuses=0xff
	gamebuino.bootloader.high_fuses=0xd8
	gamebuino.bootloader.extended_fuses=0x05
	gamebuino.bootloader.path=gamebuino_boot
	gamebuino.bootloader.file=gamebuino_boot.hex
	gamebuino.bootloader.unlock_bits=0x3F
	gamebuino.bootloader.lock_bits=0x0F
	gamebuino.build.mcu=atmega328p
	gamebuino.build.f_cpu=16000000L
	gamebuino.build.core=arduino
	gamebuino.build.variant=standard

Restart the Arduino IDE and you will see a new device type called "Gamebuino". (This change is required for external programming because the Gamebuino bootloader is larger than the original Optiboot bootloader and the fuse bits need to be modified to accommodate this).

Launching Games via Software

The boot loader can be invoked at any time to load and launch a game from the SD card. To do this simply add the following code to any sketch:

    #define load_game (*((void(*)(char*))0x7ffc))

A game can then be loaded and launched by calling this function, passing in an upper-case-only file name with the .HEX extension:

    load_game("BLINK");

This causes a long-jump into the boot loader code causing it to load and launch BLINK.HEX from the SD card.

Questions, suggestions, solutions ?

If you have any questions, ask them the in this thread.

Good luck !

Download

The current alpha version of the boot loader will be available in the files section shortly.