Cross-Compiling Bottlerocket for CM17a Firecracker on Synology

Cross-Compiling Bottlerocket, which uses the Firecracker CM17a:
http://www.linuxha.com/bottlerocket/

Following the 3rd-party app integration guide; configure, make, make install. This puts it in your local machines /usr/local/bin. You then have to upload the program ‘br’ to your Synology in the same directory.

Set your cross-compiling environment variables to point to the toolchain you installed in /usr/local:

root@xubuntu-vm:/usr/local/bottlerocket-0.04c# export CC=/usr/local/powerpc-linux/bin/powerpc-linux-gcc
root@xubuntu-vm:/usr/local/bottlerocket-0.04c# export LD=/usr/local/powerpc-linux/bin/powerpc-linux-ld
root@xubuntu-vm:/usr/local/bottlerocket-0.04c# export RANLIB=/usr/local/powerpc-linux/bin/powerpc-linux-ranlib
root@xubuntu-vm:/usr/local/bottlerocket-0.04c# export CFLAGS="-I/usr/local/powerpc-linux/include"
root@xubuntu-vm:/usr/local/bottlerocket-0.04c# export LDFLAGS="-L/usr/local/powerpc-linux/lib"

Run the configure that came with the code giving it a few extra parameters as specified in the guide:

root@xubuntu-vm:/usr/local/bottlerocket-0.04c# ./configure \
> --host=powerpc-unknown-linux \
> --target=powerpc-unknown-linux \
> --build=i686-pc-linux \
> --prefix=/usr/local
creating cache ./config.cache
checking for gcc... /usr/local/powerpc-linux/bin/powerpc-linux-gcc
checking whether the C compiler (/usr/local/powerpc-linux/bin/powerpc-linux-gcc -I/usr/local/powerpc-linux/include -L/usr/local/powerpc-linux/lib) works... yes
checking whether the C compiler (/usr/local/powerpc-linux/bin/powerpc-linux-gcc -I/usr/local/powerpc-linux/include -L/usr/local/powerpc-linux/lib) is a cross-compiler... yes
checking whether we are using GNU C... yes
checking whether /usr/local/powerpc-linux/bin/powerpc-linux-gcc accepts -g... yes
checking how to run the C preprocessor... /usr/local/powerpc-linux/bin/powerpc-linux-gcc -E
checking for a BSD compatible install... /usr/bin/install -c
checking for features.h... yes
checking for errno.h... yes
checking for sys/termios.h... yes
checking for termios.h... yes
guessing x10 port
using /dev/ttyS0 for x10 port
updating cache ./config.cache
creating ./config.status
creating Makefile
creating config.h

Run make:

root@xubuntu-vm:/usr/local/bottlerocket-0.04c# make
/usr/local/powerpc-linux/bin/powerpc-linux-gcc -I/usr/local/powerpc-linux/include -I. -Wall -O2 -DX10_PORTNAME=\"/dev/ttyS0\" -DHAVE_CONFIG_H -c ./br_cmd.c
/usr/local/powerpc-linux/bin/powerpc-linux-gcc -I/usr/local/powerpc-linux/include -I. -Wall -O2 -DX10_PORTNAME=\"/dev/ttyS0\" -DHAVE_CONFIG_H -c ./br.c
/usr/local/powerpc-linux/bin/powerpc-linux-gcc -I/usr/local/powerpc-linux/include -I. -Wall -O2 -DX10_PORTNAME=\"/dev/ttyS0\" -DHAVE_CONFIG_H -o br br.o br_cmd.o

Run ‘make install’ which installs it in /usr/local/bin on your local machine:

root@xubuntu-vm:/usr/local/bottlerocket-0.04c# make install
/usr/bin/install -c -d -m 755 /usr/local/bin
/usr/bin/install -c -m 555 br /usr/local/bin

Now copy the file /usr/local/bin/br to your synology in the same directory.

Once that is running, you issue commands as such:

DiskStation> cd /usr/local/bin/
DiskStation> ./br
BottleRocket version 0.04c

Usage: ./br [][() ...]

Options:
-v, --verbose add v's to increase verbosity
-x, --port=PORT set port to use
-c, --house=[A-P] use alternate house code (default "A")
-n, --on=LIST turn on devices in LIST
-f, --off=LIST turn off devices in LIST
-N, --ON turn on all devices in housecode
-F, --OFF turn off all devices in housecode
-d, --dim=LEVEL[,LIST] dim devices in housecode to relative LEVEL
-B, --lamps_on turn all lamps in housecode on
-D, --lamps_off turn all lamps in housecode off
-r, --repeat=NUM repeat commands NUM times (0 = ~ forever)
-h, --help this help

is a comma separated list of devices (no spaces),
each ranging from 1 to 16
is an integer from -12 to 12 (0 means no change)
is a letter between A and P
is one of ON, OFF, DIM, BRIGHT, ALL_ON, ALL_OFF,
LAMPS_ON or LAMPS_OFF

For native commands, should only be specified for ON or OFF.

DiskStation> ./br -x /dev/ttyUSB0 -v M3 OFF
./br: Turning off appliance M3
DiskStation> ./br -x /dev/ttyUSB0 -v M3 ON
./br: Turning on appliance M3
DiskStation> ./br -x /dev/ttyUSB0 -v M3 OFF
./br: Turning off appliance M3
DiskStation> ./br -x /dev/ttyUSB0 -v C1 ON
./br: Turning on appliance C1
DiskStation> ./br -x /dev/ttyUSB0 -v C1 OFF
./br: Turning off appliance C1
DiskStation> ./br -x /dev/ttyUSB0 -v C1 ON
./br: Turning on appliance C1
DiskStation> ./br -x /dev/ttyUSB0 -v C3 ON
./br: Turning on appliance C3
DiskStation> ./br -x /dev/ttyUSB0 -v C3 OFF
./br: Turning off appliance C3
DiskStation> ./br -x /dev/ttyUSB0 -v C3 ON
./br: Turning on appliance C3
DiskStation> ./br -x /dev/ttyUSB0 -v C1 OFF
./br: Turning off appliance C1
DiskStation> ./br -x /dev/ttyUSB0 -v C3 OFF
./br: Turning off appliance C3
DiskStation> ./br -x /dev/ttyUSB0 -v C LAMPS_ON
DiskStation> ./br -x /dev/ttyUSB0 -v C LAMPS_OFF
DiskStation> ./br -x /dev/ttyUSB0 -v C1 ON
./br: Turning on appliance C1
DiskStation> ./br -x /dev/ttyUSB0 -v -d25 C1
./br: For dimming either specify just a dim level or a comma
separated list containing the dim level and the devices to dim.
./br: Valid dimlevels are numbers between -12 and 12.
DiskStation> ./br -x /dev/ttyUSB0 -v -d6 C1
BottleRocket version 0.04c

Usage: ./br [][() ...]

Options:
-v, --verbose add v's to increase verbosity
-x, --port=PORT set port to use
-c, --house=[A-P] use alternate house code (default "A")
-n, --on=LIST turn on devices in LIST
-f, --off=LIST turn off devices in LIST
-N, --ON turn on all devices in housecode
-F, --OFF turn off all devices in housecode
-d, --dim=LEVEL[,LIST] dim devices in housecode to relative LEVEL
-B, --lamps_on turn all lamps in housecode on
-D, --lamps_off turn all lamps in housecode off
-r, --repeat=NUM repeat commands NUM times (0 = ~ forever)
-h, --help this help

is a comma separated list of devices (no spaces),
each ranging from 1 to 16
is an integer from -12 to 12 (0 means no change)
is a letter between A and P
is one of ON, OFF, DIM, BRIGHT, ALL_ON, ALL_OFF,
LAMPS_ON or LAMPS_OFF

For native commands, should only be specified for ON or OFF.

DiskStation> ./br -x /dev/ttyUSB0 -v -cC -d6,1
./br: Brightening lamp C1 by 6.
DiskStation> ./br -x /dev/ttyUSB0 -v -cC -d-6,1
./br: Dimming lamp C1 by 6.
DiskStation> ./br -x /dev/ttyUSB0 -v -cC -d6,3
./br: Brightening lamp C3 by 6.
DiskStation> ./br -x /dev/ttyUSB0 -v -cC -d-3,3
./br: Dimming lamp C3 by 3.
DiskStation> ./br -x /dev/ttyUSB0 -v -cC -d-3,3
./br: Dimming lamp C3 by 3.
DiskStation> ./br -x /dev/ttyUSB0 -v -cC -d-3,2
./br: Dimming lamp C2 by 3.
DiskStation> ./br -x /dev/ttyUSB0 -v -cC -d3,2
./br: Brightening lamp C2 by 3.
DiskStation> ./br -x /dev/ttyUSB0 -v C LAMPS_OFF

Advertisements
Posted in Uncategorized | Leave a comment

Home Automation on Synology NAS

I am the proud owner of a Synology DS209j NAS. This NAS has firmware that allows much more than just storage. While I only wanted one computer on 2/47 in the house. I also wanted a home automation server. Unfortunately, the Synology NAS devices weren’t intended to be home automation servers. Therefore, a lot of modification has been required to get it to act as a home automation server. These next few posts have been up in the Synology forum for a while now, but I wanted to add my work to my own blog so please click ‘read more’ to expand this post…


http://forum.synology.com/enu/viewtopic.php?f=27&t=19788#p81040

I have a Synology DS209j, and I’ll always run the latest firmware.

I’ve installed Xubuntu 9.04 in a virtual machine on my mac.

Following this page:
http://www.synology.com/us/support/3rd-party_application_integration.php

There is a document:
http://download.synology.com/download/ds/userguide/Synology%20NAS%20Server%203rd-Party%20Apps%20Integration%20Guide.pdf

Following the document I’ve downloaded the latest toolchain from Synology as well as the latest GPL source:
http://www.synology.com/us/gpl/index.php

As far as usb to serial hardware goes, I am using this product from Parallax as it give you proper RS232 levels and is very affordable:
http://www.parallax.com/tabid/768/ProductID/378/Default.aspx

From that page I followed the link to the external FTDI drivers for linux.

I renamed the ftdi_sio header and c file to .orig and placed these new files in their location in the synology source. From their I followed the document and made the modules.

Now i’ve got usbserial.ko and ftdi_sio.ko somewhere on my DS209j

Now you have to load the modules into the kernel and create the devices:

insmod usbserial.ko
insmod ftdi.ko
mknod /dev/usb/ttyUSB0 c 188 0
mknod /dev/usb/ttyUSB1 c 188 1

Also, add some lines like these to /etc/rc.local to make it persistent over reboot:

insmod /volume1/archive/usbserial.ko
insmod /volume1/archive/ftdi_sio.ko
mknod /dev/usb/ttyUSB0 c 188 0
mknod /dev/usb/ttyUSB1 c 188 1

run the command ‘dmesg’ and you should see something like this:

usb 1-2.1: new full speed USB device using ehci_hcd and address 15
usb 1-2.1: configuration #1 chosen from 1 choice
ftdi_sio 1-2.1:1.0: FTDI USB Serial Device converter detected
drivers/usb/serial/ftdi_sio.c: Detected FT232RL
drivers/usb/serial/ftdi_sio.c: Number of endpoints 2
drivers/usb/serial/ftdi_sio.c: Endpoint 1 MaxPacketSize 16384
drivers/usb/serial/ftdi_sio.c: Endpoint 2 MaxPacketSize 16384
drivers/usb/serial/ftdi_sio.c: Setting MaxPacketSize 16384
usb 1-2.1: FTDI USB Serial Device converter now attached to ttyUSB0

The X-10 device I got working for now is known as the Firecracker CM17a, and the HD11A/CM11A 2-way computer interface

Posted in Uncategorized | 2 Comments

I got one of these to help me map the circuits in my house for X10 use. With this you can do it without turning the power off to see what is on what circuit.

Posted in Uncategorized | Leave a comment

Getting started in home automation

I just picked this up from the Smarthome factory store and it prompted me to write a blog about home automation, abbreviated as HA from here on out.

I’m not going to go into a definition of what HA is as I will assume you are already aware of it. As I am interested in robotics, I am also interested in home automation. Like robotics it is a series of sensors (distance, motion, temperature), a brain (computer/MCU), and actuators (servos, relays).

The two protocols I am focusing on for now are X10 and Insteon. The place to go for X10 hardware is: http://www.x10.com, the place to go for Insteon hardware is http://www.smarthome.com. Although smarthome also sells X10 components in a pinch. I would recommend X10.com because they have nice deals on packages of hardware.

While Insteon is more modern and has error checking and correcting in a sense, I am mostly going to go with X10 for now because it is cheaper and I’m a starving student.

Starting out I would recommend buying all your X10/Insteon hardware first and use it around the house with your controllers and remotes by hand. Buy bulk in motion sensors, lamp modules, and appliance modules (2 and 3 pin).

Recent experience has told me to stay away from the X10 TM751 transceivers because they have a high failure rate. TM751s also can not accept Power Line Carrier (PLC) commands, which we will use later when we bring the computer into the picture. The transceiver I recommend for starters is the RR501 model. Later on we will replace the RR501s with something much better, a W800USB, but will require the use of a computer. The W800USB will also be able to receive X10 signals from those magnetic door contact closures which by default only work with security system receivers.

The package you see above in the picture is a kit containing an RR501 transceiver and the HR12a Palm Pad. The item number of the package is PHK05 or RC5000 depending on where you go.

Since the number of rooms in your residence will vary, I will just give you the basic inventory per room:

LM465 Dimmable Lamp Module – 1 per incandescent lamp (do not use on flourescents)
MS13a HawkEye or MS14a EagleEye Motion Sensor – 1 per room
AM466 3-Pin Appliance Module – Depending on how many 3-Pin devices you have in a room
AM486 2-Pin Appliance Module – Depending on how many 2-Pin devices you have in a room.
RR501 Wireless Transceiver – 1 per 16 wireless devices
Remotes and/or Controllers – Your choice:
Wired: http://www.x10.com/automation/plugin_controllers.html
Wireless: http://www.x10.com/automation/wireless_remotes.html#home_remotes

Note: You can use appliance modules on everything. You can use lamp modules on only incandescent lamps.

Later I will talk about adding a computer, software, computer interface, X10 wireless receiver interface, and DS10a door/window sensors.

Posted in Uncategorized | 2 Comments

Robot firmware over the air!

Sorry my posts have been kind of weak lately. I have not really felt like writing things up, and I’ve been very busy with school and work. Here is a horrible video I made last night of my robot demonstrating object avoidance and programming the target MCU wirelessly.

http://vimeo.com/moogaloop.swf?clip_id=3293393&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1
Robot firmware over the air! from Brandt Daniels on Vimeo.

Posted in Uncategorized | 1 Comment

Servo Magazine

I was featured in this month’s Servo Magazine regarding wireless programming 🙂

Check it out:

Posted in Uncategorized | Leave a comment

Wind-Up Robots

I love these wind-up robots of mine! Now all I need is the B9 from ‘Lost in Space’, R2D2, and C3-PO!

Posted in robot, toy, wind-up | Leave a comment