Today I had some time to play around with a esp32-c6 I had laying around. I wondered for a while now whether it would be possible to run Diesel on these micro controllers.
Turns out that this is possible for the SQLite backend with some adjustments to diesel and some of our dependencies :tada:

You still need to bring your own VFS to get this working.

I likely will upstream parts of these in the next days, so the next Diesel release might support this out of the box.

Command line output of flashing a ESP32-C6 via espflash and afterwards seeing Diesel queries appearing in the ouput.Source code for running an embedded Rust program creating a Sqlite Database connection via Diesel and executing several queries.

```rust

#[unsafe(no_mangle)]
extern "C" fn sqlite3_os_init() -> core::ffi::c_int {
    println!("Setup os");
    unsafe {
        crate::memory::install();
    }
    libsqlite3_sys::SQLITE_OK
}

#[esp_hal::main]
fn main() -> ! {
    let config = esp_hal::Config::default().with_cpu_clock(esp_hal::clock::CpuClock::max());
    let peripherals = esp_hal::init(config);

    println!("Firmware starting");

    esp_alloc::heap_allocator!(size: 100 * 1024);
    println!("Before sqlite");
    let mut conn = SqliteConnection::establish(":memory:").unwrap();
    conn.set_instrumentation(|event: diesel::connection::InstrumentationEvent<'_>| {
        println!("Execute query: {event:?}")
    });

    conn.batch_execute("CREATE TABLE users(id INTEGER NOT NULL PRIMARY KEY, name TEXT NOT NULL)")
        .unwrap();

    diesel::insert_into(users::table)
        .values([users::name.eq("John"), users::name.eq("Jane")])
        .execute(&mut conn)
        .unwrap();

    let delay = Delay::new();
    loop {
        let data = users::table
            .filter(users::name.eq("Jane"))
            .first::<(i32, String)>(&mut conn)
            .unwrap();
        println!("----");
        println!("Query data:");
        println!("Loaded user data: {} -> {}", data.0, data.1);
        println!("---");
        delay.delay_millis(500);
    }
}

```
0

If you have a fediverse account, you can quote this note from your own instance. Search https://social.weiznich.de/users/weiznich/statuses/115674274621429825 on your instance and quote it. (Note that quoting is not supported in Mastodon.)