Skip to content

Instantly share code, notes, and snippets.

@mfikes
Last active January 9, 2020 09:06
Show Gist options
  • Select an option

  • Save mfikes/a649ee58b3e9d5c8ecb91f3dbc6be224 to your computer and use it in GitHub Desktop.

Select an option

Save mfikes/a649ee58b3e9d5c8ecb91f3dbc6be224 to your computer and use it in GitHub Desktop.

Loading :advanced Code into an Unmodified WROVER

You can load ClojureScript :advanced code directly into an ESP32 WROVER for execution upon boot, by creating a binary and flashing it to the JavaScript "boot ROM" area. This has the same effect as when loading code via the Espruino Web IDE, in the "Direct to Flash (execute code at boot)" mode, but flashing is much quicker and more reliable.

Create :advanced Code

Here is a small program that uses enough to pull in data structures, etc, leading to nearly 100 KiB:

src/foo/core.cljs:

(ns foo.core)

(def m {:a 1, :b 2})

(js/print (reduce + (vals m)))

With deps.edn:

{:deps {org.clojure/clojurescript {:mvn/version "1.10.597"}}}

compile this program via

clj -m cljs.main -co '{:process-shim false}' -O advanced -c foo.core

Confirm that Espruino can run the resulting JavaScript by executing

espruino out/main.js

and confirming that it prints 3.

Create JavaScript Boot ROM Binary

In the above example wc -c out/main.js shows that the file is 96503 bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment