Recently, I was solving one of the Codewars.com problems in NASM (x86_64/amd64 Assembly) where I had to use some of the C functions available in the standard C library. During the code refactoring and optimization, I came across a segmentation fault while trying to run the executable. The program broke …
Author Archives: Isabekov
Multiperiod hledger-Style Reports in beancount: Pivoting a Table
I am using plain text accounting tools like hledger and beancount alongside KMyMoney to track my financial transactions and to produce summary reports about income and expenses. If you've ever used hledger, you might like its ability to …
Reverse SSH Tunnel Explained
SSH tunnels are a great tool to solve various problems with routing where a firewall does not allow to access a certain local network. They allow forwarding connections to a specified port on the server machine to a local or remote computer through an encrypted channel.
Although there are nice …
Programming Xilinx Spartan 3A FPGA via UrJTAG
A Xilinx Spartan 3A chip can be programmed by using UrJTAG's pld command by fixing some issues related to old instructions. In this example, a Prometheus FPGA board is used. It is composed of a XC3S50A chip which can be configured by using FT-232H circuit's MPSSE mode. To start with, …
Remote Debugging of Native Android ARM 64-bit Executables Using gdbserver
In this tutorial, compilation and remote debugging of a simple C program on a rooted Android with ARM 64-bit architecture is described. The computer's hostname is ArchLinux and the smartphone Asus Zenfone is running on Android 5.0.2:
Install a cross-compiler toolchain
Install Android NDK (Native Development Kit):
Keeping header of an output while grepping the rest for something else in BASH
Sometimes it is useful to keep the header of an output of some command while grepping the same output for something else. In the example below, the column information is absent:
Installing packages on Ubuntu without admin rights
Sometimes you may work on a remote machine and you don't have sudo permissions to install software you like. If the system administrator cannot add you to the sudoers file due to the strict security policy, then you will need to find a way to install your package. It happened …
Using regular expressions with Perl, sed and grep for selecting columns in delimited text
A solution without regular expressions
There are many ways for selecting columns in a delimited text. The easiest ones require GNU awk, cut and Perl. Let's consider the following file:
1 2 3 4 |
[johndoe@ArchLinux]% cat |
Sharing files over HTTP
Quick sharing of a single/multiple files in a directory over HTTP protocol will be covered. Let's assume that the file sharing will be done over wlp3s0 Wi-Fi interface and the server's IP address is 192.168.0.24 as shown below:
Fixing the table of contents bookmarks in the book “Speech and Language Processing (3rd ed. draft)” by Dan Jurafsky and James H. Martin
A draft of the new version of the book "Speech and Language Processing (3rd ed. draft)" by Dan Jurafsky and James H. Martin is available on authors' website. Although it is produced using pdflatex with hyperref, the bookmarks of the table of contents (TOC) have an incorrect hierarchy. However, the …
Modifying bookmark opening levels of PDF documents using Coherent PDF Command Line Tools (cpdf)
Sometimes large books or theses may contain many chapters, section and subsections. Reading such PDF documents with the whole table of contents hierarchy shown in the bookmarks panel may be difficult. There is a way to tell PDF viewers to show only a specific level of bookmarks and hide its …
GNU Wget Cheat sheet
Recursively download a part of a website (all files are downloaded, hierarchy is preserved and links are converted)
1 |
wget -r -k -np -nH --cut-dirs=3 "http://www.math.uconn.edu/~leykekhman/courses/MATH3795/Lecture_slides.html" |
4-bit Serial Adder/Subtractor with Parallel Load
This is a tutorial I wrote for the "Digital Systems Design" course as an introduction to sequential design. "4-bit Serial Adder/Subtractor with Parallel Load" is a simple project which may help to understand use of variables in the "process" statement in VHDL. However, basic understanding of the circuits is necessary, …
Using UrJTAG and OpenOCD to Write to a BSCAN Primitive on Xilinx Spatan 3 FPGAs
There are no tutorials explaining the use of BSCAN_SPARTAN3 primitive on Xilinx FPGAs. It's a very useful feature, which allows to literally establish a PC-to-FPGA link over a JTAG adapter. This primitive is already used in projects such as xc3sprog and Papilio-Loader to program SPI flash memory over JTAG.
BSCAN_SPARTAN3 …
Reading Device DNA on Spartan 3A chip
Among Spartan-3 generation of FPGAs only families 3A and 3AN have unique device identifier (device DNAs). DNA is a factory programmed unique 57-bit long number, whose the most significant bit is "1" and the second most significant bit is "0":
The Spartan 3A chip (xc3s50a) should be unconfigured (not loaded …
A Radare2-based Analysis of Pointers to an Array in C
Pointers and arrays are a confusing subject in C. Pointers can be of different types, which makes possible pointer arithmetic to access necessary elements in an array in different ways. Consider the following examples:
int *A[5]; This is an array of 5 pointers to integers.…
Examining Data in GDB
The GNU Debugger (GDB) is a powerful tool to debug binary executables. It can be used to do reverse-engineering as well. Let's debug the following code written by LiveOverflow:
Writing a Minimalistic “Hello, World!” program with Position Independent Code in assembly language
I wanted to write a simple program in AMD64 assembly language which prints "Hello, World!". Here is the code:
“Signed Integer” behavior of “char” data type in C
Examining data stored in the memory of the program may be interesting to understand low-level mechanism of variable management and type conversions. Let's dump content of an integer bytewise:
USERCODE Register in Xilinx Spartan 3E
The following setup was used for Basys2 board with an external FTDI-based JTAG adapter. Read the previous posts to get familiar with setup.
Specifying USERCODE
User code register provides bit stream identification and a type of version control. To write a user code into a bit stream in Xilinx ISE, …
Programming Basys2 Using xc3sprog and FTDI-Based JTAG Adapter
In order to program Basys2 board using xc3sprog and FTDI-Based JTAG Adapter, learn positions of the devices in the chain:
SVF Tutorial: Header and Trailing Registers Explained
Objective
This tutorial concerns with explaining use of some basic Serial Vector Format (SVF) instructions assuming that you are familiar with JTAG and TAP.
As an example, reading ID codes of the devices in a JTAG chain of the Digilent Basys2 FPGA board is given. A generic FTDI-MPSSE-based JTAG adapter …
Programming Basys2 Using OpenOCD and FTDI-Based JTAG Adapter
As a continuation of series of experiments with Basys2 board and FT232H-based JTAG adapter, I provide an easy way to generate SVF files for their further use in OpenOCD to program the board. No GUI interaction is needed, so it is saves a lot of time.
Programming the FPGA Chip
…Boundary Scan Operations with UrJTAG on Basys2 Development Board
UrJTAG is a good low-level tool to learn boundary scan operations and play with EXTEST, INTEST instructions. Assuming that the Basys2 board is connected to a UM232H-based JTAG adapter as described in the previous article, we can test EXTEST and INTEST instructions. Note that depending on package (VQ100, CP132, …
Connecting External FTDI-Based JTAG Adapter to Basys2 FPGA Board
I had a task to check whether OpenOCD can program a Spartan 3 series FPGA by means of FTDI-MPSSE-based JTAG adapter. There wasn't any chip available in my hands, so I had to experiment with existing hardware. I decided to solder the FTDI-based adapter to a Basys2 development board. The …
Making an MBR Bootable USB Flash Drive with GRUB on NTFS Partition
Introduction
There may be many reasons to create a bootable USB flash drive with an installed bootloader. Not all live CD's of popular distros contain hybrid MBR/El-Torito bootable sectors. So if you are trying to write the ISO image directly into the flash drive using:
Zotero Data Server Installation
A tutorial on setting up Zotero data server on Arch Linux from my old blog:…