Multiple targets from an AS7 project

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Optiboot (the Arduno UART bootloader) currently supports a couple dozen different target CPUs, using a makefile from the command line:

make atmega1284 UART=1 BAUD=RATE=115200 <more options>

Occasionally I run into people who would like to use Microchip Studio (nee Arduino Studio 7) to modify, build, and load their microcontroller.  I have "faked" AS projects for the ATmega328p, ATmega328pb, and ATmega168pb Xplained Mini boards (three separate projects/solutions), but obviously this does not scale very well.

 

Is there a well-known technique for supporting multiple target CPUs and perhaps multiple program/debug tools from a single project?  Normally a project seems to be pretty tied to a specific CPU/tool, and while you can change them in the project configuration, that's a relatively obscure operation.  I guess that in theory, the CPU type doesn't even need to be "correct", since it's calling an external makefile to do the compile, but ... it does need to be correct for burn/debug operations...

 

(I guess: same question for MPLAB-X)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


I just checked and it seems you can have projects set to different target devices in one solution:

 

and

 

However what remains a little curious is this:

 

 

That remains at "ATmega4808" whichever project I have selected but I think this is simply Visual Studio's concept of "startup project" - that is "the project you will run if you start to debug". In the pictures of the solution explorer "testGCC" is in bold because it is the one that has been "set as startup project" so perhaps one simply ignores the toolbar button.

 

Obviously with multiple projects in the solution each can have their own "Properties" and under "Toolchain" the "Symbols" can be set differently like your "UART=1" "BAUD_RATE=115200" and so on - though these would be passed as -D direct to the compilation rather than as make environment variables.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can have a Solution with multiple projects.

 

e.g. a single set of linked source files with a separate "Properties" for each project.

 

The practical result is that each "Properties" contains the target CPU, include path(s), define(s), ... relevant to a specific "Project build".   The Output files are in each separate project directory.

 

In other words,   it is just a complicated way for the auto-generated Makefile to work.   And consequently fraught with difficulties for the naive user.

 

Whereas a regular Makefile with some clear instructions can cope with the target CPU, include path(s), define(s) in a much easier way.

Most importantly,   you can generate and maintain HEX files for multiple targets all in one go.

 

Of course AS7.0 is designed to make the use of a single set of linked source files as difficult as possible.

Yes,  you can "build Solution" to create the multiple HEX files.    But you probably cease the will to live in the process.

 

Quite honestly,   I suggest that it is just "safer" to put all the "pre-built HEX files" onto GitHub.   And hope that the user selects the correct one.

Much like the Arduino IDE "burn Bootloader" just depends on the user selecting the correct "Board"

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
it seems you can have projects set to different target devices in one solution

indeed

 

clawson wrote:
However ...

and I seem to remember running into a few "howevers" with it frown

 

It's a long time ago, so I forget the details - I think it might have been because the 2 targets required different compilers (AVR8 and AVR32) ... ?

 

david.prentice wrote:
you probably cease the will to live in the process

I think I did ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


There is a "cop out" solution of course...

 

 

So if these Optiboot builders are so keen to work "in AS7" then just give them some effectively "empty" projects in a solution all set to "Use external Makefile". They think they are using Studio and meanwhile you reduce your support nightmare as you are not trying to maintain two different build systems.

 

(if only CMake had support for Studio 7 solutions/projects then everyone could be happy - one set of CMake files and the user would choose to use the "Unix Makefiles" generator or the "M'chip Studio 7" generator then everything could be maintained in a single location - we do this all the time with projects we work on - the same stuff can be built in Windows in Visual Studio or at the command line in Linux and it all centers around a single set of CMakeLists.txt files)

 

Actually I wonder what's involved in adding a generator to CMake? In my Windows version I currently see:

Generators

The following generators are available on this platform (* marks default):
  Visual Studio 16 2019        = Generates Visual Studio 2019 project files.
                                 Use -A option to specify architecture.
* Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
                                 Optional [arch] can be "Win64" or "ARM".
  Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
                                 Optional [arch] can be "Win64" or "ARM".
  Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
                                 Optional [arch] can be "Win64" or "ARM".
  Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
                                 Optional [arch] can be "Win64" or "ARM".
  Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
                                 Optional [arch] can be "Win64" or "IA64".
  Visual Studio 9 2008 [arch]  = Generates Visual Studio 2008 project files.
                                 Optional [arch] can be "Win64" or "IA64".
  Borland Makefiles            = Generates Borland makefiles.
  NMake Makefiles              = Generates NMake makefiles.
  NMake Makefiles JOM          = Generates JOM makefiles.
  MSYS Makefiles               = Generates MSYS makefiles.
  MinGW Makefiles              = Generates a make file for use with
                                 mingw32-make.
  Green Hills MULTI            = Generates Green Hills MULTI files
                                 (experimental, work-in-progress).
  Unix Makefiles               = Generates standard UNIX makefiles.
  Ninja                        = Generates build.ninja files.
  Ninja Multi-Config           = Generates build-<Config>.ninja files.
  Watcom WMake                 = Generates Watcom WMake makefiles.
  CodeBlocks - MinGW Makefiles = Generates CodeBlocks project files.
  CodeBlocks - NMake Makefiles = Generates CodeBlocks project files.
  CodeBlocks - NMake Makefiles JOM
                               = Generates CodeBlocks project files.
  CodeBlocks - Ninja           = Generates CodeBlocks project files.
  CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
  CodeLite - MinGW Makefiles   = Generates CodeLite project files.
  CodeLite - NMake Makefiles   = Generates CodeLite project files.
  CodeLite - Ninja             = Generates CodeLite project files.
  CodeLite - Unix Makefiles    = Generates CodeLite project files.
  Eclipse CDT4 - NMake Makefiles
                               = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - MinGW Makefiles
                               = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
  Kate - MinGW Makefiles       = Generates Kate project files.
  Kate - NMake Makefiles       = Generates Kate project files.
  Kate - Ninja                 = Generates Kate project files.
  Kate - Unix Makefiles        = Generates Kate project files.
  Sublime Text 2 - MinGW Makefiles
                               = Generates Sublime Text 2 project files.
  Sublime Text 2 - NMake Makefiles
                               = Generates Sublime Text 2 project files.
  Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
  Sublime Text 2 - Unix Makefiles
                               = Generates Sublime Text 2 project files.

presumably Studio 7 can't be that dramatically different to "Visual Studio 14 2015" ?

 

If there were a Studio 7 generator in CMake then these Optiboot builders could pick and choose among Eclipse, CodeBlocks, Makefiles or Studio (and any of the others that might "know" AVR).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can mix compilers,  targets, ... in one AS7.0 Solution.

It is just painful to create a new Project Properties for each project.

 

Whereas regular make can just pass a few "make variables" to a master Makefile.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
You can mix compilers,  targets, ... in one AS7.0 Solution.

Yes, it let me do that - but it didn't (quite) work.

 

@westfw: so it's worth giving it a try, as described, but not worth getting too bogged-down if it doesn't (quite) work ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
It is just painful to create a new Project Properties for each project.
I've done this kind of thing in VS2010/VS2017. The project files are just XML so if you need multiple projects with just one small difference I'd maybe prepare just two and then diff their XML. Once you know what has to change to make (a) a differently named project and (b) with the build options you require you can just copy the XML 10..15..many times and edit the differences in each - much quicker than doing the same settings repeatedly through the GUI.

 

As Studio 7 is just VS2015 then .cproj files are very similar XML to .vcxproj files in Visual Studio so the same idea should work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

It is just painful to create a new Project Properties for each project.

I think you can copy & paste within the Project Explorer ?

 

clawson wrote:
The project files are just XML so if you need multiple projects with just one small difference I'd maybe prepare just two and then diff their XML.

I often find that's foiled by tools that don't keep the bits in the XML in the same order - so a simple text diff doesn't work.

 

frown

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A thing I find a glaring omission of very many IDEs (including MS) is that there's no hierarchy of options.

 

eg, if we're having multiple targets, then there will be a load of settings that are common to both, and some that are specific to a particular target.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

A thing I find a glaring omission of very many IDEs (including MS) is that there's no hierarchy of options.

 

eg, if we're having multiple targets, then there will be a load of settings that are common to both, and some that are specific to a particular target.

The exact reason for Visual Studio's "property sheets". Not sure that made it as far as Studio 7 though :-(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Actually I wonder what's involved in adding a generator to CMake?

CMake projects in Visual Studio | Microsoft Docs

[paragraph above 'See Also']

In Visual Studio 2015, Visual Studio users can use a CMake generator to generate MSBuild project files, which the IDE then consumes for IntelliSense, browsing, and compilation.

Sysprogs (VisualGDB) may have taken a different path.

Introducing the new Advanced CMake Project Subsystem | Sysprogs

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1


Thanks all.  This actually was easier than I thought it would be, with everything using external Makefiles, and source code NOT actually added to each "project."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nice ;-) 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That looks like a good night's work.

 

westfw wrote:
like to use Microchip Studio (nee Arduino Studio 7)

Perhaps they should name it back smiley

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As Studio 7 is just VS2015 then .cproj files are very similar XML to .vcxproj files in Visual Studio so the same idea should work.