-
Notifications
You must be signed in to change notification settings - Fork 1
Developer Notes
These are random notes that may be useful for developers.
The best way to understand the code is to read it. It's pretty well commented. Here are some additional notes that explain a few things that are too wordy for the code comments.
Here are some things we learned about using github, mostly the hard way.
This is the easiest way to get set up for compilation. It uses the pre-existing project files for AVRStudio4 or AtmelStudio6 to mamnage the git clone working directory.
NOTE: I still prefer Studio 4 for development and simulation, but TinyG also compiles in Atmel Studio 6.0 and 6.1 to take advantage of the newer C compiler and libraries for major releases. The code generated by 6.x is actually better than 4 - due to newer releases of AVRGCC and the libs, so if you work in 4 it's a good idea to also compile in 6 and go to production using 6. The .hex file for 6 is in the Debug dir, the .hex from 4 is in the default dir.
Run git clone to set up TinyG working directory
git clone [email protected]:synthetos/TinyG.git
You should have a directory with all the source files but none of the Atmel project files. The project files are managed separately in TinyG/Support so they don't cause havoc with git. They are ignored by the .gitignore for this reason.
To use the AVR tools you will need the AVRStudio4 project files or the AtmelStudio6 project files, or both. You can use both - they don't collide with each other. Studio4 uses the "default" sub-directory to manage its files; Studio 6 uses "Debug".
If you are using Studio 4 copy the tinyg.aws file from support into the tinyg working directory (/firmware/tinyg).
If you are using Studio 6.0 copy tinyg_6_0.cproj into the tinyg working directory and rename it to tinyg.cproj. If you are using Studio 6.1 do the same but for tinyg_6_1.cproj
Copy these files from TinyG/support to the working directory
tinyg.aps tinyg.aws
Click on the tinyg.aps file to start studio4
Copy these files from TinyG/support to the working directory
tinyg.atsln tinyg.cproj
Click on the tinyg.atsln file to start studio6
You only need to do this is you are not using the pre-existing project files, as above
The simplest way to import TinyG or some other existing project into Studio6 is to clone the github repository and use the solution and project files found in the /support directory. If for some reason these are not available or don't work (we don't always remember to update them with project changes) or for some reason you just want to generate them yourselves the following instructions should help.
These instructions are for importing an existing project such as tinyg into Atmel Studio6 solution/project in a way that's compatible with how we have organized the directories on github. Studio6 likes to set up virgin projects and is not really set up for importing existing projects; someone at Microsoft or Atmel never really exercised this use case, it seems. So I trip over project import in 6 every single time. There is a menu item called "add existing project" but I think this is only useful for brining in a "project" into a "solution" and we are setting up a new "solution" in this case.
The directory structure we use is:
.../GitRepository/solution/project for example:
.../TinyG/firmware/tinyg
To get this do the following:
-
Create a git repository in the main directory (TinyG).
-
Open studio6 and create a new project. Parameters are:
- TinyG is a "GCC C Executable Project"
- The Name is "tinyg"
- The Location is the path for the git repository
- The Solution name is "firmware". Allow it to create a new solution and to create a directory for the solution
-
Select the processor - TinyG uses an xmega192a3. Kinen slaves usually use mega328p
-
Now move all the .c and .h files into the project directory (e.g. tinyg). If there's a collision with the main.c or PROJECT.c file then replace the project-generated file with the one you are moving in. If there's a collision with the .cproj file do not replace it, instead use the one that's already in the directory (the newer one).
-
Go to the Solution Explorer that should be in a right-hand nav box. Right click the orange project directory icon and select add / existing item. Select all the .c, .h and any other files IN THE MAIN DIRECTORY that are necessary for the compiler / linker. Don't attempt to add sub-directories until step 6. Don't bother to add .txt, .doc, .md, any .cproj or .atsln files, any AVRstudio4 project files, or anything else that you may have under git management but are not actually part of the compile/link process. If there are compilation or linking artifacts this might be a good time to run
make clean
. You may have to go back multiple times to select as the file browser doesn't work the way you think it should - at least not under VMware on OSX. -
Now do this to add the files in project sub-directories. (Aside): If you have an exiting project with sub-directories (like tinyg) there is no straightforward way to add the files to the project and leave the directory structure intact. You can't just click on the directory to add the entire directory. If you try to add a new directory it won't let you because that name is already used. If you add the items as "existing items" then navigate and click them it moves the files into the parent directory. Here's what you must do.
- Either move the sub-directory out of the path or rename it (e.g. xio_ORIG) to get it out of the way.
- Create a new directory off the parent directory with the name you want (e.g. xio).
- Move the files from the original directory into the new directory
- Go back to the nav, click on the newly created directory and select "add existing files". Add the files that are found in the newly populated sub-directory.
- Now try to build it from the Build / Build Solution menu. If it doesn't build it's probably because you left out a file in the solution explorer.
Notes:
(1) It gets worse. If you mess up and do things wrong studio6 will remember your paths in "recents" and fail the next time you try to set something up because things aren't where it thinks they should be. You have to go to the File/Recent Projects and Solutions, try to open the old paths, then remove them when they can't be found (you must have deleted the directories beforehand)
We've seen this with earlier versions. Make sure you are up to (at least) Studio6 build 1996, service pack 2. See the help
tab. Also make sure you rae on the latest firmware for the AVRISP mkii.
There is a way around this: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=105137&start=0
Add the variable as a quickwatch and append ",c" to it. If the var is part of a struct you need the entire reference, e.g. tg.inbuf,c
Then add the quickwatch to the watch. Of course this is impractical if you have a lot of ASCII vars to track
From the Studio6 Help Pages:
While debugging you might want to track a value of a variable or an expression. To do so you can right click at the expression under cursor and select Add a Watch or Quickwatch
To add a QuickWatch expression to the Watch window In the QuickWatch dialog box, click Add Watch.