Difference between revisions of "Adding Support for New Devices"

From SEGGER Wiki
Jump to: navigation, search
(Embedded Studio Project)
Line 1: Line 1:
  +
__TOC__
<table>
 
<tr>
 
<td valign="top">__TOC__</td>
 
<td valign="top"></td>
 
<td valign="top">
 
 
</td>
 
</tr>
 
</table>
 
 
This article describes how to add support for new devices / flash banks to the J-Link DLL so that they can be used with any J-Link DLL based application like for example J-Flash, J-Link Commander, IDEs, etc...This article assumes that there is already a basic understanding of the CMSIS flash algorithm structure defined by ARM as well as method of adding new devices using the Open Flash Loader concept. In general, there are two possibilities to add support for a new device:
 
This article describes how to add support for new devices / flash banks to the J-Link DLL so that they can be used with any J-Link DLL based application like for example J-Flash, J-Link Commander, IDEs, etc...This article assumes that there is already a basic understanding of the CMSIS flash algorithm structure defined by ARM as well as method of adding new devices using the Open Flash Loader concept. In general, there are two possibilities to add support for a new device:
#Use a pre-compiled flash loader
+
#'''Use a pre-compiled flash loader'''
#Compile / create the flash loader on your own
+
#'''Compile / create the flash loader on your own'''
 
##Using Keil uVision (a license is required, no trial available; Supports Cortex-M, only)
 
##Using Keil uVision (a license is required, no trial available; Supports Cortex-M, only)
 
##SEGGER Embedded Studio (can be evaluated without license; Supports Cortex-M and Cortex-A/R)<br>How to create a flash loader on your own using Embedded Studio is described below.
 
##SEGGER Embedded Studio (can be evaluated without license; Supports Cortex-M and Cortex-A/R)<br>How to create a flash loader on your own using Embedded Studio is described below.
 
<br>
 
 
= Creating a flash algorithm using SEGGER Embedded Studio =
 
= Creating a flash algorithm using SEGGER Embedded Studio =
 
This article describes how to create a flash loader using the template projects (Cortex-M and Cortex-A/R) for SEGGER Embedded Studio.
 
This article describes how to create a flash loader using the template projects (Cortex-M and Cortex-A/R) for SEGGER Embedded Studio.
Line 48: Line 38:
 
| '''thumb_crt0.s'''<br>'''crt0.s''' || Initialization file for Cortex-M (used by debug configuration, only)<br>Initialization file for Cortex-A/R(used by debug configuration, only)
 
| '''thumb_crt0.s'''<br>'''crt0.s''' || Initialization file for Cortex-M (used by debug configuration, only)<br>Initialization file for Cortex-A/R(used by debug configuration, only)
 
|}
 
|}
 
 
== Embedded Studio Projects ==
 
== Embedded Studio Projects ==
 
The projects below have been tested with SEGGER Embedded Studio V3.10.
 
The projects below have been tested with SEGGER Embedded Studio V3.10.
 
*[[File:OpenFlashLoader_CortexM_Template_EmbeddedStudio.zip]]
 
*[[File:OpenFlashLoader_CortexM_Template_EmbeddedStudio.zip]]
 
*[[File:OpenFlashLoader_CortexAR_Template_EmbeddedStudio.zip]]
 
*[[File:OpenFlashLoader_CortexAR_Template_EmbeddedStudio.zip]]
  +
== Step-By-Step Instruction ==
  +
This step-by-step instruction explains how to create your own flash loader using the template projects for Embedded Studio and how to use add a new flash bank for an existing or new device to the J-Link DLL, so that it can be used from within any application using the DLL.
  +
#Adapt the template project
  +
##'''FlashDev.c''': Modify the FlashDevice structure according to your device
  +
##'''FlashPrg.c''': Implement the flash routines Init(), UnInit(), EraseSector() and ProgramPage()
  +
##'''MemoryMap.xml''': Enter RAM base address and RAM size
  +
##'''main.c''': Make sure that the define ''_FLASH_BASE_ADDR'' defines the correct flash base address
  +
#Test the debug configuration
  +
##Connect the target to the J-Link and the J-Link to the PC
  +
##Switch to the '''Debug''' configuration in Embedded Studio ('''Build''' -> '''Set Active Build Configuration''' -> '''Debug''')
  +
##Build the project by pressing '''F7'''
  +
##Start the debug session by pressing'''F5'''
  +
##PC should be halted at main. Now debug the flash algorithm and make sure that it behaves as expected.
  +
#Build the flash loader using the release configuration
  +
##Switch to the '''Release''' configuration in Embedded Studio ('''Build''' -> '''Set Active Build Configuration''' -> '''Release''')
  +
##Build the project by pressing '''F7''' --> The flash loader file can be found here: $PROJ_DIR$\Output\Release\Exe\*.elf
  +
#JLinkDevices.xml
  +
##Create or adapt the '''JLinkDevices.xml''' (described in the J-Link User Manual (UM08001)).
  +
##Place the '''JLinkDevices.xml''' file at the correct location (described in the J-Link User Manual (UM08001)).
  +
##Now select the created or adapted device which uses the added flash bank in the application (e.g. J-Link Commander / IDE / ...).
  +
=== Create the Flash Loader ===
  +
Trouble shoot:
  +
What to do when the flashloader is not detected.

Revision as of 13:58, 2 September 2016

This article describes how to add support for new devices / flash banks to the J-Link DLL so that they can be used with any J-Link DLL based application like for example J-Flash, J-Link Commander, IDEs, etc...This article assumes that there is already a basic understanding of the CMSIS flash algorithm structure defined by ARM as well as method of adding new devices using the Open Flash Loader concept. In general, there are two possibilities to add support for a new device:

  1. Use a pre-compiled flash loader
  2. Compile / create the flash loader on your own
    1. Using Keil uVision (a license is required, no trial available; Supports Cortex-M, only)
    2. SEGGER Embedded Studio (can be evaluated without license; Supports Cortex-M and Cortex-A/R)
      How to create a flash loader on your own using Embedded Studio is described below.

Creating a flash algorithm using SEGGER Embedded Studio

This article describes how to create a flash loader using the template projects (Cortex-M and Cortex-A/R) for SEGGER Embedded Studio.

Debug Configurations

The example project contains two debug configurations:

  • Debug
  • Release

Debug configuration

This configuration allows to debug the flash algorithm in Embedded Studio. The configuration includes a main.c containing the typical function call order, executed by the J-Link DLL during flash programming. The optimization level for this configuration is set to "none".

Release configuration

This configuration does not allow debugging but creates the output elf file which can be referenced from within the JLinkDevices.xml file as "Loader". The optimization level is set to 3 (highest).

Included files

Filename Content
FlashDev.c Flash device description for the ST STM32F205RC
FlashOS.h Function prototypes, definitions and structures
FlashPrg.c Flash algorithm itself (e.g. ProgramPage(), EraseSector()
main.c Flash algorithm debug code (used by debug configuration, only)
Cortex_M_Startup.s
ARM_Startup.s
Cortex-M startup code (used by debug configuration, only)
Cortex-A/R startup code (used by debug configuration, only)
MemoryMap.xml Memory map of the ST STM32F205RC
Placement_debug.xml Debug configuration section placement file.
Placement_release.xml Release configuration section placement file.
thumb_crt0.s
crt0.s
Initialization file for Cortex-M (used by debug configuration, only)
Initialization file for Cortex-A/R(used by debug configuration, only)

Embedded Studio Projects

The projects below have been tested with SEGGER Embedded Studio V3.10.

Step-By-Step Instruction

This step-by-step instruction explains how to create your own flash loader using the template projects for Embedded Studio and how to use add a new flash bank for an existing or new device to the J-Link DLL, so that it can be used from within any application using the DLL.

  1. Adapt the template project
    1. FlashDev.c: Modify the FlashDevice structure according to your device
    2. FlashPrg.c: Implement the flash routines Init(), UnInit(), EraseSector() and ProgramPage()
    3. MemoryMap.xml: Enter RAM base address and RAM size
    4. main.c: Make sure that the define _FLASH_BASE_ADDR defines the correct flash base address
  2. Test the debug configuration
    1. Connect the target to the J-Link and the J-Link to the PC
    2. Switch to the Debug configuration in Embedded Studio (Build -> Set Active Build Configuration -> Debug)
    3. Build the project by pressing F7
    4. Start the debug session by pressingF5
    5. PC should be halted at main. Now debug the flash algorithm and make sure that it behaves as expected.
  3. Build the flash loader using the release configuration
    1. Switch to the Release configuration in Embedded Studio (Build -> Set Active Build Configuration -> Release)
    2. Build the project by pressing F7 --> The flash loader file can be found here: $PROJ_DIR$\Output\Release\Exe\*.elf
  4. JLinkDevices.xml
    1. Create or adapt the JLinkDevices.xml (described in the J-Link User Manual (UM08001)).
    2. Place the JLinkDevices.xml file at the correct location (described in the J-Link User Manual (UM08001)).
    3. Now select the created or adapted device which uses the added flash bank in the application (e.g. J-Link Commander / IDE / ...).

Create the Flash Loader

Trouble shoot: What to do when the flashloader is not detected.