Evolution of a Blog

This blog has evolved as I have as a maker. It starts at the beginning of my journey where I began to re-tread my tires in the useful lore of micro electronics and the open-source software that can drive them. While building solutions around micro-electronics are still an occasional topic my more recent focus has been on the 3D Printing side of making.

Thursday, October 31, 2013

Beaglebone Black Image Setup for 'The App'

Below is the procedure that I follow to create an Operating System mage on which my app runs.   This assumes we are starting with a distribution image that has been flashed to the internal drive of the BBB, dd'ed off that image having booted from the external SD drive, and then having used the img copy to create a new bootable SD card.  I know, there is probably an easier way to accomplish creating a new bootable image from a distribution file!

In any case then we do the following:

First make sure that the system date and time is accurate: 
ntpdate -b -s -u pool.ntp.org

Then update the package indexes for both the OS and for NPM:
opkg update
npm update 

Now install all the OS level stuff that we will be needing:
opkg install python-compiler
opkg install python-misc
opkg install python-multiprocessing
opkg install xdotool
opkg install gettext

The version of git on the BBB needs to be updated so download the tarball with the code and then do the following:
tar -xvf git-1.8.?.tar.gz
cd git-1.8.?
./configure --without-python
make install

There is a problem with npm such that it will incorrectly fail thinking that it does not have the right version of Python installed.   Fix this via the below edits:
nano /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js 
if (semver.gte(version, '2.5.0') && semver.lt(version, '3.0.0')) {
                    } else {

Now all the npm packages that we need can be installed:  
npm install -g node-gyp
npm install -g i2c
npm install -g socket.io
npm install -g descriptive-statistics
npm install -g exec-sync
npm install -g zipstream  
npm install -g line-by-line
npm install -g serialport2

Following sections, for RTC, are obsoleted by getting the date and time via the Arduino.  At this point, assuming we are wired for our I2C devices, we can set up our Real Time Clock.    This is, of course, assuming that when you run the first of the below commands you see something at address 0x68!   If there is, test it by doing the rest of the commands (get current network time, create the RTC device, write the time to the RTC, pull it off the RTC):
i2cdetect -y -r 1

ntpdate -b -s -u pool.ntp.org
echo ds3231 0x68 >/sys/bus/i2c/devices/i2c-1/new_device
hwclock -f -w /dev/rtc  
hwclock -f -s /dev/rtc

If all is well above (note that you need to check the device [/dev/rtc?] that was created to ensure you have the right name), create the following file “rtc” in “/etc/init.d”:
#! /bin/sh
# /etc/init.d/rtc

# Provides:          Time sync
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Updates time from rtc

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
    echo "Starting time sync"
    echo ds3231 0x68 >/sys/bus/i2c/devices/i2c-1/new_device
    hwclock -f /dev/rtc -s
    echo "Usage: /etc/init.d/rtc {start}"
    exit 1

exit 0

Make the above created file executable:
chmod +x rtc

And have it run automatically:
update-rc.d rtc defaults

Now make sure the board time is set, then load it to the RTC:

ntpdate -b -s -u pool.ntp.org
hwclock -f -w /dev/rtc  

Now we can create our source directories for the application.   First create a directory named "AppNameHere", cd into it, and execute the following command:
git clone https://github.com/ThamesWill/AppNameHere.git dev

Fix for possible authentication issues:

Once this has completed (note that you will need an id on github) you should execute the following script from the download:

The above should have created all the other directories and startup files that will be needed.   At this point you should be able to execute the command line configuration tool:

If everything is working you will see a list of default parameters.
One last change is to point the cloud9 environment at the source code we just downloaded. Do this by editting the following file replacing the "/etc/lib/cloud9" entries with the path to the dev directory created above.
nano /lib/systemd/system/cloud9.service 

You will now need to either reboot or tell systemctl about your changes and then restart cloud9:
systemctl --system daemon-reload
systemctl restart cloud9
nano /lib/systemd/system/cloud9.service 

Finally, make sure that you have updated the hosts file to match your server name for The App configuration


No comments:

Post a Comment