Browse Source

orangepi-release is used to select the model of the board

pull/20/head
leeboby 5 years ago
parent
commit
210a692339
  1. 63
      build
  2. 5
      examples/blink.c
  3. 117
      gpio/Makefile
  4. 1
      gpio/OrangePi.c
  5. 111
      wiringPi/Makefile

63
build

@ -49,29 +49,46 @@ select_boards()
local choice local choice
local call=${1} 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") boards=("orangepir1" "orangepizero" "orangepipc" "orangepipcplus" "orangepiplus2e" "orangepione" "orangepilite" "orangepiplus" "orangepizeroplus" "orangepizeroplus2h3" "orangepipc2" "orangepiprime" "orangepizeroplus2h5" "orangepiwin" "orangepiwinplus" "orangepi3" "orangepilite2" "orangepioneplus" "orangepi4" "orangepirk3399")
printf "All available boards:\n" if [[ -f /etc/orangepi-release ]]; then
for var in ${boards[@]} ; do
printf "%4d. %s\n" $cnt ${boards[$cnt]} source /etc/orangepi-release
((cnt+=1)) export BOARD="${BOARD}"
done
elif [[ -f /etc/armbian-release ]]; then
while true ; do
read -p "Choice: " choice source /etc/armbian-release
if [ -z "${choice}" ] ; then
continue [[ $BOARD == orangepi-r1 ]] && BOARD=orangepir1
fi [[ $BOARD == orangepi-rk3399 ]] && BOARD=orangepirk3399
[[ $BOARD == orangepizeroplus2-h3 ]] && BOARD=orangepizeroplus2h3
if [ -z "${choice//[0-9]/}" ] ; then [[ $BOARD == orangepizeroplus2-h5 ]] && BOARD=orangepizeroplus2h5
if [ $choice -ge 0 -a $choice -lt $cnt ] ; then
export PLATFORM="${boards[$choice]}" export BOARD="${BOARD}"
echo $PLATFORM
break else
fi
fi printf "All available boards:\n"
printf "Invalid input ...\n" for var in ${boards[@]} ; do
done 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} sudo=${WIRINGPI_SUDO-sudo}

5
examples/blink.c

@ -1,8 +1,9 @@
#include <stdio.h> #include <stdio.h>
#include <wiringPi.h> #include <wiringPi.h>
//#define NUM 17 //#define NUM 17 //26pin
#define NUM 28 //#define NUM 19 //for orangepi4
#define NUM 28 //40pin
int main (void) int main (void)
{ {

117
gpio/Makefile

@ -39,145 +39,68 @@ CFLAGS = $(DEBUG) -Wall -Wextra $(INCLUDE) -Winline -pipe
LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib LDFLAGS = -L$(DESTDIR)$(PREFIX)/lib
LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt LIBS = -lwiringPi -lwiringPiDev -lpthread -lrt -lm -lcrypt
ifeq ($(PLATFORM),) ifeq ($(BOARD),)
#PLATFORM = OrangePi_2G-IOT BOARD = orangepioneplus
#PLATFORM = OrangePi_PC2 endif
#PLATFORM = OrangePi_PRIME
#PLATFORM = OrangePi_ZEROPLUS ifeq ($(BOARD), orangepi2giot)
#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)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_2G_IOT EXTRA_CFLAGS = -DCONFIG_ORANGEPI_2G_IOT
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif 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_H3
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_PC2) ifeq ($(BOARD), orangepipc2)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PC2 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PC2
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_PRIME) ifeq ($(BOARD), orangepiprime)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PRIME EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PRIME
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_ZEROPLUS) ifeq ($(BOARD), orangepizeroplus)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifneq ($(findstring $(PLATFORM), "OrangePi_WIN" "OrangePi_WINPLUS"),) ifneq ($(findstring $(BOARD), "orangepiwin" "orangepiwinplus"),)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_WIN EXTRA_CFLAGS = -DCONFIG_ORANGEPI_WIN
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifneq ($(findstring $(PLATFORM), "OrangePi_ZERO" "OrangePi_R1"),) ifneq ($(findstring $(BOARD), "orangepizero" "orangepir1"),)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZERO EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZERO
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifneq ($(findstring $(PLATFORM), "OrangePi_ONEPLUS" "OrangePi_LITE2"),) ifneq ($(findstring $(BOARD), "orangepioneplus" "orangepilite2"),)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_LITE2 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_LITE2
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_3) ifeq ($(BOARD), orangepi3)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_3 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_3
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H3) ifeq ($(BOARD), orangepizeroplus2h3)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H3 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H3
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H5) ifeq ($(BOARD), orangepizeroplus2h5)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H5 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H5
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_RK3399) ifeq ($(BOARD), orangepirk3399)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_RK3399 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_RK3399
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_4) ifeq ($(BOARD), orangepi4)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_4 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_4
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
# May not need to alter anything below this line # May not need to alter anything below this line
############################################################################### ###############################################################################
SRC = gpio.c readall.c SRC = gpio.c readall.c OrangePi.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
OBJ = $(SRC:.c=.o) OBJ = $(SRC:.c=.o)

1
gpio/OrangePi.c

@ -886,7 +886,6 @@ void OrangePiReadAll(void)
printf (" +------+-----+----------+------+---+ OPi H6 +---+------+----------+-----+------+\n"); printf (" +------+-----+----------+------+---+ OPi H6 +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_3 #elif CONFIG_ORANGEPI_3
printf (" +------+-----+----------+------+---+ OPi 3 +---+------+----------+-----+------+\n"); printf (" +------+-----+----------+------+---+ OPi 3 +---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_RK3399
#elif CONFIG_ORANGEPI_RK3399 #elif CONFIG_ORANGEPI_RK3399
printf (" +------+-----+----------+------+---+OPi RK3399+---+------+----------+-----+------+\n"); printf (" +------+-----+----------+------+---+OPi RK3399+---+------+----------+-----+------+\n");
#elif CONFIG_ORANGEPI_4 #elif CONFIG_ORANGEPI_4

111
wiringPi/Makefile

@ -44,87 +44,64 @@ CFLAGS = $(DEBUG) $(DEFS) -Wformat=2 -Wextra -Winline $(INCLUDE) -pipe -fPIC
LIBS = -lm -lpthread -lrt -lcrypt LIBS = -lm -lpthread -lrt -lcrypt
ifeq ($(PLATFORM),) ifeq ($(BOARD),)
#PLATFORM = OrangePi_2G-IOT BOARD = orangepioneplus
#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
endif endif
ifeq ($(PLATFORM), OrangePi_2G-IOT) ifeq ($(BOARD), orangepi2giot)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_2G_IOT EXTRA_CFLAGS = -DCONFIG_ORANGEPI_2G_IOT
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_PC2) ifeq ($(BOARD), orangepipc2)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PC2 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PC2
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_PRIME) ifeq ($(BOARD), orangepiprime)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PRIME EXTRA_CFLAGS = -DCONFIG_ORANGEPI_PRIME
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_ZEROPLUS) ifeq ($(BOARD), orangepizeroplus)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifneq ($(findstring $(PLATFORM), "OrangePi_WIN" "OrangePi_WINPLUS"),) ifneq ($(findstring $(BOARD), "orangepiwin" "orangepiwinplus"),)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_WIN EXTRA_CFLAGS = -DCONFIG_ORANGEPI_WIN
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif 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_H3
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifneq ($(findstring $(PLATFORM), "OrangePi_ZERO" "OrangePi_R1"),) ifneq ($(findstring $(BOARD), "orangepizero" "orangepir1"),)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZERO EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZERO
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifneq ($(findstring $(PLATFORM), "OrangePi_ONEPLUS" "OrangePi_LITE2"),) ifneq ($(findstring $(BOARD), "orangepioneplus" "orangepilite2"),)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_LITE2 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_LITE2
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_3) ifeq ($(BOARD), orangepi3)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_3 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_3
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H3) ifeq ($(BOARD), orangepizeroplus2h3)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H3 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H3
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_ZEROPLUS2_H5) ifeq ($(BOARD), orangepizeroplus2h5)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H5 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_ZEROPLUS2_H5
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_RK3399) ifeq ($(BOARD), orangepirk3399)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_RK3399 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_RK3399
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
ifeq ($(PLATFORM), OrangePi_4) ifeq ($(BOARD), orangepi4)
EXTRA_CFLAGS = -DCONFIG_ORANGEPI_4 EXTRA_CFLAGS = -DCONFIG_ORANGEPI_4
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
endif endif
EXTRA_CFLAGS += -DCONFIG_ORANGEPI
############################################################################### ###############################################################################
SRC = wiringPi.c \ SRC = wiringPi.c \
@ -144,59 +121,7 @@ SRC = wiringPi.c \
pseudoPins.c \ pseudoPins.c \
wpiExtensions.c \ wpiExtensions.c \
w25q64.c \ w25q64.c \
oled.c oled.c OrangePi.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
HEADERS = $(shell ls *.h) HEADERS = $(shell ls *.h)

Loading…
Cancel
Save