Skip to content

Caching of core build may get out of sync when doing multiple windows causing build to fail. #2144

Closed
@KurtE

Description

@KurtE

Describe the problem

Over the last few weeks, I have had several occasions when a build will fail, typically in the link phase. Where at least in the cases I have reproduced a few times today and yesterday, they have been caused by the build system failing to realize that it needs to rebuild the core library and instead uses the previous build, which as built with different options. Most specially the USB Type is different between the previous build and the new build.

I have been able to resolve the problem, by clearing out the temp directory. And I know there have been several other people who have posted up on Arduino (and Teensy) forums about running into issues like this. Mostly Teensy users, although I sort of thought there were some other users ESP32? that I thought were asking for a cleanup command or the like, to resolve when they had some issue...

On my current failure, the previous build I did on another sketch in a different window was to build that sketch for USB type of: Serial + MTP. After that completed, I went back over to the window which I wanted to build using USB type: Tripple Serial. which was what I last compiled with in that window.

I reselected the triple serial, and then issued the upload command:

During the compile phase, I verbose output shows:

Compiling libraries...
Compiling core...
Using precompiled core: C:\Users\kurte\AppData\Local\Temp\arduino\cores\teensy_avr_teensy41_101959c6bdaa9a37abb86f6cd0e474a6\core.a
Linking everything together...

Nothing in core is rebuilt, so then during link:

"C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-compile\\11.3.1/arm/bin/arm-none-eabi-gcc" -O2 -flto -fno-fat-lto-objects -Wl,--gc-sections,--relax "-TC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.1\\cores\\teensy4/imxrt1062_t41.ld" -fuse-linker-plugin -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -o "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\DF3C6F8663ED76A115E18319F4CDED14/USBtoSerialMulti.ino.elf" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\DF3C6F8663ED76A115E18319F4CDED14\\sketch\\USBtoSerialMulti.ino.cpp.o" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\DF3C6F8663ED76A115E18319F4CDED14/..\\..\\cores\\teensy_avr_teensy41_101959c6bdaa9a37abb86f6cd0e474a6\\core.a" "-LC:\\Users\\kurte\\AppData\\Local\\Temp\\arduino\\sketches\\DF3C6F8663ED76A115E18319F4CDED14" -larm_cortexM7lfsp_math -lm -lstdc++
c:/users/kurte/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\kurte\AppData\Local\Temp\cc6a1npc.ltrans0.ltrans.o: in function `loop':
C:\Users\kurte\Documents\Arduino\USBtoSerialMulti/USBtoSerialMulti.ino:63: undefined reference to `usb_cdc2_line_coding'
c:/users/kurte/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\kurte\Documents\Arduino\USBtoSerialMulti/USBtoSerialMulti.ino:63: undefined reference to `usb_cdc2_line_rtsdtr'
c:/users/kurte/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\kurte\Documents\Arduino\USBtoSerialMulti/USBtoSerialMulti.ino:63: undefined reference to `SerialUSB1'
c:/users/kurte/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\kurte\Documents\Arduino\USBtoSerialMulti/USBtoSerialMulti.ino:63: undefined reference to `usb_cdc3_line_rtsdtr'
c:/users/kurte/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\kurte\Documents\Arduino\USBtoSerialMulti/USBtoSerialMulti.ino:63: undefined reference to `usb_cdc3_line_coding'
c:/users/kurte/appdata/local/arduino15/packages/teensy/tools/teensy-compile/11.3.1/arm/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\kurte\Documents\Arduino\USBtoSerialMulti/USBtoSerialMulti.ino:63: undefined reference to `SerialUSB2'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

It fails, as the core build does not include any of the code needed to support triple serial.
Note: the choice of which two USB types is not that important, other than the sketches have something in them that references the USB type functionality. Earlier I had failures with MIDI...

Not sure if this happened iwth current reelases like 2.0.4 or not, but I don't remember hitting anything like that since IDE 2 was still in beta.

Note: another user @mjs513 was also able to reproduce this with the steps I am mentioning below.

To reproduce

Have two (or more sketch windows open), where the two sketches want different USB types.

In my current case: I have an MTP sketch, in this case I am using a sketch I have up at:
https://github.com/KurtE/mtp_tft_picture_view
Which displays images off of an SD card onto a TFT like display. Can be configured for several different display types. Currently it is setup for RA8876

The second sketch I am using. Again I don't think anything specific.
USBtoSerialMulti-230403a.zip
But included to be complete. This sketch is based off of the Teensy USB Serial example that turns a teensy into a USB to Serial adapter. This one is extended that if you choose USB Type of DualSerial it will forward Two UARTS to two logical USB ports and if you choose triple Serial 3...

In each of these windows choose the same USB port of your Teensy. I am currently building for Teensy 4.1 And select the correct USB type and upload the to the Teensy. Then go to the other window make sure it has the correct USB type for the sketch and try the upload. Sometimes it will fail here. Other times go back to the first window, make sure it has the correct usb type selected and try upload again.

Expected behavior

Expect it to rebuild the core when it detects that one or more FQBN like setting change. Probably if any setting changes.

It is almost like it is caching what the core is built for in each window and not what the last actual build was for it.

Arduino IDE version

nightly-20230403

Operating system

Windows

Operating system version

11

Additional context

I have posted about this in the Arduino Thread:
https://forum.arduino.cc/t/teensy-compile-sketch-fails-clear-out-temp-build-completes/1110104

Also up on the Teensy thread: https://forum.pjrc.com/threads/72523-Teensyduino-1-59-Beta-1?p=323529&viewfull=1#post323529

And there have been other reports of strange things happening where clearing out temp fixes it.

Guessing probably arduino-cli issue, but my reproduce steps are IDE, so opened here.
Edit: and I also doun't know if it would reproduce as maybe when you run the CLI each time, it would complete the process and probably update everythings state, where maybe as IDE, the process may contain information per window and that data becomes out of sync.

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions