Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) Program in AVR C, still using the Visual Micro uploading protocols (Read 14956 times)
TED_996
Newbies
*
Offline


Posts: 7
Joined: Feb 24th, 2014
Program in AVR C, still using the Visual Micro uploading protocols
Feb 24th, 2014 at 3:11pm
Print Post  
Sorry if this is the wrong forum.

So, in order to make the sketches as small and fast as possible, I'm trying to take off the training wheels and program the Arduino (a Sparkfun Pro Micro, 32u4, very similar to the Leonardo) in AVR C. (preferably using Atmel Studio, but whatever), but, at the same time, rely on Visual Micro to do the uploading (reset the Arduino (leonardo-style, at 1200 baud, upload the sketch, etc). Also (if it is needed) I'd like to also have no problems with the bootloader (when uploading without Visual Micro / Arduino IDE, i.e. straight through avrdude something happens to the bootloader and, as a result, the board does no longer have a COM port. When I upload a sketch as I should, that problem is fixed. It might be a quirk with the pro micro.) 

The problem is that Visual Micro includes the arduino headers, links the core, and as a result an empty sketch takes up to 15% of the program space.

So, how can I get rid of the arduino headers, the arduino core, etc and keep just what I need and include manually, while letting Visual Micro do the uploading? As a bonus, I'd like to have the extension .c or .cpp, an not .ino (code completion doesn't work on .ino files, for some reason).

What I've tried:
-make a new (copy) board with the core set to something else (i picked avr, might do nothing). I get some linking error about 'undefined reference to main' in the arduino files.
-remove include statements from the "[project].vsarduino.h". Overwritten by Visual Micro.

Any ideas?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #1 - Feb 24th, 2014 at 4:04pm
Print Post  
Hi,

The vsarduino.h is only used to kick start intellisense and is not included in the compile. If you switch on tools>options>visual micro>compiler>verbose you will see what is actually compiled. Click build>clean solution to ensure you see all files being compiled (this drops the cache)

It sounds like you need to buy an avrisp mkII or jtag ice3 and to use a normal Atmel Studio project without Visual Micro (and Arduino) and without serial upload.

Quote:
Also (if it is needed) I'd like to also have no problems with the bootloader (when uploading without Visual Micro / Arduino IDE, i.e. straight through avrdude something happens to the bootloader and, as a result, the board does no longer have a COM port. When I upload a sketch as I should, that problem is fixed. It might be a quirk with the pro micro.)


I don't understand, if you loose the COM port how does Visual Micro or the Arduino Ide upload? See the verbose compile for -D'usb name'

There are rules for an Arduino code. It is not just a matter of adding your own core unless you have defined it in the correct location with an arduino.h. In Visual Micro this is more configurable than in the Arduino ide but I don't think this is what you need to do.

I hope this helps, please let me know if you want something different.

note: We are in the process of making it easier to use atmel usb/programmer for Arduino upload but I don't think this will help you because you don't want the Arduino stuff.
  
Back to top
WWW  
IP Logged
 
TED_996
Newbies
*
Offline


Posts: 7
Joined: Feb 24th, 2014
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #2 - Feb 24th, 2014 at 6:46pm
Print Post  
Quote:
It sounds like you need to buy an avrisp mkII or jtag ice3 and to use a normal Atmel Studio project without Visual Micro (and Arduino) and without serial upload.


I -can- already program the Pro Micro by running the avrdude command while the Pro Micro is in bootloader mode (for 8 seconds). That mode can be 'called' with the 1200 baud port open/close and with a double-tap on reset. (more info here: https://dlnmh9ip6v2uc.cloudfront.net/datasheets/Dev/Arduino/Boards/32U4Note.pdf). So, basically, I can flash with avrdude while the board is in the bootloader mode. The thing is, visual micro does that MUCH, MUCH better (not overriding the bootloader, opening/closing the port at 1200 baud, letting me pick the port much easily)

Quote:
I don't understand, if you loose the COM port how does Visual Micro or the Arduino Ide upload?


(as far as I know, this is the same with the Leonardo, to which the Pro Micro is very much alike) There are two ports, one for the normal usage and one for the bootloader. The 1200 baud connection is opened on the normal port, the board resets and the program is uploaded on the bootloader port. Again, this works flawlessly with Visual Micro/Arduino IDE. When my port is gone, I manually reset the board (double-tap on the reset button) and I upload a blank sketch with the arduino IDE or Visual Micro. This fixes everything.

Quote:
There are rules for an Arduino code. It is not just a matter of adding your own core unless you have defined it in the correct location with an arduino.h. In Visual Micro this is more configurable than in the Arduino ide but I don't think this is what you need to do.


(I might not understand correctly what you mean) I am already 'set' on port manipulation, I can pull the init() function from the source code, the delay() function (or write my own). I can #define HIGH, LOW, INPUT, whatever. I don't really need access to the main() function, but it would be a bonus. I asked this question because I've seen just how configurable Visual Micro is and I've wondered if there is a way to use a trick (either with a custom board or with something else) to keep the uploading functionality, but not to be forced to use the arduino headers and core (just plain AVR C), because this kind of bloats the code. Basically to use an empty core.

Thanks for the extension, it's very useful even if I can't find a solution to this.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #3 - Feb 24th, 2014 at 7:04pm
Print Post  
Thanks for explaining that it all makes sense now. You can create your own core patched together with whatever Arduino functions you need.

The instructions to do this will vary depending on arduino 1.0.x or arduino 1.5.x

I will try to post a link later today to an example

  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #4 - Feb 24th, 2014 at 7:08pm
Print Post  
ps: idea

Copy the arduino ide, set the location against the Teensy option in Visual Micro then hack the arduino.h to do whatever you need, hack the boards.txt and remove entries you don't want.

Teensy is the same as arduino 1.0.x

Visual Micro plus allows you to create new Ide entries such as My Arduino C Ide but using the built-in Teensy option works the same

The only reason for using Teensy or ano Ide option in Visual Micro is to preserve your normal arduino ide for reference purposes.
« Last Edit: Feb 24th, 2014 at 7:10pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
TED_996
Newbies
*
Offline


Posts: 7
Joined: Feb 24th, 2014
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #5 - Feb 24th, 2014 at 7:12pm
Print Post  
Tim@Visual Micro wrote on Feb 24th, 2014 at 7:04pm:
Thanks for explaining that it all makes sense now. You can create your own core patched together with whatever Arduino functions you need.

The instructions to do this will vary depending on arduino 1.0.x or arduino 1.5.x

I will try to post a link later today to an example



If I recall correctly, I am using arduino 1.0.x.

Tim@Visual Micro wrote on Feb 24th, 2014 at 7:08pm:
Copy the arduino ide, set the location against the Teensy option in Visual Micro then hack the arduino.h to do whatever you need, hack the boards.txt and remove entries you don't want.


Trying right now. Will report back.
  
Back to top
 
IP Logged
 
TED_996
Newbies
*
Offline


Posts: 7
Joined: Feb 24th, 2014
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #6 - Feb 24th, 2014 at 8:00pm
Print Post  
I made it! Well, sort of. I followed the Teensy route and I created my own core. The thing is that I had to include almost 60% of the core to get it working (including USB functionality).
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #7 - Feb 24th, 2014 at 8:10pm
Print Post  
Sort of cool then  Smiley

I just checked the normal way to do it. Not much difference except you get it all in one ide.

1. Copy ArduinoIde\hardware\arduino to ArduinoIde\hardware\MyAvrC
2. Hack all but one board from boards.txt, rename the board to whatever you want to call it such as 

mynano2.name=blah
mynano2.something=blah2

Then re-start Visual Micro or click "tools>visual micro>reload tool chains" and the board should appear using it's own core.

You can also change the boards.txt properties to share some things such as programmers/booloaders with the default arduino core but I think that will just be confusing

Quote:
The thing is that I had to include almost 60% of the core to get it working (including USB functionality


Doesn't surprise me, using a programmer on the ICSP port instead of usb/serial will dump the Arduino bootloader and also avoid the need for usb. I think using an ICE3 will get you native upload and debug in Atmel if you do ever decide to dump the Arduino code. Not sure about the .c stuff in Atmel (have no experience) and the usb is useful so I am not sure of a perfect solution
  
Back to top
WWW  
IP Logged
 
TED_996
Newbies
*
Offline


Posts: 7
Joined: Feb 24th, 2014
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #8 - Feb 24th, 2014 at 8:32pm
Print Post  
About the programmer... yeah, probably not going to happen very soon. But who knows, I guess I'll see.

Thank you very much for the assistance.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #9 - Feb 24th, 2014 at 8:51pm
Print Post  
Ok thanks, good luck
  
Back to top
WWW  
IP Logged
 
TED_996
Newbies
*
Offline


Posts: 7
Joined: Feb 24th, 2014
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #10 - Feb 25th, 2014 at 4:03am
Print Post  
A couple more things.
1) Is it possible to change the extension from .ino to .c/.cpp? There are some extensions (Resharper on Visual Studio and the whole code completion on Atmel Studio) that don't work on unknown extensions.
2) What optimization does Visual Micro tell the compiler to do? If I want to, can I change them? (basically I'd like "optimize for size")
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #11 - Feb 25th, 2014 at 12:41pm
Print Post  
Hi,

Code completion should work in atmel studio. If it is not working for you then please run the installer again and click remove then run again and click install. This should update some registry keys which Atmel somtimes overwrites. The important one is wholetomatoe\AvrExtSSource which has ;.ino concatenated to the list.

As you know you can use cpp/c/h files but you must have one .ino. We are looking at a "pro" option that might drop the need for a .ino. If you look in the build folder you will see that .ino are combined into a .cpp anyway so not such a huge step (tools>options>visual micro>compiler>show build folder)

You can add to the compiler options in the same way that teensy add compiler options. If you upgrade to arduino 1.5 you can change the entire build and link process (see boards.txt and platform.txt in 1.5). The pattern properties in 1.5 platform.txt are of most interest to you.

During the next month or so we will release a new versions which might well have some useful stuff for you
  
Back to top
WWW  
IP Logged
 
TED_996
Newbies
*
Offline


Posts: 7
Joined: Feb 24th, 2014
Re: Program in AVR C, still using the Visual Micro uploading protocols
Reply #12 - Feb 25th, 2014 at 2:14pm
Print Post  
Awesome! Can't wait! Good luck Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint