gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS Flash Equipment > EZ-V DLDI Driver with unaligned read

#137028 - ps2aich - Tue Aug 07, 2007 2:34 pm

Hi all,

I open an extra thread to not poison New DLDI Tester - flash card report thread:

I was a little disappointed that EZ-V does not pass the read alignment
test (since I recently bought one), so I modified the driver
to allow this feature:

Before I upload the modified driver to the DLDI-Wiki, please could
some EZ-V User test it (of course, it works for me, but you never know :-)): ez5s.zip


Reason for the failure was following code snippet:
Code:
*((uint32 *)(&ppbuf[i])) = CARD_DATA_RD;

which I replaced by
Code:
temp = CARD_DATA_RD;
temp1= CARD_DATA;
ppbuf[i] = *p;
ppbuf[i+1] = *(p+1);
ppbuf[i+2] = *(p+2);
ppbuf[i+3] = *(p+3);

which was already as comment there.
As result, the driver didn't fit anymore into 8k, so now it uses
16k (should be no problem since for DLDI 32k are reserved
nevertheless). If this would be an problem for anyone,
I can try to spare some space by refactoring *p usage.

Edit 080801:
Somebody noticed, that on large block reads, the driver with the unaligned read feature was much slower than the former one. So I optimzed it again by testing for unalignment.
The updated dldi can be found in the DLDI Wiki.
Code:
// test if ppbuf is 4byte-aligned
   if ((((uint32) ppbuf) & 0x3) )
   {
      // ppbuf is non-aligned
      do {
         // Read data if available
         if (CARD_CR2 & CARD_DATA_READY) {
            if (i< target)
            {
               temp = CARD_DATA_RD;
               ppbuf[i] = *p;
               ppbuf[i+1] = *(p+1);
               ppbuf[i+2] = *(p+2);
               ppbuf[i+3] = *(p+3);
            }
            i+=4;
         }
      } while (CARD_CR2 & CARD_BUSY);
   }
   else
   {
      // ppbuf is aligned
      do {
         // Read data if available
         if (CARD_CR2 & CARD_DATA_READY) {
            if (i< target)
            {
                *((uint32 *)(&ppbuf[i])) = CARD_DATA_RD;
            }
            i+=4;
         }
      } while (CARD_CR2 & CARD_BUSY);
   }


Last edited by ps2aich on Fri Aug 01, 2008 9:22 pm; edited 1 time in total

#137130 - Diddl - Wed Aug 08, 2007 8:19 am

I will test it tonight (after work). thanks for your work!



[Edit] Sorry, I can't download this???

#137240 - ps2aich - Thu Aug 09, 2007 9:24 am

Diddl wrote:
I will test it tonight (after work). thanks for your work!



[Edit] Sorry, I can't download this???


Hm, it works for me, and on the site, already a number of people
have downloaded it.

I put it additionally on another file hoster: ez5s.zip

#137262 - Diddl - Thu Aug 09, 2007 5:51 pm

sorry, today the first link works also.


very succesful!! dldi works very fine now. wolfenstein 3d works also now.

thanks for your work. could you send this to chishm for update dldi page?

#137279 - ps2aich - Thu Aug 09, 2007 8:51 pm

Diddl wrote:
sorry, today the first link works also.


very succesful!! dldi works very fine now. wolfenstein 3d works also now.

thanks for your work. could you send this to chishm for update dldi page?


Diddl, thanks for counter testing :-)

I updated the EZ5 DLDI Page in the DLDI Wiki now.
(chishms page is not maintained anymore, the Wiki is the place to go :-))

Btw, this driver update also fixes the wrong dldi spec of the driver
(it was accidently specified as Slot-2).

To Psychowood: I think you have still an ez5s_v2.dldi in your
excellent tool DLDI Right Click (I can recommend it to all EZ-V users, because
it also does the Headerfix for homebrew, which is needed for the EZ-V) ,
you can replace it by this new driver.

#137298 - dantheman - Fri Aug 10, 2007 12:14 am

Since you have uploading capability, could you add the DLDI file for the MMP (since apparently the MMD file doesn't work for all MMP users)?

I posted it at http://forum.gbadev.org/viewtopic.php?t=12963&start=30 though it appears nobody has uploaded it since then.

#137328 - ps2aich - Fri Aug 10, 2007 8:47 am

dantheman wrote:
Since you have uploading capability, could you add the DLDI file for the MMP (since apparently the MMD file doesn't work for all MMP users)?

I posted it at http://forum.gbadev.org/viewtopic.php?t=12963&start=30 though it appears nobody has uploaded it since then.


Hi dantheman,

since the DLDI Wiki is a 'Wiki', you could easily do it yourself
(I suppose you have the ability to test this dldi driver).

Simply register at the wiki, and request upload rights
at this page

Than you can add a new slot-2 device and upload the driver.

I only would do it when absolutely no other can do it, since I have
no ability to test it.

#137357 - dantheman - Fri Aug 10, 2007 8:15 pm

Ah, I was wondering where the upload rights page was. Well the problem is that I can't test it, as I don't have the device. All I have is a few reports from people who couldn't get programs to work with the default MMD DLDI file but could with the MMP one here. Ah well, I'll figure it out, thanks.

#161348 - ps2aich - Fri Aug 01, 2008 9:27 pm

Update: Speed improvement for aligned reads (see update in first post)

#161586 - josath - Wed Aug 06, 2008 9:04 pm

A further optimization would be if the buffer is unaligned, use 8-bit copies for just the few odd bytes at the beginning & end, and 32-bit copies for all the bytes inbetween.

#161634 - ps2aich - Fri Aug 08, 2008 2:48 pm

Hm, you are right, but my assumption was, that unaligned reads are only happening in certain circumstances (e.g. calculating an address in a buffer to load a texture) and not constantly.

But I will try it perhaps, since im currently optimizing further (ezteam published the ez5sdhc source code), so I currently had write speed a little bit optimized (better crc algorithm from ez5sdhc source, removing unneeded memcpy on aligned write buffer) and removed stack allocation of write buffer to a static allocated one (solved some problems with certain homebrew applications).