Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 423b9d7

Browse files
ROCK Pi 4 (RK3399) support (mysensors#1499)
* ROCK Pi 4 (RK3399) support * Code style
1 parent 4afa7a6 commit 423b9d7

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

‎configure‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ SPI driver options:
1717
Device path. [/dev/spidev0.0]
1818
1919
Building options:
20-
--soc=[BCM2711|BCM2835|BCM2836|BCM2837|AM33XX|A10|A13|A20|H3]
20+
--soc=[BCM2711|BCM2835|BCM2836|BCM2837|AM33XX|A10|A13|A20|H3|RK3399]
2121
SoC type to be used. [configure autodetected]
2222
--cpu-flags=<CPUFLAGS> CPU defining/optimizing flags to be used. [configure autodetected]
2323
--extra-cflags=<CFLAGS> Extra C flags passed to C compilation. []
@@ -248,7 +248,10 @@ function detect_machine {
248248
soc="AM33XX"
249249
;;
250250
*)
251-
soc="unknown"
251+
if [[ $machine == *"ROCK Pi 4"* ]]; then
252+
soc="RK3399"
253+
tp="RockPi4"
254+
fi
252255
esac
253256
echo "${soc} ${tp} ${cpu}"
254257
}
@@ -283,12 +286,21 @@ function gcc_cpu_flags {
283286
H3)
284287
flags="-march=armv7-a -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard"
285288
;;
289+
RK3399)
290+
flags="-march=armv8-a+crc+crypto -mtune=cortex-a72.cortex-a53 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419"
291+
;;
286292
*)
287293
flags=""
288294
esac
289295
echo ${flags}
290296
}
291297

298+
ROCKPI4_PIN_MAP=(
299+
1 2 71 4 72 6 75 148 9 147
300+
146 131 150 14 149 154 17 156 40 20
301+
39 157 41 42 25 26 64 65 74 30
302+
73 112 76 24 133 132 158 134 39 135 )
303+
292304
# Default values
293305
debug=enable
294306
gateway_type=ethernet
@@ -297,7 +309,7 @@ signing=none
297309
signing_request_signatures=false
298310
encryption=false
299311

300-
params="SOC CFLAGS CXXFLAGS CPPFLAGS LDFLAGS PREFIX CC CXX ARDUINO_LIB_DIR BUILDDIR BINDIR GATEWAY_DIR INIT_SYSTEM SPI_DRIVER"
312+
params="SOC CFLAGS CXXFLAGS CPPFLAGS LDFLAGS PREFIX CC CXX ARDUINO_LIB_DIR BUILDDIR BINDIR GATEWAY_DIR INIT_SYSTEM SPI_DRIVER TYPE"
301313

302314
for opt do
303315
if [ "$opt" = "-h" ] || [ "$opt" = "--help" ]; then
@@ -575,6 +587,17 @@ else
575587
fi
576588
fi
577589

590+
if [[ $TYPE == "RockPi4" ]]; then
591+
FLTMP=$CPPFLAGS
592+
pattern="(.+_PIN=)([0-9]+)(.*)"
593+
while [[ $FLTMP =~ $pattern ]]; do
594+
FLTMP=${BASH_REMATCH[3]}
595+
CPPFLAGS=${BASH_REMATCH[1]}${ROCKPI4_PIN_MAP[${BASH_REMATCH[2]}-1]}
596+
done
597+
CPPFLAGS=$CPPFLAGS$FLTMP
598+
CPPFLAGS="-DLINUX_ARCH_ROCKPI4 $CPPFLAGS"
599+
fi
600+
578601
if [ -z "${SPI_DRIVER}" ]; then
579602
printf "${SECTION} Detecting SPI driver.\n"
580603
if [[ $SOC == "BCM2835" || $SOC == "BCM2836" || $SOC == "BCM2837" || $SOC == "BCM2711" ]]; then

‎hal/architecture/Linux/drivers/core/interrupt.cpp‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,27 @@ struct ThreadArgs {
4242
volatile bool interruptsEnabled = true;
4343
static pthread_mutex_t intMutex = PTHREAD_MUTEX_INITIALIZER;
4444

45-
static pthread_t *threadIds[64] = {NULL};
45+
static pthread_t *threadIds[256] = {NULL};
4646

4747
// sysFds:
4848
// Map a file descriptor from the /sys/class/gpio/gpioX/value
49-
static int sysFds[64] = {
49+
static int sysFds[256] = {
5050
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5151
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5252
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5353
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
54+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
55+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
56+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
57+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
58+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
59+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
60+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
61+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
62+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
63+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
64+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
65+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5466
};
5567

5668
/*
@@ -130,7 +142,7 @@ void attachInterrupt(uint8_t gpioPin, void (*func)(), uint8_t mode)
130142
FILE *fd;
131143
char fName[40];
132144
char c;
133-
int count, i;
145+
int count;
134146

135147
if (threadIds[gpioPin] == NULL) {
136148
threadIds[gpioPin] = new pthread_t;
@@ -190,15 +202,15 @@ void attachInterrupt(uint8_t gpioPin, void (*func)(), uint8_t mode)
190202

191203
if (sysFds[gpioPin] == -1) {
192204
snprintf(fName, sizeof(fName), "/sys/class/gpio/gpio%d/value", gpioPin);
193-
if ((sysFds[gpioPin] = open(fName, O_RDWR)) < 0) {
205+
if ((sysFds[gpioPin] = open(fName, O_RDONLY)) < 0) {
194206
logError("Error reading pin %d: %s\n", gpioPin, strerror(errno));
195207
exit(1);
196208
}
197209
}
198210

199211
// Clear any initial pending interrupt
200212
ioctl(sysFds[gpioPin], FIONREAD, &count);
201-
for (i = 0; i < count; ++i) {
213+
for (inti = 0; i < count; ++i) {
202214
if (read(sysFds[gpioPin], &c, 1) == -1) {
203215
logError("attachInterrupt: failed to read pin status: %s\n", strerror(errno));
204216
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /