7 Replies Latest reply on Nov 28, 2014 3:20 PM by tmalheiro

    Galileo Gen2 ttyS0 Input/output error

    tmalheiro

      Dear all,

       

      I am trying to develop an application which requires a serial connection. I was trying to use ttyS0, which maps to IO0 and IO1, but with no success.

      I do the open with success, nevertheless, trying to use it returns error.

      errno is 5 and strerror() returns Input/output error.

      below you can check the code:

       


      int main()
      {
          struct termios tio;

          memset(&tio,0,sizeof(tio));
          tio.c_iflag=0;
          tio.c_oflag=0;
          tio.c_cflag=CS8|CREAD|CLOCAL;           // 8n1
          tio.c_lflag=0;
          tio.c_cc[VMIN]=1;
          tio.c_cc[VTIME]=5;

          screenfd = open("/dev/ttyS0", O_RDWR);
          if(screenfd == -1)
         {
            printf("Could not open the ttyS0: %s\n",strerror(errno));
            return -1;
          }    
          cfsetospeed(&tio,B115200);            // 115200 baud
          cfsetispeed(&tio,B115200);            // 115200 baud

          int ret = tcsetattr(screenfd,TCSANOW,&tio);
          if ( ret != 0)
          {
               printf("Error %d from tcsetattr: %s", errno,strerror(errno) );
          }
          close(screenfd);
          return 0;
      }

       

      Removing the termios setup and just opening the device and writing falls back to the same error.

       

      The same code works fine on ubuntu 12.04, but fails when cross compiled to galileo.

      to the build environment I have followed the intel doc Quark_BSP_BuildandSWUserGuide_329687_006.

      I have also followed How to program UART serial from Linux on Galileo Gen 2? with no success, performing    # stty -F /dev/ttyS0 9600 returns the same error.

      Doing,

      root@clanton:~# echo -n "hello" >/dev/ttyS0

      -sh: echo: write error: Input/output error

       

      any ideas?

       

      Kind regards,

      tiago

        • 1. Re: Galileo Gen2 ttyS0 Input/output error
          Intel_Peter

          Hello tmalheiro,

           

          What compiler are you using to compile that code? What firmware are you using? What image are you using? And, could you please attach a picture showing us what happens when you try to use the method on How to program UART serial from Linux on Galileo Gen 2? ? Remember to type all lines otherwise it will not work, since you're configuring the GPIO in order to use the serial port, you can check this link to learn more about it.

           

          Regards,

                      Peter

          • 2. Re: Galileo Gen2 ttyS0 Input/output error
            tmalheiro

            Hi Peter,

             

            I have followed the intel doc Quark_BSP_BuildandSWUserGuide_329687_006, thus I have downloaded the Board_Support_Package_Sources_for_Intel_Quark_v1.0.1.
            Following the instructions, after untar and setup:


            # source poky/oe-init-build-env yocto_build
            # bitbake image-full-galileo

            # bitbake image-full-galileo -c populate_sdk
            and run the output script.
            before each session, I run:
              # source /opt/clanton-tiny/1.4.2/environment-setup-x86_32-poky-linux
             
              ${CC} --version
              i586-poky-linux-uclibc-gcc (GCC) 4.7.2
              Copyright (C) 2012 Free Software Foundation, Inc.
              This is free software; see the source for copying conditions.  There is NO
              warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
             

            About the firmware, I run the Arduino 1.5.3-Intel.1.0.4 and got 'Target firmware is version '1.0.4' now.'

            About the image, I run the 'uname -a' in galileo gen2 and got:
            Linux clanton 3.8.7-yocto-standard #2 Thu Nov 20 00:03:07 WET 2014 i586 GNU/Linux
            was this what you were asking?

             

            last, here is the screenshot :

            galileoGen2UartSYSFS.png

             

             

            Thank you,
            tiago

            • 3. Re: Galileo Gen2 ttyS0 Input/output error
              Intel_Peter

              Hello tmalheiro,

               

              What permisions does the ttyS0 has?

              Type

              cd /dev

              ls -la

              Also what happens if you try the https://communities.intel.com/thread/56827 method without booting from the SD Card?

               

              Regards,

                          Peter

              • 4. Re: Galileo Gen2 ttyS0 Input/output error
                tmalheiro

                Hi Peter,

                 

                here is the output focused on the ttyS0 part

                 

                crw-rw----    1 root     root      249,   0 Jan  1 00:03 ttyGS0

                crw-rw----    1 root     root      252,   0 Jan  1 00:00 ttyQRK0

                crw-------    1 root     tty       252,   1 Jan  1 01:36 ttyQRK1

                crw-rw----    1 root     root        4,  64 Jan  1 00:00 ttyS0

                crw-rw----    1 root     root        4,  65 Jan  1 00:00 ttyS1

                 

                when I try your suggention, it works as expected!:

                galileoGen2UartSYSFS-SPIimage.png

                 

                thank you,

                tiago

                • 5. Re: Galileo Gen2 ttyS0 Input/output error
                  Intel_Peter

                  Hello tmalheiro,

                   

                  It's weird that it works booting without the SD Card and that it doesn't work booting from SD card, I think something might be wrong with your current image, it should work, with or without the SD Card, maybe you should try re-downloading/decompressing it and try it again to see if that makes it work.

                   

                  Regards,

                              Peter

                  • 6. Re: Galileo Gen2 ttyS0 Input/output error
                    tmalheiro

                    Hi Peter,

                     

                    Indeed. I must,  however,  mention that I haven't burned the Spirit into the flash, and this the flash image is the original one which came with the board.

                    I am currently building an eglibc based image.

                    Thank you for your time and effort to help me.

                     

                    Kind regards,

                    Tiago

                    • 7. Re: Galileo Gen2 ttyS0 Input/output error
                      tmalheiro

                      Sorry,  by spirit, I intended to write SPI image