Power & Source of Big Ideas

NanoPi Neo Plus2 WiringNP Not Working for all GPIOs

Moderators: chensy, FATechsupport

Hi,

Currently I am working with WiringNP (https://github.com/friendlyarm/WiringNP) and it is working great for the most part, however I need access to a lot of GPIOs and one is giving me a lot of trouble.

I have been trying to get GPIOL11 to work, this is BCM Pin 363 from what I have calculated. I have confirmed that this is what it should be by running it as an output in /sys/class/gpio/gpio363 using the following commands, in the folder that is created when exported:

Code: Select all

echo "out" > direction
echo 1 > value


Now that is working I decided to try and run it with WiringNP using the following setups:

Code: Select all

wiringPiSetupGpio();
wiringPiSetupSys();


Neither of these worked when writing to GPIOL11 (BCM 363), though i was able to get it to work for the pin beside it GPIOA17 (BCM 17). and then it wouldn't work for GPIOG8 (BCM 200). What I have actually found from this is that it doesn't seem to work for anything besides GPIOA#. Which sort of confirms itself when I use the "gpio" commands. When I do the command "gpio exports" it only ever shows GPIOA# pins. Even when I try the command "gpio export 200 out" or "gpio export 363 out".

My feeling is that this is actually something to do with the source code that is stopping it, I have already spent quite some time looking through it. Through this looking I did find a few things to improve the functionality. This was that GPIOA17 and GPIOL11 has not been configured to work with wPi output numbers or Physical output numbers. These changes can be made in this file https://github.com/friendlyarm/WiringNP ... wiringPi.c . For example, if we were to give the pins a wPi value, meaning that it will make them usable with the "wiringPiSetup()", we do the following:

Code: Select all

static int pinToGpio_neo [64] ={
    0,        //0
 /* 24 Pin */
   6, 2,   //1, 2
   3, 200,   //3, 4
   201, 1,   //5, 6
    203, 12, //7, 8
   11,  67, //9, 10
    -1,  64,   //11, 12
    65,  66,  //13, 14
    198,  199,  //15, 16
   4, 5,  //17, 18
   17, 363,   //19, 20 <--changed the values from -1, -1 to 17, 363 (GPIOA17, and GPIOL11)
    -1, 1,    //21, 22
    -1, -1,   //23, 24

    /* 12 Pin */
    -1, -1,   //25, 26
    -1, -1,   //27, 28
    -1, -1,   //29, 30
    -1, -1,   //31, 32
    -1, -1,   //33, 34
    -1, -1,   //35, 36

    /* UART0 Tx,Rx */
    -1, -1,     //37, 38

    /* 39~63 */
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};


Now doing that allowed me to use wPi 19 for my GPIOA17, however wPi 20 did not work for my GPIOL11. Also interestingly it can be seen that BCM 200 is actually mapped here to wPi 4, and it does work in the program (even though it didn't with using it in the Sys and Gpio setup mode).

So thanks to anyone who can help me! And for the mapping I thinking this would be a good things to be updated sometime in the repo.

Thanks,
Dylan
Hello,

Thanks for your detailed description. I got a similar difficulties with my nanopi neo air, and I think some of your observations are wrong (similarly to my own bad experience), let me argument. I could be wrong because I don't have H5 and discover NanoPi_NEO_Plus2.

From schematic at http://wiki.friendlyarm.com/wiki/images ... 0-1704.pdf, I found GPIOL11/IR-RX is related to infrared reception (do a search in PDF "GPIOL11") on CON2 (this is a connector with two USB pinsets).
And SPDIF-OUT/GPIOA17 is neighbour on CON2. I think you tried to manage pinout on CON1 (24pins), you are lost on the CON2.

From mapping found in http://wiki.friendlyarm.com/wiki/index. ... _Dimension
It looks nanopi neo air and your have the same mapping. But your "static int pinToGpio_neo [64] =" does not look the same as my port of RPi.GPIO_NP (this is WiringPi basically but for python).

I used this mapping https://github.com/auto3000/RPi.GPIO_NP ... b230ac92a7 The internal pinout mapping of the two software WiringPI_NP/RPi.GPIO_NP are "opposite", but you can compare them in doubt. Hope this helps.
Hi,

Thanks for the reply. I will write a reply to each of you comments on what my thoughts are. *Just a note that this may be a little less to the point, because this is my 2nd time trying to write this, as when I went to post what I originally had it signed me out :cry: So note to self, always save/copy posts somewhere else before attempting to submit.

From schematic at http://wiki.friendlyarm.com/wiki/images ... 0-1704.pdf, I found GPIOL11/IR-RX is related to infrared reception (do a search in PDF "GPIOL11") on CON2 (this is a connector with two USB pinsets).
And SPDIF-OUT/GPIOA17 is neighbour on CON2. I think you tried to manage pinout on CON1 (24pins), you are lost on the CON2.


So for this I see what you are thinking, but what I wrote in my first post is for wPi, so it is custom mapping, so it won't matter where it is. Also A17 on CON2 works with that mapping to wPi numbers. I also changed it another spot that is supposed to be mapped to physical pins as seen below, so this I put it in the physical pin position number which might be more what you are thinking (See response to 3rd comment below):

Code: Select all

static int physToGpio_neo [64] ={
    -1,
    /* 24 Pin */
    -1, -1,   //1, 2
    12, -1,   //3, 4
    11, -1,   //5, 6
    203, 198, //7, 8
    -1,  199, //9, 10
    0,   6,   //11, 12
    2,   -1,  //13, 14
    3,  200,  //15, 16
    -1, 201,  //17, 18
    64, -1,   //19, 20
    65, 1,    //21, 22
    66, 67,   //23, 24

    /* 12 Pin */
    -1, -1,   //25, 26
    -1, -1,   //27, 28
    -1, 363,   //29, 30 <--changed L11
    17, -1,   //31, 32 <-- changed A17
    -1, -1,   //33, 34
    -1, -1,   //35, 36

    /* UART0 Tx,Rx */
    4, 5,     //37, 38

    /* 39~63 */
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};


Again only GPIOA17 worked using the new physical pin mapping. Though i did realize they both gave me this error

Code: Select all

line:894 pin(363) number error


Which I actually realized I could fix, as the reason was that it couldn't find a value in the array:

Code: Select all

static int BP_PIN_MASK[12][32] = //[BANK]  [INDEX]<--changed to [12][32] from [9][32]
{
    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, //PA
    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, //PB
    { 0, 1, 2, 3, -1, -1, -1, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, //PC
    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, //PD
    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, //PE
    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, //PF
    {-1, -1, -1, -1, -1, -1, 6, 7, 8, 9, -1, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, //PG
    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, //PH
    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, //PI
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, //PJ<--Added
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,}, //PK<--Added
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,} //PL <--Added w/11
};


This fixed the problem with the error but it still didn't make GPIOL11 work. Though this does lead me to believe it is something in this file or one of the other sources files causing the problem. As it is clear from basically everything they didn't consider CON2 (12 pins). Was there a reason why maybe? But that doesn't make sense as A17 is usable.

From mapping found in http://wiki.friendlyarm.com/wiki/index. ... _Dimension
It looks nanopi neo air and your have the same mapping. But your "static int pinToGpio_neo [64] =" does not look the same as my port of RPi.GPIO_NP (this is WiringPi basically but for python).


So I will answer your comment about the Air having the same mapping here, and the one about the "static int pinToGpio_neo [64] =" below.

So yes you are correct same, pin layout, and it is shown in the code that it will use the same stuff:

Code: Select all

else if (boardId == NanoPi_NEO || boardId == NanoPi_NEO_Air || boardId == NanoPi_NEO2 || boardId == NanoPi_NEO_Plus2) {
        pinToGpio = pinToGpio_neo;
        physToGpio = physToGpio_neo;
        physToPin = physToPin_neo;
    }


I used this mapping https://github.com/auto3000/RPi.GPIO_NP ... b230ac92a7 The internal pinout mapping of the two software WiringPI_NP/RPi.GPIO_NP are "opposite", but you can compare them in doubt. Hope this helps.


As for it "static int pinToGpio_neo [64] =" being different. Yes they are but the one in your code"pin_to_gpio_nanopi " is actually the same as the "physToGpio_neo [64] =" that I just put above. The one I had in my first post was for the wPi number layout(totally random. The Phys one is exactly matching the Physical pins.

I hope this clears everything up. Sorry if it isn't as clear (this is the 2nd time I wrote this, and did not want to spend as much time).

So let me know if you find a solution for getting GPIOL11 with your Python library, this will likely be the same for mine. I will keep looking through the source code later on, but right now I am writing a NodeJS Add-on to be able to use with this. I will share that info here at some point when I am done.

Thanks,
Dylan

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 42 on 15 Jul 2016, 01:04

Users browsing this forum: No registered users and 2 guests