embedded

embedded

Data streaming between two BLE devices: PSoc6 and nRF52832

Published at September 10, 2022 ·  3 min read

I had a project where I had to stream data between two BLE devices. The data source was connected to PSoc6 and sent using its BLE transceiver to the destination device, nRF52832. Usually but not must, the peripheral devices are used as a GATT client, and the central machines are used as a GATT server. Therefore, I set the PSoc6 (The data source) as the central device (client) and the nRF52832 as the peripheral device (server)....


Setup SDCARD on stm32 MCU

Published at November 18, 2021 ·  3 min read

This post describes simple steps to make the STM32H7 work with SDCARD. I have used STM32Cube to set up the BSP for the project. It uses the library FatFS as its FAT files system at the top of the driver level. The firmware for drivers is also taken from the STM32Cube. Emphasis for SDCARD setup Select external transceiver to “yes” if the board has one. External transceivers are translating between 1....


Setup UART BLE using Nordic nrf52832

Published at September 16, 2021 ·  4 min read

I have played with Murata’s MBN52832 module BLE module. This module is based on a Nordic chipset (nRF52832), it has BLE and NFC capabilities and MCU with cortex-m4 to manage the radio operation. The module comes with a demo firmware without an AT Command interface, and the user has to write its application. However, the SW flexibility allows creating a standalone application with BLE and NFC without using a host device like a PC to operate the BLE radio....


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


Using SVD file in GDB for Cortex-m debugging

Published at June 12, 2021 ·  2 min read

Using SVD files during debugging session of a cortex-m microcontroller allows easy access to system registers value. The SVD file is an XML file that contains the necessary information about the register’s name and address. Using SVD, the IDE can read the value of system registers and display it during the debugging session. I will show here how to use SVD during GDB debug session. Installation Download and install the following project from PyCortexMDebug....


Zephyr RTOS BringUp on stm32

Published at May 7, 2021 ·  7 min read

The Zephyr RTOS is one of the best around. It makes me feel like working on embedded Linux in the sense of device integration, code styling, device tree (DTS), CMake build systems and more. It has many build-in stacks for USB, networking, BLE, file system, boot loader, DFU, and more. Its API reaches and has partial POSIX support with a custom build system that makes tiny footprints. This post is a tutorial on bringing up for STM32 board with USB and USART interfaces....


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


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


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


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