PART I of III
Step1/a download Arduino 1.5.2 BETA Mac OS X from http://downloads.arduino.cc/arduino-1.5.2-macosx.zip
Step1/b unzip and copy the resulting Arduino(.app) into “Applications” folder
Step2 follow Jantje’s instructions on http://trippylighting.com/teensy-arduino-ect/arduino-eclipse-plugin/arduino-eclipse-ide-and-plugin-v2-2-installation/, or follow my method:
Step2/a download Eclipse Kepler 32 bit version from www.eclipse.org/downloads/packages/technologyeppdownloadsreleasekeplersr2eclipse-cpp-kepler-sr2-macosx-cocoatargz (as Jantje suggests Kepler and 32 bit version is important)
Step2/b unarchive then copy the resulting “eclipse” folder into “Applications” folder
Step2/c launch Eclipse from /Applications/eclipse (waiting several seconds after previous copy operation it can be launched from Spotlight as well)
Step2/d “Select a workspace” (mine is /Users/xxxx/Documents/Arduino) and be sure that there are not an old eclipse workspace directory with the same name in that directory
Step2/e close “Welcome screen” then install “Arduino Eclipse Plugin V2.2” as follows:
Arduino Eclipse plugin
Step3 Jantje’s Arduino Eclipse plugin can be installed based on his instructions (see step 2 above) or from “Eclipse Marketplaces” as well:
Step3/a click on “Help/Eclipse Market Places…”, search for “arduino" in “Find:” field, then “Install” “Arduino Eclipse IDE V2” (press “Confirm”, check “I accept…”, press “Finish”, OK for “Security Warning”, Yes for “… restart …”)
Step3/b after Eclipse IDE restarting you should “integrate” Arduino plugin into Eclipse: click on “Eclipse/Preferences…”, then chose “Arduino”. On the left side the only missing parameter is where Eclipse can find Arduino. If you copied “Arduino” (in step 1) into “Applications” folder, you should give this information. Click “Browse” then navigate to “/Applications/Arduino(.app)”. The warning at top of the panel disappears, the “Library” and “Hardware” path has already show into our Arduino workspace, so you can click OK.
Step3/c now you have a full function Arduino Eclipse development environment but “equipped” with only the classical (and stupid) Serial “debugging” println function.
Step3/d there is very useful information about Workspace preferences in http://gnuarmeclipse.livius.net/blog/workspace-preferences/. It is almost mandatory for every Arduino Eclipse developer.
Step4 buy a cheap J-Link adapter like “USB-MiniJTAG J-Link JTAG/SWD” for USD $13 (USB-MiniJTAG JTAG/SWD Debugger/Emulator [USB-MiniJTAG] - US $13.00 : HAOYU Electronics : Make Engineers Job Easier) or for USD $22 (eBay) or their famous original non-hacked version for 60 USD (https://www.segger.com/j-link-edu.html)
J-Link GDB server
Step5 for communication with this little adapters you need their GDB server program from SEGGER (https://www.segger.com/jlink-software.html):
Step5/a for the latest version click the “Download” button on the “J-Link software & documentation pack for MAC” section
Step5/b install the downloaded “JLink_MacOSX_Vxxx.pkg”: “Continue”, “Continue”, “Agree”, “Continue”, “Install”, “Password”, “Install Software”, “Close”)
5(c) It makes a SEGGER directory in “Applications”, the GDB server in its “JLink” subdirectory, called “JLinkGDBServer”
Connecting J-Link adapter to Arduino Due
Step6 connecting J-Link adapter to Arduino Due is simple. The board has two debug connectors which have almost the same pins. A bigger one with 4 pins close to GND,13,12,11 pins with DEBUG label below it. It is the so called JTAG/SWD connector (JTAG means a debugging standard [http://en.wikipedia.org/wiki/Joint_Test_Action_Group]. SWD means Serial Wire Debug, a 2-pin alternative of JTAG with only a clock [SWDCLK] and data line [SWDIO]. The other two pins are Reset, and GND pins.
There is also a smaller 10-pin Cortex connector, at the bottom left corner of the previous one, implementing full JTAG with TMS,TCK,TDO,TDI and Reset pins. Insisting to the USD $13 budget, and based on the fact that JTAG/SWD connector has most of these and all necessary pins for debugging, it is absolutely not necessary to buy, but it is worth to mention that there are “20-pin Standard to 10-pin Cortex Adapters for ARM JTAG Programmer” which can connect your J-Link adapters and this 10-pin debug connector of Arduino Due more elegantly (e.g.: http://microcontrollershop.com/product_info.php?products_id=4650)
Good overview about these pins and connectors can be found in this forum as well on page http://forum.arduino.cc/index.php?topic=132130.0
Step6/a my cheap solution based on a 4 wire strip/flat cable with 2.54 mm pin connectors (OK, it is an additional cost of USD 1$) and some clever cross-connections based on http://forum.arduino.cc/index.php/topic,134907.0.html but only to the 4-pin debug connector (See the first picture below)
Step6/b pin1 of JTAG/SWD (close to GND pin above) is Master-Reset which should be connected to pin 15 of the 20-pin connector of J-Link adapter (pin 1 of the 20-pin connector is marked with a tiny triangle, numbering can be learned from the drawing of the previous link).
Step6/c pin2 of JTAG/SWD (close to pin 13 above) is SWDIO, connected to pin 7 of J-Link adapter
Step6/d pin3 of JTAG/SWD (close to pin 12 above) is SDWCLK, connected to pin 9 of J-Link adapter
Step6/e pin4 of JTAG/SWD (close to pin 11 above) is GND, connected to any even numbered pin of J-Link adapter
See the second picture below
6(f) finally plug the USB connector of J-Link adapter into you Mac computer which detects and connects to it automatically and seamlessly.
Connecting J-Link GDB server to adapter
Step7 you can check your adapter and server connection by starting GDB server from command line: open a “Terminal” program either from “Applicaton/Utilities” or from “Spotlight”, then launch the earlier installed SEGGER’s JLinkGDBServer. Type the following command after the prompt of the Terminal program:
/Applications/SEGGER/JLink/JLinkGDBServer -if SWD
“-if SWD” option tells GDBServer to use SWD protocol instead of the default JTAG protocol. There are many information scrolling across the display: telling that “GDB Server Listening port number” is 2331; “J-Link Host Interface” is the earlier plugged USB; our adapter, the “Target interface” communicates via the specified SWD protocol; and if everything went well the final line of the Terminal shows “Waiting for GDB connection”. Your GDB server is working and waiting for commands from a GDB client. GDB client will be launched, used, programmed and commanded by/from Eclipse performing our long waited “visual in-circuit” debugging functionalities.
Step7/a leave “Terminal” program with the waiting GDBServer alone and setup Eclipse debug functions:
Eclipse GDB Hardware Debugging plugin
Step8 Although Jantje’s Arduino Eclipse plugin brings all C/C++ compiling, building and Arduino sketch uploading functions into Eclipse environment it lacks of the desired “visual in-circuit” debug functions. So you should install Eclipse GDB Hardware plugin:
Step8/a click on “Help/Install New Software”, choose “Kepler - …” in the “Work with:” field, choose “Mobile and Device Development”, then select/check “C/C++ GDB Hardware Debugging” from the list.
Step8/b click “Next”, then “Next” again, check “I accept …”, press “Finish”, then “Yes” for “… restart …”.