Thursday, September 5, 2013

Adding GPIO SPI and I2C options to your Arch Linux Kernel

Edit 12/07/2013:
Thanks to Mr. Mauro Ribeiro, I was able to get the SPI on my ODROID-X2 board and, now I will be working on the actual development of the main project, which is, Controlling the world via SPI bus...
Mr. Mauro Ribeiro modified the kernel on https://github.com/hardkernel/linux/tree/odroid-3.8.y
and now we can build kernels with SPI1 enabled.


First lets put some list of GPIOs I used on this board:
105, 102, 110, 117
GPIO are found @
/sys/class/gpio
and then need to export as root...
#echo "105" > export
# echo "102" > export
# echo "110" > export
# echo "117" > export
# echo "out" >  gpio105/direction
# echo "out" >  gpio102/direction
# echo "out" >  gpio110/direction
# echo "out" >  gpio117/direction


# echo "1" > gpio105/value
# echo "0" > gpio105/value
# echo "1" > gpio102/value
# echo "0" > gpio102/value
# echo "1" > gpio102/value
# echo "1" > gpio105/value
# echo "0" > gpio105/value


To read from GPIO that is set as Input:
# echo "in" >  gpio105/direction
# cat /sys/class/gpio/gpio105/value



So, I had to build my Kernel to be able to enable the SPI "I hope that it is going to work..."
Make sure you have at least large SD drive, I used 8 GB and did not work.  So, 16 GB is recommended...

Edit:
OK, my 8GB SD card was not fully used, I had to use gparted and resize the partition to use the full SD card size.

1. Get the source code from the link below, I had to get linux-odroid-3.8.y.zip as others did not have my odroidx2_ubuntu_defconfig configuration file.
https://github.com/hardkernel/linux

2. Now you will have to unzip the file, so crate a folder in your home directory and save the downloaded zip file to it then use
unzip linux-odroid-3.8.y.zip
I installed 7z by using
pacman -S p7zip
Then
7z x -y zip.file.name
You will also need to get
pacman -S base-devel

Also you will need:
pacman -S gcc  make


3. make sure you work from the new created folder, linux-odroid-3.8.y
cd linux-odroid-3.8.y

zcat /proc/config.gz > .config

for Latest SPI enabled configuration, I used the following
make odroidx2_defconfig

4. Run make oldconfig
4. Now, run make menuconfig,  this will allow you to go and enable other options before you build the new kernel

5. make sure you exit and save changes when you are done,  now you should have a .config file in the current folder

6. To start build Run
make -j8
-j8 will allow the make to run up to 8 simultaneous jobs
This part will take a long time so do not set and wait for it to finish

7. Now, Run,
make -j8 modules
sudo make modules_installmake zImage

8.  Rename the current zImage to zImage.prev and copy the new zImage to /boot

kernelversion=`cat ./include/config/kernel.release`
sudo cp /boot/zImage /boot/zImage.prev
sudo cp /boot/uInitrd /boot/uInitrd.prev
sudo cp arch/arm/boot/zImage /boot
sudo cp .config /boot/config-$kernelversion


I used the steps from this location
http://odroid.us/mediawiki/index.php?title=Kernel_compiling
http://forum.odroid.com/viewtopic.php?f=52&t=81

Make sure your time is set to the correct time:
Time-Date set and check
sudo timedatectl set-time "2013-08-14 14:52:00"
timedatectl status
timedatectl set-timezone America/New_York



Warning: you may need to install module-init-tools

Now, Adding more notes about Device Tree overlay:
Install  sudo pacman -S  dtc-overlay
I need to find out where to find the correct dtc files to compile on the Odroid-x2


New Board found:
http://www.variscite.com/products/system-on-module-som/cortex-a9/dart-4460-cpu-ti-omap-4-omap4460?gclid=CJbkwpP3_roCFdF_Qgod0kMAtw

http://armbedded.eu/node/318


resources:
https://github.com/hardkernel/linux
http://archlinuxarm.org/developers/building-kernels
https://wiki.archlinux.org/index.php/Kernel_Compilation#Compilation
http://odroid.us/mediawiki/index.php?title=Kernel_compiling

This is my link to ODROID Forum question:
http://forum.odroid.com/viewtopic.php?f=17&t=1085

Good Links to building kernel:
http://docs.kali.org/development/custom-odroid-kernel-image
https://wiki.archlinux.org/index.php/Kernels/Compilation/Traditional


http://www.egr.msu.edu/classes/ece480/capstone/fall12/group02/documents/Mark-Birdsall_App-Note.pdf



1 comment:

  1. Thank you very much for this extensive guide and especially quoting your sources! The documentation on the hardkernel site is rather sparse, therefore this is highly appreciated... Cheers from Auckland!

    ReplyDelete