vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

Openwrt Linux support

Open andrewgodman opened this issue 5 years ago • 17 comments

Can we have mips and ash shell support added? I was able to work around ash not working but I can't attempt to compile the remote server on mips as the source isn't open.

andrewgodman avatar Jun 01 '19 14:06 andrewgodman

how did you work around with bash not available ?

subramanian0331 avatar Jun 11 '19 23:06 subramanian0331

my box doesn't have bash.. it has ash and i am getting an error

subramanian0331 avatar Jun 11 '19 23:06 subramanian0331

@subni9 Sorry, so work around the issue I just installed bash on the device to see if it would work. @egamma Do you want a new request for ash/non bash terminal support instead?

andrewgodman avatar Jun 17 '19 11:06 andrewgodman

Aw.. yeah I am not allowed to install bash on my box. I do need a new request for ash support..

subramanian0331 avatar Jun 17 '19 14:06 subramanian0331

any updates on this ?

subramanian0331 avatar Jul 18 '19 19:07 subramanian0331

Hi! Trying to install the remote Sever for VS Code on GL.iNet GL-AR750 with Openwrt, receiving "Unsupported architecture error" - whole log see below. Is there a work around or a feature coming for mips architecture? I fulfilled the requirements: | OpenSSH server, bash, and curl or wget but is still missing or not up to date: kernel >= 3.10, glibc >=2.17, libstdc++ >= 3.4.18, Python 2.6 or 2.7, tar

[email protected] darwin x64 SSH Resolver called for "ssh-remote+gli_router", attempt 1 SSH Resolver called for host: gli_router Setting up SSH remote "gli_router" Using commit id "2213894ea0415ee8c85c5eea0d0ff81ecc191529" and quality "stable" for server Testing ssh with ssh -V ssh exited with code: 0 Got stderr from ssh: OpenSSH_7.9p1, LibreSSL 2.7.3 Running script with connection command: "ssh" -o ClearAllForwardings=true -o ConnectTimeout=15 "gli_router" bash Install and start server if needed

Running remote connection script Unsupported architecture: mips 0986b272-d53a-4363-9b1e-592defca0012##27## "install" terminal command done Received install output: 0986b272-d53a-4363-9b1e-592defca0012##27## Unsupported architecture The remote server architecture is not supported

TobSeCretR avatar Jul 28 '19 21:07 TobSeCretR

Ok my workaround is sshfs to mount my drive locally

TobSeCretR avatar Jul 31 '19 21:07 TobSeCretR

@TobSeCretR one of the devices I'm wanting support is a GL.iNet GL-AR750 as well. How did you find using sshfs?

andrewgodman avatar Sep 21 '19 06:09 andrewgodman

Hello everyone!

I suggest a solution for remoting through visual studio code insider (vs code-insider can remote device using Openwrt). For instance, in Openwrt-SDK folder, I choose "bash", "curl" (for dowload file) package when building the firmware. In this case, I use the Raspberry Pi model 3B hardware and use OpenSDK-18.06. But, it have still failed.

[10:41:08.959] > BusyBox v1.31.0 () multi-call binary. [10:41:08.959] >

[10:41:08.960] > Usage: ps [10:41:08.960] >

[10:41:08.960] > Show list of processes [10:41:08.961] >

[10:41:08.961] > w Wide output [10:41:08.962] > bash: line 224: printenv: command not found [10:41:08.963] > Starting server... [10:41:08.964] >

[10:41:08.977] > Waiting for server log... [10:41:08.978] >

[10:41:08.979] > sleep: invalid number '.5' [10:41:08.981] > Waiting for server log... [10:41:08.994] > sleep: invalid number '.5' [10:41:08.995] >

[10:41:08.996] > Waiting for server log... [10:41:08.997] > Waiting for server log... [10:41:08.998] > sleep: invalid number '.5' [10:41:09.009] > sleep: invalid number '.5' [10:41:09.010] > Waiting for server log... [10:41:09.010] >

[10:41:09.011] > sleep: invalid number '.5' [10:41:09.012] > Waiting for server log... [10:41:09.013] > sleep: invalid number '.5' [10:41:09.015] > Waiting for server log... [10:41:09.026] > sleep: invalid number '.5' [10:41:09.026] >

/root/.vscode-server-insiders/bin/313ede61cbad8f9dc748907b3384e059ddddb79a/server.sh: line 12: /root/.vscode-server-insiders/bin/313e [10:41:12.927] > de61cbad8f9dc748907b3384e059ddddb79a/node: not found [10:41:12.927] > [10:41:12.927] > <<< End of server log

nhanlee97

nhanleos avatar Oct 01 '19 11:10 nhanleos

Hello everyone,

I posted my solution for remoting a device using OpenWRT firmware. Link here (https://forum.openwrt.org/t/which-editor-for-develop-application/45815/4)

nhanlee97

nhanleos avatar Oct 06 '19 15:10 nhanleos

Is there any progress?

hd321kbps avatar Jul 21 '20 20:07 hd321kbps

My solution is to use RMate extension with Python Rmate server on the OpenWRT device. Similar Rmate server with in C can also be used.

whatnick avatar Aug 16 '20 09:08 whatnick

I've managed to make remote server work on my x86_64 Openwrt 19.07.6 device with the help of sgerrand/alpine-pkg-glibc.

image

Here's my step: First go to the release package of alpine-pkg-glibc and download glibc-2.32-r0.apk and glibc-bin-2.32-r0.apk (for test) to the internal storage of your openwrt device.

Then, manually extract two packages onto rootfs ( do at your own risk ):

tar -zxvf glibc-2.32-r0.apk -C /
tar -zxvf glibc-2.32-bin.apk -C /

Test this to confirm if the glibc is working:

root@Openwrt:~#  /usr/glibc-compat/bin/localedef
Try `localedef --help' or `localedef --usage' for more information.

Now we have basic glibc support on our Openwrt device, but to make remote-server eventually work, A few more steps need to be done. First, tarcommand from Openwrt busybox is incompatiable with remote server installation script, we need to copy a seperate tar binary and its depends from somewhere else. Here I choose to copy from wsl ubuntu 20.04 container on my laptop. Make sure you have rsync package installed previously on your Openwrt device. check the libraries .so file which tar depends:

$ ldd $(which tar)
        linux-vdso.so.1 (0x00007fffd7411000)
        libacl.so.1 => /lib/x86_64-linux-gnu/libacl.so.1 (0x00007fd6870c0000)
        libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fd687090000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd686e90000)
        libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007fd686e00000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd686df0000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fd687153000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd686dcd000)

Upload the tar binary to /usr/sbin/ of storage of openwrt device, override the busybox one:

$rsync -Pav $(which tar) root@Openwrt:/usr/sbin/

Upload the share libraries to /usr/glibc-compat/lib/ :

rsync -Pav $(find /usr/lib | grep libacl) root@Openwrt:/usr/glibc-compat/lib/
rsync -Pav $(find /usr/lib | grep libselinux) root@Openwrt:/usr/glibc-compat/lib/
rsync -Pav $(find /usr/lib | grep libpcre) root@Openwrt:/usr/glibc-compat/lib/
rsync -Pav $(find /usr/lib | grep libdl) root@Openwrt:/usr/glibc-compat/lib/

Now on Openwrt device type tar you can see the same output as you see on ubuntu/debian/arch.

At last, deal with node.js depends for remote-server.

ldd ~/.vscode-server/bin/ea3859d4ba2f3e577a159bc91e3074c5d85c0523/node
        linux-vdso.so.1 (0x00007ffff6ce8000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f62058f0000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f6205700000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f62055b1000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f6205590000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f620556d000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6205370000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f620591b000)

Upload the share libraries again:

rsync -Pav $(find /usr/lib | grep libdl) root@Openwrt:/usr/glibc-compat/lib/
rsync -Pav $(find /usr/lib | grep libstdc++) root@Openwrt:/usr/glibc-compat/lib/
rsync -Pav $(find /usr/lib | grep libm) root@Openwrt:/usr/glibc-compat/lib/
rsync -Pav $(find /usr/lib | grep libgcc_s) root@Openwrt:/usr/glibc-compat/lib/

Now you should able to connect to the x86_64 openwrt device with ssh-remote plugin. the plugin will show some warning about glibc, but it's harmless. Be noticed: this is x86_64 devices only so far.

hathlife avatar Feb 01 '21 13:02 hathlife

Thanks to @hathlife for the steps to install vscode-server on openwrt.

Here is what I'd like to share:

I installed this OpenWrt (arch x86_64, UEFI): https://drive.google.com/drive/folders/1seZiQR_HdXdo02n6MKjzg9VR96Ll6E27

I installed this glibc-compat: https://github.com/sgerrand/alpine-pkg-glibc/releases/tag/2.34-r0

I believe you can do opkg install tar to replace the one provided by busybox, then tar should be OK. I can see that the folder at ~/.vscode-server/bin/ is populated with the .tar.gz file downloaded. My vscode-server is at: /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3

I followed the instructions to rsync-copy stuff from my WSL 2 ubuntu 20.20 system. But this seems to cause problems:

# /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/node
/root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/node: error while loading shared libraries: libdl.so.2: object file has no dynamic section

# ldd node
        /lib64/ld-linux-x86-64.so.2 (0x7f7a641a8000)
        libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f7a641a8000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f7a640c2000)
        libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f7a641a8000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x7f7a640ae000)
        libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f7a641a8000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f7a641a8000)
        ld-linux-x86-64.so.2 => /lib/ld-linux-x86-64.so.2 (0x7f7a6407a000)
Error relocating /lib/ld-linux-x86-64.so.2: unsupported relocation type 37
Error relocating node: gnu_get_libc_version: symbol not found
Error relocating node: __register_atfork: symbol not found
Error relocating node: __strdup: symbol not found
Error relocating node: setcontext: symbol not found
Error relocating node: makecontext: symbol not found
Error relocating node: backtrace: symbol not found
Error relocating node: getcontext: symbol not found

# /usr/glibc-compat/bin/ldd /root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/node
/root/.vscode-server/bin/899d46d82c4c95423fb7e10e68eba52050e30ba3/node: error while loading shared libraries: libdl.so.2: object file has no dynamic section

Then I decided to overwrite those files from WSL Ubuntu by extracting the glibc-compat lib files again:

# tar xvf /root/glibc-bin-2.34-r0.apk
# tar xzf glibc-2.34-r0.apk -C /

Then the node binary can be run, and VS Code successfully connected to remote-ssh of my OpenWrt system. I also install git as follows:

opkg install git-http
opkg install ca-bundle

Now the issue I have is extension won't install, e.g., I clicked install for the Python plugin, it is just stuck, with button showing "installing".

zeroxia avatar Dec 31 '21 09:12 zeroxia

Here is my solution:

` opkg install node

cd .vscode-server/bin/long_hash/ rm node which node cp /usr/bin/node node `

It is to replace the built-in node.

fujiawei-dev avatar May 13 '22 01:05 fujiawei-dev

With Openwrt 21.02 and glibc-2.35, I can connect to my router but won't be able to open any folder with this error message "channel 3: open failed: connect failed: connection refused vscode" I solved it by following @hathlife 's instructions with glibc-2.32 then override all the files with glibc-2.35. Hope that helps.

j999yp avatar Aug 27 '22 08:08 j999yp

Here is my solution:

` opkg install node

cd .vscode-server/bin/long_hash/ rm node which node cp /usr/bin/node node `

It is to replace the built-in node.

Here is my solution:

` opkg install node

cd .vscode-server/bin/long_hash/ rm node which node cp /usr/bin/node node `

It is to replace the built-in node.

this works for me

57f4b3da avatar Sep 17 '22 00:09 57f4b3da

This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

VSCodeTriageBot avatar Dec 17 '22 03:12 VSCodeTriageBot

I found we don't need to install all files from glibc-2.32-r0.apk.

Here are my steps:

  1. Install bash opkg install bash

  2. Install tar opkg install tar

  3. Use vscode-remote to connect to openwrt, the zip file should be unzipped under /root/.vscode-server/bin/{long-hash} it also outputs errors like the following

> Waiting for server log...
> sleep: invalid number '.03'
> Waiting for server log...
> sleep: invalid number '.03'
  1. Install file opkg install file

  2. Check which program interpreter node depends on.

cd .vscode-server/bin/long_hash/
file node

For me, it outputs below, the interpreter is /lib/ld-linux-aarch64.so.1 ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=a8fad5e4f3f62678296d00632cf12c317efc7e15, with debug_info, not stripped For x86/64 system it would be /lib64/ld-linux-x86-64.so.2

  1. Locate this file on your other Linux system if available, or alternatively, download it from the official online glibc package site. In my situation, I can obtain it from the following source: https://archlinuxarm.org/packages/aarch64/glibc. You will only need to extract the /usr/lib/ld-linux-aarch64.so.1 file from this package
  2. Copy /lib/ld-linux-aarch64.so.1 to openwrt's same path
  3. Replace node
opkg install node
cd .vscode-server/bin/long_hash/
rm node
which node
cp /usr/bin/node node
  1. Connect from vscode again.

  2. I found an error that says line 40: getconf: not found, to solve this, just go to /root/.vscode-server/bin/long_has/bin/helpers/check-requirements.sh and change the following

BITNESS=$(getconf LONG_BIT)
To
BITNESS=64
64 is my arch

11 Connect again, working now. image

quanljh avatar Jan 21 '24 14:01 quanljh