New bootloader

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
User avatar
Janka
Posts: 213
Joined: Fri Sep 21, 2012 10:46 pm
Location: inside Out

Re: New bootloader

Post by Janka » Sat May 11, 2019 4:22 pm

Jubatian wrote:
Sat May 11, 2019 8:01 am
Janka: I tried out the MMC patched version, however for some reason it behaves really odd (at least in the emulator). It works, but really slow, at the moment I have no idea why (this happens even when I use the hex you provided). I wanted to add the patch to the master repo so it existed as an option directly to build with MMC instead of SDHC, but first this will have to be resolved (I will look into it myself).
It's slow because the MMC cards I have don't support the higher clock speed. Programming fails during download. So I left it with the default speed.

User avatar
Jubatian
Posts: 1355
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: New bootloader

Post by Jubatian » Sat May 11, 2019 8:00 pm

Janka wrote:
Sat May 11, 2019 4:22 pm
It's slow because the MMC cards I have don't support the higher clock speed. Programming fails during download. So I left it with the default speed.
Wow, and I was thinking I was driving them slow. At least definitely compared to Tempest or in general how it was typically with the original kernel (14MHz, while the bootloader runs it normally at 3.5MHz). I didn't check the code, just looking at it I though some major screw-up (elsewere, probably due to a design flaw somehow triggered by the patch) is going on within, but that explains it.

Are the MMCs actually useful for playing games which would access the card? Just that I think a lot of the games attempt to drive the card at max SPI frequency.

User avatar
Janka
Posts: 213
Joined: Fri Sep 21, 2012 10:46 pm
Location: inside Out

Re: New bootloader

Post by Janka » Sun May 12, 2019 12:22 am

Which games?

It may be okay for smaller chunks, the failure is roughly after 32KB. Maybe there's some buffer underrun with those cards then.

User avatar
Jubatian
Posts: 1355
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: New bootloader

Post by Jubatian » Sun May 12, 2019 9:16 am

Janka wrote:
Sun May 12, 2019 12:22 am
Which games?

It may be okay for smaller chunks, the failure is roughly after 32KB. Maybe there's some buffer underrun with those cards then.
It seems like then communicating with SPI might be fine at higher speed, but the card can not fetch data fast enough, possilby manifesting in long waiting on Read Single / Read Multiple sectors until data actually arrived. Could you try restoring the SPI frequency (to 3.5MHz), and instead modifying SD_Wait_FF, the ldi r25, 0x10 line (Line 287)? To increase this timeout, let's say try 0x20 or 0x40 there to double / quadruple it.

If my assumption is correct, this would solve the problem while making the bootloader in overall more responsive.

User avatar
Janka
Posts: 213
Joined: Fri Sep 21, 2012 10:46 pm
Location: inside Out

Re: New bootloader

Post by Janka » Sun May 12, 2019 9:46 pm

Unfortunately, I cannot reproduce the MMC speed problems. Now some cards work at both speeds without further measures, while some don't work at all.

Should I be sad? Happy? :roll:

(But all working cards are unhappy with ACMD41 and need CMD1 instead, still.)

(I used this tutorial, by the way: http://elm-chan.org/docs/mmc/mmc_e.html)

rv6502
Posts: 23
Joined: Mon Feb 11, 2019 4:27 am

Re: New bootloader

Post by rv6502 » Mon May 13, 2019 4:54 am

Jubatian wrote:
Sun May 12, 2019 9:16 am
It seems like then communicating with SPI might be fine at higher speed, but the card can not fetch data fast enough, possilby manifesting in long waiting on Read Single / Read Multiple sectors until data actually arrived. Could you try restoring the SPI frequency (to 3.5MHz), and instead modifying SD_Wait_FF, the ldi r25, 0x10 line (Line 287)? To increase this timeout, let's say try 0x20 or 0x40 there to double / quadruple it.

If my assumption is correct, this would solve the problem while making the bootloader in overall more responsive.
Speaking of read errors. I got an old 1GB plain-SD card here with no speed rating that lists the directory content fine (10 files, with the OSX gunk) but fails to flash properly on the Uzebox. Fails a certain number of squares in depending on the file.

It's a slow one that I use for the 3D printer (I keep my better cards for other uses, takes 10 extra seconds to write the gcode for a 3 hour print... oh noes! :lol:

I'm not concerned enough (not at all. it's ridiculously old, pretty sure no cards on the market have been this slow for 7+ years.) to setup building the bootloader to fix it just yet but I can test.

User avatar
Jubatian
Posts: 1355
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: New bootloader

Post by Jubatian » Wed May 15, 2019 8:31 pm

rv6502 wrote:
Mon May 13, 2019 4:54 am
I'm not concerned enough (not at all. it's ridiculously old, pretty sure no cards on the market have been this slow for 7+ years.) to setup building the bootloader to fix it just yet but I can test.
It could be interesting to give it a go, just to see how it fails, maybe the bootloader could be tweaked a bit to be more generous!

Janka: Maybe you too with those MMCs refusing to cooperate. MMCs shouldn't be expected to understand ACMD41 as it is for SD (SDSC understanding both init protocols).

I now see that the MMC patch just lets it running really slow at ~240KHz. If a card doesn't work even at that frequency, then it I guess it is pretty much useless on SPI.

Otherwise try modifying Line 287 in sdlib.s as mentioned above (the bootloader should compile fine regardless of compiler version, it is all assembly):
Jubatian wrote:
Sun May 12, 2019 9:16 am
Could you try restoring the SPI frequency (to 3.5MHz), and instead modifying SD_Wait_FF, the ldi r25, 0x10 line (Line 287)? To increase this timeout, let's say try 0x20 or 0x40 there to double / quadruple it.

The importance is that if this times out, then the bootloader breaks connection with the card, and then retries. However the card might just not like having the connection broken there, and may just never respond properly from then until reinitializing.

I would be interested if bumping up that timeout could solve the issue (with any card which appears to work for the game selector, but fails to actually get a game uploaded).

User avatar
Janka
Posts: 213
Joined: Fri Sep 21, 2012 10:46 pm
Location: inside Out

Re: New bootloader

Post by Janka » Fri May 17, 2019 2:13 pm

As written, I cannot reproduce the problem during download. All the cards failing do so at the game selector now.

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests