Jump to content

FriendlyArm wiringPi on Armbian


sgjava

Recommended Posts

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.

Link to comment
Share on other sites

  • lanefu featured this topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines