Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
stm32duino (Read 1162 times)
Markk
Junior Member
**
Offline



Posts: 15
stm32duino
Mar 11th, 2019 at 4:50pm
 
Hi

stm32duino uses a clever option to override build options for the core etc. from a sketch.

https://github.com/stm32duino/wiki/wiki/Customize-build-options-using-build_opt....

NOTE: Despite its file extension, the
build_opt.h
file is not a header but a response file containing additional command-line options for the compiler. I guess they had to give it a header file extension for dependency detection.

For my project I add
-DHAL_OPAMP_MODULE_ENABLED
to enable support for the Operational Amplifier inside the STM32L412KB HAL.

This works nicely from the Arduino IDE. However unfortunately it does not work from Visual Micro (within Visual Studio). Instead the following errors (many of those) appear:

cc1.exe*: warning: C:\Users\Markus\Documents\Arduino\My Examples\OpAmp\OpAmp.ino: not a directory
cc1plus.exe*: warning: C:\Users\Markus\Documents\Arduino\My Examples\OpAmp\OpAmp.ino: not a directory


The build then fails because the additional define I added is not used.

stm32duino uses Arduino pre-build hooks as defined here:

https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-speci...

Maybe those are not implemented in Visual Micro?

Thanks for your help and ongoing good work with this fine product!

_Mark
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10310
United Kingdom
Re: stm32duino
Reply #1 - Mar 11th, 2019 at 8:55pm
 
Interesting, I had missed the build_opt.h and will add support for the next release.

In the meantime you can use the "Project Properties>defines" or "extra flags" to set switches or defines.

if you find that your changes to defines are not affecting the cached compiler core or libraries then you can use a local board.txt to override the extra_flags or other compiler property

To see all the arduino compiler properties switch on "vmicro>compiler>show build properties" and also "vmicro>compiler>verbose"
Back to top
« Last Edit: Mar 12th, 2019 at 12:25am by Visual Micro »  
WWW  
IP Logged
 
Markk
Junior Member
**
Offline



Posts: 15
Re: stm32duino
Reply #2 - Mar 12th, 2019 at 10:02am
 
> Interesting, I had missed the build_opt.h and will add support for the next release.

Perfect!

> In the meantime you can use the "Project Properties>defines" or "extra flags" to set switches or defines.

Very good, thanks.

> if you find that your changes to defines are not affecting the cached compiler core or libraries then you can use a local board.txt to override the extra_flags or other compiler property

That's what I actually tried first because it seems to be the "official" and core agnostic solution.

However I couldn't figure out where (i.e. in which directory) to put the boards.local.txt and all my tries were fruitless.

The documentation is a bit terse:
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5-3rd-party-Hardware-speci...

_Mark
Back to top
« Last Edit: Mar 12th, 2019 at 10:02am by Markk »  
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10310
United Kingdom
Re: stm32duino
Reply #3 - Mar 12th, 2019 at 12:50pm
 
The "Add Code" menu on the vMicro menu and the tool bar create a board.txt for you. It's just a board.txt in the project folder.
Back to top
 
WWW  
IP Logged
 
Markk
Junior Member
**
Offline



Posts: 15
Re: stm32duino
Reply #4 - Mar 12th, 2019 at 2:49pm
 
Thanks.

Using your hints I've traced it further.

1. It seems to want to use the current .ino file as an include directory:

Quote:
"C:\Users\Markus\AppData\Local\arduino15\packages\STM32\tools\arm-none-eabi-gcc\
6-2017-q2-update/bin/arm-none-eabi-gcc" -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb "@C:\Users\Markus\AppData\Local\Temp\VMBuilds\OpAmp\STM32_Nucleo_32\Debug/build_
opt.h" -c -Os -flto -Wall -std=gnu11 -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -MMD "-IC:\Users\Markus\Documents\Arduino\My Examples\OpAmp\OpAmp.ino" "-IC:\Users\Markus\AppData\Local\arduino15\packages\STM32\hardware\stm32\1.5.0\c
ores\arduino/avr" ...

cc1.exe*: warning: C:\Users\Markus\Documents\Arduino\My Examples\OpAmp\OpAmp.ino: not a directory


2. How is board.txt in the sketch folder supposed to work? I unsuccessfully tried the following two lines:
Quote:
extra_flags=-DHAL_OPAMP_MODULE_ENABLED
Nucleo_32.menu.pnum.NUCLEO_L412KB.build.extra_flags=-DHAL_OPAMP_MODULE_ENABLED


3."Project Properties" / "Micro general (Project Global)" custom "Defines" only work, after I manually delete the %TEMP%/VMBuilds/ contents. Otherwise the core is not recompiled.

Thanks,
_Mark
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10310
United Kingdom
Re: stm32duino
Reply #5 - Mar 13th, 2019 at 1:10am
 
Hi,

Sorry I didn't read your reports fully. I thought you  were saying that build_opt.h is a special file for arduino builds.

build_opt.h is something that stm32duino have designed and they have made use of standard arduino/gcc syntax

I have tested the nucleao and it built okay for me, the build_opt.h from the project folder was used.

You can see this in the verbose output during each build.

I suspect your initial problem was related to caching. Visual Micro will cache more heavily if "vMicro>Compiler>Shared Cache For Cores" is enabled. Toggle the menu item to clear the cache or switch it off.

When "vMicro>Compiler>Shared Cache For Cores" it is OFF clicking "Build>Clean Solution" will clear the temp build folder causing a clean build. You need to do this after you make changes to build_opt.h.

Does this help?


ToDo: Future builds of visual micro will give single click clear of cores cache when using shared cores.
ToDo: There is an error the first time we build each stm32 nucleo project. The error happens if we do not have a build_opt.h already in the project. The error relates to the stm build hooks creating an empty/dummy build_opt.h which causes the build folder to be created earlier than expect.

Back to top
« Last Edit: Mar 13th, 2019 at 1:13am by Visual Micro »  
WWW  
IP Logged
 
Markk
Junior Member
**
Offline



Posts: 15
Re: stm32duino
Reply #6 - Mar 13th, 2019 at 8:21am
 
Hi

Thanks a lot for the quick replies.

I found the difference to the Arduino IDE.

Arduino IDE issues:
Quote:
cmd /c if not exist "C:\Users\Markus\Documents\Arduino\My Examples\OpAmp/build_opt.h" mkdir "C:\Users\Markus\AppData\Local\Temp\arduino_build_305982\sketch" & type NUL > "C:\Users\Markus\AppData\Local\Temp\arduino_build_305982/sketch/build_opt.h"


Visual Micro add the .ino file as a subdirectory:
Quote:
cmd /c if not exist "C:\Users\Markus\Documents\Arduino\My Examples\OpAmp\OpAmp.ino/build_opt.h" mkdir "C:\Users\Markus\AppData\Local\Temp\VMBuilds\OpAmp\STM32_Nucleo_32\Release" & type NUL > "C:\Users\Markus\AppData\Local\Temp\VMBuilds\OpAmp\STM32_Nucleo_32\Release/build
_opt.h"

which naturally will always copy the empty build_opt.h because the path is wrong. The error message creating the directory shows that too:
Quote:
   
Users\Markus\AppData\Local\Temp\VMBuilds\OpAmp\STM32_Nucleo_32\Release" existiert bereits



Visual Micro somehow treats the OpAmp.ino as a directory. It also still tries to use it as an include directory, as documented earlier:

Quote:
Building project code ...
"C:\Users\Markus\AppData\Local\arduino15\packages\STM32\tools\arm-none-eabi-gcc\
6-2017-q2-update/bin/arm-none-eabi-g++" -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb "@C:\Users\Markus\AppData\Local\Temp\VMBuilds\OpAmp\STM32_Nucleo_32\Release/buil
d_opt.h" -c -Os -flto -Wall -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD "-IC:\Users\Markus\Documents\Arduino\My Examples\OpAmp\OpAmp.ino" ...
cc1plus.exe*: warning: C:\Users\Markus\Documents\Arduino\My Examples\OpAmp\OpAmp.ino: not a directory



I also created a fresh directory and .ino and it is reproducible.

Attached are the files, if you want to try with the NUCLEO L412KB.

Many thanks for your help.
_Mark
Back to top
 

OpAmp.ino (3 KB | 26 )
build_opt.h (0 KB | 19 )
 
IP Logged
 
Markk
Junior Member
**
Offline



Posts: 15
Re: stm32duino
Reply #7 - Mar 13th, 2019 at 8:31am
 
Just for clarification:

The workaround with Visaul Micro Project Global Defines + When "vMicro>Compiler>Shared Cache For Cores" it is OFF clicking "Build>Clean Solution" does work. So this bugfix is not pressing at the moment. 

_Mark
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10310
United Kingdom
Re: stm32duino
Reply #8 - Mar 13th, 2019 at 1:13pm
 
Thanks for the info. The hook uses build.source.path which obviously isn't used by many boards because it was set to the full ino path instead of the containing folder.

If you are using vs2017 or vs2019 there is a fix in the latest release here.

https://www.visualmicro.com/forums/YaBB.pl?num=1552358652


It was good time with the next major release due over the coming days. Please give it a try.

Thanks
Back to top
 
WWW  
IP Logged
 
Markk
Junior Member
**
Offline



Posts: 15
Re: stm32duino
Reply #9 - Mar 13th, 2019 at 1:36pm
 
Hi

I can confirm this resolves the issue fully and I can build using core build overrides in
build_opt.h
. It also works with the very first build.

Many thanks!  Cheesy

The only small detail to remember: It will not detect the dependency from
build_opt.h
one still needs to switch "vMicro>Compiler>Shared Cache For Cores" OFF and then choose "Build>Clean Solution".

_Mark
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10310
United Kingdom
Re: stm32duino
Reply #10 - Mar 13th, 2019 at 1:49pm
 
Thanks very much. Yes I am thinking how to make the clearing of cache more obvious. I think it's an area for great confusion. Ideas welcome.

Maybe we can add to the Build>Clean menu items, "Build>Clean Core Cache" or a radio button on a tool bar, or something

When you switch off "core cache" is does clear the cache. So switching it off and on again also works.
Back to top
« Last Edit: Mar 13th, 2019 at 1:50pm by Visual Micro »  
WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10310
United Kingdom
Re: stm32duino
Reply #11 - Mar 13th, 2019 at 2:23pm
 
Actually, with thought. It's just using a standard gcc property so we will be able to intelligently clear the cache if the file changes. Better.
Back to top
« Last Edit: Mar 13th, 2019 at 2:23pm by Visual Micro »  
WWW  
IP Logged
 
Markk
Junior Member
**
Offline



Posts: 15
Re: stm32duino
Reply #12 - Mar 13th, 2019 at 5:19pm
 
Super cool!

Again great thanks for a very nice product!   Smiley

_Mark
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print