Jump to content

I teach how to install WiringOP on Armbian


Namexx

Recommended Posts

Hello everyone! I will teach you how to install WiringOP on Armbian. It's not the most practical method, but it works.

 

First, we download the repository from the original website.

$ apt-get update
$ apt-get install -y git
$ git clone https://github.com/orangepi-xunlong/wiringOP.git

 

Then, we proceed to look for the name of our board that is associated with Armbian.

$ cat /etc/armbian-release | grep "BOARD=" | awk -F'=' '{print $2}'

 

The previous command will give us the name of the board, which is the following:

root@armbian:~# cat /etc/armbian-release | grep "BOARD=" | awk -F'=' '{print $2}'
orangepi-r1plus-lts

 

Now, we proceed to go to the WiringOP folder downloaded from Git, and we will modify the "build" file by adding the name of the board in 2 sections.

$ sudo nano wiringOP/build

 

Inside the "build" file, we will look for the following variable:

 boards=("orangepir1"
                "orangepizero"
                "orangepizero-lts"
                "orangepipc"
                "orangepipch5"
                "orangepipcplus"
                "orangepiplus2e"
                "orangepione"
                "orangepioneh5"
                "orangepilite"
                "orangepiplus"
                "orangepizeroplus2h3"
                "orangepizeroplus"
                "orangepipc2"
                "orangepiprime"
                "orangepizeroplus2h5"
                "orangepiwin"
                "orangepiwinplus"
                "orangepi3"
                "orangepi3-lts"
                "orangepilite2"
                "orangepioneplus"
                "orangepi4"
                "orangepi4-lts"
                "orangepirk3399"
                "orangepi800"
                "orangepizero2"
                "orangepizero2-lts"
                "orangepizero2-b"
                "orangepizero3"
                "orangepir1plus-lts"
                "orangepir1plus"}

 

At the end of this variable, we add the board ID that we obtained before. It will look like this after adding the board ID:

        boards=("orangepir1"
                "orangepizero"
                "orangepizero-lts"
                "orangepipc"
                "orangepipch5"
                "orangepipcplus"
                "orangepiplus2e"
                "orangepione"
                "orangepioneh5"
                "orangepilite"
                "orangepiplus"
                "orangepizeroplus2h3"
                "orangepizeroplus"
                "orangepipc2"
                "orangepiprime"
                "orangepizeroplus2h5"
                "orangepiwin"
                "orangepiwinplus"
                "orangepi3"
                "orangepi3-lts"
                "orangepilite2"
                "orangepioneplus"
                "orangepi4"
                "orangepi4-lts"
                "orangepirk3399"
                "orangepi800"
                "orangepizero2"
                "orangepizero2-lts"
                "orangepizero2-b"
                "orangepizero3"
                "orangepir1plus-lts"
                "orangepir1plus"
                "orangepi-r1plus-lts") #<- Here, the board ID was added.

 

 

 

Now, further down in the "Build" file, we will look for the following:

        if [[ -f /etc/orangepi-release ]]; then

                source /etc/orangepi-release

        elif [[ -f /etc/armbian-release ]]; then

                source /etc/armbian-release
                [[ $BOARD == orangepi-r1 ]] && BOARD=orangepir1
                [[ $BOARD == orangepi-rk3399 ]] && BOARD=orangepirk3399
                [[ $BOARD == orangepizeroplus2-h3 ]] && BOARD=orangepizeroplus2h3
                [[ $BOARD == orangepizeroplus2-h5 ]] && BOARD=orangepizeroplus2h5
                						#----->Here new board<--------------- 
        else

 

In the brand section of the code above, we will place the following code.

 

Replace [board_id_goes_here] with the actual board ID that we obtained at the beginning of the tutorial.

 

[[board_id_goes_here]] && BOARD=orangepir1plus-rk3328

 

After making the modifications, it will look like this:

        if [[ -f /etc/orangepi-release ]]; then

                source /etc/orangepi-release

        elif [[ -f /etc/armbian-release ]]; then

                source /etc/armbian-release
                [[ $BOARD == orangepi-r1 ]] && BOARD=orangepir1
                [[ $BOARD == orangepi-rk3399 ]] && BOARD=orangepirk3399
                [[ $BOARD == orangepizeroplus2-h3 ]] && BOARD=orangepizeroplus2h3
                [[ $BOARD == orangepizeroplus2-h5 ]] && BOARD=orangepizeroplus2h5
                [[ $BOARD == orangepi-r1plus-lts ]] && BOARD=orangepir1plus-rk3328
        else

 

 

The last parameter can be modified with a different board, in case of using other versions of OrangePi. You just need to look for the corresponding one in the same "build" file, and replace only the board ID.

 

Now we can close the file and proceed to apply ./build clean and ./build. However, the current version of OrangePi r1+LTS officially has a problem that we will also fix next.

$ sudo nano wiringOP/wiringPi/OrangePi.h

 

 

Inside the file, some #define statements need to be added to resolve the conflicts they are causing. Hopefully, Xunlong will fix this issue in the future. For now, we will apply a patch as I haven't been able to find where to obtain these GPIO_BASE.

 

Inside the file "Orangepi.h," we will look for the following

//csy 2019.1.8


/*********** OrangePi R1PLUS *************/
#if CONFIG_ORANGEPI_R1PLUS

#define GPIO2_BASE                                                      0xff230000
#define GPIO3_BASE                                                      0xff240000
#define GPIO_NUM                                (0x40)

#define GPIO_SWPORTA_DR_OFFSET                          0x00
#define GPIO_SWPORTA_DDR_OFFSET                         0x04
#define GPIO_EXT_PORTA_OFFSET                           0x50

#define GRF_BASE                                                        0xff100000
#define GRF_GPIO2A_IOMUX_OFFSET                         0x20
#define GRF_GPIO2BL_IOMUX_OFFSET                        0x24
#define GRF_GPIO2BH_IOMUX_OFFSET                        0x28
#define GRF_GPIO2CL_IOMUX_OFFSET                        0x2c
#define GRF_GPIO2CH_IOMUX_OFFSET                        0x30
#define GRF_GPIO2D_IOMUX_OFFSET                         0x34

#define GRF_GPIO3AL_IOMUX_OFFSET                        0x38
#define GRF_GPIO3AH_IOMUX_OFFSET                        0x3c
#define GRF_GPIO3BL_IOMUX_OFFSET                        0x40
#define GRF_GPIO3BH_IOMUX_OFFSET                        0x44
#define GRF_GPIO3C_IOMUX_OFFSET                         0x48
#define GRF_GPIO3D_IOMUX_OFFSET                         0x4c

 

We will modify this to make it look like the following:

#endif /* CONFIG_ORANGEPI_RK3399 */
//csy 2019.1.8


/*********** OrangePi R1PLUS *************/
#if CONFIG_ORANGEPI_R1PLUS

#define GPIO2_BASE                                                      0xff230000
#define GPIO3_BASE                                                      0xff240000
#define GPIO_NUM                                (0x40)

#define GPIOL_BASE                              (0x0)  #New lines added.
#define GPIO_BASE_MAP                          (0x0)   #New lines added.

#define GPIO_SWPORTA_DR_OFFSET                          0x00
#define GPIO_SWPORTA_DDR_OFFSET                         0x04
#define GPIO_EXT_PORTA_OFFSET                           0x50

#define GRF_BASE                                                        0xff100000
#define GRF_GPIO2A_IOMUX_OFFSET                         0x20
#define GRF_GPIO2BL_IOMUX_OFFSET                        0x24
#define GRF_GPIO2BH_IOMUX_OFFSET                        0x28
#define GRF_GPIO2CL_IOMUX_OFFSET                        0x2c
#define GRF_GPIO2CH_IOMUX_OFFSET                        0x30
#define GRF_GPIO2D_IOMUX_OFFSET                         0x34

#define GRF_GPIO3AL_IOMUX_OFFSET                        0x38
#define GRF_GPIO3AH_IOMUX_OFFSET                        0x3c
#define GRF_GPIO3BL_IOMUX_OFFSET                        0x40
#define GRF_GPIO3BH_IOMUX_OFFSET                        0x44
#define GRF_GPIO3C_IOMUX_OFFSET                         0x48
#define GRF_GPIO3D_IOMUX_OFFSET                         0x4c

#define CRU_BASE                                                        0xff440000
#define CRU_CLKGATE_CON16_OFFSET                        0x0240    //bit 7 8 9 10 9877

 

We save the changes and apply build clean and build.

 

The result is:

root@armbian:~/wiringOP# gpio readall
 +------+-----+----------+------+---+ R1 Plus  +---+---+--+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | GPIO |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
 |      |     | 5V       |      |   |  1 || 2  |   |      | GND      |     |      |
 |   89 |   0 | SDA.0    | ALT2 | 1 |  3 || 4  | 1 | ALT2 | SCK.0    | 1   | 88   |
 |  100 |   2 | TXD.1    | ALT5 | 1 |  5 || 6  | 1 | ALT5 | RXD.1    | 3   | 102  |
 |      |     |          |      |   |  7 || 8  |   |      |          |     |      |
 |      |     |          |      |   |  9 || 10 | 1 | ALT3 | GPIO3_C0 | 4   | 112  |
 |  103 |   5 | CTS.1    | ALT5 | 1 | 11 || 12 | 1 | ALT5 | RTS.1    | 6   | 101  |
 |   66 |   7 | GPIO2_A2 |   IN | 1 | 13 || 14 |   |      |          |     |      |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | GPIO |
 +------+-----+----------+------+---+ R1 Plus  +---+---+--+----------+-----+------+
root@armbian:~/wiringOP#

 

Edited by Namexx
Link to comment
Share on other sites

I did try to follow this instruction with a OrangePiOne, but it fails at:

Quote

 

Now, we proceed to go to the WiringOP folder downloaded from Git, and we will modify the "build" file by adding the name of the board in 2 sections.

$ sudo nano wiringOP/build

 

My fresh build file (on a fresh Armbian install) simply do not contain anything like what is shown in this instruction.

 

If I just try to build what I got it gives some warnings and what not:

Quote

 

user@orangepione:~/wiringOP$ ./build clean
wiringPi:   [Clean]
DevLib:     [Clean]
gpio:       [Clean]
Examples:   [Clean]
Gertboard:  [Clean]
PiFace:     [Clean]
Quick2Wire: [Clean]
PiGlow:     [Clean]
scrollPhat: [Clean]
Deb:
user@orangepione:~/wiringOP$ ./build
wiringPi Build script
=====================


WiringPi Library
[UnInstall]
[Compile] wiringPi.c
[Compile] wiringSerial.c
[Compile] wiringShift.c
[Compile] piHiPri.c
[Compile] piThread.c
[Compile] wiringPiSPI.c
[Compile] wiringPiI2C.c
[Compile] softPwm.c
[Compile] softTone.c
[Compile] mcp23008.c
wiringPi.c: In function ‘orangepi_pwm_set_act’:
[Compile] mcp23016.c
wiringPi.c:3675:37: warning: comparison of integer expressions of different signedness: ‘int’ and ‘uint32_t’ {aka ‘unsigned int’} [-Wsign-compare]
 3675 |                         if (act_cys >= pwm_period || act_cys < 0)
      |                                     ^~
[Compile] mcp23017.c
wiringPi.c: In function ‘orangepi_get_gpio_mode’:
wiringPi.c:6212:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 6212 |                                                 if (index >= 0 && index <= 11)
      |                                                           ^~
wiringPi.c:6232:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 6232 |                                                 if (index >= 0 && index <= 1)
      |                                                           ^~
wiringPi.c:6258:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 6258 |                                                 if (index >= 0 && index <= 7)
      |                                                           ^~
wiringPi.c:6266:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 6266 |                                                 if (index >= 0 && index <= 1)
      |                                                           ^~
wiringPi.c:6273:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 6273 |                                                 if (index >= 0 && index <= 1)
      |                                                           ^~
wiringPi.c:6281:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 6281 |                                                 if (index >= 0 && index <= 19)
      |                                                           ^~
[Compile] mcp23s08.c
wiringPi.c: In function ‘orangepi_set_gpio_mode’:
wiringPi.c:7349:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 7349 |                                                 if (index >= 0 && index <= 11)
      |                                                           ^~
wiringPi.c:7369:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 7369 |                                                 if (index >= 0 && index <= 1)
      |                                                           ^~
wiringPi.c:7381:60: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 7381 |                                                 if( (index >= 0 && index <=1) && PWM_OUTPUT == mode )
      |                                                            ^~
wiringPi.c:7399:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 7399 |                                                 if (index >= 0 && index <= 7)
      |                                                           ^~
wiringPi.c:7408:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 7408 |                                                 if (index >= 0 && index <= 1)
      |                                                           ^~
wiringPi.c:7415:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 7415 |                                                 if (index >= 0 && index <= 1)
      |                                                           ^~
wiringPi.c:7424:59: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits]
 7424 |                                                 if (index >= 0 && index <= 19)
      |                                                           ^~
wiringPi.c: In function ‘rk3588_set_pwm_reg’:
wiringPi.c:6584:41: warning: this statement may fall through [-Wimplicit-fallthrough=]
 6584 |                                         printf("You can select wiringPi pin 0/2/5/8/9/10/14/16 for PWM pin.\n");
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wiringPi.c:6585:33: note: here
 6585 |                                 case PI_MODEL_5B:
      |                                 ^~~~
[Compile] mcp23s17.c
[Compile] sr595.c
[Compile] pcf8574.c
[Compile] pcf8591.c
[Compile] mcp3002.c
[Compile] mcp3004.c
[Compile] mcp4802.c
[Compile] mcp3422.c
[Compile] max31855.c
[Compile] max5322.c
[Compile] ads1115.c
[Compile] sn3218.c
[Compile] bmp180.c
[Compile] htu21d.c
[Compile] ds18b20.c
[Compile] rht03.c
[Compile] drcSerial.c
[Compile] drcNet.c
[Compile] pseudoPins.c
[Compile] wpiExtensions.c
[Compile] w25q64.c
[Compile] oled.c
[Link (Dynamic)]
[Install Headers]
[Install Dynamic Lib]

WiringPi Devices Library
[UnInstall]
[Compile] ds1302.c
[Compile] maxdetect.c
[Compile] piNes.c
[Compile] gertboard.c
[Compile] piFace.c
[Compile] lcd128x64.c
[Compile] lcd.c
[Compile] scrollPhat.c
[Compile] piGlow.c
[Link (Dynamic)]
[Install Headers]
[Install Dynamic Lib]

GPIO Utility
[Compile] gpio.c
[Compile] readall.c
gpio.c: In function ‘doUsbP’:
gpio.c:944:25: warning: unused parameter ‘argc’ [-Wunused-parameter]
  944 | static void doUsbP (int argc, char *argv [])
      |                     ~~~~^~~~
gpio.c:944:37: warning: unused parameter ‘argv’ [-Wunused-parameter]
  944 | static void doUsbP (int argc, char *argv [])
      |                               ~~~~~~^~~~~~~
readall.c: In function ‘OrangePiReadAll’:
readall.c:2287:25: warning: this statement may fall through [-Wimplicit-fallthrough=]
 2287 |                         printf (" +------+-----+----------+--------+---+  AI PRO  +---+--------+----------+-----+------+\n");
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
readall.c:2288:17: note: here
 2288 |                 case PI_MODEL_RV:
      |                 ^~~~
[Link]
[Install]
chown: warning: '.' should be ':': ‘root.root’

All Done.

NOTE: To compile programs with wiringPi, you need to add:
    -lwiringPi
  to your compile line(s) To use the Gertboard, MaxDetect, etc.
  code (the devLib), you need to also add:
    -lwiringPiDev
  to your compile line(s).

 

 

Link to comment
Share on other sites

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