Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp32: system_architecture returns <<"Generic--">> #1371

Open
petermm opened this issue Nov 20, 2024 · 6 comments
Open

esp32: system_architecture returns <<"Generic--">> #1371

petermm opened this issue Nov 20, 2024 · 6 comments

Comments

@petermm
Copy link
Contributor

petermm commented Nov 20, 2024

erlang:system_info(system_architecture), seems off.
https://www.atomvm.net/doc/main/apidocs/erlang/estdlib/erlang.html#system-info-1 :
system_architecture the processor and OS architecture (binary)

0.6.5 release image and also local builds return <<"Generic--">> on esp32.

code search suggests it should return something like <<"ESP_IDF-3.2-xtensa_esp32">>

@UncleGrumpy
Copy link
Collaborator

UncleGrumpy commented Dec 16, 2024

So the documentation is not clear, or our implementation is wrong… it looks like this is returning the OS architecture as defined by the compiler… any of the platforms will report “Generic” if they are using neither X86_64 or ARM compilers.

@UncleGrumpy
Copy link
Collaborator

I should have said as defined by cmake configuration, not necessarily the compiler itself.

@petermm
Copy link
Contributor Author

petermm commented Dec 20, 2024

Yeah,

I cooked this up (from some of your code):

src/platforms/esp32/components/libatomvm/CMakeLists.txt

if (CMAKE_SYSTEM_NAME STREQUAL "Generic")
     if (CONFIG_IDF_TARGET_ARCH_XTENSA)
         set(CMAKE_SYSTEM_NAME "xtensa")
     elseif(CONFIG_IDF_TARGET_ARCH_RISCV)
         set(CMAKE_SYSTEM_NAME "riscv32")
     endif()
 endif()

 if (CMAKE_SYSTEM_PROCESSOR STREQUAL "")
     if (CONFIG_IDF_TARGET)
         set(CMAKE_SYSTEM_PROCESSOR "${CONFIG_IDF_TARGET}")
     endif()
 endif()

 if (CMAKE_SYSTEM_VERSION STREQUAL "")
         execute_process(
             COMMAND idf.py --version
             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
             OUTPUT_VARIABLE SYSTEM_VERSION
             OUTPUT_STRIP_TRAILING_WHITESPACE
         )
         # Use idf_get_version() to get the version directly
         string(REPLACE "ESP-IDF" "" SYSTEM_VERSION "${SYSTEM_VERSION}")
         string(REPLACE "-" "_" SYSTEM_VERSION "${SYSTEM_VERSION}")
         string(STRIP "${SYSTEM_VERSION}" SYSTEM_VERSION)
         string(REPLACE " " "" SYSTEM_VERSION "${SYSTEM_VERSION}")
     if (NOT SYSTEM_VERSION STREQUAL "")
         set(CMAKE_SYSTEM_VERSION "${SYSTEM_VERSION}")
     endif()
 endif()

which gives you: "riscv32-v5.3.2_210_g12938e511e_dirty-esp32c3"

but it runs into build issue due to this "Generic" check

if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Generic")

And I have a very limited understanding of the build system, especially across platforms..

but the utility of erlang:system_info(system_architecture) is limited, so low priority, and mostly it's deciding what output should be.

@UncleGrumpy
Copy link
Collaborator

UncleGrumpy commented Dec 20, 2024

I don't think we want to chant the CMAKE_ configuration there, that would lead to build problems... but I believe we could add a separate definition for the compiler - like AVM_SYSTEM_PROCESSOR.

@UncleGrumpy
Copy link
Collaborator

That definition for Generic is important for all of the MCU platforms in the cmake configuration process, so we don't want to mess with that.

@UncleGrumpy
Copy link
Collaborator

This is also slightly related to PR #1117 which I closed. I didn’t feel like we ever came to a logical consensus on what the returns should be, and as you point out, is not frequently needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants