This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART serial communication

Hi Guys,

I have a very simple question realted to serial communication via the provided UART interface of beaglebone.

We have a very simple RFID reader TX/RX line, it is connected via UART4 on beaglebone.

My pinmux config is the following:

static struct pinmux_config uart4_rfid_pin_mux[] = {

{"gpmc_wait0.uart4_rxd_mux2",   OMAP_MUX_MODE6 | AM33XX_PIN_INPUT_PULLUP},

{"gpmc_wpn.uart4_txd_mux2",     OMAP_MUX_MODE6 | AM33XX_PULL_ENBL},

{NULL, 0},

};

I realise that all the UART lines are there after boot whether you use it or not.

My question is do I have to do anything else from the pinmux or I cane proceed with open("/dev/ttyO4", flags) stuff and start reading the serial line.

Thanks in advance!

Best Regards,

sodjas

  • Another weird thing that for the muxing above I got:

    1.112884] _omap_mux_get_by_name: Could not find signal gpmc_wait0.uart4_rxd_mux2
    1.120788] _omap_mux_get_by_name: Could not find signal gpmc_wpn.uart4_txd_mux2

    But this is exactly how the SRM shows it...

    Any hints?

    Best Regards,

    sodjas

  • Hi Guys, another question:

    Why is there in the muxing table uart4_rxd_mux2 ?? What the _mux2 stands for?

    Could someone explain me this? Maybe this is the difference why it is dropping error and cant find it...

    Best Regards,

    sodjas

  • The "_mux2" part of the signal name indicates this is one of three possible pin mux options for the UART4_RXD signal.

    This pin mux option makes theUART4_RXD signal available on the GPMC_WAIT0 terminal configured to pin mux mode 6.  The UART4_RXD signal may also be available on MII1_TXD3 terminal configured to pin mux mode 3 and UART0_CTSn terminal configured to pin mux mode 1.

    Regards,
    Paul

  • Sorry for asking more, but I need some more info to get this :)

    I had the following info from my hw colleague:

    UART4_RX          P9                           11                           T17         uart4_rxd (mode6)

    UART4_TX          P9                           13                           U17        uart4_txd (mode6)

    As I worte I have simple RFID microcontroller with an RX and TX line on the other end.

    So I wrote in my board file:

    static struct pinmux_config uart4_rfid_pin_mux[] = {

    {"gpmc_wait0.uart4_rxd_mux2",   OMAP_MUX_MODE6 | AM33XX_PIN_INPUT},

    {"gpmc_wpn.uart4_txd_mux2",     OMAP_MUX_MODE6 | AM33XX_PIN_OUTPUT},

    {NULL, 0},

    };

    and called the pinmux setter.

    The kernel log shows:

    1.112884] _omap_mux_get_by_name: Could not find signal gpmc_wait0.uart4_rxd_mux2
    1.120788] _omap_mux_get_by_name: Could not find signal gpmc_wpn.uart4_txd_mux2

    The convention in am335x_evm is to write:

    mode0.actualmode, mux_mode etc... not?

    Could you point on potential buggy part because I know I'm not smart enough yet :)

    Thanks in advance!

    Best Regards,

    sodjas

  • I don't have a AM335X EVM. The source at Arago has the pin names are defined in

    arch/arm/mach-omap2/mux33xx.c

    The names "gpmc_wait0.uart4_rxd_mux2" and "gpmc_wpn.uart4_txd_mux2" are not define in the above file. You would have to modify the entries for "gpmc_wait0" and ""gpmc_wpn" to add in the modes you want. Assumes that the HW mux does indeed have those modes.

    I believe the mux functions allow using the actualmode name by itself if it is unique. No need to the mode0 name. Also I think the flags field are for optional parameters like pullup, input, output rather than the mode itself. Should not need to add OMAP_MUX_MODE6. The mux functions will add in the correct mode number. I guess no harm unless your specified mode number is different than the one the mux functions add.

  • Very, very useful answer mate!

    I just took a look and realised that the uart4 values form my beaglebone are not defined at all.

    So what I need to do is to add the UART4 muxing stuff in .c and the OFFSET in .h files?

    Could you tell me Norman what is the conventional mode to extend this to have the UART4 definitions because it is obvious the basic file doesn't have it?

    Thanks!

    Sorry I verfied answer beacuse it is useful but that says that the whole question is verified so I rolled back.

    cheers

  • /*
     * AM33XX mux data
     *
     * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Derived from: arch/arm/mach-omap2/mux34xx.c Original copyright follows:
     *
     * Copyright (C) 2009 Nokia
     * Copyright (C) 2009 Texas Instruments
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License version 2 as
     * published by the Free Software Foundation.
     */
    
    #include <linux/module.h>
    #include <linux/init.h>
    
    #include "mux.h"
    
    #ifdef CONFIG_OMAP_MUX
    
    #define _AM33XX_MUXENTRY(M0, g, m0, m1, m2, m3, m4, m5, m6, m7)		\
    {									\
    	.reg_offset	= (AM33XX_CONTROL_PADCONF_##M0##_OFFSET),	\
    	.gpio		= (g),						\
    	.muxnames	= { m0, m1, m2, m3, m4, m5, m6, m7 },		\
    }
    
    /* AM33XX pin mux super set */
    static struct omap_mux __initdata am33xx_muxmodes[] = {
    	_AM33XX_MUXENTRY(GPMC_AD0, 0,
    		"gpmc_ad0", "mmc1_dat0", NULL, NULL,
    		NULL, NULL, NULL, "gpio1_0"),
    	_AM33XX_MUXENTRY(GPMC_AD1, 0,
    		"gpmc_ad1", "mmc1_dat1", NULL, NULL,
    		NULL, NULL, NULL, "gpio1_1"),
    	_AM33XX_MUXENTRY(GPMC_AD2, 0,
    		"gpmc_ad2", "mmc1_dat2", NULL, NULL,
    		NULL, NULL, NULL, "gpio1_2"),
    	_AM33XX_MUXENTRY(GPMC_AD3, 0,
    		"gpmc_ad3", "mmc1_dat3", NULL, NULL,
    		NULL, NULL, NULL, "gpio1_3"),
    	_AM33XX_MUXENTRY(GPMC_AD4, 0,
    		"gpmc_ad4", "mmc1_dat4", NULL, NULL,
    		NULL, NULL, NULL, "gpio1_4"),
    	_AM33XX_MUXENTRY(GPMC_AD5, 0,
    		"gpmc_ad5", "mmc1_dat5", NULL, NULL,
    		NULL, NULL, NULL, "gpio1_5"),
    	_AM33XX_MUXENTRY(GPMC_AD6, 0,
    		"gpmc_ad6", "mmc1_dat6", NULL, NULL,
    		NULL, NULL, NULL, "gpio1_6"),
    	_AM33XX_MUXENTRY(GPMC_AD7, 0,
    		"gpmc_ad7", "mmc1_dat7", NULL, NULL,
    		NULL, NULL, NULL, "gpio1_7"),
    	_AM33XX_MUXENTRY(GPMC_AD8, 0,
    		"gpmc_ad8", "lcd_data16", "mmc1_dat0", "mmc2_dat4",
    		NULL, NULL, NULL, "gpio0_22"),
    	_AM33XX_MUXENTRY(GPMC_AD9, 0,
    		"gpmc_ad9", "lcd_data17", "mmc1_dat1", "mmc2_dat5",
    		"ehrpwm2B", NULL, NULL, "gpio0_23"),
    	_AM33XX_MUXENTRY(GPMC_AD10, 0,
    		"gpmc_ad10", "lcd_data18", "mmc1_dat2", "mmc2_dat6",
    		NULL, NULL, NULL, "gpio0_26"),
    	_AM33XX_MUXENTRY(GPMC_AD11, 0,
    		"gpmc_ad11", "lcd_data19", "mmc1_dat3", "mmc2_dat7",
    		NULL, NULL, NULL, "gpio0_27"),
    	_AM33XX_MUXENTRY(GPMC_AD12, 0,
    		"gpmc_ad12", "lcd_data20", "mmc1_dat4", "mmc2_dat0",
    		NULL, NULL, NULL, "gpio1_12"),
    	_AM33XX_MUXENTRY(GPMC_AD13, 0,
    		"gpmc_ad13", "lcd_data21", "mmc1_dat5", "mmc2_dat1",
    		NULL, NULL, NULL, "gpio1_13"),
    	_AM33XX_MUXENTRY(GPMC_AD14, 0,
    		"gpmc_ad14", "lcd_data22", "mmc1_dat6", "mmc2_dat2",
    		NULL, NULL, NULL, "gpio1_14"),
    	_AM33XX_MUXENTRY(GPMC_AD15, 0,
    		"gpmc_ad15", "lcd_data23", "mmc1_dat7", "mmc2_dat3",
    		NULL, NULL, NULL, "gpio1_15"),
    	_AM33XX_MUXENTRY(GPMC_A0, 0,
    		"gpmc_a0", "mii2_txen", "rgmii2_tctl", "rmii2_txen",
    		NULL, NULL, NULL, "gpio1_16"),
    	_AM33XX_MUXENTRY(GPMC_A1, 0,
    		"gpmc_a1", "mii2_rxdv", "rgmii2_rctl", "mmc2_dat0",
    		NULL, NULL, NULL, "gpio1_17"),
    	_AM33XX_MUXENTRY(GPMC_A2, 0,
    		"gpmc_a2", "mii2_txd3", "rgmii2_td3", "mmc2_dat1",
    		NULL, NULL, NULL, "gpio1_18"),
    	_AM33XX_MUXENTRY(GPMC_A3, 0,
    		"gpmc_a3", "mii2_txd2", "rgmii2_td2", "mmc2_dat2",
    		NULL, NULL, NULL, "gpio1_19"),
    	_AM33XX_MUXENTRY(GPMC_A4, 0,
    		"gpmc_a4", "mii2_txd1", "rgmii2_td1", "rmii2_txd1",
    		"gpmc_a20", NULL, NULL, "gpio1_20"),
    	_AM33XX_MUXENTRY(GPMC_A5, 0,
    		"gpmc_a5", "mii2_txd0", "rgmii2_td0", "rmii2_txd0",
    		"gpmc_a21", NULL, NULL, "gpio1_21"),
    	_AM33XX_MUXENTRY(GPMC_A6, 0,
    		"gpmc_a6", "mii2_txclk", "rgmii2_tclk", "mmc2_dat4",
    		"gpmc_a22", NULL, NULL, "gpio1_22"),
    	_AM33XX_MUXENTRY(GPMC_A7, 0,
    		"gpmc_a7", "mii2_rxclk", "rgmii2_rclk", "mmc2_dat5",
    		NULL, NULL, NULL, "gpio1_23"),
    	_AM33XX_MUXENTRY(GPMC_A8, 0,
    		"gpmc_a8", "mii2_rxd3", "rgmii2_rd3", "mmc2_dat6",
    		NULL, NULL, "mcasp0_aclkx", "gpio1_24"),
    	_AM33XX_MUXENTRY(GPMC_A9, 0,
    		"gpmc_a9", "mii2_rxd2", "rgmii2_rd2", "mmc2_dat7",
    		NULL, NULL, "mcasp0_fsx", "gpio1_25"),
    	_AM33XX_MUXENTRY(GPMC_A10, 0,
    		"gpmc_a10", "mii2_rxd1", "rgmii2_rd1", "rmii2_rxd1",
    		NULL, NULL, "mcasp0_axr0", "gpio1_26"),
    	_AM33XX_MUXENTRY(GPMC_A11, 0,
    		"gpmc_a11", "mii2_rxd0", "rgmii2_rd0", "rmii2_rxd0",
    		NULL, NULL, "mcasp0_axr1", "gpio1_27"),
    	_AM33XX_MUXENTRY(GPMC_WAIT0, 0,
    		"gpmc_wait0", "mii2_crs", NULL, "rmii2_crs_dv",
    		"mmc1_sdcd", NULL, NULL, "gpio0_30"),
    	_AM33XX_MUXENTRY(GPMC_WPN, 0,
    		"gpmc_wpn", "mii2_rxerr", NULL, "rmii2_rxerr",
    		"mmc2_sdcd", NULL, NULL, "gpio0_31"),
    	_AM33XX_MUXENTRY(GPMC_BEN1, 0,
    		"gpmc_ben1", "mii2_col", NULL, "mmc2_dat3",
    		NULL, NULL, "mcasp0_aclkr", "gpio1_28"),
    	_AM33XX_MUXENTRY(GPMC_CSN0, 0,
    		"gpmc_csn0", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio1_29"),
    	_AM33XX_MUXENTRY(GPMC_CSN1, 0,
    		"gpmc_csn1", NULL, "mmc1_clk", NULL,
    		NULL, NULL, NULL, "gpio1_30"),
    	_AM33XX_MUXENTRY(GPMC_CSN2, 0,
    		"gpmc_csn2", NULL, "mmc1_cmd", NULL,
    		NULL, NULL, NULL, "gpio1_31"),
    	_AM33XX_MUXENTRY(GPMC_CSN3, 0,
    		"gpmc_csn3", NULL, NULL, "mmc2_cmd",
    		NULL, NULL, NULL, "gpio2_0"),
    	_AM33XX_MUXENTRY(GPMC_CLK, 0,
    		"gpmc_clk", "lcd_memory_clk_mux", NULL, "mmc2_clk",
    		NULL, NULL, "mcasp0_fsr", "gpio2_1"),
    	_AM33XX_MUXENTRY(GPMC_ADVN_ALE, 0,
    		"gpmc_advn_ale", NULL, NULL, NULL,
    		NULL, NULL, NULL, "mmc1_sdcd"),
    	_AM33XX_MUXENTRY(GPMC_OEN_REN, 0,
    		"gpmc_oen_ren", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_3"),
    	_AM33XX_MUXENTRY(GPMC_WEN, 0,
    		"gpmc_wen", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_4"),
    	_AM33XX_MUXENTRY(GPMC_BEN0_CLE, 0,
    		"gpmc_ben0_cle", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_5"),
    	_AM33XX_MUXENTRY(LCD_DATA0, 0,
    		"lcd_data0", "gpmc_a0", NULL, NULL,
    		NULL, NULL, NULL, "gpio2_6"),
    	_AM33XX_MUXENTRY(LCD_DATA1, 0,
    		"lcd_data1", "gpmc_a1", NULL, NULL,
    		NULL, NULL, NULL, "gpio2_7"),
    	_AM33XX_MUXENTRY(LCD_DATA2, 0,
    		"lcd_data2", "gpmc_a2", NULL, NULL,
    		NULL, NULL, NULL, "gpio2_8"),
    	_AM33XX_MUXENTRY(LCD_DATA3, 0,
    		"lcd_data3", "gpmc_a3", NULL, NULL,
    		NULL, NULL, NULL, "gpio2_9"),
    	_AM33XX_MUXENTRY(LCD_DATA4, 0,
    		"lcd_data4", "gpmc_a4", NULL, NULL,
    		NULL, NULL, NULL, "gpio2_10"),
    	_AM33XX_MUXENTRY(LCD_DATA5, 0,
    		"lcd_data5", "gpmc_a5", NULL, NULL,
    		NULL, NULL, NULL, "gpio2_11"),
    	_AM33XX_MUXENTRY(LCD_DATA6, 0,
    		"lcd_data6", "gpmc_a6", NULL, NULL,
    		NULL, NULL, NULL, "gpio2_12"),
    	_AM33XX_MUXENTRY(LCD_DATA7, 0,
    		"lcd_data7", "gpmc_a7", NULL, NULL,
    		NULL, NULL, NULL, "gpio2_13"),
    	_AM33XX_MUXENTRY(LCD_DATA8, 0,
    		"lcd_data8", "gpmc_a12", NULL, "mcasp0_aclkx",
    		NULL, NULL, "uart2_ctsn", "gpio2_14"),
    	_AM33XX_MUXENTRY(LCD_DATA9, 0,
    		"lcd_data9", "gpmc_a13", NULL, "mcasp0_fsx",
    		NULL, NULL, "uart2_rtsn", "gpio2_15"),
    	_AM33XX_MUXENTRY(LCD_DATA10, 0,
    		"lcd_data10", "gpmc_a14", NULL, "mcasp0_axr0",
    		NULL, NULL, NULL, "gpio2_16"),
    	_AM33XX_MUXENTRY(LCD_DATA11, 0,
    		"lcd_data11", "gpmc_a15", NULL, "mcasp0_ahclkr",
    		"mcasp0_axr2", NULL, NULL, "gpio2_17"),
    	_AM33XX_MUXENTRY(LCD_DATA12, 0,
    		"lcd_data12", "gpmc_a16", NULL, "mcasp0_aclkr",
    		"mcasp0_axr2", NULL, NULL, "gpio0_8"),
    	_AM33XX_MUXENTRY(LCD_DATA13, 0,
    		"lcd_data13", "gpmc_a17", NULL, "mcasp0_fsr",
    		"mcasp0_axr3", NULL, NULL, "gpio0_9"),
    	_AM33XX_MUXENTRY(LCD_DATA14, 0,
    		"lcd_data14", "gpmc_a18", NULL, "mcasp0_axr1",
    		NULL, NULL, NULL, "gpio0_10"),
    	_AM33XX_MUXENTRY(LCD_DATA15, 0,
    		"lcd_data15", "gpmc_a19", NULL, "mcasp0_ahclkx",
    		"mcasp0_axr3", NULL, NULL, "gpio0_11"),
    	_AM33XX_MUXENTRY(LCD_VSYNC, 0,
    		"lcd_vsync", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_22"),
    	_AM33XX_MUXENTRY(LCD_HSYNC, 0,
    		"lcd_hsync", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_23"),
    	_AM33XX_MUXENTRY(LCD_PCLK, 0,
    		"lcd_pclk", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_24"),
    	_AM33XX_MUXENTRY(LCD_AC_BIAS_EN, 0,
    		"lcd_ac_bias_en", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_25"),
    	_AM33XX_MUXENTRY(MMC0_DAT3, 0,
    		"mmc0_dat3", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_26"),
    	_AM33XX_MUXENTRY(MMC0_DAT2, 0,
    		"mmc0_dat2", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_27"),
    	_AM33XX_MUXENTRY(MMC0_DAT1, 0,
    		"mmc0_dat1", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_28"),
    	_AM33XX_MUXENTRY(MMC0_DAT0, 0,
    		"mmc0_dat0", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_29"),
    	_AM33XX_MUXENTRY(MMC0_CLK, 0,
    		"mmc0_clk", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_30"),
    	_AM33XX_MUXENTRY(MMC0_CMD, 0,
    		"mmc0_cmd", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio2_31"),
    	_AM33XX_MUXENTRY(MII1_COL, 0,
    		"mii1_col", "rmii2_refclk", "spi1_sclk", NULL,
    		"mcasp1_axr2", "mmc2_dat3", "mcasp0_axr2", "gpio3_0"),
    	_AM33XX_MUXENTRY(MII1_CRS, 0,
    		"mii1_crs", "rmii1_crs_dv", "spi1_d0", "i2c1_sda",
    		"mcasp1_aclkx", NULL, NULL, "gpio3_1"),
    	_AM33XX_MUXENTRY(MII1_RXERR, 0,
    		"mii1_rxerr", "rmii1_rxerr", "spi1_d1", "i2c1_scl",
    		"mcasp1_fsx", NULL, NULL, "gpio3_2"),
    	_AM33XX_MUXENTRY(MII1_TXEN, 0,
    		"mii1_txen", "rmii1_txen", "rgmii1_tctl", NULL,
    		"mcasp1_axr0", NULL, "mmc2_cmd", "gpio3_3"),
    	_AM33XX_MUXENTRY(MII1_RXDV, 0,
    		"mii1_rxdv", NULL, "rgmii1_rctl", NULL,
    		"mcasp1_aclx", "mmc2_dat0", "mcasp0_aclkr", "gpio3_4"),
    	_AM33XX_MUXENTRY(MII1_TXD3, 0,
    		"mii1_txd3", NULL, "rgmii1_td3", NULL,
    		"mcasp1_fsx", "mmc2_dat1", "mcasp0_fsr", "gpio0_16"),
    	_AM33XX_MUXENTRY(MII1_TXD2, 0,
    		"mii1_txd2", NULL, "rgmii1_td2", NULL,
    		"mcasp1_axr0", "mmc2_dat2", "mcasp0_ahclkx", "gpio0_17"),
    	_AM33XX_MUXENTRY(MII1_TXD1, 0,
    		"mii1_txd1", "rmii1_txd1", "rgmii1_td1", "mcasp1_fsr",
    		"mcasp1_axr1", NULL, "mmc1_cmd", "gpio0_21"),
    	_AM33XX_MUXENTRY(MII1_TXD0, 0,
    		"mii1_txd0", "rmii1_txd0", "rgmii1_td0", "mcasp1_axr2",
    		"mcasp1_aclkr", NULL, "mmc1_clk", "gpio0_28"),
    	_AM33XX_MUXENTRY(MII1_TXCLK, 0,
    		"mii1_txclk", NULL, "rgmii1_tclk", "mmc0_dat7",
    		"mmc1_dat0", NULL, "mcasp0_aclkx", "gpio3_9"),
    	_AM33XX_MUXENTRY(MII1_RXCLK, 0,
    		"mii1_rxclk", NULL, "rgmii1_rclk", "mmc0_dat6",
    		"mmc1_dat1", NULL, "mcasp0_fsx", "gpio3_10"),
    	_AM33XX_MUXENTRY(MII1_RXD3, 0,
    		"mii1_rxd3", NULL, "rgmii1_rd3", "mmc0_dat5",
    		"mmc1_dat2", NULL, "mcasp0_axr0", "gpio2_18"),
    	_AM33XX_MUXENTRY(MII1_RXD2, 0,
    		"mii1_rxd2", NULL, "rgmii1_rd2", "mmc0_dat4",
    		"mmc1_dat3", NULL, "mcasp0_axr1", "gpio2_19"),
    	_AM33XX_MUXENTRY(MII1_RXD1, 0,
    		"mii1_rxd1", "rmii1_rxd1", "rgmii1_rd1", "mcasp1_axr3",
    		"mcasp1_fsr", NULL, "mmc2_clk", "gpio2_20"),
    	_AM33XX_MUXENTRY(MII1_RXD0, 0,
    		"mii1_rxd0", "rmii1_rxd0", "rgmii1_rd0", "mcasp1_ahclkx",
    		"mcasp1_ahclkr", "mcasp1_aclkr", "mcasp0_axr3", "gpio2_21"),
    	_AM33XX_MUXENTRY(MII1_REFCLK, 0,
    		"rmii1_refclk", NULL, "spi1_cs0", NULL,
    		"mcasp1_axr3", "mmc0_pow", "mcasp1_ahclkx", "gpio0_29"),
    	_AM33XX_MUXENTRY(MDIO_DATA, 0,
    		"mdio_data", NULL, NULL, NULL,
    		"mmc0_sdcd", "mmc1_cmd", "mmc2_cmd", "gpio0_0"),
    	_AM33XX_MUXENTRY(MDIO_CLK, 0,
    		"mdio_clk", NULL, NULL, NULL,
    		"mmc0_sdwp", "mmc1_clk", "mmc2_clk", "gpio0_1"),
    	_AM33XX_MUXENTRY(SPI0_SCLK, 0,
    		"spi0_sclk", "uart2_rxd", "i2c2_sda", NULL,
    		NULL, NULL, NULL, "gpio0_2"),
    	_AM33XX_MUXENTRY(SPI0_D0, 0,
    		"spi0_d0", "uart2_txd", "i2c2_scl", NULL,
    		NULL, NULL, NULL, "gpio0_3"),
    	_AM33XX_MUXENTRY(SPI0_D1, 0,
    		"spi0_d1", "mmc1_sdwp", "i2c1_sda", NULL,
    		NULL, NULL, NULL, "gpio0_4"),
    	_AM33XX_MUXENTRY(SPI0_CS0, 0,
    		"spi0_cs0", "mmc2_sdwp", "i2c1_scl", NULL,
    		NULL, NULL, NULL, "gpio0_5"),
    	_AM33XX_MUXENTRY(SPI0_CS1, 0,
    		"spi0_cs1", "uart3_rxd", NULL, "mmc0_pow",
    		NULL, "mmc0_sdcd", NULL, "gpio0_6"),
    	_AM33XX_MUXENTRY(ECAP0_IN_PWM0_OUT, 0,
    		"ecap0_in_pwm0_out", "uart3_txd", "spi1_cs1", NULL,
    		"spi1_sclk", "mmc0_sdwp", NULL, "gpio0_7"),
    	_AM33XX_MUXENTRY(UART0_CTSN, 0,
    		"uart0_ctsn", NULL, "d_can1_tx", "i2c1_sda",
    		"spi1_d0", NULL, NULL, "gpio1_8"),
    	_AM33XX_MUXENTRY(UART0_RTSN, 0,
    		"uart0_rtsn", NULL, "d_can1_rx", "i2c1_scl",
    		"spi1_d1", "spi1_cs0", NULL, "gpio1_9"),
    	_AM33XX_MUXENTRY(UART0_RXD, 0,
    		"uart0_rxd", "spi1_cs0", "d_can0_tx", "i2c2_sda",
    		NULL, NULL, NULL, "gpio1_10"),
    	_AM33XX_MUXENTRY(UART0_TXD, 0,
    		"uart0_txd", "spi1_cs1", "d_can0_rx", "i2c2_scl",
    		NULL, NULL, NULL, "gpio1_11"),
    	_AM33XX_MUXENTRY(UART1_CTSN, 0,
    		"uart1_ctsn", NULL, NULL, "i2c2_sda",
    		"spi1_cs0", NULL, NULL, "gpio0_12"),
    	_AM33XX_MUXENTRY(UART1_RTSN, 0,
    		"uart1_rtsn", NULL, NULL, "i2c2_scl",
    		"spi1_cs1", NULL, NULL, "gpio0_13"),
    	_AM33XX_MUXENTRY(UART1_RXD, 0,
    		"uart1_rxd", "mmc1_sdwp", NULL, "i2c1_sda",
    		NULL, "pr1_uart0_rxd_mux1", NULL, "gpio0_14"),
    	_AM33XX_MUXENTRY(UART1_TXD, 0,
    		"uart1_txd", "mmc2_sdwp", NULL, "i2c1_scl",
    		NULL, "pr1_uart0_txd_mux1", NULL, "gpio0_15"),
    	
    	_AM33XX_MUXENTRY(UART4_RXD, 0,
    		"gpmc_wait0", "mii2_crs", "gpmc_csn4", "rmii2_crs_dv",
    		"mmc1_sdcd", NULL, "uart4_rxd_mux2", "gpio0_30"),
    	_AM33XX_MUXENTRY(UART4_TXD, 0,
    		"gpmc_wpn", "mii2_rxerr", "gpmc_csn5", "rmii2_rxerr",
    		"mmc2_sdcd", NULL, "uart4_txd_mux2", "gpio0_31"),
    	
    	_AM33XX_MUXENTRY(I2C0_SDA, 0,
    		"i2c0_sda", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio3_5"),
    	_AM33XX_MUXENTRY(I2C0_SCL, 0,
    		"i2c0_scl", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio3_6"),
    	_AM33XX_MUXENTRY(MCASP0_ACLKX, 0,
    		"mcasp0_aclkx", NULL, NULL, "spi1_sclk",
    		"mmc0_sdcd", NULL, NULL, "gpio3_14"),
    	_AM33XX_MUXENTRY(MCASP0_FSX, 0,
    		"mcasp0_fsx", NULL, NULL, "spi1_d0",
    		"mmc1_sdcd", NULL, NULL, "gpio3_15"),
    	_AM33XX_MUXENTRY(MCASP0_AXR0, 0,
    		"mcasp0_axr0", NULL, NULL, "spi1_d1",
    		"mmc2_sdcd", NULL, NULL, "gpio3_16"),
    	_AM33XX_MUXENTRY(MCASP0_AHCLKR, 0,
    		"mcasp0_ahclkr", NULL, "mcasp0_axr2", "spi1_cs0",
    		NULL, NULL, NULL, "gpio3_17"),
    	_AM33XX_MUXENTRY(MCASP0_ACLKR, 0,
    		"mcasp0_aclkr", NULL, "mcasp0_axr2", "mcasp1_aclkx",
    		"mmc0_sdwp", NULL, NULL, "gpio3_18"),
    	_AM33XX_MUXENTRY(MCASP0_FSR, 0,
    		"mcasp0_fsr", NULL, "mcasp0_axr3", "mcasp1_fsx",
    		NULL, "pr1_pru0_pru_r30_5", NULL, "gpio3_19"),
    	_AM33XX_MUXENTRY(MCASP0_AXR1, 0,
    		"mcasp0_axr1", NULL, NULL, "mcasp1_axr0",
    		NULL, NULL, NULL, "gpio3_20"),
    	_AM33XX_MUXENTRY(MCASP0_AHCLKX, 0,
    		"mcasp0_ahclkx", NULL, "mcasp0_axr3", "mcasp1_axr1",
    		NULL, NULL, NULL, "gpio3_21"),
    	_AM33XX_MUXENTRY(XDMA_EVENT_INTR0, 0,
    		"xdma_event_intr0", NULL, NULL, NULL,
    		"spi1_cs1", NULL, NULL, "gpio0_19"),
    	_AM33XX_MUXENTRY(XDMA_EVENT_INTR1, 0,
    		"xdma_event_intr1", NULL, NULL, "clkout2",
    		NULL, NULL, NULL, "gpio0_20"),
    	_AM33XX_MUXENTRY(WARMRSTN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(PWRONRSTN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(NMIN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(XTALIN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(XTALOUT, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(TMS, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(TDI, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(TDO, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(TCK, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(TRSTN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(EMU0, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio3_7"),
    	_AM33XX_MUXENTRY(EMU1, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio3_8"),
    	_AM33XX_MUXENTRY(RTC_XTALIN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(RTC_XTALOUT, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(RTC_PWRONRSTN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(PMIC_POWER_EN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(EXT_WAKEUP, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(USB0_DRVVBUS, 0,
    		"usb0_drvvbus", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio0_18"),
    	_AM33XX_MUXENTRY(USB1_DRVVBUS, 0,
    		"usb1_drvvbus", NULL, NULL, NULL,
    		NULL, NULL, NULL, "gpio3_13"),
    	_AM33XX_MUXENTRY(DDR_RESETN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_CSN0, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_CKE, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_CK, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_CKN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_CASN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_RASN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_WEN, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_BA0, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_BA1, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_BA2, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A0, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A1, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A2, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A3, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A4, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A5, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A6, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A7, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A8, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A9, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A10, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A11, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A12, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A13, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A14, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_A15, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_ODT, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D0, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D1, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D2, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D3, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D4, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D5, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D6, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D7, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D8, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D9, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D10, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D11, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D12, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D13, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D14, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_D15, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_DQM0, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_DQM1, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_DQS0, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_DQSN0, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_DQS1, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_DQSN1, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_VREF, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(DDR_VTP, 0,
    		NULL, NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(AIN0, 0,
    		"ain0", NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(AIN1, 0,
    		"ain1", NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(AIN2, 0,
    		"ain2", NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(AIN3, 0,
    		"ain3", NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(VREFP, 0,
    		"vrefp", NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	_AM33XX_MUXENTRY(VREFN, 0,
    		"vrefn", NULL, NULL, NULL,
    		NULL, NULL, NULL, NULL),
    	{ .reg_offset = OMAP_MUX_TERMINATOR },
    };
    
    int __init am33xx_mux_init(struct omap_board_mux *board_subset)
    {
    	return omap_mux_init("core", 0, AM33XX_CONTROL_PADCONF_MUX_PBASE,
    			AM33XX_CONTROL_PADCONF_MUX_SIZE, am33xx_muxmodes,
    			NULL, board_subset, NULL);
    }
    #else
    int __init am33xx_mux_init(struct omap_board_mux *board_subset)
    {
    	return 0;
    }
    #endif
    

    1641.mux33xx.h

    Update:

    Based on Norman's post I added 

    #define AM33XX_CONTROL_PADCONF_UART4_RXD_OFFSET 0x0B38
    #define AM33XX_CONTROL_PADCONF_UART4_TXD_OFFSET 0x0B3C

    to mux33x.h the offsets are at the end increased by 4 as all other. I think the order doesn't matter, am I right?

    And added:

    _AM33XX_MUXENTRY(UART4_RXD, 0,
    "gpmc_wait0", "mii2_crs", "gpmc_csn4", "rmii2_crs_dv",
    "mmc1_sdcd", NULL, "uart4_rxd_mux2", "gpio0_30"),

    _AM33XX_MUXENTRY(UART4_TXD, 0,
    "gpmc_wpn", "mii2_rxerr", "gpmc_csn5", "rmii2_rxerr",
    "mmc2_sdcd", NULL, "uart4_txd_mux2", "gpio0_31"),

    to mux33x.c

    With this I don't get the error any more. But is it enough to mux my configuration? At least it compiles without warnings...

    What do you think?

    Best Regards,

    sodjas

  • Not sure what you are asking. Comparing mux33xx.c and the datasheet for AM335X would suggest that the tables in mux33xx.c are incomplete. To get past the "_omap_mux_get_by_name: Could not find" error, you could add names to the existing entries to:

    arch/arm/mach-omap2/mux33xx.c
        _AM33XX_MUXENTRY(GPMC_WAIT0, 0,
            "gpmc_wait0", "mii2_crs", NULL, "rmii2_crs_dv",
            "mmc1_sdcd", NULL, "uart4_rxd_mux2", NULL),
        _AM33XX_MUXENTRY(GPMC_WPN, 0,
            "gpmc_wpn", "mii2_rxerr", NULL, "rmii2_rxerr",
            "mmc2_sdcd", NULL, "uart4_txd_mux2", NULL),

    I don't think you need to add new entries to the table.

    However, I have the feeling that probably will not be sufficient to enable use of UART4. Search this sub-forum for UART4 issues. You will probably have to chase down code that enables power, clock, and registers the driver instance. Definitely best not to verify posts to attract more knowledgable eyes.

  • Ooops yes youre right, not UART4_TXD but GPMC_WAIT0 and same for RXD thanks.

    Register offsets are there :))) Sorry I'm too tired to concentrate, so I will correct the above mentioned and then debug!

    Thanks! I will come back if there are any results.

  • The pin muxing can be done by adding some line in mux33xx.c file , in the board file we can set up the pin mux by using  pinmux_config structure

    /***************************************************/

    static struct pinmux_config uart3_pin_mux[] = {
            {"spi0_cs1.uart3_rxd", AM33XX_PIN_INPUT_PULLUP},
            {"ecap0_in_pwm0_out.uart3_txd", AM33XX_PULL_ENBL},
            {NULL, 0},
    };
    /*****************************************************/
     the uart3_pin_mux contains a string like "spi0_cs1.uart3_rxd" , this string means you have selected the pin with the name spio_cs1 and ur going to use this as a  uart3_rxd , after some digging in the code  you can find that the above string is parsed and ur " _omap_mux_get_by_name: Could not find signal gpmc_wpn.uart4_txd_mux2"  is because the mux33xx.c file is missing some thing, u can search the pin GPMC_WPN  and place the mode name in the proper place for example

      _AM33XX_MUXENTRY(GPMC_WPN, 0,
            "gpmc_wpn", "mii2_rxerr", NULL, "rmii2_rxerr",
            "mmc2_sdcd", NULL, "*****", NULL),

    add the string  here since in 6th mode the pin acts like uart4 ,

    this is all fine and well,

    what i want to know is that if i go through the technical reference manual ,i find that there's no pin named UART4 , its there but on different pins and on different mode like the pin name uart0_rtsn , in mode 1 it is uart4_txd , now i have gone through the serial.c code and found that there are six UARTS ( 0 - 5 ) all of them are initialized the same away and the same omap_serial.c driver is used for all the UARTS, and after booting the board i have found six ttyo* ( 0-5) files ,  there are some functions named  UART*_INIT  ( i guess  uart3_init ) , but if these are the only  uarts available , how come there are six ttyo  dev files , in the serial.c file we can actually get hold of  all the six uarts , if all the uarts are availabe ,does it mean that i don't have to do any pin muxing in the board init file i 'm kind of perplexed with all the pin muxing and the avaialbility of all the UARTs without pin muxing... in the board-am335xevm.c file

  • Hi zubraj,

    Many thanks, yes I already glued this up from Normans post, thanks anyway, now I'm not getting the error.

    Fro your question: it seems that you already got a lot more deeper in this than me, but in my understanding, yes the 6 uarts are there which are represented with char devices, but if you don't do the muxing then the expansion pin your peripherial is attached won't be glued to the character device (I think...)

    This is why you are do muxing or like on a forum page echo directly modes to sys/kernel/debug/omap_mux/... http://www.jerome-bernard.com/blog/2012/06/04/beaglebone-serial-ports-and-xbees/

    I have a further question guys, regarding this serial UART communication so:

    1. I have linked TX and RX lines of my serial device (RFID reader) to expansion pin 11 and 13 (bone T17 and U17 port processor)

    2. I set up the muxing symbols in mux33xx.c and filled up a struct like inked and invoke set_pinmux

    3. After bootup there are no errors

    4. All I have to do now is open /dev/ttyO4 with paramteres I know from my serial device and the data will appear on the char device? Do I need to init explicitly any extra thing on ttyO4???

    Thanks,

    Best Regards,

    sodjas

  •  So u r saying  that , all the uarts and all the ttyo files being created in the /dev directory are dummy since there are no pin muxing in the board-am335xevm.c file

      my kernel logs are

    http://pastebin.com/fX9dtHvK

    the uarts are initialized six times by the omap_serial.c and serial_core.c ( for api's ) there Are six  ttyO( 0 - 5) devices created, so u mean to say that these are dummy and cannot be used .. as serial ports since they are all initilalized as serial ports ,  but we are not usingthat many serial ports only one i guess ttyO0 for boot sequence , so now i can modify  the 4th one

  • Yes, in my case (Beaglebone Rev. A6)

    I have 6 UART lines but some are already reserved as the SRM describes it for example O0 is for the debug console, O5 provides only tx and rx lines no cts and rts . Practically I'm free to use O1, O2, O3, O4.

    I think no matter how the board is configured all 6 char devices will be there. BUT if you don't make the muxing in my understanding practically you don't route the physically linked TX and RX lines (in my case) to /dev/ttyO4

    The linked XBEE forum tells exactly the same, the only difference is that the guy is using UART1 which is in my case reserved for Bluetooth and sets the modes from console echo-ing the mode in the corresponding mux file. I don't have any files in sys/kernel/debug/ so I deviced to set muxing to from the board file during init. But I understand this is the same stuff...

    What I don't know whether I have to do any extra thing on /dev/ttyO4 to start reading data from my RFID reader...

    /dev/ttyO4 ---- pins ---- physical (TX/RX wires) ---- RFID

    Sorry if there are gaps in my description but there are still many questions in my head too :)

    Best Regards,

    sodjas 

  • once u have pin muxed the UART according to ur requirement , then open up serial.c and access UART4  and set the required configuration for yur RF chip . (by configuration i mean the sending/recieving of data on RF has to be sent according to some configurations in my case IR so data needs to sent in 36 Khz ( RC5 )frequency ) .

  • Hey Guys!

    Thanks for all of you. I didn't even need to touch the serial.c file. After the extra mixing stuff in mux33xx.c it works like a charm.

    My RFID microcontroller sends data 115200 BAUD 8N1 this was all I needed to set ater open in readonly mode...

    Thanks again!

    Hope Zubraj will also work out his stuff!

    Best Regards,

    sodjas 

  • I guess u were using UART4  , on which tty device are yu trying to listen , i mean there are plethora of tty devices out there , i guess u have four ttyS* devices  which tty device yu have used to read the RF data , and do u have any idea what is the difference between ttyO device and ttyS devices

    Regards,

    Zubraj Singha

  • Zubraj,

    I read on a forum that the O is totally the same as S it is just a platform convention, O means the OMAP platform that's it, there is no technical difference from S which is probably the acronym for serial...

    Best Regards,

    sodjas

  • in linux kernel 3.2 provided by  TI  in sdk the ttyS* devices are not present , newayz thanks

  • Hi Sodjas,

                I'm glad it worked for you but lets recap: you're now reading UART4 at 115200 BAUD? You must have done something else to it too because when I look at my platform and do:

    stty -F /dev/ttyO4

    It tells me that speed is:

    speed 9600 baud;

    It seems like 9600 baud is the default baud rate assigned to all UARTs except ttyO0 which is 115200.

    So how did you get ttyO4 set up with 115200? Do you configure it at some later time from your own application?

    Thanks

  • Hi Arturs,

    I'm still green in this area :) but I understand the things as the following:

    The UART itself is not configurable it is just a physical connection between microcontroller (in my case RFID reader) with serial device and the beaglebone so I understand that in my case the connection is the following:

    HW [RFID reader ----- microcontroller (rx,tx only interface) ----- beaglebone expansion header (uart4rx, uart4tx)] ---- SW [/dev/ttyO4 ---- my app(open (/dev/ttyO4, 115200);)]

    The point is that I understand that the communication speed is determined by the microcontroller. The manufacturer defined there that the RFID reader will send me data on serial rx line with the following paratmeters Buad 115200, Data 8N1, no flow control. So I only set the speed to the mentioned value after open and it worked.

    I not sure, it is possible that it performed some kind of fallback to 9600, I havent a benchmarked it because I have really simple communication model here only a bunch of bytes identifying the RFID tag id...

    Sorry if this not helped...

    Best Regards,

    sodjas

  • Hi Sodjas,

                 Thanks for the quick reply. The application that you wrote ("my app")-- is it a C++ application?

    and:

    sodjas said:
    open (/dev/ttyO4, 115200);

    The "open" function that you're using-- it's not the "open" function that lives in "stdio.h", right? What include did you use to get this "open" function that accepts configuration parameters for UART comms?

    If there's some compiled library available for serial comms that is this easy to use then that's exactly what I'm looking for. 

    Well I'm pretty green too in this area but I'd like to configure ttyOx pretty dynamically in my application and that's what I'm looking for. Thanks for sharing your experience.

    Thanks.

  • I'm on Android platform, so I'm using java+jni yes, this open is a wrapper for stdio.h open+setspeed:

    here is my jni C file:

    /*
     * Copyright 2009-2011 Cedric Priscal
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     * http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    
    #include <termios.h>
    #include <unistd.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <string.h>
    #include <jni.h>
    
    #include "SerialPort.h"
    
    #include "android/log.h"
    static const char *TAG="serial_port";
    #define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO,  TAG, fmt, ##args)
    #define LOGD(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, TAG, fmt, ##args)
    #define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##args)
    
    static speed_t getBaudrate(jint baudrate)
    {
    	switch(baudrate) {
    	case 0: return B0;
    	case 50: return B50;
    	case 75: return B75;
    	case 110: return B110;
    	case 134: return B134;
    	case 150: return B150;
    	case 200: return B200;
    	case 300: return B300;
    	case 600: return B600;
    	case 1200: return B1200;
    	case 1800: return B1800;
    	case 2400: return B2400;
    	case 4800: return B4800;
    	case 9600: return B9600;
    	case 19200: return B19200;
    	case 38400: return B38400;
    	case 57600: return B57600;
    	case 115200: return B115200;
    	case 230400: return B230400;
    	case 460800: return B460800;
    	case 500000: return B500000;
    	case 576000: return B576000;
    	case 921600: return B921600;
    	case 1000000: return B1000000;
    	case 1152000: return B1152000;
    	case 1500000: return B1500000;
    	case 2000000: return B2000000;
    	case 2500000: return B2500000;
    	case 3000000: return B3000000;
    	case 3500000: return B3500000;
    	case 4000000: return B4000000;
    	default: return -1;
    	}
    }
    
    /*
     * Class:     android_serialport_SerialPort
     * Method:    open
     * Signature: (Ljava/lang/String;II)Ljava/io/FileDescriptor;
     */
    JNIEXPORT jobject JNICALL Java_android_1serialport_1api_SerialPort_open
      (JNIEnv *env, jclass thiz, jstring path, jint baudrate, jint flags)
    {
    	int fd;
    	speed_t speed;
    	jobject mFileDescriptor;
    
    	/* Check arguments */
    	{
    		speed = getBaudrate(baudrate);
    		if (speed == -1) {
    			/* TODO: throw an exception */
    			LOGE("Invalid baudrate");
    			return NULL;
    		}
    	}
    
    	/* Opening device */
    	{
    		jboolean iscopy;
    		const char *path_utf = (*env)->GetStringUTFChars(env, path, &iscopy);
    		LOGD("Opening serial port %s with flags 0x%x", path_utf, O_RDONLY | flags);
    		fd = open(path_utf, O_RDONLY | flags);
    		LOGD("open() fd = %d", fd);
    		(*env)->ReleaseStringUTFChars(env, path, path_utf);
    		if (fd == -1)
    		{
    			/* Throw an exception */
    			LOGE("Cannot open port");
    			/* TODO: throw an exception */
    			return NULL;
    		}
    	}
    
    	/* Configure device */
    	{
    		struct termios cfg;
    		LOGD("Configuring serial port");
    		if (tcgetattr(fd, &cfg))
    		{
    			LOGE("tcgetattr() failed");
    			close(fd);
    			/* TODO: throw an exception */
    			return NULL;
    		}
    
    		cfmakeraw(&cfg);
    		cfsetispeed(&cfg, speed);
    		cfsetospeed(&cfg, speed);
    
    		if (tcsetattr(fd, TCSANOW, &cfg))
    		{
    			LOGE("tcsetattr() failed");
    			close(fd);
    			/* TODO: throw an exception */
    			return NULL;
    		}
    	}
    
    	/* Create a corresponding file descriptor */
    	{
    		jclass cFileDescriptor = (*env)->FindClass(env, "java/io/FileDescriptor");
    		jmethodID iFileDescriptor = (*env)->GetMethodID(env, cFileDescriptor, "<init>", "()V");
    		jfieldID descriptorID = (*env)->GetFieldID(env, cFileDescriptor, "descriptor", "I");
    		mFileDescriptor = (*env)->NewObject(env, cFileDescriptor, iFileDescriptor);
    		(*env)->SetIntField(env, mFileDescriptor, descriptorID, (jint)fd);
    	}
    
    	return mFileDescriptor;
    }
    
    /*
     * Class:     cedric_serial_SerialPort
     * Method:    close
     * Signature: ()V
     */
    JNIEXPORT void JNICALL Java_android_1serialport_1api_SerialPort_close
      (JNIEnv *env, jobject thiz)
    {
    	jclass SerialPortClass = (*env)->GetObjectClass(env, thiz);
    	jclass FileDescriptorClass = (*env)->FindClass(env, "java/io/FileDescriptor");
    
    	jfieldID mFdID = (*env)->GetFieldID(env, SerialPortClass, "mFd", "Ljava/io/FileDescriptor;");
    	jfieldID descriptorID = (*env)->GetFieldID(env, FileDescriptorClass, "descriptor", "I");
    
    	jobject mFd = (*env)->GetObjectField(env, thiz, mFdID);
    	jint descriptor = (*env)->GetIntField(env, mFd, descriptorID);
    
    	LOGD("close(fd = %d)", descriptor);
    	close(descriptor);
    }
    
    

    hope it helps,

    sodjas

  • I think this is it, Sodjas :)

                This JNI C file basically does this:

    sodjas said:

    fd = open(path_utf, O_RDONLY | flags);

    where "flags" is what you pass to it (in your case a constant 115200). So it's got to work like that in my C++ application too. I'll try that out in an hour or so and post back wether it worked or not.

    Thanks a lot, you've been very helpful.

    P.S. Is there anything interesting in "SerialPort.h"?

  • Here is the header:

    7633.SerialPort.h

    It only contains jni related stuff and its generated by jni framework.

    You can also check out the full story of this implementation here:

    http://code.google.com/p/android-serialport-api/

    br,

    sodjas

  • Alright, I wanted to do this earlier but a few things took priority (e.g. finishing CS188.1x course at edx.org). If anyone wants to write a C++ app to test UART then here's some simple code that works (heavily influenced from what Sodjas posted). You just have to compile it and link to your application and then call "testUART()" from your main application. This worked for me on a phyCore-AM335x platform.

  • Hi all,

    I am working on GPS module using TI android SDK. My GPS is UART based it is communicating through /dev/ACM*, I wrote one uart c application, works fine and gives latitude, longitude, utc timing, position and data validation. I need to create apk using JNI(Java native interface), tried so many things but not able to open the device port.

    I followed the link http://cheng-min-i-taiwan.blogspot.in/2011/05/java-native-interface-jni-androidndk.html

    Thanks,

    Vidya

  • Hi Vidya,

    Ok a few checks to investigate:

    0. If you don't have rooted device or your own where you can modify the event file then probably you won't be able to open /dev nodes from your apk.

    1. you need to have defined to correct permissions in your /ueventd.rc or /ueventd.am335xevm.rc

    2. for me I have ttyO2 so this is the line I have in the second file:

    # RFID

    /dev/ttyO2          0004  root       root

    3. This means that "other" have read rights, I was not paranoid, and I think it is a bit tricky for the apk to be seen with root priviliges

    4. You need a uni serial implementation, I attached it to this post, this is an open source implementation and it should go to the /jni folder in my Eclipse project

    5. You need to have a java file in com.example.SerialPort.java where you declare your open and read methods as native

    6. After that you can run gen_SerialPort_h.sh to generate you the JNI c header for this java file, DO NOT FORGET to build project because javah is looking for class files in ../bin/classes - This is an Eclipse hierarchy

    7. When you have your SerialPort.h generated then the only thing you need is to copy the generated headers to the SerialPort.c file (as you can already see) and use this C implementation or implement yourself what you need

    8. To have the libs you need ndk-build in your path, go to /jni folder in command line and invoke ndk-build this will build you the .so-s - BE CAREFUL to modify everywhere what is not generated the com.exmple domain because this is just and example

    9. Then you can try invoking the native open in your app and check logcat

    10. The java file is grabbed out of context there is our custom logger in it so you will get some errors what you should fix to...

    Hope This helps,

    Cheers,

    sodjas

  • The zip for the above post, sorry

    7801.ti.zip

    cheers

  • Hi sodjas,

    Thanks for quick reply and sharing the jni folder. 

    I created one project (SerialPort) in eclipse and made a JNI folder gave the native support permission

    (project->Android Tool -> Natve Support), got SerialPort.cpp and Android.mk.  I changed the name SerialPort.cpp to SerialPort.c and same in the Android.mk file, Copied (your SerialPort.java)  SerialPort.java in working directory (SerialPort->com->example->serialport). To  getting the .h file i changed the setting in the project file (project -> properties -> Builders -> New ->Program -> (Added javah_buider)). I got header file same to your header file and i copied your SerialPort.c file in jni. 

    Major problem in MainActivity.java file How can open /dev/ttyO2.

    GPS module is connected to ttyO2 port, So i changed the  ueventd.rc as you mentioned.

    If possible could you share your whole project file.

    Thanks,

    Vidya

  • Hi,

    I can't share the whole project :) but here is a snippet how we are using serial stuff:

    SerialPort mSerialPort = new SerialPort(this.baudRate);

    InputStream mInputStream = mSerialPort.getInputStream();

    Here you have now an input stream reference so you can start reading from it in a convention java way....

    /**

    * Online buffer which is filled directly from the stream.

    */

    private final byte[] onlineBuffer = new byte[ONLINE_READ_BUFFER_LENGHT];

    ....

    final int size = this.mInputStream.read(onlineBuffer);

    The data will be in the online buffer.

    Best regards,

    sodjas


  • And another thing, it is much simpler just to download ndk and go in command line to uni folder saying ndk-build. It will then make you the .so under libs/armeabi/libserial_port.so

    Cheers,

    sodjas

  • Hi sodjas,

    Thanks for very quick reply.

    I do not have any issue in library creation,  got library (libserial_port.so) as desired folder through ndk-build in eclipse only. I am not able to open the device port in the MainActivity.java file, this is the major issue.

    If you could suggest me how to open device port in MainActivity.java file, would be better help for me.

    Thanks,

    Vidya

     

  • Hi sodjas,

    I am attaching my project file if could suggest me how to open /dev/ttyO2 device port that would be better help for me.


    Thanks,

    Vidya1563.SerialPort.zip


  • Ok in short,

    1. Your are making the project complex while there is mo reason for that, you added CDT nature with builders etc what you not need

    2. I could give you an example how to open the port and read from it, but with this WE stepped into another area, I will give you a snippet how this is opened in an activity but if you want to use it in a robust way you should start a reading thread from a service to guarantee it will remain alive during the lifecycle of your whole activity. BUT again this is a programmatic question not who to link the apk with a serial node so don't expect from the to program you a complete solution :)

    3. Why have you deleted genserial script? Do not set javah builder in eclipse because my pattern not works in that way, you should first define native methods in java, build project, implement .c file then generate .h file with the script and then invoke manually ndk-build in uni folder.

    3B Last but not least in JNI one of the most import an thing is to keep in sync with the namespace, my example was com_example_SerialPort your tryout was com_exmaple_serialport_SerialPort this would cause  UnsatifiedLinkError so you should be aware the in the java file + in the .c file + in the generated .h file these are in sync. I made this for you in the reference project.

    4. My snippet attached below. I recreated a clean android project without CDT and Javah nature.

    5. I also removed the check whether ttyO4 or ttyO2 should be opened this is specific for our project. Also baud of 9600 hardcoded you should tailor it to the specs of your device.s

    5. You now have all and more then needed information to start reading from serial port. Any other thing is related to Android and Java development patterns, for example lifecycle of services and activities etc...

    6471.SerialPort.zip

    Best Regards,

    sodjas

  • Hi Sadjas,

    Sorry for late reply, i suffered from cold.

    Today, I built SerialPort.apk in eclipse and kept in SD card (rootfs/data/app/). I also changed in ueventd.rc

    /dev/ttyO2 0004 root root 

    and also in init.rc 

    mkdir /data/misc/gps 0770 gps gps
    mkdir /data/misc/gps 0770 system system
    mkdir /data/misc/keystore 0700 keystore keystore
    mkdir /data/app 0771 system system

    # Owner mode foe GPS 

    chmod 0660 /dev/ttyO2
    chmod 777 /dev/ttyO2
    chown gps gps /dev/ttyO2
    chmod 0660 /sys/class/rfkill/rfkill0/state
    chown gps gps /sys/class/rfkill/rfkill0/state

    My board do not have USB port so i could not use adb debug. I use am command to install SerialPort.apk.       

    am start -a android.intent.action.MAIN -n com.example.serialport/com.example.serialport.MainActivity

    throws error :

    Error type 3
    Error: Activity class {com.example.serialport/com.example.serialport.MainActivity} does not exist.

    In my board side GPS is connected to /dev/ttyO2. But port does not open at all.

    My GPS evaluation module has /dev/ACM* port , could connect GPS evaluation module directly to ADT  in eclipse and see the data from /dev/ttyACM*.

    My c application works fine in the board, gives latitude, longitude, utc time, position and data validation correctly.

    Please suggest me to solve this problem.

    Thanks.

    Vidya  

  • Hi Sadjas,

    I use command line to set the /dev/ttyO2. Any idea to set this command in run time of kernel or filesystem.

    When i set Stty command my gps works fine.

    I attached both log and command file.5633.Command & running GPS.zip


    Thanks,

    Vidya


     

     


  • HI!

    Your fir comment is related to Android app development again command

    am start -a android.intent.action.MAIN -n com.example.serialport/com.example.serialport.MainActivity

    This only starts the activity, you should first install the apt with:

    pm install SerialPort.apk on the board.

    Second comment, you can execute any automated setup in your init.rc during boot, just like your pasted a piece of chmods etc, this is the conventional way.

    Simply place your script with at least 755 privileges to / root path and extend the end of your init.rc with:

    service gps_init /system/bin/sh /Gps_run.sh
      class main
      user root
      oneshot

    Vidya, these question are related to Android, I'm happy to answer your questions, but this forum is not for discussing how to start an app from command line, how to install an app and how to execute a script automatically on boot. There are plenty of examples on the Internet if type these buzzwords above.

    Best Regards,

    sodjas

  • Hi sodjas,

    Thanks for quick reply, I am very new in android just 10 days before started, You are giving awesome support to me ones again thanks.

    Now my script run automatically after getting changed in init.rc.

    But I am not getting GPS port open through SerialPort.apk, trying to solve, would like to remember you later on if could not solve. 


    Thanks,

    Vidya