@kaluma/cli v1.4.0
Kaluma CLI
Kaluma CLI is a command-line tool to program devices and boards running Kaluma runtime. It communicates with devices and boards via serial ports. Before using CLI, please ensure that your device or board is connected to a serial port.
Install
Install CLI via npm globally.
npm install -g @kaluma/cliIf you failed to install, sometime you need to install by building from source as below (e.g. Apple M1, Raspberry Pi, or some Linux).
npm install -g @kaluma/cli --unsafe-perm --build-from-sourceYou can also install locally and run with npx kaluma.
npm install @kaluma/cli --save-devRecommended Workflow
A typical workflow to program Kaluma is:
- Bundle main (
index.js) file. (kaluma bundle ...) - Flash the bundled file. (
kaluma flash ...) - Check errors or outputs in console with shell connection. (
kaluma shell ...)
Repeating these tasks is very tedious, so we recommend to use flash command with --bundle and --shell options as below:
kaluma flash index.js --bundle --shell
# shortly
kaluma flash index.js -b -sIt processes all the task sequentially. Lastly you just need to exit the shell connection by pressing ctrl+z.
Usage
help command
Print help for commands and options.
kaluma help [command]ports command
List all available serial ports.
kaluma portsflash command
Flash code (.js file) to device.
You can flash only a single .js file to Kaluma. If you have multiple .js files, you need to bundle them with
--bundleoption orbundlecommand.
kaluma flash <file> [--port <port>] [--bundle] [--shell] [--no-load] [...]<file>: Path to the file to upload.-p, --port <port>option : Path to a serial port where device is connected. You can check the available serial ports usingportscommand. (e.g./dev/tty*orCOM*). Or, you can pass a port query with serial device's VID (Vendor ID) and PID (Product ID) (e.g.@<vid>,@<vid>:<pid>). (Default:@2e8a- This is VID of Respberry Pi, so automatically finds the port of Raspberry Pi Pico if you omit--portoption)--no-loadoption : Skip code loading after flash. Use this option if you don't want to run the flashed code immediately.-b, --bundleoption : Bundle .js code before flash. If you use this option, you can also use all options ofbundlecommand.-o, --output <file>option : Seebundlecommand.-m, --minifyoption : Seebundlecommand.-c, --sourcemapoption : Seebundlecommand.-s, --shelloption: Flash code with shell connection. With this option you can see all console logs and errors. To exit the shell, pressctrl+z. Seeshellcommand.
Examples:
# flash index.js to Raspberry Pi Pico (vid: 2e8a)
kaluma flash index.js
# flash index.js to port: /dev/tty.usbmodem1441
kaluma flash index.js --port /dev/tty.usbmodem1441
# flash index.js without load
kaluma flash index.js --no-load
# bundle index.js and then flash
kaluma flash index.js --bundle
# bundle and flash index.js with shell connection
kaluma flash index.js --shell --bundleerase command
Erase code in device.
kaluma erase [--port <port>]-p, --port <port>option: Seeflashcommand.
Example:
# erase code in flash of Raspberry Pi Pico (vid: 2e8a)
kaluma erase
# erase code in flash of port: /dev/tty.usbmodem1441
kaluma erase --port /dev/tty.usbmodem1441shell command
THIS IS EXPERIMENTAL FEATURE
Shell connect (binds standard I/O to serial port).
kaluma shell [--port <port>]-p, --port <port>option: Seeflashcommand.
Example:
# shell connect to Raspberry Pi Pico (vid: 2e8a)
kaluma shell
# shell connect to the port: /dev/tty.usbmodem1441
kaluma shell --port /dev/tty.usbmodem1441bundle command
Bundle codes with webpack.
Note that you can bundle and flash at once with
--bundleoption offlashcommand.
kaluma bundle <file> [--output <file>] [--minify] [--sourcemap]<file>: Path to the file to bundle.-o, --output <file>option : Output path of bundled code. (Default:bundle.js).-m, --minifyoption : Minify the bundled code. It can reduce the code size, but it may harden to debug.-c, --sourcemapoption : Generates source-map file.
Example:
# Bundle 'index.js' into 'bundle.js'
kaluma bundle index.js
# Bundle 'index.js' into './dist/out.js'
kaluma bundle index.js --output ./dist/out.js
# Bundle 'index.js' into minified 'bundle.js'
kaluma bundle index.js --minify
# Bundle 'index.js' into 'bundle.js' with source-map file 'bundle.js.map'.
kaluma bundle index.js --sourcemapput command
Copy a file from host computer to device.
kaluma put <src> <dest> [--port <port>]<src>Path to a file to send in host computer.<dest>Path to the file received in device. Absolute file path is required.-p, --port <port>option: Seeflashcommand.
Examples:
# copy 'host.txt' [host] to '/dir/device.txt' [Raspberry Pi Pico]
kaluma put host.txt /dir/device.txt
# copy 'host.txt' [host] to '/dir/device.txt' [device]
kaluma put host.txt /dir/device.txt --port /dev/tty.usbmodem1441get command
Copy a file from device to host computer.
kaluma get <src> <dest> [--port <port>]<src>Path to a file in device. Absolute file path is required.<dest>Path to the file received in host computer.-p, --port <port>option: Seeflashcommand.
Examples:
# copy '/dir/device.txt` [Raspberry Pi Pico] to 'host.txt' [host]
kaluma get /dir/device.txt host.txt
# copy '/dir/device.txt` [device] to 'host.txt' [host]
kaluma get /dir/device.txt host.txt --port /dev/tty.usbmodem1441