dragom / linino

1 stars 0 forks source link

Make bleno work on arduino yun #1

Open dragom opened 10 years ago

dragom commented 10 years ago

Issue is created to have on one place instructions how to upgrade linino(https://github.com/arduino/linino) to make bleno(https://github.com/sandeepmistry/bleno) work.

  1. upgrade bluetooth to latest version https://github.com/arduino/linino/issues/21 https://github.com/dragom/linino/releases/tag/bluez513
  2. make nodejs for linino http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html
  3. crosscompile bleno on pc.

    Probably you will need also bluez headers on proper place (TODO missing) http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html#comment-1162830776 copy libbluetooth.so to linino /usr/lib/

  4. install also stdbuf linino package

    http://download.linino.org/dogstick/linino_dev/latest/packages/coreutils-stdbuf_8.16-1_ar71xx.ipk https://dev.openwrt.org/ticket/11076

Probably still missing some bit and pieces.. After instructions are retested by more users wiki page will be created.

The best way to find out what is missing or goes wrong is to use strace. http://download.linino.org/dogstick/linino_dev/latest/packages/strace_4.7-1_ar71xx.ipk

sandeepmistry commented 10 years ago

Awesome work @dragom! I'll get a Yun and try it out.

Do you have johnny-five and bleno working together on the Yun? (see linino node.js wiki page)

dragom commented 10 years ago

No. Just node and bleno. But jonny-five looks very interesting. Mix of bleno and jonny-five stuff will do magic! If you stuck somewhere just let me now. Currently I just have weird problems in bleno l2cap-ble.c code on Yun. I need to replace while(stdinBuf[i] != '\n') { sscanf(&stdinBuf[i], "%02x", (unsigned int*)&l2capSockBuf[i / 2]); i += 2; } with this to make it work. while(stdinBuf[i] != '\n') { unsigned int data = 0; sscanf(&stdinBuf[i], "%02x", &data); l2capSockBuf[i / 2] = data; i += 2; }

sandeepmistry commented 10 years ago

Cool! I've ordered a Yun, so will try to take a look at this next week.

That change might be good to have in master, I'm guessing the issue is either Endian or memory related.

sandeepmistry commented 10 years ago

@dragom finally got bleno going on my Yun. I had to export CFLAGS and LDFLAGS to cross-compile bleno. Next to try with johnny-five!

dragom commented 10 years ago

Great! Let me know how it goes. For cross-compile I use modified build.sh from http://fibasile.github.io/compiling-nodejs-for-arduino-yun.html

export BASEDIR=/media/verbatim/work/linino/linino/trunk export STAGING_DIR=${BASEDIR}/staging_dir

export V8SOURCE=/media/verbatim/work/linino/node/v8m-rb

export PREFIX=${STAGING_DIR}/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-

export LIBPATH=${STAGING_DIR}/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/lib/

export AR=mips-openwrt-linux-uclibc-ar export CC=${PREFIX}gcc export CXX=${PREFIX}g++ export AR=${PREFIX}ar export RANLIB=${PREFIX}ranlib export LINK=$CXX

export LDFLAGS='-Wl,-rpath-link '${LIBPATH}

export TARGET_PATH=/media/verbatim/work/linino/node/opt

export GYPFLAGS="-Dv8_use_mips_abi_hardfloat=false -Dv8_can_use_fpu_instructions=false"

export npm_config_arch=mips

export npm_config_nodedir=/media/verbatim/work/linino/node/node-v0.10.20

cd node_modules/$1 node-gyp configure build

sandeepmistry commented 10 years ago

Thanks, I got it working, here's a gist: https://gist.github.com/sandeepmistry/8927095

A few things I have to do:

::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K shutdown
#ttyATH0::askfirst:/bin/ash --login

johnny-five takes a while to issue the board ready event, not too sure what's going on, but after it fires the gist can turn the LED on/off quickly, no issues.