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:

Monday, May 20, 2013

Interfacing to the PandaBoard GPIO, SPI, etc...


Here is my experience/adventure with PandaBoard trying to use its SPI, GPIO interfaces.
This is a work in progress so, I am documenting as I progress.

GPIO are found @
/sys/class/gpio
and then need to export as root...
#echo "50" > export
# echo "39" > export
# echo "38" > export
# echo "37" > export
# echo "out" >  gpio51/direction
# echo "out" >  gpio50/direction
# echo "out" >  gpio39/direction
# echo "out" >  gpio38/direction
# echo "out" >  gpio37/direction

# echo "1" > gpio38/value
# echo "0" > gpio38/value
# echo "1" > gpio38/value
# echo "0" > gpio38/value
# echo "1" > gpio38/value
# echo "1" > gpio37/value
# echo "0" > gpio37/value


To read from GPIO that is set as Input:
# cat /sys/class/gpio/gpio34/value

I will need to use 
chmod 666 /sys/class/gpio/gpio38/value
OR
Change the rc.local  

Now, How do I do this from C program:
This file will show in details how to do all the above from C program.
Note: You will have to run this program using sudo ./Test_IO_1 until I find how to create the GPIO on boot and make it accessible to all users
Makefile
Test_IO_1.c
I included the Makefile so you can compile the C program.  I compiled the code natively, which is on the Pandaboard itself.

  1. Make a folder, Test_IO_1
  2. Copy these two files to the new folder
  3. run make
  4. you should have Test_IO_1.0 and Test_IO_1
  5. type sudo ./Test_IO_1
  6. monitor GPIO38 with a scope, multimeter or a LED

Use this image or PandaBoard datasheet to find the correct pin for GPIO38

Open a file-socket to read or write from /sys/class/gpio/gpio38/value

To Read:
rewind(fp);
fread(&read_value, sizeof(char), 1, fp);

To Write:
rewind(fp);
fwrite(&set_value, sizeof(char), 1, fp);



OK, How to modify device read/write permission on boot:
I found this tile /etc/mtab
is this the one?


Also, I found SPI stuff @
/sys/class/spi_master
There is spi1, spi2, spi3, spi4







References:
http://lxr.free-electrons.com/source/Documentation/gpio.txt
http://www.haifux.org/lectures/258/gpio_spi_i2c_userspace.pdf


https://www.kernel.org/doc/Documentation/spi/spi-summary






http://www.youtube.com/watch?v=fuEB0VCkslQ
http://comments.gmane.org/gmane.comp.embedded.pandaboard/9743
http://lxr.free-electrons.com/source/drivers/input/keyboard/gpio_keys.c


http://lxr.free-electrons.com/source/arch/arm/mach-u300/spi.c?v=2.6.34
http://elinux.org/BeagleBoard/SPI

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


Wednesday, May 15, 2013

Run archlinux on PandaBoard Step by Step

Working on installing archlinux on my PandaBoard I found this site with great information,
Archlinux ARM


But, I had to do a lot of research to find more stuff I needed to actually follow these instructions.
So, I decided to document all that and add a little more to help others if they needed.  So, this is a work in progress and will be updated as I work and add to my PandaBoard.

I am running this process on Ubuntu 13.04...

You need to get these packages
PandaBoard Bootloader Tarball   will be extracted in the FAT partition
Root Filesystem Tarball                will be extracted in the ext3 partition

Use the script provided by archlinuxarm.org xmkcard.sh from the bootloader tarball to partition and format the SD Card.
You need to make the script file executable
chmod +x xmkcard.sh

Make sure you find out the name of the SD card in the dev folder
ls /dev/sd*
ls /dev/mmc*

and you can also use mount to see what name it has when it was mounted

Now you can run
sudo ./xmkcard.sh /dev/sd_name

You need to expand the two tarballs, downloaded above, one to the FAT and the other one to the ext3
Wait:
To extract the files you will need to use this command
tar -zxvf  filename.tar.gz

And you need to be root, not sudo as some files need to be created as part of the filesystem and you have to be root.

So, recent releases of Ubuntu come with root account disabled, to enable it
sudo passwd root
This will enable the root account and will ask you to set a password

and if you want to disable the root account

sudo passwd -l root

About creating boot.scr file:
This one you will need to have mkimage executable and I am still looking for it...
So, I found out that you need to install uboot-mkimage

sudo apt-get install uboot-mkimage

Now you should be able to create the boot.scr file use this command for reference
First, Create a file bootcmd  and add this to it
fatload mmc 0 0x80300000 uImage setenv bootargs console=ttyO2,115200n8 noinitrd init=/sbin/init root=/dev/mmcblk0p2 rootwait rw loglevel=8 bootm 80300000

Then type this command:
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "PandaBoard boot script" -d bootcmd boot.scr

And now, you should have the boot.scr file in the same folder of the bootcmd file, move it to the FAT partition.


Now, take your SD Card and plug it into the PandaBoard and power it up:
Make sure you connect a serial cable to the DB9 connector for output and you will see and be able to login via the terminal if you needed to, I will include a text file with a capture of all text output

PandaBoard_Debug_Out.txt


First thing you will need is to login,
username is : root
password is: root

If you need to change root password,
Type: passwd  after you login and you will be prompted to enter new password.
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

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. 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


Change hostname
Hostname is stored in the /etc/hostname file
type
sudo nano /etc/hostname
Then edit the name to the one you prefer, save and exit
Now, you will need to edit the hosts file in the same directory
sudo nano /etc/hosts
edit the like that starts with 127.0.0.1 localhost.localdomain localhost
and add your new hostname to the end
127.0.0.1 localhost.localdomain localhost New-Hostname

Install Xserver
sudo pacman -S xorg lxde xorg-twm xorg-xclock xterm xorg-xinit
> 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


List of items to add:
system update
network
keep boot messages on display



For reference:
Use e2label /dev/sdx1 label_name to change your partition label
Use mkfs.ext3 /dev/sdc2 to format ext3 your partion
to view your board IP address use ip add show

OK, for administration stuff:
these are files I will need to know what they do...
login.defs           login and account information
mtab
iftab                 something with network
fstab


Creating boot scripts:
/etc/profile.d/locale.sh   works, but permission denied!!!


References Used:
Archlinux ARM

http://elinux.org/ArchLinux_Install_Guide
https://wiki.archlinux.org/index.php/Beginners'_Guide


https://wiki.archlinux.org/index.php/LXDE

https://wiki.archlinux.org/index.php/Bluetooth
https://wiki.archlinux.org/index.php/Wireless_Setup


Friday, May 3, 2013

How to Auto scroll TextView Android Java

I listed how to auto-scroll text containers in C# while ago, and now that I am developing other applications for Android, I needed to do the same for the following:

TextView:
Rx_text is a TextView Container.  and O_Text is a variable of type String


Rx_text.append(O_Text);
Rx_text_scroll_view.scrollTo(0, Rx_text.getBottom());


Thursday, May 2, 2013

How to Auto scroll TextBox, ListBox, ListView C# C-Sharp


Programming In C# with Visual Studio


Sometimes you need to add this little trick in your code to ease using it. this trick is to force the TextBox, ListBox, ListView, or DataGridView to scroll down to the last item was entered.


Here are some info on how to do an Auto-scroll for your program controls

TextBox auto-scroll

textBox1.SelectionStart = textBox1.Text.Length;
textBox1.ScrollToCaret();

ListBox auto-scroll

listBox1.SelectedIndex = listBox1.Items.Count - 1;
listBox1.SelectedIndex = -1;

ListView auto-scroll

listView1.EnsureVisible(listView1.Items.Count - 1);TreeView autoscroll
treeView1.Nodes[treeView1.Nodes.Count - 1].EnsureVisible();

DataGridView auto-scroll

dataGridView1.FirstDisplayedCell =
dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0];