Dump C files before compiling w/ preprocessor flags

Howdy,

I’m using PlatformIO to program an nRF52840 with LVGL and a screen. Everything works well using when using platform = nordicnrf52@6.0.0 in the platformio.ini file, but when using the latest toolkit, LVGL is not able to find a display. The upgrade to the latest Zephyr is required to address the BLE issues found a few weeks ago.

The screen is an Adafruit 2.2" TFT (240x320) driven by an ILI9340 in 16-bit mode. In Zephyr v2.4, the display module is being configured and initialized correctly, but not in Zephyr v2.6, and I am trying to track down why. My best guess is a display initialization C macro is not being enabled through the prj.conf, as all the support code for the ILI9340 is there. Zephyr v2.4 has configuration options and code explicitly for this screen, while v2.6 has a more generic ILI9340 interface, but all the correct code to use an ILI9340 is in v2.6.

Is it possible to see the .c files with the enabled / disabled preprocessor flags from the prj.conf before the code is compiled and dump them somewhere for viewing?

The compiler invocation flags can be viewed with the project task ‘Advanced → Verbose Build’. If you add the build_flags regarding -E -dM per this, you should also see all defined macros.

The request to update Zephyr OS for all platforms is open at Update Zephyr to 2.6.0 · Issue #541 · platformio/platform-ststm32 · GitHub by the way.

1 Like

Thanks Max, I found that exact same post :slight_smile:

The build tool doesn’t seem to like those build flags, and is giving the following:

Indexing .pio/build/particle_argon/zephyr/liboffsets.a
Traceback (most recent call last):
  File "/Users/username/.platformio/packages/framework-zephyr/scripts/gen_offset_header.py", line 83, in <module>
    ret = gen_offset_header(args.input, input_file, output_file)
  File "/Users/username/.platformio/packages/framework-zephyr/scripts/gen_offset_header.py", line 41, in gen_offset_header
    obj = ELFFile(input_file)
  File "/Users/username/.platformio/penv/lib/python3.9/site-packages/elftools/elf/elffile.py", line 73, in __init__
    self._identify_file()
  File "/Users/username/.platformio/penv/lib/python3.9/site-packages/elftools/elf/elffile.py", line 482, in _identify_file
    elf_assert(magic == b'\x7fELF', 'Magic number does not match')
  File "/Users/username/.platformio/penv/lib/python3.9/site-packages/elftools/common/utils.py", line 77, in elf_assert
    _assert_with_exception(cond, msg, ELFError)
  File "/Users/username/.platformio/penv/lib/python3.9/site-packages/elftools/common/utils.py", line 114, in _assert_with_exception
    raise exception_type(msg)
elftools.common.exceptions.ELFError: Magic number does not match
*** [.pio/build/particle_argon/zephyr/include/generated/offsets.h] Error 1

Where would the PlatformIO marshal the c files? I’ve found the .pio folder in my Visual Studio to view Device Trees in the past, but it only seems to contain the object files.

Ah yes, building will absolutely fail because of this, since the output file is then not a compiled object file, but a text output that shows all macros. It should be usable when one catches a specific compiler invcation (by a verbose build) and adds those flags to it, while maybe also changing the -o output file.

The file .pio/build/particle_argon/zephyr/include/generated/offsets.h looks very muc like the generated stuff?

It should be usable when one catches a specific compiler invcation (by a verbose build) and adds those flags to it, while maybe also changing the -o output file.

Is there a tutorial on this? I’m not sure I quite follow.

The file .pio/build/particle_argon/zephyr/include/generated/offsets.h looks very muc like the generated stuff?

I should have said my .pio folder mostly has object files, but also header files and merged device tree, as well as a few .a library files, but no C files.