Project 7: Embedded Programming

This week was also pretty easy. I worked on one of the linux computers in the Arch lab to do all of my work. The first step was downloading all of the files into a folder on the desktop. Note that you need the make file, the program and the file to complete the tool chain (not to mention avrdude, which is called by the make file.

Files needed in the same directory

I used the AVR in the lab rather than my own programmer because I didn’t want to have to troubleshoot two boards at once. There was a group of us on Monday who were all trying to program our boards, we initially had an issue with getting an RC=-1 error. There were five of us who all had the same error in succession. We puzzled around a bit trying to figure out what was wrong and realized that the issue was coming from the fact that we were powering the board with a laptop on battery power and we were programming the board from a desktop. The laptop had a floating ground and the voltage for the two ground pins were out of sync enough that it threw the error in the programming step. So, word to the wise, make sure that you’re operating with the same ground for both connections on the board.

I did not quite understand the process path when Neil originally explained it. I thought that avrdude was the primary interface tool that we were going to be using to program to board (i.e. we would be using the avrdude commands to interact with the board). This was incorrect. In reality, the two steps (flashing fuses and then programming) require multiple commands from avrdude. This is the purpose of the make file. The make file includes multiple calls to avrdude to perform all the steps required without having to think too much about it. So, you are actually calling the make file to compile the C, flash the fuses, and program the board. I imagine doing all of this from scratch would be time consuming and prone to errors, so the make file is your friend.

I programed my board first with the plain hello-world echo program and tested to see if it worked.


Once that was successful, I wanted to modify the C to reverse the output. So if you typed helloworld the last line of output would be dlrowolleh. I know nothing about C and I didn’t want to modify the program too much, but I identified a loop that I thought could be reversed.

The loop that I reversed

Some notes on implementation. If you modify the C file you’re using you also need to modify the make file, both the name and the global variables at the top.

The modification worked to some extent. The characters did not show up until I hit the char limit on the length of the string. I am sure that has something to do with function definitions, but I did not want to start messing with that for fear of hacking my way into an unworkable program. I am content to know that I got the board to do something other than what it was designed to do.

Success! (kinda)