<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/7715" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2015-09-07T03:53:11+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/7715</id>

		<entry>
		<author><name><![CDATA[swulf]]></name></author>
		<updated>2015-09-07T03:53:11+02:00</updated>

		<published>2015-09-07T03:53:11+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=7715&amp;p=30222#p30222</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=7715&amp;p=30222#p30222"/>
		<title type="html"><![CDATA[Re: Getting V-USB to compile under Atmel Studio 6]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=7715&amp;p=30222#p30222"><![CDATA[
So here is my experience under Atmel Studio 6 (Version: 6.2.1563 - Service Pack 2) and Windows 7 64 bit.<br /><br />'Download and unzip the latest version of the V-USB source code. Take a note of which example you are going to start with, because you need to get to the files in the /firmware folder for that example.'<br /><br /><strong class="text-strong">OK. I'm trying to build PowerSwitch so I get this <a href="https://www.obdev.at/downloads/vusb/PowerSwitch.2012-12-08.zip" class="postlink">here</a>.</strong><br /><br />'Make a new project in Atmel Studio 6 with File / New / Project. Select &quot;GCC C Executable project&quot; and your target processor, and give it a sensible name.'<br /><br /><strong class="text-strong">OK.</strong><br /><br />'Copy and paste the code from the main.c that came with V-USB for your chosen example into the main.c that Atmel Studio creates (it will be called yourpojectname.c and should be open on the screen in front of you).'<br /><br /><strong class="text-strong">OK.</strong><br /><br />'Go to the Project menu. (The name of your project should appear on that menu with Properties after it. If it doesn't, it's because you currently have a file open that is not part of your project.) Select Project / (Name of your project) Properties / Toolchain tab / AVR/GNU C Compiler / Directories / Include path and add the path to where where the firmware/usbdrv folder is for your chosen example.'<br /><br /><strong class="text-strong">So at this point I diverged. I had tried several times keeping stuff in other directories and pointing to it, and it never worked. What I did here was to copy everything from the downloaded ZIP archive ('PowerSwitch.2012-12-08.zip' in my case) into the so-called Atmel project directory 'C:\Users\&lt;Username&gt;\Documents\Atmel Studio\6.2\PSwitch3\PSwitch3' in my case. For PowerSwitch, this ended up containing the following files:<br /><br /><ul><li> Debug {directory}</li><li> PSwitch3.c</li><li> PSwitch3.cproj</li><li> asmcommon.inc</li><li> Changelog.txt</li><li> checksize</li><li> CommercialLicense.txt</li><li> License.txt</li><li> main.c</li><li> main.hex</li><li> Mskefile</li><li> oddebug.c</li><li> oddebug.h</li><li> Readme.txt</li><li> usbconfig.h</li><li> usbconfig-prototype.h</li><li> usbdrv.c</li><li> usbdrv.h</li><li> usbdrvasm.asm</li><li> usbdrvasm.S</li><li> usbdrvasm12.inc</li><li> usbdrvasm15.inc</li><li> usbdrvasm16.inc</li><li> usbdrvasm18-crc.inc</li><li> usbdrvasm20.inc</li><li> usbdrvasm128.inc</li><li> usbdrvasm165.inc</li><li> USB-ID-FAQ.txt</li><li> USB-IDs-for-free.txt</li><li> usbportability.h</li></ul><br />and the directory Debug contains the following:<br /><br /><ul><li> makedep.mk</li><li> Makefile</li><li> usbdrv.d</li><li> usbdrv.o</li><li> PSwitch3.d</li><li> PSwitch3.map</li><li> PSwitch3.o</li></ul></strong><br /><br />'    You will need to do the same for the assembler. So… AVR/GNU Assembler / General / Include paths.<br /><br /><br />    Now you will get errors like &quot;variable 'usbDescriptorDevice' must be const in order to be put into read-only section by means of '__attribute__((progmem))&quot;. So go and add const to the start of every line there is a complaint about. Changes may be necessary in usbdrv.h, usbdrv.c and your main C program.<br /><br /><br />    Copy usbconfig.h from the example project to your own project folder. At some point you will need to go in and check / change this file, but let's at least get things to compile.'<br /><br /><strong class="text-strong">I did not do any of this.</strong><br /><br />'    You will now get errors &quot;undefined reference to `usbMsgPtr'&quot;, and similar. Go to the &quot;solution explorer&quot; pane in the top right of your screen, right-click on the name of your project, then select Add / Existing item. Navigate to usbdrv.c (which will be in the firmware/usbdrv folder for your chosen example) and add it.<br /><br /><br />    While you're there, also add:<br />    usbdrvasm.asm<br />    usbdrvasm.S<br />    usbportability.h<br /><br /><br />    Now you will get a lot more const error messages generated by usbdrv.c so go and fix those.'<br /><br /><strong class="text-strong">Nope. I did add the following files in the Solution Explorer (upper right of the Atmel Studio window):<br /><br /><ul><li> usbdrv.c</li><li> usbdrvasm.asm</li><li> usbdrvasm.S</li><li> usbportability.h</li></ul></strong><br /><br />'Next you get a F_CPU not defined error. This is because normally it is defined in the makefile. So go to Project / Properties / AVR/GNU C Compiler / Symbols / Defined symbols -D and add F_CPU=12000000 or whatever frequency you are using.'<br /><br /><strong class="text-strong"><br />Nope. Now if I hit F7 it will compile with the error 'USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!'. So let's try and fix that by the suggested method:<br /><br />'So back to Project / (Your project name) Properties / Toolchain / Assembler / General / Assembler flags and add -DF_CPU=12000000 because if you don't do this second step, you'll get an error message &quot;USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!&quot;'<br /><br />Now F7 will result in a successful compile:<br /><br />'Build succeeded.<br />========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped =========='<br /></strong><p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=21561">swulf</a> — Mon Sep 07, 2015 3:53 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[winelight]]></name></author>
		<updated>2012-11-27T23:50:44+02:00</updated>

		<published>2012-11-27T23:50:44+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=7715&amp;p=23780#p23780</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=7715&amp;p=23780#p23780"/>
		<title type="html"><![CDATA[Getting V-USB to compile under Atmel Studio 6]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=7715&amp;p=23780#p23780"><![CDATA[
This is what I did to get V-USB to compile on Atmel Studio 6. Credit to the many people who've answered the various questions people have raised before here and in other forums, but I couldn't find all the answers, or all of them in the same place, which is why I made this list.<br /><br />Of course I don't know if this is the best way, or even the right way to go about it, but it gets rid of the errors for me. It seems a shame that you have to define the include paths and the CPU frequency twice: if there's some global way to do it, I can't find it.<br /><br /><ul>Download and unzip the latest version of the V-USB source code. Take a note of which example you are going to start with, because you need to get to the files in the /firmware folder for that example.</ul><br /><ul>Make a new project in Atmel Studio 6 with <strong class="text-strong">File / New / Project</strong>. Select &quot;GCC C Executable project&quot; and your target processor, and give it a sensible name.</ul><br /><ul>Copy and paste the code from the main.c that came with V-USB for your chosen example into the main.c that Atmel Studio creates (it will be called yourpojectname.c and should be open on the screen in front of you).</ul><br /><ul>Go to the Project menu. (The name of your project should appear on that menu with Properties after it. If it doesn't, it's because you currently have a file open that is not part of your project.) Select <strong class="text-strong">Project / (Name of your project) Properties / Toolchain tab / AVR/GNU C Compiler / Directories / Include path</strong> and add the path to where where the firmware/usbdrv folder is for your chosen example.</ul><br /><ul>You will need to do the same for the assembler. So… <strong class="text-strong">AVR/GNU Assembler / General / Include paths</strong>.</ul><br /><ul>Now you will get errors like &quot;variable 'usbDescriptorDevice' must be const in order to be put into read-only section by means of '__attribute__((progmem))&quot;. So go and add <strong class="text-strong">const </strong>to the start of every line there is a complaint about. Changes may be necessary in usbdrv.h, usbdrv.c and your main C program.</ul><br /><ul>Copy <strong class="text-strong">usbconfig.h</strong> from the example project to your own project folder. At some point you will need to go in and check / change this file, but let's at least get things to compile.</ul><br /><ul>You will now get errors &quot;undefined reference to `usbMsgPtr'&quot;, and similar. Go to the &quot;solution explorer&quot; pane in the top right of your screen, right-click on the name of your project, then select <strong class="text-strong">Add / Existing item</strong>. Navigate to usbdrv.c (which will be in the firmware/usbdrv folder for your chosen example) and add it.</ul><br /><ul>While you're there, also add:<br />usbdrvasm.asm<br />usbdrvasm.S<br />usbportability.h</ul><br /><ul>Now you will get a lot more <strong class="text-strong">const </strong>error messages generated by usbdrv.c so go and fix those.</ul><br /><ul>Next you get a F_CPU not defined error. This is because normally it is defined in the makefile. So go to <strong class="text-strong">Project / Properties / AVR/GNU C Compiler / Symbols / Defined symbols -D</strong> and add <strong class="text-strong">F_CPU=12000000</strong> or whatever frequency you are using.</ul><br /><ul>As before you need to do this for assembler too. So back to <strong class="text-strong">Project / (Your project name) Properties / Toolchain / Assembler / General / Assembler flag</strong>s and add <strong class="text-strong">-DF_CPU=12000000</strong> because if you don't do this second step, you'll get an error message &quot;USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!&quot;</ul><br />Bingo.<br /><br />(edit)<br /><br /><strong class="text-strong">Fuses</strong><br />One final note. If you are using Atmel Studio 6 then are you are likely using another utility to program your ATMega and set the fuses. With the default V-USB that you downloaded, this is all done for you by the makefile. So, you have another step to do.<br /><br />Work out the fuse settings (you can probably use the default value you find in the V-USB makefile, but check to be sure) and program this using your ATMega utility (probably avrdude, or a GUI for it).<br /><br />Beware: the fuses are <strong class="text-strong">inverted</strong>.<br /><br />So SPIEN (enable serial programming) is actually set to <strong class="text-strong">0</strong>, not 1, to &quot;program&quot; the fuse and enable serial programming. But if you use an online fuse calculator, or a GUI to set the fuses, they probably invert the logic again: so for SPIEN you check the checkbox to enable programming, which sets the fuse to 0, which because the fuses are inverted actually does enable the serial programming.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=9486">winelight</a> — Tue Nov 27, 2012 11:50 pm</p><hr />
]]></content>
	</entry>
	</feed>
