Skip to content

Compiling g2core on Windows 10 and Atmel Studio 7

hatchethand edited this page Apr 29, 2018 · 71 revisions

This page is for compiling the G2core project on Windows 10 with Atmel Studio 10. Please see Getting Started with G2core for information about hardware and compiling on other platforms.

Setup

📓
At this point we have given up on VMware and switched to Parallels 12 Desktop for Mac. Parallels compiles much faster due to better file system handling and has fewer problems. (For VMware the camel’s back was waking up one morning and finding Windows did an overnight update (I thought I turned that off) which doubled the size of the VM and broke the Z: drive connection. Can’t get it back.)
📓
If you are using Windows inside VMWare, please see the VMWare Setup section of our Troubleshooting page.

32/64 Bits

Go with a 64 bit Windows, AS7, Git setup all the way if you can. Support is gradually disappearing for 32 bit packages, so this project is transitioning to 64 bit only configs. This is not our fault, as the tools for 32 bit setups are starting to go away.

Don’t confuse the bit widths for Windows 10 or the ARMs, the ARMs are still 32 bits and various toolchain elements mentioned below are labeled as 32 bits referring the ARM’s bit width.

Disk Space

Atmel Studio 7 weighs in at a portly 2.01 Gb, so you need this much space on your C: drive (virtual or otherwise). The g2gore project itself downloads the entire tool chain (in g2/Motate/Tools/win32) so it’s also pretty big - currently almost 800Mb. You should have at least 1 Gb free on the drive where the repo is, which might not be `C:`.

Atmel Studio 7 - Download

To compile g2core on Windows with Atmel Studio you will want the Atmel Studio 7.0.1188 (or greater). We recommend a clean machine or VM.

  • Go to Atmel and download the Atmel Studio 7 Installer install package. Either Web or Online versions should work.

    • There may also be USB driver updates that are not in the main file. If so, you might want these as well. You should not need any of the Part Packs or other files.

    • They require you to either register or fill out a "guest" form. Otherwise it’s free.

Install AS7

  • Walk through the entire installation process

    • It should install .NET, Microsoft Studio, Atmel Drivers, Atmel Studio.

      • Install the Smart ARM 32 architecture. You do not need the 32 bit AVR architecture. If you want to also use this package to work on TinyG v8 you will need the AVR8 bit architecture. The 32 bit toolchain is currently required even though the g2core project downloads its complete toolchain.

      • We do not install the Atmel Studio Framework Code or Examples. You do NOT want this, as we don’t use it, and it takes up a lot of space.

    • Fire up AS7 for the first time

      • You do not want the Atmel Solutions Framework (ASF) when asked. You won’t want to update it and you can turn off notifications about it. Do NOT use an ASF project (like the Arduino Due board) if you are playing with g2core or you will have a lot of stuff to back out. The g2core project provides Makefiles and project files for you to use.

      • You will need the USB drivers when asked (Jungo or something like that)

Configure AS7

  • Start AS7 by clicking the g2core.atsln file in the g2 directory. This should load the g2core and Motate projects in AS7. Yes, you trust it, when asked. If for some reason the Motate project does not load it may because you didn’t initialize the Motate directory using git submodule update --init

  • Configuring Atmel Studio 7 There are a few things you need to do make sure of once you have it installed

    • Verify GDB is the selected debugger

      • Bring up the g2core Properties window by right clicking the g2core project symbol in the Solution Explorer window and selecting Properties (at the bottom)

      • Select the Advanced tab

      • Make sure Use GDB is checked, and Override Current GDB Path is not

    • Make sure project dependencies and ordering are correct

      • Right click the Solution 'g2core' (2 projects) icon at the top of the Solution Explorer.

        • Set Startup Project to Single Startup Project: g2core

        • Confirm Motate is unchecked in Project Dependencies (it doesn’t ever compile here). OK.

        • Right click Solution 'g2core' again and confirm or set Project Build Order to be g2core before Motate. OK.

    • From top menu bar select Tools / Options / Text Editor / All Languages / Tabs. Change the default TAB mode from tabs to spaces (especially if you are going to contribute back to the project). Choose the Insert Spaces option. Leave the tab spacing at 4.

    • From top menu bar hit File / Save All to make sure this sticks.

Git for Windows

The project Makefiles rely on the git command, so Git for Windows needs to be installed in your Windows environment even if you use GitHub Desktop or you’re using Windows in a VM and use Git on your host OS. Make a note of which directory Git installs into. This may affect the build process later on.

  • Go to the official Git site and download and install the Git for Windows. Get the right one for your Windows - 64 bit is preferred (version 2.10.0 at the time of this writing). It may automatically DL the Windows 32 bit version. Don’t be fooled if this is not what you want.

    • Option Dialog 1: Choose Use Git from Windows Command Prompt (default, but any should work)

    • Option Dialog 2: Choose option 2, Checkout as-is, Unix style line endings

    • Option Dialog 3: Choose MinTTY (default, but doesn’t matter for our uses)

    • Option Dialog 4: Both boxes checked ON, but turn OFF if windows weirdness (works for us)

    • When it asks you if you want icons on your desktop you might want this to get Git Bash so you can debug the Windows environment (should it come to that).

📓
The Makefiles also rely on the curl command that comes along with Git for Windows. If it weren’t for that chicken-and-egg, then we could curl to get the "portable" zip-install of Git for Windows and you wouldn’t have to do anything.

Cloning the git repository

See Cloning the Repo if you haven’t already.

Compiling and Uploading

📓
These instructions are for the Atmel-ICE debugger. Many of these instructions will work with the Atmel SAM-ICE as well. The J-Link Segger works as well and is faster and cheaper than the Atmel ICE (Student model on Adafruit), but we haven’t documented it yet - so you are on your own - or be a pal and update this page. It’s also possible to upload directly through the USB or serial ports, but there is no real-time debugger in that case.

Loading the Project

  • The g2 project directory is the parent for all of the source files and the Atmel project files. the g2core subdirectory contains the main project and the g2core project file g2core.cppproj, and Motate contains the module and its project file. Generally you shouldn’t need to work in Motate. It’s best to start AS7 by clicking on g2core.atsln in the g2 directory - or a shortcut to it. This should load both projects.

  • If you have changed your git branch you need to run git submodule update to make sure the right commit of Motate is associated with the g2core you have. It’s a good idea to run this before opening the project in any case.

  • Open AS7 by double clicking on g2core.atsln in the parent g2 directory. AS7 should fire up - tell it to trust us. AS7 has a bug so you might get this warning which can be ignored: [warning] Error updating project settings:Object reference not set to an instance of an object

📓
Git is configured to ignore the changes to some of the project’s dependent files so that they don’t cause havoc. This means that to commit changes to those files, they need to specifically be added to the commit by name.
📓
If the g2core project is present but the Motate project is missing in AS7 check out this troubleshooting item: https://github.com/synthetos/g2/wiki/Troubleshooting#problem-the-motate-directory-is-empty-the-motate-project-is-missing

Compiling the Project

To compile the project:

Windows: Choose build and processor

  1. Choose the platform you are building for (for the Due with gShield pinout, choose gShield)

  2. Click either the "Build Project" or "Build Solution" buttons — they are the same in this case. (These can also be found in the Build menu.)

    • This will create a file named g2core.elf and in the bin/$(CONFIG)-$(BOARD)/ directory for the board you are building

    • This will also create a g2core.elf file in the g2core directory (see note below)

    • You will need one of these files to upload to the board. With option 5, below, it will use this file automatically. All other ways of uploading to the board will require you to locate this file manually

    • The first time it compiles the project it will download the entire toolchain and install it in the Motate Tools directory. This can take a while (~200 Mbytes). You will want a good Internet connection.

📓
If your build fails with errors stating that it is unable to find gcc-arm-none-eabi, or similar, you may need to modify the \g2\Motate\MotateProject\motate\Motate.mk file so it points tot he correct location for your Git install. In particular, at line 236, or close to that, you’ll see a comment saying # Here we use some heuristics to find the OS. For your particular build environment, update that PATH to point to the correct directories for your Git installation, and make sure you save the changes. After that, the build will be able to properly pull down and install the tool chain for the rest of the build.
  1. Configure the Device and Atmel-ICE Tool in the g2core project Properties window, which can be found by right clicking the g2core root directory in the Solution Explorer pane.

    • In the Device tab select one of: ATSAM3X8C for a v9 board, or ATSAM3X8E for the Due, or the right M4 or M7 processor for your particular board (gQuadratic and gQuintic use ATSAMS70N19)

    • In the Tool tab select your Atmel-ICE, which must be plugged in for it to appear. If you have more than one plugged in you can identify them by the last 4 digits of the serial number

    • The Interface should be SWD. JTAG doesn’t always work. Max out clock speed to 10 MHz for best operation

    • You can now program and debug the buttons labeled '5' in the picture, as per step 5, below.

  2. (Alternately) Connect, configure and test the Atmel-ICE Tool in the Device Programming window:

    • The Tool should be Atmel-ICE. If you have more than one connected identify by the last 4 digits of the serial number.

    • The Device is one of: ATSAM3X8C for a v9 board, or ATSAM3X8E for the Due, or the right M4 or M7 processor for your particular board (gQuadratic and gQuintic use ATSAMS70N19)

    • The Interface should be SWD. JTAG doesn’t always work. Max out clock speed to 10 MHz for best operation

    • Hit Apply

    • You can hit Read the Device Signature to verify that you are connected. Or just hit the Memories tab

    • Program from the Memories tab. Make sure the file selected is the g2core.elf in the the correct bin/$(CONFIG)-$(BOARD)/ directory. (See Adding and Revising Boards for an explanation of CONFIG and BOARD.) You can also use this option to program any valid binary (particularly useful if you didn’t compile it).

  3. To compile and upload without debugging (left) or with debugging (right) click one of these two buttons. These are also available from the Debug menu.

📓
The build will copy g2core.elf, and g2core.map to the top directory after build only in Atmel Studio. This is because Atmel Studio requires those files to be in that exact location with those exact names in order to consider building successful and to know what file to flash. Be warned that this file will always contain the result of the last profile built if you build several profiles.
📓
We try to eliminate all compiler errors and warnings from the project. However, there is (we believe) a GCC linker bug that will sometimes reports that the base address (BSS) has been moved by 8 or 12 bytes. This can be ignored.

Uploading g2core to a target board (without a Atmel ICE)

To flash g2core (using the g2core.elf file you just made in step 2 above) onto a target board without using a debugger such as the Atmel ICE or Atmel SAM-ICE, please visit the Flashing g2core with Windows page.

Tips and Tricks

This is a collection of random things we’ve found help when using our standard toolchain -→ OSX 10.11 (El Capitan), Parallels VM, Windows 10, Atmel Studio 7.0.1188, Atmel-ICE.

  • A common mistake is to not update the Motate submodule after switching to a new branch or pulling a branch. Whenever you pull from github be sure to run git submodule update from the command line (e.g. OSX Terminal) to make sure the right commit of Motate is associated with the g2core you have. The short-SHA for the Motate commit can be found by going to the github, selecting the branch you are on in the Code tab, and looking for the Motate @ ba0db89 entry in the file listing. The SHA provided should match the git submodule command from the command line.

  • Whenever you pull from github you must CLEAN the g2core project. While running Clean or Rebuild should do this sometimes things get messed up due to Windows permissions. Clean clears out the /bin and /build directories, but we recommend just deleting the /bin and /build directories completely. If your build behaves badly (goes into panic, does completely unexpected things) you should delete these directories and recompile.

  • The Atmel ICE works best when connected as SWD, clock speed maxed out to 10 MHz.

  • When firing up a new instance of AS7 you may get an error trying to connect to the ICE. This may occur when you try to program, or enter Debug. Disconnect / reconnect the ICE - in Parallels: /Devices/External Devices, Atmel-ICE…​ Disconnect it, wait a second, then reconnect it.

  • If g2core project does not load it may be because the g2core.cppproj doesn’t pass the AS7 XML parser - especially after a conflicted merge. A merge conflict can be caused a collision of the Atmel ICE settings in the g2core.cppproj file. In this case open the file manually or with a mergetool and select one or the other Atmel-ICE settings. Either one is OK because you can change to the right one once AS7 is open.

  • If the USB gets thoroughly confused it’s time for a VM and OSX reboot. Happens occasionally.

Troubleshooting Windows Configurations

See the Issues with compiling on Windows section of the Troubleshooting page.

Clone this wiki locally