1. Preparation
https://github.com/Xilinx/PYNQ-Networking
随着国产化进程的推进,相当的应用已经可在国产化服务器(ARM/X86)上运行,本文将使用容器以及虚拟化两种技术对ARM/X86服务器上运行高性能的Android桌面进行探索。
调研了一圈实现,业界性价比最高的还是用板卡。。但是初始研究成本高一些,决心做的话可以先买一些现成的深圳货,但是对于入门的厂商来说还是用arm服务器跑容器合适,毕竟是安卓。
Docker-Android
Anbox(LXC)
Xdroid
由于qemu的ARM模拟的VGA设备由于其天生架构问题,不能正常使用,因而暂时需要使用virtio-vga设备方可显示(https://www.linux-kvm.org/images/0/09/Qemu-gfx-2016.pdf)。
NetLogo is a very useful tools for ABM, and Python is also a handful language for building proof of concept.
In this post I will show you how to call python language in NetLogo. For more information please follow here.
breed [data-points data-point] breed [centroids centroid] globals [ any-centroids-moved? ] to setup clear-all set-default-shape data-points "circle" set-default-shape centroids "x" generate-clusters reset-centroids end to generate-clusters let cluster-std-dev 20 - num-clusters let cluster-size num-data-points / num-clusters repeat num-clusters [ let center-x random-xcor / 1.5 let center-y random-ycor / 1.5 create-data-points cluster-size [ setxy center-x center-y set heading random 360 fd abs random-normal 0 (cluster-std-dev / 2) ;; Divide by two because abs doubles the width ] ] end to reset-centroids set any-centroids-moved? true ask data-points [ set color grey ] let colors base-colors ask centroids [die] create-centroids num-centroids [ move-to one-of data-points set size 5 set color last colors + 1 set colors butlast colors ] clear-all-plots reset-ticks end to go if not any-centroids-moved? [stop] set any-centroids-moved? false assign-clusters update-clusters tick end to assign-clusters ask data-points [set color [color] of closest-centroid - 2] end to update-clusters let movement-threshold 0.1 ask centroids [ let my-points data-points with [ shade-of? color [ color ] of myself ] if any? my-points [ let new-xcor mean [ xcor ] of my-points let new-ycor mean [ ycor ] of my-points if distancexy new-xcor new-ycor > movement-threshold [ set any-centroids-moved? true ] setxy new-xcor new-ycor ] ] update-plots end to-report closest-centroid report min-one-of centroids [ distance myself ] end to-report square-deviation report sum [ (distance myself) ^ 2 ] of data-points with [ closest-centroid = myself ] end ; Copyright 2014 Uri Wilensky. ; See Info tab for full copyright and license.
TensorFlow version: 1.14
import numpy as np import tensorflow as tf num_points = 100 dimensions = 2 points = np.random.uniform(0, 1000, [num_points, dimensions]) def input_fn(): return tf.compat.v1.train.limit_epochs( tf.convert_to_tensor(points, dtype=tf.float32), num_epochs=1) num_clusters = 5 kmeans = tf.contrib.factorization.KMeansClustering( num_clusters=num_clusters, use_mini_batch=False) # train num_iterations = 10 previous_centers = None for _ in xrange(num_iterations): kmeans.train(input_fn) cluster_centers = kmeans.cluster_centers() if previous_centers is not None: print 'delta:', cluster_centers - previous_centers previous_centers = cluster_centers print 'score:', kmeans.score(input_fn) print 'cluster centers:', cluster_centers # map the input points to their clusters cluster_indices = list(kmeans.predict_cluster_index(input_fn)) for i, point in enumerate(points): cluster_index = cluster_indices[i] center = cluster_centers[cluster_index] print 'point:', point, 'is in cluster', cluster_index, 'centered at', center
Here’s the snapshot.
And here’s the code.
extensions [ py ] breed [data-points data-point] breed [centroids centroid] data-points-own [ cluster-id ] centroids-own [ cluster-id centx centy ] globals [ testoutput centroid-list ] to setup clear-all py:setup py:python (py:run "import tensorflow as tf" "import numpy as np" ) set testoutput py:runresult "1" py:set "testoutput" testoutput set-default-shape data-points "circle" set-default-shape centroids "x" generate-clusters ; For python py:set "num_points" num-clusters py:set "points" [list xcor ycor] of data-points py:set "num_clusters" num-clusters py:set "num_round" num-round if debug = True [ py:run "print('Points Cordinates:', points)" ;for debug ] ;reset-centroids end to generate-clusters set testoutput py:runresult "testoutput + 1" let cluster-std-dev cluster-range let cluster-size num-data-points / num-clusters repeat num-clusters [ let center-x random-xcor / 1.5 let center-y random-ycor / 1.5 create-data-points cluster-size [ setxy center-x center-y set heading random 360 fd abs random-normal 0 (cluster-std-dev / 2) ] ] end to train ; Cluster center (py:run "points = np.asarray(points)" "def input_fn():" " return tf.compat.v1.train.limit_epochs(tf.convert_to_tensor(points, dtype=tf.float32), num_epochs=1)" "kmeans = tf.contrib.factorization.KMeansClustering(num_clusters=num_clusters, use_mini_batch=False)" "num_iterations = num_round" "previous_centers = None" "for _ in range(num_iterations):" " kmeans.train(input_fn)" " cluster_centers = kmeans.cluster_centers()" " if previous_centers is not None:" " print(('delta:', cluster_centers - previous_centers))" " previous_centers = cluster_centers" " print(('score:', kmeans.score(input_fn)))" "print(('cluster centers:', cluster_centers))" "# map the input points to their clusters" "cluster_indices = list(kmeans.predict_cluster_index(input_fn))" "print('cluster indices: ', cluster_indices)" "for i, point in enumerate(points):" " cluster_index = cluster_indices[i]" " center = cluster_centers[cluster_index]" " print(('point:', point, 'is in cluster', cluster_index, 'centered at', center))" ) end to show-shape set centroid-list py:runresult "cluster_centers" foreach centroid-list [ x -> create-centroids 1 [ set xcor ( item 0 x ) set ycor ( item 1 x ) set size 3 set color white ] ] end
Ref:
[1] https://www.altoros.com/blog/using-k-means-clustering-in-tensorflow/
[2] https://www.tensorflow.org/api_docs/python/tf/contrib/factorization/KMeansClustering
Nowadays ARM-based servers are being applied to many scenarios, so we are going to port some workload to the minimal ARM SoC with NVIDIA GPU to evaluate the feasibility of production usage.
Hardware: Legacy ARM SoC boards, e.g. Raspberry Pi, Beagle Board, NVIDIA Jetson(GPU) and standard ARM-based servers.
MPI: OpenMPICH and MPICH2.
Share Storage: ARM-based Glusterfs with pNFS.
Application: ANY
Ref:
Before stepping into the virtio acceleration, we will build and run a Linux(PetaLinux) in FPGA.
Despite the poor performance of simulation in X86, it’s very convenient to create POC.
We choose MPSoC zcu106(PS) to test ARM, Zynq zc702(PS) to test ARM and Kintex UltraScale kcu705(PL) to test MicroBlaze softcore.
OS: Ubuntu 16.04 Desktop
Vivado: 2019.1
Xilinx SDK: 2019.1
PetalLinux SDK: PetaLinux 2019.1
BSP: Evaluation Board BSP or generated from Vivado/Xilinx SDK
QEMU is in the PetaLinux SDK directory, it’s not necessary to rebuild if you do not wanna modify anything.
git clone git://github.com/Xilinx/qemu.git cd qemu apt install libglib2.0-dev libgcrypt20-dev zlib1g-dev autoconf automake libtool bison flex libpixman-1-dev git submodule update --init dtc ./configure --target-list="aarch64-softmmu,microblazeel-softmmu" --enable-fdt --disable-kvm --disable-xen make -j4
petalinux-create -t project -n zcu106_arm_a53 --template zynqMP -s ../bsp/xilinx-zcu106-v2019.1-final.bsp petalinux-config # Decide what to build
After the project created, pre-built images is in directory pre-built. You can test it via petalinux-boot
petalinux-boot --qemu --prebuilt 3 # Start ZCU106 virtual machine with prebuilt kernel
To accelerate the sstate mirror check process, you need download the sstate cache in Ref [5].
If you are using petalinux as root, you need modify sanity.conf like this:
cat /opt/petalinux/v2019.1/components/yocto/source/aarch64/layers/core/meta/conf/sanity.conf # Sanity checks for common user misconfigurations # # See sanity.bbclass # # Expert users can confirm their sanity with "touch conf/sanity.conf" BB_MIN_VERSION = "1.39.1" SANITY_ABIFILE = "${TMPDIR}/abi_version" SANITY_VERSION ?= "1" LOCALCONF_VERSION ?= "1" LAYER_CONF_VERSION ?= "7" SITE_CONF_VERSION ?= "1" #INHERIT += "sanity"
petalinux-boot --qemu --prebuilt 3
#!/bin/bash /root/Desktop/qemu_zynq_devices/qemu/aarch64-softmmu/qemu-system-aarch64 \ -M arm-generic-fdt-7series -machine linux=on -smp 2 -m 1G \ -serial /dev/null -serial mon:stdio -display none \ -kernel images/linux/uImage -dtb images/linux/system.dtb
Now we’ll add sdcard and try to boot Ubuntu Core OS.
qemu-img create qemu_sd.img 2G -M arm-generic-fdt-7series -machine linux=on -smp 2 -m 1G \ -serial /dev/null -serial mon:stdio -display none \ -kernel images/linux/uImage -dtb images/linux/system.dtb
Ref:
[1] Build QEMU: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842060/QEMU
[2] Zynq UltraScale+ QEMU: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841606/QEMU+-+Zynq+UltraScalePlus
[3] CoSim: https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842109/QEMU+SystemC+and+TLM+CoSimulation
[4] Xilinx Evaluation Board BSP files and Yocto local mirror: https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html
As we all know, P4 is about to be the future of OpenFlow 2.0, and to achieve an totally software defined network with programmable control plane and data plane.
Since we’ve got P4 working on X86 server
In SDN controller ONOS.
Since the MicroBlaze provides the lockstep feature, so finally we can make a POC.
[1] Triple Modular Redundancy: https://www.xilinx.com/support/documentation/ip_documentation/tmr/v1_0/pg268-tmr.pdf
[2] Fault Tolerance Technique for Dynamically Reconfigurable Processor: https://pdfs.semanticscholar.org/2e98/b34ee8736eba7747b223c333de5739a6e601.pdf
[3] Xilinx Reduces Risk and Increases Efficiency for IEC61508 and ISO26262 Certified Safety Applications: https://www.xilinx.com/support/documentation/white_papers/wp461-functional-safety.pdf
[4] Spartan-6 FPGA Dual-Lockstep MicroBlaze Processor with Isolation Design Flow: https://www.xilinx.com/support/documentation/application_notes/xapp584-dual-lockstep-microblaze-IDF.pdf
[5] MicroBlaze Processor Reference Guide: https://www.xilinx.com/support/documentation/sw_manuals/xilinx2019_2/ug984-vivado-microblaze-ref.pdf
注意:本文内容仅限于实验室安全测试目的,禁止用于任何商业或违反当地法律法规的活动。
不管是较贵的Ettus还是入门的HackRF,抑或是最初级的RTL-SDR设备,都可以使用这篇教程中的绝大部分内容。
https://www.gnuradio.org/grcon/grcon17/presentations/
https://www.gnuradio.org/grcon/grcon18/presentations/
https://www.gnuradio.org/grcon/grcon19/presentations/
https://github.com/mossmann/hackrf/wiki
https://www.hackrf.net/hackrf%E4%B8%8Egnuradio%E5%85%A5%E9%97%A8%E6%8C%87%E5%8D%97/
http://www.hackrf.net/faq/
https://wiki.myriadrf.org/LimeSDR
https://myriadrf.org/news/limesdr-made-simple-part-1/
HackRF One | Ettus B200 | Ettus B210 | BladeRF x40 | LimeSDR | LimeSDR mini | |
---|---|---|---|---|---|---|
Frequency Range | 1MHz-6GHz | 70MHz-6GHz | 70MHz-6GHz | 300MHz-3.8GHz | 100kHz-3.8GHz | 100kHz-3.5GHz |
RF Bandwidth | 20MHz | 61.44MHz | 61.44MHz | 40MHz | 61.44MHz | 30.72MHz |
Sample Depth | 8 bits | 12 bits | 12 bits | 12 bits | 12 bits | 12 bits |
Sample Rate | 20MSPS | 61.44MSPS | 61.44MSPS | 40MSPS | 3.2MSPS | 61.44MSPS |
Transmitter Channels | 1 | 1 | 2 | 1 | 2 | 1 |
Receivers | 1 | 1 | 2 | 1 | 2 | 1 |
Duplex | Half | Full | Full | Full | Full | Full |
Interface | USB 2.0 | USB 3.0 | USB 3.0 | USB 3.0 | USB 3.0 | USB 3.0 |
Programmable Logic Gates | 64 macrocell CPLD | 75k | 100k | 40k (115k avail) | 40k | 40k |
Chipset | MAX5864, MAX2837, RFFC5072 | AD9364 | AD9361 | LMS6002M | LMS7002M | LMS7002M |
Open Source | Full | Schematic, Firmware | Schematic, Firmware | Schematic, Firmware | Full | Full |
Oscillator Precision | +/-20ppm | +/-2ppm | +/-2ppm | +/-1ppm | +/-1ppm initial
+/-4ppm stable |
+/-1ppm initial
+/-4ppm stable |
Transmit Power | -10dBm+ (15dBm @ 2.4GHz) | 10dBm+ | 10dBm+ | 6dBm | 0 to 10dBm | 0 to 10dBm |
Price | 249€ euros VAT Exc. | 991€ euros VAT Exc. | 1658€ euros VAT Exc. | 625€ euros VAT Exc. | 332€ euros VAT Exc. | 190€ euros VAT Exc. |
https://unicorn.360.com/blog/2017/04/12/LimeSDR-Getting-Started-Quickly/
https://oneguyoneblog.com/2016/09/15/sdrsharp-sdr-installing-windows-10/
下载SDR#后,重启按F7进入“禁用驱动签名”的运行模式,运行其中的install-rtlsdr.bat,替换第0个驱动
接收信号建议使用gqrx(MacOS、Linux),也可以用sdrsharp(Windows)。
https://www.rtl-sdr.com/big-list-rtl-sdr-supported-software/
$ port info gqrx $ sudo port install gqrx
接收信号以后,你可以做的内容就比较多了,这里我会举一些比较有意思的例子。
http://dalvikplanet.blogspot.com/2017/03/how-to-get-working-rtl2832u-r820t2-on.html
SDR软件
虚拟声卡
WXtoimg
gpredict/orbitron
https://www.rtl-sdr.com/rtl-sdr-tutorial-receiving-noaa-weather-satellite-images/
https://wischu.com/archives/528.html
GSM嗅探
https://www.cnblogs.com/k1two2/p/7000942.html
https://swling.com/blog/2016/04/guest-post-using-the-hackrf-one-for-dgps-beacon-reception/
http://sdrgps.blogspot.com/2016/12/rtl-sdr-to-orbit-with-limesdr.html
https://www.rtl-sdr.com/ksdr/
zigbee https://github.com/bastibl/gr-ieee802-15-4
https://github.com/BastilleResearch/scapy-radio/tree/master/gnuradio/gr-zigbee
https://gist.github.com/gyaresu/343ae51ecbb70486e270
https://www.cnblogs.com/k1two2/p/5477291.html#4245780
https://gorgias.me/2017/07/30/HackRF-GPS-%E6%AC%BA%E9%AA%97/
https://github.com/osqzss/LimeGPS
Windows软件sdrangel
http://gareth.codes/hackrf-transmit/
https://github.com/fsphil/hacktv
http://www.irrational.net/2014/03/02/digital-atv/
http://www.hackrf.net/2014/06/hackrf_nbfm_tx_n_ctcss_squelch/
http://www.xn--hrdin-gra.se/blog/wp-content/uploads/2015/08/nbfm-tx.grc
https://gist.github.com/gyaresu/343ae51ecbb70486e270
https://nuclearrambo.com/wordpress/transferring-a-text-file-over-the-air-with-limesdr-mini/
https://github.com/martinmarinov/TempestSDR
https://www.evilsocket.net/2016/03/31/how-to-build-your-own-rogue-gsm-bts-for-fun-and-profit/
https://yatebts.com/open_source/
https://cn0xroot.com/2017/01/10/iot-mode-fuzzing-with-openbt/
https://yq.aliyun.com/articles/310348
https://www.cnblogs.com/k1two2/p/5666667.html
https://cn0xroot.com/2017/04/12/limesdr-getting-started-quickly/
Prepare:
Ubuntu Desktop 16.04 & LimeSDR 1.4s with LimeSuite 17.12(If not, OpenUSRP will fail.)
#packages for soapysdr available at myriadrf PPA sudo add-apt-repository -y ppa:myriadrf/drivers sudo apt-get update #install core library and build dependencies sudo apt-get install -y git g++ cmake libsqlite3-dev #install hardware support dependencies sudo apt-get install -y libsoapysdr-dev libi2c-dev libusb-1.0-0-dev #install graphics dependencies sudo apt-get install -y libwxgtk3.0-dev freeglut3-dev # Install for building uhd sudo apt-get install libboost-all-dev libusb-1.0-0-dev python-mako doxygen python-docutils cmake build-essential
$ cd ~ # build and install limesuite $ git clone https://github.com/myriadrf/LimeSuite.git $ cd LimeSuite $ mkdir builddir && cd builddir $ cmake ../ $ make -j4 $ sudo make install $ sudo ldconfig $ cd ~ # build uhd, install, enable lime, rebuild $ git clone https://github.com/EttusResearch/uhd.git $ cd uhd/host/ $ mkdir build && cd build $ cmake ../ $ make -j4 $ sudo make install $ git clone https://github.com/jocover/OpenUSRP.git lib/ursp/OpenUSRP # DO NOT GO OUT $ echo "INCLUDE_SUBDIRECTORY(OpenUSRP)">>lib/ursp/CMakeLists.txt $ cmake ../ $ make -j4 $ sudo make install
$ git clone https://github.com/pothosware/SoapySDR $ cd SoapySDR $ mkdir builddir;cd builddir; cmake ../ $ make -j4 $ sudo make install $ git clone https://github.com/myriadrf/LimeSuite $ cd LimeSuite
软件定义无线电的内容即是可以灵活定义信号的处理过程,比如输出到TCP/UDP、文字音视频解码等。其中比较有名的有GNURadio、SoapySDR、Pothos(IDE)等(这里以GNURadio为例)。推荐在Linux中安装,当然也可在MacOS或者Windows中使用MacPorts进行安装,除此之外,也有PyBombs可选。
在MacOS中安装需要使用MacPorts、XQuartz,MacPorts安装内容如下。
$ port info gnuradio $ sudo port install gnuradio+wxgui gr-osmosdr sox $ port content gnuradio $ sudo port install hackrf $ sudo port install rtl-sdr $ sudo port search gr- # if you wanna more modules in gnuradio, don't be shy
然后打开XQuartz,将/opt/local/bin/gnuradio-companion加入到X自定义应用程序菜单中(建议修改默认的X终端程序内容为xterm -e “source ~/.bash_profile;/bin/bash”)。
https://greatscottgadgets.com/sdr/
https://gist.github.com/machinaut/addf3438ef0c1a9cad38
https://osmocom.org/projects/gr-osmosdr/wiki/GrOsmoSDR#RTL-SDRSource
https://pypi.org/project/pyrtlsdr/#description
UPDATE: 老王的笔记中也总结了一些关于devconf的内容。
This article is just a collection of ideas and posts.
Recently I was doing some performance-tunning of QEMU/KVM with kinds of pure-software ways. However, it ended with the existence of QEMU/KVM’s process load.
I just remembered that I used to do some co-sim work with National Instruments LabView about ten years ago…(during college life…fk…I’m still young…)
TBD: Start QEMU instance(s) with passthrough-ed PCI(PCI-SRIOV) devices like ethernet controller or NVMe controller designed in PCI FPGA to offload the emulated works.
TBD: Start QEMU instance with devices ported to passthrough-ed PCI FPGA as many as possible, i.e. usb controller, ethernet controller and etc..(Like a dock with kinds of devices…)
But I think it will be replaced by Trial No.1.
TBD: Co-Sim.
SoC FPGA, as DOM0.
ASIC offload with slight host management.
[1] Running Xilinx in QEMU, https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842060/QEMU
[2] Building Xen Hypervisor with Petalinux 2019.1, https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/99188792/Building+Xen+Hypervisor+with+Petalinux+2019.1
[3] QEMU SystemC and TLM CoSimulation, https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842109/QEMU+SystemC+and+TLM+CoSimulation
因为Jetson如果作为边缘设备,那么我们需要进一步探索虚拟化在其上的可能性,从而使FT有更容易的路线可走,还有既然它的芯片是PCIE的,那理应可以透传。
参考:https://elinux.org/Jetson/Nano/Upstream
什么build rootfs、uboot之类的就不要了,那是后期嵌入式的活,我们在现有环境上build kernel即可。
访问链接https://developer.nvidia.com/embedded/downloads并下载源码包,包括Jetson自有以及L4T源码,也可以点击如下链接直接下载。
https://developer.nvidia.com/embedded/dlc/l4t-sources-32-1-jetson-nano
解压其中的kernel部分。
https://developer.nvidia.com/embedded/dlc/l4t-jetson-driver-package-32-1-jetson-nano
下载并解压后,得到如下文件系统。
Host: sudo su sudo apt install nfs-kernel-server sudo echo "/home/lofyer/Downloads *(rw,no_root_squash,no_subtree_check)" >> /etc/exports sudo exportfs -avf Jetson Nano: sudo su apt instlal libncurses-dev mount root@192.168.0.59:/home/lofyer/Downloads /mnt cd /mnt/ cp /proc/config.gz . gunzip config.gz mv config .config make menuconfig # find and enable kvm, tegra hypervisor make -j4; make -j4 modules_install make -j4 Image cp arch/arm64/boot/Image /boot/Image-kvm
然后编辑启动项,默认从新kernel启动。
# vi /boot/extlinux/extlinux.conf TIMEOUT 10 DEFAULT secondary MENU TITLE p3450-porg eMMC boot options LABEL primary MENU LABEL primary kernel LINUX /boot/Image INITRD /boot/initrd APPEND ${cbootargs} rootfstype=ext4 root=/dev/mmcblk0p1 rw rootwait LABEL secondary MENU LABEL kernel with kvm LINUX /boot/Image-kvm INITRD /boot/initrd APPEND ${cbootargs} rootfstype=ext4 root=/dev/mmcblk0p1 rw rootwait
自带的:
apt install qemu-kvm kvm --help
自己编的:
git clone https://github.com/qemu/qemu cd qemu ./configure --enable-kvm make -j4
只能使用machine类型为arm进行加速。
算了,现在不看了,等下半年。