Using bootloader to load sketches from SD with arduino uno

Libraries, utilities, bootloaders...

Using bootloader to load sketches from SD with arduino uno

Postby flea » Thu Feb 09, 2017 3:20 pm

Hey guys,

I was really happy when I found the GB bootloader, because this is exactly what I need for a project of mine. My basic intention is to load sketches from the SD card in order to update my arduino uno in the field. Thus flashing the arduino via the serial interface is not an option.

So here is what I've done so far:

I checked the documentation on the GB bootloader here: https://github.com/Rodot/Gamebuino/tree ... buino_boot and followed the instructions. I was able to flash the bootloader successfully to my arduino uno via USBasp. Afterwards I checked if the arduino is still optiboot compliant and uploaded the Blink example via USB. This worked, so I assume that the GB bootloader is successfully flashed.

Next I created a partition 32MB partition on my 4GB microSD card that is FAT16 formatted. I copied the compiled HEX-file "blink.hex" to the SD card. When I run the arduino example sketch for displaying all files on the SD card, the sketch gets listed. Thus I also assume that the wiring of the SD card is correct. Here is the output of the sketch:

Initializing SD card...initialization done.
BLINK.HEX 6195
done!

I also double checked the wiring with the schematics of GB and everything seems fine. Here is the wiring:

ARDUINO -> Adafruit microSD breakout
5V -> 5V
GND -> GND
PIN 10 -> CS
PIN 11 -> DI
PIN 12 -> DO
PIN 13 -> CLK

At least I flashed the sketch that is responsible for loading the target sketch to the arduino. Which looks like the following:

Code: Select all
#define load_game (*((void(*)(const char* filename))(0x7ffc/2)))

void setup() {
  Serial.begin(9600);
  delay(4000);
  Serial.println("Load Blink");
  delay(100);
  load_game("BLINK");
}

void loop() {
  // put your main code here, to run repeatedly:

}


After the "Load Blink" is written to the serial monitor the sketch is stucked and the red LED on the Adafruit microSD flashes infinitely.

Here is an image of the wiring.
2017-02-09-161159.jpg
Wiring
2017-02-09-161159.jpg (163.24 KiB) Viewed 3245 times


Do you guys have an idea what the problem might be? Is there anything else I have to consider when formatting the SD card? I would be grateful for any help!
flea
 
Posts: 2
Joined: Thu Feb 09, 2017 2:27 pm

Re: Using bootloader to load sketches from SD with arduino u

Postby Sorunome » Thu Feb 09, 2017 3:33 pm

IIRC you need to somehow specially format a larger SD card to make it recognizable by the bootloader, easiest would be to just grab a small micro sd card and format it FAT16

EDIT: More on that here: http://gamebuino.com/wiki/index.php?tit ... ng#SD_card
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Using bootloader to load sketches from SD with arduino u

Postby flea » Thu Feb 09, 2017 3:58 pm

Sorunome wrote:IIRC you need to somehow specially format a larger SD card to make it recognizable by the bootloader, easiest would be to just grab a small micro sd card and format it FAT16

EDIT: More on that here: http://gamebuino.com/wiki/index.php?tit ... ng#SD_card


Thank you. I'll check that out. Is there a way to format the SD card to make it recognizable? That would be awesome, since a SD with less than 2GB would take some days to arrive.
flea
 
Posts: 2
Joined: Thu Feb 09, 2017 2:27 pm

Re: Using bootloader to load sketches from SD with arduino u

Postby Sorunome » Thu Feb 09, 2017 4:18 pm

This might help: viewtopic.php?f=11&t=3133
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Using bootloader to load sketches from SD with arduino u

Postby Myndale » Mon May 01, 2017 3:34 am

A couple of other things to keep in mind....although you're using a Uno you'll need to make sure your target board is set to Gamebuino. The SD bootloader is 4K so your Uno needs to be set with different flags.

Also I notice you're using a hardware burner. You'll need it to burn the bootloader but make sure you're not also using it to upload the blink sketch; avrdude typically does a full chip erase each time it uploads.
Myndale
 
Posts: 507
Joined: Sat Mar 01, 2014 1:25 am


Return to Software Development

Who is online

Users browsing this forum: No registered users and 1 guest