The on_boot.gcode file is a special G-code file that Smoothieware automatically executes when the board boots up. This feature allows you to run initialization commands, homing sequences, or startup configurations without manual intervention.
on_boot.gcode is a standard G-code file stored on your Smoothieboard’s SD card that runs automatically after the board completes its boot sequence. Think of it as a startup script for your CNC machine, 3D printer, laser cutter, or other Smoothie-controlled device.
The file must be placed in the root directory of your Smoothieboard’s SD card:
/sd/on_boot.gcode
When you connect your Smoothieboard via USB, the SD card appears as a removable drive. Simply copy the on_boot.gcode file to the root of this drive, alongside your config file.
The file uses standard G-code format:
; or ()The on_boot.gcode feature is controlled by two configuration options in your config file:
| Option | Default Value | Description |
|---|---|---|
true |
Enable or disable automatic execution of the on_boot.gcode file | |
/sd/on_boot.gcode |
Path to the G-code file to execute on boot |
Add these lines to your config file:
on_boot_gcode_enable true
on_boot_gcode /sd/on_boot.gcode
To temporarily disable the feature without deleting the file:
on_boot_gcode_enable false
Or simply comment out the line:
# on_boot_gcode_enable true
The on_boot.gcode file executes:
The most common use case is to automatically home your machine when it powers up:
; Home all axes on startup
G28 ; Home X, Y, and Z axes
For 3D printers, you might want to home and then move to a specific position:
; Home and move to printing start position
G28 ; Home all axes
G0 Z10 ; Raise Z to 10mm
G0 X0 Y0 ; Move to front-left corner
A more comprehensive startup sequence for a 3D printer:
; 3D Printer startup sequence
G21 ; Set units to millimeters
G90 ; Use absolute positioning
M82 ; Set extruder to absolute mode
G28 ; Home all axes
G0 Z50 ; Raise Z to safe height
G0 X10 Y10 ; Move to safe position
M104 S0 ; Ensure hotend is off
M140 S0 ; Ensure bed is off
For a CNC mill, you might want to ensure safe startup conditions:
; CNC Mill startup sequence
G21 ; Metric units
G90 ; Absolute positioning
G17 ; XY plane selection
M5 ; Ensure spindle is off
G28.2 Z0 ; Home Z axis only (safe for mill)
G53 G0 Z-5 ; Move to machine coordinates Z safe height
M0 ; Pause for user to verify before homing XY
Do not rely on startup G-code to keep a laser safe. Avoid automatic laser arming, homing, and travel moves at boot. Have a qualified person verify the machine’s laser output and independent door and other safety interlocks before enabling laser power. See the laser cutter installation guide for more context.
You can use on_boot.gcode to load settings saved with
; Load saved settings
M501 ; Load settings from config-override
If your on_boot.gcode file is not running on boot:
on_boot.gcode (case may matter on some systems)/sd/on_boot.gcode)on_boot_gcode_enable true is in your config fileon_boot_gcode /sd/on_boot.gcode matches your file locationIf commands execute but don’t work correctly:
G4 P500 (500ms delay) between commandsIf only some commands execute:
Enable verbose output in your config to see detailed execution:
loglevel 4
Then watch the console during boot to see what’s happening.
You can also test your on_boot.gcode file manually by playing it:
play /sd/on_boot.gcode
The on_boot.gcode feature is fully supported in Smoothieware v1 with the configuration options documented above.
Smoothieware v2 also supports boot-time G-code execution. While the exact implementation may vary slightly, the core concept remains the same. Consult the v2 documentation for specific configuration details.
M501 ; Load settings from config-override
Similar to on_boot.gcode, you can define G-code sequences for suspend and resume events:
after_suspend_gcode: Runs when print is pausedbefore_resume_gcode: Runs before resuming a paused printSee Player Options for details.
The on_boot.gcode file provides a powerful way to automate your machine’s startup sequence:
Whether you’re running a 3D printer, CNC mill, laser cutter, or other machine, on_boot.gcode can save time and ensure consistent initialization every time you power on your Smoothieboard.