2020

Archive 2020

Install embedded Linux toolchain on windows

Published at November 25, 2020 ·  2 min read

The toolchain for embedded Linux should be matched for the target image, and that is why we can’t just find and download it from somewhere. Therefore, we should be it. This is a tutorial on how to build and install YOCTO SDK on a windows machine. This allows developing embedded Linux on windows using eclipse or even visual studio. Setup YOCTO build If you already have a YOCTO build, you need to make the following simple steps:...


Debugging of cypress psoc6 in Linux terminal.

Published at November 5, 2020 ·  3 min read

I have used OpenOCD in my embedded projects, and here is a simple explanation how to work with OpenOCD with PSOC6 of cypress and here. Cypress has its own porting for OpenOCD for its interfaces: kitprog3 & kitprog4. Usually, I work on a Linux terminal using a command line with cgdb but, OpenOCD is already installed on modus, the default IDE of cypress. The PSOC6 is dual-core MCU: CM0+ and CM4, and when booting, it first powers on the CM0+, and if the CM4 is also needed, the CM0+ has to power it on....


Simple OpenAMP application for stm32mp157

Published at October 25, 2020 ·  3 min read

The stm32mp157 is SOC from STMicroelectronics , and it has within it a dual-core Cortex-A7 MPU and Cortex-M4 MCU. The Cortex-A7 is the application processor that operates Linux, and the Cortex-m4 runs RTOS or bare-metal application. The Cortex-M4 can be used for real-time tasks, such as creating a periodic and accurate control signal without jitter. In this kind of application, the Cortex-aA7 will run the master application and control the application of the Cortex-m4 using RPMsg Messaging Protocol....


Compile Linux kernel for zynq

Published at October 17, 2020 ·  2 min read

In previous post I shoed how to build and install Linux system on microzed board. When one tries to modify the kernel & u-boot, it is better to build and test it separately outside the Yocto build. I use Yocto’s kernel & u-boot sources and its SDK for the custom build. build the kernel To enable SDK , just type the following command. . /opt/poky/3.0.3/environment-setup-cortexa9t2hf-neon-poky-linux-gnueabi This script will define a series of enviement variables like $CC & $CXX that needed for the build....


Eclipse with CMake project on windows

Published at September 12, 2020 ·  5 min read

CMake is a powerful tool to manage c/c++ projects, and I prefer to use it in on my embedded projects also. Usually, the MCU has some communication with other processors (usually PC), and CMake also allows easy integration between both projects: MCU and HOST. For example, a shared source code that simultaneously able to recompile in both processors when any change occurs in these shared files. Usually, I work in a Linux environment in the terminal where everything is installed correctly in its place, and things work great....


install linux on microzed board

Published at August 1, 2020 ·  4 min read

The microzed development board has Xilinx zynq7000 chip. It has an application process unit with cortex a9 and FPGA fabric. The board also contains interfaces like SDIO and QSPI. I want to install Linux on it directly with yocto and without petalinux, which runs yocto behind the scene, so I tried to eliminate the need to use it. Why do so? It is interesting, and I have a lot of experience with yocto and it very easy to work with its script once you know it easy porting to other processors: IMX, stm32Mp157, etc' using build tools like CMake,Autotools, and yocto scripts make it very easy to port SW between different processors....


Custom opkg repository

Published at June 18, 2020 ·  2 min read

The post presenst simple example to create opkg repository to upgrade embbded linux systems using nginx server. The opkg pakcge should be installed as part of the image furing the first instalation. To add opkg to yocto image type type folloing line in file conf/local.conf IMAGE_INSTALL_append = " opkg \ " downlad and install opkg utils: git clone git://git.yoctoproject.org/opkg-utils and create Packages.gz file: cd /path-to-yocto-build/build/tmp/deploy/ipk ~/opkg-utils/opkg-make-index . > Packages.gz install nginx I haved used gentoo system , so inorder to install nginx on gentoo type:...


Kalman filter and pair trading

Published at May 1, 2020 ·  4 min read

Pair trading is a type of cointegration approach to statistical arbitrage trading strategy in which usually a pair of stocks are tcraded in a market-neutral strategy, i.e. it doesn’t matter whether the market is trending upwards or downwards, the two open positions for each stock hedge against each other. The key challenges in pairs trading are to: Choose a pair which will give you good statistical arbitrage opportunities over time Choose the entry/exit points One of the challenges with the pair trading is that cointegration relationships are seldom static....


Simple Hello World application using qt5 for embedded Linux device.

Published at April 1, 2020 ·  2 min read

This blog presents a simple example of how to create a qt5 application for a Linux embedded device that runs Wayland or x-server. I’m using Yocto build system. I already have a BSP for IMX8 + toolchain so. I just have to install qt5 on it. In the time that I wrote this page. See here a reference to use Yocto project. bug workaroud I worked with sumo branch and had to do some work around over three bugs that I found during the compilation of qt5....


Debug Linux Kernel With Qemu

Published at March 18, 2020 ·  2 min read

I have tried to debug the Linux kernel using GDB and a system emulator qemu. I use YOCTO and standard pokey distribution to build Linux image and kernel. I made changes to the standard .config file to support debug symbols and remove the KASLR option from the kernel kernel config The kernel has to modify as the following: Build a Linux kernel with debug symbols by set: CONFIG_DEBUG_INFO=y Remove KASLR definition from the Linux kernel by unset: CONFIG_RANDOMIZE_BASE....


Install Yocto and kernel development tools of IMX8

Published at February 24, 2020 ·  2 min read

The GCC toolchain and kernel installation. The purpose of this post is to show the installation process of development tools for imx8m-var-dart, which is SOM made by Variscite. When using yocto, the kernel, userspace applications, and toolchain are part of the build. Still, when developing kernel modules, device tree changes, or userspace applications, it is more practical to make a standalone kernel build and to work on it outside the yocto....


Linux UIO driver to handle with IRQ source.

Published at February 24, 2020 ·  6 min read

The Userspace I/O framework (UIO) is part of the Linux kernel and allows device drivers to be written almost entirely in userspace. UIO is suitable for hardware that does not fit into other kernel subsystems (Like special HW like FPGA) and allowing the programmer to write most of the driver in userspace using all standard application programming tools and libraries. This greatly simplifies the development, maintenance, and distribution of device drivers for this kind of hardware....


Linux char device to handle with IRQ

Published at February 20, 2020 ·  2 min read

We have an external FPGA that triggers GPIO. To handle the IRQ in userspace, it had to write a Linux chr device to control the IRQ in the kernel space and than signalize the userspace using a standard system call. Here is the simple drive: #include <linux/module.h>#include <linux/kernel.h> /* printk() */#include <linux/moduleparam.h>#include <asm/uaccess.h>#include <asm/pgtable.h>#include <linux/fs.h>#include <linux/gfp.h>#include <linux/cdev.h>#include <linux/sched.h>#include <linux/interrupt.h>#include <linux/of_address.h>#include <linux/of_irq.h>#include <linux/of_platform.h> #include <linux/semaphore.h> DECLARE_WAIT_QUEUE_HEAD(hq); static int irq_num; static int x=0; //spinlock_t mLock = SPIN_LOCK_UNLOCKED; unsigned long flags; static DEFINE_SPINLOCK(mLock); static irqreturn_t fpga_irq_handle(int irq, void *dev_id) { wake_up(&hq); // printk(KERN_DEBUG "Interrupt\n"); return IRQ_HANDLED; } static ssize_t fpga_read(struct file *file, char __user *buf,size_t count,loff_t *ppos) { wait_event(hq,x); return 0; } static struct file_operations fpga_fops = { ....


Linux module magic info

Published at February 20, 2020 ·  3 min read

Sometimes we want to build a module separate from the kernel. When the kernel is built, it generates a magic number, which probably depends on compiler version, kernel version, git source revision, etc. Time is also probably part of this magic number, since the kernel may build with the same parameters but with a different timestamp, it will have a different magic number, and then we will get this message when we try to insert it:...


Linux core isolation

Published at February 18, 2020 ·  1 min read

I have a real-time task that needed to run periodically at a constant rate - a continuous IRQ drives it. Just running this task on a multithreaded environment can cause it to run in different timing values. When the system runs on stress (using stress utility) the system is not a response to all IRQ requests. A possible solution to this problem is to use Linux core isolation. In this case, we assign a specific core for the task, and the Linux kernel is getting out from the SMP balancing, and this core can use for a particular job with minimal interrupts....


Linux module to disassemble code in the Linux kernel.

Published at February 18, 2020 ·  4 min read

Here is a simple module to disassemble memory using a Linux kernel module. This module is integrated into this module based on Zydis. Also, there is a userspace application to demonstrate the Zydis library on a test function in user space and disassembly of the same c function at the kernel space. Also can dissemble internal c functions of the kernel like printk, kmalloc, etc.' It could download the project from here....


Color transformation from Bayer to RGB

Published at February 17, 2020 ·  4 min read

A Bayer filter mosaic is a color filter array (CFA) for arranging RGB color filters on a square grid of photosensors. Its particular arrangement of color filters is used in most single-chip digital image sensors used in digital cameras, camcorders, and scanners to create a color image. The filter pattern is 50% green, 25% red and 25% blue - see here. Color conversion algorithm The conversion algorithm is based on simple linear interpolation of pixels to find the missing value....


My First Post

Published at February 10, 2020 ·  2 min read

It is My first Hugo post. I decided to work with Hugo after I had experience with word press. I write documents in Markdown format and use GitHub to manage my files, tags, and categories instead of using MySQL database is much easier to manage and deploy. To learn how to create such a blog in Hugo, you can try this blog. Table Of Contents diagram mathematical equations Refer to table of content for more information on creating a Hugo post with a table of contents....