Cross Compiling OpenCV for Xilinx Zynq Arm on Ubuntu Linux OS

I am writing this to keep a log for myself and others whenever I want to cross compile OpenCV for Xilinx Zynq – ARM platform for Ubuntu 14.04. I have followed instructions mentioned on Xilinx-Wiki however I had to tweak quite a few instructions for me at a few places in order to successfully compile OpenCV. I have chosen to download and compile OpenCV-2.4.9 in particular. I did this a while ago so the Xilinx Vivado tools are older versions Vivado 2014.4. I have not tried on other versions of Ubuntu and OpenCV but I think it should still work. I have not listed any OS level dependencies that is required before attempting to start cross compiling OpenCV for Xilinx Zynq. The prerequisite is that the Xilinx Vivado tools have been installed correctly in Ubuntu /opt/Xilinx/ directory and can be invoked from Linux shell prompt. The following are my compilation of the instructions:

  1. First install Xilinx Vivado Tools successfully without any problems in /opt/Xilinx/Vivado folder.
  2. Create a text file (env_opencv_xilinx) with the following environment variables to be sourced so that the Vivado tools are available on command line:
  3. export CROSS_COMPILE=arm-xilinx-linux-gnueabi-
    source /opt/Xilinx/Vivado/2014.4/settings64.sh
  4. Source env_opencv_xilinx file
  5. Download OpenCV-2.4.9 from http://opencv.org/downloads.html
  6. Unzip and untar OpenCV and place it in /home/user/opencv-2.4.9 folder
  7. Download ffmpeg-2.8.10 from http://www.ffmpeg.org/download.html#releases
  8. Unzip and untar FFmpeg folder. I chose to move the ffmpeg-2.8.10 folder inside the opencv-2.4.9 folder.
  9. Change directory inside the ffmpeg-2.8.10 folder
  10. Run: ./configure –enable-shared –disable-static –cross-prefix=arm-xilinx-linux-gnueabi- –arch=armv7l –target-os=linux –prefix=/home/user/opencv-2.4.9_arm/ffmpeg-2.8.10/
  11. Add the following paths in the env_opencv_xilinx and source it again:
  12. export LD_LIBRARY_PATH=/home/user/opencv-2.4.9_arm/ffmpeg-2.8.10/lib:${LD_LIBRARY_PATH}
    export C_INCLUDE_PATH=/home/user/opencv-2.4.9_arm/ffmpeg-2.8.10/include:${C_INCLUDE_PATH}
    export CPLUS_INCLUDE_PATH=/home/user/opencv-2.4.9_arm/ffmpeg-2.8.10/include:${CPLUS_INCLUDE_PATH}
    export PKG_CONFIG_PATH=/home/user/opencv-2.4.9_arm/ffmpeg-2.8.10/lib/pkgconfig:${PKG_CONFIG_PATH}
  13. Create a folder called build within the opencv-2.4.9 directory.
  14. Add the following lines in a text file called toolchain.make and place it in the /home/user/opencv-2.4.9/ folder:
  15. set( CMAKE_SYSTEM_NAME Linux )
    set( CMAKE_SYSTEM_PROCESSOR arm )
    set( CMAKE_C_COMPILER arm-xilinx-linux-gnueabi-gcc )
    set( CMAKE_CXX_COMPILER arm-xilinx-linux-gnueabi-g++ )
    set( CMAKE_INSTALL_PREFIX /home/user/opencv-2.4.9_arm/build )
    set( CMAKE_FIND_ROOT_PATH /opt/Xilinx/SDK/2014.4/gnu/arm/lin/arm-xilinx-linux-gnueabi )
  16. Copy all the generated SO library files from ffmpeg-2.8.10/lib/ folder to opencv-2.4.9/build/lib folder otherwise OpenCV build process may not find the FFmpeg libraries automatically.
  17. Change directory into the build folder.
  18. I have chosen to set the BUILD_opencv_nonfree=ON as I would like to explore the algorithms available in the non-free of OpenCV.
  19. Run: cmake -D CMAKE_TOOLCHAIN_FILE=toolchain.make -D BUILD_opencv_nonfree=ON /home/user/opencv-2.4.9_arm/
  20. Check the configuration information of OpenCV to confirm the FFmpeg library is detected.
  21. Customise Build options by running: ccmake .
  22. I have chosen to keep WITH_JPEG and WITH_PNG set to ON so that the applications can read and write JPEG and PNG format image files, however Xilinx recommends the following options to be set to OFF
  23. WITH_1394, WITH_CUDA, WITH_CUFFT, WITH_EIGEN, WITH_GSTREAMER, WITH_GTK, WITH_JASPER, WITH_OPENEXR, WITH_PVAPI, WITH_QT, WITH_TBB, WITH_TIFF, WITH_UNICAP, WITH_V4L, WITH_XINE
  24. First press ‘c’ then ‘g’ to generate new Makefile. Alternatively edit CMakeCache.txt to modify build options. Check that WITH_FFMPEG=ON in CMakeCache.txt to enable FFmpeg support.
  25. Run: make
  26. Copy and Save build/lib/libopencv_core.so.2.4.9 in a different folder than lib.
  27. Run: make install .If all goes well then there will not be any errors however I did get an error here saying libopencv_core.so.2.4.9 not found, flagged by the module/core/cmake_install.cmake script. I checked that this particular SO was generated however during the make install process, due to may be some incorrectly generated command in some script it gets removed. I did not have time to debug this in detail however I fond a work around to complete the installation.
  28. Edit build/modules/core/cmake_install.cmake and remove the following lines, this will not generate the error during “make install” and the installation should now complete:
  29. “FILE(INSTALL DESTINATION “${CMAKE_INSTALL_PREFIX}/lib” TYPE SHARED_LIBRARY FILES
    “/home/jj901099/opencv-2.4.9_arm/build/lib/libopencv_core.so.2.4.9”
    “/home/jj901099/opencv-2.4.9_arm/build/lib/libopencv_core.so.2.4”
    “/home/jj901099/opencv-2.4.9_arm/build/lib/libopencv_core.so”
    )”
  30. Copy the saved libopencv_core.2.4.9 back to the build/lib/ folder. That’s it.

If I have not missed any step then Opencv-2.4.9 should have now compiled in the opencv-2.4.9/build directory, enjoy image processing.

 

Share Button

My First, Hand Soldered SMD PCB with FPGA – Papilio Duo

This is my first experience with hand soldering SMD components. Assembled the Paplio Duo board by completely hand soldering and it works! I could not have done it without the help and guidance of my fellow members at RLAB. So proud to be able to successfully solder the Xilinx Spartan 6 FPGA on this board :).

Website for this Open Source board is at Gadget Factory .

rajpapilio1

Share Button

Installing Altera Modelsim on 64-bit Ubuntu 14.04 – Linux

I downloaded and the ModelSim-Altera Starter Edition for Linux from Altera (now part of Intel) website at the following webpage:

http://dl.altera.com/?product=modelsim_ae#tabs-2

I then installed it on the 64-bit Ubuntu-14.04. After which I ran the following command from within the bin directory of the installed Modelsim and despite the executable present I got the following error:

command$> ./vsim: No such file or directory

I investigated further on internet and found that I require 386 – 32-bit libraries for Ubuntu since the Modelsim seems to be 32-bit. So I took the following steps on the Linux command prompt:

$>sudo dpkg –add-architecture i386
$>sudo apt-get update
$>sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
$>sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0

After installing the above, and invoking vsim, I got the following error:

libXft.so.2: cannot open shared object file

So I took the following steps:

$>sudo apt-get install libxft2 libxft2:i386 lib32ncurses5

Then I got the following error and to fix that I took the following steps

libXext.so.6: cannot open shared object file. libXext.so.6 not found

$>sudo apt install libxext6

$>sudo apt install libxext6:i386

And finally, this solved the problem. I was able to invoke Modelsim using ./vsim command.

Share Button

DIY Solar Charging Station for Electronic Gadgets

DIY Solar Charging Station for Electronic Gadgets using an existing Mobile Power Bank, Solar Panel and charging cable with multiple pins (Mobile Phone, Tablet, Power Bank etc.).

 

IMG_20150614_124716

IMG_20150614_124935

 

IMG_20150614_125044

IMG_20150614_125203

IMG_20150614_125003

IMG_20150614_125635

IMG_20150614_125655

IMG_20150614_125454

Share Button

Oxford Launch 2014 Weekend

Participated in the weekend long event called Oxford Launch 2014 . The aim was to come up with a Minimum Viable Product at the end of the weekend. Twitter page of the Oxford Launch event.

B2-ailDCAAAaDUN

 

B3D0bcvIgAEabU9

Then I joined the team SenseCrowd

B3JgyUXCcAACQHf

 

B3Ju-jSCYAAcx1M

 

ByYy3JZIAAEgCTX

 

 

Share Button

NanoSat Weekend at Satellite Applications Catapult

IMG_20150926_174842

 

IMG_20150926_120041

IMG_20150926_125153

 

IMG_20150926_125148

IMG_20150926_125141

IMG_20150926_125136

IMG_20150926_134833 (Large)

 

 

Share Button

My Second Quadcopter

Here I would like to show you the second Quadcopter that I built.

IMG_20150609_205048

 

Share Button

Unboxing My Very Own Zedboard

I purchased my very own Zedboard in order to work on some of the cool FPGA stuff at my home in my Electronic Lab. This board has the state-of-the-art Xilinx Zynq 7020 FPGA. Here I show unboxing the contents of the Zedboard that I received.

IMG_20150925_155200

 

IMG_20150925_155259

 

IMG_20150925_155307

 

IMG_20150925_155316

 

IMG_20150925_155338

 

IMG_20150925_155651

 

 

Share Button

EkZee: A Portable Gadget to Remove Viruses from USB Drives (Kickstarter Campaign)

I ran a campaign on the kickstarter.com in order to mass manufacture this device however due to insufficient marketing the campaign did not meet its goal. Nevertheless I gained valuable experience and feedback from people around the world. Currently I am improving EkZee based on the feedback. And I think now I know what to do in order to make such a crowd funding campaign a success. So this proves one of the well known NLP presuppositions: There is no failure, only feedback :).

https://www.kickstarter.com/projects/1675461711/ekzee-a-portable-gadget-to-remove-viruses-from-usb

EkZee is a portable, pocket-sized, standalone electronic device which detects and deletes executables that can contain virus on USBs

beware

ekzee1

This USB stick could infect your computer with viruses.

Don’t worry help is at hand! All you need is EkZee (Patent Pending) and your worries are over. Simple to use, deadly effective (for computer bugs/viruses).

So, what is EkZee?

EkZee is a pocket-sized and standalone electronic device which detects and deletes all the executables that can contain malware (short for malicious software such as virus and spyware) from the USBs. EkZee is a patent pending technology.

ekzee2

Why can’t a conventional PC based anti-virus software be used to clean USBs?

It is often too late to use the conventional anti-virus software in the computer to disinfect the infected USB flash drive. This is due to the fact that many viruses can easily circumvent or infect the pre-installed anti-virus software in a PC ultimately rendering the anti-virus systems ineffective.

So you can not risk cleaning the USBs using your PC when you do not know what it is infected with. Many times malware can get into your computers and spread infection as soon as USBs are plugged in.

The EkZee Habit is Simple: How Does It Work ?

If you have any USBs you need to Get the EkZee Habit

On a single press of a button EkZee detects and pre-emptively deletes all the executables that can contain malware such as viruses and spyware from the USB flash drive prior to insertion into a computer.

This is simple, cheap but powerful way of preventing malware contagion carried by team members; particularly those who are often working on-the-move; attending external meetings and wish to be able to exchange documents with clients and collaborators readily using a USB – EkZee frees them to do so free from any risk or worry.

So please EkZee your USB before using it on your computer or lending it to anyone to use on their computer – EkZee USBs every time before use; the EkZee Habit; is simple and essential for cyber security.

EkZee is a standalone independent device and does not require a conventional PC to carry out its operation.

EkZee remains impenetrable to malware so it cannot get infected while carrying out its operation. This is because EkZee ‘s own functional code is stored in its unmodifiable internal architecture.

EkZee does not affect data files such as word processor, PDF, image, video files and spread-sheets etc.

Computers that control critical infrastructure such as power stations, gas stations, utilities, nuclear reactors, space stations and other industries are prone to virus infection by removable storage devices. This is because the transport of data in and out of these computers is typically carried out using USBs which can act as malware carriers rapidly spreading the infection across the organisation.

Malware can steal personal information and passwords. Malware can remotely control your PC, transmit confidential information from your PC, download new malware and cause significant and sometimes irreversible losses and damage to enterprise reputation and business, critical infrastructure such as power stations, gas stations, industries and utilities etc. which are typically controlled by computers.

Background: What is Computer Malware?

“Malware, short for malicious software, is software used or programmed by attackers to disrupt computer operation, gather sensitive information, or gain access to private computer systems.’Malware’ is a general term used to refer to a variety of forms of hostile or intrusive software. Malware includes computer viruses, spyware, adware and other malicious software.” (Source: Wikipedia)

How Do USBs Get Infected ?

USB flash drives are widely used as a convenient, portable, high storage and cost-effective means of data transfer. USBs have no built-in protection against malware.

Therefore USBs are susceptible to becoming infected by malware and could easily spread the infection to other computers.

When a USB flash drive is connected to an infected PC, the virus from the infected PC propagates into the flash drive and infects it.

The infected USB flash drive becomes a carrier and in turn spreads the virus into other PCs when the drive is plugged into the PCs to transfer or copy any data.

Similarly, other USB flash drives are in turn infected further once they access the infected PC. The infected PC then infects other computers on the network and in this way the infection rapidly spreads into many computers and USB flash drives.

The malware which in this way finds its way into the heart of the enterprise then can start stealing information and disturbing it as well as potentially sabotaging enterprise devices and operations including business process and mission critical structures.

EkZee very cost-effectively and rapidly breaks the chain of malware infection from USB to personal computers (PC) and to other USBs and stops them all becoming carriers spreading the malware far and wide within and beyond the organisation.

Specifications: EkZee version 1.0

At present we have our own proprietary way of malware detection and removal in EkZee.

EkZee currently supports USBv1.1 and USBv2 based flash drives and memory cards (Requires a separate USB memory card reader to read Secure Digital – SD, CompactFlash).

Power Requirements

EkZee is currently powered by a standard USB port on a PC or a laptop.

We will supply a USB to mini-usb cable with every EkZee unit. EkZee has a mini usb connector to which the supplied cable is connected to power the EkZee unit. This makes EkZee a battery-less device and hence less expensive to produce, sell and run.

Supported Filesystems

EkZee currently supports FAT12, FAT16 and FAT32 file systems on USB flash drives and memory cards having a single partition (typical).

EkZee has been successfully tested to work with flash drives upto sizes of 128GB.

Detected Malwares

EkZee comes preloaded with definitions to detect more than 100 Microsoft Windows Operating System (trademark of Microsoft Inc.) based executables that can contain malware. EkZee can also detect hidden executable files. EkZee has been tested with real malware samples as well.

Definitions and Firmware Update

We are planning to provide updates for EkZee firmware and malware definitions (a subscription based service) on our website. Since EkZee requires additional hardware and firmware support for the updates, we are exploring potential solutions for the implementation of the update process within EkZee.

Disclaimer & License Agreement (Limitation of Liabilities)

We have carried out extensive testing to make sure EkZee performs as specified without affecting any of the non-executable user data. However, by buying (backing) EkZee the buyer (here Kickstarter backer) agrees that in no event shall the inventors/suppliers/manufacturers/creators of EkZee be liable to the buyer (here Kickstarter backer) for any (incidental or accidental or consequential or otherwise) damage or loss of data or program or else as a result of using EkZee. Supplier’s (here Creators of EkZee) maximum liability under this contract shall be limited to the purchase price of the Product (here EkZee). Furthermore, we reserve the right to alter specifications, features and products at any time without prior notice.

Full license agreement will be published on EkZee website. This is Inline with the disclaimers and license agreements other anti-virus vendors have on their websites.

How Was EkZee born ?

It all began with a thought when I visited India in 2011. While downloading pictures from a memory card removed from a camera the anti-virus in my computer gave a warning that there was a virus in the memory card. This triggered a chain of thought in my mind. The camera belonged to someone whom I knew, a local person in India. The only way a virus could have entered into the memory card of the camera could have been while downloading pictures to a computer which must have been infected with a computer virus. I thought if I can find a way to remove viruses from the memory card i.e. a removable storage devices, the spread of such viruses/malware could be easily stopped. Also the virus removal device has to be a separate standalone device which should function outside of any personal computer. Such a device must not get infected while carrying out its operation. Also it must not affect other normal data files like images, documents etc.

And this is how the original idea of EkZee was born!

What Have We Done So Far?

After initial thought about EkZee, we wanted to create a proof-of-concept. So we first created the EkZee prototype on a breadboard by wiring a few components and a high-performance microprocessor. The following two images show the very first EkZee prototype wired on the breadboard.

EkZee Circuit on a Breadboard, The Very First EkZee

EkZee Circuit on a Breadboard, The Very First EkZee

Afterwards, in order to reduce the power consumption of the EkZee circuit, we replaced the previously selected high-performance microprocessor with a low-power and a low-performance one.

Further, in order to reduce the physical size of the circuit we decided to create the EkZee prototype on a general purpose printed circuit board.

The following two images show EkZee prototype embedded on a general purpose PCB.

EkZee Circuit Tested on a General Purpose PCB, Component Side
EkZee Circuit Tested on a General Purpose PCB, Component Side
EkZee Circuit on a General Purpose PCB, Solder Side
EkZee Circuit on a General Purpose PCB, Solder Side

PCB Design & Layout

In order to reduce the physical size even further and make EkZee extremely small so it could fit perfectly to a user’s pocket almost like a USB, we decided to use Surface Mounted (very tiny) components. These components are extremely difficult to solder onto a general purpose PCB. Hence we created our first Printed Circuit Board (PCB) design and layout for the EkZee prototype. We have had the above PCB manufactured professionally and have successfully tested the functionality. The following sections and images show pictures of EkZee prototype and its functionality.

Manufactured PCB Prototype

Manufactured PCB for EkZee, Top Side
Manufactured PCB for EkZee, Top Side
Manufactured PCB for EkZee, Bottom Side
Manufactured PCB for EkZee, Bottom Side

EkZee Prototype

We would like to show you the images of our EkZee prototype. We have successfully tested EkZee on various USB flash drives and memory cards.

EkZee Printed Circuit Board, Prototype From Inside
EkZee Printed Circuit Board, Prototype From Inside

As you can see in the above image, the actual size of EkZee circuit is quite small but we have used an off-the-shelf enclosure for the prototype which makes it look bigger than it need be but the future prototypes will be provided in custom-sized packaging that allows the EkZee unit to be offered in small match box or even smaller sizes.

EkZee Can be Powered from a USB Port of a Computer or a Phone-Charger with a USB Port
EkZee Can be Powered from a USB Port of a Computer or a Phone-Charger with a USB Port
USB Flash Drive is inserted into EkZee
USB Flash Drive is inserted into EkZee
Press a Button to Bring EkZee Into Action
Press a Button to Bring EkZee Into Action
EkZee Works On Memory Cards as well
EkZee Works On Memory Cards as well
EkZee in Action with a Memory Card
EkZee in Action with a Memory Card
EkZee Working, Indicated by the Red LED.
EkZee Working, Indicated by the Red LED.

What you see in the above photos is an actual working prototype. We’ve developed several prototypes that we’re using for testing and for development. Our Hardware design is complete and our software is under beta test at the moment but it is very stable and we are very close to finalizing so that our EkZees will soon be ready for shipping to our users.

Current Enclosure Design

We have designed a plastic enclosure for the 1st Batch of EkZees. The designed enclosure is such that no screws are required to close the case which reduces the cost of production. The top and bottom ends simply click in.

EkZee, Plastic Click Case Prototype. Bottom Circuit Holder.
EkZee, Plastic Click Case Prototype. Bottom Circuit Holder.
EkZee, Plastic Click Case Prototype. Top Cover.
EkZee, Plastic Click Case Prototype. Top Cover.
EkZee PCB Inside the Designed Enclosure
EkZee PCB Inside the Designed Enclosure

The image of the British pound coin in the following image serves to show the size of the final EkZee.

EkZee, Plastic Case, Click Design. Closed. Pocket Sized.
EkZee, Plastic Case, Click Design. Closed. Pocket Sized.
Share Button

My First Quad-Copter

img-20150125-wa0002

img-20150125-wa0003

img-20150125-wa0004

img-20150211-wa0014

Sharing with you the first flight of the first quad-copter that I ever built from scratch at my home lab in my garage.

 

 

Share Button