Tue Jul 01, 2014 10:46 am
albertinjo wrote:The bootloader works really weird on my aruino, the loader sketch works fine, I can read files from my sd card with the SDfat library. Only problem is that I cant invoke the loader sketch while holding the C button on startup??
Tue Jul 01, 2014 10:59 am
jonnection wrote:albertinjo wrote:The bootloader works really weird on my aruino, the loader sketch works fine, I can read files from my sd card with the SDfat library. Only problem is that I cant invoke the loader sketch while holding the C button on startup??
I got interested and looked at the code.
The bootloader code does not "wait" to read the state of the C button at all, it is checking the state once and almost immediately after reset.
My suspicion is that there is nothing wrong with the code, but that your C button, reason or another, is not low when the bootloader runs (line 307 in gamebuino_boot.c in GitHub). It can pick up interference from an adjacent pin or something. Another factor overlooked sometimes is that breadboarded circuits behave slightly differently to circuitboarded circuits due to the electrical characteristics of a breadboard. This can affect the volatility of a pin, especially directly after a reset. (Myndale can correct me if I'm talking rubbish).
I would try these two tricks:
1) Force the button C (PC3, arduino pin A03) into low state by binding it to GND through a 10k resistor. Then reset and see if loader comes up.
2) If this helps, remove resistor and write a small waiting loop around the C button state check on line 307 in gamebuino_boot.c
Tue Jul 01, 2014 11:04 am
jonnection wrote:1) Force the button C (PC3, arduino pin A03) into low state by binding it to GND through a 10k resistor. Then reset and see if loader comes up.
ripper121 wrote:I think there is a internal PullUp/Down resistor that you can activate
Tue Jul 01, 2014 5:46 pm
rodot wrote:jonnection wrote:1) Force the button C (PC3, arduino pin A03) into low state by binding it to GND through a 10k resistor. Then reset and see if loader comes up.
The microcontroller resets once the loader is loaded... so it will enter in an infinite loop where it continuously flash the loader (an wear out the flash memory). You won't even have time to see the loader screen before it starts to flash the loader again. If I were you I would NOT DO THAT.
Tue Jul 01, 2014 5:51 pm
jonnection wrote:but what if someone holds the C button down continuously, out of stupidity ?
Tue Jul 01, 2014 6:01 pm
rodot wrote:jonnection wrote:but what if someone holds the C button down continuously, out of stupidity ?
What if someone powers its Gamebuino with 220V :3
Well it won't flash the loader 60 times per second, because it takes a few seconds to load it. But yes you can holding down the C buttons will continuously flash the loader. I just wonder why someone would hold down the C buttons for weeks until the flash memory wears out
Wed Jul 02, 2014 6:24 pm
jonnection wrote:rodot wrote:jonnection wrote:but what if someone holds the C button down continuously, out of stupidity ?
What if someone powers its Gamebuino with 220V :3
Well it won't flash the loader 60 times per second, because it takes a few seconds to load it. But yes you can holding down the C buttons will continuously flash the loader. I just wonder why someone would hold down the C buttons for weeks until the flash memory wears out
On the contrary. Jammed keys is usually always somehow taken into account. You can test this with almost any device, you will find there is some sort of fail-safe mechanism.
EDIT: In any case, Rodot is right. Do not pull down C with a resistor as I said, that was bad advice
I'm going to build and burn the bootloader myself and start digging into it, perhaps I will find out something for Albertinjo. I will dig into the SPI communication between the bootloader and the SD card with my logic analyzer to get a better idea of whats going on.
Wed Jul 02, 2014 8:04 pm
Wed Jul 02, 2014 9:58 pm
while (PINC & (1<<PC3)) {}
Wed Jul 02, 2014 10:23 pm