Last edited · 124 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 STABLE (at the top of the page) version (supported by Teensyduino if that's required) but not the "Windows app" version or "Release Candidate, "hourly builds", Beta versions, etc.

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.
  • There are also flashing instructions on the FYSETC S6 Wiki page near the bottom.

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/main/package_stmicroelectronics_index.json
    • Install support for this board from within the menu Tools>Board>Boards Manager.
      • Use STM32 libraries version 2.2.0
      • On Windows, for the FYSETC S6 (STM32F446) version 2.1
        • You must flash the older Bootloader-FYSETC_S6_10000.hex using the STM32 CubeProgrammer as the newer one doesn't work for us.  Instructions for flashing the bootloader are on this same Wiki page linked here where you download it from.
      • On Windows, for the FYSETC S6 (STM32F446) any version
        • You must also find the "stm32CubeProg.sh" file by searching in C:\Users\~\AppData\Local\Arduino15 then using Notepad edit it and change the ADDRESS= line from 0x8000000 to 0x8010000.
          • Note that Windows has the AppData folder set to hidden, so you have to show hidden files or navigate directly into it even though you don't see it.
          • This script file change corrects the Arduino IDE/OnStep firmware upload so it doesn't overwrite the bootloader; if you accidentally overwrite it you have to flash the bootloader again using the instructions above.
        • 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 generally 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.)

Note: More experienced OnStep users should feel free to try OnStepX instead of OnStep at this point.  It isn't as well tested but it has reached apparent stability; and the design/feature set go well beyond what OnStep offers.

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 release-4.24 directory however they are now approaching obsolescence.  The Smart Web Server (SWS) and Smart Hand Controller (SHC) are rapidly becoming proven superior alternatives to those old Addons and I encourage their use.

Getting the Additional Libraries

There are several additional Arduino libraries that OnStep and its companion software might need depending on the Config.h options enabled.

Download and unzip the archive contents in your ~/Documents/Arduino/libraries folder to add support for any of these if needed.

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:

  • Where default settings apply I generally don't list them below.
  • 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 before upload:
    • For the ESP32S:
      • These use an external USB to serial adapter on the default serial port for firmware upload.  This is the ESP32S module's USB port, simply plug in.
      • Board ESP32 Dev Module.
      • The Boot button on the module may need to be pressed for > 2 seconds to allow firmware upload.
    • For the BluePill STM32F103 and STM32F303:
      • These use an external USB to serial adapter on the STM32's default serial port for firmware upload.  Never use the USB port on the microcontroller, plug into the USB port on the Bluepill board instead!
      • Board Generic STM32F1 series, Board part number BluePill STM32F103CB (or C8 with 128kb) OR...
      • Board Generic STM32F3 series, Board part number RobotDyn STM32F303CC.
      • Upload method STM32CubeProgrammer (Serial).
      • U(S)ART Support Generic Serial.
      • Optimize Smallest (-Os default) or Smallest (-Os) with LTO (for even less flash memory use.)
      • USB Support None.
      • 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 (default USB port) capable boot loader for firmware upload.
      • Board Generic STM32F4 series, Board part number BlackPill F411CE (or BlackPill F401CC).
      • Upload method STM32CubeProgrammer (DFU).
      • U(S)ART Support Enabled (no generic 'Serial').
      • USB Support CDC (generic 'serial' superseded U(S)ART).
      • 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 (default USB port) capable boot loader for firmware upload.
      • Board 3D printer boards, Board part number FYSETC_S6.
      • Upload method STM32CubeProgrammer (DFU).
      • U(S)ART Support Generic Serial
      • USB Support CDC (generic 'serial' superseded U(S)ART).
      • 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.
      • For the S6 v2 some users have reported success only after flashing with Marlin prior to flashing OnStep.
      • Again, for Linux there are flashing instructions on the S6 Wiki page near the bottom.

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.