Libraries

Raspberry Pi: Enabling 64-bit Kernel and Compiling RTL8111H Driver


Recently, I’ve been using the Compute Module 4 and a custom board with a Realtek RTL8111H PCIe Ethernet controller to develop a network router. However, the Raspberry Pi OS didn’t come with the required r8168 or r8169 drivers for the RTL8111. But fortunately, compiling and installing these drivers was relatively easy. Or at least until I discovered a neat trick: by adding arm_64bit=1 to the /boot/config.txt file, I could switch to a 64-bit kernel. This made the kernel 64-bit, but all user-space programs remained 32-bit. This was ideal for me, as all the routing work was retained in the kernel. Although a full 64-bit Raspberry Pi OS is still in development, I’m happy to stick with the 32-bit version for now.

  •  PROJECTS
  •  SOFTWARE
  •  LIBRARIES
  •  HOW-TO
  •  MORE STUFF
Donate

Raspberry Pi – Compiling a Module for the 64-bit Kernel

 3 Jul 2021

Recently I’ve been working on a network router using the Compute Module 4 and a custom base board with a Realtek RTL8111H PCIe Ethernet controller. Raspberry Pi OS doesn’t come pre-installed with the r8168 or r8169 driver needed for the RTL8111, but getting it compiled and installed is pretty easy. Or at least until I found out that it’s…

Si4463 Wireless Library: A Wireless Communication Solution for AVR and Arduino

This is a library for the Silicon Labs Si4463 wireless IC, which has been used in (or will be used in) some of my projects. The Si4463 offers various configuration options, including modulation, data packet format, and CRC algorithm, and can output up to +20dBm (100mW) of power. Additionally, the Si4463 is also used in many pre-made modules, such as the HopeRF RFM26W and the Dorji_Com DRF4463F. The entire Si446x transceiver series should also be compatible with this library.

This library allows users to configure the chip to send and receive variable-length data packets (up to 128 bytes) and trigger callback functions when events occur (such as receiving new data packets and completing data packet transmission). These callback functions run directly from the interrupt routine, making the program’s response to events much faster than with polling libraries.

Download from GitHub
Documentation

Pinout

Si4463ATmega328Arduino UnoArduino MegaDescription
VCC3.3V3.3V3.3VPower (3.3V)
GPIO0
GPIO1
SDOB4 (18)1250SPI MISO
SDIB3 (17)1151SPI MOSI
SCLKB5 (19)1352SPI SCK
NSELB2 (16)1010

MCP2221/MCP2221A USB Converter Open Source HID Library

This is an open-source library that aims to provide a multi-platform interface solution for interacting with Microchip’s MCP2221/MCP2221A USB-to-UART and I2C/SMBus serial converters. The library supports access to various functions of the converter, including 4 GPIO pins, 3 10-bit ADCs, and 1 5-bit DAC. Unlike Microchip’s proprietary DLL library, this project aims to provide an open-source, cross-platform alternative.

This library also makes use of HIDAPI.

Supported features:

FeatureStatus
ADCSupported
DACSupported
GPIOSupported
Interrupt inputSupported
Clock reference outputSupported
USB Descriptors
(Manufacturer, product, serial, VID, PID)
Supported
I2C/SMBLimited support, WIP
Flash password protectionNot yet implemented
C++ and C# wrappersNot yet implemented

Download from GitHub
Documentation

Bits of info about the MCP2221

  • Doesn’t use a crystal, only requires 1 small capacitor when powered with 3.3V or 2 capacitors when powered with 5V.
  • Available in a hacker friendly DIP package.
  • Has a remote wake function which when used in conjunction with the interrupt input can be used to wakeup the USB host (usually a PC), just

USB RGB LED Controller Based on AVR Microcontroller

Why not upgrade the CPU usage LED project to a general-purpose RGB LED controller? The current CPU usage LED controller uses a value between 0 and 255 to calculate the color it should be and then fades to that color. This is indeed quite limited; changing the color and fading method requires firmware updates. In contrast, a general-purpose RGB LED controller can let the host software handle all the work, and the controller only needs to be told what brightness the red, green, and blue LEDs should be, providing greater flexibility and scalability.

To simplify interactions with the controller, I developed a library that wraps all LibUSB content. With this library, you can achieve basic functionality with just a few lines of code (only 10 lines).


#include <rgbledctrl.h> int main() { rgbledctrl_init(); rgbledctrl_find(); s_rgbled_device* rgbLed = rgbledctrl_open(); rgbledctrl_setR(rgbLed, 200); // Set red value to 200 rgbledctrl_close(rgbLed); return 0; }

The library also has support for reading and writing to the EEPROM of the controller. Class wrappers for C++ and C# .NET are also provided.

Download from GitHub
Documentation

AVRDUDE Studio – A Microcontroller Programming Tool Based on AVRDUDE

AVRDUDESS is a graphical interface for AVRDUDE, designed to simplify the programming process of Atmel microcontrollers. It provides a user-friendly interface that allows users to easily upload code, read and write to the microcontroller’s flash, EEPROM, and other configurations.

Some key features:

  • Supports all programmers and MCUs that AVRDUDE supports
  • Supports presets, allowing you to change between devices and configurations quickly and easily
  • Drag and drop files for easy uploading
  • Automatically lists available COM ports
  • Cross-platform with the use of Mono for Linux & macOS

DOWNLOAD HERE

High-Precision Timing Library for AVR

This lightweight library is specifically designed for millisecond-level time tracking. It supports the “unsigned long long” data type, allowing it to accurately track up to 584.9 million years! Additionally, it can adapt to clock frequencies of up to 20MHz, with most common frequencies having no timing errors.

Compared to Arduino’s built-in millis() timer, this library is especially useful when running at clock frequencies of 8MHz or below or when tracking time for more than 50 days.

Download from GitHub

Brief comparison against the Arduino millis()

Arduino millis()

  • Microsecond support
  • Doesn’t loose or gain time at any clock frequency
  • Loss of resolution at lower frequencies

This library

  • Faster execution
  • Less RAM used
  • Always updates millisecond count every millisecond
  • Support for ‘unsigned long long’ data type, 64 bit integer allows tracking time for up to 584.9 million years, Arduino millis() uses ‘unsigned long’ which goes up to 49.71 days
  • Uses CTC mode for the timer, which might make it a little bit more difficult to use the timer for multiple things

Accuracy at commonly used clock frequencies

ClockThis library (TIMER0)This library (TIMER1)

Introduction to nRF905 Wireless Transceiver IC Library

The nRF905 is a wireless transceiver IC similar to the nRF24L01, but with a working frequency of 433/898/915MHz, offering a longer range and more IO pins. Although the data rate of nRF905 is only 50Kbps, lower than the 2Mbps of nRF24L01, this library provides considerable flexibility.

The library supports the use of interrupts and allows for the option of connecting two modules, as their status can also be accessed through the IC’s status registers. Additionally, the library supports basic collision avoidance mechanisms.

NOTE: v3.0.0 of the library was released on 12th September 2017, the default CD pin has changed and the AM pin is now used by the library.

Download

Arduino: [HERE] and [Documentation] (or use the Arduino library manager and search for “nrf905”)

AVR (non-Arduino): [HERE] and [Documentation]

nRF905ATmega48/88/168/328Arduino UnoDescription
VCC3.3V3.3VPower (3.3V)
CED7 (13)7Standby – High = TX/RX mode, Low = standby
TXEB1 (15)9TX or RX mode – High = TX, Low = RX
PWRB0 (14)8Power-up – High = on, Low = off
CDD4 (6)4Carrier detect – High when a signal is detected, for collision

From Arduino to AVR Microcontrollers: My Electronic Journey

I’ve been following Arduino and finally got my hands on an Uno and a 16×2 character LCD with RGB backlight. This new electronic world is exciting me. For years, I’ve been interested in digital control devices like LCDs, wondering how to use them, but was always blocked by the complexity of microcontrollers. However, using Arduino’s LCD library made it easy to connect the LCD, and I quickly made a stereo audio VU meter and a basic FFT spectrum analyzer.

Next, I started exploring wireless technology. I bought NRF24L01 wireless modules, a USBASP AVR programmer, a USB to UART converter, and an ATMega168 microcontroller from Ebay. Using the Mirf library, I successfully made one controller change the LCD backlight color of another controller.

After getting used to the Arduino IDE, I wanted to dive deeper into how the code truly controls the chip. So, I downloaded Atmel Studio 6, the ATMega168 chip datasheet, and followed tutorials on avrfreaks.net to learn the basics of AVR microcontrollers, starting from timers and interrupts. Now, I’ve grasped the basics of AVR microcontrollers and have many project ideas involving AVR uCs.