krishworkstech.com

BeagleBone Black Overview for Embedded Development

  • BeagleBone® Black is an affordable, open-source development board powered by an ARM® Cortexâ„¢-A8 processor, ideal for hobbyists and developers. It boots Linux in under 10 seconds and is ready for use within 5 minutes via a single USB connection.
  • Designed for flexibility, it includes essential peripherals and supports expansion through “capes” or custom circuits, making it perfect for experimenting with a wide range of applications and hardware interfaces.
Rectangle 26832 (1) (1)

How to Install crosstool-NG for Cross-Compilation

Crosstool-NG is an open-source tool that helps automate the process of building cross-compilation toolchains. Originally based on Dan Kegel’s crosstool, it has evolved into a powerful, menu-driven utility. It allows you to create custom toolchains for different architectures, making it ideal for embedded development. The process typically involves steps like crosstool-ng download to fetch the required toolchain components and crosstool-ng install to build and install the complete toolchain.

image (29)
image (30)

Building a Cross-Compiler Toolchain for BBB

The BeagleBone Black has a TI AM335x SoC, which contains an ARM Cortex A8 core and a VFPv3 floating-point unit. Since the BeagleBone Black has plenty of RAM and storage, we can use glibc as the C library. The closest sample is arm-cortex_a8-linux-gnueabi.

image (31)

To develop for the BeagleBone® Black (ARM Cortex-A8), use crosstool-NG to create a cross-compilation toolchain. Start with an ARMv7-A (Cortex-A8) target and customize it. This will let you build ARM software on your host machine and run it directly on the BeagleBone® Black.

image (32)

the build will take about half an hour. The toolchain will be installed in
~/x-tools/arm-cortex_a8-linux-gnueabi

image (33)

Anatomy of a Toolchain

After building crosstools-ng in toolchain, it’s important to understand its structure and how to use it.
The generated toolchain includes a cross-compiler and related tools located in a dedicated directory, which must be added to your system’s PATH to compile code for your target architecture.

Target: BeagleBone Black
Toolchain Prefix: arm-cortex_a8-linux-gnueabi-
Toolchain Path: ~/x-tools/arm-cortex_a8-linux-gnueabi/bin

Group 1707478171 (1)

In the next part, we’ll see how to use this toolchain with a practical example targeting the BeagleBone Black board.

Develop smarter!

Use our BeagleBone-based workflows to test and deploy your IoT solutions faster and more reliably

How to Verify Your ARM Cross-Compiler Setup

We previously saw how to setup cross compile environment. This command outputs the version of the cross-compiler, ensuring you’re using the correct version for your build.

image (34)

Additionally, to check the sysroot used by your cross-compiler, you can run arm-cortex_a8-linux-gnueabi-gcc -print-sysroot. This command returns the path to the sysroot, which contains essential libraries and headers for the target architecture. The sysroot ensures that the correct dependencies are available during compilation, allowing your code to be built for the ARM target system.

Step-by-Step Guide to Cross-Compile C Programs for ARM

Step 1: Write a Simple C Program (helloworld.c)
Create a new file named helloworld.c with the following content:

image (35)

Additionally, to check the sysroot used by your cross-compiler, you can run arm-unknown-linux-gnueabi-gcc -print-sysroot. This command returns the path to the sysroot, which contains essential libraries and headers for the target architecture. The sysroot ensures that the correct dependencies are available during compilation, allowing your code to be built for the ARM target system.

 

Just for reminder: C is portable at the source code level, but the compiled binary is architecture-specific.

Step 2: Compile the Program Using the Cross-Compiler
Once you’ve written the program, you need to compile it for the target architecture. Assuming you’ve already set up the ARM cross-compiler, use this command to compile the program for an ARM-based system (e.g., ARM Cortex-A8)

image (36)

arm-cortex_a8-linux-gnueabi-gcc: Specifies the ARM cross-compiler.
helloworld.c: The source file we want to compile.
-o helloworld: Specifies the output file name (helloworld).

Step 3: Verify the Binary
After compiling the program, you can verify that the binary is correctly built for the ARM architecture using the file command.

image (37)

This confirms that the helloworld binary is an ARM Cortex-a8 specific executable (not an x86 or other architecture binary). You can now run this on an BeagleBone Black with ARM Cortex-a8.
Copy the helloworld binary file to the BeagleBone and run it to see the program’s output.

Step 4: Running ARM Cortex-A8 Binary on BeagleBone
Run the Cross-Compiled Binary on BeagleBone

image 30071

Note: To resolve issues with running a binary like helloworld, ensure that the required libraries, such as ld-linux.so.3 and libc.so.6, are present in the /lib folder. If you encounter an error like “cannot open shared object file: No such file or directory,” it indicates that the necessary dynamic loader (ld-linux.so.3) may be missing or located elsewhere. In that case, check if the library exists in directories like /lib/arm-linux-gnueabi/ and create a symbolic link to the correct loader using the command :
$ sudo ln -s /lib/arm-linux-gnueabi/ld-linux.so.3 /lib/ld-linux.so.3
After creating the symlink, try running the binary again, and it should execute successfully

Toolchains in Different Devices

image (19)

QEMU Toolchain Setup

Rectangle 26838

BeagleBone-Toolchains Setup

Rectangle 26839

Raspberry Pi Toolchain Setup

FAQs

BeagleBone Black is used for embedded systems, IoT development, robotics, and real-time applications due to its ARM Cortex-A8 processor and Linux support.

To set up a custom cross-compilation toolchain for BeagleBone Black development, you can use crosstool-NG targeting ARM Cortex-A8.

To cross-compile a C program for BeagleBone Black, write your C code, compile it using the ARM cross-compiler (e.g., arm-cortex_a8-linux-gnueabi-gcc), and transfer the binary to your BBB.

To run ARM-compiled binaries successfully on BBB, you need dynamic libraries like ld-linux.so.3 and libc.so.6 in your /lib directory.

Scroll to Top
  • Schematic design
  • PCB and schematic source files
  • Assembling drawing files
  • Providing prototype/sample and production PCB service
  • Testing and validation of designed hardware
  • HIPAA
  • Azure Key
  • Management
  • ES, Checksum,
  • MD5sum
  • AWS
  • Azure
  • GCP
  • DigitalOcean
  • Kotlin
  • Python
  • Tensorflow
  • Computer Vision
  • ECG
  • SPO2
  • Heart Rate
  • Glucometer
  • Blood Pressure
  • UX UI Process
  • Figma and FigJam
  • Adobe Suite
  • Selenium Java
  • Postman
  • Swagger
  • Jmeter
  • SQL
  • Java Scripter
  • Test ng
  • Extents Reports
  • Flutter
  • Java
  • Kotlin
  • Swift
  • Dart
  • React JS
  • Python
  • NodeJS
  • Django
  • HTML, CSS, JS
RDBMS
  • PostgreSQL
  • Oracle
  • MySQL
  • MariaDB
No SQL Based
  • MongoDB
  • GCP
  • FirestoreDB
  • DynamoDB
  • Azure
  • CosmosDB
  • AWS