14 Replies Latest reply on Mar 31, 2017 12:59 PM by Intel Corporation

    GPIO pins not working properly on arduino101


      Hello, I'm using the arduino 101 with Zephyr ... I am having problems with using the gpio pins in input mode.

      1) IO8 seems to be perpetually not working as inout or output

      2) Though I am configuring all pins as inpul pull down, the pins are not following this configuration. pins IO13, IO3 and IO5 seem to be perpetually pulled up.

      any suggestion on what the issue might?

      3) Also facing similar issue regarding pu, pd in d2000 as well

        • 1. Re: GPIO pins not working properly on arduino101
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello me_5,
          Thanks for reaching out!
          Could you please show us how you are setting up the pins on both cases? Also, how did you determine that IO8 is not functional and that IO13, IO3 and IO5 are always set as pull-up?
          Regarding the issue with the D2000, despite Curie (and therefore Arduino 101) being based on the module, it may still be a different issue. Hence, I suggest you to post a question for this issue on its forum, which you can find in https://communities.intel.com/community/tech/microcontrollers.
          I will be waiting for your response.
          Pedro M.

          • 2. Re: GPIO pins not working properly on arduino101

            Hi, thanks for replying.

            let me share my code with you :


            #include <zephyr.h>
            #include <board.h>
            #include <device.h>
            #include <gpio.h>
            #include <pinmux.h>
            #include <misc/printk.h>
            #define delay 500
            #define noofpins 9
            int input_pins[noofpins] = {18,17,19,15,20,0,3,1,2}; //ard 2,3,4,5,7,10,11,12,13
            int ret=5;
            int in_val=5;
            void main()
              struct device* pinmux_dev = device_get_binding(CONFIG_PINMUX_DEV_NAME);
              if (pinmux_dev==NULL)
                printk("pin failed to get binding\n");
                printk("pin binding successfull\n");
              for(int i=0; i<noofpins; i++)
                    ret=pinmux_pin_set(pinmux_dev, input_pins[i], PINMUX_FUNC_A);
              printk("Pin %d mode set ret as %d\n",input_pins[i], ret);
              struct device* dev = NULL;
              dev = device_get_binding("GPIO_0");
              if (dev==NULL)
                printk("device failed to get binding\n");
                printk("device binding sucessfull\n");
              for(int i=0; i<noofpins; i++)
                 ret = gpio_pin_configure(dev, input_pins[i], GPIO_DIR_IN | GPIO_PUD_PULL_DOWN);
                 if (ret==0)
                 printk("pin %d configured as input \n", input_pins[i]);
                 printk("pin configuration error");
                for(int i=0; i<noofpins;i++)
               ret = gpio_pin_read(dev,input_pins[i],&in_val);
               if (ret==0)
                  printk("GPIO read at pin %d successfull with value %d\n", input_pins[i], in_val);
                  printk("GPIO read unsuccessfull");


            so in this case, the pins are being configured as input but they are not following the command of being pulled down (or pull up- have tried that too, i have also tried disabling the gpio pins and then enabling them again). Whatever i try, their default state doesnt change.  A few pins come up as 1 and a few as 0. on configuration, i want all pins as either 0 or 1. Do help.


            Also about  IO8, if i add that to my array i.e input_pins[] (as gpio pin 16 on zephyr) then the code stops executing after displaying pin binding successful on the serial monitor. This problem arises even if i try to configure it as output. Do help

            • 3. Re: GPIO pins not working properly on arduino101

              Also, sending you a screenshot of the serial monitor. sorry, pins 3,5,13(arduino pins) are pulled down while others are pulled up.




              • 4. Re: GPIO pins not working properly on arduino101
                Intel Corporation
                This message was posted on behalf of Intel Corporation

                Hello me_5,
                Thank you for providing me this information.
                We will take a look at this and see if we can replicate this behavior. If we are able to do so, or we are able to find out why this might be happening, I will make sure to update you in here.
                Meanwhile, something that might be useful to know is, are you using the M tree or the Z tree?
                Pedro M.

                • 5. Re: GPIO pins not working properly on arduino101
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hello me_5,


                  I've been doing some tests on my Arduino 101 and unfortunately I've not been able to run your code. I'm getting the following error:


                  makers@makers:~/Documents/Peter/CODK_Z/CODK-Z$ make compile-x86 
                  Compiling x86 core
                  make O=/home/makers/Documents/Peter/CODK_Z/CODK-Z//out/x86 BOARD=arduino_101_factory ARCH=x86 -C /home/makers/Documents/Peter/CODK_Z/CODK-Z/test/x86
                  make[1]: Entering directory `/home/makers/Documents/Peter/CODK_Z/CODK-Z/test/x86'
                  make[2]: Entering directory `/home/makers/Documents/Peter/CODK_Z/zephyr'
                  make[3]: Entering directory `/home/makers/Documents/Peter/CODK_Z/CODK-Z/out/x86'
                    Using /home/makers/Documents/Peter/CODK_Z/zephyr as source for kernel
                    GEN     ./Makefile
                    CHK     include/generated/version.h
                    CHK     misc/generated/configs.c
                    CHK     include/generated/offsets.h
                    CHK     misc/generated/sysgen/prj.mdef
                    CC      src/main.o
                  /home/makers/Documents/Peter/CODK_Z/CODK-Z/test/x86/src/main.c: In function 'main':
                  /home/makers/Documents/Peter/CODK_Z/CODK-Z/test/x86/src/main.c:30:3: warning: implicit declaration of function 'k_sleep' [-Wimplicit-function-declaration]
                    LD      src/built-in.o
                    AR      libzephyr.a
                    LINK    zephyr.lnk
                  src/built-in.o: In function `main':
                  /home/makers/Documents/Peter/CODK_Z/CODK-Z/test/x86/src/main.c:30: undefined reference to `k_sleep'
                  /home/makers/Documents/Peter/CODK_Z/CODK-Z/test/x86/src/main.c:57: undefined reference to `k_sleep'
                  collect2: error: ld returned 1 exit status
                  make[3]: *** [.tmp_zephyr.prebuilt] Error 1
                  make[3]: Leaving directory `/home/makers/Documents/Peter/CODK_Z/CODK-Z/out/x86'
                  make[2]: *** [sub-make] Error 2
                  make[2]: Leaving directory `/home/makers/Documents/Peter/CODK_Z/zephyr'
                  make[1]: *** [all] Error 2
                  make[1]: Leaving directory `/home/makers/Documents/Peter/CODK_Z/CODK-Z/test/x86'
                  make: *** [compile-x86] Error 2


                  These are the steps I followed:


                  mkdir -p ~/CODK && cd $_
                  git clone https://github.com/01org/CODK-Z.git
                  cd CODK-Z
                  make clone
                  sudo make install-dep
                  make setup
                  source ../zephyr/zephyr-env.sh
                  make compile-x86
                  make upload-x86-dfu
                  ***I checked that the board got flashed correctly and closed the terminal to start a new session.
                  cd ~/CODK/CODK-Z
                  source ../zephyr/zephyr-env.sh
                  make project PROJ_DIR=test
                  ***I received the message that the new project got created correctly, I closed the terminal to start a new session and copied the code into test/x86/src/main.c
                  cd ~/CODK/CODK-Z
                  source ../zephyr/zephyr-env.sh
                  make compile-x86


                  Do you get the same output? If you don't, what steps did you take to compile this code? I'm using the Z tree.
                  Let me know.
                  Pedro M.

                  • 6. Re: GPIO pins not working properly on arduino101

                    Hi, Thanks for the reply.

                    To answer your question, I am not familiar with the terminology of "tree". Correct me if I am wrong but it is used solely with respect to Intel Curie Open Development Kit?

                    What I am doing is flashing the zephyr code directly via the terminal window without the use of any other development kit

                    Is the use of z-tree necessary? If so, how is it used? could you please elaborate? Also, is it something only for  Intel Curie Open Development Kit?

                    • 7. Re: GPIO pins not working properly on arduino101
                      Intel Corporation
                      This message was posted on behalf of Intel Corporation

                      Yes, you are correct, the term tree refers to Curie's ODK. You can find details about the A, M, Z trees and their differences in https://software.intel.com/en-us/node/674972

                      I am indeed trying to compile and upload your code using the ODK by following the instructions found in:


                      How did you upload your project to your Arduino 101? Could you please send us the step by step process to see if we can replicate the behavior you described?

                      Let me know.
                      Pedro M.

                      • 8. Re: GPIO pins not working properly on arduino101

                        Hi, I've gone through the links u sent. I tried installing it but got the following error:

                        Ign http://in.archive.ubuntu.com trusty InRelease

                        Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB]          

                        Get:2 http://in.archive.ubuntu.com trusty-updates InRelease [65.9 kB]         

                        Hit http://ppa.launchpad.net trusty InRelease                                 

                        Hit http://in.archive.ubuntu.com trusty-backports InRelease                   

                        Ign http://extras.ubuntu.com trusty InRelease                                 

                        Get:3 http://extras.ubuntu.com trusty Release.gpg [72 B]                      

                        Hit http://in.archive.ubuntu.com trusty Release.gpg                           

                        Hit http://ppa.launchpad.net trusty/main amd64 Packages                       

                        Hit http://extras.ubuntu.com trusty Release                                   

                        Get:4 http://in.archive.ubuntu.com trusty-updates/main Sources [392 kB]       

                        Get:5 http://security.ubuntu.com trusty-security/main Sources [126 kB]        

                        Hit http://extras.ubuntu.com trusty/main Sources                              

                        Hit http://ppa.launchpad.net trusty/main i386 Packages                        

                        Hit http://extras.ubuntu.com trusty/main amd64 Packages                       

                        Hit http://ppa.launchpad.net trusty/main Translation-en                       

                        Hit http://extras.ubuntu.com trusty/main i386 Packages                        

                        Get:6 http://in.archive.ubuntu.com trusty-updates/restricted Sources [5,911 B]

                        Get:7 http://in.archive.ubuntu.com trusty-updates/universe Sources [174 kB]

                        Get:8 http://in.archive.ubuntu.com trusty-updates/multiverse Sources [7,510 B]

                        Get:9 http://in.archive.ubuntu.com trusty-updates/main amd64 Packages [954 kB]

                        Get:10 http://security.ubuntu.com trusty-security/restricted Sources [4,637 B]

                        Get:11 http://security.ubuntu.com trusty-security/universe Sources [49.9 kB]  

                        Get:12 http://in.archive.ubuntu.com trusty-updates/restricted amd64 Packages [16.4 kB]

                        Get:13 http://security.ubuntu.com trusty-security/multiverse Sources [3,194 B]

                        Get:14 http://security.ubuntu.com trusty-security/main amd64 Packages [588 kB]

                        Get:15 http://in.archive.ubuntu.com trusty-updates/universe amd64 Packages [399 kB]

                        Ign http://extras.ubuntu.com trusty/main Translation-en_IN                    

                        Get:16 http://security.ubuntu.com trusty-security/restricted amd64 Packages [13.4 kB]

                        Get:17 http://security.ubuntu.com trusty-security/universe amd64 Packages [153 kB]

                        Ign http://extras.ubuntu.com trusty/main Translation-en                       

                        Get:18 http://security.ubuntu.com trusty-security/multiverse amd64 Packages [4,139 B]

                        Get:19 http://in.archive.ubuntu.com trusty-updates/multiverse amd64 Packages [14.0 kB]

                        Get:20 http://security.ubuntu.com trusty-security/main i386 Packages [547 kB] 

                        Get:21 http://in.archive.ubuntu.com trusty-updates/main i386 Packages [916 kB]

                        Get:22 http://security.ubuntu.com trusty-security/restricted i386 Packages [13.1 kB]

                        Get:23 http://security.ubuntu.com trusty-security/universe i386 Packages [153 kB]

                        Get:24 http://in.archive.ubuntu.com trusty-updates/restricted i386 Packages [16.2 kB]

                        Get:25 http://in.archive.ubuntu.com trusty-updates/universe i386 Packages [400 kB]

                        Get:26 http://security.ubuntu.com trusty-security/multiverse i386 Packages [4,278 B]

                        Get:27 http://security.ubuntu.com trusty-security/main Translation-en [325 kB]

                        Get:28 http://security.ubuntu.com trusty-security/multiverse Translation-en [2,201 B]

                        Get:29 http://security.ubuntu.com trusty-security/restricted Translation-en [3,357 B]

                        Get:30 http://security.ubuntu.com trusty-security/universe Translation-en [89.5 kB]

                        Get:31 http://in.archive.ubuntu.com trusty-updates/multiverse i386 Packages [14.4 kB]

                        Get:32 http://in.archive.ubuntu.com trusty-updates/main Translation-en [473 kB]

                        Get:33 http://in.archive.ubuntu.com trusty-updates/multiverse Translation-en [7,340 B]

                        Get:34 http://in.archive.ubuntu.com trusty-updates/restricted Translation-en [3,847 B]

                        Get:35 http://in.archive.ubuntu.com trusty-updates/universe Translation-en [211 kB]

                        Hit http://in.archive.ubuntu.com trusty Release                               

                        Hit http://in.archive.ubuntu.com trusty-backports/main Sources                

                        Hit http://in.archive.ubuntu.com trusty-backports/restricted Sources          

                        Hit http://in.archive.ubuntu.com trusty-backports/universe Sources            

                        Hit http://in.archive.ubuntu.com trusty-backports/multiverse Sources          

                        Hit http://in.archive.ubuntu.com trusty-backports/main amd64 Packages         

                        Hit http://in.archive.ubuntu.com trusty-backports/restricted amd64 Packages   

                        Hit http://in.archive.ubuntu.com trusty-backports/universe amd64 Packages     

                        Hit http://in.archive.ubuntu.com trusty-backports/multiverse amd64 Packages   

                        Hit http://in.archive.ubuntu.com trusty-backports/main i386 Packages          

                        Hit http://in.archive.ubuntu.com trusty-backports/restricted i386 Packages    

                        Hit http://in.archive.ubuntu.com trusty-backports/universe i386 Packages      

                        Hit http://in.archive.ubuntu.com trusty-backports/multiverse i386 Packages    

                        Hit http://in.archive.ubuntu.com trusty-backports/main Translation-en         

                        Hit http://in.archive.ubuntu.com trusty-backports/multiverse Translation-en   

                        Hit http://in.archive.ubuntu.com trusty-backports/restricted Translation-en   

                        Hit http://in.archive.ubuntu.com trusty-backports/universe Translation-en     

                        Hit http://in.archive.ubuntu.com trusty/main Sources                          

                        Hit http://in.archive.ubuntu.com trusty/restricted Sources                    

                        Hit http://in.archive.ubuntu.com trusty/universe Sources                      

                        Hit http://in.archive.ubuntu.com trusty/multiverse Sources                    

                        Hit http://in.archive.ubuntu.com trusty/main amd64 Packages                   

                        Hit http://in.archive.ubuntu.com trusty/restricted amd64 Packages             

                        Hit http://in.archive.ubuntu.com trusty/universe amd64 Packages               

                        Hit http://in.archive.ubuntu.com trusty/multiverse amd64 Packages             

                        Hit http://in.archive.ubuntu.com trusty/main i386 Packages                    

                        Hit http://in.archive.ubuntu.com trusty/restricted i386 Packages              

                        Hit http://in.archive.ubuntu.com trusty/universe i386 Packages                

                        Hit http://in.archive.ubuntu.com trusty/multiverse i386 Packages              

                        Hit http://in.archive.ubuntu.com trusty/main Translation-en                   

                        Hit http://in.archive.ubuntu.com trusty/multiverse Translation-en             

                        Hit http://in.archive.ubuntu.com trusty/restricted Translation-en             

                        Hit http://in.archive.ubuntu.com trusty/universe Translation-en               

                        Ign http://in.archive.ubuntu.com trusty/main Translation-en_IN                

                        Ign http://in.archive.ubuntu.com trusty/multiverse Translation-en_IN          

                        Ign http://in.archive.ubuntu.com trusty/restricted Translation-en_IN          

                        Ign http://in.archive.ubuntu.com trusty/universe Translation-en_IN            

                        Fetched 6,215 kB in 21s (291 kB/s)                                            

                        Reading package lists... Done

                        apt-get install -y git make gcc gcc-multilib g++ libc6-dev-i386 g++-multilib python3-ply

                        Reading package lists... Done

                        Building dependency tree      

                        Reading state information... Done

                        g++ is already the newest version.

                        g++-multilib is already the newest version.

                        gcc is already the newest version.

                        gcc-multilib is already the newest version.

                        make is already the newest version.

                        python3-ply is already the newest version.

                        git is already the newest version.

                        libc6-dev-i386 is already the newest version.

                        0 upgraded, 0 newly installed, 0 to remove and 74 not upgraded.

                        dpkg --purge modemmanager

                        dpkg: warning: ignoring request to remove modemmanager which isn't installed

                        cp -f /root/CODK/CODK-Z//flashpack/drivers/rules.d/*.rules /etc/udev/rules.d/

                        service udev restart

                        stop: Unknown job: udev

                        start: Unknown job: udev

                        make: *** [install-dep] Error 1


                        I continued with the installation anyway and while trying to compile the "hello" i got the following error:

                        root@aerxlabs-Satellite-C850:~/CODK/CODK-Z# cd ..

                        root@aerxlabs-Satellite-C850:~/CODK# cd zephyr

                        root@aerxlabs-Satellite-C850:~/CODK/zephyr# source zephyr-env.sh

                        root@aerxlabs-Satellite-C850:~/CODK/zephyr# cd ..

                        root@aerxlabs-Satellite-C850:~/CODK# cd CODK-Z/arc/examples/hello

                        root@aerxlabs-Satellite-C850:~/CODK/CODK-Z/arc/examples/hello# make compile-arc

                        make[1]: Entering directory `/root/CODK/zephyr'

                        make[2]: Entering directory `/root/CODK/CODK-Z/arc/examples/hello/outdir'

                          GEN     ./Makefile

                        scripts/kconfig/conf --silentoldconfig Kconfig


                        *** Configuration file ".config" not found!


                        *** Please run some configurator (e.g. "make oldconfig" or

                        *** "make menuconfig" or "make xconfig").


                        make[4]: *** [silentoldconfig] Error 1

                        make[3]: *** [silentoldconfig] Error 2

                        make[2]: *** No rule to make target `compile-arc'.  Stop.

                        make[2]: Leaving directory `/root/CODK/CODK-Z/arc/examples/hello/outdir'

                        make[1]: *** [sub-make] Error 2

                        make[1]: Leaving directory `/root/CODK/zephyr'

                        make: *** [compile-arc] Error 2



                        These are the instructions i've been following till now, before trying to install the intel ODK:

                        https://www.zephyrproject.org/doc/getting_started/installation_win.html  (to install zephyr)

                        https://nexus.zephyrproject.org/content/sites/site/org.zephyrproject.zephyr/1.4.0/board/arduino_101.html (to compile and flash)

                        • 9. Re: GPIO pins not working properly on arduino101
                          Intel Corporation
                          This message was posted on behalf of Intel Corporation

                          I see, I haven't had any issues with the examples provided on the ODK. However, I believe I was able to find the issue in my compilation thanks to your post. I was compiling for x86 not arc. I just tested compiling your code for arc and there was no issue, not yet at least.

                          Please let me do some tests to see if I can replicate the issue. I will post all the steps I took and the results of my tests as soon as possible.

                          Also, I wanted to as you how you connected the serial monitor to your Arduino 101? Is it connected to the board's USB port or pins 0 and 1?

                          Pedro M.

                          • 10. Re: GPIO pins not working properly on arduino101

                            Hi, sorry for replying so late.

                            The serial monitor is connected via pins 0 and 1.

                            I Think its more of a problem with the configuration in the code and Zephyr environment than anything else.


                            Thanks for the help though. If you do find anything do let me know.

                            • 11. Re: GPIO pins not working properly on arduino101
                              Intel Corporation
                              This message was posted on behalf of Intel Corporation

                              I understand, thank you for letting us know. I'm still working on this, let me do some more testing and I'll get back to you as soon as possible.

                              Pedro M.

                              • 12. Re: GPIO pins not working properly on arduino101
                                Intel Corporation
                                This message was posted on behalf of Intel Corporation

                                Hi me_5,

                                I'm sorry it's taken so long to come back to you. I've a few questions for you.

                                Firstly, I can see from your code that you are using UART but I also noticed that you used ARC to compile. What confuses us is the information found at https://www.zephyrproject.org/doc/boards/x86/arduino_101/doc/board.html. Under supported features you will see that UART is not supported on ARC. So, this makes me believe you are in fact x86, so, we would you to answer us this questions:

                                1. Are you interested in using CODK-M, a combination of Arduino CoreLibs and Zephyr 1.6? Or, are you more interested in CODK-Z, straight Zephyr environment?
                                In case you are indeed interested in using the CODK-Z, I suggest you to go to contact the Zephyr team directly as they have the better information on their drivers. You can contact them at info@zephyrproject.org.
                                2. If you are indeed using the CODK-M, could you please clarify us if you are using the ARC Corelibs or the x86 Zephyr or both on your project? In addition, which core are you going to use to drive these pins?

                                Let me know.
                                Pedro M.

                                • 13. Re: GPIO pins not working properly on arduino101
                                  Intel Corporation
                                  This message was posted on behalf of Intel Corporation

                                  Hello me_5,

                                  Do you have any updates about this?

                                  Pedro M.

                                  • 14. Re: GPIO pins not working properly on arduino101
                                    Intel Corporation
                                    This message was posted on behalf of Intel Corporation

                                    Hello me_5,

                                    In case you still need help, please let us know by replying to this thread.

                                    We'll try to help you in any way we can.
                                    Pedro M.