linux

linux

Low Level Debug of STM32MP15c7

Published at June 21, 2021 ·  4 min read

Low-level debug of MCU may essential during the bring-up process of a new board. Especially for checking critical components like the DDR. The MCU under debubung is STM32MP157. I strongly based on the yocto build system for the SDK and the compilation and signature of the system. See here and How to configure TF for a manual build of TF-A without yocto. It can be uses the STM32_Programmer_CLI load TSV files into the EMMC....


Linux Gadget Device.

Published at January 19, 2021 ·  4 min read

This post is an example of making a USB device from a Linux embedded machine where any HOST can control it. From Linux documention: Most Linux developers will not be able to use this API since they have USB host hardware in a PC, workstation, or server. Linux users with embedded systems are more likely to have USB peripheral hardware. To distinguish drivers running inside such hardware from the more familiar Linux “USB device drivers,” which are host-side proxies for the real USB devices, a different term is used: the drivers inside the peripherals are “USB gadget drivers....


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:...


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....


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:...


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....