{"id":960,"date":"2020-11-07T21:57:51","date_gmt":"2020-11-07T20:57:51","guid":{"rendered":"https:\/\/next-hack.com\/?p=960"},"modified":"2020-11-08T18:43:29","modified_gmt":"2020-11-08T17:43:29","slug":"setting-up-atmel-studio-for-usvc","status":"publish","type":"post","link":"https:\/\/next-hack.com\/index.php\/2020\/11\/07\/setting-up-atmel-studio-for-usvc\/","title":{"rendered":"Setting up Atmel Studio for uSVC"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\"><strong>The first steps\u2026<\/strong><\/h3>\n\n\n\n<p>Instead of discussing and explaining a lot of functions, our opinion is that starting with a step-by-step example is the best way to get into uSVC programming. In the last news, <a href=\"https:\/\/github.com\/next-hack\/uSVC\/tree\/master\/software\/uSVC_Template_Project\" target=\"_blank\" rel=\"noreferrer noopener\">we provided you with a template project<\/a>, which already has the kernel library and essential files, as well as the compiler settings and linker script. In this way, you don\u2019t have to do all the tedious settings, each time, from scratch. The experienced developers are also encouraged to analyze the project to already understand how it works (beginners: we will explain it later!), and the different debug and release settings, with particular emphasis on the linker script.<\/p>\n\n\n\n<p>However, before we start coding, we need to setup everything, and in particular our main development tool for uSVC: Atmel Studio 7.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Installing uChip Drivers<\/strong><\/h3>\n\n\n\n<p>If you use Windows 10, no drivers are required.<\/p>\n\n\n\n<p>Otherwise:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li>Download the latest uChip package from here <a href=\"https:\/\/github.com\/ITACAInnovation\/uChip\">https:\/\/github.com\/ITACAInnovation\/uChip<\/a><\/li><li>Unzip the file somewhere.<\/li><li>In the drivers\/ subfolder find and execute uchip_driver_installer.exe<\/li><\/ol>\n\n\n\n<p>Please note, that some antivirus might recognize uchip_driver_installer.exe as a virus, due to their too much sensitive heuristic configuration. This is of course a false positive!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Setting up Atmel Studio<\/strong><\/h3>\n\n\n\n<p>After you download and install Atmel Studio from Microchip\u2019s website, you should download and install BOSSA 1.91 or later from here: <a href=\"https:\/\/github.com\/shumatech\/BOSSA\/releases\">https:\/\/github.com\/shumatech\/BOSSA\/releases<\/a> (e.g. <a href=\"https:\/\/github.com\/shumatech\/BOSSA\/releases\/download\/1.9.1\/bossa-x86-1.9.1.msi\">https:\/\/github.com\/shumatech\/BOSSA\/releases\/download\/1.9.1\/bossa-x86-1.9.1.msi<\/a>). After installation, you should integrate it for uSVC programming. Here is how to do it:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li>Find the directory of where \u201cBossac.exe\u201d has been installed. If you have installed the x86 version (32-bit version), then bossac.exe should be (by default) in \u201cC:\\Program Files (x86)\\BOSSA\\bossac.exe\u201d. Instead if the x64 version (64-bit version) has been installed, then BOSSAc will be in \u201cC:\\Program Files\\BOSSA\\bossac.exe\u201d. Note this directory down.<\/li><li>Open Atmel Studio, go to menu&nbsp; \u201cTools\u201d and select \u201cExternal Tools\u201d. A window like that one below should appear:<\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"457\" height=\"454\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/11\/externaltools.png\" alt=\"\" class=\"wp-image-962\"\/><\/figure><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\" id=\"block-0fb8a10e-d332-4d35-8b40-7bb3014e242a\"><li>Click on Add. On \u201cTitle\u201d choose something meaningful. For instance \u201cuSVC Debug Upload\u201d.<\/li><li>On Command, put the directory on which you found bossac.exe. In our case \u201cC:\\Program Files (x86)\\BOSSA\\bossac.exe\u201d.<\/li><li>On Arguments, put:<\/li><\/ol>\n\n\n\n<p><code>-d -i -e -w&nbsp; -o 0x2000 -R \"$(ProjectDir)\\Debug\\$(TargetName).bin\"<\/code><\/p>\n\n\n\n<p><strong>Warning! It is extremely important to specify <code>\u2013o 0x2000<\/code>, otherwise you might corrupt the bootloader!<\/strong><\/p>\n\n\n\n<p>The window should now look like this one:<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"457\" height=\"454\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/11\/externalToolsAdd-1.png\" alt=\"\" class=\"wp-image-969\"\/><\/figure><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"6\"><li>Finally, press &#8220;OK&#8221;.<\/li><\/ol>\n\n\n\n<p>A new entry, named \u201cUSVC Debug UPLOAD\u201d should appear on the menu \u201cTools\u201d. This entry will be used to test the games. What about creating game packages to be put in the SD? Well, this is for another tutorial!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"upload-debug\"><strong>Uploading games in debug mode to uSVC<\/strong><\/h3>\n\n\n\n<p>Throughout the next tutorials, we will ask you several times to \u201cupload the game to uSVC in debug mode\u201d. Here is how to do this.<\/p>\n\n\n\n<p>In uSVC, games are typically loaded from the SD card. This would require you to create a game package (as we will discuss in a future tutorial) and put them in the SD, which is a rather long sequence of operations.<\/p>\n\n\n\n<p>However, if you are just programming your own game, a much faster way to test your code is to upload directly the game to uChip. Warning: this will overwrite the uSVC game loader! You can restore it later by opening the uSVC_Game_Loader project and using the same upload procedure.<\/p>\n\n\n\n<p>To upload the game in debug mode:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Make sure you are using the debug mode configuration. To make sure that the active configuration is \u201cdebug\u201d you should see \u201cDebug\u201d like the figure below.<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"234\" height=\"100\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/11\/debugmode.png\" alt=\"\" class=\"wp-image-964\"\/><\/figure><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Instead, if in the same position you see \u201cRelease\u201d, click on the little black arrow on the right, and select \u201cDebug\u201d&nbsp; (you can also set this by going to the \u201cConfiguration Manager\u201d in the \u201cBuild\u201d menu, and select \u201cDebug\u201d under \u201cActive solution configuration\u201d).<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Build the project by pressing F7, and make sure that there are no errors.<\/li><li>connect uChip to a USB port of your PC.<\/li><li>double tap on the reset button of uChip (so that it will enter its bootloader). After that, the built-in uChip LED should blink with a pulsating pattern.<\/li><li>Select Tools and then \u201cUSVC Debug UPLOAD\u201d (or the entry name you previously created in \u201cSetting up Atmel Studio\u201d). After some while your project is uploaded!<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Setting up a project<\/strong><\/h3>\n\n\n\n<p>Before actually doing anything, you must create an Atmel Studio Project. We created an empty template project, which includes the uSVC kernel library, the uSVC configuration header, and the settings to run directly your game on uSVC (when you upload the game using the external tool you have configured in the previous step), or through the game loader.<\/p>\n\n\n\n<p>To use the project, you must create an Atmel Studio Solution, and add the project to that solution. You can rename the name later in Atmel Studio. To create an Atmel Studio Solution:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li>From menu \u201cFile\u201d choose New -&gt; Project, and from there select \u201cAtmelStudio Solution\u201d on the left, and on the right, make sure that \u201cBlank Solution\u201d has been chosen.<\/li><li>Under Name, we wrote \u201cMySolution\u201d. Of course, you can choose the name you want.<\/li><li>Under location, choose where the directory having the same name of the solution (in our case \u201cMySolution\u201d) should be created. For instance we have chosen below&nbsp; \u201cD:\\MyDirectory\u201d.<br>With these settings, the window will appear like this:<\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"446\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/11\/newProject.png\" alt=\"\" class=\"wp-image-961\"\/><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\"><li>By pressing ok, Atmel Studio will create in \u201cD:\\MyDirectory\u201d a new directory, named \u201cMySolution\u201d, and there you will find a file named \u201cMySolution.atsln\u201d.<\/li><li>Download the uSVC repository from here: <a href=\"https:\/\/github.com\/next-hack\/uSVC\/archive\/master.zip\">https:\/\/github.com\/next-hack\/uSVC\/archive\/master.zip<\/a>.<\/li><li>&nbsp;Extract somewhere the zip archive.<\/li><li>In the directory where you extracted the archive, go in the \u201csoftware\u201d folder: you should see a \u201cuSVC_Template_Project\u201d folder.<\/li><li>Copy the \u201cuSVC_Template_Project\u201d directory where \u201cMySolution.atsln\u201d is located (see point 4). You can safely rename the directory \u201cuSVC_Template_Project\u201d to what you want, e.g. \u201cMyFirstTutorial\u201d. In the new directory, you\u2019ll also find \u201cuSVC_Template_Project.cproj\u201d. This file can be safely renamed inside the Atmel Studio, see next steps.<\/li><li>From the solution explorer on the right, right-click on \u201cSolution: MySolution\u201d, and on the pop-up menu choose \u201cAdd-&gt;Existing Project\u2026\u201d.<\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"356\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/11\/addProject.png\" alt=\"\" class=\"wp-image-965\"\/><\/figure><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ol class=\"wp-block-list\" start=\"10\"><li>Navigate through the \u201cuSVC_Template_Project.cproj\u201d, which, if you followed the same configurations, should be in D:\\MyDirectory\\MySolution\\MyFirstTutorial\\ uSVC_Template_Project.cproj\u201d.<\/li><li>The solution explorer should now be populated with various items.<\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"219\" height=\"473\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/11\/projectAdded.png\" alt=\"\" class=\"wp-image-966\"\/><\/figure><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\" start=\"11\"><li>To safely change the project name, find \u201cuSVC_Template_Project\u201d (under Solution: \u2018MySolution\u2019 in the \u201cSolution Explorer\u201d window), right click on it, and click on rename (or press F2). You can now enter a new name, for instance, \u201cMyFirstProject\u201d.<\/li><\/ol>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"219\" height=\"211\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/11\/projectRenamed.png\" alt=\"\" class=\"wp-image-967\"\/><\/figure><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><strong>Note! <\/strong>Actually an Atmel Studio Solution is just a container of projects. You can add many projects (which also do not have to reside in the same solution directory!) to a single solution. However, we prefer to keep everything separated, therefore we always create a new solution for each new project. The choice is yours!<\/p>\n\n\n\n<p>Each uSVC project must include the following files:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li>The usvc_kernel directory, with all the kernel files.<\/li><li>The main.c file, where the main function resides.<\/li><li>The main.h file, where you can include all the file headers you are going to use in your project. This allows you to include just \u201cmain.h\u201d instead of having to include multiple headers.<\/li><li>The kernel configuration file, usvc_config.h<\/li><\/ol>\n\n\n\n<p>In the following article we will start our first tutorial: drawing tiles!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The first steps\u2026 Instead of discussing and explaining a lot of functions, our opinion is that starting with a step-by-step example is the best way to get into uSVC programming. In the last news, we provided you with a template&#8230; <a class=\"read-more-button\" href=\"https:\/\/next-hack.com\/index.php\/2020\/11\/07\/setting-up-atmel-studio-for-usvc\/\">(READ MORE)<\/a><\/p>\n","protected":false},"author":2,"featured_media":966,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[32,27],"tags":[],"class_list":["post-960","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-all-projects","category-usvc"],"_links":{"self":[{"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/posts\/960"}],"collection":[{"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/comments?post=960"}],"version-history":[{"count":4,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/posts\/960\/revisions"}],"predecessor-version":[{"id":991,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/posts\/960\/revisions\/991"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/media\/966"}],"wp:attachment":[{"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/media?parent=960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/categories?post=960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/tags?post=960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}