AVR Dragon JTAG on Ubuntu Precise

November 27th, 2012

Lt. Col. Pat Ichi Karg at Little Rock Air Show in F4 PhantomI have a BACnet Development Kit which uses the example firmware compiled from the open source BACnet Protocol Stack hosted on SourceForge.net using gcc-avr. I attempted to load the firmware onto the kit using an Atmel AVR Dragon USB JTAG programmer.  I connected the AVR Dragon to my Ubuntu Precise Linux Laptop and attached the 2×5 JTAG cable to the development kit board, and attempted to program using avrdude as I had many times over the last several years.

avrdude -c dragon_jtag -p m644p -P usb -B 8 -U hfuse:w:0x93:m -U lfuse:w:0xD7:m -U efuse:w:0xFC:m
avrdude: usb_open(): cannot read serial number "error sending control message: Operation not permitted"
avrdude: usb_open(): cannot read product name "error sending control message: Operation not permitted"
avrdude: usbdev_open(): error setting configuration 1: could not set config 1: Operation not permitted
avrdude: usbdev_open(): did not find any USB device "usb"
make: *** [writefuses] Error 1

Aha, I said, I must need to edit the UDEV rules for AVRICEas I did previously.  But alas, that did not solve the problem.  It seems the syntax for the UDEV rules have changed from using ‘SYSFS’ to using ‘ATTR’, and so the new rules use the following text in a /etc/udev/rules.d/45-atmel.rules file :

# udev rules file for atmel usb devices (for udev 0.98 version) 
# 
SUBSYSTEM!="usb_device", ACTION!="add", GOTO="avrisp_end"
# Atmel Corp.JTAG ICE mkII 
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2103", MODE="660", GROUP="dialout"
# Atmel Corp. AVRISP mkII
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2104", MODE="660", GROUP="dialout"
# Atmel Corp. Dragon
ATTR{idVendor}=="03eb", ATTR{idProduct}=="2107", MODE="660", GROUP="dialout"
LABEL="avrisp_end"

After saving the file, unplugging and plugging the AVR Dragon into the USB port, I was finally able to program the board.

avrdude -c dragon_jtag -p m644p -P usb -B 8 -U hfuse:w:0x93:m -U lfuse:w:0xD7:m -U efuse:w:0xFC:m
avrdude: jtagmkII_initialize(): warning: OCDEN fuse not programmed, single-byte EEPROM updates not possible
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e960a
avrdude: reading input file "0x93"
avrdude: writing hfuse (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0x93:
avrdude: load data hfuse data from input file 0x93:
avrdude: input file 0x93 contains 1 bytes
avrdude: reading on-chip hfuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xD7"
avrdude: writing lfuse (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xD7:
avrdude: load data lfuse data from input file 0xD7:
avrdude: input file 0xD7 contains 1 bytes
avrdude: reading on-chip lfuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: reading input file "0xFC"
avrdude: writing efuse (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xFC:
avrdude: load data efuse data from input file 0xFC:
avrdude: input file 0xFC contains 1 bytes
avrdude: reading on-chip efuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.

BACnet Committee Meets in San Antonio

August 14th, 2012

Carl Neilson is the incoming Chairman of the BACnet committee.

Our BACnet committee and working groups met in San Antonio in June, 2012. The Riverwalkwas an interesting place to walk and find some food!  The BACnet committee leadership changed at this meeting: Carl Neilson is now chairing the committee, with Bernhard as vice-chair and Mike as Secretary.  David Fisher presented the annual Swan Award to Carl Neilson. Three old-timers, Steve Bushby, Mike Newman, David Fisher received recognition for 25 years since the inception the BACnet SPC.

Steve Bushby, Mike Newman, and David Fisher

View of San Antonio from BTL working group meeting.

The Alamo in San Antonio

BACnet Committee Meets in San Francisco

June 5th, 2012

Our BACnet committee and working groups met in San Francisco in May, 2012.  It was fun to see friends, enjoy some cool weather, and eat some good food in a big city.

BACnet meetin in SF at PGEBACnet meeting in SF at PGE

Next door to Pacific Gas and Electric, our host, is a restaurant called Buca di Beppo, an Italian restaurant known for its large portions and eccentric decor.  We had lunch at one of the specialty tables – a “Pope’s Table” that seats 12-18.

One night, our group was feeling adventuresome, and loaded onto BART to find an infamous San Francisco dining establishment called Rosamunde Sausage Grill.

A lot of our proposals had gone out for public review in the Spring, and so we had to create comment responses to any of the comments received.  Some of the proposals sailed through the public review process without needing any substantive changes, which mean they will go to ASHRAE and be reviewed and approved for publication.

BACnet Property_List property

One of the new items that made it through publication was the Property_List property, which will be added to all objects for the new revision of BACnet. I proposed this little gem in 2007, and it was met with stiff resistance by those developing XML to describe BACnet devices.  The pundits said that if we introduced the Property_List property, everyone would use it instead of XML, and that we should wait until XML and the Application Profiles working group completed their work.  The proposal was tabled for a couple years, but came to life again during the Objects and Services working group meetings.  A few tweaks were made to the STK-026 proposal, and Add-135-2010ao was ready for public review.

12.x.X Property_List
This read only property is a BACnetARRAY of property identifiers, one property identifier for each property that exists within the object. The Object_Name, Object_Type, Object_Identifier, and Property_List properties are not included in the list.

Additionally, from the ReadPropertyMultiple specification:

The Property_List property shall not be returned when properties ALL or REQUIRED are requested.

Pretty simple, but pretty powerful for being able to discover all the properties in all the objects in a device.  One of the comments received in public review summed up our sentiments:

Property_List is a very good addition. If someone had thought of this in 1995, we could have avoided the evil “ALL” property. However, since this property is “required”, but didn’t previously exist, and since it is likely to be widely used, it is worth flagging the protocol revision at which it is introduced.

The Protocol_Revision hasn’t been issued yet for this change, since the enumerations and other numbers associated with the published specification are no longer created when the proposals are going through the public review process.

BACnet Meeting and Plugfest in Atlanta

November 29th, 2011

I went to the BACnet meetings in Atlanta in October, 2011. A couple of weeks later in November, 2011, I went to the BACnet Plugfest in Atlanta. Lots of fun!

The Lighting Applications working group met for a couple of days, and crafted responses to the public review comments for our Lighting Output object. We also got the draft for the next pubic review done, and it should be reviewed with only substantive changes. Good news for this object that has been in the works for many, many years. We also crafted public review responses for the Channel object and the WriteGroup service, and drafted a subsequent review document.

tin drum for lunch

Coleman, Dave, Dana, Don, and I ate at the Tin Drum restaurant for lunch. Delicious!

The BACnet meetings were again held in the spacious Georgia Tech Technology Square Research Building.

I brought a WattStopper DLM setup for the BACnet International Plugfest, held at the Westin hotel in Atlanta.  It’s always fun to have bright lights controlled by a BACnet universal dimmer!  I presented a workshop on the work that the Lighting Applications working group has been doing, with some tips for developers.  It was titled “New BACnet objects and services have been proposed to support lighting control. What can you do with them? What can you do to prepare your devices?”

BACnet Leader of the Pack Awards

October 14th, 2011

BACnet International presented its annual “Leaders of the Pack” program to recognize the achievements of individuals and companies involved in the BACnet community. The Award Ceremony took place during the 2011 Facility Decisions Conference & Expo on October 11-12, 2011 in Las Vegas, NV.

I received one of the awards (although I wasn’t in Las Vegas), which was really unexpected.  The full list of recipients is listed on the BACnet International “Leaders of the Pack” website press release.

Pete Baselici was at the awards ceremony, so he received the award for me, and presented it to me when he returned.

BACnet Bill

June 5th, 2011

Bill Swan at the January 2011 BACnet meeting in Las VegasI received the news yesterday that my friend, Bill Swan, died after a sudden illness.  I had just seen Bill at the interim BACnet meetings in San Francisco at the beginning of May, 2011.  A week later he was in Germany for a BACnet Plugfest.  Bill became critically ill a week later.

I have always enjoyed being around Bill. We had lots of things in common – photography, BACnet, microcontrollers, politics, family, and religion.  Twice a year we met together at BACnet meetings at the ASHRAE meetings over a weekend, and Bill would always be searching out a local Anglican church to attend, while I sought a Catholic church.  Twice a year we met during the week for BACnet interim meetings, usually in Germantown and Atlanta, and enjoyed the local food. We would compare photography ideas and equipment stories, talk about putting BACnet into tiny devices, and discuss elections and local politics.  We often talked about his family – his wife Kathy, and his daughters and how they were doing in school.

Bill Swan at the 2009 BACnet PlugfestBill was a prolific writer, and wrote the BACnet Bill blog and the Continuing Home blog.  He wrote numerous BACnet tutorials and articles.  He wrote numerous BACnet proposols (at least 89) to create new objects and services, or fix problems in BACnet, and collaborated on many more.  I recall Bill as ever the international collaborator, bringing needs from other countries into our BACnet committee.  I remember when Bill took over the BACnet Chair from Steve Bushby, and how he moved from being a timid leader, to running the BACnet meetings with confidence.

The BACnet committee and working groups are a small bunch of unique individuals, and any single contributor would be missed.  But Bill will be missed not just for his contributions, but for his friendship, creativity, and gentle nature that he brought with him.

BACnet Meetings and Embedded Systems Conference

May 24th, 2011

I had BACnet meetings the week of May 2, 2011, in San Francisco. It also happened that the Embedded Systems Conference was the same week in San Jose. I perused my BACnet meeting schedule, and found that I could attend the Embedded Systems Conference on Thursday morning, which would enable me to see the exhibits, and also hear the keynote from Jeri Ellsworth.

My flight to San Francisco from Birmingham went through Houston.  In Houston, I got to ride the Automated People Mover train between concourses, always a highlight on my trips since I worked on these vehicles at several airport and downtown systems for Westinghouse Transportation Systems from 1992-1997.   The train performed flawlessly – perfect programmed stop, smooth acceleration, and very little jerk.  Much to my delight, San Francisco Airport also had Automated People Mover trains, and they also worked very well to get me to the rental car garage.

Guideway for the Automated People MoverView from Automated People Mover

The BACnet meetings were held at the The Pacific Energy Center in downtown San Francisco.  We discussed the Property_List property for objects, the Zero Config algorithm for MS/TP MAC addressing, and the You-Are service for address and device ID assignment. More importantly, we celebrated Cinqo de Mayo at Chevy’s.

BACnet Meeting at Pacific Energy CenterBACnet Meeting at Pacific Energy CenterCinco de Mayo at Chevy's

On Thursday I arrived at the Embedded Systems Conference a little early, and got to meet Jeri in her motion activated Light Emitting Dress before her talk. After the keynote, I toured the exhibits and picked up several new development kits from microcontroller vendors. The nice surprise was to see my STM32 Challenge contest entry displayed at the STM exhibit. I didn’t win, but I had fun.  The STM32 Design Challenge entry was just a simple port of my BACnet Protocol Stack to the STM32F103 ARM Cortex M3 XL-Density Performance Line microcontroller with 1 MByte of embedded Flash and 96K SRAM. I also created a printed circuit board to attach to the STM32 Discovery Kit so that I could integrate RS-485, LEDs, and a DIP switch.

Jeri Ellsworth keynote presentation at ESCT-Rex at ESCSTM32 Design Challenge Finalists

Cloudshark – Wireshark in the Cloud

December 7th, 2010

Clouds from an AirplaneA post on the Wireshark developers mailing list showed up at the beginning of December, 2010, about the Cloudshark.org website.  Cloudshark is a website that allows you to view Wireshark captures online.  The captures can be in any capture format that Wireshark or T-Shark supports.  The site also allows linking to captures by using “http://cloudshark.org/view?url=” as the URL.  Here are a couple  captures that I have stored at my kargs.net/captures/ site:

BACnet MS/TP

Plugfest with Delta Controls

TimeSync Decode Noon

BACnet Services

Wireshark on Ubuntu not as root

October 21st, 2010

I often need to capture BACnet network traffic using Wireshark while I am running Ubuntu Linux. I’ve always had to run Wireshark as root (usually via gksu or kdesu) in order to capture from any interfaces (i.e. eth0, wlan0).  For awhile, there was an additional Wireshark menu item that included the “run as root” option. However, running an application “as root” has some downsides (like being insecure), and in the latest release of Ubuntu, there is no menu item to run “as root”.   The downside of running as root for me was that the capture files saved by default into /root directory, and saved with root group and owner permissions.

Today, after launching the menu and seeing no interfaces (again), I decided to search the Internet and find a better way, and found two things of note. The first method, which I found posted on Ubuntu Forums, is the manual way of configuring Wireshark to run as a normal user (with admin group privileges) by configuring only dumpcap to have the elevated privileges:

$ sudo apt-get install libcap2-bin wireshark
$ sudo chgrp admin /usr/bin/dumpcap
$ sudo chmod 750 /usr/bin/dumpcap
$ sudo setcap cap_net_raw,cap_net_admin+eip /usr/bin/dumpcap

The second method was outlined in Ubuntu Bug #513903 at Lauchpad and can be done with Ubuntu Lucid and beyond. It creates a new group “wireshark”, configures dumpcap with setcap, and requires the user to manually add themselves to the “wireshark” group (then log out and log back in to activate it).

$ sudo dpkg-reconfigure wireshark-common
$ sudo adduser skarg wireshark
$ exit

Don’t do both methods, as they are slightly different solutions.

BACnet Meeting in Albuquerque

July 17th, 2010

I attended the recent BACnet meetings in Albuquerque, and in the process, learned to spell the city name!  I participated in the Lighting Applications working group, the Objects and Services working group, the BACnet SSPC, and the MS/TP working group.

One of the proposals that started in the MS/TP working group made it through the public review process, and was voted by our committee to be published!

The Journey of a Small BACnet Proposal

In typical bike shed fashion, a small change to the BACnet standard took a very long time to become a standard.  Here is the story.

In November, 2002, I proposed (my 13th proposal) to expand the allowable baud rates for MS/TP to include 57600 bps and 115200 bps.  When reviewing MS/TP in Clause 9, I noticed that the baud rates specified in 9.2.3 are rather limited, and the fastest one doesn’t work well on PC based UARTs (76800 bps).  Since PC based control was becoming more prevalent in 2002, it seemed appropriate to permit fast speeds for PC compatible UARTs.

Someone reviewed the proposal, and asked for some data regarding the maximum length of an RS-485 segment while running at 115,200 bps.  I searched for the best literature I could find on the subject, and ended up with an Application Note from National Instruments which contained a nice graph of Cable Length vs Data Rate for RS-485.

Unfortunately, there was not a table of data along with the graph. I found and quickly learned how to use Scilab, the free platform for numerical computation. I did some linear interpolation (curve fitting) based on points (red dots) from the graph (Scilab Script):

-->// Scilab 3.0
-->// data from the graph
-->// The data is linear, but the graph is logarithmic
-->t = [0.1 0.2 0.4 0.5 0.8 1.0];
-->y = [4000 2000 1000 800 500 400];
-->xyd = [t;y];
-->yi=exp(interpln(log(xyd),log(t)));
-->err = (y-yi)'
err  =
1.0D-12 *
!   0.4547474 !
!   0.2273737 !
!   0.2273737 !
!   0.1136868 !
!   0.1705303 !
!   0.1136868 !
-->tt = [0.1 0.1152 0.2 0.2304 0.4 0.4608 0.5 0.8 1.0];
-->yi=exp(interpln(log(xyd),log(tt)));
-->xyi = [tt ; yi]'
xyi  =
!   0.1       4000.     !
!   0.1152    3472.2222 !
!   0.2       2000.     !
!   0.2304    1736.1111 !
!   0.4      1000.      !
!   0.4608    868.05556 !
!   0.5       800.      !
!   0.8       500.      !
!   1.        400.      !

Since the graph was logarithmic, the points had to be converted.  Scilab took the points (t,y), created a table (xyd), interpolated (yi), checked the error of the curve for each point (err).  Then I added some standard baud rates to the list of points (tt), and did the same interpolation.  The result is the table (xyi) which includes .1152 (baud rate) at 3472.2222 feet.  I de-rated and used 3280 feet (1000 meters) as a safety margin.

I compiled the information into a revised proposal, and submitted the information to the working group in October, 2004.   At the April, 2005 Germantown meeting, the MS/TP working group voted this proposal up to the BACnet SSPC for review and future publication.

The document was discussed again at a subsequent MS/TP working group meeting in 2006, with concern raised over the reduced distance for the higher baud rate.  A consensus vote decided to eliminate 115,200 bps as a possible rate, leaving 57,000.  I revised the proposal to that effect in April, 2006, and it was voted up to the full SSPC BACnet Committee for review and future publication.

In October, 2008, there was a discussion of MS/TP baud rates on BACnet-L mailing list.  Coleman indicated that:

I’d like to get a proposal together that rewords the baud requirements in clause 9 of 135.  We’ve discussed 115200 several times in the MS/TP-WG, but I’m thinking something a little less contentious like making 38400 the default and making 9600, 19200, 57600, 76800, and 115200 optional.

Coleman sent a note to me indicating that he had modified the proposal again, mandating that 38400 be a default baud rate in addition to 9600.  I checked the venerable “BACnet Document Status Summary” which indicated that my proposal was still in MS/TP working group instead of SSPC.  Bummer.  It had been sitting around for years due to some missing communication.

I wrote to Coleman and said that I would prefer to leave my original proposal in the SSPC-135 queue as-is since it is more likely to be adopted sooner than later as it is now 3 years in the queue – and a case can be made that it has been sitting there awhile.  I suggested that another proposal with the additional mandatory baud rates would be better or could be discussed along with my proposal in the SSPC-135 meeting and added prior to a public review vote by SSPC-135.

My proposal finally made it to the floor of the Atlanta BACnet committee meeting in November, 2009, at the very end of the meeting.  After a short discussion, Coleman’s proposal was suggested to replace mine.  As meeting time was running out, David Fisher, convener of the MS/TP working group, “passionately insisted that [Coleman's proposal] will get a due amount of serious discussion time in Orlando. This proposal has been delayed unreasonably for years now.”

Coleman’s proposal was discussed at the next SSPC meeting in Orlando in January, 2010.  After a brief discussion and a minor revision, the proposal was voted to Publication Public Review as Addendum 135-2008ab. The pubic review period lasted from March 26 to May 10, 2010.  It received 2 comments requiring resolution, and 4 supportive comments (which do not require any action to be resolved).

One of the supportive comments suggested that we consider changing MS/TP timing delays when using the 115,200 baud rate in order to provide the fastest possible throughput when using the new speed.  It was decided to consider this request, and some analysis was done.  When we met in Abuquerque, in June, 2010, the analysis was presented as “no significant speed improvements could be made by changing the time delays.”  The BACnet committee voted to approve the public review comment responses, and since there were no substantive changes to the addendum, it is now published as an addendum to the BACnet standard.