11 Replies Latest reply on Dec 22, 2015 1:29 AM by Bennett

    How to enable usage of serial port /dev/ttyMFD2

    IntelAnonymous

      Good day,

       

      I am trying to use mraa to access /dev/ttyMFD2 with C++.

       

      I configured a slave device in a way that it sends each second the character '@'. I also used cat on /dev/ttyMFD2 to see what's going on.

      klammeraffe2.PNG

       

      An oscilloscope has been used to verify that the '@' byte is sent each second. However, I realized that the '@' byte is not received every second. Sometimes nothing is received for several seconds. Then it works again for up to ten seconds correctly, then receiving stops again etc.


      After searching this forum I read that ttyMFD2 is used as the "console output". However, I can not find a way to get rid of this.

       

      class TTYUART

      As  suggested here how to activate uart2 I tried using the _detach_console function but without effect. Has anyone successfully used this class for /dev/ttyMFD2?

       

       

      fw_setenv bootargs_console

      As found in another thread using this bash example causes the edison to block when rebooting. You have to flash the edison afterwards. Therefore this solution does not work.

       

       

      systemctl stop serial-getty@ttyMFD2.service

      As suggested here UART2 for data transfer using NodeJS the above bash code should remove the console from MFD2. However, I do not receive a single byte after using this code. When starting the service again I get the behavior described at the beginning of this thread.

       

       

      So what is the right approach to actually use /dev/ttyMFD2 respectively getting rid of the console output to /dev/ttyMFD2?

       

       

       

       


        • 1. Re: How to enable usage of serial port /dev/ttyMFD2
          Intel_Alvarado

          Hi,

           

          Why are you using the –parodd and –cstopb options?

          Check the output of stty -F /dev/ttyMFD2 –a. In the first line you’ll see the speed of the port communication. Try using this baud rate, in my case is 115200.

          Also, what image and mraa versions are you using?

           

          Let us know your results.

           

          Sergio

          • 2. Re: How to enable usage of serial port /dev/ttyMFD2
            IntelAnonymous

            Dear Sergio,

             

            I am using the latest mraa version. My edison image is a custom image based on the edison-src-ww25.5-15.tgz files.

             

            I think the main problem is that the system is using ttyMFD2 as a console output. Immediately after starting the edison the oscilloscope shows a lot of traffic on this UART. However, I have WLAN SSH access, I do not need these console outputs.

             

            How can I temporarily (after booting) or permanently (in the image sources) remove the console access to ttyMFD2? I really do appreciate any help here since older solutions as written in my first posts do not seem to work and since I do need both UARTs

             

            Thanks

            • 3. Re: How to enable usage of serial port /dev/ttyMFD2
              IntelAnonymous

              I tried changing the bootargs_console line in recipes-bsp/u-boot/filesedison.env. However, each change resulted in a not booting edison:

               

              • bootargs_console=console=none
              • bootargs_console=console=
              • #bootargs_console=console=none
              • bootargs_console=console=ttyMFD1 earlyprintk=ttyMFD1,keep   (Just to test whether the edison would boot)

               

              Changing everything back to ttyMFD2 and everything works fine. How can I remove console access to ttyMFD2?

              • 4. Re: How to enable usage of serial port /dev/ttyMFD2
                Ruscoff
                system("systemctl stop serial-getty@ttyMFD2.service"); 
                

                 

                It works fine on my application.

                 

                By the way i don't use mraa system call:

                 

                void BLEHandler::configurePort()
                {
                  char cmd[256];
                
                
                  //Abilito la ricezione GP134 RX INPUT
                  system("echo 134 > /sys/class/gpio/export 2>&1");
                  system("echo mode1 > /sys/kernel/debug/gpio_debug/gpio134/current_pinmux");
                  system("echo in > /sys/class/gpio/gpio134/direction");
                
                
                  //Abilito la trasmissione GP135 TX OUTPUT
                  system("echo 135 > /sys/class/gpio/export 2>&1");
                  system("echo mode1 > /sys/kernel/debug/gpio_debug/gpio135/current_pinmux");
                  system("echo out > /sys/class/gpio/gpio135/direction");
                
                
                  sprintf(cmd, "stty -F %s %d -echo -echoe -echok raw",  ttyName , BAUD_RATE);
                  system(cmd);
                }
                
                bool BLEHandler::openPort()
                {
                  BLEportD = open( ttyName, O_RDWR | O_NOCTTY | O_NDELAY);
                
                
                  if(BLEportD != -1)
                  fcntl(BLEportD, F_SETFL, FNDELAY); //set no blocking
                
                  return BLEportD != -1;
                }
                
                
                void BLEHandler::closePort()
                {
                  if(BLEportD != -1)
                  {
                  close(BLEportD);
                  BLEportD = -1;
                  }
                }
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                1 of 1 people found this helpful
                • 5. Re: How to enable usage of serial port /dev/ttyMFD2
                  CMata_Intel

                  Hi IntelAnonymous,

                   

                  Have you been able to remove the console access from ttyMFD2?

                  Did you try with Ruscoff suggestion?

                   

                  Regards,

                  Charlie

                  • 6. Re: How to enable usage of serial port /dev/ttyMFD2
                    IntelAnonymous

                    No, I still can not get rid of the outputs during boot time.

                     

                    I want to use this UART with connected devices. All these outputs are causing trouble. Isn't there any way to completely turn of the UART2 usage? I mean, flashing is also possible without these outputs.

                    • 7. Re: How to enable usage of serial port /dev/ttyMFD2
                      Ruscoff

                      I had same problems, i had to place transistor on power line of device and power it on only after the software get rid of tty2.

                      Other ways of use tty2 seems buggy with currrent release.

                      I think the best you can achieve with mine ways is to start a service just after the kernel load external port.

                      • 8. Re: How to enable usage of serial port /dev/ttyMFD2
                        IntelAnonymous

                        When exactly do you power the transistor? Which "power line of device" do you mean?

                        • 9. Re: How to enable usage of serial port /dev/ttyMFD2
                          Ruscoff

                          With an Intel Edison I/O i switch on or switch off a transistor (BJT, MOSFER, power Driver) to enable or disable the power supply for external device. You need to know a little a bit of electronics because Edison output with 1.8V and external device has 3v3 or higher voltage and if you wont want burn something the transistor circuit has to be designed carefully. However in google you can find many many tutorial on how to do that.

                          • 10. Re: How to enable usage of serial port /dev/ttyMFD2
                            Intel_Alvarado

                            Hi IntelAnonymous,

                             

                            Do you have any updates trying to disable the console access of ttyMFD2?

                             

                            Sergio

                            • 11. Re: How to enable usage of serial port /dev/ttyMFD2
                              Bennett

                              I solved this problem by using the commands as specified in Using ttyMFD2 in linux userspace


                              systemctl stop serial-getty@ttyMFD2.service

                              dmesg -n 1

                               

                              But that only got me a consistent write, I still couldn't read. To get full functionality, I had to power my board from a source other than the computer. In other words, I used an external 5V power supply, which is how my project will be powered anyway. I won't pretend to know exactly why, but I would imagine it has something to do with the serial connection that's made when you plug into the computer, even though the console stream has been disabled.

                               

                              Hope this helps!

                              1 of 1 people found this helpful