Merge branch 'support-rm2fb' of https://github.com/danshick/reStream into danshick-support-rm2fb

This commit is contained in:
Rien Maertens 2021-01-28 23:24:58 +01:00
commit 322dbfa4e4
No known key found for this signature in database
GPG Key ID: AE66CE42F1AF9DEF
3 changed files with 40 additions and 17 deletions

View File

@ -16,11 +16,20 @@ reMarkable screen sharing over SSH.
2. [Set up an SSH key and add it to the ssh-agent](https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent), then add your key to the reMarkable with `ssh-copy-id root@10.11.99.1`. **Note:** the reMarkable 2 doesn't support `ed25519` keys, those users should generate and `rsa` key. Try out `ssh root@10.11.99.1`, it should **not** prompt for a password. 2. [Set up an SSH key and add it to the ssh-agent](https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent), then add your key to the reMarkable with `ssh-copy-id root@10.11.99.1`. **Note:** the reMarkable 2 doesn't support `ed25519` keys, those users should generate and `rsa` key. Try out `ssh root@10.11.99.1`, it should **not** prompt for a password.
3. Clone this repository: `git clone https://github.com/rien/reStream`. 3. Clone this repository: `git clone https://github.com/rien/reStream`.
4. Copy the `restream` executable to the reMarkable and make it executable. 4. Copy the `restream` executable to the reMarkable and make it executable.
``` ```
# scp restream.arm.static root@10.11.99.1:/home/root/restream # scp restream.arm.static root@10.11.99.1:/home/root/restream
# ssh root@10.11.99.1 'chmod +x /home/root/restream' # ssh root@10.11.99.1 'chmod +x /home/root/restream'
``` ```
--or--
Install via [toltec](https://github.com/toltec-dev/toltec) if you use it (currently in the [testing branch](https://github.com/toltec-dev/toltec/blob/testing/docs/branches.md)).
```
# ssh root@10.11.99.1 'opkg install restream'
```
### Windows ### Windows
1. Install [git for windows](https://gitforwindows.org/), which includes `Git BASH`. 1. Install [git for windows](https://gitforwindows.org/), which includes `Git BASH`.
@ -60,6 +69,7 @@ If you have problems, don't hesitate to [open an issue](https://github.com/rien/
## Requirements ## Requirements
On your **host** machine: On your **host** machine:
- Any POSIX-shell (e.g. bash) - Any POSIX-shell (e.g. bash)
- ffmpeg (with ffplay) - ffmpeg (with ffplay)
- ssh - ssh
@ -77,13 +87,13 @@ apt install v4l2loopback-utils v4l2loopback-dkms
In some package managers `v4l2loopback-utils` is found in `v4l-utils`. In some package managers `v4l2loopback-utils` is found in `v4l-utils`.
After installing the module you must enable it with After installing the module you must enable it with
``` ```
modprobe v4l2loopback modprobe v4l2loopback
``` ```
To verify that this worked, execute: To verify that this worked, execute:
``` ```
v4l2-ctl --list-devices v4l2-ctl --list-devices
@ -94,6 +104,7 @@ The result should contain a line with "platform:v4l2loopback".
## Troubleshooting ## Troubleshooting
Steps you can try if the script isn't working: Steps you can try if the script isn't working:
- [Set up an SSH key](#installation) - [Set up an SSH key](#installation)
- Update `ffmpeg` to version 4. - Update `ffmpeg` to version 4.

View File

@ -104,10 +104,16 @@ case "$rm_version" in
pixel_format="rgb565le" pixel_format="rgb565le"
;; ;;
"reMarkable 2.0") "reMarkable 2.0")
pixel_format="gray8" if ssh_cmd "[ -f /dev/shm/swtfb.01 ]"; then
width=1872 width=1404
height=1404 height=1872
video_filters="$video_filters,transpose=2" pixel_format="rgb565le"
else
width=1872
height=1404
pixel_format="gray8"
video_filters="$video_filters,transpose=2"
fi
;; ;;
*) *)
echo "Unsupported reMarkable version: $rm_version." echo "Unsupported reMarkable version: $rm_version."
@ -129,7 +135,7 @@ if ! lz4 -V >/dev/null; then
fi fi
# check if restream binay is present on remarkable # check if restream binay is present on remarkable
if ssh_cmd "[ ! -f ~/restream ]"; then if ssh_cmd "[ ! -f ~/restream ] && [ ! -f /opt/bin/restream ]"; then
echo "The restream binary is not installed on your reMarkable." echo "The restream binary is not installed on your reMarkable."
echo "Please install it using the instruction in the README:" echo "Please install it using the instruction in the README:"
echo "https://github.com/rien/reStream/#installation" echo "https://github.com/rien/reStream/#installation"
@ -185,13 +191,15 @@ fi
set -e # stop if an error occurs set -e # stop if an error occurs
restream_rs='PATH="$PATH:/opt/bin/:." restream'
if $unsecure_connection; then if $unsecure_connection; then
listen_port=16789 listen_port=16789
ssh_cmd "./restream --listen $listen_port" & ssh_cmd "$restream_rs --listen $listen_port" &
sleep 1 # give some time to restream.rs to start listening sleep 1 # give some time to restream.rs to start listening
receive_cmd="nc 10.11.99.1 $listen_port" receive_cmd="nc 10.11.99.1 $listen_port"
else else
receive_cmd="ssh_cmd ./restream" receive_cmd="ssh_cmd $restream_rs"
fi fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086

View File

@ -8,6 +8,7 @@ use lz_fear::CompressionSettings;
use std::default::Default; use std::default::Default;
use std::fs::File; use std::fs::File;
use std::path::Path;
use std::io::{BufRead, BufReader, Read, Seek, SeekFrom, Write}; use std::io::{BufRead, BufReader, Read, Seek, SeekFrom, Write};
use std::net::{TcpStream, TcpListener}; use std::net::{TcpStream, TcpListener};
use std::process::Command; use std::process::Command;
@ -31,20 +32,23 @@ fn main() -> Result<()> {
let ref opts: Opts = Opts::parse(); let ref opts: Opts = Opts::parse();
let version = remarkable_version()?; let version = remarkable_version()?;
let height = 1872;
let streamer = if version == "reMarkable 1.0\n" { let streamer = if version == "reMarkable 1.0\n" {
let width = 1408; let width = 1408;
let height = 1872;
let bytes_per_pixel = 2; let bytes_per_pixel = 2;
ReStreamer::init("/dev/fb0", 0, width, height, bytes_per_pixel)? ReStreamer::init("/dev/fb0", 0, width, height, bytes_per_pixel)?
} else if version == "reMarkable 2.0\n" { } else if version == "reMarkable 2.0\n" {
let width = 1404; let width = 1404;
let height = 1872; if Path::new("/dev/shm/swtfb.01").exists() {
let bytes_per_pixel = 1; let bytes_per_pixel = 2;
ReStreamer::init("/dev/shm/swtfb.01", 0, width, height, bytes_per_pixel)?
let pid = xochitl_pid()?; } else {
let offset = rm2_fb_offset(pid)?; let bytes_per_pixel = 1;
let mem = format!("/proc/{}/mem", pid); let pid = xochitl_pid()?;
ReStreamer::init(&mem, offset, width, height, bytes_per_pixel)? let offset = rm2_fb_offset(pid)?;
let mem = format!("/proc/{}/mem", pid);
ReStreamer::init(&mem, offset, width, height, bytes_per_pixel)?
}
} else { } else {
Err(anyhow!( Err(anyhow!(
"Unknown reMarkable version: {}\nPlease open a feature request to support your device.", "Unknown reMarkable version: {}\nPlease open a feature request to support your device.",