UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer pullanlu
Observer
14,730 Views
Registered: ‎04-21-2012

Use UARTLITE for Zynq-based Systems

We added a few UARTLITE devices to a custom board based on Zynq.

The board is running Linux 3.0 from the branch xilinx-14.1-build3-trd.

The device tree was updated to include those UARTLITE devices.

Rebooting the board there is no /dev/ttyULx created.

 

So I tried to reconfigure the Linux with "make menuconfig" and found no entry for UARTLITE.

 

Looking at the serial/Kconfig and found the UARTLITE as below:

 

config SERIAL_UARTLITE

    tristate "Xilinx uartlite serial port support"
    depends on PPC32 || MICROBLAZE || MFD_TIMBERDALE
    select SERIAL_CORE
    help
      Say Y here if you want to use the Xilinx uartlite serial controller.

      To compile this driver as a module, choose M here: the
      module will be called uartlite.

I commented out the line "depends on PPC32 || MICROBLAZE || MFD_TIMBERDALE" to make the UARTLITE available in "make menuconfig". Select UARTLITE and recompile the linux to find the following errors:

 

scripts/kconfig/mconf Kconfig
#
# configuration written to .config
#


*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

plu@ubuntu:~/proj/gcv/src/linux-xlnx$ less .config
plu@ubuntu:~/proj/gcv/src/linux-xlnx$ make ARCH=arm
scripts/kconfig/conf --silentoldconfig Kconfig
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      init/version.o
  LD      init/built-in.o
  CC      kernel/module.o
  GZIP    kernel/config_data.gz
  IKCFG   kernel/config_data.h
  CC      kernel/configs.o
  LD      kernel/built-in.o
  CC      drivers/tty/serial/amba-pl010.o
  CC      drivers/tty/serial/amba-pl011.o
  CC      drivers/tty/serial/uartlite.o
drivers/tty/serial/uartlite.c: In function 'ulite_receive':
drivers/tty/serial/uartlite.c:79:3: error: implicit declaration of function 'ioread32be' [-Werror=implicit-function-declaration]
drivers/tty/serial/uartlite.c: In function 'ulite_transmit':
drivers/tty/serial/uartlite.c:124:3: error: implicit declaration of function 'iowrite32be' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

make[3]: *** [drivers/tty/serial/uartlite.o] Error 1
make[2]: *** [drivers/tty/serial] Error 2
make[1]: *** [drivers/tty] Error 2
make: *** [drivers] Error 2
plu@ubuntu:~/proj/gcv/src/linux-xlnx$ git branches
git: 'branches' is not a git command. See 'git --help'.
plu@ubuntu:~/proj/gcv/src/linux-xlnx$ git branch
  master
* xilinx-14.1-build3-trd

 

HOW TO ENABLE THE UARTLITE DRIVER?

 

Thanks

0 Kudos
29 Replies
Voyager
Voyager
14,714 Views
Registered: ‎05-09-2008

Re: Use UARTLITE for Zynq-based Systems

Hi pullanlu,

 

you must change all "'ioread32be" and "iowrite32be" on "drivers/tty/serial/uartlite.c"

 

#define xuartlite_readl(offset)           ioread32(offset)
#define xuartlite_writel(val, offset)    iowrite32(val, offset)

 

but from my tests the serial does not work anyway.

 

On the "PL" section of Zync the Kernel drivers it is still quite immature.

 

Same problem with I2C and others device.

 

secureasm

 

0 Kudos
Highlighted
Observer pullanlu
Observer
14,685 Views
Registered: ‎04-21-2012

Re: Use UARTLITE for Zynq-based Systems

Hi secureasm,

 

With the changes you described, I was able to compile the uartdriver and see the device modes /dev/ttyULx created.

As you said, the serial interface did not work quite right.

 

We were able to see tx/rx and interrupt lines toggling when accessing the interface. However, the /proc/interrupts does not show increment of corresponding interrupt; and noting was seen from the 'microcom' output.

 

Has anyone successfully added a UARTLITE to Zynq PL?

 

Thanks

 

Pullan

0 Kudos
Voyager
Voyager
14,681 Views
Registered: ‎05-09-2008

Re: Use UARTLITE for Zynq-based Systems

Hi,

 

> Has anyone successfully added a UARTLITE to Zynq PL?

 

No, I tried in many ways but without success, the same applies for I2C and other peripherals.

 

I think this part is still "immature", I hope to be proven wrong ...

 

secureasm

0 Kudos
Newbie jmumper
Newbie
14,612 Views
Registered: ‎01-22-2013

Re: Use UARTLITE for Zynq-based Systems

Has anyone successfully added a UARTLITE to Zynq PL?

 

Yes,

It took some configuring of uartlite.c.

 

In ulite_startup(...), change the request_irq flags to:

 

ret = request_irq(port->irq, ulite_isr, IRQF_TRIGGER_RISING, "uartlite", port);

 

Also, add the axi-uartlite driver to __devinitdata :

 

static struct of_device_id ulite_of_match[] __devinitdata = {
{ .compatible = "xlnx,opb-uartlite-1.00.b", },
{ .compatible = "xlnx,xps-uartlite-1.00.a", },
{ .compatible = "xlnx,axi-uartlite-1.02.a", },
{}
};

 

This is what my device tree instantiation looks like:

 

serial@80000000 {
compatible = "xlnx,axi-uartlite-1.02.a";
reg = <0x80000000 0x1000>;
interrupts = < 0 54 4 >;
interrupt-parent = <&gic>;
clock = <50000000>;
};

 

Of course you'll have to change the interrupt, clock, and reg parameters to match your implementation.

 

I have attached my copy of uartlite.c for reference.

 

Jimmy

Explorer
Explorer
13,310 Views
Registered: ‎06-23-2013

Re: Use UARTLITE for Zynq-based Systems

  It looks like Jimmy's very helpful changes are not yet in linux-xlnx/drivers/tty/serial/uartlite.c


Has anybody got a test application for uartlite to share ?

dogbytes
0 Kudos
Explorer
Explorer
13,267 Views
Registered: ‎06-23-2013

Re: Use UARTLITE for Zynq-based Systems

Got a test application but had to step back, no longer boots to login prompt,

with uartlite entries in the devicetree and xilinx_zynq_defconfig

CONFIG_SERIAL_UARTLITE=y

 

Bitfile was included in the boot.bif -> boot.bin

 

Hangs after,

uartlite 50000000.uartlite: failed to get alias id, errno -19
uartlite 50000000.uartlite: failed to get port-number

 

jimmy's uartlite.c got compile errors so we are using,

git log uartlite.c | more
commit 068160c0befae2e4d1cd98f781161424683339e9
Merge: 2530265 19f949f
Author: Michal Simek <michal.simek@xilinx.com>
Date:   Fri Mar 15 18:39:09 2013 +0100

Planning to add in,    { .compatible = "xlnx,axi-uartlite-1.02.a", },

 

 

dogbytes
0 Kudos
Explorer
Explorer
13,257 Views
Registered: ‎06-23-2013

How to build uartlite.ko ? Re: Use UARTLITE for Zynq-based Systems

If CONFIG_SERIAL_UARTLITE=y

then getting the ulite_probe errors of previous post, so trying to build uartlite.ko as a loadable module

Although drivers/tty/serial/uartlite.o is built, no uartlite.ko is found in linux-xlnx/lib/modules subtree.

What am I missing to build uartlite.ko ?

 

The .config has,

 

CONFIG_MODULES=y


#CONFIG_MODULE_FORCE_LOAD is not set dy20131216 make uartlite.ko
CONFIG_MODULE_FORCE_LOAD=y

CONFIG_SERIAL_UARTLITE=m

 

Our Ubuntu kernel was based on  3.8.0-xilinx-00015-gabc285b for a zc706 based custom board.

dogbytes
0 Kudos
Explorer
Explorer
13,251 Views
Registered: ‎06-23-2013

make ARCH=$ARCH modules Re: How to build uartlite.ko ? Re: Use UARTLITE for Zynq-based Systems

make ARCH=$ARCH modules

 

produced

  LD [M]  drivers/tty/serial/uartlite.ko

Alright then, (insmod, test, code, build) repeat.

Anybody have any tips about uartlite.c for Zynq ?

dogbytes
0 Kudos
Explorer
Explorer
13,225 Views
Registered: ‎06-23-2013

echo "ttyUL0hello" > /dev/ttyUL0 Re: make ARCH=$ARCH modules Re: How to build uartlite.ko ? Re: Use UARTLITE for Zynq-based Systems

Ah, this worked,

echo "ttyUL0hello" > /dev/ttyUL0

dogbytes
0 Kudos
Explorer
Explorer
10,273 Views
Registered: ‎06-23-2013

ttyUL1 flawed Re: echo "ttyUL0hello" > /dev/ttyUL0 Re: make ARCH=$ARCH modules Re: How to build uartlite.ko ? Re: Use UARTLITE for Zynq-based Systems

Curiously although /dev/ttyUL0 is okay, /dev/ttyUL1 drops characters.  Console /dev/ttyPS0 is fine on zc706 based board.

 

Full post at the following:

 

http://forums.xilinx.com/t5/Embedded-Processor-System-Design/Weird-problem-with-getchar-and-UARTLite-extral-NUL-after-each/td-p/170156

dogbytes
0 Kudos
Scholar vanmierlo
Scholar
10,184 Views
Registered: ‎06-10-2008

Re: Use UARTLITE for Zynq-based Systems

Jimmy,

 

Thanks for the modified uartlite.c file. It didn't quite work out of the box for the current xilinx linux kernel (3.9), but with some modifications it started to work. I had to replace the tty_struct with tty_port and for irq sharing I had to add IRQF_SHARED. Further I had to remove __devinit/__devexit/__devinitdata.

 

I have attached the modified file. Don't forget to enable the uartlite driver in the kernel configuration as it is off by default.

 

Maarten

0 Kudos
Newbie lgzhust
Newbie
10,043 Views
Registered: ‎03-23-2014

Re: Use UARTLITE for Zynq-based Systems

after I do as what you said ,I have found the ttyUL0 in the /dev,and I can also send something out by write the fp=/dev/ttyUL0,but when I read by the fp ,I can receive nothing by the ttyUL0, I don't know why ,can you help me? can you give me  a test code demo for the uartlite driver ? Thank you very much!

0 Kudos
Explorer
Explorer
9,994 Views
Registered: ‎06-23-2013

Re: Use UARTLITE for Zynq-based Systems

Here's an answer for lgzhust: here is some code that read 7 bytes from /dev/ttyUL0

 

Our Zynq PL has /dev/ttyUL0 implemented.  On the ARM side, using Ubuntu 12.10 driver uartlite.c

Yes, I've read from /dev/ttyUL0 and printed the 7 bytes showing the hex values, to our log file.

 

#define CAMUL_RVERLEN 7

 

        fdcamtty = open(devname, O_RDWR | O_NOCTTY);

 

               // parameter passed in: unsigned char *rdata

 

                nb = read( fdcamtty, rdata, CAMUL_RVERLEN);
                pbLog("cam_rcmd: read nb=%d\t", nb);
                for (ic = 0; ic < na; ic++) {
                        pbLog("0x%.2x ", rdata[ic]);
                }
                pbLog("\n");

dogbytes
0 Kudos
Explorer
Explorer
9,993 Views
Registered: ‎06-23-2013

Re: Use UARTLITE for Zynq-based Systems

Using Ubuntu 12.10 on zc706 custom board:

The last git commit for uartlite.c was in March 2013 and the driver references OPB Uartlite.

But there is LogiCORE IP AXI UART Lite (v1.02a)

Can anybody speak to whether these are compatible, and does uartlite.c need updating ?

 

The reason is that some unreliability in reading /dev/ttyUL0 has occurred.

Also any tips in debugging it would be appreciated.

 

dogbytes
0 Kudos
Scholar vanmierlo
Scholar
9,982 Views
Registered: ‎06-10-2008

Re: Use UARTLITE for Zynq-based Systems

Well there isn't really an official LogiCORE IP AXI UART Lite (v1.02a). I saw it appear in the code from Jimmy and I kept it. Then I created the wiki page ( http://www.wiki.xilinx.com/Uartlite+Driver ) describing the driver and placed it there too for inclusion in the devicetree. I also tried to get this into git but it was not accepted. See here: https://github.com/Xilinx/linux-xlnx/issues/24 I have not yet tried to send my patch upstream. And reliability issues is exactly why I made the patch, though I had them when writing.

 

Maarten

0 Kudos
Explorer
Explorer
9,935 Views
Registered: ‎06-23-2013

Re: Use UARTLITE for Zynq-based Systems

  We may want to use: status = tcsendbreak( int filedes, int duration)

 

However in uartlite.c the routine seems unimplemented, why ?

 

static void ulite_break_ctl(struct uart_port *port, int ctl)
{
    /* N/A */
}

dogbytes
0 Kudos
Scholar vanmierlo
Scholar
9,929 Views
Registered: ‎06-10-2008

Re: Use UARTLITE for Zynq-based Systems

Because it is also not implemented in the uart_lite IP maybe? Have you seen it mentioned in the documentation (PG142)? And since you can't change the baudrate at runtime either you can also not simulate it by setting a low baudrate and sending a 0x00. You can't even toggle the TX output manually.

0 Kudos
Explorer
Explorer
7,715 Views
Registered: ‎06-23-2013

Re: Use UARTLITE for Zynq-based Systems

Getting back to ttyUL0 using pyserial, ser.write experiment shows when writing wcmd is 5 ascii characters:

w0000

w0001

w0002

...

 

TX failure in about 13 of 100 writes, sends a partial wcmd, typically just the first char,

w

 

There seems to be no ioctl interface in uartlite.c to access the RXFIFO, TXFIFO, STATUS, CONTROL registers.

Has anybody done any work on this?

dogbytes
0 Kudos
Scholar vanmierlo
Scholar
7,462 Views
Registered: ‎06-10-2008

Re: Use UARTLITE for Zynq-based Systems

Have you applied any of the changes from https://github.com/Xilinx/linux-xlnx/issues/24 ?

0 Kudos
Visitor anikus88
Visitor
7,662 Views
Registered: ‎11-25-2014

Re: Use UARTLITE for Zynq-based Systems

i am trying to use UARTLITE on zedboard. I have added it in the kernel and after boot i can see ttyUL2 in the dev. 

but when i

echo HELLO > /dev/ttyUL2

 

it hangs and stuck there even ctrl+c can not break.

0 Kudos
Scholar vanmierlo
Scholar
7,645 Views
Registered: ‎06-10-2008

Re: Use UARTLITE for Zynq-based Systems

Did you also add the uartlite in the PL? At the correct address? And did you load this fpga binary?

 

Trying to access non-existing devices on the AXI-bus can lead to lockups.

0 Kudos
Visitor anikus88
Visitor
7,641 Views
Registered: ‎11-25-2014

Re: Use UARTLITE for Zynq-based Systems

yes i have added uartlite in PL and also loaded bitfile on fpga

0 Kudos
Scholar vanmierlo
Scholar
7,639 Views
Registered: ‎06-10-2008

Re: Use UARTLITE for Zynq-based Systems

Interrupt connected?

0 Kudos
Visitor anikus88
Visitor
7,637 Views
Registered: ‎11-25-2014

Re: Use UARTLITE for Zynq-based Systems

yes interrupt is connected but when i look into /proc/interrupts it does not show uartlite. 

but while booting i get message

 

42c10000.serial: ttyUL2 at MMIO 0x42c10000 (irq = 91) is a uartlite.

 

0 Kudos
Visitor primefield
Visitor
7,597 Views
Registered: ‎07-16-2014

Re: Use UARTLITE for Zynq-based Systems

vanmierlo,

 

Thanks for all your work on modifying the uartlite driver. I got mine up and running successfully :).

 

I just wanted to say, that, I can confirm that if you attempt to echo to the port or read from it from the command line, there are issues...

 

Like:

1. Doing a 'echo AAAAAA > /dev/ttyUL*', only 3 chars will be received on the other side.

2. Doing a 'echo A > /dev/ttyUL*', the char will be received, but, with an added 'newline'.

 

But, if you use pySerial for example, you can loop through a string and successfully send as many chars as you like, as long as you don't try to send more than one char in a given 'ser.write' command, otherwise, only one char is received, which, again, is odd behaviour.

 

All in all though, it is 'manageable', considering I had written my own 'non kernel based solution' in C and Python before, reading and writing 'directly' to the memory locations for the UARTLITE, and that worked great, but, I really wanted to have the UARTLITE be 'recognized' 'as a serial port' by the kernel.

 

So, just wanted to say thanks!

0 Kudos
Visitor primefield
Visitor
7,583 Views
Registered: ‎07-16-2014

Re: Use UARTLITE for Zynq-based Systems

Maybe that was somewhat premature, lol...

 

"linaro@linaro-server:~$ python serialtest.py"

serialtest.py:

"import serial
ser = serial.Serial('/dev/ttyUL1', 9600)
str = "Testing123!!!Testing123!!!Testing123!!!"
for l in str:
    ser.write(l)
ser.close()"

only "Testing123!!!Test" is received, and then, it hangs, too bad...

 

looks like I'll be sticking with the 'other solution' for now...

0 Kudos
Visitor primefield
Visitor
7,520 Views
Registered: ‎07-16-2014

Re: Use UARTLITE for Zynq-based Systems

OK,

 

So, I spent some hours redoing much of uartlie.c, the kernel driver, making it more in line with xilinx_uartps.c, anyway, in the end, the result was still similar, I could now send up to 16 characters without issue...

 

The issue is, if you ONLY need to send a total of 16 characters per 'event', then, fine, the UARTLITE is great, and a slightly modified driver, works great, then, you can use C or python, or whatever, and 'extend' that 16 character limit via a custom protocol of your choosing.

 

But, if you want 'full UARTability', then, consider doing what I just did, just enable the UART 0 in the ZYNQ, set it for EMIO, generate a new HDL wrapper for your design, an editable one, and 'output' your RX and TX pins via the HDL wrapper and the constraints file, works great, and the /dev/ttyPS1 shows up and works as a 'TRUE AND RELIABLE' UART, LOL!!!

 

If anyone was interested in the modified uarlite.c driver, I'll attach it below.

0 Kudos
Scholar vanmierlo
Scholar
7,508 Views
Registered: ‎06-10-2008

Re: Use UARTLITE for Zynq-based Systems

As long as you don't change at least this piece of code, it will never work reliably. It first writes to the hardware, which can fire an interrupt, before it adapts icount. The interrupt can (and will on a multicore CPU) be triggered before icount is adjusted.

 

/* Get the data from the UART circular buffer and
 * write it to the ULITE_TX register.
 */
ulite_uart_iowrite(
	port->state->xmit.buf[port->state->xmit.tail],
	ULITE_TX);
port->icount.tx++;

 

0 Kudos
Explorer
Explorer
7,494 Views
Registered: ‎06-23-2013

Re: Use UARTLITE for Zynq-based Systems

Hi vamierlo,

   We did tests where we found a few characters would be output by ulite_start_tx from the write in user space because there is not put_char implemented, but significantly my coworker never saw any of his printk in ulite_isr.

   Independently I observed the ulite_isr did not lock out interrupts, so I asked my colleague to use spin_lock_irqsave and its partner.  I saw what you said about SMP and I will keep in mind that we have the other ARM core configured to its default, sharing the Linux processing burden.

   We ask our FPGA coworker how wide is the interrupt and the answer was 8ns.  We asked for longer while also changing the devicetree.dts entry from 0 to rising edge.  We tested with 800ns pulse and got into ulite_isr.  We are now using 80ns pulse and ttyUL0 is writing fine now.  Our commands we send are at most 10 characters long.

 

   There was not a lot of information on how wide the interrupt pulse should be for Zynq 7045.  We felt sure the next interrupt would not come until well after 80ns.

 

   We have also seen ttyUL1 emit only 3 characters and our changes have not improved ttyUL1, but we only need ttyUL0 so we are ignoring ttyUL1 problems in favor of other more urgent work. 

Best wishes.

dogbytes
0 Kudos