nxhack / openwrt-node-packages

OpenWrt Project Node.js packages. v18.x TLS and v20.x LTS
GNU General Public License v2.0
259 stars 101 forks source link

Does this support linkit smart 7688? #8

Closed yangpu closed 6 years ago

yangpu commented 7 years ago

You may save my time if this support linkit smart 7688.

nxhack commented 7 years ago

I don't have linkit smart 7688. Please try it and Please report it. Regards

nxhack commented 7 years ago

@yangpu Compile was successful. But because I don't have target machine, I am unable to run test.

LEDE trunk r3748-48ae44d
CONFIG_TARGET_BOARD="ramips"
CONFIG_TARGET_SUBTARGET="mt7688"
CONFIG_TARGET_PROFILE="DEVICE_LinkIt7688"
CONFIG_TARGET_ARCH_PACKAGES="mipsel_24kc"
jcrben commented 7 years ago

@nxhack I noticed that Atheros AR933x has a caveat - but what hardware are you testing or developing on?

nxhack commented 7 years ago

@jcrben It is running on "Arduino Yun". Of course kernel FPU emulation is enabled.

system type             : Atheros AR9330 rev 1
machine                 : Arduino Yun
cpu model               : MIPS 24Kc V7.4
nxhack commented 7 years ago

There was a report that it was running at "ramips". So I will close this issue.

Cleanshooter commented 7 years ago

I would love to test this I have a LInkit 7688 lying around but I'm not sure how to run the compiler... Any getting started tips? Would it require me to flash my LinkIt with LEDE or can it run directly on OpenWRT?

nxhack commented 7 years ago

Hi @Cleanshooter

https://lede-project.org/toh/hwdata/mediatek/mediatek_linkit_smart_7688 Please read the nice documentations : https://lede-project.org/faq/before_installation (make a kernel with CONFIG_MIPS_FPU_EMULATOR=y) Read this for building custom packages for node.js. Custom packages can be installed with luci. Enjoy!

nxhack commented 7 years ago

If you want to rebuild mediatek 's firmware.

Read 'Build the firmware from source codes' https://docs.labs.mediatek.com/resource/linkit-smart-7688/en/tutorials/firmware-and-bootloader/build-the-firmware-from-source-codes

and use https://github.com/nxhack/openwrt-node-packages/tree/for-15.05

Hopefully it may work. I will try a some. wait a moment.

Cleanshooter commented 7 years ago

@nxhack thanks for the reply... yeah I was looking at the first few links for lede and I'm just not well versed enough with the project to understand it's setup. Plus all the getting started stuff looked like I needed to install it on my device which I'd rather avoid.

I'm going to try rebuilding the MediaTek firmware just to ensure compatibility. I'll let you know how it goes.

nxhack commented 7 years ago

Hi @Cleanshooter MediaTek Build the firmware from source codes + add some modifications.

  1. Install prerequisite packages to build the firmware:
    sudo apt-get install git g++ libncurses5-dev subversion libssl-dev gawk libxml-parser-perl unzip wget

    1-1. Make working directory

    mkdir Build_Path_Some_Where
    cd Build_Path_Some_Where
  2. Download the OpenWrt CC source codes:
    git clone git://git.openwrt.org/15.05/openwrt.git
  3. Prepare the default configuration file for feeds:
    cd openwrt
    cp feeds.conf.default feeds.conf
  4. Add the LinkIt Smart 7688 development board's feed:
    echo 'src-git linkit https://github.com/MediaTek-Labs/linkit-smart-7688-feed.git' >> feeds.conf

    4-1. Add the node.js packages feed:

    echo 'src-git node https://github.com/nxhack/openwrt-node-packages.git;for-15.05' >> feeds.conf
  5. Update the feed information for all available packages to build the firmware:
    ./scripts/feeds update

    5-1. Change the packages installed as default:

    wget https://gist.githubusercontent.com/nxhack/7ced4d866a59ebc72737589b49a220f8/raw/1bebfe9f6091f55a5856bc4af00da456a4995b09/mtk-linkit.patch
    patch -p1 < mtk-linkit.patch

    5-2. Copy kernel objects for support kernel 3.18.45: see : https://github.com/MediaTek-Labs/linkit-smart-7688-feed/issues/37

    cp ./feeds/linkit/mtk-sdk-wifi/wifi_binary/mt_wifi.ko_3.18.44 ./feeds/linkit/mtk-sdk-wifi/wifi_binary/mt_wifi.ko_3.18.45
    cp ./feeds/linkit/mtk-sdk-wifi/wifi_binary/mt_wifi.ko_3.18.44_all ./feeds/linkit/mtk-sdk-wifi/wifi_binary/mt_wifi.ko_3.18.45_all

    5-3. Fix build error of depend on node.js version:

    wget https://gist.githubusercontent.com/nxhack/4357d51918ba8f3cb5cc00080ad0815c/raw/e96758224ade8cb224523aedf5ea3249a6a59425/MRAA.patch
    patch -p1 < MRAA.patch

    5-4. Prepare for building node.js(patch to toolchain)

    patch -p1 < ./feeds/node/for_building_latest_node.patch

    5-5. FIX: git submodule command not work properly.

    wget https://gist.githubusercontent.com/nxhack/78fa1df0a1224a168191dd1ab5b3336e/raw/94b6ded945c61809103e529ddbc41cb4cb757792/fix-git-submodule.patch
    patch -p1 < fix-git-submodule.patch
  6. Install all packages:
    ./scripts/feeds install -a

    6-1. Use node.js custom packages:

    rm ./package/feeds/packages/node
    rm ./package/feeds/packages/node-arduino-firmata
    rm ./package/feeds/packages/node-cylon
    rm ./package/feeds/packages/node-hid
    rm ./package/feeds/packages/node-serialport
    ./scripts/feeds install -a -p node
  7. Prepare the kernel configuration:
    make menuconfig

Select the following options:

Target System: Ralink RT288x/RT3xxx Subtarget: MT7688 based boards Target Profile: LinkIt7688

7-1. Select optional packages of node.js custom feed. You can select version of node.js and modules that you need.

Save and exit (use the default configuration file without any modification)

  1. Start the compilation process:
    make V=99

Add toolchain patch steps. 28/07/2017 Add fix git submodule not work 16/08/2017

Cleanshooter commented 7 years ago

@nxhack You found some of the pieces I was missing... I got some of them but not all the stuff you did above.

I just finished a build of my own and right now and I'm trying to flash it... but it just won't take.

I'm going to start a new build with some of your suggestions and let it run over night...

Cleanshooter commented 7 years ago

7-1. Select optional packages of node.js custom feed.

Save and exit (use the default configuration file without any modification)

How do I do this? In the makeconfig? What menu options do I need to use? Do I go to Languages and select Node.js and then select all those libraries? Not super familiar with this utility.

nxhack commented 7 years ago

Hi @Cleanshooter

7-1. Select optional packages of node.js custom feed.

Save and exit (use the default configuration file without any modification)

How do I do this? In the makeconfig? What menu options do I need to use? Do I go to Languages and select Node.js and then select all those libraries? Not super familiar with this utility.

In the node custom feed, if there is a module you want, select it.

make menuconfig

Languages -> Node.js -> (Select module that you want)

If '*' it will be put into firmware. 'M' will be only built, not put into firmware.

Cleanshooter commented 7 years ago

Hey I just wanted you to know this works great! Would you have any objections to me posting the built image on my blog for people to download and flash to their firmware or would you rather host it in the repo?

Also, I'm curious what the patches would look like to do a v6 build... is it possible to do a build for Nodejs v6 (current LTS). I was checking the other posts and @cooboyno111 mentioned that he pulled it off...

I successfully compiled nodejs6. on Chaos Calmer(15.05) . You need to change toolchain from uclibc0.9 to uclibc-ng 1.0.6. You need to remove ICU support. The librpc version of the library that needs to be modified is 2015-11-04. Uclibc-ng 1.0.6 adds support for C99, which is required by nodejs6. If you use glibc to compile openwrt, CC might be passed.

I'm guessing this would mean another patch to the openwrt repo...

nxhack commented 7 years ago

Hey I just wanted you to know this works great! Would you have any objections to me posting the built image on my blog for people to download and flash to their firmware or would you rather host it in the repo?

Congrats! And Now, You are not a beginner of OpenWrt! Open your knowledge is wonderful. But I don't know license issue of LInkit firmware. Please ask mediatek.

I'm guessing this would mean another patch to the openwrt repo...

https://github.com/nxhack/openwrt-node-packages/blob/for-15.05/README.md Chaos Calmer(15.05) still not supported?

Please try, Please challenge.

cooboyno111 commented 7 years ago

I can run nodejs v6 on mt7628 chip。 I don't have a mt7688 device on this side。 linkit-smart-7688-feed.git dependency GDB 7.8 server. GDB 7.8 server cannot compiler in openwrtcc with unlibc-ng。 I'm trying to compile using the uclibc0.9.33.2 patch。 patch -p1 < ./feeds/node/for_building_latest_node.patch make toolchain/clean linkit-smart-7688-feed.git pass I remove GDB 7.8 server from Package/mtk-linkit compiler pass in openwrtcc with unlibc-ng。

Cleanshooter commented 7 years ago

@cooboyno111

I'd love to know what changes to made to this repo to compile in node v6.

Did/could you fork this repo so that I could look at your changes?

nxhack commented 7 years ago

@Cleanshooter The 'for-15.05' branch is modified. Prepared necessary patches for build latest node.js version.

Please following steps.

./scripts/feeds update node
make oldconfig
patch -p1 < ./feeds/node/for_building_latest_node.patch
make toolchain/clean
make

You can select version of node.js in menuconfig. (default version is v6)

Since the npm module has been separated, please select it if necessary.

Cleanshooter commented 7 years ago

DUDE!!! The updates you've made are great! I'm running the build right now. I'll let you know how it goes. It took me a while to find the version selector in the make menuconfig but I see you defaulted to v6 (<-- Thx).

@nxhack You made my day. I'm hoping with this I'll finally be able to run my app on my LinkIt 7688. I was really bummed out when I saw that openWRT only had Node 0.12.7 OOTB and it took a lot of digging to find your wonderful repo. Thank you so much for sharing it! A lot of my code and dependencies needed Node v6, which I only found out after a few failed compile attempts.

Cleanshooter commented 7 years ago

Worked! I'm about to test my app on it now. I would note to others that you can't fit all the packages on the LinkIt 7688 though. The entire thing has to be under 30MB (I think) and if you add too many node libraries it will blow up on you. All I added was NPM and it came out to 25MB.

nxhack commented 7 years ago

@Cleanshooter If you want extend target machine's filesystem, You can use extroot mechanizm. https://docs.labs.mediatek.com/resource/linkit-smart-7688/en/tutorials/file-storage/mounting-the-root-fs-on-an-sd-card

cooboyno111 commented 7 years ago

@Cleanshooter remove ICU,remove NPM. LinkIt 7688 9.4M

nxhack commented 7 years ago

Oh, libmraa, libupm build will fail in situation of node.js v8.x. But I do not care at this point. ;)

Cleanshooter commented 7 years ago

@cooboyno111 I might remove them but for some that might not be a viable option as npm is used by some packages/software during run time.

cooboyno111 commented 7 years ago

@Cleanshooter In ejdb, for example, you need to understand the file structure of node_modules and what can be streamlined. i remove 3 line add 1line //var binary = require('node-pre-gyp'); //var path = require('path'); //var ejdblib_path = binary.find(path.resolve(path.join(__dirname, './package.json'))); var ejdblib = require('./ejdb_native.node'); Only three files were eventually committed to the firmware ejdb.js ejdb_native.node package.json Original program 45m。 Streamlined 1.5m

tcpipchip commented 6 years ago

Does it works to LEDE ? I Got illegal instruction when runs Node

tcpipchip commented 6 years ago

I mean node 8 on lede on linkit smart 7688

nxhack commented 6 years ago

Let's hack and try hard by referring to this.

https://github.com/changyuheng/linkit-smart-7688-feed

And, Be sure to enable MIPS_FPU_EMULATOR kernel option.

tcpipchip commented 6 years ago

I will try again soon! That procedure includes Node 8 package and libmraa ? Thank you so much! I hope to use your amazing azure amazon ibm packages :)

nxhack commented 6 years ago

That procedure includes Node 8 package and libmraa ?

No.

enable node.js v8.x :

echo 'src-git node https://github.com/nxhack/openwrt-node-packages.git' >> feeds.conf
./scripts/feeds update node
rm ./package/feeds/packages/node
rm ./package/feeds/packages/node-*
./scripts/feeds install -a -p node
make menuconfig

Please do the related hack described above.

libmraa's node.js v8.x support seems to be difficult. hack please and Good luck!

tcpipchip commented 6 years ago

Thanks! I will report you monday!

tcpipchip commented 6 years ago

still getting ILLEGAL INTRUCTION when runs NODE

i enable the FPU EMULATION on make kernel_menuconfig

nxhack commented 6 years ago

@tcpipchip

Please tell me the result of executing this command on your target machine.

ls -l /sys/kernel/debug/mips/fpuemustats
node --version
npm --version
tcpipchip commented 6 years ago

I compiled again node v8 to linkit smart 7688, but now on ubuntu 17. And i had to remove some package dependencies of node! I guess that now will works! https://github.com/MediaTek-Labs/linkit-smart-7688-feed?files=1 Tomorrow i will test!

tcpipchip commented 6 years ago

Now all is working! Linkit running LEDE with NODE V8 :)

tcpipchip commented 6 years ago

Btw, thank you for all the help! next step to see if libmraa compile

tcpipchip commented 6 years ago

LIBMRAA not works on LEDE. Did you get some progress there ?

tcpipchip commented 6 years ago

Still no success on LIBMRAA here :(

btw, about node-node-red-contrib-gpio How can i do the NODE-RED see this NODE in the NODE-RED WEB ?

nxhack commented 6 years ago

@tcpipchip

Please test this. https://github.com/nxhack/openwrt-intel-iot-devkit

tcpipchip commented 6 years ago

Thank you so much! Doing now the compile!

tcpipchip commented 6 years ago

make[4]: Entering directory '/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb' make[4]: 'libhidapi-libusb.so' is up to date. make[4]: Leaving directory '/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb' mv /home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb/libhidapi-libusb.so /home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb/libhidapi-libusb.so.0 mv: '/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb/libhidapi-libusb.so' and '/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb/libhidapi-libusb.so.0' are the same file Makefile:77: recipe for target '/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/.built' failed make[3]: [/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/.built] Error 1 make[3]: Leaving directory '/home/osboxes/Lede/linkit-smart-7688-lede/feeds/packages/libs/hidapi' package/Makefile:105: recipe for target 'package/feeds/packages/hidapi/compile' failed make[2]: [package/feeds/packages/hidapi/compile] Error 2 make[2]: Leaving directory '/home/osboxes/Lede/linkit-smart-7688-lede' package/Makefile:101: recipe for target '/home/osboxes/Lede/linkit-smart-7688-lede/staging_dir/target-mipsel_24kc_musl-1.1.16/stamp/.package_compile' failed make[1]: [/home/osboxes/Lede/linkit-smart-7688-lede/staging_dir/target-mipsel_24kc_musl-1.1.16/stamp/.package_compile] Error 2 make[1]: Leaving directory '/home/osboxes/Lede/linkit-smart-7688-lede' /home/osboxes/Lede/linkit-smart-7688-lede/include/toplevel.mk:205: recipe for target 'world' failed make: [world] Error 2

tcpipchip commented 6 years ago

Second time

make[4]: Entering directory '/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb' make[4]: 'libhidapi-libusb.so' is up to date. make[4]: Leaving directory '/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb' mv /home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb/libhidapi-libusb.so /home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb/libhidapi-libusb.so.0 mv: '/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb/libhidapi-libusb.so' and '/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/libusb/libhidapi-libusb.so.0' are the same file Makefile:77: recipe for target '/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/.built' failed make[3]: [/home/osboxes/Lede/linkit-smart-7688-lede/build_dir/target-mipsel_24kc_musl-1.1.16/hidapi-0.8.0-rc1/.built] Error 1 make[3]: Leaving directory '/home/osboxes/Lede/linkit-smart-7688-lede/feeds/packages/libs/hidapi' package/Makefile:105: recipe for target 'package/feeds/packages/hidapi/compile' failed make[2]: [package/feeds/packages/hidapi/compile] Error 2 make[2]: Leaving directory '/home/osboxes/Lede/linkit-smart-7688-lede' package/Makefile:101: recipe for target '/home/osboxes/Lede/linkit-smart-7688-lede/staging_dir/target-mipsel_24kc_musl-1.1.16/stamp/.package_compile' failed make[1]: [/home/osboxes/Lede/linkit-smart-7688-lede/staging_dir/target-mipsel_24kc_musl-1.1.16/stamp/.package_compile] Error 2 make[1]: Leaving directory '/home/osboxes/Lede/linkit-smart-7688-lede' /home/osboxes/Lede/linkit-smart-7688-lede/include/toplevel.mk:205: recipe for target 'world' failed make: [world] Error 2

tcpipchip commented 6 years ago

Removed HIDLIB from menuconfig and compiled. need to test the bin :)

tcpipchip commented 6 years ago

libupm, libmraa installed! I need to test with node-red

nxhack commented 6 years ago

@tcpipchip Did the running test succeed? If it works, I will send pull request it in the official package of OpenWrt.

tcpipchip commented 6 years ago

@nxhack I can today 18/04 make import the LIBUPM libs from python. Next step is make NODE import too... And config the LIBMRAA to view the GPIOS, I2C, SPI... For example pin = mraa.Gpio(44) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/site-packages/mraa.py", line 734, in init this = _mraa.new_Gpio(pin, owner, raw) ValueError: Invalid GPIO pin specified Can you help us ?

nxhack commented 6 years ago

I do not have mt7688, so I can not confirm it. Please check first that gpio is recognized by OS.

ls -l /sys/class/gpio/
tcpipchip commented 6 years ago

Only 3 gpios! Is there some option to enable on make menuconfig ?

nxhack commented 6 years ago

check

ls -l /sys/devices/platform
nxhack commented 6 years ago

FYI: https://github.com/intel-iot-devkit/mraa/issues/620 https://wiki.openwrt.org/doc/hardware/port.gpio