nerves-keyboard / xebow

Firmware for the Keybow written in Elixir
40 stars 10 forks source link

Run on host for development #46

Closed amclain closed 4 years ago

amclain commented 4 years ago

Xebow should be able to start up the BEAM on the host, without being dependent on running on the target hardware. This will help with working on the web interface, designing animations, and being able to run commands like iex -S mix to experiment with the code without flashing the hardware.

doughsay commented 4 years ago

I desparately need this. The blocker that I can't figure out is that VintageNet tries to boot for me when I run iex -S mix and fails with:

(Mix) Could not start application vintage_net: VintageNet.Application.start(:normal, []) returned an error: shutdown: failed to start child: VintageNet.NameResolver
    ** (EXIT) an exception was raised:
        ** (File.Error) could not write to file "/etc/resolv.conf": permission denied
            (elixir 1.10.3) lib/file.ex:1050: File.write!/3
            (vintage_net 0.8.0) lib/vintage_net/name_resolver.ex:78: VintageNet.NameResolver.init/1
            (stdlib 3.13) gen_server.erl:417: :gen_server.init_it/2
            (stdlib 3.13) gen_server.erl:385: :gen_server.init_it/6
            (stdlib 3.13) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

I don't really understand why, since VintageNet is a dependency for the keybow target only, not host... so shouldn't it just not be there at all? I definitely don't WANT it to start...

amclain commented 4 years ago

I may be able to look into this if you've got the phoenix app running on your WIP branch.

doughsay commented 4 years ago

I may be able to look into this if you've got the phoenix app running on your WIP branch.

I do, the PR should compile and run on the hardware. I might suggest though, that throwing phoenix into the mix is going to make things even more complicated. Getting the firmware running on host from before I added phoenix is a reduced problem set.

I had to do a lot of config shenanigans to get local phoenix running back when I was doing this for Excalibur. I think a lof of that config stuff is relevant and should be copied over. See here: https://github.com/doughsay/keyboard/tree/master/firmware/config

vanvoljg commented 4 years ago

As you pointed out, we definitely need to make sure to try and fix the slew of errors from not having Circuits and USBGadget defined before closing this issue.

I'm not sure if we should mock or stub the modules, or if there's a way to config those applications to disable themselves in the host.exs configuration...

amclain commented 4 years ago

I'm not sure if we should mock or stub the modules

We may want to inject host dependencies in that either function reasonably without the hardware, or no-op.