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] 2  Send TopicPrint
Hot Topic (More than 8 Replies) VM needs to do a "clean" when changing MCU types (Read 24273 times)
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
VM needs to do a "clean" when changing MCU types
May 5th, 2014 at 8:18pm
Print Post  
When changing the target MCU, but using the same source code, VM doesn't delete the already compiled library code, to cause a rebuild.

I do this frequently, where the same source code is compiled for
Teensy 3.0
Teensy 3.1
AVR mega32

If I forget to do a clean manually, it dutifully builds a .hex file that is invalid but will download!

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


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: VM needs to do a "clean" when changing MCU types
Reply #1 - May 6th, 2014 at 7:13pm
Print Post  
Hi,

The compiler is cached using mcu processor type so switching boards will always use it's own cache.

The cache manager should detect a change of lib modified dates and should also detect a change of project defines/constants.

What is changing in the project or libraries that affects the libraries and that should cause a re-build?

Thanks

ps: "Build>Clean Solution" is a short term workaround until we establish what is changing, but you probably already know about that
  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: VM needs to do a "clean" when changing MCU types
Reply #2 - May 7th, 2014 at 3:32am
Print Post  
VM+VS consistently does not clean and recompile library sources when I change CPU types from the list shown above.

Is it simply that the library source and .o dates match? But changing the MCU type means the .o is invalid.

I can't point the finger of blame at VM versus VS as I don't know the internals.
« Last Edit: May 7th, 2014 at 3:34am by stevech »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: VM needs to do a "clean" when changing MCU types
Reply #3 - May 7th, 2014 at 8:44pm
Print Post  
It's a VM thing that is for sure.

Can you please switch on the show build folder option then you will understand what I mean about each build cached per cpu type

You will see that libraries are compiled and .o files stored per cpu/board type. So the question is what has changed (other than the board/mcu) that Vm is not detecting.

Thanks
  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: VM needs to do a "clean" when changing MCU types
Reply #4 - May 8th, 2014 at 4:17am
Print Post  
thanks for working with me on this.
I did enable the show build folders. I did clean on each MCU target and I do see the respective folders get purged. Then as I rebuild for each target, the two MCUs' folders get repopulated with object files. This all looks OK to me.

I have the build config set to build for debug not release. In the debug folder, there is another set of object files with today's date but older times. I see the .hex file there. 
Build-clean does not erase the files in this debug folder.

Here's something maybe noteworthy.
If I hit the F7 key, the objects in the MCU-specific build folder update. Nothing changes in the debug folder.
If I use the rebuild menu option, the files in the debug folder do update. Hitting F5 has the same effect.

Perhaps this means nothing.. since doing a clean and then build does make new object files in the build folder but not the debug folder. But hitting F5 does make new objects in the debug folder.

So I conclude none of this seems to show a problem or cause for the .hex that gets sent to be the  wrong one, which do see happen consistently.



  
Back to top
 
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: VM needs to do a "clean" when changing MCU types
Reply #5 - May 8th, 2014 at 4:20am
Print Post  
Very high in my wants list is to eliminate the need to alter F_CPU in the project properties when using or no longer using the Teensy3 as the target. I always forget to do this, and it is several steps. 
I finally put some #if statements in my code to toss a compiler error saying "wrong clock speed for the target CPU".

I wish this could be automated based on which MCU is the target.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: VM needs to do a "clean" when changing MCU types
Reply #6 - May 8th, 2014 at 4:12pm
Print Post  
Hi,

You might find that creating new configurations (Debug teensyX, Debug TeensyY) for each board then setting the #defines for the (Configuration) instead of the (Project) might be easier. This way you just need to switch the configuration when you switch board.

Another idea is to edit the teensy boards.txt and add your own entries with your own hardware flavours. Then when you switch board you would not have to set any defines at all and visual micro will cache per flavour.

By the way, where are you setting F_CPU? In the project properties I hope?
« Last Edit: May 8th, 2014 at 4:15pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: VM needs to do a "clean" when changing MCU types
Reply #7 - May 8th, 2014 at 4:14pm
Print Post  
Please ignore the files in the /debug folder they are not the "real" build system and are part of a new "under development system" which is not required by you and will cause confusion.

The only import build folder is the one shown by "Show build folder"

Thanks
  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: VM needs to do a "clean" when changing MCU types
Reply #8 - May 9th, 2014 at 2:02am
Print Post  
Tim@Visual Micro wrote on May 8th, 2014 at 4:12pm:
Hi,

You might find that creating new configurations (Debug teensyX, Debug TeensyY) for each board then setting the #defines for the (Configuration) instead of the (Project) might be easier. This way you just need to switch the configuration when you switch board.

Another idea is to edit the teensy boards.txt and add your own entries with your own hardware flavours. Then when you switch board you would not have to set any defines at all and visual micro will cache per flavour.

By the way, where are you setting F_CPU? In the project properties I hope?

I'm setting F_CPU in the project properties. To get to that I have to
1. Get the solution  explorer display up, which I now do routinely. As a newbie way back, it was very difficult to even do this.
2. click on the project. As a newbie back then, the difference between a project and a solution (Microsoft nonsense) was confusing.
3. Hit ALT-ENTER keys, to open the properties. As a newbie, this trick took a lot of time to find. The menus to do this didn't seem tow work correctly.
4. key in the F_CPU and some other standard defines (not mine). 

I now  have a shortcut. When I change to do an AVR build with the same source code, I put an "x" in front of the F_CPU so it is disabled for the AVR build. The AVR build gets F_CPU from somewhere else.


I looked at boards.txt - for AVR and teensy31. For the latter there are lower case f_cpu=nnn entries but I think they apply only to the Arduino IDE windows. 
I don't know what I'd add per your suggestion on adding F_CPU to the boards.txt file.

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


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: VM needs to do a "clean" when changing MCU types
Reply #9 - May 9th, 2014 at 1:20pm
Print Post  
Hi,

You can click the question mark to open project properties quickly.

Quote:
key in the F_CPU and some other standard defines (not mine).


These are only your defines, so remove any that you are not using anymore. Vm doesn't expect any except for what your hardware expects.

Quote:
I put an "x" in front of the F_CPU so it is disabled for the AVR build


Use the "defines - configuration" instead of "defines - project". create your own configuration names using the drop down list on the tool bar. Then you save your defines for a named configuration. This means that when you switch board you only need to select a different configuration from the drop down list and will not need to change defines or open project properties.
  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: VM needs to do a "clean" when changing MCU types
Reply #10 - May 9th, 2014 at 4:29pm
Print Post  
I no longer need to do the "clean" when switching target board types. If I follow the same procedure each time. There is some situation with mistakes I have to avoid though, such as mistakenly directing the build to download to the wrong board type. But I'm OK if I follow the procedure.

Regarding using different build configs for using the same source code with different targets. Would you mind being a bit more detailed on this? I searched the menus but don't the the concept nor the menu choices/steps so I can move the defines out of the project properties. 

I don't "get it" with this instruction:
Quote:
"defines - configuration" instead of "defines - project".


Thanks
Steve
« Last Edit: May 9th, 2014 at 4:31pm by stevech »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: VM needs to do a "clean" when changing MCU types
Reply #11 - May 9th, 2014 at 4:35pm
Print Post  
Hi,

On the tool bar you will see the configurations drop down Release/Debug. You can add to this list by dropping it down and clicking the edit/configure option. Add your own names to this list such as teensyXYZ1, teensyXYZ2

Then when you select teensyXYZ2 set the "Defines - Configuration" in the project properties (instead of "Defines - Project")

Thus when selecting teensyXYZ1 you will get a build with the defines specified for teensyXYZ1

Does this make sense, it's almost the same as what you have done except using the Configuration specific options instead (still set in project properties but are specific to the selected configuration)
  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: VM needs to do a "clean" when changing MCU types
Reply #12 - May 9th, 2014 at 4:47pm
Print Post  
I'll give it a try.
Can't the F_CPU and so on that are board specific happen automatically for teensy 2 and teensy 3.x boards since all of these are among the choices in the drop-down list to the right of the Arudino version choice?
« Last Edit: May 9th, 2014 at 4:49pm by stevech »  
Back to top
 
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: VM needs to do a "clean" when changing MCU types
Reply #13 - May 9th, 2014 at 5:18pm
Print Post  
OK, with your instruction above, I fumbled a bit and got two new project configurations done.. one for Teensy 3.1 and one for mega32_16MHz. 

I'm still confused as to why the Teensy 3 F_CPU doesn't happen automatically due to choosing it from the board type drop-down in the toolbar where the Arduino version is chosen.  If this worked, there'd be no need for special new project configuration names and special project defines- as those are in the boards.txt, right?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: VM needs to do a "clean" when changing MCU types
Reply #14 - May 10th, 2014 at 1:17pm
Print Post  
Yes as I said you earlier can edit the Teensy boards.txt and add your own custom hardware/boards by copying and renaming existing entry.

Or you can just hack the existing teensy3 entry by adding F_CPU to a fixed value ...

If you make changes to boards.txt then click "Tools>Visual Micro>reload Tool chains" or re-start the Ide


Boards.txt Info

The boards.txt format allows for multiple .option[n] entries like this one

Code
Select All
teensy3.build.option1=-mthumb
teensy3.build.option2=-nostdlib
teensy3.build.option3=-D__MK20DX128__
 



You can probably just add the F_CPU= to a new option. You need to increment the option[n] (option1,option2,option3) so that it is the next highest of whatever already if defined

Code
Select All
teensy3.build.option1=-mthumb
teensy3.build.option2=-nostdlib
teensy3.build.option3=-D__MK20DX128__
teensy3.build.option4=F_CPU=1000000000000000000000L :) 



The boards.txt is under teensyIDE/hardware/Teensy

This is the existing teensy3 entry ...

Code
Select All
teensy3.name=Teensy 3.0
teensy3.upload.protocol=halfkay
teensy3.upload.maximum_size=131072
teensy3.upload.maximum_ram_size=16384
teensy3.upload.speed=12000000
teensy3.upload.disable_flushing=true
teensy3.bootloader.path=undefined
teensy3.serial.restart_cmd=true
teensy3.serial.safe_baud_rates_only=true
teensy3.upload.avrdude_wrapper=teensy_reboot
teensy3.build.mcu=mk20dx128
teensy3.build.cpu=cortex-m4
teensy3.build.option1=-mthumb
teensy3.build.option2=-nostdlib
teensy3.build.option3=-D__MK20DX128__
teensy3.build.cppoption1=-fno-rtti
teensy3.build.linkoption1=-mthumb
teensy3.build.additionalobject1=-larm_cortexM4l_math
teensy3.build.linkscript=mk20dx128.ld
teensy3.build.architecture=arm-none-eabi
teensy3.build.command.gcc=arm-none-eabi-gcc
teensy3.build.command.g++=arm-none-eabi-g++
teensy3.build.command.ar=arm-none-eabi-ar
teensy3.build.command.objcopy=arm-none-eabi-objcopy
teensy3.build.command.objdump=arm-none-eabi-objdump
teensy3.build.command.size=arm-none-eabi-size
teensy3.build.core=teensy3
teensy3.build.noarchive=true
teensy3.build.elide_constructors=true
teensy3.build.gnu0x=true
teensy3.build.dependency=true
teensy3.build.time_t=true
#teensy3.build.linker_relaxation=true
teensy3.build.post_compile_script=teensy_post_compile
#teensy3.build.serial_number=true 



This is how to copy and rename an existing entry. Note the additional "option4" and new name+description...

Code
Select All
myteensy3_96.name=Teensy 3.0 at 96mhz
myteensy3_96.upload.protocol=halfkay
myteensy3_96.upload.maximum_size=131072
myteensy3_96.upload.maximum_ram_size=16384
myteensy3_96.upload.speed=12000000
myteensy3_96.upload.disable_flushing=true
myteensy3_96.bootloader.path=undefined
myteensy3_96.serial.restart_cmd=true
myteensy3_96.serial.safe_baud_rates_only=true
myteensy3_96.upload.avrdude_wrapper=teensy_reboot
myteensy3_96.build.mcu=mk20dx128
myteensy3_96.build.cpu=cortex-m4
myteensy3_96.build.option1=-mthumb
myteensy3_96.build.option2=-nostdlib
myteensy3_96.build.option3=-D__MK20DX128__
myteensy3_96.build.option4=F_CPU=96000000L
myteensy3_96.build.cppoption1=-fno-rtti
myteensy3_96.build.linkoption1=-mthumb
myteensy3_96.build.additionalobject1=-larm_cortexM4l_math
myteensy3_96.build.linkscript=mk20dx128.ld
myteensy3_96.build.architecture=arm-none-eabi
myteensy3_96.build.command.gcc=arm-none-eabi-gcc
myteensy3_96.build.command.g++=arm-none-eabi-g++
myteensy3_96.build.command.ar=arm-none-eabi-ar
myteensy3_96.build.command.objcopy=arm-none-eabi-objcopy
myteensy3_96.build.command.objdump=arm-none-eabi-objdump
myteensy3_96.build.command.size=arm-none-eabi-size
myteensy3_96.build.core=teensy3
myteensy3_96.build.noarchive=true
myteensy3_96.build.elide_constructors=true
myteensy3_96.build.gnu0x=true
myteensy3_96.build.dependency=true
myteensy3_96.build.time_t=true
#myteensy3_96.build.linker_relaxation=true
myteensy3_96.build.post_compile_script=teensy_post_compile
#myteensy3_96.build.serial_number=true 



NB: THE SPEED MIGHT BE WRONG IN OPTION4, HAS NOT BEEN VALIDATED
« Last Edit: May 10th, 2014 at 1:24pm by Tim@Visual Micro »  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: VM needs to do a "clean" when changing MCU types
Reply #15 - May 10th, 2014 at 9:13pm
Print Post  
thanks. From your earlier comment, I had looked at adding to boards.txt. But I have to find where its structure and usage is documented, if anywhere. With your new comments, perhaps I can figure it out.

With your latest help, I improved switching board types but using the same source and solution/project, is now much faster.. three selections and recompile. 

Off now to try to discern boards.txt  syntax.

---
First thing I see in the current boards.txt for Teensy is that for Teensy3.1 board, there exists
teensy31.build.option4=-DTEENSYDUINO=118

I assume I cannot just add a new option5:
teensy31.build.option5=-DF_CPU=96000000
« Last Edit: May 10th, 2014 at 9:18pm by stevech »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: VM needs to do a "clean" when changing MCU types
Reply #16 - May 10th, 2014 at 9:41pm
Print Post  
Yes sorry that was not clear. An unlimited number of option[n] are supported

So option5 is ok
« Last Edit: May 10th, 2014 at 9:41pm by Tim@Visual Micro »  
Back to top
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: VM needs to do a "clean" when changing MCU types
Reply #17 - May 10th, 2014 at 10:57pm
Print Post  
Not sure if the -D is needed.
Experimenting...
  
Back to top
 
IP Logged
 
stevech
Member
***
Offline


Posts: 147
Location: So. Calif. US
Joined: Jun 16th, 2013
Re: VM needs to do a "clean" when changing MCU types
Reply #18 - May 12th, 2014 at 12:43am
Print Post  
Success! Using VisualMicro/VisualStudio for both AVR and Teensy 3 targets using same source code for both, a quick change to the boards.txt file allows just changing the target MCU to do a build. No longer do I have to setup a custom project or other special things. Just pick the target and COM port and compile/download. As it should be!

See post #5 at
http://forum.pjrc.com/threads/25757-Q-on-altering-boards-txt

How the boards.txt file is really used in Arduino is a great mystery.
« Last Edit: May 12th, 2014 at 12:43am by stevech »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: VM needs to do a "clean" when changing MCU types
Reply #19 - May 12th, 2014 at 11:37am
Print Post  
Excellent time prevents me from explaining these things so it is great that you have run with this.

Yes Arduino 1.0.x, Teensy and Arduino 1.5.x have their own boards.txt formats. Fortunately they don't clash so Visual Micro allows them all to be used for any board. It's easier that way!

Thanks again
  
Back to top
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint