Skip to main content

#2: Doing Something with the Beaglebone Black

Something Useful: Retroshare

I actually want to run Streamtuner and Retroshare on the BBB.   More about Retroshare here: http://www.aeronetworks.ca/2013/07/your-own-darknet.html

The BBB will make a nice static DHT reference for my small circle of friends and devices on Retroshare, to ensure that all can always connect no matter how much anyone or anything moves around.

Expand the SD Linux File System

If you followed my first BBB post, then you have probably seen this already:
grep: write error: No space left on device

It looks like the first thing to do, is expand the root partition to fill the SD card, otherwise there is no room to do anything :(

On you computer, use screen to connect to the serial console over a FTDI USB serial cable:
$ screen /dev/ttyUSB0 115200

On a Mac, screen works the same, but the device is something like /dev/tty.usbserial-AH0142BF

So, what was that about Macs having sensible device names? Sigh...

Then power the BBB up using the USB cable, or a 5V PSU.

Login and set user to root:
Login: username
password
$ su -
password

See what is there:
# fdisk /dev/mmcblk0
Disk /dev/mmcblk0: 7.5 GiB, 8010072064 bytes, 15644672 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00036e16

Device         Boot     Start       End  Blocks  Id System
/dev/mmcblk0p1 *         1953     41015   19531+  c W95 FAT32 (LBA)
/dev/mmcblk0p2          41016    291015  125000   c W95 FAT32 (LBA)
/dev/mmcblk0p3         291016  15644671 7676828  83 Linux
 

The above tells me that the SD card is 8GB and there are 3 partitions.  The 3rd one is the Linux partition that we got to fix.  Note that the Linux partition fills the whole device, meaning that the partition is OK, but the file system doesn't fill the whole partition.  So it is only a file system problem, not a partition problem.

Grow the File System

Grow the filesystem over the rest of the partition:
$ su -
password
# resize2fs /dev/mmcblk0p3

La voila!

Well, assuming that it still works, otherwise you are back at square one and need to rewrite the SD card again, as per my other BBB post...

Make a SD Backup

At this point, it may be a smart idea to make a backup of the whole SD card, so that next time you have to rewrite the stupid thing, you don't need to do the setup steps again.  So shutdown now, power off and plug the SD card into a laptop computer then use dd or cat with gzip to make a copy of the SD card:
# cat /dev/mmcblk0 | gzip -9 > bbb-f20-1.gz 

or on a Mac, which will likely do a partial automount, you got to unmount it first:
$ sudo umount /dev/disk1s1
$ sudo cat /dev/disk1 | gzip -9 > bbb-f20-1.gz

Why does Macs have sensible device names while Linux is such a mess lately?

Since at this time the SD image is still mostly zeroes, the compressed image will be manageable, but it will take a looong taaaime to do, so go and get a tall, cold one...

Accessing the BBB Hardware

The serial ports are available in /dev/ttyox (that 'o' really is a letter, not a zero), while the GPIO ports are available in /sys/class/gpio:
$ ls /dev/ttyo* 
$ ls /sys/class
ata_device  graphics     mem            ptp          scsi_generic  vc
ata_link    hidraw       misc           pwm          scsi_host     vtconsole
ata_port    hwmon        mmc_host       raw          sound         watchdog
bdi         i2c-adapter  net            regulator    spi_master
block       ieee80211    pci_bus        rfkill       thermal
bsg         input        pcmcia_socket  rtc          tty
dma         leds         power_supply   scsi_device  udc
gpio        mdio_bus     pps            scsi_disk    usbmon


$ ls -al /sys/class/gpio
total 0
drwxr-xr-x.  2 root root    0 Jan  1  2000 .
drwxr-xr-x. 45 root root    0 Jan  1  2000 ..
--w-------.  1 root root 4096 Jan  1  2000 export
lrwxrwxrwx.  1 root root    0 Jan  1  2000 gpiochip0 -> ../../devices/virtual/gpio/gpiochip0
lrwxrwxrwx.  1 root root    0 Jan  1  2000 gpiochip32 -> ../../devices/virtual/gpio/gpiochip32
lrwxrwxrwx.  1 root root    0 Jan  1  2000 gpiochip64 -> ../../devices/virtual/gpio/gpiochip64
lrwxrwxrwx.  1 root root    0 Jan  1  2000 gpiochip96 -> ../../devices/virtual/gpio/gpiochip96
--w-------.  1 root root 4096 Jan  1  2000 unexport


Feel free to poke around, don't be shy...

Hardware Information:
Using GPIOs on Linux:
It is relatively straight forward to access a GPIO from a script, using simple echo statements, but one has to configure them before one can use them.

See table 10 on page 70 for the P8 header and table 11 on page 72 for the P9 header in the reference manual https://github.com/CircuitCo/BeagleBone-Black/blob/master/BBB_SRM.pdf?raw=true

For example, P9 pin 15 is gpio[16] and is on gpiochip32, which has an offset of 32, so pin 15 is 16+32 = gpio48.

Two P9 header GPIO pin number mapping to kernel names:
  • pin 15 = gpio48
  • pin 16 = gpio51
To enable both pins:
# echo 48 > /sys/class/gpio/export
# echo 51 > /sys/class/gpio/export 

Now, there should be two new subdirectories in /sys/class/gpio representing these two pins and one can set the direction and a value for pin 15 and watch it toggle with an oscilloscope:
# echo out > /sys/class/gpio/gpio48/direction
# echo 0 > /sys/class/gpio/gpio48/value
# echo 1 > /sys/class/gpio/gpio48/value

Note that the BBB uses 3.3V logic and a pin can drive up to 5mA, so be careful with what you connect to it so you don't blow the pin drivers up.

You could use something like this opto-coupled solid state relay to control things with only 0.5mA per pin:
http://www.vishay.com/docs/81646/vo14642a.pdf 

A 3.3V supply minus 1.5V forward diode voltage, divide by 0.5mA, means using either a 270 or 330 Ohm series resistor on this type of opto-coupler.

La voila!


Comments

Popular posts from this blog

Parasitic Quadrifilar Helical Antenna

This article was reprinted in OSCAR News, March 2018:  http://www.amsat-uk.org If you want to receive Satellite Weather Pictures , then you need a decent antenna, otherwise you will receive more noise than picture. For polar orbit satellites, one needs an antenna with a mushroom shaped radiation pattern .  It needs to have strong gain towards the horizon where the satellites are distant, less gain upwards where they are close and as little as possible downwards, which would be wasted and a source of noise.  Most satellites are spin stabilized and therefore the antenna also needs circular polarization, otherwise the received signal will flutter as the antennas rotate through nulls. The helical antenna, first proposed by Kraus in 1948, is the natural solution to circular polarized satellite communications.  It is a simple twisted wire - there seems to be nothing to it.  Various papers have been published on helix antennas, so the operation is pretty well understood. Therefore,

Weather Satellite Turnstile Antennas for the 2 meter Band

NEC2, 2 m band, 146 MHz, Yagi Turnstile Simulation and Build This article describes a Turnstile Antenna for the 2 meter band, 146 MHz amateur satcom, 137 MHz NOAA and Russian Meteor weather satellites.  Weather satellite reception is described here .  A quadrifilar helical antenna is described here .   Engineering, is the art of making what you need,  from what you can get. Radiation Pattern of the Three Element Yagi-Uda Antenna Once one combine and cross two Yagis, the pattern becomes distinctly twisted. The right hand polarization actually becomes visible in the radiation pattern plot, which I found really cool. Radiation Pattern of Six Element Turnstile Antenna Only a true RF Geek can appreciate the twisted invisible inner beauty of a herring bone antenna... Six Element Turnstile Antenna Essentially, it is three crosses on a stick.  The driven elements are broken in the middle at the drive points.  The other elements can go straight throug

Patch Antenna Design with NEC2

The older free Numerical Electromagnetic Code version 2 (NEC2) from Lawrence Livermore Lab assumes an air dielectric.  This makes it hard (but not impossible) for a radio amateur to experiment with Printed Circuit Board Patch antennas and micro strip lines. Air Spaced Patch Antenna Radiation Pattern You could use the free ASAP simulation program , which handles thin dielectrics, you could shell out a few hundred Dollars for a copy of NEC4 , You could buy GEMACS if you live in the USA, or you could add distributed capacitors to a NEC2 model with LD cards (hook up one capacitor in the middle of each element.), but that is far too much money/trouble for most. More information on driving an array antenna can be found here: https://www.aeronetworks.ca/2019/03/driving-quad-patch-array-antenna.htm l Air Dielectric Patch   The obvious lazy solution is to accept the limitation and make an air dielectric patch antenna. An advantage of using air dielectric, is that the antenn