Saturday, September 14, 2013

Beaglebone Black angstrom

Status Update:
This is a list of working Not working items, so you do not get disappointed after reading the post.  This is  a work in progress...

Angstrom:
GPIO
ADC
I2C1
SPI almost, having some issues with CLK, and Data input output.

ArchLinux:
:-(



First Using angstrom distribution:
opkg is the app-get for angstrom....

Linux beaglebone 3.8.11 #1 SMP Wed May 8 07:34:27 CEST 2013 armv7l GNU/Linux

after opkg update, opkg upgrade
Linux beaglebone 3.8.13 #1 SMP Thu Sep 5 16:35:35 CEST 2013 armv7l GNU/Linux


Install Sudo
opkg install sudo

Network settings:
This post here is great source for setting Static IP
http://derekmolloy.ie/set-ip-address-to-be-static-on-the-beaglebone-black/

add user:
su
useradd xyz-user
passwd xyz-user

Update Time and Time Zone:
rm /etc/localtime
ln  /usr/share/zoneinfo/EST /etc/localtime
/usr/bin/ntpdate-sync 
nano default/ntpdate     to set / enable sync server
date             to check your new time


Using GPIO:
#echo 44 > /sys/class/gpio/export

Reference:
http://www.phys-x.org/rbots/index.php?option=com_content&view=article&id=104:lesson-1-beaglebone-black-blink-led&catid=46:beaglebone-black&Itemid=81
http://www.auctoris.co.uk/2012/08/23/gpio-with-sysfs-on-raspberry-pi-part-2/


Using the I2C:
i2cdetect -y -r 1
root@beaglebone:~# i2cdetect -y -r 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --   

i2cdump -y 1 0x50 w     or
i2cdump -y 1 0x50 b

Link....
http://minix-i2c.blogspot.com/2013/07/using-i2c-tools-with-angstrom-linux-on.html



Using the SPI:
I found the required files in /lib/firmware/ BB-SPIDEV*
all I did finally, is echo this line

root@beaglebone:/lib/firmware# echo BB-SPIDEV0 >  /sys/devices/bone_capemgr.9/slots

Then ls /dev/spi* and here is what I got...

Now what is next? the question is what is really here that works?



Using Analog Inputs:


sh-4.2# echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots
sh-4.2# find /sys/ -name '*AIN*'
/sys/devices/ocp.2/helper.14/AIN0
/sys/devices/ocp.2/helper.14/AIN1
/sys/devices/ocp.2/helper.14/AIN2
/sys/devices/ocp.2/helper.14/AIN3
/sys/devices/ocp.2/helper.14/AIN4
/sys/devices/ocp.2/helper.14/AIN5
/sys/devices/ocp.2/helper.14/AIN6
/sys/devices/ocp.2/helper.14/AIN7
sh-4.2# cat /sys/devices/ocp.2/helper.14/AIN1
OR  
sh-4.2# cat /sys/devices/ocp.2/helper.14/AIN*



References:
http://www.gigamegablog.com/2012/01/29/beaglebone-linux-101-configuring-angstrom-linux/
http://beaglebone.cameon.net/home/reading-the-analog-inputs-adc
http://www.gigamegablog.com/2012/01/22/beaglebone-coding-101-using-the-serial-and-analog-pins/


BeagleBone Black Updating the Software
Getting Started with BeagleBone Black
============================================================
Now, I am trying arch Linux to see if it works better:

http://archlinuxarm.org/platforms/armv7/ti/beaglebone-black


Steps I used:

  1. pacman -Syu
  2. passwd
  3. pacman -S sudo adduser gcc make
  4. adduser username
  5. EDITOR=nano visudo
  6. copy my files




To Setup eth0 configuration Static:
systemctl disable netctl-ifplugd@eth0
cp /etc/netctl/examples/ethernet-static /etc/netctl/ethernet-static
nano /etc/netctl/ethernet-static #edit to you liking
Use /24 for  255.255.255.0
Use /16 for 255.255.0.0
netctl enable ethernet-static
reboot.







References:
http://hipstercircuits.com/enable-spi-1-0-and-1-1-with-device-tre-overlays-on-beaglebone/




References & Commands:
How to auto mount drive at boot...            /etc/fstab   http://www-rohan.sdsu.edu/doc/debian/ch-disks.html
Debian Tutorial http://www-rohan.sdsu.edu/doc/debian/



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



Run Android Jelly Beans on ODROID-X2 Step by Step

After all the problem getting SPI working on the ODROID-X2 Board, I decided to visit the Android world and see what it takes to put it on the ODROID-X2 Board.  And I was so amazed how easy it is...





Android 4.1 Beats-1.6:
http://com.odroid.com/sigong/nf_file_board/nfile_board_view.php?keyword=&tag=ODROID-X2&bid=182

Android 4.1 Beats-1.8 update:
http://com.odroid.com/sigong/nf_file_board/nfile_board_view.php?keyword=&tag=ODROID-X2&bid=192

How to install the update:



Google Apps:
http://goo.im/gapps/gapps-jb-20121011-signed.zip




Building Android Kernel:
http://forum.xda-developers.com/showthread.php?p=38144723

Open source from Samsun:
http://opensource.samsung.com/

Reference to building the Android ODROID-X2 kernel
https://github.com/leekyuhyuk/Odroid-X2-Android-OS-4.1-Kernel
check the readme , build.sh

Reference to Tool Chain download:
http://dev.odroid.com/projects/4412boot/#s-10.1
https://sourcery.mentor.com/GNUToolchain/release1294?lite=arm&cmpid=7108&downloadlite=scblite2012&signature=4-1377441150-0-1ca6798bb3b7e362eb68e47b2522d2d75e2f1f79

Install 32bit libraries on 64bit Linux:
install ia32-libs


Main Source Tree for Hard-Kernel:
http://dn.odroid.com/



Great News/Progress:
After re-building the kernel, and it was finished I found the following:

LD [M]  drivers/spi/spidev.ko
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready

So, I know now there are some module I need to load/copy with the kernel
I used the following line to copy my new Android Kernel to the board.
busybox dd conv=notrunc seek=1256960 bs=1 if=/tmp/zImage of=/dev/block/mmcblk0

I built it with built-in instead and now I see spidev in the /sys/class/sysdev and in the sys/modules/spidev  but I am not sure yet how it can be used? or is it working

I need a different option to add spi_master

Sunday, August 4, 2013

Micro SD Cards Failing within a year of their use

Micro SD Cards are very popular little storage that are on every  phone or media device now.  We store our precious pictures, music, documents , and all types of files.  But, can we really really really trust it?

On my current  cell phone, Samsung Galaxy Note, I had 32GB SanDisk Ultra class 10.  I bought it from Best-buy, so it is not off a XYZ on eBay somewhere in the unknown world.  This Micro SD failed within three months and I had so many pictures and other files on it, I can not really list them.  What happened I am not sure!  I tried everything to recover it or even format it and see if I can reuse it, but, sadly nothing worked with this card.

Today, I just noticed a sd card simple on my other cell phone, Samsung infuse, which had a PNY 16GB class 10 Micro SD card for a while, I think over 6 months, it also failed miserably  and I could not recover anything on it or even format it!!  Now what is going on with these SD cards?  Is it just me or is it PNY brand or what is going on?

I use these cards on a lot of my devices and specially my embedded development systems and I really hate to start distrust these things because I will become very paranoid with all my equipment!!!

Does anyone out there have any opinion or experience with these SD card in general and you want to share your experience?  please, add to this post...

Friday, July 26, 2013

Run arch linux on ODROID-X2 Step by Step

Get the image from Home

http://archlinuxarm.org/platforms/armv7/samsung/odroid-x2

To write the image to your SD card use the following command line
dd if=ArchLinuxARM-2013.07-odroid-x2.img  of=/dev/sdxxxx  bs=10M
Make sure /dev/sdxxxx is the correct dev for your SD card
Make sure to umount your SD card first...
Once dd is done writing the image to SD card use sync to flush any buffers


login using id and password  root/root
you will have to login first time using serial terminal or SSH.

If you can not find the IP address for the ODROID board, then you might want to setup static IP address;
  1. cd /etc/network.d   then type ls , you should see ethernet-eth0
  2. edit the file ethernet-eth0 using  sudo nano ethernet-eth0
  3. comment the dhcp configuration 
  4. un-comment and enter your correct ip address that you want to set and your dhcp address
  5. save and insert the sd card in your board and ping that address
  6. you should get echo back after 10-15 seconds
  7. for some reason it does not pickup the static by it self, I had to use netcfg-daemon start
Copy of my ethernet-eth0
## Change for static
CONNECTION='ethernet'
DESCRIPTION='A basic static ethernet connection using iproute'
INTERFACE='eth0'
IP='static'
ADDR='172.16.71.239'
NETMASK='255.255.0.0'
##ROUTES=('192.168.0.0/24 via 192.168.1.2')
GATEWAY='172.16.1.45'
DNS=('172.16.1225' '172.16.1.233')


OK, this time with "Linux alarm 3.8.13.12-2-ARCH #2 SMP PREEMPT Tue Nov 12 20:41:34 CST 2013 armv7l GNU/Linux" I had to go to /etc/netcfg/ and edit eth0  

escription='A basic static ethernet connection'
Interface=eth0
Connection=ethernet
IP=static
Address=('192.168.71.239/24')
#Routes=('192.168.0.0/24 via 192.168.1.2')
Gateway='192.168.1.1'
DNS=('192.168.1.1' '192.168.1.2')



If you need to change root password,
Type: passwd  after you login and you will be prompted to enter new password.



How to update System in archlinux
We use pacman to install/update the system packages
So, type pacman-key --init to create pacman key first
you might need to switch to another console and type
ls -R / && ls -R / && ls -R /
now, when it is done, type pacman -Syu to update the system
It will take some time and will download and update your system
To add/install packages use pacman -S package_name


How to add your username to suders
Install sudo, modify visudo

  1. Install adduser by using pacman -S adduser
  2. Install sudo to be able to use root privilege
  3. Type  adduser username

and follow/answer all questions, set defaults, set password...
Now we need to edit the visudo to allow new user to use the sudo command
Type
EDITOR=nano visudo
Edit/ uncomment the following line
# %sudo ALL=(ALL) ALL  ==>>   %sudo ALL=(ALL) ALL
save and then create sudo group
groupadd sudo
now add sudo group to your user name
usermod -a -G sudo username
reboot and test your sudo access.  you will need to logout and login again...

Getting the WiFi setup
Setting the WiFi I had to install wicd
sudo pacman -Su wicd
then I got to run ip add show  to see list of your network device eth0, lo, wlan0
I have WEP security so, I run
sudo iwconfig wlan0 essid "your essid here" key your_hex_Keysudo dhcpcd wlan0
Now, if you have different settings like WEP, WPA, WPA2,..  refer to the link here

So, I started investigating netcfg
it works with the profiles saved in /etc/network.d
and by default it has one profile for the ethernet-eth0
so, I copied wireless-wep from the examples folder
updated the parameters in wireless-wep to my wireless network and
type: sudo netcfg wireless-wep -u

Two things:
  1. my key is stored in the profile file in text --- not good
  2. it still does not start on boot .....
I found netcfg-menu that needs dialog..
The netcfg-menu will make it simple to start specific profile as long as you created a profile for it as I have above. but still no auto-start on boot!

What is the /etc/conf.d/netcfg ???
I did it..  in the netcfg file there is a line called NETWORKS that is by default is like this...
NETWORKS=(ethernet-eth0)
So, I added my second profile just like this
NETWORKS=(ethernet-eth0 wireless-wep)
and now, both network profiles are up and running on boot....
Now, I needed to install wicd-gtk to work on the GUI



How to get your HDMI Working:
To be able to login from Arch Linux on a monitor instead of serial port of SSH you need
pacman -Su linux-odroid-x2

Trying to install:
sudo pacman -S xorg-server lxde xf86-video-fbdev
you can add xorg-apps but it is not required
sudo pacman -S xorg lxde xorg-twm xorg-xclock xterm xorg-xinit
All this so far did not get me to boot from the HDMI monitor...??????
After installing an image for Ubuntu 13.04 I got the board to run on HDMI interface and I logged in.  so it is not a hardware issue, it is a configuration.

> create file ~/.xinitrc in your home directory and add this line to it
exec startlxde
> there was an error not finding a cache file and I had to create it manually
OK, the file name was cookie and this is what I did
cd .config/pulse
echo > cookie
The echo command created a file cookie then I had to use nano and add the line I mentioned above
Now you should be able to use startx and get your LXDE desktop

Had to install fbset and run sudo fbset -fb /dev/fb1
Edited /etc/X11/xorg.conf

Section "Device"
        Identifier "HDMI"
        Driver  "fbdev"
        Option  "fbdev"           "/dev/fb1"
EndSection
Section "Screen"
        Identifier   "Default Screen"
        Device       "HDMI"
        DefaultDepth 24
EndSection
Section "DRI"
        Mode 0666
EndSection

after I added these settings to xorg.conf file it worked and I logged to LXDE finally....


To be able to forward X11 windows I had to do:
I am not sure yet which one did the trick but I will have to do this again on my other board...

  • Enable the AllowTcpForwarding option in sshd_config on the server.
  • Enable the X11Forwarding option in sshd_config on the server.
  • Set the X11DisplayOffset option in sshd_config on the server to 10.
  • Enable the X11UseLocalhost option in sshd_config on the server.
Also:
  • Enable the ForwardX11 option in ssh_config on the client.
  • Enable the ForwardX11Trusted if gui is drawing badly.
You need to restart the ssh daemon on the server for these changes to take effect, of course.
To use the forwarding, log on to your server through ssh:


Time-Date set and check
sudo timedatectl set-time "2013-08-14 14:52:00"
timedatectl status
timedatectl set-timezone America/New_York



Scratch Pad:
Do not use this method use adduser better
If you need to add new user so you do not login with the root
Type:     useradd user_name
Then change password:  passwd user_name
where user_name is the new user name you want to create

You will need to install sudo to be able to use root privilege with your new user id





Commands you might need:
Check CPU usage    top
Check SD usage       df  -h
systemctl start sshd
systemctl enable sshd.service
systemctl restart sshd.service



List to Do:
sudo root access
WiFi
HDMI
GPIO
SPI
Bluetooth
ssh -X ip-address




References:
https://wiki.archlinux.org/index.php/Wireless_Setup
https://wiki.archlinux.org/index.php/Bluetooth
https://wiki.archlinux.org/index.php/Ssh#X11_Forwarding
https://wiki.archlinux.org/index.php/Running_X_apps_as_root  Running X apps as root



list of stuff I did on new ArchLinuxARM-2013.11:

  1. login as root/root
  2. pacman -Syu
  3. pacman -S sudo adduser
  4. adduser username
  5. EDITOR=nano visudo
  6. Created new sudo group and added to new username
  7. Log in with new username
  8. Tested new username sudo
  9. If you do too much sudo, you can use sudo -s
  10. I kept the IP to DHCP, and on my second board, I changed it to Static
  11. change IP to static follow steps above...
  12. trying to install lxde
  13. sudo pacman -S xorg lxde xorg-twm xorg-xclock xterm xorg-xinit
  14. created .xinitrc and added exec startlxde
  15. Added pulse folder in .config and then created empty cookie file
  16. Install fbset then run sudo fbset -fb /dev/fb1
  17. created file /etc/X11/xorg.conf then copied the data above to it





Saturday, July 6, 2013

How to get Ubuntu to play Amazon instant Movies

I finally got to try Amazon Prime membership and started to use the futures including free shipping on some of the items listed, and play the instant movies that will work only on some of the Operator Systems.

What a disappointment, it does not work on all the Android devices that I have, however, it works on
Amazon Kindle!!!  I thought that that runs a version of Android too, so why not the rest of Android devices?

I found a fix on here though...
you will need to download the Free flash player APK from here


Now, my Ubuntu can not stream these movies, Why?
Here is fix:

sudo mkdir /etc/hal/fdi/preprobe

sudo mkdir /etc/hal/fdi/information

/usr/sbin/hald --daemon=yes --verbose=yes

rm -rf ~/.adobe



References:
http://askubuntu.com/questions/286297/is-there-a-work-around-to-get-protected-hulu-or-amazon-prime-instant-videos-work

http://forum.xda-developers.com/showthread.php?t=1774336

Monday, July 1, 2013

How tos in MS Windows to develop your application peacefully

I wanted to capture all the tools and tricks that I was able to find after a long research and reading.  This way I can come back here and reuse it or someone else can find it.

Command Line Commands that solved my problems:

To Enable Remote Desktop:
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f

To Disable Remote Desktop:
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 1 /f


Task List / Kill:
taskkill -pid 4104
taskkill -im iexplore.exe
tasklist -m
tasklist -svc





Some references: