Difference between revisions of "Bootloader"

From Gamebuino Wiki
Jump to: navigation, search
m (Download)
(Overview)
Line 3: Line 3:
  
 
=== Overview ===
 
=== 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.
+
The bootloader is a small program that permanently resides in Gamebuino memory which allows you to load games via SD card or USB port. Under normal circumstances loading a new game into Gamebuino would require you to use an external programmer connected to the Gamebuino's ICSP port. The bootloader makes this process easier and faster by eliminating the need for a separate hardware programmer.
 +
 
 +
The Gamebuino will be delivered with a bootloader already installed. The Gamebuino is a modified version of the Arduino UNO's "Optiboot" bootloader with some extra features added. The first modification is a feature that launches the game section sketch (LOADER.HEX) when you reset the device holding down the C button. The other major addition is the ability for this skecth (or any other) to load and launch other games on the SD card by calling into the bootloader.
 +
 
 +
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. And of course ICSP programming still works normally for more advanced users wishing to program Gamebuino (or replace the bootloader with another) using a hardware programmer.
  
 
=== Sources ===
 
=== Sources ===

Revision as of 2014-03-22T02:58:58

Overview

The bootloader is a small program that permanently resides in Gamebuino memory which allows you to load games via SD card or USB port. Under normal circumstances loading a new game into Gamebuino would require you to use an external programmer connected to the Gamebuino's ICSP port. The bootloader makes this process easier and faster by eliminating the need for a separate hardware programmer.

The Gamebuino will be delivered with a bootloader already installed. The Gamebuino is a modified version of the Arduino UNO's "Optiboot" bootloader with some extra features added. The first modification is a feature that launches the game section sketch (LOADER.HEX) when you reset the device holding down the C button. The other major addition is the ability for this skecth (or any other) to load and launch other games on the SD card by calling into the bootloader.

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. And of course ICSP programming still works normally for more advanced users wishing to program Gamebuino (or replace the bootloader with another) using a hardware programmer.

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.