Skip to content

Commit

Permalink
Support Orange Pi 5
Browse files Browse the repository at this point in the history
  • Loading branch information
orangepi-xunlong committed Dec 2, 2022
1 parent c569021 commit 8ea28b3
Show file tree
Hide file tree
Showing 19 changed files with 3,999 additions and 5,744 deletions.
104 changes: 0 additions & 104 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -43,108 +43,6 @@ check_make_ok() {
fi
}

select_boards()
{
local cnt=0
local choice
local call=${1}

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"
"orangepir1plus-lts"
"orangepir1plus")

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

else

printf "All available boards:\n"
for var in ${boards[@]} ; do
printf "%4d. %s\n" $cnt ${boards[$cnt]}
((cnt+=1))
done

while true ; do
read -p "Choice: " choice
if [ -z "${choice}" ] ; then
continue
fi
if [ -z "${choice//[0-9]/}" ] ; then
if [ $choice -ge 0 -a $choice -lt $cnt ] ; then
export BOARD="${boards[$choice]}"
break
fi
fi
printf "Invalid input ...\n"
done
fi

[[ $BOARD == orangepir1 ]] && BOARD=orangepir1-h2
[[ $BOARD == orangepizero ]] && BOARD=orangepizero-h2
[[ $BOARD == orangepizero-lts ]] && BOARD=orangepizero-h2
[[ $BOARD == orangepipc ]] && BOARD=orangepipc-h3
[[ $BOARD == orangepipch5 ]] && BOARD=orangepipc-h3
[[ $BOARD == orangepipcplus ]] && BOARD=orangepipcplus-h3
[[ $BOARD == orangepiplus2e ]] && BOARD=orangepiplus2e-h3
[[ $BOARD == orangepione ]] && BOARD=orangepione-h3
[[ $BOARD == orangepioneh5 ]] && BOARD=orangepione-h3
[[ $BOARD == orangepilite ]] && BOARD=orangepilite-h3
[[ $BOARD == orangepiplus ]] && BOARD=orangepiplus-h3
[[ $BOARD == orangepizeroplus ]] && BOARD=orangepizeroplus-h5
[[ $BOARD == orangepipc2 ]] && BOARD=orangepipc2-h5
[[ $BOARD == orangepiprime ]] && BOARD=orangepiprime-h5
[[ $BOARD == orangepiwin ]] && BOARD=orangepiwin-a64
[[ $BOARD == orangepiwinplus ]] && BOARD=orangepiwinplus-a64
[[ $BOARD == orangepi3 ]] && BOARD=orangepi3-h6
[[ $BOARD == orangepi3-lts ]] && BOARD=orangepi3-h6
[[ $BOARD == orangepilite2 ]] && BOARD=orangepilite2-h6
[[ $BOARD == orangepioneplus ]] && BOARD=orangepioneplus-h6
[[ $BOARD == orangepizero2 ]] && BOARD=orangepizero2-h616
[[ $BOARD == orangepizero2-lts ]] && BOARD=orangepizero2-h616
[[ $BOARD == orangepizero2-b ]] && BOARD=orangepizero2-h616
[[ $BOARD == orangepir1plus ]] && BOARD=orangepir1plus-rk3328
[[ $BOARD == orangepir1plus-lts ]] && BOARD=orangepir1plus-rk3328

export BOARD="${BOARD}"
}

sudo=${WIRINGPI_SUDO-sudo}

if [ x$1 = "xclean" ]; then
Expand Down Expand Up @@ -210,8 +108,6 @@ if [ x$1 != "x" ]; then
exit 1
fi

select_boards

echo "wiringPi Build script"
echo "====================="
echo
Expand Down
2 changes: 1 addition & 1 deletion debian-template/wiringPi/DEBIAN/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: wiringPi
Version: 2.46
Section: libraries
Priority: optional
Architecture: armhf
Architecture: arm64
Depends: libc6
Maintainer: Boby Lee <[email protected]>
Description: The wiringPi libraries for the OrangePi, headers and gpio command
Expand Down
6 changes: 3 additions & 3 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ Build-Depends: debhelper (>= 8)

Package: libwiringpi2
Section: libs
Architecture: armhf
Architecture: arm64
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: GPIO librariees for Raspberry Pi (runtime).
Runtime for the popular wiringPi library.

Package: wiringpi
Architecture: armhf
Architecture: arm64
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: gpio utility for Raspberry Pi
The wiringPi gpio command line utility, for GPIO access on a
Raspberry Pi from the command line.

Package: libwiringpi-dev
Architecture: armhf
Architecture: arm64
Depends: libwiringpi2 (= ${binary:Version}), libc6-dev, ${misc:Depends}
Suggests: wiringpi
Description: GPIO development library for Raspberry Pi
Expand Down
64 changes: 51 additions & 13 deletions examples/blink.c
Original file line number Diff line number Diff line change
@@ -1,30 +1,68 @@
#include <stdio.h>
#include <wiringPi.h>

#define NUM 17 //26pin
//#define NUM 18 //26pin
//#define NUM 20 //for Orange Pi Zero 2
//#define NUM 19 //for Orange Pi 4
//#define NUM 28 //40pin
unsigned char getGpioNum(void)
{
int model = -1;

piBoardId (&model);

switch (model)
{
case PI_MODEL_3:
case PI_MODEL_LTIE_2:
case PI_MODEL_ZERO:
case PI_MODEL_ZERO_PLUS_2:
case PI_MODEL_ZERO_PLUS:
case PI_MODEL_4_LTS:
case PI_MODEL_800:
case PI_MODEL_5:
return 17;
break;
case PI_MODEL_ZERO_2:
return 21;
break;
case PI_MODEL_WIN:
case PI_MODEL_PRIME:
case PI_MODEL_PC_2:
case PI_MODEL_H3:
case PI_MODEL_RK3399:
case PI_MODEL_4:
return 28;
break;
case PI_MODEL_R1_PLUS:
return 8;
break;
default:
printf ("Oops - unable to determine board type... model: %d\n", model);
return -1;
break;
}
}

int main (void)
{
int i = 0;
unsigned char gpio_num = 0;

wiringPiSetup();

wiringPiSetup () ;
gpio_num = getGpioNum();
if (-1 == gpio_num)
printf("Failed to get the number of GPIO!\n");

for (i = 0; i < NUM; i++)
for (i = 0; i < gpio_num; i++)
pinMode (i, OUTPUT) ;

for ( ;; )
{
for (i = 0; i < NUM; i++)
digitalWrite (i, HIGH) ; // On
delay (2000) ; // mS
for (i = 0; i < gpio_num; i++)
digitalWrite (i, HIGH); // On
delay (2000);

for (i = 0; i < NUM; i++)
digitalWrite (i, LOW) ; // Off
delay (2000) ;
for (i = 0; i < gpio_num; i++)
digitalWrite (i, LOW); // Off
delay (2000);
}

return 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/w25q64_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include <string.h>
#include "w25q64.h"

#define SPI_CHANNEL 0 // /dev/spidevX.0
#define SPI_CHANNEL 4 // /dev/spidevX.0
//#define SPI_CHANNEL 1 // /dev/spidevX.0

#define SPI_PORT 0
#define SPI_PORT 1
//#define SPI_PORT 1

void dump(uint8_t *dt, uint32_t n) {
Expand Down
76 changes: 1 addition & 75 deletions gpio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,84 +39,10 @@ CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe
LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib
LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt

ifeq ($(BOARD),)
BOARD = orangepioneplus-h6
endif

ifeq ($(BOARD), orangepi2giot)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_2G_IOT
endif

ifneq ($(findstring $(BOARD), "orangepione-h3" "orangepilite-h3" "orangepipc-h3" "orangepiplus-h3" "orangepipcplus-h3" "orangepiplus2e-h3"),)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_H3
endif

ifeq ($(BOARD), orangepipc2-h5)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PC2
endif

ifeq ($(BOARD), orangepiprime-h5)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PRIME
endif

ifeq ($(BOARD), orangepizeroplus-h5)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS
endif

ifneq ($(findstring $(BOARD), "orangepiwin-a64" "orangepiwinplus-a64"),)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_WIN
endif

ifneq ($(findstring $(BOARD), "orangepizero-h2" "orangepir1-h2"),)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZERO
endif

ifneq ($(findstring $(BOARD), "orangepioneplus-h6" "orangepilite2-h6"),)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_LITE2
endif

ifeq ($(BOARD), orangepi3-h6)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_3
endif

ifeq ($(BOARD), orangepizero2-h616)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZERO2
endif

ifeq ($(BOARD), orangepizeroplus2h3)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H3
endif

ifeq ($(BOARD), orangepizeroplus2h5)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H5
endif

ifeq ($(BOARD), orangepirk3399)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_RK3399
endif

ifeq ($(BOARD), orangepi4)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_4
endif

ifeq ($(BOARD), orangepi4-lts)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_4_LTS
endif

ifeq ($(BOARD), orangepi800)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_800
endif

ifeq ($(BOARD), orangepir1plus-rk3328)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_R1PLUS
endif

EXTRA_CFLAGS += -DCONFIG_ORANGEPI

# May not need to alter anything below this line
###############################################################################

SRC = gpio.c readall.c OrangePi.c
SRC = gpio.c readall.c

OBJ = $(SRC:.c=.o)

Expand Down
Loading

0 comments on commit 8ea28b3

Please sign in to comment.