-
Notifications
You must be signed in to change notification settings - Fork 13
building from source task #65
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
base: main
Are you sure you want to change the base?
Conversation
UncleGrumpy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very cool feature! One that has been on my todo list to add to the atomvm_rebar3_plugin for a while. I work much more in Erlang, so my Elixir is not that great, but I did spot a few problems, and have some suggestions on improving usability.
|
It might also be good to consider allowing a ESP-IDF docker image. I suspect many more Elixir developers will already have docker installed (or at least be more familiar with it than ESP-IDF), so it would be extra cool to pull in a docker image of ESP-IDF if they don't already have it installed. |
|
Hey @UncleGrumpy , when i try to build AtomVM , the build fails because we are using the the |
|
Added docker feat based on this |
This is not something I have seen before, and I have been working almost exclusively with main branch for at least the last few months. Was this testing a docker build, or did this happen with an installed ESP-IDF? It has been a few ESP-IDF releases since I last used an esp-idf docker image, although we do use them in the AtomVM CI, so I don’t think that would be the problem. |
|
@UncleGrumpy , this issue from the missing header happened with both toolchains. Esp idf installed and docker |
|
Interesting. Which ESP-IDF version? I think I am a point release behind locally (still using 5.5.1). I will try updating my toolchain this evening and see if I can reproduce the problem, I believe the AtomVM CI may also need to be bumped to 5.5.2, I will look into that too. This may be a new issue that you were the first to discover. I think you should open an issue in the AtomVM repo, and be sure to include Host OS, and ESP-IDF version in the report, along with the error and any other details that might be relevant. |
|
I tried with the last ESP version 6.X and then I tried with 5.4.1 which afaik is the last supported by AtomVM but not sure. It happens the same with both versions. |
I have not tried 6.0 yet, but I believe a PR was recently merged to allow ESP-IDF 6.0 builds. ESP-IDF 5.5.1 is definitely working for main branch, we might not have updated the main branch docs to reflect this, that is something we will need to make sure is up to date before a 0.7.0 release of AtomVM. Since you are hitting this error with ESP-IDF 5.4.1 and 6.0 then I don’t think just switching to 5.5.x will be any different. |
|
Okay @UncleGrumpy , today I will post an issue in AtomVM with this error and how to reproduce it. Meanwhile could you review the code and see if everything is fine ? |
|
Hey @UncleGrumpy , I tried 4 times to compile the AtomVM cloning each time just in case and it seems to be fixed. this command but with each version mix atomvm.esp32.build --use-docker --chip esp32s3 --idf-version latest
it seems i had something weird in the cache or it has been fixed. by default |
That is great! I would not necessarily expect any of the 6.x IDF versions to work at the moment. I think AtomVM itself will need some updating. If it works with stable releases from 5.1 (or 5.2) to 5.5 that is all that would be expected at the moment. The AtomVM main branch uses 5.5.x for release builds so that should probably be the default here too. I believe 5.5.2 is the latest, we still need to bump that in the AtomVM CI, which I believe is still using 5.5.1. There shouldn’t be any breakage between these versions since the point releases are usually just bug fixes. |
| selected_device <- EsptoolHelper.select_device(), | ||
| :ok <- confirm_erase_and_flash(selected_device, image_path), | ||
| true <- | ||
| EsptoolHelper.erase_flash([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think we will need a --no_erase (or better name?) option both for release and custom_image, but we can always do that in a follow up PR..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one erases as well, it has the same behavior as the release, what i wonder is why if i try the full workflow in a real board with a simple project it does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think there is a bug on later elixir like 1.19 - where we need to add @requirements ["app.config"] eg:
use Mix.Task
@requirements ["app.config"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird I am using Elixir 1.18.4 and Erlang 27
lib/mix/tasks/esp32.build.ex
Outdated
| end | ||
| end | ||
|
|
||
| defp build_generic_unix(atomvm_path) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should build in docker if that option is set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fine bc this is built with generic c compiler toolchain, since we dont need the idf toolchain for this i think is fine to keep it like this even if the docker is specified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, building fails since macos homebrew now has mbedtls@4 default, and one needs to build atomvm libs with:
export MBEDTLS_PREFIX="/opt/homebrew/opt/mbedtls@3"
cmake .. ${MBEDTLS_PREFIX:+-DCMAKE_PREFIX_PATH="$MBEDTLS_PREFIX"} -G Ninja
So as a user I expected it to use docker and "just work", so a bit confusing..
don't know if elixir:1.19-otp-28 https://hub.docker.com/layers/library/elixir/1.19.4-otp-28/ family of docker images has enough to build atomvm libs?
either way PR is huge DX improvement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one reason as well is that cmake only builds the elixir stuff if it is detected in the env and the container does not have elixir installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't know if elixir:1.19-otp-28 https://hub.docker.com/layers/library/elixir/1.19.4-otp-28/ family of docker images has enough to build atomvm libs?
ah okay i understood, i believe in this image from elixir is missing some libs required for building atomVM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does not have cmake neither make, an alternative would be to make a custom docker image with all the tooling but this would require to do it in AtomVM repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a better solution for the time being would be to add a —mbedtls_dir option, and if that is not given use MBEDTLS_PREFIX if that is exported to the environment.
I think it should be reasonable to expect cmake, either ninja or make, OTP, Elixir and either docker or ESP-IDF to already be installed on the build host. I would say to simplify the options look for and use ninja first, and if that isn’t found fall back to make. We will just need to be sure this is included in the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@UncleGrumpy and @petermm , could you try to build it with docker ? i believe there is something weird but i am not sure why. |
|
i believe i broke something in the build when i have changed to the elixir boot. output of boot in my esp-s3 EDIT: I managed to fix the build in the EDIT 2: I am trying to debug why Docker esp-idf container produces a different image than the Esp-idf installed natively. |
This seems more like it was flashed to the wrong offset than a library problem. It isn’t finding the partition with AtomVM, so it hasn’t made it as far as trying to load the library partition. |
|
Actually the offset must have been correct, it did find the partition table, so the problem is with the compiled VM. |
yup the result of the docker build is like this, but the native AtomVM build it is working. i believe it is bug with the docker flow in the tool, but it is hard to find. |
So for debugging in the docker container you can start a shell (docker run sh) and then use the commands the same as you would for a local install of ESP-IDF. My last 4 days have been brutal at work, but I will try building with docker this evening if I can stay awake long enough ;-) |
I discovered the problem with the docker container. I am working on a fix for the AtomVM repo that will change the configuration of the mkimage.sh and mkimage.config. The problem is that the paths to the binary files are configured by cmake in the container and then need to be executed in the host environment to use OTP to execute the escript. I can change the mkimage.sh script to find the esp32/build dir at runtime (rather than have it set by cmake) and pass that directly to the escript to use as the base for finding the partition binaries. We should fix this there so users, other tools, and IDEs can use docker builds. |
|
Amazing I had a mini fix which was patching the paths for the container build but it seems that is not working. |
the purpose from this task is to make easy to test Elixir AtomVM with main branch code from the AtomVM repository for ESP32.
this task requires
idf.pyinstalled ordockerfor compiling the AtomVM from source.feel free to comment any issue in the implementation as well.
Thank you for your attention.
Workflow with custom build
Using ESP-IDF Docker container