Showing posts with label Mac OSX. Show all posts
Showing posts with label Mac OSX. Show all posts

Tuesday, 8 March 2016

Updating RepRapFirmware and PanelDue firmware using Mac OS X as a host

(Guest post by Michael Hackney, SublimeLayers.blogspot.com and www.EclecticAngler.com)

Recently, I worked out the process for updating Duet and PanelDue using a Macintosh computer as a host. Once you have the right tools and information, it's quite simple. I've tested this on Mac OS X Yosemite and El Capitan.

Firmware updates for both the Duet and PanelDue are performed via USB. Before we can update that firmware though, we need to install the right tool. This tool is called BOSSA and is an Open Source flash programmer for the Atmel SAM microcontroller used on both the Duet and PanelDue. Unfortunately, there are many different versions of BOSSA, including both command line (BOSSAC) and GUI versions, but only a few of them will actually work! Not to worry, I'll make sure you get a workable version.

1) Get BOSSAC
You can get the BOSSAC command line utility with the Arduino IDE 1.6.1 release. This release is no longer supported but since you can install multiple versions of Arduino IDE on OS X, it isn't an issue to install it. Another option is to find a copy of the BOSSAC utility and use that. I've extracted BOSSAC from the Arduino 1.6.1 IDE and made it available on my Google drive: BOSSAC for Mac OS X.

2) Get the new firmware
Once you have the BOSSAC utility, you need to download the firmware you are planning to install. These are found on David Crocker's GitHub here:

RepRapFirmware-dc42
PanelDue firmware

I like to keep the BOSSAC utility and the firmware versions all in one place in a single folder for convenience.

3) Find the Duet's or PanelDue's port number
This is the most finicky step in the process but this should make it a little easier. The tricky part is that the device we need is not available until you press the Erase and Reset buttons on the Duet or PanelDue. But, there already may be devices with similar names so it isn't obvious which one to use. So, I look in the device directory (/dev) first, then Erase-Reset the board and then look in the device directory again to see what's new!

  • Launch the Terminal application and type "cd /dev" and press [return] (without the quotes). /dev is the directory where Mac OS X keeps all of its device files.
  • There are lots of devices in the directory but we are only interested in a particular type. You can see everything by issuing the "ls" command. But to narrow it down to the USB device we need, run "ls | grep tty.usbmodem". 
  • Now hook up the USB cable to your Duet or PanelDue and press the Erase button and then the Reset button. 
  • Run "ls | grep tty.usbmodem" again and watch the output for the new device that should be found. It will look something like tty.usbmodem14444421 but most likely with a different number sequence.
4) Run BOSSAC
Now we're ready to flash the new firmware. I'll show two ways of doing this depending on if you are using the Arduino IDE BOSSAC or the "naked" BOSSAC. In both cases you run BOSSAC from a Terminal window, so launch Terminal if needed. Then, "cd" into the folder where you keep your firmware .bin files to make it easier.

4a) Running BOSSAC from the Arduino IDE
Type the following command into the Terminal window but replace the YOUR_PORT_# with the port number you found in step 3 and the firmware version you are uploading. Note that this assumes several things: 1) that you installed the Arduino 1.6.1 IDE in your Applications folder and that you have "cd" into the folder that contains the firmware. Make sure you type it exactly and don't forget the "-R" at the end:
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/bossac --port=tty.YOUR_PORT_# -U true -e -w -v -b RepRapFirmware-1.09o-dc42.bin -R

4b) Running BOSSAC directly
This example assumes that you have placed the bossac utility in the same folder with your firmware .bin file and you have "cd" into the folder in a Terminal window. Make sure you type it exactly and don't forget the "-R" at the end:

./bossac --port=tty.YOUR_PORT_# -U true -e -w -v -b RepRapFirmware-1.09o-dc42.bin -R

Here is an example of what you should from bossac as it runs:
./bossac --port=tty.usbmodem1444431 -U true -e -w -v -b RepRapFirmware-CHTest-3.bin -RErase flashWrite 309308 bytes to flash[==============================] 100% (1209/1209 pages)Verify 309308 bytes of flash[==============================] 100% (1209/1209 pages)Verify successfulSet boot flash trueCPU reset.
When bossac finishes, it resets the board and you are ready to go.



Friday, 26 February 2016

How to compile RepRapFirmware-dc42 for Duet on Mac OS X

(Guest post by Michael Hackney, SublimeLayers.blogspot.com and www.EclecticAngler.com)

As RepRapFirmware gains momentum, more users will want to contribute to its development. There are some good resources for setting up a development environment for Windows computers but very few resources for developing on Mac OS X. I tried for several months to setup my environment and wasn't able to, so I pushed forward and started with a clean slate and documented every step along the way.  Now that it's done, I can install the development environment from scratch in about 15 minutes.

As I discovered, one of the more significant challenges I confronted was the interdependence of specific versions of the various tools and even the operating system. I worked through each of these with the goal of using the most up-to-date version for each component possible, starting with the operating system. Please pay particular attention to these versions as you work through the setup process - they are highlighted in bold. I highly recommend starting with the specific versions I used and once you have your environment running, update components one at a time if necessary. And if you do that successfully, please leave a comment here so others can benefit.

The reference date for this process is 2/14/2016.

Start with your Macintosh updated to Mac OS X: El Capitan 10.11.3 I have not attempted this on earlier versions of OS X so if you are successful, please leave a comment. I'll also leave comments when new versions of OS X come out.

1) Get the tools and setup the basic environment

The first step is to download the development tools. This development environment is based on the Open Source Eclipse IDE. However, a special plug-in to integrate the Arduino tools is required. Putting together this environment was a big challenge but now there is a pre-built Arduino Eclipse  IDE that eliminates the grunge work. A big thanks goes out to Jantje for this work!
Create a folder to use for the root of everything. Please note, once you start this process you can not change the path later. Eclipse is very finicky about installation path so pick something you can live with. Also, DO NOT include spaces in the pathname. NONE!  I created a folder named "Development" on my desktop and will use that for this document. My path looks like:

/Users/mhackney/Desktop/Development

Now copy the Eclipse tar file and Arduino file into Development and unpackage them (on OS X you can simply double-click the tar file to untar it). You can delete the tar file once you've unpackaged it.

Next, open the Arduino.app package (by control-clicking it's icon) and navigate to /Contents/Resources/Java
  • Copy the /libraries and /hardware folders into your Development folder.
At this point, your Development folder should look like:
  • Create a folder named workspace inside the eclipseArduino folder.
2) Configuring Eclipse

Now you can launch he Eclipse application - called eclipseArduinoIDE in the eclipseArduino folder. When Eclipse asks you for the workspace, click [Browse...] and navigate to your Development/eclipseArduino/workspace folder and click the [Open] button. Check the "Use this as default" box and click [OK].

Click the EclipseArduinoIDE menu and choose "Preferences..." then select the Arduino tab in the list on the left. 
  • Set the "Arduino IDE path" to your Arduino.app
  • Set the "Private Library path" to the library folder you copied to your Development folder
  • Set the "Private Hardware path" to the hardware folder you copied to your Development folder
  • Click Apply then [OK] (choose [OK] for the dialogs that tell you Arduino is newer than the plugin)
Here's what the dialog should look like (with your Development path substituted of course) when you are done:


Next, click the Arduino menu and select New Sketch. Set the project name to RepRapFirmware and then make sure sam/boards.txt is selected. Select Arduino Due (Native USB Port) for board. You can set the COM port now also but if you don't know it, it can be set later.

Quit Eclipse.

3) Setup the RepRapFirmware

Download the latest version of dc42 dev branch of RepRapFirmware: https://github.com/dc42/RepRapFirmware (Click the [Download ZIP] button at the upper right). At this writing version 1.09r-dc4 is the latest). Copy all of the files to the RepRapFirmware folder in your workspace folder.

Copy the patched libraries out of RepRapFirmware/ArduinoCorePatches into the Arduiuno.app package. The path is Arduino.app/Contents/Resources/Java/hardware/arduino/sam. Use the "Merge" option and "Apply to All" when the copy dialog asks what to do. Remove the ArduinoCorePatches folder from the RepRapFirmware folder (you can delete it).

Launch EclipseArduinoIDE and setup the project like this:
  • Remove the RepRapFirmware.ino file from the RepRapFirmware Project list on the left - this will delete it from the filesystem too.
  • Select the RepRapFirmware project in the Project Explorer and control-click and select Refresh. All of the source files should appear in the list.
  • Select the RepRapFirmware project in the Project Explorer and control-click and select Index->Rebuild. 
Select the RepRapFirmware project in the Project Explorer and control-click and select Properties... at the bottom of the menu.
    • Find the C/C++ General/Paths and Symbols page. Now you need to add each of the library folders in the workspace/RepRapFirmware/Libraries folder to the GNU C list. Do this by clicking the [Add...] button. Then check the Add to all languages box and click the [File system...] button to navigate to the workspace/RepRapFirmware/Libraries/EMAC (the first folder library to add). Do this for each of the folders in the Libraries folder. It's a little tedious but gets the job done. 
    • You also have to explicitly add SD_HSMC/utility the same way.
    • You also have to add hardware/arduino/sam/system/libsam/include (this is the hardware folder you copied to your Development folder)
    • Then click [Apply] and click [Yes] to rebuild the indexes.
    When you are finished, your list should look like this:
    • Next click the C/C++ Build/Environment tab on the left list. 
      • Set JANTE.EXTRA.C.COMPILE to -std=gnu99 
      • Set JANTJE.EXTRA.CPP.COMPILE to -std=gnu++11
      • Find the A.BUILD.USB FLAGS variable and remove the manufacturer and product part - it looks like this: 
        • '-DUSB_MANUFACTURER=${A.BUILD.USB_MANUFACTURER}' '-DUSB_PRODUCT=${A.BUILD.USB_PRODUCT}'
      • Now find all occurances of the compiler flag "-Os" and change them to "-O2". This is in:
        • A.COMPILER.C.ELF.FLAGS
        • A.COMPILER.C.FLAGS
        • A.COMPILER.CPP.FLAGS
      • Remove the '-w' option in A.COMPILER.C.FLAGS and A.COMPILER.CPP.FLAGS
      • Click the [Apply] button and click [OK] to exit the dialog
    That's It!

    It might seem a little tedious but you'll be rewarded with a RepRapFirmware development environment when you are done. I've successfully installed on four different Mac computers.

    If you have any questions, comments or additions please post a comment.