Read write registers and control GPIO's directly

About

From factory Carambola is shipped with ttyS0 disabled. Or to be more precise it is in GPIO mode. Which is sometimes not what we want. It is very easy to change this.

MMIO

In order to change internal Carambola registers you need small tool called io. You can install it when building the carambola distribution or later by running

opkg install io

If for some reason you get error installing io (for a while it was not on package repository, now it is fixed), download it compiled.

cd /usr/bin
wget http://www.8devices.com/files/mmio
chmod 777 ./mmio

Registers

Registers of interest: (System Control) 0x1000.0000 + (GPIO Purpose Select offset) 0x60

Read to test

Check what you have. 0x1D means you need to change it.

root@OpenWrt:/tmp# ./io 0x10000060
10000060:  1f

Change ttyS0 mode

One single command.

./io 0x10000060 0x01

inittab

Edit your /etc/inittab file to look like this:

root@OpenWrt:/# cat /etc/inittab 
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
#ttyS0::askfirst:/bin/ash --login  #<------------- comment this line to disable console on ttyS0
ttyS1::askfirst:/bin/ash --login

Future work

If you wish (and probably it is so) you need to run this command every time you start your Carambola. This can be done by altering /etc/rc.local file to something like:

io 0x10000060 0x01
exit 0

*Note: This is quick and dirty way to enable ttyS0.