RPi4 bootloop with nerves_livebook when adding :wx to extra applications

Hello everyone. I’m new to nerves project so forgive my ignorance.
I have created a nerves_livebook.fw for RPi4 to be able to use livebook. Everything was fine. I decided to use observer in my code. After some search and troubleshooting I rebuilt wxWidgets, Erlang and Elixir from source code to get Erlang with wx support. I have added :wx and :observer to the extra applications in mix.exs.

I have build a new nerves_livebook.fw successfully without errors. But, with this firmware RPi4 got into a bootloop. Removing :wx from extra applications made the RPi4 boot without a problem. It is like wx is initializing at boot but something is missing that causes RPi4 to reboot. Any idea of the reason and how to solve it?

I’m using Ubuntu 22.04 on RPI4 to avoid cross compiling also:
wxWidgets version 3.3
Erlang/OTP 26.1.1
Elixir 1.15.6-otp-26

extra_applications: [:logger, :runtime_tools, :inets, :ex_unit, :wx, :observer]

I don’t believe wx is included in the Nerves systems. It’s also usually only a host tool. So when you include it in the firmware, it’s missing from the compiled OTP version and it also has no screen to render on.

What I believe you might actually want is to run observer and wx on your host machine and connect that UI to your Nerves device with Erlang distribution.

Thank you for your reply. I have seen something similar to what you have mentioned about wx is not included in Nerves system. Based on some search results, nerves_system_rpi4 is a dependency of nerves system mentioned in deps of mix.exs file. I found that it is possible to add wx to its source code and compile it. Then change the nerves_system_rpi4 dependency to the new build file.

I found that I should modify nerves_defconfig file and add these lines:

Enable wxWidgets support

BR2_PACKAGE_WXWIDGETS=y
BR2_PACKAGE_WXWIDGETS_GTK3=y

also to modify fwup.conf and add these:
file-resource wx { host-path = “${NERVES_APP}/rootfs_additions/wx” }
and
fat_write(${NERVES_APP_PART_OFFSET}, “wx”, “${wx}”)

in addition to modify config.exs file like this:
config :nerves, :firmware, fwup_conf: “config/fwup.conf”, rootfs_additions: “rootfs_additions”, wx: true

which then I learned that rootfs_additions is deprecated and replaced by rootfs_overlay
The line fat_write mentioned above seems to lack for something when I tried to add it to the file. My lack of information in this field is not an ally. Hopefully someone can figure it out.

Be reminded that I have build Erlang/OTP from source code using command:
./configure --with-wx

I’m afraid that you might be out of luck with using wxWidgets with Nerves. I looked into this years ago. I’m looking again to see if there’s anything new. The situation seems to be the same:

  1. WxWidgets isn’t in upstream Buildroot (buildroot.org / buildroot · GitLab). That means that it won’t be in Nerves. You’ll need to port it to Buildroot first. I’m not sure where you found BR2_PACKAGE_WXWIDGETS, but perhaps they have a recipe?
  2. Erlang doesn’t support crosscompiling the wx application. See https://github.com/erlang/otp/blob/master/lib/wx/configure.ac#L341

I think this is going to be an uphill battle to use WxWidgets to work with Nerves sadly. Once you get past those two things, you’ll probably run into having to configure X Windows. That can be a big task. None of the supported platforms on the WxWidgets website looked like great options to me.

All is not lost. If you’re just interested in observer, then the usual route with Nerves devices is to enable Erlang distribution, start up IEx on your PC and connect to the Nerves device, start up Observer and then use the menus to select the node that’s the Nerves device.

If you are interested in making a user interface, Scenic probably has the most people around here who can help out. There are other options, but that’s probably a different post.

One last thing since I know there are a lot of parts to Nerves when you start having to venture down these paths. If you go farther in this direction, you generally don’t need to modify the fwup.conf when enabling options in Buildroot. Buildroot’s output is mostly to the root filesystem. The fwup.conf is needed when you start modifying bootloader options. On the RPi4, this generally comes up when you need to change the config.txt file.

Sorry for the not so good news. I hope it saves some time, at least.

1 Like

Thank you for your detailed answer. I have been investigating this for the past 2 months. I didn’t want to post a question without having enough information.

I’m building a program that will run on RPi4 using nerves_livebook. This program can be accessed by other developers using any device with a browser to add new tools and so they may need observer for their tasks and this is the reason that I want observer to work on Nerves from RPi4.

Hopefully it will be available in the future. Thank you all.

Another idea would be to try Phoenix LiveDashboard. It’s available under Settings->About and has many similar features to observer.

Thank you for your support. I’ll try what you have suggested. :thinking: