Skip to content

Unable to run hello-world #60

@mordv

Description

@mordv

I was going through docs

After mix atomvm.packbeam i get:

21:29:26.362 [error] Process #PID<0.236.0> raised an exception
** (RuntimeError) found error while checking types for Mix.Tasks.Atomvm.Uf2create.run/1:

** (MatchError) no match of right hand side value: {:EXIT, {:badarg, [{:erlang, :binary_to_atom, [<<117, 102, 50, 116, 111, 111, 108, 64, 109, 97, 105, 110, 96, 101, 114, 108, 97, 110, 103, 96, 108, 101, 110, 103, 116, 104, 32, 105, 111, 96, 102, 111, 114, 109, 97, 116, 64, 104, 97, 108, 116, ...>>, :utf8], [error_info: %{module: :erl_erts_errors}]}, {:beam_lib, :extract_atom, 2, [file: ~c"beam_lib.erl", line: 1217]}, {:beam_lib, :get_atom_data, 8, [file: ~c"beam_lib.erl", line: 981]}, {:beam_lib, :scan_beam1, 2, [file: ~c"beam_lib.erl", line: 942]}, {:beam_lib, :scan_beam, 4, [file: ~c"beam_lib.erl", line: 927]}, {:beam_lib, :read_chunk_data, 3, [file: ~c"beam_lib.erl", line: 899]}, {:beam_lib, :read_chunk_data, 2, [file: ~c"beam_lib.erl", line: 890]}, {Module.ParallelChecker, :cache_module, 2, [file: ~c"lib/module/parallel_checker.ex", line: 360]}]}}
The exception happened while checking this code:

def run(args) do
  config = Mix.Project.config()

  with {:atomvm, {:ok, avm_config}} <- {:atomvm, Keyword.fetch(config, :atomvm)},
       {:args, {:ok, options}} <- {:args, parse_args(args)},
       {:pack, {:ok, _}} <- {:pack, Mix.Tasks.Atomvm.Packbeam.run(args)} do
    app_start =
      parse_addr(
        Keyword.get(
          avm_config,
          :app_start,
          Map.get(options, :app_start, System.get_env("ATOMVM_PICO_APP_START", "0x10180000"))
        )
      )

    family_id =
      validate_fam(
        Keyword.get(
          avm_config,
          :family_id,
          Map.get(options, :family_id, System.get_env("ATOMVM_PICO_UF2_FAMILY", "rp2040"))
        )
      )

    :ok =
      :uf2tool.uf2create(
        <<String.Chars.to_string(config[:app])::binary, ".uf2">>,
        family_id,
        app_start,
        <<String.Chars.to_string(config[:app])::binary, ".avm">>
      )

    IO.puts(<<"Created ", String.Chars.to_string(config[:app])::binary, ".uf2">>)
  else
    {:atomvm, :error} ->
      IO.puts("error: missing AtomVM project config.")
      :erlang.exit({:shutdown, 1})

    {:args, :error} ->
      IO.puts("Syntax: ")
      :erlang.exit({:shutdown, 1})

    {:pack, _} ->
      IO.puts("error: failed PackBEAM, uf2 file will not be created.")
      :erlang.exit({:shutdown, 1})
  end
end

Please report this bug at: https://github.com/elixir-lang/elixir/issues

    (stdlib 6.2.2.2) beam_lib.erl:899: :beam_lib.read_chunk_data/3
    (stdlib 6.2.2.2) beam_lib.erl:890: :beam_lib.read_chunk_data/2
    (elixir 1.17.0) lib/module/parallel_checker.ex:360: Module.ParallelChecker.cache_module/2
    (elixir 1.17.0) lib/module/types/of.ex:318: Module.Types.Of.remote/6
    (elixir 1.17.0) lib/enum.ex:2531: Enum."-reduce/3-lists^foldl/2-0-"/3
    (elixir 1.17.0) lib/module/types/of.ex:299: Module.Types.Of.remote/8
    (elixir 1.17.0) lib/module/types/expr.ex:333: Module.Types.Expr.of_expr/3
    (elixir 1.17.0) lib/module/types/expr.ex:125: Module.Types.Expr.of_expr/3

elixir and erlang versions (asdf)

cat .tool-versions

erlang 27.3.4.3
elixir 1.17.0-otp-27

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions