5 Replies Latest reply on Jul 29, 2015 9:52 AM by xthunderheartx

    Exposing ttyS1 on the Arduino header

    xthunderheartx

      Has anyone managed to expose UART1 (ttyS1) on the Arduino header?  Brenndan arfoll suggested writing a logic '1' to raw gpio76/77 which I tried, but apparently that isn't enough.  That guy is busy so instead of hounding him on github I thought I would see if anyone here has tried it with success.

       

      I have a bit of test code that uses termios to setup and read/write to the port and it works fine with the default mapping.  I just 'systemctl stop serial-getty@ttyS1.service' and jump rx/tx at the ftdi header.  Then I can write out to the port and read it right back.  All good.  But if I set gpio76/77 high and move the jumper to pins 2&3 of the Arduino header I get nothing.  Is other chicanery required?

       

      Thanx,

       

      Dallas

        • 1. Re: Exposing ttyS1 on the Arduino header
          xthunderheartx

          Ok using Brendan's suggestion and information from this thread GPIO Mapping for GEN2? by SpiderKenny I convinced myself that indeed gpio76 and gpio77 do in fact control the output of MUX9 (TX1) and MUX10 (RX1) respectively and that a '1' would select the proper input signals  However I can write a 1 to both those pins all day long and it still doesn't seem to work.  The UART keeps talking on the FTDI header but nothing at IO2/IO3.

           

          Here is what I'm doing

           

          bool mapUART1()
          {
            bool mapGOOD = true;
            mraa_result_t result;
            mraa_gpio_context gpio76; // UART1 TX Pin MUX
            mraa_gpio_context gpio77; // UART1 RX Pin MUX
          
            gpio76 = mraa_gpio_init_raw(76);
            gpio77 = mraa_gpio_init_raw(77);
          
            if (gpio76 == NULL || gpio77 == NULL)
            {
                 syslog (LOG_DEBUG, "Couldn't get raw context");
                 return (false);
            }
          
            if (
                 ((result = mraa_gpio_write (gpio76, 1)) != MRAA_SUCCESS)
                 ||
                 ((result = mraa_gpio_write (gpio77, 1)) != MRAA_SUCCESS)
               )
            {
                 syslog (LOG_DEBUG, "Couldn't set raw value");
                 mapGOOD = false;
            }
          
            mraa_gpio_close (gpio76);
            mraa_gpio_close (gpio77);
          
            return (mapGOOD);
          }
          

           

          I call this then setup termios as usual for /dev/ttys1 and just start sending an uppercase 'U' in a loop.  Comes out on the FTDI header as I said but not IO3 as it should.

           

          If go look at /sys/class/gpio/gpio77/value it is '1'  Same for gpio76.

           

          So what am I doing wrong?  arfoll, AlexT_Intel, CMata_Intel, SpiderKenny anybody?

          • 2. Re: Exposing ttyS1 on the Arduino header
            arfoll

            I've replied on mraa_uart_init(1) on galileo returns NULL and syslogs "uart: platform has only 1" · Issue #244 · intel-iot-devkit/mraa ·… but for the sake of clarity - you also need to pin pin16 OUT LOW and pin17 OUT HIGH.

            • 3. Re: Exposing ttyS1 on the Arduino header
              CMata_Intel

              Hi xthunderheartx,

               

              Do you have updates in this? Did you try with the suggestions above?

               

               

              Regards,

              Charlie

              • 4. Re: Exposing ttyS1 on the Arduino header
                xthunderheartx

                Yeah Charlie, Brendan sorted me out, I was just too wound-up to see it!  Man I need to get out of this room ... I don't even know what day it is!  I'll post an example as soon as I can learn to actually follow directions and make it work.

                • 5. Re: Exposing ttyS1 on the Arduino header
                  xthunderheartx

                  Thanks to Brendan arfoll I got this to work.  This test code ignores results so needs be fixed for that of course.  Thanx for your patience Brendan!  Jeff jlengel might be interested.


                  bool mapUART1()
                  {
                    bool mapGOOD = true;
                    mraa_gpio_context gpio76; // UART1 TX Pin MUX
                    mraa_gpio_context gpio77; // UART1 RX Pin MUX
                    mraa_gpio_context gpio16; // IO3 level shifter
                    mraa_gpio_context gpio17; // IO3 pullup
                  
                  
                    // First, set the Level/Pullup mode for IO3/TX
                  
                  
                    gpio16 = mraa_gpio_init_raw (16);           // TX Level Shifter
                    mraa_gpio_dir (gpio16, MRAA_GPIO_OUT);      // direction to OUT
                    mraa_gpio_write (gpio16, 0);                // Enable /(U26.4) I think
                  
                  
                    gpio17 = mraa_gpio_init_raw (17);           // TX Pull UP/DOWN
                    mraa_gpio_dir (gpio17, MRAA_GPIO_OUT);      // direction to OUT
                    mraa_gpio_write (gpio17, 1);                // HIGH to pull up
                  
                  
                    // Now select the alternate inputs on MUX9 (TX) and MUX10.  The direction
                    // on these pins is fixed (OUT only).
                  
                  
                    // IO3/TX
                    gpio76 = mraa_gpio_init_raw(76);
                    mraa_gpio_write (gpio76, 1);                // Galileo U4.16(MUX9_SEL) to HIGH
                  
                  
                    // IO2/RX
                    gpio77 = mraa_gpio_init_raw(77);
                    mraa_gpio_write (gpio77, 1);                // Galileo U4.17(MUX10_SEL) to HIGH
                  
                  
                    // You're in business.  Clean up
                    mraa_gpio_close (gpio16);
                    mraa_gpio_close (gpio17);
                    mraa_gpio_close (gpio76);
                    mraa_gpio_close (gpio77);
                  
                  
                    return (mapGOOD);
                  }