Tuesday, September 30, 2014

ADB errors

1. ADB error: device not found

http://stackoverflow.com/questions/21408674/adb-error-device-not-found

2. ADB error: device offline
It is because of an old version of ADB (e.g., 1.0.29). It requires 1.0.31 or greater. 

http://stackoverflow.com/questions/10680417/error-device-offline



Thursday, September 25, 2014

Parameter passing inline gcc assembly error

This does not work: 

static void beep(unsigned short divisor)
{
    __asm__ volatile(
// set 8254 timer contol register to accept divisor
// IO port: 0x43
// 0xb6: 1011 0110
// channel2, access mode lo and hi, square wave
                "movb $0xb6, %%al\n"
                "out %%al, $0x43\n"

// load the divisor into ax
"mov %0, %%ax\n"

// set the low 8 bits of time2 counter
// IO port: 0x42
                "out %al, $0x42\n"

// set the high 8 bits of timer2 counter
// IO port: 0x42
                "movb %ah, %al\n"
                "out %al, $0x42\n"

// configure Speaker IO controller Port 0x61
// save the contents of 0x61
    "in $0x61, %al\n"
"movb %al, %ah\n"
// set bit 0, 1 to 1; enables the timer and NAND gate
                "or $0x3, %al\n"
                "out %al, $0x61\n"

// Run spin loop to delay
"mov $0x50E0, %cx\n"
"BEEP_DELAY: nop\n"
"nop\n"
"loop BEEP_DELAY\n"

// Trun off the speaker
"mov %ah, %al\n"
"out %al, $0x61"
:
:"r" (divisor)
   );
}

This works: 

static void beep(unsigned short divisor)
{
    __asm__ volatile(
// set 8254 timer contol register to accept divisor
// IO port: 0x43
// 0xb6: 1011 0110
// channel2, access mode lo and hi, square wave
                "movb $0xb6, %%al\n"
                "out %%al, $0x43\n"

// load the divisor into ax
"mov %0, %%ax"
:
:"r" (divisor)
   );

    __asm__ volatile(

// set the low 8 bits of time2 counter
// IO port: 0x42
                "out %al, $0x42\n"

// set the high 8 bits of timer2 counter
// IO port: 0x42
                "movb %ah, %al\n"
                "out %al, $0x42\n"

// configure Speaker IO controller Port 0x61
// save the contents of 0x61
    "in $0x61, %al\n"
"movb %al, %ah\n"
// set bit 0, 1 to 1; enables the timer and NAND gate
                "or $0x3, %al\n"
                "out %al, $0x61\n"

// Run spin loop to delay
"mov $0x50E0, %cx\n"
"BEEP_DELAY: nop\n"
"nop\n"
"loop BEEP_DELAY\n"

// Trun off the speaker
"mov %ah, %al\n"
"out %al, $0x61\n"
   );
}

Wednesday, September 24, 2014

PS2 Keyboard Info

http://www.computer-engineering.org/ps2keyboard/

http://wiki.osdev.org/PS/2_Keyboard

http://wiki.osdev.org/%228042%22_PS/2_Controller

Wednesday, September 17, 2014

How to install setuptools under a local python

Supposed you have a local python, which is used to built other staff. For example, buildozer will have this


src/.buildozer/android/platform/python-for-android/build/hostpython/Python-2.7.2

And this Python is missing setuptools for compiling, you need to install it under this Python. 

manual download the development version of setuptools from https://pypi.python.org/pypi/setuptools#downloads
move this setuptools into the Python directory
cd into the setuptools direcotry
find the executable for this python

run ../python.exe[where your python executable is] setup.py install

this will install setuptools under the local python. 

Note using easy_install setup tools only installs in your system not the local Python.  

Tuesday, July 22, 2014

Start network after boot on CentOS

You have two options, use the network-scripts or networkmanager

For myself, I want to use the network scripts. 
chkconfig NetworkManager off
chkconfig network on
Disable the NetworkManager and enable the old network

Then, you need to make sure you are setting up a correct network script at /etc/sysconfig/network-scripts/ifcfg-eth0

make sure ONBOOT=yes

Example of external network interface using DHCP:

$ vim /etc/sysconfig/network-scripts/ifcfg-em1
DEVICE=em1
HWADDR=00:26:B9:3E:33:A9
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=dhcp
DHCP_HOSTNAME=sr2s1
PEERDNS=yes

Example of internal network interface using static IP:

vim /etc/sysconfig/network-scripts/ifcfg-p1p1
DEVICE=p1p1
HWADDR=00:1B:21:44:8D:70
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.0.21
BROADCAST=192.168.0.255
NETMASK=255.255.255.0
NAME=p1p1


update an OpenVZ kernel to the latesr version on CentOS

yum update vzkernel

Update source.list on Ubuntu

http://askubuntu.com/questions/329450/e-some-index-files-failed-to-download-they-have-been-ignored-or-old-ones-used

  • How to solve this trouble in Ubuntu 12.04
Open a terminal (CTRL+ALT+T) and issue the following commands in order.
SOLUTION:
sudo cp /etc/apt/sources.list ~/ 
sudo wget "http://pastebin.com/raw.php?i=uzhrtg5M" -O /etc/apt/sources.list 
sudo apt-get update
sudo rm /etc/apt/sources.list.d/ubuntu-extras.list
sudo apt-get update
This solution is not general. It is specific to the sources.list file of the Original Poster.
The second command which starts with wget downloads and replaces the sources.list file with a specific for Precise (Ubuntu 12.04) sources.list file. See the file in raw format by visiting this page.
The fourth command removes the ubuntu-extras.list file which had an impact/conflict with another file of the same, so we removed it to avoid the error
W: Duplicate sources.list entry
see comments above.