Ds30 Loader Main Manual
Ds30 Loader Main Manual
ds30 Loader
Main manual
Table of contents
Table of contents ........................................................................................................................ 2
Introduction................................................................................................................................ 5
ds30 Loader ............................................................................................................................ 5
Prerequisites and Requirements ............................................................................................ 5
Trademarks............................................................................................................................. 5
Why use a boot loader ........................................................................................................... 5
Usage .......................................................................................................................................... 6
Operating system considerations........................................................................................... 6
Windows ............................................................................................................................. 6
Linux ................................................................................................................................... 6
Mac OS X ............................................................................................................................ 6
Install the required tool suite ................................................................................................. 6
Modify firmware settings ....................................................................................................... 6
Build the firmware.................................................................................................................. 6
Write firmware ....................................................................................................................... 6
Prepare the application .......................................................................................................... 7
Setup the host application ..................................................................................................... 7
Write the application ............................................................................................................. 7
Procedure 1 ........................................................................................................................ 7
Procedure 2 ........................................................................................................................ 7
Procedure 3 ........................................................................................................................ 7
Wait for the write operation to complete. ............................................................................ 7
Firmware matrix ......................................................................................................................... 8
Clients ......................................................................................................................................... 9
Console ................................................................................................................................... 9
GUI .......................................................................................................................................... 9
API........................................................................................................................................... 9
CAN ........................................................................................................................................... 10
Lawicel .................................................................................................................................. 11
IXXAT .................................................................................................................................... 11
Vector ................................................................................................................................... 11
Configuration ............................................................................................................................ 12
Basic settings ........................................................................................................................ 12
Port name ......................................................................................................................... 12
Baud rate .......................................................................................................................... 12
Write flash ........................................................................................................................ 12
Write eeprom ................................................................................................................... 12
Read flash ......................................................................................................................... 12
Read eeprom .................................................................................................................... 12
Serial ..................................................................................................................................... 12
Flow control...................................................................................................................... 12
CAN ....................................................................................................................................... 12
PIC ID ................................................................................................................................ 12
GUI ID ............................................................................................................................... 12
Extended frames .............................................................................................................. 13
DLC.................................................................................................................................... 13
Advanced .............................................................................................................................. 13
Don’t write goto to the user application.......................................................................... 13
Allow overwrite of the boot loader.................................................................................. 13
Write configuration bits ................................................................................................... 13
Custom boot loader.......................................................................................................... 13
Auto baud rate ................................................................................................................. 13
Echo verification ............................................................................................................... 13
Put CRC before goto ......................................................................................................... 14
Don’t write empty pages .................................................................................................. 14
Don’t set goto to bl at 0x00.............................................................................................. 14
Timing ................................................................................................................................... 14
Hello timeout.................................................................................................................... 14
Poll time............................................................................................................................ 14
Timeout ............................................................................................................................ 14
Delay after port open ....................................................................................................... 14
Reset ..................................................................................................................................... 14
RTS .................................................................................................................................... 14
DTR ................................................................................................................................... 14
Command ......................................................................................................................... 15
ID ...................................................................................................................................... 15
DLC.................................................................................................................................... 15
Baud rate .......................................................................................................................... 15
Activation ............................................................................................................................. 15
RTS .................................................................................................................................... 15
DTR ................................................................................................................................... 15
Security ................................................................................................................................. 15
Password .......................................................................................................................... 15
Operation ................................................................................................................................. 16
Parsing of hex‐file ................................................................................................................. 16
Validation ......................................................................................................................... 16
Data collection.................................................................................................................. 16
Check of data that could overwrite the boot loader ....................................................... 16
Check and move of GOTO ................................................................................................ 16
Counting of data ............................................................................................................... 16
Set GOTO to boot loader .................................................................................................. 16
Write ..................................................................................................................................... 16
Raise of process priority ................................................................................................... 16
Device reset ...................................................................................................................... 16
Auto baud rate ................................................................................................................. 16
Find boot loader ............................................................................................................... 17
Determine boot loader size .............................................................................................. 17
Parse hex‐file .................................................................................................................... 17
Write ................................................................................................................................. 17
Boot loader upgrade procedure ............................................................................................... 18
Troubleshooting ....................................................................................................................... 19
Known issues ........................................................................................................................ 19
Error messages ..................................................................................................................... 19
HW schematics ......................................................................................................................... 21
UART / software UART ......................................................................................................... 21
Components ..................................................................................................................... 21
Schematic ......................................................................................................................... 21
CAN ....................................................................................................................................... 22
Components ..................................................................................................................... 22
Schematic ......................................................................................................................... 22
Appendix A – Links ................................................................................................................... 23
Appendix B – memory map ...................................................................................................... 24
Appendix C – Write time samples ............................................................................................ 25
Appendix D ‐ Files ..................................................................................................................... 26
Package content ................................................................................................................... 26
Files created by ds30 Loader ................................................................................................ 26
Introduction
ds30 Loader
ds30 Loader is a boot loader supporting PIC12, PIC16, PIC18, PIC24, dsPIC, and PIC32 families
of MCUs from Microchip. It supports all devices in each family out of the box (those in
production). The firmware is written in assembler. The PC clients run on Windows, Linux,
and Mac OS X.
Trademarks
All rights to copyrights, registered trademarks, and trademarks reside with their respective
owners.
Drawbacks of using a boot loader include added boot‐up time and increased flash memory
usage.
Usage
Operating system considerations
Windows
N/A
Linux
The user running ds30 Loader should be a member of the dialout group. To add a user in the
dialout group run the following command as a super user:
useradd –G dialout username
Mac OS X
The user running ds30 Loader should have sufficient rights to read from and write to the
desired port.
Write firmware
Write the firmware to your device using your favorite programmer. For detailed information,
refer to the firmware manual.
Procedure 1
1. Press the write button in the GUI.
2. Reset the PIC/dsPIC.
Procedure 2
1. Reset the PIC/dsPIC.
2. Press the write button in the GUI before the boot loader times out.
This procedure may be more reliable than procedure 1.
Procedure 3
0. Implement a reset command in the application. See the reset part in the
configuration section in this document for more information.
1. Configure the reset command under the reset the in the GUI. Advanced mode need
to be enabled first.
2. Press the write button in the GUI.
Firmware matrix
The following firmwares are available. For detailed information refer to the firmware
manual.
Clients
Console
It is a command line interface that runs on Windows, Linux, and MAC OS X. Refer to the
console manual for more information.
GUI
It is a graphical user interface that runs on Windows, Linux, and MAC OS X. Refer to the GUI
manual for more information.
API
The API is used to integrate boot loader functionality in a .NET application. It is ordered
separately; contact MG Digital Solutions for more information.
CAN
The ds30 Loader supports boot loading on the CAN bus. See table 1 for available firmwares
and table 2 for supported CAN adapters. CAN operation is not available in the free edition.
Lawicel
There may be issues related to Lawicel CAN adapters, see the Trouble shooting‐Known issues
section in this document.
The Lawicel CAN232 adapter is shipped with the baud rate set to 57600. The baud rate can
be increased for a performance improvement; it is done in the configuration window
available in ds30 Loader GUI. The serial interface baud rate cannot be changed with the ds30
Loader console application.
If the ds30 Loader console application is used, the serial interface baud rate must be set
manually in the Lawicel port configuration file to reflect the baud rate the Lawicel adapter is
configured for.
IXXAT
There may be issues related to IXXAT CAN adapters, see the Trouble shooting‐Known issues
section in this document.
The bitrates can be fully customized by editing the ixxatBitRates.xml file. It is located in the
same directory as the ds30 Loader executables.
Vector
The bitrates can be fully customized by editing the vectorBitRates.xml file. It is located in the
same directory as the ds30 Loader executables.
Configuration
This section is valid for ds30 Loader GUI, ds30 Loader console and the ds30 Loader API.
Basic settings
Port name
The name of the port that will be used to communicate with the boot loader firmware.
Baud rate
The baud/bit rate that the port will be setup for prior to communicating with the boot loader
firmware.
Write flash
When checked, the flash memory is written during a write operation. This is disabled if the
chosen hex‐file does not contain any program memory locations.
Write eeprom
When checked, the eeprom memory is written during a write operation. This is disabled if
the chosen hex‐file does not contain any eeprom memory locations.
Read flash
When checked, the flash memory is read during a read operation.
Read eeprom
When checked, the eeprom memory is read during a read operation.
Serial
Flow control
Sets the serial port flow control mode.
CAN
PIC ID
This setting is only available for CAN ports, it specifies the PIC CAN ID, and it should be set to
the same value as in the boot loader firmware. This can be entered as decimal (example 10)
or hex (example 0xa).
GUI ID
This setting is only available for CAN ports. It specifies GUI CAN ID and it should be set to the
same value as in the boot loader firmware. This can be entered as decimal (example 10) or
hex (example 0xa).
Extended frames
When set extended frames are sent and only extended frames are received.
DLC
This setting determines how many bytes of data will be send in each CAN frame. Not that
not all CAN firmwares support high DLC than 1.
Advanced
This page contains advanced settings that are normally not used.
Echo verification
If the device hardware or firmware is set‐up to echo all received data this option must be
enabled. When enabled, the ds30 Loader engine will compare all sent data with the echo
and give an error if there is a mismatch.
Timing
Hello timeout
Specifies the time to send the hello command before giving up when no response is
received.
Poll time
Specifies the interval at which the hello command is sent to the boot loader.
Timeout
Specifies the communication timeout.
Reset
RTS
When enabled, the RTS pin is held high prior to communication with the firmware. The value
of reset time specifies the time the RTS pin is held high. This is only available for serial ports
and hardware support must be present.
DTR
When enabled, the DTR pin is held high prior to communication with the firmware. The
value of reset time specifies the time the DTR pin is held high. Hardware support must be
present. This is only available for serial ports.
Command
When enabled, a command is sent to the device to request reset or loading of the boot
loader. When a CAN port is used, the macros $PICID and $GUIID can be used, they will be
expanded to a two or four‐byte big endian value depending on if extended is used or not.
The value of reset time specifies the time to wait after the command is sent before trying to
communicate with the boot loader.
ID
The CAN id to be used when sending the reset command.
DLC
The CAN DLC to use when sending the reset command.
Baud rate
The baud rate to use when sending the reset command.
Activation
RTS
When checked, the RTS pin is used to activate the device by holding it high during a write
operation. Hardware support must be present.
DTR
When checked, the DTR pin is used to activate the device by holding it high during a write
operation. Hardware support must be present.
Security
Password
The password will be sent before any boot loader operation is performed.
Operation
Parsing of hex-file
The following operations take place during the parsing of a hex file:
Validation
The hex file is validated. Line checksums, file format and file completeness is checked. If any
error is detected, the parsing is aborted.
Data collection
All data found in the hex‐file that fits in the selected devices memory area are stored in RAM
buffers.
Counting of data
The data in the buffers are counted for presentation.
Write
The following operations take place during a write operation:
Device reset
If activated in the reset tab, the device is reset.
Parse hex-file
The hex‐file is parsed if needed depending on if the determined boot loader size is different
from the one used during last parse.
Write
Program, eeprom and configuration bits are sent for write by the firmware. If checksum
error is detected by the firmware, the GUI retries 3 times. If all 3 tries fail, the write
operation is aborted.
This guide assumes you have the ds30 Loader installed in the default location. The default
location may differ between different firmware versions. Follow these steps carefully. The
most critical step is 16: if it fails the boot loader is likely to stop working.
Troubleshooting
Known issues
With the Lawicel CAN adapters read operation is not possible for most combinations
of bit rate and serial interface baud rate. Typically any bit rate above 50k will not
work for read flash operation. Write operation still works.
The IXXAT ISB‐to‐CAN compact adapter takes several hundred milliseconds to setup.
This means that the firmware timeout cannot be set shorter than this if a reset
command is used and the application uses a different bit rate than the boot loader.
Error messages
“The hex‐file contains code This occurs when the loaded Select correct device.
that will overwrite the boot hex‐file contains memory Set custom boot loader
loader” locations that could properties under the
overwrite the boot loader. Itadvanced tab to the values
can also occur if the wrong from the firmware, usually
device is selected. called BLPLP and BLSIZEP in
settings.inc.
Because the application does Free up program memory if
not know the actual boot needed.
“Hex‐file contains more If you use the export Use the hex‐file produced by
config locations than the function from MPLAB this the assembler or linker.
device has” might happen.
“Last row containing configs On PIC18FJ, PIC24FJ, and on To write the last page in
was found in hex file, last some PIC24E/dsPIC33E flash, check the write configs
page has been disabled. devices the configuration checkbox under the
Consult manual for more words are stored as the last advanced tab.
information.” words in the ordinary flash
address space. The It is unlikely that the last
configuration words are vital page will contain any code,
to the PIC operation. To therefore it is usually safe to
avoid corrupting the not write the last page and
configuration words or this is also recommended.
changing them which could
lead to the boot loader not
functioning properly the last
page in flash will not get
written.
HW schematics
UART / software UART
This is just a sample implementation of UART communication. The schematic comes without
warranty.
Components
Name Value Comment
IC1 PIC Required PIC microcontroller
IC2 MAX202 Required RS232 level converter
X1 DB9 Optional Connector
R1 10kΩ Required Master clear pull-up
C1 100n Recommended Decoupling capacitor
C2 10µF Recommended Filter capacitor
C3 100nF Recommended Decoupling capacitor
C4 100nF Required Charge pump capacitor
C5 100nF Required Charge pump capacitor
C6 100nF Required Charge pump capacitor
C7 100nF Required Charge pump capacitor
R2 10kΩ Optional Reset by RTS, base current limiter
R3 10kΩ Optional Reset by RTS, base pull-down
D1 1N4148 Optional Reset by RTS, RTS signal rectifier
Q1 BC547 Optional Reset by RTS, RTS signal inverter
Schematic
CAN
This is just a sample implementation of CAN communication. The schematic comes without
warranty.
Components
Name Value Comment
IC1 PIC Required PIC microcontroller
U1 MCP2551 Required CAN transceiver
X1 DB9 Optional Connector
R1 10kΩ Required Master clear pull-up
R2 120Ω Optional Bus termination
R3 22k Ω Required Slew rate control, see the datasheet
C2 10µF Recommended Filter capacitor
C3 100nF Recommended Decoupling capacitor
Schematic
Appendix A – Links
ds30 Loader website
http://www.ds30loader.com
Mono / MonoDevelop
http://www.mono‐project.com
Eagle
http://www.cadsoft.de
a. The goto application word at 0x00 is normally created automatically by the compiler.
The GUI moves the goto to just before the boot loader code.
b. The user application is not affected by the boot loader
c. A new goto at 0x00 pointing to the boot loader code is created by the GUI.
d. The boot loader code is normally placed at the end of the memory.
b b b
USER USER
APPLICATION APPLICATION
USER
APPLICATION
a GOTO USER
APPLICATION
a GOTO USER
APPLICATION d
d BOOTLOADER
BOOTLOADER
CONFIGS
Appendix D - Files
Package content
File Description
\copying.txt The license for ds30 Loader
\bin Contains binaries
\bin\canlibCLSNET.dll Use by the Kvaser CAN port plug‐in
\bin\PCANBasic.dll Used by the PCAN CAN port plug‐in
\bin\PCANBasic_x64.dll Used by the PCAN CAN port plug‐in, this needs to be
manually renamed to PCANBasic.dll on x64 systems.
\bin\PCANBasic_x86.dll Used by the PCAN CAN port plug‐in, this needs to be
manually renamed to PCANBasic.dll on x86 systems.
\bin\vcinet2.dll Used by the IXXAT CAN port plug‐in
\bin\vxlapi.dll Used by the Vector CAN port plug‐in
\bin\vxlapi64.dll Used by the Vector CAN port plug‐in
\bin\vxlapi_NET20.dll Used by the Vector CAN port plug‐in
Requires: vxlapi.dll
\bin\ds30LoaderGui.exe Graphical user interface for ds30 Loader
\bin\ds30LoaderConsole.exe Console application for ds30 Loader.
\bin\ixxatBitRates.xml Contains CAN timings used by IXXAT CAN port plug‐in
for different bit rates
\bin\vectorBitRates.xml Contains CAN timings used by IXXAT CAN port plug‐in
for different baud rates
\documentation Contains all documentation for the ds30 Loader
\firmware xxx Contains a MPLAB IDE project for a single Microchip
device family
\firmware xxx\ds30loader.mcp MPLAB IDE project file
\firmware xxx\src\devices.inc Contains device constants
\firmware xxx\src\settings.inc Contains boot loader settings that should be
checked/changed before download
\firmware xxx\src\user_init.inc User initialization and exit code
\firmware xxx\src\ds30loader.s/asm Contains the boot loader code
File Description
settingsPortLawicel.xml Settings saved by Lawicel CAN port plug‐in
settingsPortSerial.xml Settings saved by serial port plug‐in
settingsPortVector.xml Settings saved by Vector CAN port plug‐in
settings.xml GUI settings