Last edited · 98 revisions  

 


Uploading the Firmware

In order to upload the firmware to your micro-controller, you need to complete several tasks.

Install and configure the Arduino IDE

Install the Arduino environment (IDE).  The recent versions seem to be consistently reliable so download the latest (supported by Teensyduino if that's required) but not the "Windows app" version.

If you are using a Teensy (3.2, 3.5, 3.6, or 4.0) be sure to download and install Teensyduino.

If you are using an STM32F103, RobotDyn F303, F411, and F446 board (e.g. the Blue Pill, Black Pill, MaxSTM, FYSETC S6), then you need to install the STM32CubeProgrammer.

For Linux Users Only: For the STM32F103, RobotDyn F303 and F411, you should use the stm32flash program, which should already be in your distro's repository. For the FYSETC S6, you should use the free dfu-util program, which should already be in your distro's repository.

From the Arduino IDE:

  • If you will be using the ESP8266 (WeMos D1 Mini) to run the Smart Web Server (for Wifi) now is a good time to add support for that:
  • If you are using the ESP32 to run OnStep (or to run the Smart Hand Controller or Smart Web Server):
  • If you are using an STM32 to run OnStep:
    • Select File>Preferences "Additional Boards Manager URLs" and add: https://github.com/stm32duino/BoardManagerFiles/raw/master/STM32/package_stm_index.json
    • Install support for this board from within the menu Tools>Board>Boards Manager.
      • Use STM32 version 1.9.0 only (ignore the warnings about it being depreciated, etc. version 2.0.0 doesn't work for OnStep)
      • On Windows, for the FYSETC S6 (STM32F446,) you must also find the "stm32CubeProg.bat" file by searching in ~\AppData\Local\Arduino15 then (using Notepad;) edit it and change the SET ADDRESS line from 0x8000000 to 0x8010000 (see the S6 Wiki page for what to do to fix things if you upload without changing this address.)
        • Other STM32 boards we use must NOT have this change.
  • Tip:
    • Where more than one "Additional Boards Manager URLs" are present use a comma "," between the URLs.
  •  

Getting the OnStep Firmware

Unless the Wiki instructions for your particular board states otherwise, it is recommended that you use the latest OnStep release.  Follow this link for release-4.24 to GitHub and select the "Code" button, and choose "Download ZIP"

Unzip the folder to your PC. This can be on your desktop or in your ~/Documents/Arduino folder.

The directory will be named "OnStep-release-4.24". You must rename the directory to "OnStep", otherwise you will not be able to compile properly.  Double clicking on "OnStep.ino" will then open OnStep in the Arduino IDE (if everything is installed correctly.)

Also, remember there is separate (but related) source code for the Smart Hand Controller (SHC) and WiFi and Ethernet servers in the /src/addons directory within your OnStep directory.  However, the Smart Web Server (SWS) is rapidly becoming a proven superior alternative to the WiFi and Ethernet Addons and I encourage its use.

Preliminary Firmware Configuration

Before you start with the configuration, you should use the Configuration Calculator spreadsheet to calculate your mount's specific parameters.

Instead of editing the Config.h file manually, you can use the web based Online Configuration Generator to get a basic working configuration fast.

The values from the spreadsheet are critical in matching OnStep to your hardware. This includes your final stage gear ratio (GR2), your secondary (transfer) gear ratio (GR1), the full steps per rotation of your stepper motors and how many microsteps each motor full step is divided up into by your stepper driver.  By default OnStep will operate at 1 degree/second slew speed.  If the mechanical design warrants it feel free to adjust the SLEW_RATE_BASE_DESIRED and/or the runtime slew rate controls up or down as required to determine what the best SLEW_RATE_BASE_DESIRED is for your hardware.

  1. Open the OnStep folder you downloaded/unzipped from GitHub.
  2. Double click on OnStep.ino file (inside the OnStep folder.) This opens the project so you can edit the configuration and upload the software.
  3. Select the tab for the Config.h file, Instructions for configuration are in that file.
  4. Near the top enter the selection for the PINMAP that matches your hardware.  For example if you have an OnStep MiniPCB2 controller you would use a Value of MiniPCB2 instead of OFF.
  5. A little further down is the MOUNT_TYPE parameter.  This defaults to GEM but for ALTAZM or FORK mounts you'll want to change it now.
  6. The AXIS1 RA/AZM section is next, enter the parameters from the spreadsheet: AXIS1_STEPS_PER_DEGREE, AXIS1_STEPS_PER_WORMROT.  Also, usually AXIS1_DRIVER_MODEL gets set to the type of stepper driver you're using (Config.h lists the types) and set AXIS1_DRIVER_MICROSTEPS to match the microstep mode you chose in the spreadsheet.
  7. The AXIS2 DEC/ALT section follows, enter the parameters from the spreadsheet: AXIS2_STEPS_PER_DEGREE.  Also, usually AXIS2_DRIVER_MODEL gets set to the type of stepper driver you're using (Config.h lists the types) and set AXIS2_DRIVER_MICROSTEPS to match the microstep mode you chose in the spreadsheet.
    *** Notice you can also reverse the direction of movement for each axis in this section using AXISn_DRIVER_REVERSE should that be required (and it frequently is.)  You'll want to evaluate/correct this, if necessary, once connected and "operational". ***
  8. You should review all of the other settings in the Config.h file to be sure they match your hardware.  Most of these are optional and OnStep will work reasonably well without changing them from the defaults.   Take a moment and read through...  these are the features OnStep supports and this is an excellent place to learn about them.  Each setting has a comment describing its purpose and available options.  Each section has a comment with a link to an online Wiki page with an expanded description of each setting.

Uploading the Firmware

After you have done the above, proceed with the configuration.  These are basic "generic" instructions for flashing a wide variety of OnStep hardware review the board's Wiki page for more specific instructions, if present:

  • In the Arduino IDE Tools menu select the correct board and port.
    • For the most part boards can be easily found by name but a few are tricky:
      • The ESP32 comes in many types but the ESP32 Dev Module using its default settings generally seems to work for the variants we use.
      • The FYSETC S6 is in 3D printer boards.
      • The STM32F103 BluePill is called BluePill F103CB (or C8 with 128KB).
  • Where the operating frequency can be changed I always use the default (not overclocked.)
  • Where the compiler optimizations can be changed I use Fastest (but NOT with LTO) except in one special case where the code would be too big:
    • The STM32F103 BluePill, where we need Smallest Code.
  • For these boards additional options in the Arduino IDE Tools menu need to be set and/or additional steps taken to upload:
    • For the ESP32S:
      • The Boot button on the module may need to be pressed for > 2 seconds to allow firmware upload.  Note, this shouldn't be needed with a MaxESP3.
    • For the STM32F103 and STM32F303 BluePill (these do not have an ROM based DFU "USB Device Firmware Upload" capable boot-loader):
      • Upload method STM32CubeProgrammer (Serial).
      • U(S)ART Support Generic Serial.  These use an external USB to serial adapter on the STM32's default serial port for firmware upload.
      • USB Support None (hence you should NEVER plug into the Bluepill USB port.)
      • Jumper Boot0 for firmware upload (HIGH, +) and power on.  Once done flashing power off and return the jumper to its normal (run) position.
      • On Linux, if you installed the stm32flash program, then use the command: stm32flash -g 0x8000000 -b 115200 -w /path/to/OnStep.ino.bin /dev/ttyUSB0
    • For the STM32F411 and STM32F401 BlackPill (these have an ROM based DFU capable boot-loader that works):
      • Upload method STM32CubeProgrammer (DFU).
      • U(S)ART Support Enabled (no generic 'Serial').
      • USB Support CDC (generic 'serial' superseded U(S)ART).  These use the STM32's built-in USB port for firmware upload.
      • Press and hold button BOOT0 while powering on or resetting then release BOOT0.
      • On Linux, if you installed the stm32flash program, then use the command: stm32flash -g 0x8000000 -b 115200 -w /path/to/OnStep.ino.bin /dev/ttyUSB0
    • For the STM32F446 FYSETC S6 (these have an Flash based DFU capable boot-loader that works):
      • Upload method STM32CubeProgrammer (DFU).
      • U(S)ART Support Generic Serial
      • USB Support CDC (generic 'serial' superseded U(S)ART).  These use the STM32's built-in USB port for firmware upload.
      • For the S6 v1 press and hold button BOOT0 while powering on or resetting then release BOOT0.
      • For the S6 v2 there is a three position pin header. jumper the LEFT (3.3V pin) to the center (BOOT0) to have it enter DFU mode then power on or reset.  Once done flashing remove the jumper for RUN mode.
      • On Linux, if you installed the dfu-util program, then use the command: dfu-util -a 0 -s 0x08010000 -D /path/to/OnStep.ino.bin

Then upload.

Verifying That OnStep Is Working

Once the upload of the firmware is complete, you should verify that OnStep is running on your board.

  • To do this, open Serial Monitor in the Arduino IDE, set the baud to 9600, connect the USB to your computer, then enter the following command:
    • :GVP#
  • If you get a response like this:
    • On-Step#
  • Then OnStep is working as intended on your board, and responding to commands.

  • Tip:
    • Some boards require an extra step here. For example, the STM32 Blue Pill, you need to first disconnect the USB cable, power off the board, and move the Flash/Run switch to the Run position.