Skip to main content

Scripting in MultiProg

What are scripts?

MultiProg has a built-in Lua scripting engine that lets you automate any operation: flash firmware, read memory, patch bytes, create custom targets, and more. No compilation needed — write a .lua text file and run it.

In the current API version, scripts primarily provide access to the hex buffer, file operations, and basic programming actions (connect, read, write, verify, erase). Low-level programmer and target functions (custom protocols, debug registers, raw probe commands) are not yet exposed — this is planned for future releases. If you have ideas or specific needs, feel free to contact us.

Requirements

Nothing extra is needed. MultiProg ships with the Lua engine built in. The deployed MultiProg.exe includes everything — no separate Lua installation required.

Script execution and debugging are only available inside MultiProg — there is no external IDE integration or standalone runner at this time. You can write .lua files in any text editor, but running and debugging requires the built-in Script Console.

Engine versions

ComponentVersion
Lua5.5.1
Sol2 (C++ binding)3.3.0
Script APIcheck at runtime: mp.app.script_api_version()
Sandbox

The Lua os and io standard libraries are NOT exposed to scripts — os.clock, os.time, os.date, io.open and similar will be nil. Use mp.utils.timestamp() / mp.utils.time() / mp.utils.date() for timing and wall-clock, and the mp.file.* family for filesystem. The full string, table, math, bit (Lua 5.5 native), and coroutine libraries are available unchanged.

Getting Started

  1. Open MultiProg.
  2. Go to the Script Console tab (or Menu → Script → Script Console, hotkey Ctrl+L).
  3. Write your script in the editor, or pick one from the Examples dropdown.
  4. Click ▶ Run.

Your First Script

-- Show current configuration
local cfg = mp.config.get()
mp.log.info("Target: " .. cfg.target)
mp.log.info("Family: " .. cfg.family)
mp.log.info("Programmer: " .. cfg.programmer)

-- List memory regions
local regions = mp.memory.get_regions()
for i, name in ipairs(regions) do
mp.log.info("Region " .. i .. ": " .. name)
end

mp.log.success("Done!")

Editor Features

  • Syntax highlighting — Lua keywords, mp.* API calls, strings, numbers, comments.
  • Auto-complete — type mp. to see all modules and functions.
  • Breakpoints — click the line number gutter to toggle breakpoints (red dots).
  • Error navigation — on error, the editor jumps to and highlights the error line.
  • REPL — input field at the bottom evaluates expressions instantly.
  • API Reference tab — built-in documentation for all functions.

Stopping a Script

Click ■ Stop. Long-running scripts should check mp.check_stop():

while not mp.check_stop() do
-- work
mp.sleep(100)
end

What's in the API

The Lua API spans 12 modulesmp core plus 11 namespaced modules — for about 235 functions total. See the full API reference for per-module details.

Where to next?