RetroBSD

2.11BSD operating system for microcontrollers
It is currently Sun Mar 29, 2020 12:21 pm

All times are UTC




Post new topic Reply to topic  [ 47 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: Sat Oct 10, 2015 7:09 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
I've seen somewhere there is command 6 which switches SDIO and SPI into 50MHz high speed mode with sdhc cards. Default speed is 25MHz. Do we have any experience with it? People write the write speed improves a bit, while read goes twice as fast then.
We may experiment with higher SPI speeds - ie 30MHz may work (even a little bit overclocked).
For example:
http://electronix.ru/forum/lofiversion/ ... 05763.html
Quote:
Проверить можно следующим образом:
1. Посылаем CMD6 с аргументом 0x00000001 (Mode 0, Function: High-Speed)
2. Принимаем 512 бит данных, в них смотрим бит 400 == 1, биты 379:376 == 1 - функция поддерживается,
разрешено переключение
3. Посылаем CMD6 с аргументом 0x80fffff1 (Mode 1, Function: High-Speed)
4. Принимаем 512 бит данных, проверяем биты 379:376 == 1 - успешно переключились
5. Ждем минимум 8 тактов, затем переключаем частоту

Важный момент: некоторые карты требуют паузы после CMD6, даже если осуществляется только проверка,
а не переключение.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sat Oct 10, 2015 7:14 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
I never tried it. On pic32mx we have not much freedom for experiments: only 13MHZ and 20MHz rates are possible. Makes sense to try on MZ.


Top
 Profile  
 
PostPosted: Sat Oct 10, 2015 7:18 am 
Contributor

Joined: Mon Nov 12, 2012 1:34 pm
Posts: 1092
Hi Serge and Pito,

Hmmmm.... A PIC32MZ...EF version of RetroBSD?

Can't be that hard. New startup and maybe a few pointers?

Wiz


Top
 Profile  
 
PostPosted: Sat Oct 10, 2015 7:23 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
With retrobsd we can try as well. With baremetal we can set something between 25-40MHz (overclocked a little bit).
Moreover, I think the High Speed mode may fix issues at slower SPI speeds one may have as well - my understanding is it only changes some dynamic parameters inside the card.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sat Oct 10, 2015 7:32 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
SPI clock on MX is BUS_CLK/2/n. With 80MHz processor clock, we can get only 40MHZ, 20 MHZ, 13MHZ, 10MHZ and lower.

From my experience, only some cards can work with clock 20MHz.


Top
 Profile  
 
PostPosted: Sat Oct 10, 2015 7:34 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Quote:
From my experience, only some cards can work with clock 20MHz.


I think the High Speed mode may fix issues at slower SPI speeds one may have with the sdcard as well - my understanding is it only changes some dynamic parameters with input/output SPI (SDIO) circuitry inside the sdcard.

You must not run SPI at higher speed when the card is in high speed mode.

The card will draw a few mA more and the signals will have much better shape (and better matching).

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Oct 14, 2015 2:35 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
OK, I'll put this into my TODO list for the future enhancements.
Thanks.


Top
 Profile  
 
PostPosted: Fri Oct 16, 2015 1:19 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Here is an overview of the access modi (ie. high speed), driver strength settings and power settings for the various sdhc cards.
Attached simplified SD Spec 4.10 with details.
Most of today's sdhc cards (especially UHS-I) support High-speed mode with 3.3V signalling in SPI mode.


Attachment:
cmd6.JPG
cmd6.JPG [ 57.12 KiB | Viewed 39828 times ]


Attachment:
sdcard_modes_cmd6.JPG
sdcard_modes_cmd6.JPG [ 141.1 KiB | Viewed 39828 times ]


Attachments:
part1_410.zip [1.76 MiB]
Downloaded 819 times

_________________
Pukao Hats Cleaning Services Ltd.
Top
 Profile  
 
PostPosted: Wed Nov 11, 2015 12:19 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
My first experiments with CMD6 on Fubarino SD:

Normally, the 96MHz/96MHz and 24MHz SPI settings with my sdcard (Sammy EVO CL10 UHS-I 8GB) does not work.

Now, with my simple CMD6 hack:

Code:
96MHz/96MHz and 24MHz SPI:
========================
sd0: type SDHC, size 7838720 kbytes, speed 24 Mbit/sec
sd0a: partition type b7, sector 2, size 204800 kbytes
sd0b: partition type b8, sector 409602, size 2048 kbytes
sd0c: partition type b7, sector 413698, size 102400 kbytes
phys mem  = 128 kbytes
user mem  = 96 kbytes
root dev  = (0,1)
swap dev  = (0,2)
root size = 204800 kbytes
swap size = 2048 kbytes
/dev/sd0a: 1521 files, 13118 used, 190881 free
I2C dev found, addr(r/w): 00(01/00)  1E(3D/3C)  4C(99/98)  53(A7/A6)  57(AF/AE)  68(D1/D0)  69(D3/D2)  77(EF/EE)
Wed Nov 11 12:57:32 CET 2015
Starting daemons: update cron


2.11 BSD UNIX (pic32) (console)

login: root
Password:


60MHz/60MHz and 30MHz SPI:
========================
sd0: type SDHC, size 7838720 kbytes, speed 30 Mbit/sec
sd0a: partition type b7, sector 2, size 204800 kbytes
sd0b: partition type b8, sector 409602, size 2048 kbytes
sd0c: partition type b7, sector 413698, size 102400 kbytes
phys mem  = 128 kbytes
user mem  = 96 kbytes
root dev  = (0,1)
swap dev  = (0,2)
root size = 204800 kbytes
swap size = 2048 kbytes
/dev/sd0a: 1521 files, 13119 used, 190880 free
I2C dev found, addr(r/w): 00(01/00)  1E(3D/3C)  4C(99/98)  53(A7/A6)  57(AF/AE)  68(D1/D0)  69(D3/D2)  77(EF/EE)
Wed Nov 11 13:12:06 CET 2015
Starting daemons: update cron


2.11 BSD UNIX (pic32) (console)

login:

# make clean
rm -f *.o *~ hello stdarg skeleton primelist primesum test1 test2 test3  gpio adc rain q8 tetris lcd6
# time make
cc  -o hello  hello.c
cc  -o stdarg  stdarg.c
cc  -o skeleton  skeleton.c
cc  -o primelist  primelist.c
cc  -o primesum  primesum.c
cc  -o test1  test1.c
cc  -o test2  test2.c
cc  -o test3  test3.c
cc  -o gpio  gpio.c
cc  -o adc  adc.c
cc  -o rain  rain.c
cc  -o q8  q8.c
cc  -o tetris  tetris.c
cc  -o lcd6  lcd6.c
       22.0 real         5.0 user        12.5 sys
#


The hack in sd.c:
Code:
..
        //  PITO's CMD6 experiments, 11/2015
        spi_select(io);
        // here we set HighSpeed 50MHz, we do not tackle the power and io driver strength yet
        card_cmd(unit, 0x06, 0x80000001);           
        udelay(10000);
        // read 64 dummy bytes, we do not check the high speed status inside these bits yet
        for (i=0; i<64; i++)
            spi_transfer(io, 0xFF);
        udelay(10000);
        card_release(io);

    /* Fast speed. */
    spi_brg(io, SD_MHZ * 1000);
    return 1;
}

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Nov 11, 2015 12:46 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Code:
2.11 BSD Unix for PIC32, revision G451 build 14:
     Compiled 2015-11-11 by pito@UBU1404:
     /home/pito/Retronew/retrobsd/sys/pic32/baremetal
cpu: 795F512H 68 MHz, bus 68 MHz
oscillator: HS crystal, PLL div 1:2 mult x17
spi2: pins sdi=RG7/sdo=RG8/sck=RG6
uart2: pins rx=RF4/tx=RF5, interrupts 40/41/42, console
sd0: port SPI2, pin cs=RG9
gpio1: portB, pins iiiiiiiiiiiiiiii
gpio2: portC, pins iiii------------
gpio3: portD, pins ----iiiiiiii---i
gpio4: portE, pins --------iioiiiii
gpio5: portF, pins ------------i-ii
gpio6: portG, pins ------------ii--
adc: 15 channels
pwm: 5 channels
sd0: type SDHC, size 7838720 kbytes, speed 34 Mbit/sec
sd0a: partition type b7, sector 2, size 204800 kbytes
sd0b: partition type b8, sector 409602, size 2048 kbytes
sd0c: partition type b7, sector 413698, size 102400 kbytes
phys mem  = 128 kbytes
user mem  = 96 kbytes
root dev  = (0,1)
swap dev  = (0,2)
root size = 204800 kbytes
swap size = 2048 kbytes
/dev/sd0a: 1521 files, 13119 used, 190880 free
I2C dev found, addr(r/w): 00(01/00)  1E(3D/3C)  4C(99/98)  53(A7/A6)  57(AF/AE)  68(D1/D0)  69(D3/D2)  77(EF/EE)
Wed Nov 11 13:45:46 CET 2015
Starting daemons: update cron


2.11 BSD UNIX (pic32) (console)

login:


Code:
# cd /share/examples/c
# make clean
rm -f *.o *~ hello stdarg skeleton primelist primesum test1 test2 test3  gpio adc rain q8 tetris lcd6
# time make
cc  -o hello  hello.c
cc  -o stdarg  stdarg.c
cc  -o skeleton  skeleton.c
cc  -o primelist  primelist.c
cc  -o primesum  primesum.c
cc  -o test1  test1.c
cc  -o test2  test2.c
cc  -o test3  test3.c
cc  -o gpio  gpio.c
cc  -o adc  adc.c
cc  -o rain  rain.c
cc  -o q8  q8.c
cc  -o tetris  tetris.c
cc  -o lcd6  lcd6.c
       20.3 real         4.3 user        11.9 sys
#

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Nov 11, 2015 1:05 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Code:
2.11 BSD Unix for PIC32, revision G451 build 16:
     Compiled 2015-11-11 by pito@UBU1404:
     /home/pito/Retronew/retrobsd/sys/pic32/baremetal
cpu: 795F512H 72 MHz, bus 72 MHz
oscillator: HS crystal, PLL div 1:2 mult x18
spi2: pins sdi=RG7/sdo=RG8/sck=RG6
uart2: pins rx=RF4/tx=RF5, interrupts 40/41/42, console
sd0: port SPI2, pin cs=RG9
gpio1: portB, pins iiiiiiiiiiiiiiii
gpio2: portC, pins iiii------------
gpio3: portD, pins ----iiiiiiii---i
gpio4: portE, pins --------iioiiiii
gpio5: portF, pins ------------i-ii
gpio6: portG, pins ------------ii--
adc: 15 channels
pwm: 5 channels
sd0: type SDHC, size 7838720 kbytes, speed 36 Mbit/sec
sd0a: partition type b7, sector 2, size 204800 kbytes
sd0b: partition type b8, sector 409602, size 2048 kbytes
sd0c: partition type b7, sector 413698, size 102400 kbytes
phys mem  = 128 kbytes
user mem  = 96 kbytes
root dev  = (0,1)
swap dev  = (0,2)
root size = 204800 kbytes
swap size = 2048 kbytes
/dev/sd0a: 1521 files, 13120 used, 190879 free
I2C dev found, addr(r/w): 00(01/00)  1E(3D/3C)  4C(99/98)  53(A7/A6)  57(AF/AE)  68(D1/D0)  69(D3/D2)  77(EF/EE)
Wed Nov 11 14:03:36 CET 2015
Starting daemons: update cron


2.11 BSD UNIX (pic32) (console)

login: root
Password:
Welcome to RetroBSD!
erase ^?, kill ^U, intr ^C
# cd /share/examples/c
# make clean
rm -f *.o *~ hello stdarg skeleton primelist primesum test1 test2 test3  gpio adc rain q8 tetris lcd6
# time make
cc  -o hello  hello.c
cc  -o stdarg  stdarg.c
cc  -o skeleton  skeleton.c
cc  -o primelist  primelist.c
cc  -o primesum  primesum.c
cc  -o test1  test1.c
cc  -o test2  test2.c
cc  -o test3  test3.c
cc  -o gpio  gpio.c
cc  -o adc  adc.c
cc  -o rain  rain.c
cc  -o q8  q8.c
cc  -o tetris  tetris.c
cc  -o lcd6  lcd6.c
       19.5 real         4.0 user        11.8 sys
#

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Nov 11, 2015 1:14 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
RetroBSD - Sdcard @ 40MHz SPI - Fubarino SD and Sammy Evo 8GB CL10 UHS-I with my CMD6 hack:
Code:
2.11 BSD Unix for PIC32, revision G451 build 18:
     Compiled 2015-11-11 by pito@UBU1404:
     /home/pito/Retronew/retrobsd/sys/pic32/baremetal
cpu: 795F512H 80 MHz, bus 80 MHz
oscillator: HS crystal, PLL div 1:2 mult x20
spi2: pins sdi=RG7/sdo=RG8/sck=RG6
uart2: pins rx=RF4/tx=RF5, interrupts 40/41/42, console
sd0: port SPI2, pin cs=RG9
gpio1: portB, pins iiiiiiiiiiiiiiii
gpio2: portC, pins iiii------------
gpio3: portD, pins ----iiiiiiii---i
gpio4: portE, pins --------iioiiiii
gpio5: portF, pins ------------i-ii
gpio6: portG, pins ------------ii--
adc: 15 channels
pwm: 5 channels
sd0: type SDHC, size 7838720 kbytes, speed 40 Mbit/sec
sd0a: partition type b7, sector 2, size 204800 kbytes
sd0b: partition type b8, sector 409602, size 2048 kbytes
sd0c: partition type b7, sector 413698, size 102400 kbytes
phys mem  = 128 kbytes
user mem  = 96 kbytes
root dev  = (0,1)
swap dev  = (0,2)
root size = 204800 kbytes
swap size = 2048 kbytes
/dev/sd0a: 1521 files, 13121 used, 190878 free
I2C dev found, addr(r/w): 00(01/00)  1E(3D/3C)  4C(99/98)  53(A7/A6)  57(AF/AE)  68(D1/D0)  69(D3/D2)  77(EF/EE)
Wed Nov 11 14:12:29 CET 2015
Starting daemons: update cron


2.11 BSD UNIX (pic32) (console)

login: root
Password:
Welcome to RetroBSD!
erase ^?, kill ^U, intr ^C
# cd /share/examples/c
# make clean
rm -f *.o *~ hello stdarg skeleton primelist primesum test1 test2 test3  gpio adc rain q8 tetris lcd6
# time make
cc  -o hello  hello.c
cc  -o stdarg  stdarg.c
cc  -o skeleton  skeleton.c
cc  -o primelist  primelist.c
cc  -o primesum  primesum.c
cc  -o test1  test1.c
cc  -o test2  test2.c
cc  -o test3  test3.c
cc  -o gpio  gpio.c
cc  -o adc  adc.c
cc  -o rain  rain.c
cc  -o q8  q8.c
cc  -o tetris  tetris.c
cc  -o lcd6  lcd6.c
       18.6 real         3.6 user        11.4 sys
#


Happy to see it basically works.
The next step is the FINETUNING :lol: :lol: :ugeek: :ugeek: :ugeek:

PS: The pic32MX's max datasheet SPI speed is 25MHz, so we overclock the SPI here a bit :)
The pic32MZ's max datasheet SPI speed is 50MHz..

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Nov 11, 2015 1:56 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
LiteBSD - sdcard @ 50MHz SPI - Sammy Evo 8GB, CL10, UHS-I - on the SDZL board with my dirty CMD6 hack:
Code:
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.

4.4BSD-Lite build 0 compiled 2015-11-11
    pito@UBU1404:LiteBSD/sys/compile/SDZL.pic32
cpu: PIC32MZ2048ECG064 rev A5, 200 MHz
oscillator: system PLL div 1:6 mult x50
cache: 16/4 kbytes
real mem = 512 kbytes
avail mem = 348 kbytes
using 18 buffers containing 73728 bytes of memory
spi2 at pins sdi=G7/sdo=G8/sck=G6
uart1 at pins rx=D2/tx=D3, interrupts 112/113/114
uart2 at pins rx=B7/tx=B6, interrupts 145/146/147, console
sd0 at port spi2, pin cs=G9
sd0: type SDHC, size 7838720 kbytes, speed 50 Mbit/sec
sd0a: partition type b7, sector 2, size 524288 kbytes
sd0b: partition type b8, sector 1048578, size 32768 kbytes
sd0c: partition type b7, sector 1114114, size 102400 kbytes
bpf: lo0 attached
WARNING: preposterous clock chip time -- CHECK AND RESET THE DATE!

starting file system checks.
/dev/rsd0a: file system is clean; not checking
starting network
clearing /tmp
standard daemons: update.
Sun Oct 25 01:50:52 PDT 2015


4.4BSD-Lite (bsd.net) (console)

login: root
Last login: Sun Oct 25 01:50:46 on console
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
        The Regents of the University of California.   All rights reserved.

4.4BSD-Lite UNIX #1: Fri Apr 01 00:00:00 PDT 1994

Welcome to 4.4BSD-Lite!

erase ^H, kill ^U, intr ^C status ^T
Don't login as root, use the su command.
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 5.189 seconds = 1578 kbytes/sec
 Read speed: 8 Mbytes in 2.396 seconds = 3419 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 4.655 seconds = 1759 kbytes/sec
 Read speed: 8 Mbytes in 2.386 seconds = 3433 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 4.629 seconds = 1769 kbytes/sec
 Read speed: 8 Mbytes in 2.402 seconds = 3410 kbytes/sec
# ls
.cshrc          .klogin         .login          .profile        .rhosts
# cd /
# ls
.cshrc          dev             root            tmp             var
.profile        etc             sbin            u
bin             home            test            usr
# cd u
# ls
debug.log       teraterm488.exe
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 3.725 seconds = 2199 kbytes/sec
 Read speed: 8 Mbytes in 2.398 seconds = 3416 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 3.766 seconds = 2175 kbytes/sec
 Read speed: 8 Mbytes in 2.393 seconds = 3423 kbytes/sec
#
#

Serial 460k but still..
Code:
 # time ls -lR /
..
        6.90 real         4.88 user         0.11 sys
#

And my CMD6 hack itself (in sd.c):
Code:
 ..
        //  PITO's CMD6 experiments, LiteBSD hack, 11/2015
        sd_select(io);
        // here we set HighSpeed 50MHz, we do not tackle the power and io driver strength yet
        card_cmd(unit, 0x06, 0x80000001);           
        udelay(10000);
        // read 64 dummy bytes, we do not check the high speed status inside these bits yet
        for (i=0; i<64; i++)
            spi_transfer(io, 0xFF);
        udelay(10000);
        sd_deselect(io);

    /* Fast speed. */
    spi_set_speed(io, SD_KHZ);
    return 1;
}

Cool!!! :P :P :P :P :P :P :P

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Nov 11, 2015 6:21 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
My naive shot worked, but the correct algorithm is as follows (I've started to read the spec):
Code:
1. Issue CMD6 in mode 0 (check) or mode 1 (switch)
2. CMD6 answers with R1 response, and 512bits of statuses
3. After CMD6 mode 1 (switch) additional 8 clocks must be issued, then the switch occurs.


Code:
        //  **** PITO's CMD6 experiments, LiteBSD hack, 11/2015
        // select the card
        sd_select(io);

        // we do not check with CMD6 check (bit31=0) yet, we know well our card is ok
        // now, here we will switch the card into the HighSpeed 50MHz mode
        // we do not tackle the power limit and output drivers strength yet
        // switch with bit31=1, bit0=1 is 50MHz, all other settings set to card's defaults
        card_cmd(unit, 0x06, 0x80000001);     
        // card command got R1, we do not check that yet 
        // the above .ru source recommends to add a delay here
        udelay(10000);
   
        // now do read 64 STATUS bytes, we do not check the statuses inside these bits yet
        for (i=0; i<64; i++)
            spi_transfer(io, 0xFF);

        // issue at least 8 clocks, then the switch of the sdcard mode occurs
        for (i=0; i<2; i++)
            spi_transfer(io, 0xFF);

        // deselect the card       
        sd_deselect(io);

So I missed 8 final clocks, but it had worked..
No warranties of any kind :)

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Nov 11, 2015 8:19 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Tried with
Code:
card_cmd(unit, 0x06, 0x80001101)
or
card_cmd(unit, 0x06, 0x80FF11F1)  // F means no change
;

It still works (1.44W, driverA, 50MHz). Still waiting on my LeCroy to check the signal edges :)

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Nov 11, 2015 8:27 pm 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
It's amazing!
I have about forty different SD and microSD cards in my collection - need to test them all. :)
Is this mode safe enough?
I mean, wouldn't it cause some negative side effects?


Top
 Profile  
 
PostPosted: Wed Nov 11, 2015 8:37 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Of course your filesystem may get corrupt, when the clock speed is too high for the card or for your board.
I've done a dozen experiments with pic32mz w/ SDZL @50MHz and the Sammy 8GB CL10 and it still works fine without a single crash. We need a stress test to check the stuff fully.

With retrobsd on fubarino at 40MHz it crashed after few minutes of playing with (sdcard timeouts something) it and the fs seems to be corrupt so I have to reinstall it. Note: the pic32mx max SPI speed is 25MHz (not 40MHz).

I think with CL10 (best w/ UHS-I) cards and above it will work at least with these two boards (fubarino 30MHz). Not sure about the boards with 20cm long SPI wires..
I would not try with old CL4 cards. I've seen somewhere CL6 may work too.

This is what I run just now (SDZL, Sammy CL10 UHS-I @ 50MHz SPI):
Code:
        //  PITO's CMD6 experiments, 11/2015
        sd_select(io);
        // here we set HighSpeed 50MHz, max power 1.44W, driver strength A
        card_cmd(unit, 0x06, 0x80FF11F1);           
        udelay(10000);
        // read 64 statuses bytes, we do not check the statuses inside these bits yet
        for (i=0; i<64; i++)
            spi_transfer(io, 0xFF);
        // and finally do a switch to high speed
        for (i=0; i<8; i++)
            spi_transfer(io, 0xFF);
        sd_deselect(io);

    /* Fast speed. */
    spi_set_speed(io, SD_KHZ);
    return 1;
}

Code:
Welcome to 4.4BSD-Lite!

erase ^H, kill ^U, intr ^C status ^T
Don't login as root, use the su command.
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 6.327 seconds = 1294 kbytes/sec
 Read speed: 8 Mbytes in 2.402 seconds = 3410 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 6.009 seconds = 1363 kbytes/sec
 Read speed: 8 Mbytes in 2.402 seconds = 3410 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 4.673 seconds = 1753 kbytes/sec
 Read speed: 8 Mbytes in 2.397 seconds = 3417 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 4.659 seconds = 1758 kbytes/sec
 Read speed: 8 Mbytes in 2.395 seconds = 3420 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 6.623 seconds = 1236 kbytes/sec
 Read speed: 8 Mbytes in 2.410 seconds = 3399 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 6.673 seconds = 1227 kbytes/sec
 Read speed: 8 Mbytes in 2.407 seconds = 3403 kbytes/sec
# cd /u
# ls
debug.log       teraterm488.exe
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 5.780 seconds = 1417 kbytes/sec
 Read speed: 8 Mbytes in 2.597 seconds = 3154 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 3.993 seconds = 2051 kbytes/sec
 Read speed: 8 Mbytes in 2.401 seconds = 3411 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 3.729 seconds = 2196 kbytes/sec
 Read speed: 8 Mbytes in 2.394 seconds = 3421 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 3.755 seconds = 2181 kbytes/sec
 Read speed: 8 Mbytes in 2.405 seconds = 3406 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 3.767 seconds = 2174 kbytes/sec
 Read speed: 8 Mbytes in 2.394 seconds = 3421 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 3.722 seconds = 2200 kbytes/sec
 Read speed: 8 Mbytes in 2.394 seconds = 3421 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 3.731 seconds = 2195 kbytes/sec
 Read speed: 8 Mbytes in 2.394 seconds = 3421 kbytes/sec
#
#

What else to run on LiteBsd to stress the sdcard fully??

PS: that hack is not a driver :) We have to query the sdcard with CMD6 (bit31=0) and it returns R1 plus 512bits of statuses. From the bits you can judge on the card's capabilities. Then you issue CMD6 with bit31=1 (switch) with settings, it returns R1 plus 512bits again, If you sniff into the bits you see which functions switches were acknowledged by the sdcard.
After that you do 8 clocks and you can switch over the SPI to highspeed.
A lot of messing with bits, that exercise has to be fulfilled by experts, I'm just a pioneer.. :idea:

PS1:
Max speed - you can set here is 50MHz, as the 25 and 50 are the only supported with 3.3V signalling (we do not have 1.8V signalling with pic32mz/mx). Default speed with our cards is 25MHz.

Power - it is the max power the card may take out of the socket - 0.36W - 2.88Watt, basically it is the current taken from the sdcard's Vcc source, measured at 3.6V. The SD Spec says the speeds 50MHz and above may require higher max power settings to be set (default for our typical cards is 0.36W/0.72W =100mA/200mA).

Driver strength - in our case the sdcard's SPI data output pin strenght, no idea what it means in practice (mA, load in pF, edges in ns??) - no info found on the web. SD Spec is not disclosing that. The default is usually set to B with our cards, the higher speeds are with A, C, D then.
EDIT: the driver strength is applicable for 1.8V signaling only.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Nov 11, 2015 9:18 pm 
Contributor

Joined: Mon Nov 12, 2012 1:34 pm
Posts: 1092
Hi Pito and all,

Most impressive :) :).

Two cards at once? interleaved? like DOS xcopy with both floppies flashing back and forth :).

I think it would be neat to get Retro running under LiteBSD!

Lots of fun.

Wiz


Top
 Profile  
 
PostPosted: Wed Nov 11, 2015 10:38 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
We still have DMA handy.. It may improve the speed a bit. Moreover, it may deload the CPU.. Max SPI throughput with pic32mz is 6.25MB/sec. We may improve by 100% :P

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Thu Nov 12, 2015 8:15 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Hmm, with 120/120/30MHz retrobsd I am getting these rather average results:
Code:
# cd /u
# ls
README.txt  lost+found
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 20.610 seconds = 397 kbytes/sec
 Read speed: 8 Mbytes in 6.100 seconds = 1342 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 22.230 seconds = 368 kbytes/sec
 Read speed: 8 Mbytes in 6.000 seconds = 1365 kbytes/sec
# diskspeed
Testing 4-kbyte block size.
Write speed: 8 Mbytes in 20.765 seconds = 394 kbytes/sec
 Read speed: 8 Mbytes in 6.000 seconds = 1365 kbytes/sec
 #

Why the write is so slow on retrobsd?
LiteBSD:
200/100/50MHz = 2200/3400 WR/RD
RetroBSD:
120/120/30MHz = 390/1360 WR/RD
The same sdcard.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 47 posts ]  Go to page 1, 2, 3  Next

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron




Powered by phpBB® Forum Software © phpBB Group

BSD Daemon used with permission