Tuesday, April 30, 2024

Generate cross compile toolchain in Gentoo

Gentoo crossdev

Table of Contents

1. Introcution

Crosstool-ng is commonly used to build a cross-compiler toolchain in various Linux distributions. In Gentoo, the cross-compiler environment generator, crossdev, has been made for our convinience. It is a set of bash scripts that utilize emerge to provide a system integrated cross-compilation capability.

In this article, we are going to walk through building cross-compiler toolchain for an operating system and the embedded target (bare matel).

Emerge to install crossdev.

$ sudo emerge --ask sys-devel/crossdev

Sunday, April 14, 2024

Install and run Docker on Gentoo Linux

Install and run docker on gentoo linux

1 Introduction

Docker is a container virtualization environment that can establish development or runtime environments without modifying the host operating system. It is faster and lighter than full hardware virtualization.

This article will guide you through the steps required to install and run Docker on Gentoo Linux.

2 Installtion

The official sys-kernel/gentoo-kernel-bin package supports running Docker.

For the customized kernel, refer to Docker: Kernel to configure the proper kernel options.

Default USE flags can be utilized. It is recommended to read the messages for the package app-containers/docker when emerging Docker and recompile the kernel based on what is not set but should be.

To check the kernel configuration compatibility, run:

$ /usr/share/docker/contrib/check-config.sh

Install the app-containers/docker and app-containers/docker-cli packages.

$ sudo emerge --ask --verbose app-containers/docker app-containers/docker-cli

Thursday, April 11, 2024

Connect USB device to WSL

Connect USB device to WSL

Connect USB device to WSL

1 Introduction

This article will guide you through the steps required to connect a USB device to Linux running on Windows Subsystem for Linux (WSL).

2 Prerequisites

  • Install WSL and ensure it is updated to the latest version.

For installation guidance, refer to How to install Linux on Windows with WSL

  • Install a Linux distribution configured to WSL 2.

Heap and Priority Queue

Heap and Priority Queue

1 Introduction to Heap and Priority Queue

A heap is a tree-based data structure that adheres to the heap property: in a max heap, any parent node's key (value) is greater than or equal to the keys of its children. Conversely, in a min heap, the key of a parent node is less than or equal to the keys of its children.

For more details, refer to Wikipedia: Heap (data structure).

A priority queue is an abstract data type similar to a regular queue or stack, where each element has an associated priority. Elements with higher priority are served before those with lower priority.

For more details, refer to Wikipedia: Priority queue.

Although they are conceptually different, priority queues are often referred to as heaps because they are commonly implemented using heaps.

The binary heap is a data structure that efficiently supports the basic priority queue operations. It allows O(1) performance for accessing the root, O(log n) for insertions and deletions, and O(n) for initially building the heap from a set of n elements.

Note that the time complexity to build a heap is O(n log n) using a top-down approach, whereas a bottom-up approach achieves O(n).