The atomvm_packgleam library is just a standalone utility that can be added to your gleam project dependencies
in order to create a packed .avm file of your project for the AtomVM machine to be flashed onto your IoT device.
Add the following line to your gleam.toml file under [dev-dependencies].
atomvm_packgleam = { git = "https://github.com/karlsson/atomvm_packgleam", ref="main"}You will need gleam 1.9.1 or later that support github repositories.
The utility is using the AtomVM packbeam
tool.
Your main module, named the same as your project, will need a pub fn start() { ... } function that
AtomVM uses as entry point to start the application.
import gleam/io
// Gleam run start
pub fn main() {
io.println("Hello from gleam run!")
}
// For AtomVM start
// Start the application, callback for AtomVM init.
pub fn start() {
io.println("Hello from AtomVM!")
}To create the avm file execute:
gleam run -m atomvm_packgleam # Create an `<application>.avm` fileThe file name is picked from the name attribute in your gleam.toml file. The tool will list all files that are bundled in the .avm file and location of the file under the build directory.
In order to flash your device, check the AtomVM documentation for the available devices.