From 39d0330d4af82ca89f0dc32fd60ceb8c240cfa58 Mon Sep 17 00:00:00 2001 From: Miroslav Ondra Date: Thu, 2 Aug 2018 22:00:28 +0200 Subject: [PATCH] fixed module version fixed processing on-boot undefined boards fixed raspbian script --- modules/unipi/raspbian | 41 ++++++++++++++++++++------------ modules/unipi/src/unipi_common.h | 2 +- modules/unipi/src/unipi_spi.c | 4 ++-- modules/unipi/src/unipi_tty.c | 5 +++- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/modules/unipi/raspbian b/modules/unipi/raspbian index c6df706..b48e09d 100755 --- a/modules/unipi/raspbian +++ b/modules/unipi/raspbian @@ -1,10 +1,17 @@ #!/bin/bash -mkdir -p tmp -wget -q http://archive.raspberrypi.org/debian/dists/stretch/main/binary-armhf/Packages.gz -O - | gunzip \ -| awk '/^Package: raspberrypi-kernel-headers[[:blank:]]*$/ { ok=1; next} /^Package: / {ok=0;} (ok!=1) {next} -/^Version: / {print "RPI_FIRMWARE_VER=" $2 } -/^Filename: / {print "RPI_FIRMWARE_FILE=" $2; nextfile }' > tmp/versions +############################################### +# +# for new version checking delete file tmp/versions +# +################################################# +if [ -s tmp/versions ]; then + mkdir -p tmp + wget -q http://archive.raspberrypi.org/debian/dists/stretch/main/binary-armhf/Packages.gz -O - | gunzip \ + | awk '/^Package: raspberrypi-kernel-headers[[:blank:]]*$/ { ok=1; next} /^Package: / {ok=0;} (ok!=1) {next} + /^Version: / {print "RPI_FIRMWARE_VER=" $2 } + /^Filename: / {print "RPI_FIRMWARE_FILE=" $2; nextfile }' > tmp/versions +fi cd tmp . versions @@ -16,17 +23,21 @@ cd tmp # alternate method to get raspberrypi-kernel_${RPI_FIRMWARE_VER}.zip # get commit number used for making this kernel version -wget https://raw.githubusercontent.com/raspberrypi/firmware/stable/extra/git_hash -O- > .git_hash -GIT_VER=`cat .git_hash` -wget https://github.com/raspberrypi/linux/archive/$GIT_VER.zip -O raspberrypi-kernel_${RPI_FIRMWARE_VER}.zip -unzip raspberrypi-kernel_${RPI_FIRMWARE_VER}.zip -mv linux-$GIT_VER linux-raspberrypi-kernel_${RPI_FIRMWARE_VER} -#----------------------------------------------------------------------- -rm raspberrypi-kernel_${RPI_FIRMWARE_VER}.zip +if [ ! -d linux-raspberrypi-kernel_${RPI_FIRMWARE_VER} ]; then + wget https://raw.githubusercontent.com/raspberrypi/firmware/stable/extra/git_hash -O- > .git_hash + GIT_VER=`cat .git_hash` + wget https://github.com/raspberrypi/linux/archive/$GIT_VER.zip -O raspberrypi-kernel_${RPI_FIRMWARE_VER}.zip + unzip raspberrypi-kernel_${RPI_FIRMWARE_VER}.zip + mv linux-$GIT_VER linux-raspberrypi-kernel_${RPI_FIRMWARE_VER} + #----------------------------------------------------------------------- + rm raspberrypi-kernel_${RPI_FIRMWARE_VER}.zip +fi -wget http://archive.raspberrypi.org/debian/${RPI_FIRMWARE_FILE} -dpkg-deb -x `basename ${RPI_FIRMWARE_FILE}` h -### raspberrypi-kernel-headers_1.20180417-1_armhf.deb h +if [ ! -r `basename ${RPI_FIRMWARE_FILE}` ]; then + wget http://archive.raspberrypi.org/debian/${RPI_FIRMWARE_FILE} + dpkg-deb -x `basename ${RPI_FIRMWARE_FILE}` h + ### raspberrypi-kernel-headers_1.20180417-1_armhf.deb h +fi KERNEL_VER=`ls -1 h/lib/modules | grep '\-v7'` echo $KERNEL_VER diff --git a/modules/unipi/src/unipi_common.h b/modules/unipi/src/unipi_common.h index a09f806..4fed882 100644 --- a/modules/unipi/src/unipi_common.h +++ b/modules/unipi/src/unipi_common.h @@ -51,7 +51,7 @@ #if NEURONSPI_SCHED_REQUIRED > 0 #include #endif -#define NEURONSPI_MAJOR_VERSIONSTRING "Version 1.13:2018:07:19" +#define NEURONSPI_MAJOR_VERSIONSTRING "Version 1.14:2018:08:02" #define NEURONSPI_MAX_DEVS 3 #define NEURONSPI_MAX_UART 128 diff --git a/modules/unipi/src/unipi_spi.c b/modules/unipi/src/unipi_spi.c index 9557df7..a78be07 100644 --- a/modules/unipi/src/unipi_spi.c +++ b/modules/unipi/src/unipi_spi.c @@ -140,7 +140,7 @@ ssize_t neuronspi_read (struct file *file_p, char *buffer, size_t len, loff_t *o driver_data = spi_get_drvdata(spi_driver_data); if (driver_data == NULL) return -2; if (driver_data->spi_driver == NULL) return -2; // Invalid private data - if (driver_data->first_probe_reply[0] == 0) return -3; // No device present + if ((driver_data->first_probe_reply[0] == 0) && !(driver_data->probe_always_succeeds) ) return -3; // Device not present mutex_lock(&(private_data->lock)); if (private_data->recv_buf == NULL) { mutex_unlock(&(private_data->lock)); @@ -211,7 +211,7 @@ ssize_t neuronspi_write (struct file *file_p, const char *buffer, size_t len, lo driver_data = spi_get_drvdata(spi_driver_data); if (driver_data == NULL) return -2; if (driver_data->spi_driver == NULL) return -2; // Invalid private data - if (driver_data->first_probe_reply[0] == 0) return -3; // Device not present + if ((driver_data->first_probe_reply[0] == 0) && !(driver_data->probe_always_succeeds) ) return -3; // Device not present send_header = buffer[3]; if (buffer[4]) { // Frequency setting frequency = (buffer[4] << 8 | buffer[5]) * 1000; diff --git a/modules/unipi/src/unipi_tty.c b/modules/unipi/src/unipi_tty.c index a18dbd0..a6aa074 100644 --- a/modules/unipi/src/unipi_tty.c +++ b/modules/unipi/src/unipi_tty.c @@ -930,6 +930,7 @@ static int unipi_tty_ioctl(struct tty_struct *tty, struct file *file, } } +#ifdef CONFIG_COMPAT static long unipi_tty_compat_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg) { @@ -949,7 +950,7 @@ static long unipi_tty_compat_ioctl(struct tty_struct *tty, struct file *file, return n_tty_compat_ioctl_helper(tty, file, cmd, arg); } } - +#endif static struct tty_ldisc_ops unipi_tty_ops = { .magic = TTY_LDISC_MAGIC, @@ -961,7 +962,9 @@ static struct tty_ldisc_ops unipi_tty_ops = { .read = unipi_tty_read, .write = unipi_tty_write, .ioctl = unipi_tty_ioctl, +#ifdef CONFIG_COMPAT .compat_ioctl = unipi_tty_compat_ioctl, +#endif .set_termios = unipi_tty_set_termios, .poll = unipi_tty_poll, .receive_buf = unipi_tty_receive_buf, -- 2.34.1