Skip to content

AVR Arduino RAW development environment (non IDE)

I spent the good part of a day attempting to get a raw AVR cross platform dev environment up and running.  It was a challenge to say the least.  Your best bet is to do the following:

1) read tuxgraphics.org install instructions here the only thing I added was c++ support and dwarf2

2) I used the latest releases of all three primary items (binutils, gcc, avr-libc) and they seem to hook up okay

3) DO use the paths that the tuxgraphics site specifies.

4) DO create a sub directory in the download directories from your Tar for binutils and gcc to config, make and make install

5) DON’t create a sub directory in the download directory for avr-libc.  For some reason the config utility gets confused and the config.log sends you off into lots of red herring directions.  I spent the good part of a day in this spot.

6) The avrdude problems.  Yes, this did not go as listed in texgraphics.  the config command is suppose to discover things you are missing but it does a very poor job of it.  In my case I was missing yacc and flex.  Finding the right yacc (cause there are  more then one) was a bit of a challenge but some web searching found that I needed to install ‘bison’.  I got a bit further but config didn’t help.  Make came back and was missing some tool which with the error  “[lexer.c] Error 1 “after another search on the web I discovered was supplied by ‘flex’  After installing ‘flex’ all was well.

As you can see, it can be a challenge working with the latest releases of AVR tools.

With any luck, you will have an environment ready to test a hello world program and not have burned up a day in the process!

Y to the MAX

Okay, so I have a great rural location (QTH in ham talk) but Internet access is weak. Things will change but not as fast as I like so maybe I should help it along. see rural wimax info here .   I’m “self employed” now and can decide what I spend my time on. Seems like an opportunity. What do you think?

update: I’m going 3g rev a with Verizon.  Picked up a USB dongle and will be getting a data plan.  Have not decided whether to cancel my comcast in Seattle.  I need to see what kind of performance Verizon 3g will have in Seattle and Brooking, OR…..

Day 7: Humming a sweet song home

Bandon in sight and motor humming along.  All is well with the bike for the 400 mile ride north.  I did manage a longwire out the balcony of the Bandon Beach Motel, which, by the way, is in Bandon and is by the beach!  My room faces south with a clear shot to the horizon.  The beach is below, about 75 feet.  I’m on the second floor.  I throw my wire out and string it over a sightseeing parking lot to a 10 foot sign I can climb on.  I have about 120 feet of wire out with a slight down slope.  The wire is at least 15 feet over the parking entrance and easily clears the cars that come through.  QRV again.  California is favored in this setup with some pattern of propagation to the east and west.  I’m able to make 3 contacts before the wind picks up and I must take the antenna down for safety.  Thanks to WA6UIJ, KJ7LB and KG6VPU for the Bandon contacts.

Morning comes fast and I’m off to my coffee and the long ride home.

I’ve done longer treks then 400 miles in a day, however, 400 miles on a bike is not easy.  Unlike a cage vehicle, there is really no way to stretch.  On my bikes, my right hand is glued to the throttle and the best I can hope for is resting my left hand or twisting to the left for a stretch.  I’ve done damage to my neck and back before, on long rides, when my electric heated clothing has failed.  Cold, fixed position on a human body for hundreds of miles at a time is not good.  I have found out the hardway. This trip my electrics are working OK, I had to disable the pants and be careful of drawing down the battery (see first blog entry for this trip) but I was able to keep warm.  I also decided that 100 miles at a time was enough, so I gassed up every 100 miles and got off the bike to do some yoga stretches.  This made a huge difference.  I recommend this approach for anyone riding long distances and not competing in a contest like the Iron Butt Rally!

Seattle is in sight before dark and I manage to hit rush hour traffic heading north through the City on the 99.  Safe  and home, I thank my bike for cooperating and headed for the shower.

So goes my first Winter coast ride from San Francisco to Seattle.

Thanks for reading!

–Paula

Day 6, A dark and rainy night…..

I had no problem getting up early, packing and getting under way. It started raining the night before and was still raining when I got up at 5 O dark 30. Rain gear, bike loaded, and battery charged, I fired up the sv650 and got out of dodge. The 101 is really dark at the wee hours and when it is wet. As I tooled down the road at 50 plus I couldn’t help but think what would happen if a deer or bear were to run across the road. The rain pounded but I was warm and toasty inside my Frog Togs.

Then it happend (no, not a deer or bear). My bike started missing on one of the cylinders. I dropped to a lower gear and revd. It seemed to clear up, only to return a mile later. I’m ten miles north of Trinidad with 95 miles to travel by 9:30 in the morning. One cylinder was still running and I wasn’t about to stop in the middle of no where on a dark and rainy night (dawn had not arrived yet and was still an hour away). So I continued, keeping the revs up and my speed at about 45 MPH. If I could just make it to Klamath. If I could just make it to Cresent City, If I could just make it to Brookings where I will meet my real estate friend. I limp along on 1 cylinder, afraid to stop as I wasn’t sure the bike would start up on a single working cylinder. 10 miles south of Brookings, OR, my destination, the yellow ‘out-of-gas’ indicator starts blinking. I’m getting terrible gas milage as half the gas is getting blown out the tail pipe raw. I’m thinking that my chances of making Brookings before I run out of gas are pretty slim. The yellow light goes solid at 8 miles south of Brookings. No gas is imminent. As I round a sweeping curve, there, just ahead, is a Shell station!

Okay, pull in, shut the bike down, gas up. I dismount and look the bike over. My natural curiosity has me feeling the engine and I notice the front cylinder is cool while the rear one is hot. Well that makes sense. The front one must not be firing. I touch the front spark plug wire and it seems a bit loose. I push on it and it moves deeper onto the spark plug. Could that be it? a loose wire?

Talking, nice talk, to my bike, I press the starter button and to my surprise it starts up, still on one cylinder but it is running. Off to Brookings while I contemplate how the heck I’m going to get all the way to Seattle on one cylinder, well, clearly that was not going to happen.

Brookings is my morning destination. I’m meeting with a real estate agent to look at a possible new QTH up in the mountains east of Brookings. I tell her my tail of whoa and ask if she might have a dry place I could park the bike and take a look at the front cylinder ignition system (plug, wire and plug connector). She sets me up with a garage and after checking out some properties I pull into a nice dry spot out of the weather.

Taking inventory of the tools I brought, I quickly determine that I can get to the plug wire, and plug. This requires pushing the radiator forward by removing a bolt. Good thing its the forward cylinder as the rear would require me to pull the tank and more.

I pull the wire off the plug and look over the plug end of the wire. It is soaking wet! How wet? Think, wire sitting in a puddle. I poke my finger into the well in the valve cover where the plug sits. It’s filled with water. Well, spark plugs don’t work so well when they are emersed in water. Usng a rag, I carefully push a corner of the rag into the well with my finger and pull the rag out. The entire corner I pushed in is soaking wet. I smell it to be sure its water and not gas or antifreeze, Its just water that must have splashed in when the plug wire was loose. Hmmmm, how did that plug wire get loose anyway.

After getting the well dried I pull the plug and clean it up. I borrow a hair dryer and dry everything out and put the plug and wire back together. One last test. Am I getting juice to the the plug? I stick a screwdiver into the end of the spark plug wire, hold it close to the frame and hit the starter. Lots of blue spark!

Put the bike back together and hit the starter. Vroom, both cylinders firing! I thank my agent for her help and head on north to Bandon where I hope to go QRV (and hope the bike is really fixed).

–P

Day 5, Foggy and cold

Last night Dan sped down the hill on the SV650 one last time to visit his friends which left me with time to spend poking around 40 meters. Two more contacts were logged. KB7ZTI, Mark, from Washington, and I scored Hawaii with Martin, KH6MB! All on 5 watts

Late afternoon caffeine keeps me up all night. And so it was Saturday night. By about 5 pst, I got up and tuned about the 40 meter band. I could hear a lonely JA calling CQ. No one was returning his call. Another clear frequency so I gave him an answer and he came right back! Amazing, JA1NUT, Shin, gave me a 549 signal report and a solid copy.

It was nearly time to do my final packing and load up my bike, so I turned the knob one more time and who was calling CQ? Why K1NVY! A quick chat with my friend Fred and then QRT with hopes to go QRV in Trinidad, CA later in the day.

The ride north 300 miles on the 101 was cold and foggy.sv650gate Just soggy enough to make my electric clothing work real hard. I found out how hard when I stopped in Ukia to gas up. I shut down my heating connection, gassed up and hit the starter switch on the bike. Brr Brr, click click click. Not what one wants to hear from ones bike. Fortunately, a gas station patron asked me if I wanted a push to bump start the bike which worked fine. So much for keeping the heated clothing on full blast. I’ll now have to calibrate how much power I can suck out of the alternator before I draw down the battery….

The WX (weather in ham talk) got better as I headed north. There was even some sun as I passed through Eureka which is just south of Trinidad. A few minutes later and I pulled into the Sea Cliffs Hotel. I chose this hotel from the reviews on Google. I was not impressed. We are talking 1960’s vintage and looks as old as it is. The Bates  hotel rings a bell.  The couple that ran the place seemed nice enough but there was something strange about the entire place. One other couple, with a baby, were staying here. I was put in a different room then I had requested because this other family was, well, having a difficult time.

There is no Sea to be seen and not cliffs near this property. Worse, it is in a sort of hole with land sloping up on three sides. No QRV here.

In town I ate t the Eatery. A classic deep fried food place. Not what my stomach had in mind. Needless to say I was not very impressed by Trinidad and disappointed that I couldn’t get on the air.

One saving grace was that my bike could be parked in an open stall that was covered keeping it dry for the early morning get away.

I’m a bit cynical when it comes to odd behavior. And so it was that the husband of the couple  who owned the place asked me what kind of bike I had, then changed the subject to his wife who engaged in conversation. When I turned back towards where my room and bike were, the husband had gone into the stall where my bike was parked and was walking away, glancing in my direction but not asking me about my bike. Odd.

So much for Day 5.

–P

Day 4, trip prep

Topping off the tank, checking the tire pressure, admiring the new chain, wiring and  mounting the radar detector (I’ll be passing through to many small burgs where local revenue depends on poorly marked signage and local patrol waiting), checking the aux electric port for my heated jacket and gloves.  These are some of the day before a trip tasks to ensure a safe, dependable and warm ride!

Dan takes me to Philz in the Misson (24 and Folsum) where an eclectic crowd meets to enjoy the City’s best coffee.  It was good, but I knew I was going to pay for the mid afternoon caffeine.  Getting to sleep tonight will be a challenge.

Last night (Friday night) I went QRV for a couple of hour and chatted with Rich,  W0EPC from Colorado and Ron,K4WEE from Kentucky all on  watts.

I started thinking about why this QRP setup was performing so well.  The antenna is nothing more then a long wire.  A short length (12 feet) slopes up from my desk to a ceiling mount point, then slopes down, at about 40 degrees, from the third floor ceiling to a window on the second floor and is about 27 feet.  Not much of an antenna.  The house sits high on north side of Collingwood hill and three sides slow down and away from the house at a fair steep pitch.  I think this might be the key to good QRP.  That is, finding a location where at least three sides slope away fairly steeply.

This morning, before coffee, a managed a chat with KC9AOJ, Bill,from Illinois.  Ron is number 9 in my QRP motorcycle trip log.

–P

Day 2/3 I noticed it was a full moon!

I’m not particularly spiritual, but things do seem to get a bit exotic during the full moon. I met up with my son Dan on Wednesday and we did a bunch of catching up as he has been living out of his backpack since his Birthday, last July. He definitely got some of my adventure genes.

Wednesday night I managed to connect with N1NVY in Renton, WA for a nice chat on 40 CW. Once again I’m amazed at a long wire that took me 5 minutes to set up and the Elecraft K1 can do when you are way up on a hill!

Thursday Dan and I discovered Bernie’s coffee shop in Noe Valley where the Interenet is free! Dan took off to visit some friends and I took of to take care of some business. We later met with my friend Frances (who lives in San Francisco) and had a late lunch/early dinner at (I’ll update this) and caught up on each others lives. Frances rode us up the hill and Dan took the bike to go and visit some friends for the evening. I went back n the air to see what I could hear. WA0JLY, Denny from Ft Collins, CO filled in another entry in the log.

Friday morning I woke up early and listened around a bit discovering how noisy my supposedly quiet pc power supply was. It turns out that when I have it hooked up to a load (my netbook) and it is, say, charging the battery, well, wide band mush of about 2 s units arrives. Disconnect the netbook and run just the 50ma on the K1 and I get the moving “grrrs’ with wonderful silence in between. I’ll need to work on that part of my setup.

Going down to the kitchen I discover a note from Dan. “bike has dead battery, left on 19th and Dolores”. Ugh. bad thing go through my head like, is it just the battery, is it the regulator, is it the alternator? I wake up Dan and we head down to see if we can connect a charger to his friend’s house and get the battery recharged. ( I’m guessing, hoping, that Dan just put the ignition switch all the way over to aux and killed the battery while parked, Dan is not thinking thats the case). Well, Dan’s friend likes to get up late, really late. We hung out at the Dolores Cafe before I finally realized I was suppose to be up on top of the hill to meet a contractor. Dang, full moon. We finally get into Dan’s friends apartment to hook up the charger and get the bike charging. I give it 5 minutes hoping that will be enough so I can scoot up the hill. No joy. I leave Dan with the bike and hike up the hill (300 feet vert in 1/2 mile). I manage to get to the house just before the contractor was giving up. Dan shows up on the bike about 5 minutes later and all is well with the world once more. Phew.

Getting clear of all that drama, Dan and I grab a burger at Barney’s and go to see Avatar. If you haven’t seen it you must. It has changed the movie landscape.

Enough for this QSO , 73’s (thats best regards in ham talk)

-P

There’s always a day 1!

Okay, so I’m a geek girl.  I’m also an adventurous soul and I decided to ride my sv650 up the coast from San Francisco to Seattle with my new QRP rig (Thats a low power ham radio for those who are not ‘Hams’).  I flew down to SF with check bags as I didn’t think security would appreciate a roll of wire, a metal box, motocycle clothing with wires, well, you get the picture.  Got into my SF place on a hill near twin peaks and went QRV (going on the air in ham talk) at around 1 in the morning of 1/26/2010.

My QRP station in SF

My QRP station in SF

I managed to get a line of site QSO (making a radio contact in ham talk) with Dave, N7FZY and had a nice chat about radios and antenna on CW (morse code in ham talk).  I had a long wire strung accross my uper level flat with a short counter pose.  I was quite impressed that I could get anything out!.

Next morning I got up early, turned the rig on and tuned about 40, 30 and 20 meters (ham bands in ham talk).  I heard OE3AID calling CQ (is anyone listening n ham talk) and no one was getting back to him so I gave him a call.  To my surprise, he came right back with a nice signal report!  I just worked Austria on  watts with a long wire.  Must have something to do with being on top of a hill!

Okay, so I’m not here in SF for ham radio.  I’m meeting my son who has just got back from a trip to Nepal where he did volunteer work for about six months.  Check out his blog here.  More on this later.

So for all you Hams out there, I’ll try to be QRV in the evenings (7:00-we hour) and mornings (7:00am- coffee time)

mprintf: A thread safe printf: mprintf library

So, I decided to take this one step further and build a library that hides the details of the mutex and variadic macro. To use the library you will need to:

  1. Go into your libraries directory and make a new directory called ‘mprintf’
  2. Copy these two files into the new directory; mprintf.h mprintf.cpp
  3. Put the #include <mprintf.h> and #include <cserial.h> into all the sketches or programs that will be using mprintf.
  4. Put the following two statements at the beginning of your setup() function

serial_stdout_init(9600);
mprintf_init();

5. use mprintf the same way you would use printf

example: mprintf(“hello world\n”);

Update: 20100118:  make sure your freeRTOS task has more then the minimum stack.  mprintf will not work properly for some value conversions (like int or decimal or anything that requires addition stack depth).  I increased by 2 X (2 * configMINIMAL_STACK_SIZE) and all is well for a while.  I’m working on getting some kind of high water stack report by task so we can see when things are getting read to blow up!).  Note, tasks use stack for their local variables.  Global variables (not welcome) are safer until a good method of reporting predicted stack usage can be generated from the compiler.  Thoughts? send them to me!

mprintf: a simple thread safe printf for DuinoOS Part A: Getting a thread safe printf to work

There are lots of ways to implement a thread safe printf for DuinOS (or free RTOS). The following is a version that renames printf as mprintf. Like an fprintf function, mprintf has a leading parameter which must be passed with the rest of the printf variables. This implementation exposes the methodology used to make printf thread safe. A future version will incorporate the methodology and hide the implementation details from the user.

There are 3 steps to make mprintf available for use:

  1. Enable MUTEX semaphores in our DuinOS (or freeRTOS)
  2. Create an mprintf variadic macro.
  3. Initialize the MUTEX to be used in your program when calling mprintf

Enabling MUTEX capabilities in your DuinOS.

Mutexs come disabled in the DuinOS. You must find the freeRTOSConfig.h file in your installation. Usually located at

~/arduino-0017/hardware/cores/arduino.DuinOS

directory. Open this file in your favorite text editor and add the following line (if not already there):

#define configUSE_MUTEXES 1

A good place to add this line is after the

#define INCLUDE_vTaskDelay 1

line. Your sketches and programs will no compile with MUTEXES enabled.

Building the variadic macro.

First, be sure to add the following #includes to the top of your sketch/program:

#include <cserial.h>
#include “DuinOS/FreeRTOS.h”
#include “DuinOS/semphr.h”
#include “DuinOS/queue.h”

I’m not going to go into how variadic macros work. It’s safe to say that they do work and they allow us to define a macro that looks like a function which can have a varying number of parameter. This is required because printf support varying numbers of parameters. Place the following code at the beginning of your sketch/program but after your includes:

#define mprintf(xM,…) while (xSemaphoreTake(xM,1000)==pdTRUE) {}\
printf(__VA_ARGS__);\
xSemaphoreGive(xM);\

The back slashes are required and no, they are not comments. They are used to extend the #define as if it were a single line.

Initialize the MUTEX.

The mutex to be used must be global as we will be using mprintf in any of our sketch or program functions. Some where after the #includes at the top of of our sketch/program, place the following line:

xSemaphoreHandle pMutex;

We can use any Mutex name you like. Here I use pMutex.

Next add the following lines at the beginning of your setup() function:

pMutex = xSemaphoreCreateMutex();

if( pMutex != NULL ) {
// The semaphore was created successfully.
printf(“could create pMutex semaphore\n”);
// The semaphore can now be used.
}

Note, I use printf here rather then mprintf. Why? because pMutex, which we will use as the first parameter in mprintf, must be used within one of the tasks in DuinOS. As we have not launched any tasks yet, the scheduler has not started so no mutex checks will be made (bad thing), however, no threads have started so no one else will be calling printf (good thing).

You now can add an mprintf call to one of your tasks or routines called by your tasks (note: you MUST use mprintf from within a task environment or you will get unpredictable results. Add a line that looks like this to one of your t asks:

mprintf(pMutex,”%s\n”,”Hello World”);

If all goes well (you have implemented unthread safe printf and thread safe mprintf) the message will be sent out the hardware serial port.

Good luck and have fun!

Paula