Skip to content

Loom Deployment Guide

millbren edited this page Aug 27, 2019 · 13 revisions

Loom Deployment Guide

This guide offers a quick overview of the steps one should take before deploying Loom into production. Some of these steps may cause unexpected consequences, so it is recommended that time is in place for testing your deployment after this process is followed. In addition, some of these steps may change the Arduino IDE in ways that are difficult to reverse--if you are experiencing problems compiling after following these steps, you may want to reinstall your Arduino IDE.

Low Power Fix

As of version 1.6.19 of the Adafruit SAMD core libraries, all pins on the Feather M0 are initialized to input with a pullup resistor. As detailed in this issue in SleepyDog, the pullup resistors have a total constant draw of ~1mA, resulting in high current usage during low-power sleep modes. Adafruit has addressed this issue in this pull request, and has pushed this change to version 1.5.0 of the core libraries. As a result, to keep current drawdown during sleep mode we will need to update the core libraries.

Before beginning this process, ensure that every pin being used by your sketch has been initialized to input or output manually using ''pinMode''. If a pin in uninitialized and assumed to be input when your sketch starts, you may encounter difficulty and unpredictable bugs. This is best avoided with a quick pin review before deployment.

The Easy Method

Open the Arduino IDE. Under the "Tools" menu, hover over the "Board: ..." button, and click "Boards Manager" at the top of the menu that appears. Wait for the manager to finish refreshing, then enter "Adafruit SAMD" into the search bar. Scroll until you see the item labeled ''Adafruit SAMD Boards by Adafruit version X.X.X''. If the version number is 1.5.0 or greater, you already have a low power patch. If not, you will need to update your core libraries. Take note of the version number displayed in the item title, then click the "update" button on the ''Adafruit SAMD Boards by Adafruit version X.X.X'' item. Once the core libraries finish installing, simply recompile your code to apply the fix. Ensure that all aspects of your project are still functioning.

The Hard Method

If you attempted the above method and some aspect of your project broke irreversibly, you may be dependent on a specific version of the core libraries. In this case, you will need to revert your core libraries (same instructions as above, but select the version you noted in the drop-down menu and click "install") and apply the low power fix manually.

First, navigate to the ''wiring.c'' file in the Adafruit SAMD core libraries installed on your computer. This file can be in a few places:

  • Windows: Open an explorer window, and copy the following path into the address bar: HOMEPATH\AppData\Local\Arduino15\packages\adafruit\hardware\samd Double click on the folder with the highest number (mine was named ''%%1.5.0%%'', yours might be lower), double click on the ''cores'' folder, and then the ''arduino'' folder. You should be in a folder full of ''.c'' and ''.h'' files with a path something like C:\Users\Noah\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.0\cores\arduino

  • Mac: Open a terminal window (under ''Applications/Utilities/Terminal'') and run the command ''echo $USER''. Open a Finder window, and under the "Go" menu click "Go to Folder...". Paste in the following path, replacing ''your-username'' with the output from the terminal command we ran earlier: /Users//Library/Arduino15/packages/adafruit/hardware/samd Click "Go". Double click on the folder with the highest number (mine was named ''1.5.0'', yours might be lower), then the ''cores'' folder, and finally the ''arduino'' folder. You should be in a folder full of ''.c'' and ''.h'' files with a path something like /Users/openslab/Library/Arduino15/packages/adafruit/hardware/samd/1.5.0/cores/arduino

Once in the right directory, open ''wiring.c'' in your favorite text editor, find the lines below, and delete them from the file:

code C++ // Setup all pins (digital and analog) in INPUT mode (default is nothing) for (uint32_t ul = 0 ; ul < NUM_DIGITAL_PINS ; ul++ ) { pinMode( ul, INPUT ) ; }

These lines take the pins out of their lower-power initial state and into input by default, creating the undesirable current draw detailed above.

Save ''wiring.c'', recompile your code, and pins will no longer default to input. Ensure that all components of your project are still functioning.

Clone this wiki locally