Search code examples
assemblycompiler-errorsarduinoesp8266arduino-esp8266

Understanding ESP8266 Assembly Errors in Arduino IDE on upgrade from Boards Package v2.x to 3.x


[Updated post: I originally had a broader question, but have narrowed down my problem to the change from using ESP8266 Boards Package v2.x to ESP8266 Boards Package v3.x]

On reinstalling the Arduino IDE on a new computer, I tried going with the latest versions of everything, but I've found that moving from ESP8266 Boards Package 2.x to 3.x is triggering essentially meaningless error messages which are making it impossible to either search for possible solutions, or help me decide where to look. There's hundreds of lines of errors, but they're all like this:

/var/folders/9_/nlhqn4y90zl54rhtm87_x0gc0000gn/T//ccwAAS5l.s:19400: Error: junk at end of line, first unrecognized character valued 0x9
/var/folders/9_/nlhqn4y90zl54rhtm87_x0gc0000gn/T//ccwAAS5l.s:19401: Error: bad register name:   a2
/var/folders/9_/nlhqn4y90zl54rhtm87_x0gc0000gn/T//ccwAAS5l.s:19401: Error: junk at end of line, first unrecognized character valued 0x9
/var/folders/9_/nlhqn4y90zl54rhtm87_x0gc0000gn/T//ccwAAS5l.s:19412: Error: bad register name:   a2
/var/folders/9_/nlhqn4y90zl54rhtm87_x0gc0000gn/T//ccwAAS5l.s:19412: Error: junk at end of line, first unrecognized character valued 0x9
/var/folders/9_/nlhqn4y90zl54rhtm87_x0gc0000gn/T//ccwAAS5l.s:19413: Error: bad register name:   a3

Or this:

/var/folders/9_/nlhqn4y90zl54rhtm87_x0gc0000gn/T//ccwAAS5l.s:22064: Error: operation combines symbols in different segments
/var/folders/9_/nlhqn4y90zl54rhtm87_x0gc0000gn/T//ccwAAS5l.s:55163: Error: operation combines symbols in different segments
/var/folders/9_/nlhqn4y90zl54rhtm87_x0gc0000gn/T//ccwAAS5l.s:55203: Error: operation combines symbols in different segments

I've tried looking for that file (ccwAAS5l.s) on the computer, but can't find it.

There's nothing in any of the errors that look even closely like anything in my code, or any of my dependencies.

Some demo sketches compile, so it's not a global issue. There's clearly an incompatibility in my code - and I know that the ESP8266 Boards Package upgrade to v3 does introduce some breaking changes (https://github.com/esp8266/Arduino/releases).

I'm at a loss for how to use any of this to track down the source of my problems. It'd be fine if it could point to errors in my code... but I've not got a clue as to how to track down assembler errors. I can't even post any sensible snippets here, because my code runs to thousands of lines and don't know which are relevant.

Any pointers on what this error means, or where to start looking for a solution?

Very many thanks!


Solution

  • The suggestions from @PeterCordes in the comments on my original question helped me find the cause - I'd recommend others with similar issues follow that advice.

    The result wasn't very obvious, but thought worth sharing some examples. The first entry in the compiler error was:

    KDHomeNode.ino.s: Assembler messages:
    KDHomeNode.ino.s:4896: Error: bad register name:    sp
    KDHomeNode.ino.s:4896: Error: junk at end of line, first unrecognized character valued 0x9
    

    Once I eventually managed to find the .ino.s file, and went to line 4896, I found the following (where the relevant line is addi sp, sp, -32:

    _ZN7Buttons8onChangeEv:
    .LVL430:
    .LFB4255:
        .file 27 "/Users/dave/Documents/Development/KDHome/Arduino/KDHomeNode/IOButtons.h"
        .loc 27 95 90 is_stmt 1 view -0
        .loc 27 96 7 view .LVU1293
        .loc 27 95 90 is_stmt 0 view .LVU1294
        addi    sp, sp, -32
    .LCFI150:
        s32i.n  a12, sp, 24
    

    Not at all clear what was wrong from that line, but scrolling up suggested my IOButtons.h file, and perhaps the onChange() event? The only seemingly notable thing about that function was that it was a callback for an interrupt. Looking at the reference for Interrupts (https://arduino-esp8266.readthedocs.io/en/latest/reference.html#interrupts) had a note about potential issues if playing with memory within those functions, and I realised that I'd inadvertently added some logging capabilities within that function. Not a lot, just the following - but the printDebug function itself does quite a bit of strncpy and Serial.print()ing

              char pin_str[3];
              char press_time_str[12];
              itoa(_pin, pin_str, 10);
              ltoa(press_time, press_time_str, 10);
              printDebug("Button ", pin_str, " pressed (", press_time_str, "ms)");
    

    Anyway, by commenting those lines out the whole thing compiles perfectly now, even after adding back all of the other code / third party libraries / etc that I'd tried removing yesterday.

    Perhaps the strangest thing, I thought, was that there were hundreds if not thousands of lines of compiler errors, spread across over 168,000 lines in the .ino.s file, referring to all sorts of different functions - but fixing only the first managed to resolve the rest! So I think good advice to anyone - don't be disheartened if it looks like there's massive issues that will take forever to work through. Just start at the top, and the rest might resolve themselves.

    Thanks again to Peter for his help in finding the cause.