PiSupply / PaPiRus

Resources for PaPiRus ePaper eInk displays
https://www.pi-supply.com/product/papirus-epaper-eink-screen-hat-for-raspberry-pi/
Other
347 stars 84 forks source link

use PapiRus on tinkerboard. #140

Open alr2000 opened 7 years ago

alr2000 commented 7 years ago

Hi! I would like to use the Papirus screen on a Tinker Board. Could be possible? I´m pretty new at linux and python, so could you do a few hints to work on?

Thanks!

tvoverbeek commented 7 years ago

Should be possible. Tinker Board TinkerOS is also based on Debian ARM as is Raspbian. I did a quick compare of the Tinker Board 40-pin GPIO connector and the RPi 40-pin GPIO connector. For the Papirus HAT you need I2C and SPIO. Both are on the same pins. They obviously tried to be as compatible as possible with the RPi. Software wise you need to port the driver from the repaper repository (https://gitub.com/repaper/gratis). Probably works without changes. Good luck (but you'll need a bit more knowledge about Linux than a newbie)

alr2000 commented 7 years ago

Dear tvoverbeek, Thanks for the swift reply. I´m taking a look to the repaper repository, I realized that I should create a new folder inside the gratis/PlatformWithOS folder with the Tinkerboard specific data, and also modify some make files to allow the compilation with the new platform. Could you point the important steps that I should follow?

Thanks.

P.S. Maybe I should post this topic in the repaper repository to get help from them.

tvoverbeek commented 7 years ago

@air2000, Suggest to copy the RaspberryPi directory to a new Tinkerboard directory and check the gpio and spi definitions and modify for tinkerboard. Probably not much is needed since the pin layout is almost identical to the RaspberryPi one. For spi you will have to llok at the TinkerboardOS specifics. HTH.

shawaj commented 7 years ago

I've ordered a couple tinker boards to test with but doubt I'll get around to anything anytime soon. If I do I'll post back here.

On 24 Jul 2017 3:10 pm, "tvoverbeek" notifications@github.com wrote:

@AIR2000 https://github.com/air2000, Suggest to copy the RaspberryPi directory to a new Tinkerboard directory and check the gpio and spi definitions and modify for tinkerboard. Probably not much is needed since the pin layout is almost identical to the RaspberryPi one. For spi you will have to llok at the TinkerboardOS specifics. HTH.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/140#issuecomment-317434502, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNCur-ViX54gmowdTlwU-T5S-h0lwl7ks5sRKXIgaJpZM4OfJZi .

alr2000 commented 7 years ago

I did some improvements. The screen is reacting to the communication, but isn´t accurate. I used a GPIO C library(https://tinkerboarding.co.uk/wiki/index.php?title=GPIO) instead of change all the raspberry registers. I change the content of the functions on PlatformWithOS/RaspberryPi/gpio.c to use the library. Also I change the PlatformWithOS/RaspberryPi/epd_io.h to match the new pin numbering and my spi device on /dev/spidev2.0.

This is the result using the PlatformWithOS/driver_common/epd_test compiled with make rpi EPD_IO=epd_io.h PANEL_VERSION='V231_G2' img_1772

Any hints?

alr2000 commented 7 years ago

I check the pins with a oscilloscope and I get these results: The first image correspond with the clean and image0 of the epd_test img_1774 The second image correspond to a detailed clean. img_1775 YELLOW= Discharge BLUE= Panel GREEN = Reset PINK= Border.

I´m going to try with a raspberry to see if the signals match in the two devices.

shawaj commented 7 years ago

Have you set the screen size to 2.0 inch in the driver?

On 25 Jul 2017 9:26 am, "alr2000" notifications@github.com wrote:

I check the pins with a oscilloscope and I get these results: The first image correspond with the clean and image0 of the epd_test [image: img_1774] https://user-images.githubusercontent.com/30339082/28562021-fb263d8a-7120-11e7-995f-78d437a2f966.JPG The second image correspond to a detailed clean. [image: img_1775] https://user-images.githubusercontent.com/30339082/28562024-fca074aa-7120-11e7-95a6-57e125c93a9b.JPG YELLOW= Discharge BLUE= Panel GREEN = Reset PINK= Border.

I´m going to try with a raspberry to see if the signals match in the two devices.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/140#issuecomment-317666869, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNCug8cXla4YjhVwESeLn7jgS3Vf_8kks5sRabHgaJpZM4OfJZi .

alr2000 commented 7 years ago

@shawaj No, I used only PlatformWithOS/driver_common/epd_test 2.0 to test it. Where should I change?

shawaj commented 7 years ago

That should have worked if you did EPD test with 2.0 after.

It's getting communication which is a good sign but it's not displaying the correct information.

@repaper @charmingsu have you ever seen an issue like this before? Wondering what the issue could be?

On 25 Jul 2017 9:35 am, "alr2000" notifications@github.com wrote:

@shawaj https://github.com/shawaj No, I used only PlatformWithOS/driver_common/epd_test 2.0 to test it. Where should I change?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/140#issuecomment-317668880, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNCunzPGqPA7tt5Cd5-82BtflYXSVnTks5sRaizgaJpZM4OfJZi .

alr2000 commented 7 years ago

Seems to be that GPIO signals are fine. these two are from the raspberry. img_1778 img_1776 I think should be the SPI.

alr2000 commented 7 years ago

I found another diference between the raspberry and the TinkerBoard SPI bus. I send 3 bytes[0x80,0x82,0x81] with mode 0 and bit 8 bits per word, with no delay. This is the raspberry spi . img_1845 This one is the tinkeboard img_1847

As you can seen the raspberry does a clock pause between each byte, but the tinkerboard doesn´t do this pause. Could it be the problem? I don´t now how sensitive is the clock pin on the display, but according with the DS, the behavior should be like the raspberry. image

shawaj commented 7 years ago

Could you open an issue at https://github.com/repaper/gratis referencing this issue just so it gets the attention of someone from Pervasive?

Also copying in @repaper @charmingsu

On 2 Aug 2017 12:22 pm, "alr2000" notifications@github.com wrote:

I found another diference between the raspberry and the TinkerBoard SPI bus. I send 3 bytes[0x80,0x82,0x81] with mode 0 and bit 8 bits per word, with no delay. This is the raspberry spi . [image: img_1845] https://user-images.githubusercontent.com/30339082/28871293-3346d9ea-7784-11e7-96f3-3b5f681c4a8a.JPG This one is the tinkeboard [image: img_1847] https://user-images.githubusercontent.com/30339082/28871496-1005bd24-7785-11e7-865e-54290dc92fe6.JPG

As you can seen the raspberry does a clock pause between each byte, but the tinkerboard doesn´t do this pause. Could it be the problem? I don´t now how sensitive is the clock pin on the display, but according with the DS, the behavior should be like the raspberry. [image: image] https://user-images.githubusercontent.com/30339082/28871583-873cdfd0-7785-11e7-9cc1-b1803a51a0bc.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/140#issuecomment-319644280, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNCukOS46etgqpe8D__iviGD2xraxe9ks5sUFvugaJpZM4OfJZi .

alr2000 commented 7 years ago

Thanks, I already did it. I hope they can help.

shawaj commented 7 years ago

The screen is obviously getting some data as it's changing the screen which is promising but annoying!

Hopefully it's a fairly simple fix :-)

On 2 Aug 2017 1:06 pm, "alr2000" notifications@github.com wrote:

Thanks, I already did it. I hope they can help.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/140#issuecomment-319652851, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNCujUHijHx98AzbYPAuhPSNyEkQr_vks5sUGZBgaJpZM4OfJZi .

shawaj commented 7 years ago

@tvoverbeek do you have any ideas?

Do you have a Tinker board?

On 2 Aug 2017 1:15 pm, "Aaron Shaw" shawaj@gmail.com wrote:

The screen is obviously getting some data as it's changing the screen which is promising but annoying!

Hopefully it's a fairly simple fix :-)

On 2 Aug 2017 1:06 pm, "alr2000" notifications@github.com wrote:

Thanks, I already did it. I hope they can help.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/140#issuecomment-319652851, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNCujUHijHx98AzbYPAuhPSNyEkQr_vks5sUGZBgaJpZM4OfJZi .

tvoverbeek commented 7 years ago

Aaron,

No, I do not have a Tinkerboard. Do not know if they have any support forums which might help with the Tinker board SPI details.

Ton

On Wed, Aug 2, 2017 at 2:56 PM, Aaron Shaw notifications@github.com wrote:

@tvoverbeek do you have any ideas?

Do you have a Tinker board?

On 2 Aug 2017 1:15 pm, "Aaron Shaw" shawaj@gmail.com wrote:

The screen is obviously getting some data as it's changing the screen which is promising but annoying!

Hopefully it's a fairly simple fix :-)

On 2 Aug 2017 1:06 pm, "alr2000" notifications@github.com wrote:

Thanks, I already did it. I hope they can help.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/PiSupply/PaPiRus/issues/140#issuecomment-319652851 , or mute the thread https://github.com/notifications/unsubscribe-auth/ ADNCujUHijHx98AzbYPAuhPSNyEkQr_vks5sUGZBgaJpZM4OfJZi .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/140#issuecomment-319663688, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJE7hv_l3gWJitPaeXl0_fU6JWpN5VYks5sUHHkgaJpZM4OfJZi .

shawaj commented 7 years ago

@tvoverbeek shall I send you a Tinker?

@alr2000 do you know if there's a forum or support area for Tinker?

On 2 Aug 2017 2:07 pm, "Ton van Overbeek" notifications@github.com wrote:

Aaron,

No, I do not have a Tinkerboard. Do not know if they have any support forums which might help with the Tinker board SPI details.

Ton

On Wed, Aug 2, 2017 at 2:56 PM, Aaron Shaw notifications@github.com wrote:

@tvoverbeek do you have any ideas?

Do you have a Tinker board?

On 2 Aug 2017 1:15 pm, "Aaron Shaw" shawaj@gmail.com wrote:

The screen is obviously getting some data as it's changing the screen which is promising but annoying!

Hopefully it's a fairly simple fix :-)

On 2 Aug 2017 1:06 pm, "alr2000" notifications@github.com wrote:

Thanks, I already did it. I hope they can help.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/PiSupply/PaPiRus/issues/140# issuecomment-319652851 , or mute the thread https://github.com/notifications/unsubscribe-auth/ ADNCujUHijHx98AzbYPAuhPSNyEkQr_vks5sUGZBgaJpZM4OfJZi .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/140#issuecomment-319663688, or mute the thread https://github.com/notifications/unsubscribe- auth/ABJE7hv_l3gWJitPaeXl0_fU6JWpN5VYks5sUHHkgaJpZM4OfJZi .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/140#issuecomment-319666604, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNCujLv5UJdLcikCMa_IX_OS8JgUz3fks5sUHSSgaJpZM4OfJZi .

alr2000 commented 7 years ago

Dear @shawaj , yes there is an area in https://tinkerboarding.co.uk/forum/forum-1.html.

alr2000 commented 7 years ago

Ok, I found the problem. It was the SPI of the tinkerboard. If it uses the DMA it sends random data beyond 32 bytes.(each screen row is 76 bytes long for the 2.0 inch). So you have to disable the spi dma in the kernel. More info on: https://github.com/rockchip-linux/kernel/issues/19

shawaj commented 7 years ago

Thanks so much for your investigation work here!

So you have a guide on how to build this in full?

On 16 Aug 2017 9:37 am, "alr2000" notifications@github.com wrote:

Ok, I found the problem. It was the SPI of the tinkerboard. If it uses the DMA it sends random data beyond 32 bytes.(each scren row is 76 bytes long for the 2.0 inch). So you have to disable the spi dma in the kernel. More info on: rockchip-linux/kernel#19 https://github.com/rockchip-linux/kernel/issues/19

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PiSupply/PaPiRus/issues/140#issuecomment-322704289, or mute the thread https://github.com/notifications/unsubscribe-auth/ADNCur_nRwVJRGl-bkrMxKbp9L950d-oks5sYqo4gaJpZM4OfJZi .

alr2000 commented 7 years ago

1° Get the kernel sources from https://github.com/TinkerBoard/debian_kernel 2° Modify /drivers/spi/spi_rockchip.c according to rockchip-linux/kernel#19 3° Compile the kernel: sudo make miniarm-rk3288_defconfig sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- 4° Substitute the new kernel(zImage) in the /boot folder of the current TinkerOS system. 5° Reboot 6° Get gratis Library git clone https://github.com/repaper/gratis.git 7°A Download and install GPIO C Library for Tinkerboard according to https://tinkerboarding.co.uk/wiki/index.php?title=GPIO 7°B You can investigate the Wiring pi Library to get the TinkerBoard Register to controll the GPIO pins like the Raspberry's code does(steps 9 and 10 should be modified accordingly ). 8° Create a new folder for Tinkerboard system on PlatformWithOS 9° Modify the Makefile to allow the tinkerboard code and include the wiringPi library on it. 10° Add to the Tinkerboard folder theses files epd-fuse.sh epd_io.h epd_io_free_uart.h gpio.c gpio.h

epd_io.h

#if !defined(EPD_IO_H)
#define EPD_IO_H 1

#define panel_on_pin  4
#define border_pin    15
#define discharge_pin 16
#define pwm_pin       2
#define reset_pin     5
#define busy_pin      6
*/
#define SPI_DEVICE    "/dev/spidev2.0"
#define SPI_BPS      8000000

#endif

gpio.c

// Copyright 2013-2015 Pervasive Displays, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied.  See the License for the specific language
// governing permissions and limitations under the License.

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <err.h>
#include "gpio.h"
#include <wiringPi.h>

bool GPIO_setup() {
        wiringPiSetup ();
        return true;
}

// remove the map
// revoke access to GPIO and PWM
bool GPIO_teardown() {
        return true;
}

void GPIO_mode(int pin, int mode) {
        pinMode(pin,mode);
}
int GPIO_read(int pin) {
        return digitalRead(pin);
        }

void GPIO_write(int pin,int value)
{
        digitalWrite (pin, value);
}

gpio.h

// Copyright 2013-2015 Pervasive Displays, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied.  See the License for the specific language
// governing permissions and limitations under the License.

#if !defined(GPIO_H)
#define GPIO_H 1

#include <stdbool.h>
#include <stdint.h>

// GPIO modes
typedef enum {
        GPIO_INPUT,   // as input
        GPIO_OUTPUT,  // as output
        GPIO_PWM      // as PWM output (only for P1_12
} GPIO_mode_type;

// functions
// =========

// enable GPIO system (maps device registers)
// return false if failure
bool GPIO_setup();

// release mapped device registers
bool GPIO_teardown();

// set a mode for a given GPIO pin
void GPIO_mode(int pin, int  mode);

// return a value (0/1) for a given input pin
int GPIO_read(int pin);

// set or clear a given output pin
void GPIO_write(int pin, int value);

// set the PWM ration 0..1023 for hardware PWM pin (GPIO_P1_12)
void GPIO_pwm_write(int pin, uint32_t value);

#endif

The rest of the files stay the same. 11° Compile and test the epd_test.c [12°] Get the PaPiRus code and start playing!

shawaj commented 7 years ago

@tvoverbeek @francesco-vannini what do you think about this?

Looks like mostly changes to RePaper GitHub but probably worth us formally doing this as the PaPiRus codebase itself will stay the same

shawaj commented 6 years ago

Just FYI - the Asus Tinker staff are looking at this as we speak