本文主要目的为测试这块板子的性能,看看其是否有作为边缘节点的能力。

Env

Ubuntu 18.04(jetson-nano-sd-r32.1-2019-03-18)

Prepare

$ sudo set -i 's/ports.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
$ sudo apt install -y curl x11vnc openjdk openjfx libopenjfx-jni libopenjfx-java

Build

$ git clone https://github.com/NetLogo/NetLogo
$ cd NetLogo
$ git submodule update --init
$ ./sbt netlogo/compile

Run and Package

$ ./sbt netlogo/run
$ ./sbt dist/buildNetLogo

Addon: Add VNC server to your board

$ sudo apt install -y x11nvc
$ x11vnc # to generate ~/.vnc files
$ echo 'x11vnc --loop &' >> ~/.xsessionrc

Ref

https://github.com/NetLogo/NetLogo/wiki/Building

https://github.com/NetLogo/NetLogo/wiki/Releasing

I’ve got a NetGear R6300 V2 in hand.

As you already know, installing openvswitch in openwrt is very simple now. But for openflow, you need rebuild the openwrt image.

Install openvswitch

In any openwrt system you can just do:

root@OpenWrt:~# opkg update
root@OpenWrt:~# opkg install kmod-openvswitch
root@OpenWrt:~# opkg install openvswitch
root@OpenWrt:~# ovsdb-tool create

To build the openflow supported openwrt, you need:

Build openwrt

OS: Ubuntu 14.04
Openwrt source: https://downloads.openwrt.org/chaos_calmer/15.05/bcm53xx/generic/OpenWrt-SDK-15.05-bcm53xx_gcc-4.8-linaro_uClibc-0.9.33.2_eabi.Linux-x86_64.tar.bz2

Prepare your build env:

root@ubuntu# apt-get install build-essential binutils flex bison autoconf gettext texinfo sharutils subversion libncurses5-dev ncurses-term zlib1g-dev gawk git ccache
root@ubuntu# git clone https://github.com/CPqD/openflow-openwrt.git
root@ubuntu# tar xf OpenWrt-SDK-15.05-bcm53xx_gcc-4.8-linaro_uClibc-0.9.33.2_eabi.Linux-x86_64.tar.bz2
root@ubuntu# cd OpenWrt-SDK-15.05-bcm53xx_gcc-4.8-linaro_uClibc-0.9.33.2_eabi.Linux-x86_64
root@ubuntu# ln -s openflow-openwrt/openflow-1.3/files
root@ubuntu# cd packages/
root@ubuntu# ln -s ~/openflow-openwrt/openflow-1.3/
root@ubuntu# cd ..
root@ubuntu# make menuconfig

Select the OpenFlow package under Network and build the image.

root@ubuntu# make -j4 V=s

Bugfix: gdbm build ERROR

$ make V=s package/gdbm/{clean,configure}
change prefix from "...buildbot..." to "/home/demo/OpenWrt..."
$ make V=s

屏幕快照 2015-12-01 上午12.41.59

屏幕快照 2015-12-01 上午10.18.25

屏幕快照 2015-12-01 上午10.16.45

屏幕快照 2015-12-01 上午2.02.02

屏幕快照 2015-12-01 上午1.10.52

files:

backup-OpenWrt-2015-11-30.tar

root@OpenWrt:~# ovs-vsctl show
ebcae155-3c74-4088-a0bd-1802438f7148
    Bridge "ovsbr0"
        Port "eth0.3"
            Interface "eth0.3"
        Port "ovsbr0"
            Interface "ovsbr0"
                type: internal
        Port "wlan0"
            Interface "wlan0"
        Port "eth0.4"
            Interface "eth0.4"
config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'fd6d:a096:2bef::/48'

config interface 'lan'
	option force_link '1'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option _orig_ifname 'eth0.1 radio0.network1'
	option _orig_bridge 'true'
	option ifname 'eth0.1'

config interface 'wan'
	option ifname 'eth0.2'
	option force_link '1'
	option proto 'dhcp'

config interface 'wan6'
	option ifname 'eth0.2'
	option proto 'dhcpv6'

config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '3 5t'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '4 5t'

config switch_vlan
	option device 'switch0'
	option vlan '3'
	option ports '2 5t'

config switch_vlan
	option device 'switch0'
	option vlan '4'
	option ports '1 5t'

config switch_vlan
	option device 'switch0'
	option vlan '5'
	option ports '0 5t'

config interface 'port3_eth04'
	option proto 'none'
	option ifname 'eth0.4'
	option auto '1'

config interface 'port4_eth05_admin'
	option proto 'static'
	option ifname 'eth0.5'
	option netmask '255.255.255.0'
	option ipaddr '192.168.2.1'

config route

config interface 'port2_eth03_nm'
	option proto 'static'
	option ifname 'eth0.3'

config interface 'ovsbr0'
	option proto 'static'
	option ifname 'ovsbr0'
	option ipaddr '192.168.77.1'
	option netmask '255.255.255.0'
	option type 'bridge'

config interface 'wlan0'
	option proto 'none'
config wifi-device 'radio0'
	option type 'mac80211'
	option channel '11'
	option hwmode '11g'
	option path '18000000.axi/bcma0:7/pci0000:00/0000:00:00.0/0000:01:00.0/bcma1:1'
	option txpower '20'
	option country '00'

config wifi-iface
	option device 'radio0'
	option mode 'ap'
	option ssid 'OpenWrt-1'
	option key 'password'
	option encryption 'none'
	option network 'wlan0'
sleep 10
/etc/init.d/openvswitch restart

今日入手Nexus5美版(D820)
blahblahblah…
好吧,开始unlock以及root

先下载这个包,里面包含CM的镜像,unlock/lock的apk
http://cloud.lofyer.org/public.php?service=files&t=af14640b4f32d2e491d80a117db2bbe9

下载完成后,同时按住音量上下键再按开机,进入bootloader的前奏(相当于bios选项),此时电脑上应该会有所表示(比如windows的弹出要安装驱动啦,没驱动下个sdk搜索一下,比如linux的dmesg啦)

解压下载的文件,运行里面的root-$YOUROS(win、mac、linux)脚本,然后你看到请求unlock的选项,选择unlock并按电源键确认,此时pc上的脚本也会让你下一步;
下一步就是出现红色的机器人,说正在写脚本以及镜像,在写的时候pc上的脚本再下一步就可以自动让它退出了,然后稍等几分钟让它重启,重启的时候你会看到google标志下面的锁标志。

出于莫名其妙的安全感,在root以后可以安装压缩包里面的apk文件将bootloader再次锁上,这样,就这样。

两者都入手已经一个月了,可平时有些忙(惰者多忙),也就只零零散散准备了一些资料,还没开始整合。
整个流程大概是这个我用文字描述的粗略的样子:

空间建模:获取飞行器初始坐标,与leapmotion的可视区域进行map。
一级控制:leapmotion获得的手掌运动信息(可预处理)进入arduino通过nfr2401发送给X4,进行粗略运动指令传达。
二级控制:根据摄像头采集的飞行器位置数据与手掌位置信息对比,进行二阶指令传达。
回馈控制:在二级控制的基础上进行微调。
错误返回:如果超出leapmotion可视范围,则进行回馈控制将X4返回初始位置(0,0,0),超出摄像头范围,则需。。。人工重置。

在Windows中

夹持器与四轴飞行器都是Arduino-Based,通信就用串口。
代码放在git.lofyer.org
感觉VS好难。。试试在gentoo下驱动leapmotion

在Gentoo下使用,这个方式应该适用于所有非debian系

先下载sdk包,下载后解压。
看到里面有个deb的包,用alien转化为tar包

alien -t Leap-0.8.0-x64.deb
tar xf leap-0.8.0.tgz
cp -irf usr/* /usr/local/
cp -irf lib/udev/rules.d/25-com-leapmotion-leap.rules /etc/udev/rules.d

然后将普通用户加入plugdev组

sudo usermod -a -G plugdev $USER

刷新组关系,注销当前用户也可

exec su -l $USER

运行leapd与LeapControlPanel即可

在64位机器上缺少32位库文件
freetype.so.6, libasound.so.2

sudo emerge -avt app-emulation/emul-linux-x86-xlibs
sudo emerge emul-linux-x86-soundlibs

实例:编译MotionVisualizer

Make -C Builds/Linux

卖家太给力了,昨天就顺丰发货,今天下午我冒着炎炎烈日去取货,激动。。

先来张盒子,看着就感觉那帮老外工业设计功底深厚。
DSC_0003

开箱:Leapmotion一台,数据线两根(一长一短),说明书一张
DSC_0006

看着感觉好爽的样子~~~
DSC_0008

我拍的一段简单使用视频。

已经在官网注册并下载了sdk(windows、linux,我没Mac),设备不出意外下个月到。
等到了再更新文章,到时会更新sdk配置,与arduino交互的相关代码。
可控的目前想到了飞行器、机械手(夹持器 – -)。

We had a wiki here.
http://elinux.org/RPi_Xorg_rpi_Driver#Design

And vc sdk on github. It’s also in /opt/vc.
https://github.com/raspberrypi

X using gpu.
https://github.com/simonjhall/fbdev_exa

Playback accelerating.
http://wiki.matthiasbock.net/index.php/Hardware-accelerated_video_playback_on_the_Raspberry_Pi

Compile gstreamer{*} in Pi
http://permalink.gmane.org/gmane.comp.video.gstreamer.devel/43011

Using wayland instead of X
Here’s the build instruction
http://wayland.freedesktop.org/raspberrypi.html
For recently PI_DEBIAN img, we should just

apt-get install weston weston-dev

Using xwayland to run X application in wayland..

Notes:
1. If you’re going to compile cairo using egl, you shall meet a problem like undeclared ‘None’, just DEFINE one as 0L.
2. Using soft link rather than copying one when library is missing.

Waiting4Test
Tuning Rasbian
Speedup CPU:
raspi-config
arm_freq=900
I always use this hack and my rpi run without problem
Change scheduler/elevator at boot time:
we use more responsive/less disk io usage scheduler:
modify the /boot/cmdline.txt

dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=120,data=writeback elevator=deadline rootwait quiet

Tuning sysctl.conf:
as manual say, sysctl.conf is the “Configuration file for setting system variables”… well there are lot of variables you can put inside this file and for everyone we can write a book.
Our goal is to gain more speed and tell our system to use less io/ram. Let’s put in the /etc/sysctl.conf:

vm.dirty_background_ratio = 20
vm.dirty_expire_centisecs = 0
vm.dirty_ratio = 80
vm.dirty_writeback_centisecs = 1200
vm.overcommit_ratio = 2
vm.laptop_mode = 5
vm.swappiness = 10

Tuning SDCard:
Quite hard to understand, but changing the partition alignment of the SDCard can highly improve the write speed of our sdcard. Basically we have to align the first partition to the erase block size of our sdcard. I suggest to read an reread the reference link.
To do that in our sdcard that contain our RaspberryPI Debian distro we have to:
backup our filesystem from linux:
cd /media/mymmcblk0p2/ (the partitition that’s contain debian fs)
tar -cvpzf /home/gibbio/RPI-TC_fs.tgz –exclude=./proc –exclude=./lost+found –exclude=./sys –exclude=./mnt –exclude=./media –exclude=./dev ./
cd /media/mymmcblk0p1/ (the partitition that’s contain boot kernel etc)
tar -cvpzf /home/gibbio/RPI-TC_boot.tgz ./
Now use printcsd.py to find the erase block size, most sd have 128K so we use 128K/Sector size = 256 sectors (mine have 64k so we have to use 64k/512b = 128 sector alignement)

sfdisk -f -H224 -S56 /dev/mmcblk0
Checking that no-one is using this disk right now …
OK
Disk /dev/mmcblk0: 244448 cylinders, 224 heads, 56 sectors/track
Old situation:
Units = cylinders of 6422528 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/mmcblk0p1 0 – 0 0 0 Empty
/dev/mmcblk0p2 0 – 0 0 0 Empty
/dev/mmcblk0p3 0 – 0 0 0 Empty
/dev/mmcblk0p4 0 – 0 0 0 Empty
Input in the following format; absent fields get a default value.

Usually you only need to specify and (and perhaps ).
/dev/mmcblk0p1 :,8,c
/dev/mmcblk0p1 0+ 7 8- 50175+ c W95 FAT32 (LBA)
(enter enter)
/dev/mmcblk0p2 :
/dev/mmcblk0p2 8 1246 1239 7771008 83 Linux
/dev/mmcblk0p3 :
/dev/mmcblk0p3 0 – 0 0 0 Empty
/dev/mmcblk0p4 :
/dev/mmcblk0p4 0 – 0 0 0 Empty
New situation:
Units = cylinders of 6422528 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/mmcblk0p1 0+ 7 8- 50175+ c W95 FAT32 (LBA)
/dev/mmcblk0p2 8 1246 1239 7771008 83 Linux
/dev/mmcblk0p3 0 – 0 0 0 Empty
/dev/mmcblk0p4 0 – 0 0 0 Empty
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Do you want to write this to disk? [ynq] y
Successfully wrote the new partition table
Re-reading the partition table …
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)

gibbio # fdisk -l…
Disk /dev/mmcblk0: 8010 MB, 8010072064 bytes
224 heads, 56 sectors/track, 1247 cylinders, total 15644672 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ee283
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 1 100351 50175+ c W95 FAT32 (LBA)
/dev/mmcblk0p2 100352 15642367 7771008 83 Linux

now create ext4 FS:
mke2fs -t ext4 -E stripe-width=32 -m 0 /dev/mmcblk0p2
make FAT32 partition via gparted
gibbio # fdisk /dev/mmcblk0
Command (m for help): p
Disk /dev/mmcblk0: 8010 MB, 8010072064 bytes
224 heads, 56 sectors/track, 1247 cylinders, total 15644672 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ee283
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 1 100351 50175+ c W95 FAT32 (LBA)
/dev/mmcblk0p2 100352 15642367 7771008 83 Linux
Command (m for help): x
Expert command (m for help): p
Disk /dev/mmcblk0: 224 heads, 56 sectors, 1247 cylinders
Nr AF Hd Sec Cyl Hd Sec Cyl Start Size ID
1 00 0 2 0 223 56 7 1 100351 0c
2 00 0 1 8 223 56 1023 100352 15542016 83
3 00 0 0 0 0 0 0 0 0 00
4 00 0 0 0 0 0 0 0 0 00
Expert command (m for help): b
Partition number (1-4): 1
New beginning of data (1-100351, default 1): 128
Expert command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Now eject the sdcard, reinsert and make the restore from the tgz:
cd /media/mymmcblk0p2/
tar -xvpzf RPI-TC_fs.tgz -C ./
mkdir proc mnt sys boot dev
umount /media/mymmcblk0p2/
cd /media/mymmcblk0p1/
tar -xvpzf RPI-TC_boot.tgz -C ./
umount /media/mymmcblk0p1/
Eject the sdcard, plug into our Raspberry Pi and power on!

DigitalWrite(pin,HIGH);
DELAY(10);
DigitalWrite(pin,LOW)
DELAY(10);

观察波形(上升沿触发)频率是51Hz,峰值为0.520V(使用外接电源的情况下,USB作电源为0.505V)。
除掉市电滤波的原因,应该是128本身Timer造成的问题,因DELAY使用的是Timer,选中的端口同样为Timer可用的端口,故在电平维持时可看到波形有毛刺(示波器太烂了吧)。
psb