SPI driver for U3+ (PCB rev 0.5)

Moderators: mdrjr, odroid

SPI driver for U3+ (PCB rev 0.5)

Unread postby odroid » Sun Jul 20, 2014 3:06 pm

We’ve shipped ODROID-U3 PCB Rev 0.5(U3+) since the end of June 2014.
There are 4 major differences against Rev 0.2.
1. Micro-USB port can work in USB host mode too.
2. USB host power protector IC was changed to NCP380 from AP2411.
3. HDMI reverse-current blocking IC AP2331 was placed on the correct place.
4. HW SPI port

You can see the schematics of Rev 0.5 in this link.
http://www.hardkernel.com/main/products ... &tab_idx=2

U3 IO Shield board was also updated to Rev 0.3 from Rev 0.2 by adding a SPI Flash memory.
http://www.hardkernel.com/main/products ... &tab_idx=2

HW SPI port
The Serial Peripheral Interface or SPI bus is a synchronous serial data link that operates in full duplex mode.
spi.png
spi.png (5.55 KiB) Viewed 6225 times


To access the SPI/GPIO on new J5 connector, you must update kernel first.
The SPI modules were enabled at July 17, 2014.
Code: Select all
wget http://builder.mdrjr.net/tools/kernel-update.sh
chmod +x kernel-update.sh
sudo ./kernel-update.sh


The SPI bus is added on new J5 (IO Port#2) 4-pin connector on PCB.
Note that SPI port supports only master mode and 1.8 Volt interface like other IO ports on Exynos processor.
board.png
board.png (665.2 KiB) Viewed 6225 times


Pin Descrption
pinmap.png
pinmap.png (15.47 KiB) Viewed 6225 times


You can use 4 pins as GPIO mode or SPI mode. After booting, the pins are in GPIO mode by default.
This example script sets all pins to output and toggle 5 times at 1Hz frequency.
At the beginning, it unloads the SPI driver modules to make sure the GPIO mode.
At the finishing, it releases the GPIOs for the next usage.
Code: Select all
modprobe spi-s3c64xx
modprobe odroid-ioboard
dmesg | grep ioboard
modprobe -r odroid-ioboard
modprobe -r spi-s3c64xx

count=0
stop=5

echo 20 > /sys/class/gpio/export
echo 21 > /sys/class/gpio/export
echo 22 > /sys/class/gpio/export
echo 23 > /sys/class/gpio/export

echo out > /sys/class/gpio/gpio20/direction
echo out > /sys/class/gpio/gpio21/direction
echo out > /sys/class/gpio/gpio22/direction
echo out > /sys/class/gpio/gpio23/direction

while :
do
   count=$(($count+1))

   echo 1 > /sys/class/gpio/gpio20/value;
   echo 1 > /sys/class/gpio/gpio21/value;
   echo 1 > /sys/class/gpio/gpio22/value;
   echo 1 > /sys/class/gpio/gpio23/value;
   echo "GPB[4],GPB[5],GPB[6],GPB[7] set output HIGH"
   sleep 1;

   echo 0 > /sys/class/gpio/gpio20/value;
   echo 0 > /sys/class/gpio/gpio21/value;
   echo 0 > /sys/class/gpio/gpio22/value;
   echo 0 > /sys/class/gpio/gpio23/value;
   echo "GPB[4],GPB[5],GPB[6],GPB[7] set output LOW"
   sleep 1;

    if [ $count -eq $stop ]; then
        echo "GPIO TEST STOP"
      echo 20 > /sys/class/gpio/unexport
      echo 21 > /sys/class/gpio/unexport
      echo 22 > /sys/class/gpio/unexport
      echo 23 > /sys/class/gpio/unexport
      exit 0
    fi
done


Let’s try the SPI mode.

How to load the SPI driver module for generic SPI usage!
Load the module to activate the SPI host.
Code: Select all
$ sudo modprobe spi-s3c64xx

Load the module to activate the generic SPI.
Code: Select all
$ sudo modprobe spidev

And you will have a standard SPI node.
Code: Select all
$ /dev/spidev1.0


How to load the SPI driver module for serial Flash!
Load the module to activate the SPI host.
Code: Select all
$ sudo modprobe spi-s3c64xx

Load the serial flash (misc) driver
Code: Select all
$ sudo modprobe odroid-ioboard

And you will have a Serial Flash node
Code: Select all
$ /dev/ioboard-spi-misc


Where are the SPI device drivers in Kernel 3.8.y?
- SPI host interface driver:
https://github.com/hardkernel/linux/blob/odroid-3.8.y/drivers/spi/spi-s3c64xx.c
- SPI generic driver
https://github.com/hardkernel/linux/blob/odroid-3.8.y/drivers/spi/spidev.c
- Serial SPI Flash add-on driver example
https://github.com/hardkernel/linux/blob/odroid-3.8.y/drivers/hardkernel/ioboard-spi-misc.c
Note that spidev.ko and odroid-ioboard.ko can’t be loaded at the same time.

We’ve tested the ioboard-spi-misc.ko with a Serial SPI Flash memory SST25WF020A on the new IO Shield and the maximum speed was 40Mhz of SPI clock.

Refer this link to know the generic SPIDEV driver usage in detail.
https://www.kernel.org/doc/Documentation/spi/spidev
User avatar
odroid
Site Admin
 
Posts: 25293
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: SPI driver for U3+ (PCB rev 0.5)

Unread postby odroid » Wed Jul 22, 2015 4:40 pm

Refer this link.
We could driver the SPI clock upto 38Mhz.
http://odroid.com/dokuwiki/doku.php?id=en:u3_ioport_spi
User avatar
odroid
Site Admin
 
Posts: 25293
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID


Return to Hardware and peripherals

Who is online

Users browsing this forum: No registered users and 3 guests