From 210a69233973ea9470ded05a6bde38dd4da95e42 Mon Sep 17 00:00:00 2001 From: leeboby Date: Mon, 15 Jun 2020 11:23:49 +0800 Subject: [PATCH] orangepi-release is used to select the model of the board --- build | 63 ++++++++++++++++--------- examples/blink.c | 5 +- gpio/Makefile | 117 ++++++++-------------------------------------- gpio/OrangePi.c | 1 - wiringPi/Makefile | 111 +++++++------------------------------------ 5 files changed, 81 insertions(+), 216 deletions(-) diff --git a/build b/build index bed3864..6e35079 100755 --- a/build +++ b/build @@ -49,29 +49,46 @@ select_boards() local choice local call=${1} - boards=("OrangePi_R1" "OrangePi_ZERO" "OrangePi_PC" "OrangePi_PLUS" "OrangePi_PCPLUS" "OrangePi_PLUS2E" "OrangePi_ONE_H3" "OrangePi_LITE_H3" "OrangePi_ZEROPLUS2_H3" "OrangePi_PC2" "OrangePi_PRIME" "OrangePi_ZEROPLUS" "OrangePi_ZEROPLUS2_H5" "OrangePi_WIN" "OrangePi_WINPLUS" "OrangePi_3" "OrangePi_LITE2" "OrangePi_ONEPLUS" "OrangePi_4" "OrangePi_RK3399") - - 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 PLATFORM="${boards[$choice]}" - echo $PLATFORM - break - fi - fi - printf "Invalid input ...\n" - done + boards=("orangepir1" "orangepizero" "orangepipc" "orangepipcplus" "orangepiplus2e" "orangepione" "orangepilite" "orangepiplus" "orangepizeroplus" "orangepizeroplus2h3" "orangepipc2" "orangepiprime" "orangepizeroplus2h5" "orangepiwin" "orangepiwinplus" "orangepi3" "orangepilite2" "orangepioneplus" "orangepi4" "orangepirk3399") + + if [[ -f /etc/orangepi-release ]]; then + + source /etc/orangepi-release + export BOARD="${BOARD}" + + 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 + + export BOARD="${BOARD}" + + 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 } sudo=${WIRINGPI_SUDO-sudo} diff --git a/examples/blink.c b/examples/blink.c index 8e10710..f449d35 100644 --- a/examples/blink.c +++ b/examples/blink.c @@ -1,8 +1,9 @@ #include #include -//#define NUM 17 -#define NUM 28 +//#define NUM 17 //26pin +//#define NUM 19 //for orangepi4 +#define NUM 28 //40pin int main (void) { diff --git a/gpio/Makefile b/gpio/Makefile index f319e1f..7a9e251 100755 --- a/gpio/Makefile +++ b/gpio/Makefile @@ -39,145 +39,68 @@ CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt -ifeq ($(PLATFORM),) - #PLATFORM = OrangePi_2G-IOT - #PLATFORM = OrangePi_PC2 - #PLATFORM = OrangePi_PRIME - #PLATFORM = OrangePi_ZEROPLUS - #PLATFORM = OrangePi_WIN - #PLATFORM = OrangePi_H5 - #PLATFORM = OrangePi_ZERO - #PLATFORM = OrangePi_R1 - #PLATFORM = OrangePi_H3 - #PLATFORM = OrangePi_LITE2 - PLATFORM = OrangePi_ONEPLUS - #PLATFORM = OrangePi_ZEROPLUS2_H3 - #PLATFORM = OrangePi_ZEROPLUS2_H5 - #PLATFORM = OrangePi_3 - #PLATFORM = OrangePi_RK3399 -endif - -ifeq ($(PLATFORM), OrangePi_2G-IOT) +ifeq ($(BOARD),) + BOARD = orangepioneplus +endif + +ifeq ($(BOARD), orangepi2giot) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_2G_IOT -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifneq ($(findstring $(PLATFORM), "OrangePi_ONE_H3" "OrangePi_LITE_H3" "OrangePi_PC" "OrangePi_PLUS" "OrangePi_PCPLUS" "OrangePi_PLUS2E"),) +ifneq ($(findstring $(BOARD), "orangepione" "orangepilite" "orangepipc" "orangepiplus" "orangepipcplus" "orangepiplus2e"),) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_H3 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_PC2) +ifeq ($(BOARD), orangepipc2) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PC2 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_PRIME) +ifeq ($(BOARD), orangepiprime) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PRIME -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_ZEROPLUS) +ifeq ($(BOARD), orangepizeroplus) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifneq ($(findstring $(PLATFORM), "OrangePi_WIN" "OrangePi_WINPLUS"),) +ifneq ($(findstring $(BOARD), "orangepiwin" "orangepiwinplus"),) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_WIN -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifneq ($(findstring $(PLATFORM), "OrangePi_ZERO" "OrangePi_R1"),) +ifneq ($(findstring $(BOARD), "orangepizero" "orangepir1"),) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZERO -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifneq ($(findstring $(PLATFORM), "OrangePi_ONEPLUS" "OrangePi_LITE2"),) +ifneq ($(findstring $(BOARD), "orangepioneplus" "orangepilite2"),) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_LITE2 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_3) +ifeq ($(BOARD), orangepi3) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_3 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H3) +ifeq ($(BOARD), orangepizeroplus2h3) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H3 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H5) +ifeq ($(BOARD), orangepizeroplus2h5) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H5 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_RK3399) +ifeq ($(BOARD), orangepirk3399) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_RK3399 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_4) +ifeq ($(BOARD), orangepi4) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_4 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif +EXTRA_CFLAGS += -DCONFIG_ORANGEPI + # May not need to alter anything below this line ############################################################################### -SRC = gpio.c readall.c - -ifeq ($(PLATFORM), OrangePi_2G-IOT) - SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_PC2) - SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_PRIME) - SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_ZEROPLUS) - SRC += OrangePi.c -endif - -ifneq ($(findstring $(PLATFORM), "OrangePi_WIN" "OrangePi_WINPLUS"),) - SRC += OrangePi.c -endif - -ifneq ($(findstring $(PLATFORM), "OrangePi_ONE_H3" "OrangePi_LITE_H3" "OrangePi_PC" "OrangePi_PLUS" "OrangePi_PCPLUS" "OrangePi_PLUS2E"),) - SRC += OrangePi.c -endif - -ifneq ($(findstring $(PLATFORM), "OrangePi_ZERO" "OrangePi_R1"),) - SRC += OrangePi.c -endif - -ifneq ($(findstring $(PLATFORM), "OrangePi_ONEPLUS" "OrangePi_LITE2"),) - SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_3) - SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H3) - SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H5) - SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_RK3399) - SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_4) - SRC += OrangePi.c -endif +SRC = gpio.c readall.c OrangePi.c OBJ = $(SRC:.c=.o) diff --git a/gpio/OrangePi.c b/gpio/OrangePi.c index ababaf8..6f7ddeb 100755 --- a/gpio/OrangePi.c +++ b/gpio/OrangePi.c @@ -886,7 +886,6 @@ void OrangePiReadAll(void) printf (" +------+-----+----------+------+---+ OPi H6 +---+------+----------+-----+------+\n"); #elif CONFIG_ORANGEPI_3 printf (" +------+-----+----------+------+---+ OPi 3 +---+------+----------+-----+------+\n"); -#elif CONFIG_ORANGEPI_RK3399 #elif CONFIG_ORANGEPI_RK3399 printf (" +------+-----+----------+------+---+OPi RK3399+---+------+----------+-----+------+\n"); #elif CONFIG_ORANGEPI_4 diff --git a/wiringPi/Makefile b/wiringPi/Makefile index af769b8..5677e05 100755 --- a/wiringPi/Makefile +++ b/wiringPi/Makefile @@ -44,87 +44,64 @@ CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wextra -Winline $(INCLUDE) -pipe -fPIC LIBS = -lm -lpthread -lrt -lcrypt -ifeq ($(PLATFORM),) - #PLATFORM = OrangePi_2G-IOT - #PLATFORM = OrangePi_PC2 - #PLATFORM = OrangePi_PRIME - #PLATFORM = OrangePi_ZEROPLUS - #PLATFORM = OrangePi_WIN - #PLATFORM = OrangePi_H3 - #PLATFORM = OrangePi_LITE2 - PLATFORM = OrangePi_ONEPLUS - #PLATFORM = OrangePi_ZERO - #PLATFORM = OrangePi_ZEROPLUS2_H3 - #PLATFORM = OrangePi_ZEROPLUS2_H5 - #PLATFORM = OrangePi_3 - #PLATFORM = OrangePi_RK3399 +ifeq ($(BOARD),) + BOARD = orangepioneplus endif -ifeq ($(PLATFORM), OrangePi_2G-IOT) +ifeq ($(BOARD), orangepi2giot) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_2G_IOT -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_PC2) +ifeq ($(BOARD), orangepipc2) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PC2 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_PRIME) +ifeq ($(BOARD), orangepiprime) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PRIME -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_ZEROPLUS) +ifeq ($(BOARD), orangepizeroplus) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifneq ($(findstring $(PLATFORM), "OrangePi_WIN" "OrangePi_WINPLUS"),) +ifneq ($(findstring $(BOARD), "orangepiwin" "orangepiwinplus"),) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_WIN -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifneq ($(findstring $(PLATFORM), "OrangePi_ONE_H3" "OrangePi_LITE_H3" "OrangePi_PC" "OrangePi_PLUS" "OrangePi_PCPLUS" "OrangePi_PLUS2E"),) +ifneq ($(findstring $(BOARD), "orangepione" "orangepilite" "orangepipc" "orangepiplus" "orangepipcplus" "orangepiplus2e"),) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_H3 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifneq ($(findstring $(PLATFORM), "OrangePi_ZERO" "OrangePi_R1"),) +ifneq ($(findstring $(BOARD), "orangepizero" "orangepir1"),) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZERO -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifneq ($(findstring $(PLATFORM), "OrangePi_ONEPLUS" "OrangePi_LITE2"),) +ifneq ($(findstring $(BOARD), "orangepioneplus" "orangepilite2"),) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_LITE2 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_3) +ifeq ($(BOARD), orangepi3) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_3 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H3) +ifeq ($(BOARD), orangepizeroplus2h3) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H3 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H5) +ifeq ($(BOARD), orangepizeroplus2h5) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H5 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_RK3399) +ifeq ($(BOARD), orangepirk3399) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_RK3399 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif -ifeq ($(PLATFORM), OrangePi_4) +ifeq ($(BOARD), orangepi4) EXTRA_CFLAGS = -DCONFIG_ORANGEPI_4 -EXTRA_CFLAGS += -DCONFIG_ORANGEPI endif +EXTRA_CFLAGS += -DCONFIG_ORANGEPI + ############################################################################### SRC = wiringPi.c \ @@ -144,59 +121,7 @@ SRC = wiringPi.c \ pseudoPins.c \ wpiExtensions.c \ w25q64.c \ - oled.c - -ifeq ($(PLATFORM), OrangePi_2G-IOT) -SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_PC2) -SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_PRIME) -SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_ZEROPLUS) -SRC += OrangePi.c -endif - -ifneq ($(findstring $(PLATFORM), "OrangePi_WIN" "OrangePi_WINPLUS"),) -SRC += OrangePi.c -endif - -ifneq ($(findstring $(PLATFORM), "OrangePi_ONE_H3" "OrangePi_LITE_H3" "OrangePi_PC" "OrangePi_PLUS" "OrangePi_PCPLUS" "OrangePi_PLUS2E"),) -SRC += OrangePi.c -endif - -ifneq ($(findstring $(PLATFORM), "OrangePi_ZERO" "OrangePi_R1"),) -SRC += OrangePi.c -endif - -ifneq ($(findstring $(PLATFORM), "OrangePi_ONEPLUS" "OrangePi_LITE2"),) -SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_3) -SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H3) -SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H5) -SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_RK3399) -SRC += OrangePi.c -endif - -ifeq ($(PLATFORM), OrangePi_4) -SRC += OrangePi.c -endif + oled.c OrangePi.c HEADERS = $(shell ls *.h)