1
\$\begingroup\$

Checking uart overrun and framing error flags in linux. In some microcontrollers I can access overrun and framing error flags programmatically. Is it possible to access these flags from command line?

\$\endgroup\$
  • 1
    \$\begingroup\$ What are you running Linux on? \$\endgroup\$ – Nick Alexeev Mar 14 '14 at 18:11
  • \$\begingroup\$ On Beaglebone Black. I can send ok, but receiving too many bytes. Other equipment works ok. with very same settings. \$\endgroup\$ – sdfsdfsdf Mar 15 '14 at 8:24
0
\$\begingroup\$

I've read and written to registers in the past by writing a kernel module that creates an entry in the /proc filesytem. Then I can read the registers by doing cat /proc/lpc32xx_regcheck for example.

This code might be garbage; It might be against "best practices" to do it this way. I'm not a Linux programmer by any means, but it worked for me for debugging.

#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <linux/fb.h>
#include <linux/stat.h>

#include <mach/platform.h>
#include <mach/hardware.h>
#include <mach/i2s.h>

struct proc_dir_entry *lpc32xx_regcheck = NULL;
static int my_proc_read(char *buf, char **start, off_t offset, int count, int *eof);

static int my_proc_read(char *buf, char **start, off_t offset, int count, int *eof)
{
    int len = 0;

    len += sprintf( buf + len, "LPC3250 I2S REGISTER DUMP:\n");
    len += sprintf( buf + len, "I2S0 RXFIFO     :0x%X\n", __raw_readl(io_p2v(0x2009400C)));
    len += sprintf( buf + len, "I2S1 RXFIFO     :0x%X\n", __raw_readl(io_p2v(0x2009C00C)));
    len += sprintf( buf + len, "I2S0 STATE      :0x%X\n", __raw_readl(io_p2v(0x20094010)));
    len += sprintf( buf + len, "I2S1 STATE      :0x%X\n", __raw_readl(io_p2v(0x2009C010)));
    len += sprintf( buf + len, "I2S0 DMA0       :0x%X\n", __raw_readl(io_p2v(0x20094014)));
    len += sprintf( buf + len, "I2S1 DMA0       :0x%X\n", __raw_readl(io_p2v(0x2009C014)));
    len += sprintf( buf + len, "I2S0 DMA1       :0x%X\n", __raw_readl(io_p2v(0x20094018)));
    len += sprintf( buf + len, "I2S1 DMA1       :0x%X\n", __raw_readl(io_p2v(0x2009C018)));
    len += sprintf( buf + len, "I2S0 IRQ        :0x%X\n", __raw_readl(io_p2v(0x2009401C)));
    len += sprintf( buf + len, "I2S1 IRQ        :0x%X\n", __raw_readl(io_p2v(0x2009C01C)));
    len += sprintf( buf + len, "I2S0 TXRATE     :0x%X\n", __raw_readl(io_p2v(0x20094020)));
    len += sprintf( buf + len, "I2S1 TXRATE     :0x%X\n", __raw_readl(io_p2v(0x2009C020)));
    len += sprintf( buf + len, "I2S0 RXRATE     :0x%X\n", __raw_readl(io_p2v(0x20094024)));
    len += sprintf( buf + len, "I2S1 RXRATE     :0x%X\n", __raw_readl(io_p2v(0x2009C024)));

     len += sprintf( buf + len, "\nWriting to P_MUX_CLR...\n");
    __raw_writel(0x1c,io_p2v(0x40028104));

    len += sprintf( buf + len, "NEW P_MUX STATE :0x%X\n", __raw_readl(io_p2v(0x40028108)));

    if(len <= count + offset)
        *eof = 1;
    *start = buf + offset;

    len -= offset;

    if( len > count)
        len = count;
    if( len <0)
        len = 0;

    return len;
}


static int __init test_init(void)
{
    printk("Hello.\n");

    lpc32xx_regcheck = create_proc_entry("lpc32xx_regcheck", S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, NULL);

    if (lpc32xx_regcheck)
    {
        lpc32xx_regcheck->read_proc = my_proc_read;
    }

    return 0;
}

static void __exit test_exit(void)
{
    printk("Goodbye.\n");
}

module_init(test_init);
module_exit(test_exit);

MODULE_AUTHOR("dext0rb");
MODULE_LICENSE("LOL");
\$\endgroup\$
  • \$\begingroup\$ appreciating your answer, But do you know how to do it from command line? \$\endgroup\$ – sdfsdfsdf Mar 15 '14 at 9:01
  • \$\begingroup\$ Yes. My answer implies you compile this code (or something like it) and run it on your distro. You access the proc filesystem from command line with the cat command. \$\endgroup\$ – dext0rb Mar 16 '14 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.