Uncategorized

I2C communication in BeagleBoneBlack

A bit of a background.

I wanted to log temperature and humidity in my room for no reason and I wanted to do it on my BBB. My plan is to post this data to a web application as an experiment, because I have never ever done web apps in my life.

I’m going to use the Si7021 module which I bought from core electronics (here is the link)

Adafruit Si7021 Temperature & Humidity Sensor Breakout Board ADA3251 Adafruit in Australia - Express Delivery Australia Wide (Feature image)
https://core-electronics.com.au/media/catalog/product/cache/1/image/650×650/fe1bcd18654db18f328c2faaaf3c690a/3/2/3251-00.jpg
(more…)

Setting up the BeagleBoneBlack (BBB)

Disclaimer

The main purpose of this blog entry is for me to remember what I did to configure the BeagleBone-Black single board computer.


A couple of years back (somewhere around 2014) I was working on projects primarily ran on Embedded Linux operating systems. I purchased a BeagleBone-Black to learn driver development, kernel internals, etc.. However, I did not have time (or rather priority) to do any projects on these boards. Fast-forward 6 years, and now, somehow I feel like I have some spare time to dedicate to hobby projects.

My BeagleBone-Black still lives in it’s original packaging and last week I decided to get it updated to the latest operating system. I checked what version I have in the eMMC and realized that it is the ancient version that the manufacturers originally flahsed way back in 2014. The Angstrom distribution which is now tagged as outdated.

I’m going to list down the steps I followed to get the board updated with the latest BeagleBone-Black image and setup wifi.

List of things to buy

  1. Micro SD card (I bought a SanDisk-Ultra microSDHC 16GB card)
  2. 5V Power supply with a center positive barrel connector (I bought one which can provide 3 A current)
  3. A wifi dongle (I bought a $4 cheap RTL8188CUS based wifi dongle)

Flashing the latest firmware

References

  1. Beaglebone black – Getting Started
  2. Link to latest (as at 20-05-2020) debian image

Steps

  • Download the SD Card format software (Balena-etcher)
  • Download the latest debian image
  • Flash the debian image to the microSD Card using ‘BalenaEtcher’
  • Remove power from BeagleBoneBlack
  • Insert the microSD card
  • Apply power to BeagleBoneBlack while holding the UserBoot button
  • Once the 4 blue LEDs are ON, let go of the button
  • Connect the board to PC
  • Wait for sometime for the device to boot
  • Once it is booted, connect to 192.168.7.2 using your favorite SSH client
  • Issue the command:
debian@beaglebone:~$ cat /etc/dogtag
  • Output for me is:
BeagleBoard.org Debian Buster IoT Image 2020-04-06
  • Open /boot/uEnv.txt and change the following line
##enable Generic eMMC Flasher:
##make sure, these tools are installed: dosfstools rsync
#cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh

to

#enable Generic eMMC Flasher:
#make sure, these tools are installed: dosfstools rsync
cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh
  • Reboot the BeagleBoneBlack
  • Now you will see that LEDs will be fading left to right and it is the cue that the image is being flashed to eMMC
  • This took around 20~30 mins to complete.
  • Once the flash operation has completed, the LEDs switch off
  • Remove the SD CARD and apply power again
  • Now it boots from eMMC and check the version again. You should get the same dogtag as above
BeagleBoard.org Debian Buster IoT Image 2020-04-06
  • Done!

Setting the default boot to be SD CARD

Reference

  1. https://www.erdahl.io/2016/12/beaglebone-black-booting-from-sd-by.html

Steps

  • Connect to BeagleBoneBlack terminal
  • Execute ‘lsblk’ command

BBB#1

  • Find out what is the microSD card (In my case mmcblk0 because it is 16 GB)
  • Execute ‘sudo fdisk /dev/mmcblk1’
  • Then select ‘a’ to toggle bootable flag
  • Then select ‘w’ to save and ‘q’ to exit
  • Then execute ‘sync’ and ‘reboot’
  • Now you should be rebooting in microSD card
  • You can confirm this by using ‘sudo fdisk -l’
  • In my case it looks like below (notice the * under /dev/mmblk0p1 boot column)

BBB#2

  • Done!

Setting up wifi

This is super easy now with connmanctl!

Reference

  1. A guide by Digikey

Steps

connmanctl> enable wifi
connmanctl> scan wifi
connmanctl> services
output: <WifiName> <WifiLongName>
connmanctl> agent on
connmanctl> connect <WifiLongName>
connmanctl> quit

That’s it!

I hope it helped.

Using ‘printf’ in microcontrollers

We, as electronics enthusiasts, daily write hundreds of firmware code segments for various microcontrollers. Unlike software, when it comes to debugging microcontroller code, the challenges we face are much more fundamental. I believe that the most common method for debugging firmware is using the good old printf (just like the cout in C++ and println in Java).

When we develop conventional C code for Linux systems, printf works without any hassle. However, to enable the same functionality in microcontrollers, we need to peel away a layer in the C library and find out how exactly printf works.

How printf works?

As you may already know, printf function is implemented within the C library. I will not go through the full printf function definition. If you want you can read http://blog.hostilefork.com/where-printf-rubber-meets-road/. It’s one of the best write-ups I have seen.

However, the important part is, at the end of this function chain, printf calls another function called write. This is a standard system call in Linux, a part of kernel API. However, for microcontrollers, we don’t have such liberties and thus, we have to implement this function ourselves.

(more…)

Raspberry Pi torrent box with AWS

This post is more or less a continuation of my previous blog post, Converting your Raspberry Pi into a light weight torrent box.

If you follow this post you will be able to develop your own fully functional and easily extendable torrent box for your personal use. Please note that there may be web sites which already have services similar and better than what I have implemented. We are here to learn how to do that aren’t we? Everyday is a school day!!!

BONUS!!! If my server is running now following link would allow you to check what I am downloading now. 😉 Copy and paste the below in your browser.

(For mozilla)

view-source:http://54.191.41.142:8080/getStatus

(For other)

http://54.191.41.142:8080/getStatus

Right click and select view source to display the status in a better format.

So far we have set-up the deluge torrent client in our RPi (RaspberryPi) and we have confirmed that it is operational. This step is very important to have a working torrent-box.

First I will go through the design or the architecture of the solution that I am going to develop.

Architecture

Architecture1.vsdx.jpg (more…)