Difference between revisions of "Programming the Device"

From OpenCircuits
Jump to navigation Jump to search
 
(32 intermediate revisions by 6 users not shown)
Line 1: Line 1:
==Requirements==
+
Description on how to use dsPicProgrammer to download firmware to [{{SERVER}}/DsPIC30F_5011_Development_Board DsPIC30F 5011 Development Board]
  
===Hardware===
+
==Loading Bootloader (Once only)==
#PC with COM port (Windows XP Installed for MPLAB)
+
 
 +
===Hardware Requirement===
 +
#PC with USB port (with Windows)
 
#ICD2 Programmer
 
#ICD2 Programmer
 
#Target Board
 
#Target Board
 
#5V Power Supply
 
#5V Power Supply
  
===Software===
+
===Software Requirement===
#[http://ww1.microchip.com/downloads/en/DeviceDoc/MP750.zip MPLAB IDE v7.50]: v7.60 is not compatible with our current [http://www.sure-electronics.com/ ICD2 Programmers]. There are consistent "Devices cannot be founded" warnings.
+
#[http://ww1.microchip.com/downloads/en/DeviceDoc/MP750.zip MPLAB IDE v7.50]: v7.60 is not compatible with our current [http://www.sure-electronics.com/ ICD2 Programmers]. There are consistent "Devices cannot be founded" warnings. See [http://www.sureelectronics.net/pdfs/DB-DP003.pdf manual] for details.
#[http://chungyan5.no-ip.org/websvn/listing.php dsPicProgrammer] ('''dsPicProgrammer.jar''')
 
#[http://users.frii.com/jarvi/rxtx/download.html RXTX driver]: download and upzip rxtx-2.1-7-bins-r2.zip (Final)
 
  
 
===Files===
 
===Files===
#[http://chungyan5.no-ip.org/websvn/listing.php dsPicBootloader] ('''bl_5011.hex'''). Original assembly code by ingenia can be downloaded from [http://www.ingenia-cat.com/download/iBL.s here].
+
#[http://chungyan5.no-ip.org/vc/?root=dspic_bootloader dsPicBootloader] ('''bl_$(MODEL).hex''').
#Application hex file (e.g. '''app.hex''')
 
 
 
  
==Loading Bootloader (Once only)==
+
===Procedure===
 
{|border="1" cellspacing="0" cellpadding="5"
 
{|border="1" cellspacing="0" cellpadding="5"
 
|+ Loading Bootloader
 
|+ Loading Bootloader
Line 32: Line 30:
 
*Run MPLAB IDE on PC
 
*Run MPLAB IDE on PC
 
*Select: Configure>Select Devices...
 
*Select: Configure>Select Devices...
*Choose dsPIC30F5011
+
*Choose the correct dsPic model
 
|-valign="top"
 
|-valign="top"
| Target <-> ICD 2  ||
+
| Load Bootloader ||
*Use six pin cable. Beware of the pin assignments. Only pin 1 - 5 should be used.
+
*Select: File>Import...
*Place Jumper on target board (if any). The Jumper connects target V<sub>cc</sub> to ICD 2.
+
*Select '''bl_$(MODEL).hex'''
*Do '''NOT''' power-up the target.
 
 
|-valign="top"
 
|-valign="top"
 
| ICD 2 <-> PC ||
 
| ICD 2 <-> PC ||
 
*Plug-in ICD 2 to PC via USB cable
 
*Plug-in ICD 2 to PC via USB cable
 +
|-valign="top"
 +
| Target <-> ICD 2  ||
 +
*Connect six pin cable to target board. Beware of the pin assignments. Only pin 1 - 5 are used.
 
*Power-up the target.
 
*Power-up the target.
 +
|-valign="top"
 +
| ICD 2 <-> PC ||
 
*Select: Programmer>Select Programmer>MPLAB ICD 2
 
*Select: Programmer>Select Programmer>MPLAB ICD 2
 
*If this is the first time the ICD 2 is connected to PC, MPLAB IDE will automatically download the required OS to ICD 2, wait until it has finished
 
*If this is the first time the ICD 2 is connected to PC, MPLAB IDE will automatically download the required OS to ICD 2, wait until it has finished
 
*If you have not connected and powered up the target, you might see Warnings on invalid device IDs, and/or running self tests.
 
*If you have not connected and powered up the target, you might see Warnings on invalid device IDs, and/or running self tests.
 
*See results of self test if necessary: Programmer>Settings, Status Tab. Refer to [http://ww1.microchip.com/downloads/en/DeviceDoc/51331B.pdf ICD2 User's Guide] Chapter 7.
 
*See results of self test if necessary: Programmer>Settings, Status Tab. Refer to [http://ww1.microchip.com/downloads/en/DeviceDoc/51331B.pdf ICD2 User's Guide] Chapter 7.
|-valign="top"
 
| Load Bootloader ||
 
*Select: File>Import...
 
*Select '''bl_5011.hex'''
 
 
|-valign="top"
 
|-valign="top"
 
| Start Programming ||
 
| Start Programming ||
 
*Select: Programmer>Program
 
*Select: Programmer>Program
 +
*Wait until finishes
 
|-valign="top"
 
|-valign="top"
 
| Finishing ||
 
| Finishing ||
*Power-down the Taget
+
*Power-down the Target
 
*Select: Programmer>Select Programmer>None
 
*Select: Programmer>Select Programmer>None
 
*Unplug USB cable
 
*Unplug USB cable
Line 62: Line 61:
  
  
==Loading Firmware==
+
==Download and Loading Firmware==
<!--using Firefox-File-Page_Setup-Format-Scale-85% to print -->
+
===dsPicProgrammer User Guide===
===Java Environment Setup (Once only)===
+
[http://chungyan5.no-ip.org/download/software/dsPicProgrammer/dsPicProgrammerUserGuide_V2.0.1.pdf dsPicProgrammerUserGuide_V2.0.1]
*Download and install the latest JDK or JRE
+
 
**Available from [http://java.sun.com/javase/downloads/index.jsp Sun Microsystems] (e.g. JDK 6 Update 3)<br>[[Image:1 1 java.JPG]]<br>
+
===Hardware Requirement===
*Download and Extract RXTX Driver
+
#PC (Linux/Windows) with COM Port OR USB-COM converter cable
**Available from [http://users.frii.com/jarvi/rxtx/download.html RXTX]
+
#Target Board (with bootloader)
**File: rxtx-2.1-7-bins-r2.zip (Final)
+
#5V Power Supply
**Extract the files using software such as WinRAR<br>[[Image:1 2 rxtx.JPG]]<br>
+
 
*Copy RXTXcomm.jar to
+
===Software Requirement===
**For Windows users, C:\Program Files\Java\X\lib\ext (under the latest jre, e.g. X = jre1.6.0_03)
+
#[http://chungyan5.no-ip.org/vc/?root=dspicProgrammer dsPicProgrammer]
**For Linux users, /usr/lib/jvm/java-version/jre/lib/ext<br>[[Image:1 3 rxtxcomm.JPG]]<br>
+
 
*Copy rxtxSerial.dll/librxtxSerial.so to
+
===Files===
**For Windows users, C:\Program Files\Java\X\bin (under the lastest jre, e.g. X = jre1.6.0_03)
+
#Application hex file (e.g. '''app.hex''')
**For Linux users, /usr/lib/jvm/java-version/jre/lib/[machine type] (i386 for instance)<br>[[Image:1 4 rxtxserial.JPG]]<br>
+
 
*Download dsPicProgrammer
+
===Procedure===
**Available from [http://chungyan5.no-ip.org/vc here]
+
 
**directly download this [http://chungyan5.no-ip.org/open_data/electronic_computer/platforms/dspic/dsPicProgrammer/dsPicProgrammer1.5.2.zip package]
+
====Setup COM Port====
**Expand the latest tag under dsPicProgrammer
+
[[Image:DSC00921.JPG | 480px]]
**File: dsPicProgrammer.jar<br>[[Image:1 5 dspicprogrammer.JPG]]<br>
+
*Connect your USB-COM converter cable to your computer
**Save the file (dsPicProgrammer.jar) and your hex file (foo.hex) to your local directory (e.g. C:\dsPicProgrammer\)<br>[[Image:1 6 dspicprogrammer2.JPG]]<br>
+
*Or Using a real COM PORT
 +
 
 +
 
 +
----
 +
=====Find out your COM port Number=====
 +
[[Image:1.jpg | 480px]]
 +
*Go to Control Panel \ Device Manager
  
===Download Firmware===
+
 
*Start a Command Prompt
+
----
**Start -> Run<br>[[Image:2 1 run.JPG]]<br>
+
[[Image:2.jpg | 480 px]]
**Enter cmd<br>[[Image:2 2 cmd.JPG]]<br>
+
*Find out your Device COM Port Number
*Run dsPicProgrammer
+
 
 +
 
 +
----
 +
====Get the Dspic Programmer====
 +
[[Image:programmer_3.jpg |480px]]
 +
*Download [http://chungyan5.no-ip.org/open_data/electronic_computer/platforms/dspic/dsPicProgrammer/dsPicProgrammer3.00.01s.zip dsPicProgrammer.zip], from [http://chungyan5.no-ip.org/open_data/electronic_computer/platforms/dspic/dsPicProgrammer/ws/ updated directory] or [http://chungyan5.no-ip.org/vc svn server]
 +
*Unzip the dsPicProgrammer.zip, then you have an unziped file.
 +
 
 +
 
 +
----
 +
====Download Firmware====
 +
[[Image:programmer_4.jpg |480px]]
 +
*Save your .hex file(foo.hex) to the folder called firmware.
 +
*Run dsPicProgrammer.bat (Windows) / dsPicProgrammer.sh (linux)
 
**Make sure your device is connected through a "Direct RS232 Cable" to PC Serial Port.  
 
**Make sure your device is connected through a "Direct RS232 Cable" to PC Serial Port.  
**Change to the directory where dsPicProgrammer.jar is located and run the command:
 
***[path/to/java/]java -Djava.library.path=[path/to/rxtxlib] -jar dsPicProgrammer.jar COM1 57600 foo.hex
 
****for example, jre\bin\java -Djava.library.path=.\rxtx\bin -jar dspicProgrammer.jar COM1 57600 foo.hex
 
***Or directly using dsPicProgrammer.bat COM1 57600 foo.hex(Windows)
 
***java -jar dsPicProgrammer.jar /dev/ttyS0 57600 foo.hex (Linux)
 
:::where COM1 is your COM Port ID
 
:::57600 is communication speed [in bps]
 
:::foo.hex is your firmware new file
 
::[[Image:2 3 command.JPG]]
 
:*When the program prompt you for an input, press y:<br>[[Image:2 4 prompt.JPG]]<br>
 
:*If communication can be established, you should see something like this:<br>[[Image:2 5 progress.JPG]]<br>
 
:*Wait until programming is completed.<br>[[Image:2 6 complete.JPG]]<br>
 
:*after all completed, power OFF your device, then power ON again, enjoy your new updated.
 
  
  
==Troubleshooting==
+
----
===Invalid COM Port===
+
[[Image:programmer_6.jpg |480px]]
*In case of selecting an invalid COM port, you should see the error message:<br>gnu.io.NoSuchPortException: Choosing COM Port Error<br>[[Image:3 1 com err.JPG]]<br><br>
+
*Choose a COM port
===Missing firmware file===
+
*Choose a baudrate
*In case of selecting a firmware file that does not exist, you should see the error message:<br>java.io.FileNotFoundException: foo1.hex <The system cannot find the file specified><br>[[Image:3 2 file err.JPG]]<br><br>
+
::115200 is communication speed [in bps]
===Missing RXTX driver===
+
 
*In case of missing the RXTX driver, you should see the error message:<br>Exception in thread “main” java.lang.NoClassDefFoundError: gnu/io/UnsupportedCommOperationException<br>[[Image:3 3 rxtx err.JPG]]<br><br>
+
 
 +
----
 +
[[Image:programmer_7.jpg |480px]]
 +
*Choose a .hex file
 +
 
 +
 
 +
----
 +
[[Image:programmer_8.jpg |480px]]
 +
*Press start
 +
*Then press Yes to confirm programming the device
 +
 
 +
 
 +
 
 +
----
 +
[[Image:programmer_9.jpg | 480px]]
 +
*The status during programming
 +
 
 +
 
 +
----
 +
[[Image:programmer_10.jpg |480px]]
 +
*The programming have been completed, press OK the close the message box
 +
 
 +
----
 +
===Troubleshooting===
 +
====Invalid COM Port====
 +
*In case of selecting an invalid COM port, you should see the error message:<br>''gnu.io.NoSuchPortException: Choosing COM Port Error''<br>[[Image:3 1 com err.JPG]]<br><br>
 +
*Solution: check the COM port ID, or close any programs that are using the COM Port
 +
====Missing firmware file====
 +
*In case of selecting a firmware file that does not exist, you should see the error message:<br>''java.io.FileNotFoundException: foo1.hex <The system cannot find the file specified>''<br>[[Image:3 2 file err.JPG]]<br><br>
 +
*Solution: check the file path
 +
====Missing RXTX driver====
 +
*In case of missing the RXTX driver, you should see the error message:<br>''Exception in thread “main” java.lang.NoClassDefFoundError: gnu/io/UnsupportedCommOperationException''<br>[[Image:3 3 rxtx err.JPG]]<br><br>
 +
*Solution:
 +
**Copy '''RXTXcomm.jar''' to '''/dsPicProgrammer/rxtx/lib'''
 +
**Copy '''rxtxSerial.dll''' to '''/dsPicProgrammer/rxtx/bin''' (Window)
 +
**Copy '''librxtxSerial.so''' to '''/dsPicProgrammer/rxtx/bin''' (Linux)
 +
====Missing JAVA====
 +
*In case of missing JAVA JDK or JRE, an error message will be prompted.
 +
*Solution:
 +
**Copy the contents under directory '''C:/Program Files/Java/jre$(VERSION)/''' to '''/dsPicProgrammer/jre'''
 +
 
 +
== Further reading ==
 +
 
 +
* [[PIC Programmers, In Circuit Programming and BootLoaders]]

Latest revision as of 23:29, 25 April 2012

Description on how to use dsPicProgrammer to download firmware to DsPIC30F 5011 Development Board

Loading Bootloader (Once only)

Hardware Requirement

  1. PC with USB port (with Windows)
  2. ICD2 Programmer
  3. Target Board
  4. 5V Power Supply

Software Requirement

  1. MPLAB IDE v7.50: v7.60 is not compatible with our current ICD2 Programmers. There are consistent "Devices cannot be founded" warnings. See manual for details.

Files

  1. dsPicBootloader (bl_$(MODEL).hex).

Procedure

Loading Bootloader
Step Remarks
Install MPLAB IDE
  • Do NOT connect ICD 2 (via USB) to PC
  • Execute MPLAB vX.XX Install.exe
Install USB Driver
  • Follow the instruction in (C:\Program Files\Microchip\MPLAB IDE\ICD2\Drivers\Ddicd2.htm)
Select Target Chip
  • Run MPLAB IDE on PC
  • Select: Configure>Select Devices...
  • Choose the correct dsPic model
Load Bootloader
  • Select: File>Import...
  • Select bl_$(MODEL).hex
ICD 2 <-> PC
  • Plug-in ICD 2 to PC via USB cable
Target <-> ICD 2
  • Connect six pin cable to target board. Beware of the pin assignments. Only pin 1 - 5 are used.
  • Power-up the target.
ICD 2 <-> PC
  • Select: Programmer>Select Programmer>MPLAB ICD 2
  • If this is the first time the ICD 2 is connected to PC, MPLAB IDE will automatically download the required OS to ICD 2, wait until it has finished
  • If you have not connected and powered up the target, you might see Warnings on invalid device IDs, and/or running self tests.
  • See results of self test if necessary: Programmer>Settings, Status Tab. Refer to ICD2 User's Guide Chapter 7.
Start Programming
  • Select: Programmer>Program
  • Wait until finishes
Finishing
  • Power-down the Target
  • Select: Programmer>Select Programmer>None
  • Unplug USB cable


Download and Loading Firmware

dsPicProgrammer User Guide

dsPicProgrammerUserGuide_V2.0.1

Hardware Requirement

  1. PC (Linux/Windows) with COM Port OR USB-COM converter cable
  2. Target Board (with bootloader)
  3. 5V Power Supply

Software Requirement

  1. dsPicProgrammer

Files

  1. Application hex file (e.g. app.hex)

Procedure

Setup COM Port

DSC00921.JPG

  • Connect your USB-COM converter cable to your computer
  • Or Using a real COM PORT



Find out your COM port Number

1.jpg

  • Go to Control Panel \ Device Manager



2.jpg

  • Find out your Device COM Port Number



Get the Dspic Programmer

Programmer 3.jpg



Download Firmware

Programmer 4.jpg

  • Save your .hex file(foo.hex) to the folder called firmware.
  • Run dsPicProgrammer.bat (Windows) / dsPicProgrammer.sh (linux)
    • Make sure your device is connected through a "Direct RS232 Cable" to PC Serial Port.



Programmer 6.jpg

  • Choose a COM port
  • Choose a baudrate
115200 is communication speed [in bps]



Programmer 7.jpg

  • Choose a .hex file



Programmer 8.jpg

  • Press start
  • Then press Yes to confirm programming the device



Programmer 9.jpg

  • The status during programming



Programmer 10.jpg

  • The programming have been completed, press OK the close the message box

Troubleshooting

Invalid COM Port

  • In case of selecting an invalid COM port, you should see the error message:
    gnu.io.NoSuchPortException: Choosing COM Port Error
    3 1 com err.JPG

  • Solution: check the COM port ID, or close any programs that are using the COM Port

Missing firmware file

  • In case of selecting a firmware file that does not exist, you should see the error message:
    java.io.FileNotFoundException: foo1.hex <The system cannot find the file specified>
    3 2 file err.JPG

  • Solution: check the file path

Missing RXTX driver

  • In case of missing the RXTX driver, you should see the error message:
    Exception in thread “main” java.lang.NoClassDefFoundError: gnu/io/UnsupportedCommOperationException
    3 3 rxtx err.JPG

  • Solution:
    • Copy RXTXcomm.jar to /dsPicProgrammer/rxtx/lib
    • Copy rxtxSerial.dll to /dsPicProgrammer/rxtx/bin (Window)
    • Copy librxtxSerial.so to /dsPicProgrammer/rxtx/bin (Linux)

Missing JAVA

  • In case of missing JAVA JDK or JRE, an error message will be prompted.
  • Solution:
    • Copy the contents under directory C:/Program Files/Java/jre$(VERSION)/ to /dsPicProgrammer/jre

Further reading