In embedded systems, sometimes it’s required to have an operating system to handle complex processes such as internet connection, advanced file handling, and use full speed USB peripherals such as webcams and Wi-Fi cards. These can’t be done by using microcontrollers, instead a microprocessor is needed. Due to the higher complexity of making a PCB for these advanced chips, a commercial single-board-computer can be used to incorporate these advanced functions into a project. In this guide we go over on how to setup a BeagleBone Black to run Linux and how to set it up into a “headless” configuration, enable one of the UART ports and test it.
How to use it?This guide is meant to get started on a system that can be incorporated into embedded system projects that are controlled with a microcontroller but have no access to advanced file system, internet controller, access to advanced USB peripherals such as webcams and other high-level functions and script languages. This method can be used to modularize embedded projects in such a way that a system can be upgraded by just swapping the daughter board that requires an upgrade and the rest of the system can remain untouched. It can be beneficial for mobile robotics, for example, that might need to do video processing and all the BBB processing power needs to be focused on that task and smaller boards can control other aspects of the robot such as drivetrain control and robotic arm movements, and all these boards can receive the needed commands from the UART ports from the BBB.
What materials are needed?To follow this guide successfully it’s assumed that the following list have been gathered prior to starting:
- BeagleBone Black board (original)
- SD card (minimum 8GB, 32GB recommended)
- Ethernet Cable
- Network Router
- 5V power supply for BBB
- SD Card reader (if computer doesn’t have a built in one)
- It’s assumed that the user understands how to download and install programs in a responsible way to their personal computer and have administrator rights to do it.
For all the commands that will be run on the BBB terminal, a quick explanation of what the command does or a side note can be given after the command. For example:
sudo apt update
Fetches the updated catalog for current installed programs.
Don’t expect to be commanded to “type” or “enter” before the command.
Keywords and Glossary- Advanced IP Scanner: Free Network Scanner to analyze local area network through the computer.
- Baudrate: rate at which information is transferred in a communication channel.
- BalenaEtcher: tool to flash OS images onto SD cards and USB drives.
- BeagleBone Black or (BBB): low-power open-source single-board computer produced by Texas Instruments.
- Bonescript: is a Node.js library specifically optimized for the Beagle family and featuring familiar Arduino function calls
- Cloud9: is a cloud-based integrated development environment that lets you write, run, and debug your code with just a browser.
- Debian: is one of the oldest operating systems based on the Linux kernel.
- Device Tree Overlay: special device tree blob fragments that allow you to override specific parts of the device tree without having to re-compile the whole device tree. In other words, it’s a piece of code that changes the functionality of the pinouts of the BBB.
- EMMC: embedded multi-Media card, in the BBB is the onboard flash memory, it can store the operating system.
- Headless: headless configuration of the BBB is when you run the board without a screen attached to it.
- Image: file with.img name extension and stores raw disk information, used to create backups.
- Logic Analyzer: is an electronic instrument that captures and displays multiple signals from a digital system or digital circuit.
- minicom: is a text-based serial port communication program, it is used to talk to external serial devices.
- Nano: small editor for the terminal of Linux.
- NodeRed: allows to create functionality by wiring together flows of data between nodes using a browser. It is used by modeling bits of application functionality between devices like sensors, cameras, and wireless routers.
- Putty: SSH client.
- SSH: Secure Shell Protocol is a cryptographic network protocol for operating network services securely over an unsecured network.
- UART: universal asynchronous receiver-transmitter is a serial communication protocol used to communicate two devices.
Follow this link: https://beagleboard.org/latest-images and download “Buster IoT” for the AM3358 under the “Recommended Debian Images” Section. The link is usually blue, download the latest image available.
1. Download and install balenaEtcher from this link: https://www.balena.io/etcher/ and install it on your computer.
2. Insert your microSD card to your computer.
3. On balenaEtcher, click on: “Flash from file” and a window will open, look for the image you downloaded on Step 1.
- Select your SD card. MAKE SURE YOU SELECT THE CORRECT DRIVE BECAUSE ALL THE PARTITIONS AND DATA WILL BE ERASED!
- Click on: “Flash!”, you will get a “Permission” dialog window. Click on “Accept” to start the flashing process. This step will take about 5 minutes depending on the speed of your computer, card reader, and card speed. It will take an additional 3 minutes to verify the image on the SD card. Once it finishes successfully eject the card safely.
4. With the power DISCONNECTED, insert the SD card into the BeagleBone SD slot.
5. To boot into Debian from the SD card and not it’s onboard flash memory, the USER/BOOT button must be pressed while the power is connected.
6. After all the lights turn blue and then off, you may stop pressing the button. After it has fully booted, the first LED will be blinking in a “heartbeat” fashion.
3. Connect to network and logging in into DebianSince we won’t be using a monitor for this setup, we will have to connect to the BeagleBone through SSH. Meaning that we will connect the board to the network through the ethernet port. After connecting to the ethernet port, and successfully booting into Linux, we need to find the board’s private IP address. The easiest way for me to find the BeagleBone private address is by using “Advanced IP Scanner” on a computer that is on the same network as the BeagleBone, it can be downloaded from the following link: https://www.advanced-ip-scanner.com/
1. Once the BeagleBone is running, connect it to your network by using an ethernet cable (a Wi-Fi card can be added later). Having the green and orange light in the ethernet connector is a sign of communication. As seen in Figure 3, the BBB must be connected to the same router that your computer is connected to. The blue cable is the ethernet cable going from the router to the BBB. To communicate between your computer and the BBB internet is not required, but it is needed to download updates and other packages into the BBB. The computer that you are using to connect to the BBB doesn’t have to be connected through ethernet cable to the router, it can be connected through Wi-Fi, if they are connected on the same network.
2. Open “Advanced IP Scanner”, make sure that in the IP address bar you are in the correct range. I will have mine to scan from 192.168.1.1 – 192.168.1.254 as shown in Figure 4. Depending on your router, your IP address range might be different. You can try 192.168.2.1 – 192.168.2.254 if the first range didn’t work. The length of your listed devices after scan will depend on how many devices are connected to your network (you might even find devices that are getting “free” internet from you 😉).
3. The IP address that my BeagleBone was automatically assigned by the router is 192.168.1.125
4. To connect through SSH, PuTTy will be used. It can be downloaded from the following link: https://www.putty.org/
5. In PuTTY, I’ll be connecting using the SSH protocol and port 22. Enter the IP address of the board. For quick connection, under “Saved Sessions”, a quick profile can be saved.
6. You will be asked for the login username, the default username is “debian” and then you will be asked for the password, which the default is “temppwd”. It can be changed later, and it’s recommended. I will keep the default values for the rest of the document. Note: A warning message might pop up depending on whether this device has been previously connected to the same computer with a different IP address or not, since we know it’s our own BBB in our network, we can agree to connect to it if asked.
Since we’ll be running Debian from the SD card, we don’t need the internal memory to be enabled since they take up I/O pins that can be used for other purposes. Also, since we’ll be controlling the BBB through the network and won’t be connecting a screen to the HDMI port of the board, we can disable the HDMI port and have more I/O available for more devices. To disable EMMS and HDMI, we need to modify the uEnv.txt file as a root.
1. We use “nano” as the text editor to modify the uEnv.txt file.
sudo nano /boot/uEnv.txt
“sudo” is used to run “nano” as a super user or “root”. Otherwise, we won’t have permission to modify the file. Be careful when running commands using sudo.
- By default, the "nano" text editor is included in most distributions of Linux.
2. Remove the “#” symbol on the line “#disable_uboot_overlay_emmc=1”
3. To save the modification done to the file and close the text editor, press “Ctrl” + “x” on your keyboard. You will be prompted if you want to save the changes. Press “y” and then “enter” to confirm.
4. Type:
sudo reboot
“sudo reboot” will restart the BeagleBone.
then enter the password if asked for it.
5. After the system reboots, you will get an error that the connection is lost. This is normal, open another session as done before using PuTTY.
Once back in the board, repeat the steps above, but this time remove the “#” symbol on the line “#disable_uboot_overlay_video=1”to disable the HDMI port and free up additional I/O in the header.
6. Again, save the changes, enter the password when prompted and reboot the BeagleBone.
7. At this point both the EMMC and the HDMI port will be disabled.
4. Expand system on SD cardThe SD card that I’m using is 32GB of storage, but when I run the command:
df -h
I can see that I can only use 3.4GB. In the latest image of Debian, there is a script that will expand the partition to use the whole SD card, storage space might be needed to install applications, updates, and other user files.
In the folder “tools” of Debian, we can see the included files that can help us automate several things. We are interested in “grow_partition.sh".
All steps needed to expand the 3.4GB partition into using all the space available in the SD are shown below:
1. Go to /opt/scripts/tools directory where grow_partition.sh should be located.
cd /opt/scripts/tools/
“cd” is the command to “change directory” it is used when you want to go to a different folder in Linux.
2. Verify grow_partition.sh exists by listing all contents of the current directory.
ls
Use “ls” to see all the files and folders in a directory, in this case, the “tools” directory.
3. Run grow_partition.sh.
sudo ./grow_partition.sh
Run the grow_partition.sh file as an executable/script.
4. Reboot the BBB
sudo reboot
and log back again.
5. Verify the storage space has increased for the mmcblk0p1 partition:
df -h
Now that we have all the space available, we can continue to download and install updates. But before that, we should remove three systems that take up space and will slow down installing and downloading updates.
5. Remove Bonescript, Cloud9 and NodeRedI won’t be using Bonescript, Cloud9 and NodeRed to develop on the BeagleBone, I followed the steps on this page: https://www.diozero.com/internals/bbbsetup.html to remove them. This page has additional tips and steps that can help in the development and maintenance of the board. Type the commands on the snipped bellow to free up space in the SD card and makes updating the board more efficient.
For the commands: “sudo apt -y remove c9-core…” and “sudo apt -y purge c9-core…” I removed the “-y” for them to work. I typed the commands as follows:
sudo apt remove c9-core-installer bonescript nodejs bb-node-red installer
sudo apt purge c9-core-installer bonescript nodejs bb-node-red installer
After each of these 2 commands were entered, you will be prompted if “you want to continue?”, press the letter “y”and then press the key “enter” on your keyboard.
After running all the commands, reboot the BeagleBone. Let’s get ready to install updates.
6. Install updatesAs in all OS, we should install the latest updates. Updates can either add features, fix bugs and/or add security features. In Debian based OS (we installed Debian in this guide), we use the following two commands.
- "sudo apt update" which downloads an updated list of the packages you currently have installed. You can think of it as updating a catalog magazine with its newest additions from the current applications you have installed.
- "sudo apt upgrade" which downloads and installs all available packages that are on the list you just updated with the previous command. You can think of it as buying all the items in the catalog magazine.
Remember, “apt upgrade” will download and install whatever is in the saved catalog. If you want to install the newest packages and apps, you must “apt update” your catalog first.
1. Update the list of installed packages.
sudo apt update
Enter the password if requested. Depending on internet speed and what’s the current state of your OS, this might take a few minutes. Wait until it finishes.
2. Download and install available packages.
sudo apt upgrade
Enter the password if requested. Depending on internet speed and what’s the current state of your OS, this might take a few minutes. Eventually, you will get a message with a small report. At the end of the report, you are told how much of additional storage will be needed to complete the upgrade. Type “y” and then “enter”. Again, this might take a few minutes.
3. For safe measure, reboot the board and log back in.
7. Install minicomTo use the console to send commands, characters, strings, etc. through one of the UART ports, we need an application. The application I chose is called: minicom.
minicom should not be able to be installed before the “apt update” command. But since we have done that step, we should be able to install minicom by running the command “sudo apt install minicom”. “apt install” will look for an application (in this case “minicom” and if it’s in the catalog, it will download it and install it.
1. Install minicom:
sudo apt install minicom
2. You will get alerted on the space required, and what additional apps will be installed to install minicom. Press “y” and then “enter” to accept.
To test minicom, we need to select a UART port to use on the BeagleBone. The board has 4 Full duplex UARTs plus one that only has the TX pin available. For this test I will be using UART4. The header pin order and location can be seen in the following chart:
UART4 pins are located on header P9 on pins 11 and 13. RXD (receiving channel) is on pin 11. And TXD (transmitting channel) is on pin 13. For the BBB to talk to other development boards or devices, both must have a common reference voltage, which we call “Ground”. Ground is labeled as “DGND” (digital ground) and can be found on several pins: 1, 2, 43, 44, 45, and 46 of header “P9”. And on pins: 1 and 2 of header “P8”. I will be testing the UART4 port and minicom by using a logic analyzer; a device that can see the digital levels on the pins and record them in a wave form.
The logic analyzer’s software that I used has several functions, one is to just monitor a digital signal vs time, and the other is to try to interpret different common communication protocols, I will be using both. A UART-to-USB adapter may be used to test the system, but it won’t help to figure out if there are other issues such as timing issues, etc.
For UART communication, the TX pin of one of the devices must be connected to the RX pin of the other device and vice-versa. IMPORTANT!!! The BeagleBone logic level is from 0V to 3.3V, applying voltage higher than 3.3V on any pin (1.8V on analog pins) will damage the board. If the other device you are communicating with is higher than 3.3V, use shift level converter or use a voltage divider to convert the higher voltage to 3.3v.
Since the UART protocol is asynchronous, both devices communicating must agree on several specifications which are:
- Baud Rate: (speed of transfer) number of bits to transfer per transaction.
- Parity-bit: the parity-bit option tells the receiving device that the last bit has been sent and transaction is over.
- Polarity: determines if the line will be logic “high” or logic “low” while idling. Note: not all devices allow polarity to be changed.
1. Make the following connections: ground signals together, BBB's UART4 TX to the logic analyzer receiving pin, and BBB's UART4 RX to the sending pin of the logic analyzer.
As a real world example, one could connect the BBB to a daughter board like a Servo Controller board. The orange wire connects the RX pin of UART4 in the BBB to the TX pin of the daughter board and the white wire connects the TX pin of UART4 in the BBB to the RX pin of the daughter board.
2. Open minicom and setup the communication settings:
minicom -b 9600 -D /dev/ttyO4
“minicom” is the application we are running for UART communication. “-b 9600” sets the baudrate to 9600. “-D /dev/ttyO4” sets the serial device to UART4 on the BeagleBone.
3. Once minicom is running, try typing letter or number. We won’t be able to see anything we typed in the minicom terminal unless we enable the “echo” function.
4. NOTHING HAPPENED! Let’s fix it. Exit minicom by pressing “Ctrl” + “a” on your keyboard and then “z”. This will open a menu, we need to select “exit and reset”, let’s press “x” on the keyboard. Then press “y” to confirm the exit. In the next section, it will be explained how to fix this no print issue.
To use the UART4 communication, we need to enable it by editing the uEnv.txt. Just like we disabled the HDMI and the EMMC uboot overlay. We need to enable UART4 device tree overlay. Device Tree is a binary file that is read at boot time and sets the functions of each pin. This must be done since each pin can have more than one function. To change the functionality of each pin without recompiling the whole Device Tree, Device Tree Overlays have been created. These overlays will modify the Device Tree at boot time and configure the pins appropriately and the driver gets loaded for such function if necessary. There are currently several overlays already compiled and available in the BeagleBone’s directory: /lib/firmware/.
1. Edit the uEnv.txt file using nano.
sudo nano /boot/uEnv.txt
2. Enable the BB-UART-00A0 device tree overlay by modifying the following line:
“#uboot_overlay_addr4==lib/firmware/<file4>.dtbo”
to
“uboot_overlay_addr4=/lib/firmware/BB-UART4-00A0.dtbo”
3. Press “Ctrl” + “x” on your keyboard. Then “y” and then “enter” to save the changes to the same file.
4. Reboot the board.
Now we are ready to use minicom to send data through UART.
1. Open minicom with the settings to use the serial communication at a baud of 9600 and use the UART4 which is “TTYO4”.
minicom -b 9600 -D /dev/ttyO4
2. As you type in the minicom terminal, the logic analyzer will see the pulses coming out of the BBB TX pin of UART4 and displays the data.
When pressing “a” in the minicom terminal, the logic analyzer saw the following pulses shown on Figure 28.
When sending keystrokes using the `protocol analyzer` function of the logic analyzer and specifying UART, we can see all the data sent/received via the BBB RX/TX pins as seen on Figure 29.
On Figure 29, the minicom instance has the “local echo” option enabled so we can see what we typed.
- BBB transmit: on the right, we can see the logic analyzer window with the received characters. Notice that the letters are not the same as the one on minicom on the left, that’s because on minicom we typed the “backspace” key to correct typos, and the logic analyzer represents those keystrokes as “/b”.
- BBB receive: If we type something in the TX section of the protocol analyzer, and press “enter”, we can see the string showing up on the minicom terminal.
3. To exit minicom press “Ctrl” + “A”, then “z” to enter the menu. Then press “x” to exit. And then “enter” to confirm the exit.
ConclusionThis guide can be used to get started to interface a single board computer that runs Linux such as the BeagleBone Black to other embedded systems projects that required higher level functionality such as robust internet connection and use of advanced USB devices. It shows how to get started to connect the BBB without a screen and simple common commands that are used in Linux often. It also shows how to disable and enable device tree overlays to modify the default functionality of the general-purpose inputs and outputs on the BBB.
References and additional reading- https://beagleboard.org/blog/2022-02-15-using-device-tree-overlays-example-on-beaglebone-cape-add-on-boards
- http://www.ofitselfso.com/BeagleNotes/Disabling_The_EMMC_Memory_On_The_Beaglebone_Black.php
- http://www.ofitselfso.com/BeagleNotes/Beaglebone_Black_And_Device_Tree_Overlays.php
- https://www.diozero.com/internals/bbbsetup.html
- https://beagleboard.org/support/bone101
Comments