This method applies to LPC1768 and LPC1769 boards, and other boards which are flashed by copying a file named firmware.bin
to the SD card and resetting the board. This includes some STM32 boards which have the required bootloader installed (e.g., SKR Pro v1.1, SKR Mini E3 v2).
Flashing a board from the SD requires that the host can mount the board's on-board SD card to a known mount point in the host filesystem. If your firmware does not expose the SD card to the host, and cannot be configured to do so, this method will not work.
The following options should be enabled in the Marlin firmware configuration in order for the board's SD card to be accessible by the OctoPrint host:
Configuration.h:
#define SDSUPPORT
Configuration_adv.h:
#define SDCARD_CONNECTION ONBOARD
Optionally, if you do not routinely use the SD card in Marlin, you can prevent Marlin mounting the card at startup, which will make firmware flashing faster as the firmware's lock on the card does not have to be released.
Configuration_adv.h:
#define SD_IGNORE_AT_STARTUP
Some boards (e.g., SKR Mini E3 V2) need to have a specfic build environment specified in order to include USB storage support in the firmware. If you are compiling with PlatformIO, you can open your platformio.ini
file and check the variable default_envs
- environments with USB host storage will end in _USB
or _USB_maple
.
If you plug your board into a PC the computer should see the SD card as a storage device. If this is not the case you need to check and adjust your firmware configuration.
There are several ways to have the SD card mounted by the host. Depending on your level of experience and knowledge with Linux you are free to use whatever method you prefer.
For new users, using usbmount is recommended and is documented below. When properly installed and configured it will automatically mount the board's SD card to /media/usb
.
Usbmount needs to be installed and configured to make it work. The instructions below assume that you are running OctoPrint on a Raspberry Pi as the user pi
.
Usbmount can be installed using the package manager. Run this command in an SSH prompt on your OctoPrint host:
sudo apt-get install usbmount
Usbmount must be configured so that the mounted device has the correct permissions for the 'pi' user to access the SD card.
-
Run this command in an SSH prompt on your OctoPrint host:
sudo nano /etc/usbmount/usbmount.conf
-
Find the
FS_MOUNTOPTIONS
line and change it to:FS_MOUNTOPTIONS="-fstype=vfat,gid=pi,uid=pi,dmask=0022,fmask=0111"
systemd-udevd must be configured so that the mount is accessible.
-
Run this command in an SSH prompt on your OctoPrint host:
sudo systemctl edit systemd-udevd
-
Insert these lines then save and close the file:
[Service] PrivateMounts=no MountFlags=shared
-
Run the following commands in an SSH prompt on your OctoPrint host:
sudo systemctl daemon-reload sudo service systemd-udevd --full-restart
Once usbmount is installed and configured the on-board SD card should be mounted at /media/usb
the next time it is plugged in or restarted.
Important: Do not modify the permissions on any of the /media/usb* directories!
See here and here for the explanation of why this is important and a very bad idea.
The plugin needs to be able to unmount the SD card to reduce the risk of file system corruption. The default command the plugin will use is sudo umount /media/usb
. You must be able to run this command at the command line without being prompted for a password.
If your system is configured to allow pi
to run all sudo
commands without a password (the default) then you do not need to do anything further.
Alternatively, you can disable the unmount command entirely by clearing the Unmount command field in the plugin's advanced settings, however this is not recommended.
If you need to enter a password when running sudo
commands as pi
you will need to create a new sudoers
entry in order for the plugin to work correctly.
-
Run this command in an SSH prompt on your OctoPrint host to create a new sudo rule file:
sudo nano /etc/sudoers.d/020_firmware_updater
-
Paste this line into the new file:
pi ALL=NOPASSWD: /bin/umount
-
Save and close the file
The only required setting is the path to the firmware update folder. If using usbmount it will be /media/usb
.
Option | Description |
---|---|
Reset before flashing | Adds an extra board reset prior to flashing - can help ensure that the SD card is mounted correctly. |
Unmount command | The command used to unmount the SD card prior to resetting the board. Clear the command line to disable it |
Ender 3 V2 printers with 4.2.x boards do not expose the SD card via the USB port. They cannot be updated using this method.
The M997
command is used to reset the board. If flashing an existing Marlin installation, the existing firmware must be newer than March 2nd, 2019 (i.e this commit) as that is when the M997
was added to support resetting the board.
A board running too-old Marlin firmware will report 'Board reset failed' when attempting to flash from the plugin.
The firmware upload will fail if the SD card is not accessible, either because it is not mounted on the host, or because the printer firmware has control over it.
The most common causes are:
- Firmware not correctly configured to expose SD card to host via USB - reconfigure the firmware
- Firmware is using the SD card so it is not available to the host - release the firmware's hold on the card with the
M22
command - usbmount is not configured correctly - follow the instructions to install and configure usbmount