Difference between revisions of "Programming the Device"

From OpenCircuits
Jump to navigation Jump to search
(→‎Software: del how to download RXTX driver)
Line 10: Line 10:
 
#[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.
 
#[http://chungyan5.no-ip.org/websvn/listing.php dsPicProgrammer] ('''dsPicProgrammer.jar''')
 
#[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===

Revision as of 19:46, 16 October 2008

Requirements

Hardware

  1. PC with COM port (Windows XP Installed for MPLAB)
  2. ICD2 Programmer
  3. Target Board
  4. 5V Power Supply

Software

  1. MPLAB IDE v7.50: v7.60 is not compatible with our current ICD2 Programmers. There are consistent "Devices cannot be founded" warnings.
  2. dsPicProgrammer (dsPicProgrammer.jar)

Files

  1. dsPicBootloader (bl_5011.hex). Original assembly code by ingenia can be downloaded from here.
  2. Application hex file (e.g. app.hex)


Loading Bootloader (Once only)

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 dsPIC30F5011
Target <-> ICD 2
  • Use six pin cable. Beware of the pin assignments. Only pin 1 - 5 should be used.
  • Place Jumper on target board (if any). The Jumper connects target Vcc to ICD 2.
  • Do NOT power-up the target.
ICD 2 <-> PC
  • Plug-in ICD 2 to PC via USB cable
  • Power-up the target.
  • 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.
Load Bootloader
  • Select: File>Import...
  • Select bl_5011.hex
Start Programming
  • Select: Programmer>Program
Finishing
  • Power-down the Taget
  • Select: Programmer>Select Programmer>None
  • Unplug USB cable


Loading Firmware

Java Environment Setup (Once only)

  • Download and install the latest JDK or JRE
  • Download and Extract RXTX Driver
    • Available from RXTX
    • File: rxtx-2.1-7-bins-r2.zip (Final)
    • Extract the files using software such as WinRAR
      1 2 rxtx.JPG
  • Copy RXTXcomm.jar to
    • For Windows users, C:\Program Files\Java\X\lib\ext (under the latest jre, e.g. X = jre1.6.0_03)
    • For Linux users, /usr/lib/jvm/java-version/jre/lib/ext
      1 3 rxtxcomm.JPG
  • Copy rxtxSerial.dll/librxtxSerial.so to
    • For Windows users, C:\Program Files\Java\X\bin (under the lastest jre, e.g. X = jre1.6.0_03)
    • For Linux users, /usr/lib/jvm/java-version/jre/lib/[machine type] (i386 for instance)
      1 4 rxtxserial.JPG
  • Download dsPicProgrammer
    • Available from here
    • directly download this package
    • Expand the latest tag under dsPicProgrammer
    • File: dsPicProgrammer.jar
      1 5 dspicprogrammer.JPG
    • Save the file (dsPicProgrammer.jar) and your hex file (foo.hex) to your local directory (e.g. C:\dsPicProgrammer\)
      1 6 dspicprogrammer2.JPG

Download Firmware

  • Start a Command Prompt
  • Run dsPicProgrammer
    • 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
2 3 command.JPG
  • When the program prompt you for an input, press y:
    File:2 4 prompt.JPG
  • If communication can be established, you should see something like this:
    2 5 progress.JPG
  • Wait until programming is completed.
    2 6 complete.JPG
  • after all completed, power OFF your device, then power ON again, enjoy your new updated.


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

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

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