Visual Studio Ide for Arduino
https://www.visualmicro.com/forums/YaBB.pl
Other >> Project Guidance >> Program in AVR C, still using the Visual Micro uploading protocols
https://www.visualmicro.com/forums/YaBB.pl?num=1393254696

Message started by TED_996 on Feb 24th, 2014 at 3:11pm

Title: Program in AVR C, still using the Visual Micro uploading protocols
Post by TED_996 on Feb 24th, 2014 at 3:11pm
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?

Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by Visual Micro on Feb 24th, 2014 at 4:04pm
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.

Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by TED_996 on Feb 24th, 2014 at 6:46pm

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.

Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by Visual Micro 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


Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by Visual Micro on Feb 24th, 2014 at 7:08pm
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.

Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by TED_996 on Feb 24th, 2014 at 7:12pm

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.


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.

Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by TED_996 on Feb 24th, 2014 at 8:00pm
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).

Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by Visual Micro on Feb 24th, 2014 at 8:10pm
Sort of cool then  :)

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

Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by TED_996 on Feb 24th, 2014 at 8:32pm
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.

Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by Visual Micro on Feb 24th, 2014 at 8:51pm
Ok thanks, good luck

Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by TED_996 on Feb 25th, 2014 at 4:03am
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")

Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by Visual Micro on Feb 25th, 2014 at 12:41pm
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

Title: Re: Program in AVR C, still using the Visual Micro uploading protocols
Post by TED_996 on Feb 25th, 2014 at 2:14pm
Awesome! Can't wait! Good luck :)

Visual Studio Ide for Arduino » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2019. All Rights Reserved.