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.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).
Uzebox Bootloader V5
Re: New bootloader
Re: New bootloader
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.
Re: New bootloader
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 may be okay for smaller chunks, the failure is roughly after 32KB. Maybe there's some buffer underrun with those cards then.
Re: New bootloader
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.
Re: New bootloader
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?
(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)
Should I be sad? Happy?
(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)
Re: New bootloader
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.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.
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!
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.
Re: New bootloader
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):
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).
Re: New bootloader
As written, I cannot reproduce the problem during download. All the cards failing do so at the game selector now.
Re: New bootloader
Bootloader faults with some SD cards (discovered during Tempest SDHC tests).
Some information on this, as far as I see, general limitations of the SD library which might happen to be stressed in this case (if so, I really can't grasp why such formattings are even used):
Some information on this, as far as I see, general limitations of the SD library which might happen to be stressed in this case (if so, I really can't grasp why such formattings are even used):
- The first partition must start within 32 MBytes (64K * 512b sector size).
- The FAT of the first partition must start within 32 MBytes (64K * 512b sector size).
Re: New bootloader
I suspect that the empty space in the beginning is to align the filesystem with the underlying erase size.
Someone asked SanDisk support why their card had 16 MB of free space at the beginning and the official reply was:
"You may leave the 16MB unallocated space as it is. A portion of the total capacity is used to store certain functions including optimizations of the memory that support performance and endurance and therefore is not available for user storage."
Regardless, I just went out and bought a brand new SanDisk 16GB SDHC card, and this is what fdisk reports:
And this is what it looks like in gnome-disks:
And this is what hexdump -C /dev/sdb looks like:
I haven't stored anything on this 16GB card yet, I wanted to keep it blank for science, but this empty 4.2MB of space is what the other two SanDisk SDHC cards (4GB, 8GB) that froze the bootloader look like, and when I reformatted the 8GB one to get rid of that free space at the beginning it started working with the bootloader, but I suspect its write performance may be impacted now that the filesystem is not aligned (no worries if I dedicate this for the Uzebox, unless someone makes a game that needs to write data fast). I emailed you a compressed copy of the first 10MB of the 4GB card that hangs the bootloader, because it was too big to attach here (1.8MB). It had other non-Uzebox stuff on it (WAVE files) for an AVR-based WAVE Player I created, and it works fine with that code.
Someone asked SanDisk support why their card had 16 MB of free space at the beginning and the official reply was:
"You may leave the 16MB unallocated space as it is. A portion of the total capacity is used to store certain functions including optimizations of the memory that support performance and endurance and therefore is not available for user storage."
Regardless, I just went out and bought a brand new SanDisk 16GB SDHC card, and this is what fdisk reports:
Code: Select all
Disk /dev/sdb: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Disk model: Power Saving USB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/sdb1 8192 31116287 31108096 14.9G c W95 FAT32 (LBA)
Code: Select all
$ sudo hexdump -C /dev/sdb
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 82 |................|
000001c0 03 00 0c fe ff ff 00 20 00 00 00 ac da 01 00 00 |....... ........|
000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00000200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00400000 eb 00 90 20 20 20 20 20 20 20 20 00 02 40 56 02 |... ..@V.|
00400010 02 00 00 00 00 f8 00 00 3f 00 ff 00 00 20 00 00 |........?.... ..|
00400020 00 ac da 01 d5 0e 00 00 00 00 00 00 02 00 00 00 |................|
00400030 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00400040 80 00 29 62 35 33 66 4e 4f 20 4e 41 4d 45 20 20 |..)b53fNO NAME |
00400050 20 20 46 41 54 33 32 20 20 20 00 00 00 00 00 00 | FAT32 ......|
00400060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
004001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00400200 52 52 61 41 00 00 00 00 00 00 00 00 00 00 00 00 |RRaA............|
00400210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
004003e0 00 00 00 00 72 72 41 61 ff ff ff ff 02 00 00 00 |....rrAa........|
004003f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00400400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
004005f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00400600 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00400c00 eb 00 90 20 20 20 20 20 20 20 20 00 02 40 56 02 |... ..@V.|
00400c10 02 00 00 00 00 f8 00 00 3f 00 ff 00 00 20 00 00 |........?.... ..|
00400c20 00 ac da 01 d5 0e 00 00 00 00 00 00 02 00 00 00 |................|
00400c30 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00400c40 80 00 29 62 35 33 66 4e 4f 20 4e 41 4d 45 20 20 |..)b53fNO NAME |
00400c50 20 20 46 41 54 33 32 20 20 20 00 00 00 00 00 00 | FAT32 ......|
00400c60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00400df0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00400e00 52 52 61 41 00 00 00 00 00 00 00 00 00 00 00 00 |RRaA............|
00400e10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00400fe0 00 00 00 00 72 72 41 61 ff ff ff ff 02 00 00 00 |....rrAa........|
00400ff0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00401000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
004011f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00401200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
0044ac00 f8 ff ff 0f ff ff ff 0f ff ff ff 0f 00 00 00 00 |................|
0044ac10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00625600 f8 ff ff 0f ff ff ff 0f ff ff ff 0f 00 00 00 00 |................|
00625610 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
3b597fe00 b8 31 1d c8 45 5a 1b 99 b9 74 1d 05 a7 b7 d2 73 |.1..EZ...t.....s|
3b597fe10 0c 95 0a 17 1e 7b a9 d8 5a 09 6c d1 e3 e5 71 6f |.....{..Z.l...qo|
3b597fe20 c7 67 97 fa 14 a2 ac 89 3b 1d 66 5d f2 8d 39 99 |.g......;.f]..9.|
3b597fe30 a9 22 87 b3 e4 7c da 89 83 a5 e1 43 e7 dd 23 f7 |."...|.....C..#.|
3b597fe40 79 5a 5a e0 e3 47 d0 4f 8e 3b 7b 4d 46 b3 ca 21 |yZZ..G.O.;{MF..!|
3b597fe50 21 f8 98 ac 79 36 27 91 ab 6b 64 1d c1 83 57 5f |!...y6'..kd...W_|
3b597fe60 df 14 70 8c 1e 20 da 86 17 c6 08 8e dd f5 9d f2 |..p.. ..........|
3b597fe70 f7 50 8d 40 27 34 cf c9 0d 51 8c 31 7a 35 95 66 |.P.@'4...Q.1z5.f|
3b597fe80 4a 99 13 aa 23 e3 6a af 58 26 34 85 2e 55 66 af |J...#.j.X&4..Uf.|
3b597fe90 21 f2 69 e7 d3 d7 27 1e 2f d6 86 0c 37 7f 1e 05 |!.i...'./...7...|
3b597fea0 0d 16 83 18 6c 76 37 71 d9 27 78 8b 9e 55 31 99 |....lv7q.'x..U1.|
3b597feb0 63 fa 44 44 82 8c 92 01 0b b1 4e 9c 1e b0 16 47 |c.DD......N....G|
3b597fec0 bd 90 2f dd 55 1c 5e 96 47 1e 64 45 1b 6a 14 c2 |../.U.^.G.dE.j..|
3b597fed0 f1 81 1b 10 4b fe b0 fa 55 aa 44 7a 31 af ee 0a |....K...U.Dz1...|
3b597fee0 c6 c2 2a b6 ed 24 60 0d e0 4f 33 64 38 82 c9 14 |..*..$`..O3d8...|
3b597fef0 86 0a 21 e6 6d 94 89 83 52 94 d0 14 06 52 1e 50 |..!.m...R....R.P|
3b597ff00 c7 28 90 68 a9 3f d5 00 d1 bf 81 55 f9 2a a2 7a |.(.h.?.....U.*.z|
3b597ff10 7c 68 58 11 2d ca 0c 9f 85 5c 8f 83 c1 34 80 55 ||hX.-....\...4.U|
3b597ff20 fa 30 b0 35 86 0f a6 cd fb 90 a9 e1 fb 06 c5 c4 |.0.5............|
3b597ff30 c8 d6 19 41 1f 64 7e 15 11 e3 ae 2b 0e 3f a1 e6 |...A.d~....+.?..|
3b597ff40 bd da 24 8c 47 12 fd 80 2d a2 4a a3 2e 00 85 f2 |..$.G...-.J.....|
3b597ff50 cf 2c 7d fa bb dd 9c 9a 87 53 2a ff a1 71 d1 f2 |.,}......S*..q..|
3b597ff60 c7 21 9b 91 2e cc 15 53 c5 b5 54 4b 36 43 64 f1 |.!.....S..TK6Cd.|
3b597ff70 61 90 45 63 b3 b0 24 a4 18 6e 7e aa 78 3f 93 82 |a.Ec..$..n~.x?..|
3b597ff80 4e c3 a2 bd 58 84 7d 58 81 74 c2 66 83 35 5c 3d |N...X.}X.t.f.5\=|
3b597ff90 0a cf 71 a2 88 ef 8f 84 dd 68 06 df 52 5d 7a ae |..q......h..R]z.|
3b597ffa0 3c b2 95 ca 1c fe 42 7b b4 32 ea 58 0f c6 f5 59 |<.....B{.2.X...Y|
3b597ffb0 d2 7b eb 1e 5c c6 a1 f2 c1 60 7b 4b d5 c3 ca a5 |.{..\....`{K....|
3b597ffc0 97 74 04 24 ee 4e bc 6c 4a 36 71 08 4d bb c9 16 |.t.$.N.lJ6q.M...|
3b597ffd0 c8 27 ae b5 b5 17 3b f1 04 74 3c cd eb bd e5 d4 |.'....;..t<.....|
3b597ffe0 e0 bc 2d 43 d9 16 29 d0 97 0c 00 85 0d da a7 17 |..-C..).........|
3b597fff0 f1 56 28 97 02 83 97 00 3a 72 a1 9b ff fc 3b dd |.V(.....:r....;.|
3b5980000