PlatformIO Community

ESP8266 "Error: unknown opcode or format name" when compiling with -include "umm_malloc/umm_malloc_cfg.h"

When I compile with:

    build_flags =
      -DDEBUG_BUILD
      -DWEBSOCKET_DISABLED
      -DDEBUG_ESP_OOM
      -include "umm_malloc/umm_malloc_cfg.h"

I have followed the instructions at https://docs.platformio.org/en/latest/platforms/espressif8266.html#debug-level to set the debug level.

I get error messages with the includes of umm_malloc_cfg.h. I get about 600 lines of errors but this is just a selection of them. They’re all essentially the same, but for different header files.

...
c:\users\user\.platformio\packages\toolchain-xtensa\lib\gcc\xtensa-lx106-elf\4.8.2\include\stddef.h: Assembler messages:
c:\users\user\.platformio\packages\toolchain-xtensa\lib\gcc\xtensa-lx106-elf\4.8.2\include\stddef.h:147: Error: unknown opcode or format name 'typedef'
...
C:\Users\user\.platformio\packages\framework-arduinoespressif8266\tools\sdk\libc\xtensa-lx106-elf\include/machine/_default_types.h:17: Error: unknown opcode or format name 'typedef'
Compiling .pio\build\esp8266\FrameworkArduino\core_esp8266_app_entry_noextra4k.cpp.o
C:\Users\user\.platformio\packages\framework-arduinoespressif8266\tools\sdk\libc\xtensa-lx106-elf\include/machine/_default_types.h:30: Error: unknown opcode or format name 'typedef'
Compiling .pio\build\esp8266\FrameworkArduino\core_esp8266_eboot_command.cpp.o
C:\Users\user\.platformio\packages\framework-arduinoespressif8266\tools\sdk\libc\xtensa-lx106-elf\include/machine/_default_types.h:33: Error: unknown opcode or format name 'typedef'

When I remove the -include "umm_malloc/umm_malloc_cfg.h" line, I get the following error

Linking .pio\build\esp8266\firmware.elf
c:/users/user/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld.exe: .pio\build\esp8266\firmware.elf section `.text1' will not fit in region `iram1_0_seg'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\esp8266\firmware.elf] Error 1

But I guess that “umm_malloc_cfg.h” is meant to be allocating the IRAM correctly and is therefore required.

I have tried tracing the includes to figure out if one of them has a bug in them but it’s a bit of a maze.

Does this also occur with a very simple firmware?

The way I see it, umm_malloc.h is included which already includes the config.

Brilliant, thanks for that. With a minimal blink project, it looks like when it’s passed as an include to gcc it gets this error but otherwise it compiles fine.

Looks like I will need to find what’s taking up all the space and trim it out.

So why does https://docs.platformio.org/en/latest/platforms/espressif8266.html#debug-level say that it’s required as a build_flag?

It’s possible to generate map files with extra linker options (Generate a .map file) and analyze it (e.g. amap). You may be able to force a non-passing build (due to out of IRAM) to pass by artificially modifying the underlying linker file (C:\Users\<user>\.platformio\packages\framework-arduinoespressif32\tools\sdk\ld\esp32_out.ld and related) with hacked len = .. directives). Though I think it’s clear why the build doesn’t pass: .text1 in IRAM contains function code which has the ICACHE_RAM_ATTR attribute. The umm_malloc library does that with its functions to provide a higher execution speed than when it’s executed from flash. If there is other stuff (SDK, wifi, libs,…) using IRAM instruction code space, there may be an overflow.

At the time the documentation was written it may have been required. Some later commits (https://github.com/esp8266/Arduino/commit/7a43092df0c8734577870f5630ee0062150c1074) definitely changed something regarding the typedef errors you are receiving.

Also, are you sure you’re on the latest package version for the Arduino-ESP8266 framework? Because it seems to me that above commits were targeted to fix those compilation problems. Check with pio platform update or in the VSCode GUI.

I could of course also be wrong and without that flag it will compile but not actually use umm_malloc

Thanks heaps for your help. I’ll have a dig through but I do use a lot of built in libraries so I’m not sure how I’m going to fit everything in. I only have a couple of one line interrupt functiosn in IRAM so I don’t think there’s much I’ll be able to take out. Will definitely check out the map though and see if it points to anything.

And yeah, I’m at the latest for everything - I tried updating before asking the question, didn’t want it to be something silly like that haha