Wednesday, 20th of August 2008
Wednesday, 20th of August 2008
"gumstix" — 12 posts
I bought two of these LCDs and the associated connectors from Electronics Goldmine. You can get one here.
For twenty bucks, I couldn't pass it up. Would have preferred to get something with a touchscreen interface, but this is a good size. The datasheet is here.

I followed much of the info on the wiki. Here is the pinouts and connection for my connex 400 (R687):

03 VCC
04
VCC
05
GND
06
GND
07
R0 (Red data input LSB)_________________ _ L_DD13 Pin 08/GPIO(71)
08 R1 (Red data input)_____________________ _ L_DD14 Pin 55/GPIO(72)
09 R2 (Red data input MSB)_________________ _ L_DD15 Pin 56/GPIO(73)
10 G0 (Green data input LSB)_______________ _ L_DD08 Pin 06/GPIO(66)
11 G1 (Green data input)_________________ _ _ L_DD09 Pin 02/GPIO(67)
12 G2 (Green data input MSB)___________ __ __ L_DD10 Pin 51/GPIO(68)
13 B0 (Blue data input LSB)___________ ____ _ L_DD02 Pin 13/GPIO(60)
14 B1 (Blue data input)______________________ L_DD03 Pin 04/GPIO(61)
15 B2 (Blue data input MSB)__________________ L_DD04 Pin 47/GPIO(62)
16 HSYNC (Horizontal Line Synchronization)-> LCLK Pin 16/GPIO(75)
17
VSYNC (Vertical Line Synchronization)--->FCLK Pin 41/GPIO(74)
18 S/D (Shut down)-------------------------> #STBY GP_81 Pin 21/GPIO(81) (NSSP_CLK)
19
MCK (Master Clock) --------------------->L_PCLK Pin 57/GPIO(76)
20
VCC______________________________________VDD_2
21
LED VDD (Backlight VDD)___________________________
22
LED GND (Backlight GND)__________________________

The connector has 0.5mm pins which i wasn't up for soldering wire-wrap up to directly, although other have. Instead I bought a little board from Schmartboard. It is the #202-0007-01, you can see the whole board here. I trimmed it down to what you see below:





































I connected up the board and connector according to the above chart and epoxied over the connector under the board.


I followed the wiki to setup the kernel and bootargs. Some of the options have changed in the kernel menuconfig. I have:
Device Drivers->Character devices->Virtual Terminal = Enabled
Device Drivers->Graphics support->Support for frame buffer devices = Enabled
Device Drivers->Graphics support->Enable Video Mode Handling Helpers = Enabled
Device Drivers->Graphics support->PXA LCD framebuffer support = Enabled
Device Drivers->Graphics support->PXA LCD command line parameters = Enabled
Device Drivers->Graphics support->Console display driver support->VGA text console = Disable
Device Drivers->Graphics support->Framebuffer Console support = Enabled

fbcon got compiled with the above. I chose Chris Diamond's ALPS driver. I first tried the "none of the above" options but then the bootargs didn't do anything. Chris said that it needs some settings, then you override them in bootargs. I haven't had time to look into setting up a menuconfig option for this screen yet.

I'm using the following bootargs:
GUM> setenv bootargs console = tty0 console=ttyS0,115200n8 root=1f01 rootfstype=jffs2 reboot=cold,hard 
video=pxafb:mode:240x160-16,active,hsynclen:7,right:16,left:6,upper:19,lower:19,vsynclen:2,hsync:1,vsync:1,pixclockpol:0,
pixclock:216363
GUM> saveenv
I connected it up to a bench powersupply and fired it up. I had a small solder bridge on two of the pins which caused some problems, but once I cleared that everything was fine. Above you can see a .pbm image blitted to the board.


to start the screen:
pxaregs GPSR2_81 1

Here are a couple of the escape commands for fbcon:
echo "Hello World!" > /dev/tty0 //text output
echo -ne '\033[0;0H' > /dev/tty0 //move cursor to 0,0
echo -ne '\033[?25l' > /dev/tty0 //turn off the cursor
echo -ne '\033[?25h' > /dev/tty0 //turn on the cursor

I powered the backlight (2 LEDs) and around 6-7v it seems brightest. This isn't a very bright LCD. White's are grey. As long as you are happy with that, then this is a pretty good, cheap LCD with a small form factor.





Today was not a good day...

I wanted to reflash with a new kernel enabled for the DS1307 real time clock. I compiled the new kernel and tried to transfer it via serial. For some reason, the transfer would not go through. It would just timeout. I tried several different things and the did something stupid -- I did the uboot commands to erase the flash. Since I couldn't transfer, I now had no bootloader, no FS and no kernel. Bricked. Yell

My gumstix is back to the company to get reflashed.

Lesson learned.

Of course, I still don't know why I couldn't transfer files via serial. I set the serial connection up like normal and had no problem talking to uboot. Hopefully it was just a random gremlin and won't come up again when I get the reflashed one back.
set carrier-watch off
set speed 115200
set file type bin
set reliable
fast
set flow-control none
set rec pack 4096
set send pack 4096
set window 5
set prefixing all
Dave Hyland wrote a great program to monitor GPIOs. It can launch a program with the pin # and edge.
More info on the wiki here.

To add a pin use something like this:

gpio-event 58:f:20

to remove the pin do:

gpio-event -- -58:f
Well, today decided I should upgrade u-boot and the filesystem -- wanted to make sure I could do it before I got too far with this project. Also wanted to make I had all the latest and greatest changes.

I tried to follow the instructions here, specifically the ones titles "Flashing over SSH/Ethernet." Turns out they kinda of worked. Everything went through without an error. The only problem was on the reboot, I got the following error:

U-Boot 1.2.0 (Aug 17 2007 - 14:29:48) - 400 MHZ -1508
*** Welcome to Gumstix ***

DRAM: 64 MB
Flash: 16 MB
Using default environment

SMC91C1111-0
Net: SMC91C1111-0
Hit any key to stop autoboot: 2 \0x08\0x08\0x08 1 \0x08\0x08\0x08 0
Instruction Cache is ON
Copying kernel to 0xa2000000 from 0x00f00000 (length 0x00100000)...done
## Booting image at a2000000 ...
Bad Magic Number
GUM>


Ouch. After a deep breath, I realized that it booted the new u-boot, so I now needed to follow the new instructions for verdex boards and gumstix after 1326 (where do you find out your damn version??). Anyways, I then did the following from ckermit:

GUM> loadb a2000000
kermit>send rootfs.arm_nofpu.jffs2
kermit>connect
## Ready for binary (kermit) download to 0xA2000000 at 115200 bps...
GUM>pro on 1:0-1 && jera all && cp.b a2000000 40000 ${filesize} -- NOTE: don't fill in the filesize, but leave it as "${filesize}" -- I tried and it doesn't work Wink
Protect Flash Sectors 0-1 in Bank # 1
.. done
Erase Flash Bank # 1 - Warning: 2 protected sectors will not be erased!
.............................................................................................................................. done
Copy to Flash... done
GUM> loadb a2000000
## Ready for binary (kermit) download to 0xA2000000 at 115200 bps...

kermit>send uImage
kermit>connect

GUM> katinstall 100000
Copying kernel from 0xa2000000 to 0x00f00000 (length 0x00100000)...Erasing...
........ done
Erased 8 sectors
Writing...done
GUM> katload 100000
Copying kernel to 0xa2000000 from 0x00f00000 (length 0x00100000)...done
GUM> bootm
## Booting image at a2000000 ...
Image Name: uImage
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 925092 Bytes = 903.4 kB
Load Address: a0008000
Entry Point: a0008000
OK

Starting kernel ...

U-Boot 1.2.0 (Aug 17 2007 - 14:29:48) - 400 MHz - 1508

*** Welcome to Gumstix ***

DRAM: 64 MB
Flash: 16 MB
Using default environment

SMC91C1111-0
Net: SMC91C1111-0
Hit any key to stop autoboot: 0
Instruction Cache is ON
Copying kernel to 0xa2000000 from 0x00f00000 (length 0x00100000)...done
## Booting image at a2000000 ...
Image Name: uImage
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 925092 Bytes = 903.4 kB
Load Address: a0008000
Entry Point: a0008000
OK

Starting kernel ...

Linux version 2.6.21gum (root@ubuntu) (gcc version 4.1.1) #1 PREEMPT Fri Aug 17 14:22:15 PDT 2007
CPU: XScale-PXA255 [69052d06] revision 6 (ARMv5TE), cr=0000397f
Machine: The Gumstix Platform
Memory policy: ECC disabled, Data cache writeback
Memory clock: 99.53MHz (*27)
Run Mode clock: 398.13MHz (*4)
Turbo Mode clock: 398.13MHz (*1.0, inactive)
CPU0: D VIVT undefined 5 cache
CPU0: I cache: 32768 bytes, associativity 32, 32 byte lines, 32 sets
CPU0: D cache: 32768 bytes, associativity 32, 32 byte lines, 32 sets
Built 1 zonelists. Total pages: 16256
Kernel command line: console=ttyS0,115200n8 root=1f01 rootfstype=jffs2 reboot=cold,hard
PID hash table entries: 256 (order: 8, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 62896KB available (1684K code, 161K data, 132K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
Time: pxa_timer clocksource has been installed.
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
JFFS2 version 2.2. (NAND) (SUMMARY) (C) 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler cfq registered (default)
pxa2xx-uart.0: ttyS0 at MMIO 0x40100000 (irq = 15) is a FFUART
pxa2xx-uart.1: ttyS1 at MMIO 0x40200000 (irq = 14) is a BTUART
pxa2xx-uart.2: ttyS2 at MMIO 0x40700000 (irq = 13) is a STUART
pxa2xx-uart.3: ttyS3 at MMIO 0x41600000 (irq = 0) is a HWUART
Probing Gumstix Flash ROM at physical address 0x00000000 (16-bit bankwidth)
Gumstix Flash ROM: Found 1 x16 devices at 0x0 in 16-bit bank
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
cfi_cmdset_0001: Erase suspend on write enabled
Using static partitions on Gumstix Flash ROM
Creating 3 MTD partitions on "Gumstix Flash ROM":
0x00000000-0x00040000 : "Bootloader"
0x00040000-0x00f00000 : "RootFS"
0x00f00000-0x01000000 : "Kernel"
TCP cubic registered
XScale DSP coprocessor detected.
VFS: Mounted root (jffs2 filesystem).
Freeing init memory: 132K
NET: Registered protocol family 1
smc91x: not found (-19).
CPLD responded with: c2
Initializing random number generator... done.
Starting Bluetooth subsystem:pccard: PCMCIA card inserted into slot 0
pcmcia: registering new device pcmcia0.0
cfio: module license 'unspecified' taints kernel.
pccard: PCMCIA card inserted into slot 1
pcmcia: registering new device pcmcia1.0
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
hcid.
Starting network...
hda: SanDisk SDCFB-192, CFA DISK drive
udhcpc (v0.9.9-pre) started
Dec 31 16:00:10 udhcpc[172]: udhcpc (v0.9.9-pre) started
m
Dec 31 16:00:10 udhcpc[172]: [truncated] m
Before register driver
ide0 at 0xc48a0000-0xc48a0007,0xc48a000e on irq 50
ide-cs: hda: Vpp = 0.0
Entering cf_attach()
pcmcia: request for exclusive IRQ could not be fulfilled.
pcmcia: the driver needs updating to supported shared IRQ lines.
BasePort1=0xc4880000, AssignedIRQ=49
After calling wlan_add_card function
After register driver
SCSI subsystem initialized
hda: max request size: 128KiB
hda: 375808 sectors (192 MB) w/1KiB Cache, CHS=734/16/32
hda: hda1
Starting Rendezvous:
Starting dropbear sshd: NET: Registered protocol family 10
Mobile IPv6
OK
Starting httpd...
Starting system message bus: done



Welcome to the Gumstix Linux Distribution!

gumstix login:

------------------------

Cool!
A couple of notes: I had to delete several suprious "-e"s in my modprobe.conf file and also in /etc/network/interfaces. Supposedly these are due to ubuntu symlinking /bin/sh to dash instead of bash. i deleted the symlink and remade it directly to bash instead and rebuilt -- all is good.

[root@gumstix init.d]# uname -a
Linux gumstix 2.6.21gum #1 PREEMPT Fri Aug 17 14:22:15 PDT 2007 armv5tel unknown

[root@gumstix init.d]# cat /etc/gumstix-release
DISTRIB_ID='gumstix'
DISTRIB_DESCRIPTION=''
DISTRIB_RELEASE='1511'
DISTRIB_CODENAME=''
BUILD_DATE='Mon Aug 20 15:40:21 PDT 2007'
BUILD_HOSTNAME='ubuntu'


Also, because the kernel is now loaded in a separate part of flash (I think) and the bootloader doesn't have to search for it, boot up times are much, much faster.
Wired up a toggle switch to the robostix in the following manner:


GPIO----------switch--------------GND
|
|------------10k resistor--------Vcc


I have the switch on port c.7 and set the direction to in.

Switch is open
# i2c-io 0x0b getdir c.7
in
# i2c-io 0x0b get c.7
0

Switch is closed
# i2c-io 0x0b get c.7
1
Dave Hylands has written a great little program to read GPIO and ADC pins on the robostix from the gumstix. There are several commands.

Info Retrieves information about the robostix program
Get port.pin Retrieves the value of a pin
Set port.pin val Sets the value of a pin
SetDir port.pin dir Sets the direction of a pin
ReadReg regIdx Reads an 8 bit register
WriteReg regIdx val Writes a value into an 8 bit register

If a GPIO pin is set for input:
1 : pullup resistor enabled
0 : pullup resistor disabled

if a GPIO pin is set for output:
1 : 5v
0: 0v

To turn on the blue LED on the robostix:
i2c-io 0x0b setdir g.3 out
i2c-io 0x0b set g.3 0


and to turn if off:
i2c-io 0x0b set g.3 1
I setup the MaxBotix MaxSonar-EZ1 today onto AD0. The only problem I had was reading the results. You set the dir using f.0 but you read adc.0 to get the information from the sensor.

for example:

i2c-io 0x0b get adc.0
to read the sensor's output

i2c-io 0x0b setdir f.0 in
to set the sensor for input

The sensor seems to read fine.

I'm taking the value and multiplying it a bit to get an output in inches:
round((($adc0*2.65/1024) * 100) * 2);

Here is the whole microperl script:
#!/usr/bin/microperl

# setup
$s = `/sbin/i2c-io 0x0b setdir f.0 in`;
$s = `/sbin/i2c-io 0x0b set f.0 off`;

while(1) {
$adc0 = `/sbin/i2c-io 0x0b get adc.0`;
#print "$adc0";
$dist = round((($adc0*2.65/1024) * 100) * 2);
print "$dist\n";
}

sub round {
my($number) = shift;
return int($number+.5);
}
Followed instructions on:
http://docswiki.gumstix.com/I2c

I used the precompiled sources.

You have to get the i2c bootloader working on the robostix first and this requires that you get an ISP or the gumstix ISP setup (see post). See this wiki entry.

the you can install i2c-Boot-m128-16MHz.hex
uisp --wr_fuse_l=0xbf --wr_fuse_h=0xc2 --wr_fuse_e=0xff (the fuses only need to be set once)
uisp --erase --upload if=i2c-Boot-m128-16MHz.hex

the red LED should start flashing if all went well.

You then need to get i2c-load setup on the gumstix. I downloaded a compiled version from here.
(which is the correct one for my version).

Worked like a charm. running the info command I get:
# ./i2c-load --reset 0x0b info
I2C Dev Addr: 0x0b
Version: 1
MinVersion: 1
Part Number: 0x9702 (ATMega128)
Reg Size: 256
RAM Size: 4096
EEPROM Size: 4096
Page Size: 256
Flash Size: 128k
Node Name: not set
Boot Delay: unset, defaults to 5 seconds
I2C Addr: unset, defaults to 0x0b


Now with i2c-load you can download programs to the robostix.
so i hosed the wifi with i stupid typo in /etc/network/interfaces....

i connected my Mac to the gumsix using a KeySpan USB->Serial connector.

used screen as the terminal program:
screen /dev/tty.KeySerial1 115200 cs8 ixoff

I have the console-st board, so it is setup to use the serial port closest to the power connector. The process is:
/sbin/getty -L ttyS0 115200 vt100

Then boot-up the gumstix and got the boot messages and a login prompt. yeah.
Some info at: http://docwiki.gumstix.org/Buildroot_on_MacOSX

I was installing on a OS X 1.4.9 dual G4 1.25Mhz

installed Subversion 1.4.3
installed wget-1.10.2 http://ftp.gnu.org/pub/gnu/wget/

then ran:
/usr/local/bin/svn co -r1161 http://svn.gumstix.com/gumstix-buildroot/branches/users/osx/trunk/ osx

-r tells the revision number for my gumstix board. found in /etc/gumstix-release on the board when it ships. mine says:
DISTRIB_ID='gumstix'
DISTRIB_DESCRIPTION=''
DISTRIB_RELEASE='1161'
DISTRIB_CODENAME=''
BUILD_DATE='Mon Nov 6 11:20:28 PST 2006'
BUILD_HOSTNAME='azazel.hughes-family.org'


cd osx
make defconfig
make

This took sometime as things downloaded and compiled. First to download is linux-2.6.15

uname -a
Linux gumstix 2.6.18gum #1 Mon Nov 6 11:18:37 PST 2006 armv5tel unknown

on the gumstix that I just received...few minor revs ahead.

If configure: error: C++ preprocessor "/lib/cpp" fails sanity check

  sudo mkdir /lib
sudo ln -s /usr/bin/cpp /lib/cpp

To change options on the build, just do:
  make menuconfig

Added an old CF I 192MB Sandisk card to the wifistix-CF. it shows up on boot:

Dec 31 16:01:09 gumstix user.warn kernel: hda: SanDisk SDCFB-192, CFA DISK drive
Dec 31 16:01:09 gumstix user.info kernel: Set (GPIO,out,clear) via /proc/gpio/GPIO7
Dec 31 16:01:09 gumstix user.info kernel: Set (GPIO,out,set) via /proc/gpio/GPIO7
Dec 31 16:01:09 gumstix user.warn kernel: ide0 at 0xc4880000-0xc4880007,0xc488000e on irq 50
Dec 31 16:01:09 gumstix user.info kernel: ide-cs: hda: Vpp = 0.0
Dec 31 16:01:09 gumstix user.info kernel: hda: max request size: 128KiB
Dec 31 16:01:09 gumstix user.info kernel: hda: 375808 sectors (192 MB) w/1KiB Cache, CHS=734/16/32
Dec 31 16:01:09 gumstix user.info kernel: hda: hda1

mount with /mnt/cf

it shows in /etc/fstab as:
/dev/hda1 /mnt/cf vfat sync,noauto 0 0
Finally got off my but and bought a gumstix computer. Bought the following:

1 x 5.0 volt power adapter  
1 x serial null-modem cable  
1 x console-st  
1 x gumstix connex 400xm  
1 x robostix  
1 x Screws & Spacers kit  
1 x wifistix-CF FCC

to start with. I was able to get the gumstix, wifistix and robostix put together into a little sandwich. Not so easy and afread to screw something up, but got it together.

I then got the wifi up and running. At first I couldn't get a connection, but then I remembered I had enabled MAC address filtering on my AP. Once I added the MAC address from the wifistix (printed on a little label on the chip), I got a connection to the AP which is running DHCP.

I was able to ssh as root@ using "gumstix" as the password. Cool.