USE KERNEL 3.8.13.  I spent days trying to figure out why 
4.4.1/2/3-bone-rt-5 wasn't working.  Selecting the omap-serial driver 
(rather than the 8250-omap driver) won't work because some of the rs485 
patches didn't get included in later kernels.

Since last Thursday, my job was getting RS485 working on BBB.

I used a MikroElectrinika MikroBUS cape*, and an RS485 Click** plugged into 
mikroBUS socket 1.  I actually rather like this setup.

*http://www.mikroe.com/click/mikrobus-cape/
**http://www.mikroe.com/click/rs485-3.3v/

For mikroBUS socket 1, RX and TX pins are routed to the Sitara uart2, and 
the data direction control connects to J9 pin 14 (a.k.a gpio1[18], a.k.a. 
"echo 50 >/sys/class/gpio/exports").  It's only necessary to load the 
BB-UART2 overlay ("echo BB-UART2 >/sys/devices/capemgr.*/slots" or 
"capemgr.enable_partno=BB-UART2" in the uEnv.txt boot file) and do your 
programming.

Use this for the RS485 setup structure:

struct omap_serial_rs485 {
    __u32 flags;                            /* RS485 feature flags */
#define OMAP_SER_RS485_ENABLED (1 << 0)     /* If enabled */
#define OMAP_SER_RS485_RTS_ON_SEND (1 << 1) /* Logical level for
                                               RTS pin when
                                               sending */
#define OMAP_SER_RS485_RTS_AFTER_SEND (1 << 2) /* Logical level for
                                                  RTS pin after sent*/
#define OMAP_SER_RS485_RTS_BEFORE_SEND (1 << 3)
#define OMAP_SER_RS485_USE_GPIO (1 << 5)
    __u32 delay_rts_before_send; /* Delay before send (milliseconds) */
    __u32 delay_rts_after_send;  /* Delay after send (milliseconds) */
    __u32 gpio_pin;              /* GPIO Pin Index */
    __u32 padding[4];            /* Memory is cheap, new structs
                                    are a royal PITA .. */
};

... because the omap-serial rs485 patches slightly enhanced the regular 
struct serial_rs485 you find in sys/serial.h

Here's my rs485 setup code (error checking omitted):

        struct omap_serial_rs485 rs485;
        i = ioctl(m_fd, TIOCGRS485, &rs485); // whats' the current setup?
        rs485.flags |= OMAP_SER_RS485_ENABLED; // Enable RS485 mode
        rs485.flags |= OMAP_SER_RS485_USE_GPIO; // use a GPIO pin for
                                                // direction control
        rs485.flags &= 
~(OMAP_SER_RS485_RTS_AFTER_SEND|OMAP_SER_RS485_RTS_ON_SEND);
        rs485.delay_rts_before_send = 0; // No delay from RTS-assert before 
xmit
        rs485.delay_rts_after_send = 0; // No delay after xmit until 
RTS-negate
        rs485.gpio_pin = m_pin;         // select the direction control pin

        i = ioctl(m_fd, TIOCSRS485, &rs485); // establish

I built and installed kernel 3.8.13-bone79 this morning.   Finally I'm 
working well.

On Friday, February 12, 2016 at 10:42:24 AM UTC-5, RobertCNelson wrote:
>
> On Fri, Feb 12, 2016 at 9:33 AM, Taceant Omnes <[email protected] 
> <javascript:>> wrote: 
> > I would like to use RS485 with the BBB. 
> > 
> > root@beaglebone:~/test# uname -a 
> > Linux beaglebone 4.1.15-ti-r40 #1 SMP PREEMPT Thu Jan 7 23:32:17 UTC 
> > 2016 armv7l GNU/Linux 
> > 
> > I am using the kernel above. Its source code is at 
> > 
> https://github.com/RobertCNelson/linux-stable-rcn-ee/tree/4.1.15-ti-rt-r40 
>
> You need to rebuild and swap these two configs: 
>
> disable: CONFIG_SERIAL_8250_OMAP 
>
> enable: CONFIG_SERIAL_OMAP 
>
> > ... however it does not include the changes in this patch: 
> > 
> https://github.com/RobertCNelson/bb-kernel/blob/am33x-v3.8/patches/fixes/0007-omap-RS485-support-by-Michael-Musset.patch#L30
>  
>
> 485 is pretty much built-in to CONFIG_SERIAL_OMAP 
>
> It's the last thing still being talked about for integration into 
> CONFIG_SERIAL_8250_* for possibly 4.6.x 
>
> > Which kernel should I use that includes the changes in the patch or 
> > something similar? 
>
> and use this overlay as reference, as it's been reported to work with 
> that config chanage above.. 
>
>
> https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-UART4-RS485-00A0.dts
>  
>
> Regards, 
>
> -- 
> Robert Nelson 
> https://rcn-ee.com/ 
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to