Bugfixed bootloader for your Fakebuinos here

Libraries, utilities, bootloaders...

Bugfixed bootloader for your Fakebuinos here

Postby jonnection » Fri Jul 25, 2014 1:51 am

Hello Albertinjo and others who have been fighting with your SD cards

It took me a day of debugging, but I think I found the mistake: SCLK was dropping out of sync during MMC read first sector because of an unnecessary reinitialization of the SPI bus (it is already running at this stage). The SCK signal 'hiccups', SPI loses sync and the rest of the communication between the MCU and the MMC turns into rubbish.



In mmc_fat.c, I simply commented out the line #200 you see below. It was a simple fix, but took time to find.

Code: Select all
cmd[0] = 0x40 + MMC_READ_SINGLE_BLOCK;
   cmd[1] = (adr & 0x00FF0000) >> 0x10;
   cmd[2] = (adr & 0x0000FF00) >> 0x08;
   cmd[3] = (adr & 0x000000FF);
   cmd[4] = 0;
   
   // There is something odd about how this behaves, so I'll disable it - Jonne
   // testing proves theory correct
   //SPCR = 1<<SPE | 1<<MSTR | SPI_READ_CLOCK; //SPI Enable, SPI Master Mode


Furthermore, I suspect this might be the cause why the Gamebuino is so picky about what cards will work and what not. I use a normal 2GB SD card in my Fakebuino, and I suspect it will will work with others too.

It might be, that the cards Rodot is using are somehow special. But having seen the error on the logic analyzer, I am amazed that any of the cards work, so bad is the "hiccup".

Here is a compiled bootloader for your pleasure. No guarantees given ofcourse. Use on your own risk.

I tried it for the whole evening, worked without a single fail for me, both from hard reset and within programs.

https://drive.google.com/file/d/0BweEjvtKj1KLSm1oWmkxRThveFE/edit?usp=sharing
User avatar
jonnection
 
Posts: 317
Joined: Sun May 04, 2014 8:21 pm

Re: Bugfixed bootloader for your Fakebuinos here

Postby rodot » Fri Jul 25, 2014 7:53 am

Awesome, I'll try this bootloader with a few micro SD card, and update the official bootloader if it works fine. Thanks a lot for this contribution :D
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Bugfixed bootloader for your Fakebuinos here

Postby treflip » Fri Jul 25, 2014 2:24 pm

Awesome jonne! Thank you!!!

I can now load from SD... the only question I have is from watching a video on how the gamebuino is suppose to work- shouldn't the C button take the game out of play and into the menu? I have to reset my nano to get back to menu.
treflip
 
Posts: 83
Joined: Fri May 30, 2014 4:50 pm
Location: Florida

Re: Bugfixed bootloader for your Fakebuinos here

Postby ripper121 » Fri Jul 25, 2014 3:03 pm

No the C button don´t bring you back to the menu.
User avatar
ripper121
 
Posts: 224
Joined: Fri Apr 04, 2014 2:02 pm
Location: Germany

Re: Bugfixed bootloader for your Fakebuinos here

Postby jonnection » Fri Jul 25, 2014 5:25 pm

What c does inside game seems to depend on game
Bootloader doesnt affect that.
User avatar
jonnection
 
Posts: 317
Joined: Sun May 04, 2014 8:21 pm

Re: Bugfixed bootloader for your Fakebuinos here

Postby albertinjo » Sat Jul 26, 2014 10:59 am

aaaaaah yeahhh

Hi jonnection!
Thanks for your awsome solution, you are awsome. You have done what I was trying for 3 months, I am following the gamebuino project from the beginning of the indiegogo campaign and you have finally made the damn bootloader work on fakebuios.
I admire your coding skills.
I just downloaded and I hope it works on my DIY gamebuino v1.0.
And you even compiled the bootloader.....awsome, I am so happy right now

Going to burn it in my DIY gamebuino and post some videos and pictures soon!!!!


Also... in the video I could clearly see that your screen blacks out a bit every time the sound is outputted to the speaker...... I had that problem when my DIY gamebuino v1.0 was just a breadboarduino... and I solved it with putting a simple 100uF capacitor real close to the Vcc and GND pins of my LCD, the capacitor reduces the noise microcontroller is producing while outputting sound to the speaker.

Anyway thanks again!!!!
User avatar
albertinjo
 
Posts: 98
Joined: Wed Mar 26, 2014 2:26 pm

Re: Bugfixed bootloader for your Fakebuinos here

Postby jonnection » Sat Jul 26, 2014 12:46 pm

Hello Albertinjo

You are most welcome. Thanks for the tip on the capacitor - I'll try it out. I have noticed you are pretty knowledgeable yourself. If you ever want to collaborate on some coding / Gamebuino building then give me a message.

Debugging communication between Arduino & external peripherals is almost impossible if you do not have a logic analyzer. I highly recommend getting one, my XZL_Studio - AX is a USBee clone and has saved the day many times.

Below is the output from the logic analyzer, where you can clearly see what happens during the early stages of the bootloading process, and also shows the "hiccup" that throws the SPI comms off the rails.

1. Reset MMC by 10 times 0x FF SPI pulse
Image

2. Send command reset to MMC, wait MMC to respond with 0x01
Image

3.Initialize MMC - MMC SEND OP COND - expects 0x01 as response
Image

4. Sent MMC OP COND and got 0 as response - means MMC INIT is OK
Image

5. At mmc_fat.c mmc start read block function line. The error is visible at the blue line. The MCU is supposed to send a command that starts with 0x40, instead it sends 0x1F. After that everything turns rubbish.
Image

6. SCK apparently tires to run double speed (at vertical blue line in the picture), then goes totally bonkers and stops. At this point we are supposed to read the first 512 bytes block from the card, and it doesn't get anywhere near done. No wonder bootloader didn't work for me.
Image
User avatar
jonnection
 
Posts: 317
Joined: Sun May 04, 2014 8:21 pm

Re: Bugfixed bootloader for your Fakebuinos here

Postby albertinjo » Sun Jul 27, 2014 9:15 am

Hello jonnection!
I just tried your bootloader on my DIY gamebuino and it works like magic!!
Thank you really much, I see you really know a lot about SPI connection, I dont have a logic analyzer but I will get one in the future.
Sure we can collaborate on some projects, I have been thinking of making a DIY gamebuino v2.0.....it would be soldered on a real PCB instead of a proto board, the only problem is that i have never made a PCB myself, I am always using proto boards

Thanks for imprssive screenshots, I am going to post a video of your bootloader in action.

Also I noticed the bootloader flashes the LOADER.hex file every time microcontroller is reset or powered, I thought R0d0ts bootloader was supposed to flash the LOADER.hex only when the C button was held, have you somehow disabled that function, anyway it works great, sometimes it glitches a bit and freezes so I have to restart it, but that is becouse of my messy connections.

Try the capacitor, just put 100uF (or bigger) on Vcc and GND lines of power supply, it filtered the noise made by the sound output fine on my fakebuino.
User avatar
albertinjo
 
Posts: 98
Joined: Wed Mar 26, 2014 2:26 pm

Re: Bugfixed bootloader for your Fakebuinos here

Postby ripper121 » Sun Jul 27, 2014 10:00 am

albertinjo wrote:Sure we can collaborate on some projects, I have been thinking of making a DIY gamebuino v2.0.....it would be soldered on a real PCB instead of a proto board, the only problem is that i have never made a PCB myself, I am always using proto boards


Its easy :)
http://www.ladyada.net/library/pcb/inhouseetch.html

Here a set:
http://www.ebay.de/itm/PROFI-Atzset-Pla ... 3cd3e29c0b
User avatar
ripper121
 
Posts: 224
Joined: Fri Apr 04, 2014 2:02 pm
Location: Germany

Re: Bugfixed bootloader for your Fakebuinos here

Postby jonnection » Sun Jul 27, 2014 1:11 pm

albertinjo wrote:Hello jonnection!
Also I noticed the bootloader flashes the LOADER.hex file every time microcontroller is reset or powered, I thought R0d0ts bootloader was supposed to flash the LOADER.hex only when the C button was held, have you somehow disabled that function, anyway it works great


No I did not touch the part where the C button press is recognized. I have noticed the same thing: every time I power on the board, the loader.hex is reloaded. However, with my Fakebuino, reset works perfectly: the loader is not loaded. I can reset from games and it comes back to the game.

My suspicion is that the effect of the greater capacitance of the breadboard Fakebuino is affecting the C button. There is no other logical explanation. I will add a small wait for the detection of the C pin to the bootloader in order to fix it.

I am working also on a completely different bootloader with some cool features. But that will still take time.
User avatar
jonnection
 
Posts: 317
Joined: Sun May 04, 2014 8:21 pm

Next

Return to Software Development

Who is online

Users browsing this forum: No registered users and 14 guests

cron