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 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}

5
examples/blink.c

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

117
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)

1
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

111
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)

Loading…
Cancel
Save