Skip to content

mod_hello

A minimal "hello world" module. It is the canonical template for writing your own ESPM module: it touches no hardware, requires no syscalls beyond basic introspection, and exits cleanly.

Field Value
Version 1.0.0
Targets esp32, esp32c3, esp32c6, esp32s3, esp32s2, esp32h2
Min heap 1024 bytes
Syscalls none
Source mod_hello.c

Commands

Command Description
hello Print a greeting plus chip model, core count, revision, free heap, uptime, and a random value.

What it does

On ESPM_CMD_EXEC the module reads get_chip_info(), get_free_heap(), get_time_us(), and random() from the syscall table and logs them. It is the smallest possible demonstration of a module running from IRAM.

#include "espm_module.h"

int module_entry(espm_sys_t *sys, int cmd, void *arg)
{
    if (cmd == ESPM_CMD_INIT) { sys->printf("[mod_hello] init OK\n"); return 0; }
    if (cmd == ESPM_CMD_EXEC) {
        uint32_t model, cores, rev;
        sys->get_chip_info(&model, &cores, &rev);
        sys->printf("[mod_hello] chip=%lu cores=%lu rev=%lu\n",
                    (unsigned long)model, (unsigned long)cores, (unsigned long)rev);
        return 0;
    }
    if (cmd == ESPM_CMD_STOP) { sys->printf("[mod_hello] stop\n"); return 0; }
    return -1;
}

See also