Modifying the build process

Hi Guys,

Just wondering if there is a way to fine tune the build process in Arduino Studio (1.8.16) when hitting the Sketch > Verify/Compile button?

The problem is that I have an assembly file (.S) in my project, but when you go to compile, it gets renamed temporarily to have an extension ".S.cpp" buy the IDE, causing an error to be thrown.

In file included from c:\users\user\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\io.h:272:0,
from c:\users\user\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\avr\include\avr\pgmspace.h:90,
from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:28,
from sketch\oscillate_pin.S.cpp:1:

The workaround I have been using is to change the extension to something that Arduino Studio doesn't recognise before I launch the program (e.g. ._S). This stops the IDE adding it to the project and leaves just the .ino file in the editor. After this, I then change the extension of the '.S' back.

Once this is done the program will compile and launch correctly. So I was wondering if there was a batch file or something that controls the build process to prevent any .S files being renamed to .S.cpp.

Any advice would be greatly appreciated.

I just came up with a bit of a temporary workaround by making a batch file, which seems to do the job. But if there is a better way, I'd love to know it.

In the meantime, this is the workaround. It prevents the .S file from appearing in Arduino Studio and allows the project to compile properly. The downside is to edit the assembly file, you need to use a different editor.

rename *.S *._S
timeout /T 5 /NOBREAK
rename *._S *.S

this might be old but seems to indicate it's working (assuming Arduino Studio is the standard IDE)

➜ see Progrsmming arduino with assembly - #3 by pert

Thanks for the reply.

Looking at the posts after the one you linked, other people were experiencing a similar issue which never got resolved either. Maybe a bug crept in to a subsequent IDE build which was never fixed?

The process I am using is identical to the post you linked though, with an .ino C file and .S asm file.

Works perfectly is the .S file isn't in the editor (which seems can only be achieved if the file isn't present on launch of the editor), but as soon as the file is present in the editor.

I have about 20 different combined C and ASM projects and the failure rate is 100% on any computer. Tested on Windows 10 and 11 also. Very easy problem to replicate.

I'm using 1.8.15 on a Mac

I've duplicated the code in the link and I've a test folder with 2 files:

opening test.ino in the IDE shows both files are recognized and loaded into the editor

hitting upload just compiles fine and I get a blinking LED on my UNO

Seems to work for me.

Cool. Mac though, so different platform really. Would be interested to see what a fellow Windows user experiences.

Did a clean install of Windows 10 on this computer last weekend in fact, installed Arduino Studio, created an .ino and and .S file and failed instantly. That was without transferring any of my old files back whatsoever. Completely clean system.

Same thing, rename the .S to something else, launch the editor, name it back, and all good (for that session).

Yep, sorry don't have a windows machine setup here so that I could test... All macOS or Linux around here.
Could indeed be a windows only bug.

➜ + @pert in case he can test on windows

It might be a variant of this:

@j64c. Please tell us what is the exact sketch folder name and .ino file name.

1 Like

No probs at all! Thanks for taking a look though. Much appreciated! :smile:

I have the 'workaround' anyway, so it's not the end of the world. Still be interested to see if other Windows users can replicate. Happens on every Windows box I use.

At the end of the day it's really just a minor annoyance.

can you confirm the enclosing folder name is exactly the same as the main .ino file name (capitalisation included)?

could you post a Zip of a non confidential example failing on your system. I could try to compile that.

in0 is 100% spot on!

If I rename the file to "zzzzz.S" it appears in the editor after the ino file and does infact compile correctly. So there is definitely a bug in the editor.

Oh and the project structure is as follows (which fails)


But this variant works perfectly


The latter causes the .S file to load last in the editor.


the IDE expects exact capitalisation to match the enclosing folder's name for the main .ino


the other files can be before or after alphabetically it does not matter. Just ensure this rule is enforced (as you can see in my image in #5, the .S file is before alphabetically but appears after the .ino file in the IDE tabs)

1 Like

I'm glad to hear it is working now. Enjoy using assembly language seamlessly in the Arduino IDE!

It's not a capability I will probably ever use, but I think it is very cool that the IDE supports assembly in sketches.

1 Like

Wow, thanks guys awesome help from both fronts!

credit should go to @in0 for identifying the root cause and having the idea of the wrong file naming

glad it's working now

1 Like

Will certainly make things a lot more seamless that's for sure! :smiley:

Having great fun learning the ASM side of these chips BTW. I particularly like being able to control the ATMega chips down to the exact clock cycle (down to the 62.5nS chunk anyway).

1 Like