Jump to content

Recommended Posts

Posted

So I'm working on a generic way to do MMIO GPIO on Armbian and chatting with @diozeroit seems like a wiringPi implementation is a good place to start for ideas.  Armbian supports many FriendlyArm boards, so I took a look at https://github.com/friendlyarm/WiringNP. Of course out of the box it fails because it's probing for things found only in its home made OS distros. I found a way to hack the getBoardType function to hard code your board type for Armbian and probably other distros. This will work only on the board you hack it for. Honestly there should have been a way to pass in a parameter to override the detection code. In any event here's the method to use.

 

Look up your board in BoardHardwareInfo in my case it's a NanoPi Duo, so I'd use this. Since arrays are zero based it falls on element 32. Now I hack getBoardType and right after that line add:

*retBoardInfo = &gAllBoardHardwareInfo[32];
return gAllBoardHardwareInfo[32].boardTypeId;

Then follow normal build instructions here.

gpio readall
 +-----+-----+----------+------+---+-NanoPi-Duo--+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |    MIC_N |      |   |  1 || 2  |   |      | EPhySPD  |     |     |
 |     |     |    MIC_P |      |   |  3 || 4  |   |      | EPhyLinK |     |     |
 |     |     | LineOutR |      |   |  5 || 6  |   |      | EPhyTXP  |     |     |
 |     |     | LineOutL |      |   |  7 || 8  |   |      | EPhyTXN  |     |     |
 |     |     |     CVBS |      |   |  9 || 10 |   |      | EPhyRXP  |     |     |
 | 198 |   8 |   GPIOG6 | ALT5 | 0 | 11 || 12 |   |      | EPhyRXN  |     |     |
 | 199 |   9 |   GPIOG7 | ALT5 | 0 | 13 || 14 |   |      | USB-DP2  |     |     |
 |  15 |   7 |  GPIOA15 | ALT5 | 0 | 15 || 16 |   |      | USB-DM2  |     |     |
 |  16 |   0 |  GPIOA16 | ALT5 | 0 | 17 || 18 |   |      | USB-DP3  |     |     |
 |  14 |   2 |  GPIOA14 | ALT5 | 0 | 19 || 20 |   |      | USB-DM3  |     |     |
 |  13 |   3 |  GPIOA13 | ALT5 | 0 | 21 || 22 | 0 |  OFF | GPIOG11  | 16  | 203 |
 |  12 |  12 |  GPIOA12 | ALT5 | 0 | 23 || 24 | 0 |   IN | GPIOL11  | 18  | -1  |
 |  11 |  13 |  GPIOA11 | ALT5 | 0 | 25 || 26 |   |      | 0v       |     |     |
 |     |     |       0v |      |   | 27 || 28 |   |      | 3.3v     |     |     |
 |   4 |  14 |   GPIOA4 | ALT5 | 0 | 29 || 30 |   |      | 5v       |     |     |
 |   5 |  15 |   GPIOA5 | ALT4 | 0 | 31 || 32 |   |      | 5v       |     |     |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |
 +-----+-----+----------+------+---+-NanoPi-Duo--+------+----------+-----+-----+

If you search there were other solutions by using /etc/sys_info, but I was too lazy to create that file.

  • lanefu featured this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines