runfalk / synology-wireguard

WireGuard support for some Synology NAS drives
MIT License
920 stars 131 forks source link

Add Geminilake Platform #48

Closed carlyman closed 3 years ago

carlyman commented 3 years ago

Description Compile for DS920+ (Geminilake)

Steps to reproduce

git clone https://github.com/runfalk/synology-wireguard.git
cd synology-wireguard/
sudo docker build -t synobuild .
sudo docker run --rm --privileged --env PACKAGE_ARCH=geminilake --env DSM_VER=6.2 -v $(pwd)/artifacts:/result_spk synobuild

Output

Cloning into 'pkgscripts-ng'...

PlatformNotAvailableError:
[Geminilake] is not available platform.

Expected behavior Compiled SPK

Synology NAS model DS920+

runfalk commented 3 years ago

It doesn't seem like Synology provides a specific SDK for Gemini Lake (https://sourceforge.net/projects/dsgpl/files/toolkit/). Some googling seems to indicate that Gemini Lake is very similar to Apollo Lake. So maybe you can try an Apollo Lake release and see if that works?

Let me know if it works for you!

developStorm commented 3 years ago

Had a shot on it but unfortunately the DSM is not allowing to install either x86 or apollolake package.

I also saw that https://github.com/nirev/synology-tailscale could actually work with geminilake and they credit that their building process is based on this project. So maybe you can checkout their implementation?

runfalk commented 3 years ago

Hm, they don't do any compilation in that project it seems. They just label the amd64 package as compatible with a lot of CPUs. If you're feeling adventurous you could try:

  1. Clone this project
  2. Modify INFO.sh and hard code arch to x64 x86 apollolake avoton braswell broadwell broadwellnk bromolow cedarview denverton dockerx64 grantley purley kvmx64 x86_64 (that's what the Tailscale project uses)
  3. Create new docker image and make a new build according to the README.

If this works then one of the architectures in that list allows it to be installed. If you figure out which one I may be able to make a geminilake compatible release.

developStorm commented 3 years ago

After did modification the apollolake version seems to work for me! https://github.com/developStorm/synology-wireguard/actions/runs/209949062


Update: I hope someone could test this out, I can install and activate it in DSM but encountering issue with wg-quick up. image

runfalk commented 3 years ago

Could you provide kernel logs such as from dmesg when this happens?

developStorm commented 3 years ago

Not really, my NAS was disconnected from the network and becomes unresponsive so that I have to force restart it. The log should already be lost during restart.

runfalk commented 3 years ago

Hm, could you paste your config? (remember to redact sensitive information)

You could try to save the log to disk using something like (wg-quick up wg0; dmesg) > log.txt

vidalpascual commented 3 years ago

Anything new about this? I would like to install docker WireGuard in my DS920+

runfalk commented 3 years ago

I'm not sure what you're asking for @vidalpascual. This project has nothing to do with docker. Docker is only used on your desktop to build the SPK, but it's actually technically not required.

You could try the same approach I proposed to @developStorm and get an SPK that you can install on your device.

vidalpascual commented 3 years ago

Sorry for the misunderstanding. I wanted to say that I would like to install this SPK WireGuard packet in my DS920+. I don't think that @developStorm approach went so well: "my NAS was disconnected from the network and becomes unresponsive"

runfalk commented 3 years ago

It could be a configuration issue. Hard to tell at this point.

Without someone with a Gemini Lake NAS to assist me with the debugging, I can't help.

vidalpascual commented 3 years ago

I can help you then, what do you need me to do?

Kopernikus1979 commented 3 years ago

Same here, also with a DS920+ What can we do ?

runfalk commented 3 years ago

Hm, they don't do any compilation in that project it seems. They just label the amd64 package as compatible with a lot of CPUs. If you're feeling adventurous you could try:

1. Clone this project

2. Modify `INFO.sh` and hard code `arch` to `x64 x86 apollolake avoton braswell broadwell broadwellnk bromolow cedarview denverton dockerx64 grantley purley kvmx64 x86_64` (that's what the Tailscale project uses)

3. Create new docker image and make a new build according to the README.

If this works then one of the architectures in that list allows it to be installed. If you figure out which one I may be able to make a geminilake compatible release.

Perform the steps here and try it. As long as you don't try to run wg-quick on startup I think everything should be OK, though no guarantees of course. If your NAS become unresponsive like for @developStorm try to restart it.

If it doesn't work, please provide dmesg output and your wireguard configuration.

MadWalnut commented 3 years ago

I can try this on my DS720+. I have cloned and replaced INFO.sh like you said. Now what do I fill in the build command for the arch?

sudo docker run --rm --privileged --env PACKAGE_ARCH=<arch> --env DSM_VER=6.2 -v $(pwd)/artifacts:/result_spk synobuild

developStorm commented 3 years ago

I tried this before:

sudo docker run --rm --privileged --env PACKAGE_ARCH=amd64 --env DSM_VER=6.2 -v $(pwd)/artifacts:/result_spk synobuild

But as you can see I ended up failing, so I'm not sure if that's the right parameter.

MadWalnut commented 3 years ago

I tried 3 different archs now:

amd64:

PlatformNotAvailableError:
[amd64] is not available platform.

apollolake: builds but I can't install it in DSM. Aborts with a generic error message.

geminilake: I get further than @developStorm in the OP but it fails later on during the build:

2020-10-15 05:30:50 (200 KB/s) - 'wireguard-linux-compat-1.0.20200908.tar.xz' saved [262708]

patching file wireguard-linux-compat-1.0.20200908/src/compat/Kbuild.include
Hunk #1 succeeded at 42 with fuzz 2.
make[1]: Entering directory '/source/WireGuard/wireguard-linux-compat-1.0.20200908/src'
make[2]: Entering directory '/source/WireGuard/wireguard-linux-compat-1.0.20200908/src'
make[2]: *** /usr/local/i686-pc-linux-gnu/i686-pc-linux-gnu/sys-root/usr/lib/modules/DSM-6.2/build: No such file or directory.  Stop.
make[2]: Leaving directory '/source/WireGuard/wireguard-linux-compat-1.0.20200908/src'
Makefile:26: recipe for target 'module' failed
make[1]: *** [module] Error 2
make[1]: Leaving directory '/source/WireGuard/wireguard-linux-compat-1.0.20200908/src'
Makefile:64: recipe for target 'wireguard-linux-compat-1.0.20200908/src/wireguard.ko' failed
make: *** [wireguard-linux-compat-1.0.20200908/src/wireguard.ko] Error 2
make: Leaving directory '/source/WireGuard'

[Error] Build project fail!

Time cost: 00:00:06 [Build-->WireGuard]
[INFO] Build WireGuard finished!

----------------- Time cost statistics -----------------
Time cost: 00:00:06 [Build-->WireGuard]

########################################################
      Error(s) occurred on project "WireGuard"
########################################################
1 projects, 1 failed.

[Error] Check [/logs/error.build] for fixing errors.

Install log
===========
cat: /build_env/ds.geminilake-6.2/logs.install: No such file or directory

/logs/error.build does not exist.

developStorm commented 3 years ago

Sorry I might have misled you, but I actually tried x64 and apollolake architecture: https://github.com/developStorm/synology-wireguard/actions/runs/209949062/workflow

I'm not sure why you weren't able to install the apollolake version since I was, at least, be able to install it before

developStorm commented 3 years ago

It doesn't seem like Synology provides a specific SDK for Gemini Lake (https://sourceforge.net/projects/dsgpl/files/toolkit/).

Apparently there is an official SDK for Gemini now, however, it doesn't compile properly - the error message is the same as @MadWalnut provided.

Kopernikus1979 commented 3 years ago

@runfalk

Maybe you can have a look now, since there's a official SDK for Gemini. I think if we have to wait for Synology for Wireguard support.....

babcoccl commented 3 years ago

Ran into the same problem. The problem is that at /usr/local/i686-pc-linux-gnu/i686-pc-linux-gnu/sys-root/usr/lib/ there is no 'modules' directory. In fact the only place that exists for DSM-6.2 is under this path: /usr/local/x86_64-pc-linux-gnu/x86_64-pc-linux-gnu/sys-root/usr/lib/modules/DSM-6.2/build/

Matige commented 3 years ago

The error when compiling for Geminilake using the recently released SDK is due to an error in pkgscripts-ng. I have already submitted a pull request (https://github.com/SynologyOpenSource/pkgscripts-ng/pull/26). For the Geminilake platform you should also skip applying memneq patch.

After applying these changes the package was built without any problems. Unfortunately, I don't currently have a Geminilake device to check its operation. However, two DS220+ are already coming to me, so I will soon find out if Wireguard works properly.

If you want to test a package yourself, the easiest way to build a package is to edit the build.sh file and change the line git clone https://github.com/SynologyOpenSource/pkgscripts-ng to git clone -b patch-1 https://github.com/Matige/pkgscripts-ng

Then run the docker build with the additional --env HAS_MEMNEQ=1 argument sudo docker run --rm --privileged --env PACKAGE_ARCH=geminilake --env DSM_VER=6.2 --env HAS_MEMNEQ=1 -v $(pwd)/artifacts:/result_spk synobuild

babcoccl commented 3 years ago

The error when compiling for Geminilake using the recently released SDK is due to an error in pkgscripts-ng. I have already submitted a pull request (SynologyOpenSource/pkgscripts-ng#26). For the Geminilake platform you should also skip applying memneq patch.

After applying these changes the package was built without any problems. Unfortunately, I don't currently have a Geminilake device to check its operation. However, two DS220+ are already coming to me, so I will soon find out if Wireguard works properly.

If you want to test a package yourself, the easiest way to build a package is to edit the build.sh file and change the line git clone https://github.com/SynologyOpenSource/pkgscripts-ng to git clone -b patch-1 https://github.com/Matige/pkgscripts-ng

Then run the docker build with the additional --env HAS_MEMNEQ=1 argument sudo docker run --rm --privileged --env PACKAGE_ARCH=geminilake --env DSM_VER=6.2 --env HAS_MEMNEQ=1 -v $(pwd)/artifacts:/result_spk synobuild

Thanks, I will do this on my 920+ tomorrow and report back.

Kopernikus1979 commented 3 years ago

@Matige @babcoccl

That's great news! After compiling could you share a version with me so I can test on my 920+?

Matige commented 3 years ago

@Kopernikus1979

WireGuard version: 1.0.20200908 WireGuard tools version: 1.0.20200827 libmnl version: 1.0.4

You use it at your own risk. I am not responsible for the consequences of using this package. WireGuard-geminilake-1.0.20200908.zip

Kopernikus1979 commented 3 years ago

@Matige

Thx! I'll report my results back.

babcoccl commented 3 years ago

@Matige

I've tried about 5 times now and got through some failed to download packages to completeness errors (they were ending the DL before they were complete for some reason) but now arrive at this error: DownloadToolkitError: ] 0% URL https://sourceforge.net/projects/dsgpl/files/toolkit/DSM6.2/ds.geminilake-6.2.env.txz does not exist. Please ask synology support for assistance. ] 0% ] 0% ] 0% [ERROR] pkgscripts-ng/EnvDeploy -p geminilake -v 6.2 failed! ] 0% cp: cannot create regular file '/build_env/ds.geminilake-6.2/etc/ssl/certs/': No such file or directory ] 0%

Matige commented 3 years ago

@babcoccl

Read the section Avoiding timeouts when downloading build files in README. You can download these files manually and map the folder to the /toolkit_tarballs Docker volume.

babcoccl commented 3 years ago

@Matige Even cloning the patch I'm still arriving at the same pkgscripts issue as before: make[1]: Entering directory '/source/WireGuard/wireguard-linux-compat-1.0.20200908/src' make[2]: Entering directory '/source/WireGuard/wireguard-linux-compat-1.0.20200908/src' make[2]: /usr/local/i686-pc-linux-gnu/i686-pc-linux-gnu/sys-root/usr/lib/modules/DSM-6.2/build: No such file or directory. Stop. make[2]: Leaving directory '/source/WireGuard/wireguard-linux-compat-1.0.20200908/src' Makefile:26: recipe for target 'module' failed make[1]: [module] Error 2

Matige commented 3 years ago

@babcoccl You must have gone wrong somewhere because I did the compilation in the morning and it all went smoothly. I even included the compiled package in the comment. Are you sure you have made changes in the build.sh file?

runfalk commented 3 years ago

@babcoccl make sure you have actually made a new Docker image. The build script is included in the image when you create it, so after each update to it you must rebuild the docker image.

babcoccl commented 3 years ago

@babcoccl You must have gone wrong somewhere because I did the compilation in the morning and it all went smoothly. I even included the compiled package in the comment. Are you sure you have made changes in the build.sh file?

You're right, I'm dumb, must not have escaped vim correctly when I thought I wrote.

@runfalk I actually did clean up everything manually to make sure I was starting fresh. Still getting the error above even after changing the build script and clearing everything out. I've reviewed @Matige changes and in theory I shouldn't be getting that incorrect path anymore. I'll keep playing with it and see if I can get anything different

babcoccl commented 3 years ago

Let me repeat, I am dumb ( I forgot to re-build the docker image). So long story short, here's the dumbed down version to get it up and running on your Geminilake: 1.git clone https://github.com/runfalk/synology-wireguard.git 2.cd synology-wireguard/

  1. sudo vi build.sh
  2. Locate line 36 (git clone https://github.com/SynologyOpenSource/pkgscripts-ng) position your cursor on it
  3. 'i' for insert
  4. Delete the line and replace with 'git clone -b patch-1 https://github.com/Matige/pkgscripts-ng'
  5. Escape key
  6. :wq Enter to exit vim
  7. sudo docker build -t synobuild .
  8. sudo docker run --rm --privileged --env PACKAGE_ARCH=geminilake --env DSM_VER=6.2 --env HAS_MEMNEQ=1 -v $(pwd)/artifacts:/result_spk synobuild

Now you should have a usable .spk in your artifacts folder. Thanks @runfalk and @Matige for figuring it out. Hopefully pkgscripts-ng merges your pull request soon, I approved it (not that that will do anything) :-)

runfalk commented 3 years ago

That repo does unfortunately seem quite abandoned from Synology. I might end up building the patch into this project to work around the issue.

babcoccl commented 3 years ago

That repo does unfortunately seem quite abandoned from Synology. I might end up building the patch into this project to work around the issue.

Or fork the pkgscripts-ng repo and maintain it in parallel? :-(

babcoccl commented 3 years ago

@runfalk I think you can close this one down as the manual build is pretty painfree

runfalk commented 3 years ago

I'll keep it open so people with Gemenilake can find it easily. I'll close it when Synology fixes their repo or when I get around to implementing the patch myself.

meptalon commented 3 years ago

You use it at your own risk. I am not responsible for the consequences of using this package. WireGuard-geminilake-1.0.20200908.zip

Thanks a million! This one does work well with my brand new DS220+ (geminilake) with the standard instructions provided on the main git page. Nothing extra like docker install or package build. Used it straight and it works like a charm.

runfalk commented 3 years ago

Seems like there are geminilake support is available now, so I'll close this.

runfalk commented 3 years ago

Turns out the support wasn't there quite yet, but I have merged a workaround based on @Matige's work.