Serial
From Ubicom Developer
Table of content
Contents |
S/W UART (TIO)
Adding the S/W UART package
The package ipUARTTIO needs to be added to the project configuration ultra7k_media.lpj. This can simply be done with the ConfigTool. To make sure that you have a working copy of the file ultra7k_media.lpj back up the file ultra/projects/mainexec/config/ultra7k_media.lpj to e.g. Your home directory.
1: On the command line from the root of the SDK run:
./ultra/tools/bin/win32/ConfigTool-Unix-wine.exe ultra/projects/mainexec/config/ultra7k_media.lpj
This will start the ConfigTool and loads the config file ultra7k_media.lpj
2: Select "Add Package..." from the "Package" menu. This will bring up the "Select Package" dialog window with the available packages. If "Add Package" is greyed out or you receive the message "Project is using 'dependency-only' mode", then follow the instructions here.
3: Scroll down to locate the package "ipUARTTIO - UART Virtual Peripheral"
4: Select the package "ipUARTTIO - UART Virtual Peripheral" and click the "Ok" button. The "ipUARTTIO - UART Virtual Peripheral" has now been added to the project and you should see it in the list.
5: Under ipUARTTIO change "Minimum HRT Slot Spacing" to "8".
6: Select "Save" from the File menu to save the changes. DO NOT CLICK any of the other buttons in the toolbar since this will cause misconfiguration of the project.
7: Select "Exit" from the file menu to close the ConfigTool.
Configuring the UART
The UARTTIO that you have just added can be activated and configured using the Kernel boot command line option. Below is a descriptions of the option.
uarttio=UARTTIO,(baud,txpin,rxpin,handshake,...)
"*pin" is the index of the pin, i.e. PA5 would be pin 5. The formula for calculating the ping is:
(port * 32) + pin
Port numbering starts at 0 for port A.
handshake should always be 0
For example to enable a UART with 57600 baud on the IAP board's expansion header J14 pin 5 and 7 which are connected to the IP7K pins PA5 and PA7 (aka RA5 and RA7), you should add the following to the Kernel command line:
uarttio=UARTTIO,57600,5,7,0
Below are the steps to add the ports configurations string to the Kernel command line.
Enabling the UART in the Linux configuration
1: In the root of the SDK type "make menuconfig".
2: In the main menuconfig check "[X] Regenerate ultra configs". This will force ultra to be reconfigured and build with the new configuration.
3: Also select "[X] Run distro menuconfig" and save/exit out of the menuconfig.
4: In the following distribution config menu under "Kernel/Library/Defaults Selection --->" select "[*] Customize Kernel Settings" and save/exit out of the menuconfig.
5: In the "Linux Kernel Configuration" Under "Processor type and features --->" add uarttio=UARTTIO,57600,5,7,0 to the "Built-in kernel command line" string. Your "Built-in kernel command line" can look something like the below:
console=ttyUM0 video=ubicom32vfb:vram_size=1024,xres=320,yres=240 uarttio=UARTTIO,57600,5,7,0
6: Navigate to "Device Drivers ---> Character devices ---> Serial drivers" and select "Ubicom UARTTIO support". Also select "Ubicom UARTTIO console support". Leave "Maximum number of UARTTIO virtual serial ports" to it's default setting.
It should look something like this:
<*> Ubicom UARTTIO support
(4) Maximum number of UARTTIO virtual serial ports
<*> Ubicom UARTTIO console support
6: Save and exit out of the kernel configuration.
When the kernel boots you should see something like the following. Important section are marked with >>>>:
[ 0.000000] Linux version 2.6.28.10 (rwessels@thor) (gcc version 4.4.1 20100127 (stable) (GCC) ) #69 Thu Mar 18 16:54:08 PDT 2010
.......
[ 0.000000] processor dram 40100000-48000000, expecting 40100000-48000000
[ 0.000000] IP7K Processor, Ubicom, Inc. <www.ubicom.com>
[ 0.000000] Device Tree:
>>>> [ 0.000000] 3fffb544: sendirq=255, recvirq=009, name=UARTTIO
[ 0.000000] 3fffbb40: sendirq=014, recvirq=013, name=audio
[ 0.000000] 3fffbfd0: sendirq=255, recvirq=255, name=board
.......
.......
[ 6.000000] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 6.250000] ttyUV0 at MMIO 0x40d9ae80 (irq = 9) is a UBI32_UARTTIO
>>>> [ 6.250000] Serial: Ubicom32 uarttio #0: tx:134 rx:128 baud:0
[ 6.250000] Serial: Ubicom32 uarttio started on thread:9 irq:9
The uart should now show up as /dev/ttyUV0 with major 206 and minor 64.
If it is not visible under /dev/ then you can create it by using: mknod /dev/ttyUV c 206 64 on the running target.
Or you can edit the file uClinux/vendors/Ubicom/InternetAudioPlayer/initramfs_list and add it there.
nod /dev/ttyUV 666 0 0 c 206 64
The serial port still needs to be configured to set it to your desired speed. This can easily be done with the command stty. To query the current settings of the device execute the following command.
/ # stty -F /dev/ttyUV0
The output of this command should look something like the below. Please refer to the stty man page for details on the output.
speed 9600 baud; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -brkint -imaxbel
To configure the serial port with e.g. baud-rate 57600, 8 data bits 1 stop bit and no parity, execute stty like below
/ # stty cs8 57600 -F /dev/ttyUV0
To test the serial port using a console use getty as follows.
/ # /bin/getty -nl /bin/sh 57600 /dev/ttyUV0
Since the output of the GPIO's is TTL, a line driver / reciever such as the MAX3222E is needed.
Troubleshooting
1. If you're receiving a dialog box saying the "Project is using 'dependency-only' mode", please follow the instructions below:
Disable DepsOnlyMode Control in the project file. Save and Exit. Re-open the .lpj file and add ipUARTTIO package.






