Modifying the loader

Libraries, utilities, bootloaders...

Modifying the loader

Postby Sorunome » Tue Mar 31, 2015 6:31 am

Heya, I wanted to modify the loader so that if you click to open a SAV file it'll search for a HEX file with the same name and open that one instead.
I got that part working however the whole eeprom saving stuff doesn't seem to be working now, as in the files created are empty and me finding a ton of trash files on my micro SD
So, I wonder, do I do something obvious wrong? https://github.com/Sorunome/Gamebuino/b ... r.ino#L198

Beware when trying this, I couldn't delete the garbage files other than re-formatting my SD card

EDIT: After some intense debugging it seems like the garbage files are created while saving the eeprom https://github.com/Sorunome/Gamebuino/b ... eeprom.ino

This is very surprising to me as I didn't change it at all and when I enable the debugging messages it does save to the correct file.
What might also be noteworthy is that the SAV file is empty afterwards.

EDIT2: out of curiosity, why do the save files save the upper and lower bytes separate? Wouldn't that just bloat the size of the savefile? Or is that to make sure that \0 is the end of the file?

EDIT3: The thing is that the garbage files are only created/the SAV file is empty if, when the debugging messages enabled, allow the saving to the (Correctly-named) SAV file.
Ironically if I comment out the file.writeLn(buffer); it does not create garbage files, which is pretty odd to me.

EDIT4: an fsck turns all the garbage files into folders and truncates the saves created...what is even happening o.O I don't even.....
I use the tinyFAT library provided in the Gamebuino repo.

EDIT5: I'm compiling on archlinux x86_64, do i need to set any compiler flags or something manually?
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Modifying the loader

Postby rodot » Tue Mar 31, 2015 4:29 pm

I can't tell about the garbage file it creates, but about your EDIT2 yeah I did that to make sure /0 is the end of the file. Probably far from the best solutions but is was quick to implement, it's pretty simple so it doesn't eat to much flash and the eeprom loading/saving is pretty quick anyway.
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Modifying the loader

Postby Sorunome » Tue Mar 31, 2015 5:01 pm

rodot wrote:I can't tell about the garbage file it creates, but about your EDIT2 yeah I did that to make sure /0 is the end of the file. Probably far from the best solutions but is was quick to implement, it's pretty simple so it doesn't eat to much flash and the eeprom loading/saving is pretty quick anyway.

the garbage files are like random invalid entries on the inode table.
What might be noteworthy is that the .SAV files produced by this are always 1040b and when loading appear to be empty.

On which platform (win7/archlinux/whatever) / with which exact tinyFAT library did you compile the original loader on?

EDIT: The garbage files only show up on the computer, not on the gamebuino loader.
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Modifying the loader

Postby rodot » Wed Apr 01, 2015 7:44 pm

Oh, I just saw you forked it on GitHub from my last commit... which I mistakenly did to the master branch instead of the beta hence some things might have been broken. I just reverted it and committed to the right branch. Sorry about that! I don't know if it's the source of your problems though.
I compiled it using arduino IDE 1.6.2 on windows 7 using the original tinyFAT. I just checked, and it creates files correctly... but it seems so mess saves between games, I'll have to investigate that, might be a big issue.
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Modifying the loader

Postby Sorunome » Thu Apr 02, 2015 12:15 am

What do you mean with that it messes saves between games?
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Modifying the loader

Postby milk » Thu Apr 02, 2015 9:40 am

I am also fooling around with the loader, and I have the same problem. Files are not read from SD (File empty), so EEPROM is left to its previous status. Every game that saves add or remove data to the same EEPROM data. I also tried in saveeeprom() to write fixed data, and it is not written correctly (file on SD is full of 0x00).

About the loader, I wanted to show only hex files, all others are not usable anyway. From there, there is no need to show the file extension anymore. The file size is not very important neither. I also added a small text (to be replaced by a floppy icon) to mark games that have saved data. In the end, it makes a really clean HUI to choose your game, without
User avatar
milk
 
Posts: 11
Joined: Tue Mar 10, 2015 2:16 pm

Re: Modifying the loader

Postby Sorunome » Thu Apr 02, 2015 12:23 pm

I haven't been able to build it with windows7 correctly, either. as the error literately happens on the file.writeLn(buffer); I suspect a library bug.

EDIT: weird, if it only stores \xFF's it isn't creating random data, though the SAV file will be filled with \x00's

EDIT2: doing a file.writeLn("asdfasdf"); also screws up the file system. Are there any other FAT libraries we could use?

EDIT3: it seems to do the writing somehow to the partition instead of the file, because if i do something like
Code: Select all
  res=file.openFile("SPINSPIN.SAV", FILEMODE_TEXT_WRITE);
  if (res==NO_ERROR)
  {
    for(byte i=0; i< 1024/BUFFER_SIZE; i++){
      buffer[BUFFER_SIZE+1] = '\0';
      for(byte j = 0; j<BUFFER_SIZE; j+=2){
        byte b = EEPROM.read((i*BUFFER_SIZE+j)/2);
        //buffer[j] = 0x0F | b;
        //buffer[j+1] = 0xF0 | b;
        buffer[j] = 0xFF;
        buffer[j+1] = 0xFF;
      }
      file.writeLn("asdfasdf");
    }
    file.closeFile();
    gb.display.print(completeName);
    gb.display.println(F(" saved"));
    gb.display.update();
  }
  else{
    gb.display.println(F("Error"));
    gb.display.update();
  }

Which has hard-coded stuff the garbage file names look like this:
Code: Select all
drwxr-xr-x 0 sorunome sorunome          0 Feb  1  2107 asdf??as.dfa
d????????? ? ?        ?                 ?            ? asdfasdf.??a
-rw-r--r-- 1 sorunome sorunome 1717859169 Mar  4  2031 dfasdf??.asd
so another thing pointing torwards this being a library issue.

EDIT4: rodot, would you mind posting the exact tinyFAT.cpp you used to compile it?

EDIT5: I'm getting the exact same issue on the tinyFAT example

EDIT6: I also tried compiling the original, unmodified code, of the master branch and it is still giving that weird bug.
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Modifying the loader

Postby rodot » Thu Apr 02, 2015 5:22 pm

So it doesn't come from the Gamebuino Library then... can you try with a different operating system ? A different micro SD card ?
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Modifying the loader

Postby Sorunome » Thu Apr 02, 2015 5:56 pm

rodot wrote:So it doesn't come from the Gamebuino Library then... can you try with a different operating system ? A different micro SD card ?

This is the only micro SD card I have and i also tried with windows 7.

The micro-SD is formatted to FAT16.

EDIT: I also tried re-downloading the tinyFAT library from the official website and it didn't work with that one either.
User avatar
Sorunome
 
Posts: 629
Joined: Sun Mar 01, 2015 1:58 pm

Re: Modifying the loader

Postby milk » Thu Apr 02, 2015 6:51 pm

Well, I am under Linux, and obviously not the same SD as Sorunome, with the same result.
User avatar
milk
 
Posts: 11
Joined: Tue Mar 10, 2015 2:16 pm

Next

Return to Software Development

Who is online

Users browsing this forum: No registered users and 2 guests

cron