Flasher/Flasher DSK - Getting Started

From SEGGER Wiki
Jump to: navigation, search

Content of DSK

The Flasher DSK is a bundle of J-Link Device Support Kit and Flasher DSK (for U-Flash). Thus, in addition to the release notes and license, the archive also contains archives for each component. Please unpack these archives into a folder of your choice, preferably the same one. Both will extract a sub folder DSK.

The Flasher DSK (for U-Flash) provides, below the folder DSK:

ReleaseNotes_FlasherDSK.html
the release notes
Tools
it contains the PCode compiler (pccu.exe) and the Device Package Builder (FlasherDSK Device Package Builder.exe) to test, distribute and publish a customer device package.
Source
it contains templates for:

FlasherDSK.emPackage
an Embedded Studio package, to integrate support for PCode development into Embedded Studio, to make development more convenient.

For J-Link Device Support Kit please refer J-Link_Device_Support_Kit.

Relations of components

This "Getting Started" refers to "all other" devices to be programmed, since ARM-based devices are sufficiently covered by the J-Link Device Support Kit. Please refer to J-Link_Device_Support_Kit for more information about this.

Main component for programming those devices is U-Flash (see U-Flash User Manual UM08037 for more information). U-Flash requires device specific Device Definition Files (DDF) to configure a Flasher for standalone mode. A Device Definition File contains information about the device itself, most important for operation are:

There is also some additional information to help the user set up and operate these devices.

When creating the configuration:

  • All information from DDF about the memory areas is used to create the DAT file. Only data areas defined in the DDF are taken over at all.
  • The specified algorithm is pulled from the repertoire of all available and added to the configuration.
  • The configuration values resulting after the user query are written into an UNI file and these are added to the configuration.

The algorithm to use is a PCode compiled by the PCode Compiler for U-Flash (PCCU). The resulting executable file, we call it PEX file for short, is loaded by the Flasher and according to the necessary steps the defined entry points, parameterized accordingly, are jumped to and the return values are processed.

The possible entry points invoked by the Flasher during operation are:

int Init(void) Directly after start of operation (after switching on Vsupply, when applicable
int EraseChip(void) To perform a mass erase, when specified
int CheckBlank(U32 Addr, U32 Len) Before erasing, if only "dirty" data is to be erased.
int Erase(U32 Addr, U32 Len) To erase a sector
int Program(U32 Addr, U32 Len) To program a sector
int Read(U32 Addr, U32 Len) To read back a sector and send data to CLI
int Verify(U32 Addr, U32 Len) To verify a sector
int Secure(void) To apply security measures to protect the software
int DeInit(void) The very last call before operation ends. Is called regardless of error state)

PCode

Flasher PCodes are C-like script files which are compiled into object code called PEX files. These PEX files can then be loaded and executed by the Flasher firmware. PCodes have several entry functions which are called by the Flasher depending on the performed tasks (erase, program, verify, ...). The flasher feeds these entry functions with information about the target hardware's Non Volatile Memory (NVM) and the application data to be programmed into the NVM. This information is obtained from DAT and UNI files which also need to be provided to the Flasher and are loaded together with the PEX file. The DAT and UNI files on the other hand are generated from a HEX file and XML file which contains information about the target's NVM.

The available entry point functions are:

   int Init(void);
   int DeInit(void);
   int Secure(void);
   int Verify(U32 Addr, U32 Len)
   int Read(U32 Addr, U32 Len)
   int Program(U32 Addr, U32 Len)
   int EraseChip(void)
   int Erase(U32 Addr, U32 Len)
   int CheckBlank(U32 Addr, U32 Len)

Entry point functions with address and length parameters can be called multiple times with different arguments, depending on the number of NVM sections described in the respective XML file and on the NVM sections used in the HEX file. If the HEX file contains data for a memory section described in the XML file, the according entry point function for the performed task is called with the address and length of the section to work with. For Program(), Verify() and Read() this information is not enough. Program() and Verify(), for instance, need access to the data from the HEX file and Read() needs to store the read data somewhere. This is done via a buffer that is allocated by the flasher and which either contains the data required for programming and verification or is used as a storage for the read data. The pseudo-variable JLINK_pDataArea is a pointer which contains the address to this buffer and can be used within the PCode. The size of the buffer is determined by the HEAP_SIZE pragma and has to be big enough to hold the largest memory section available in the XML file for the target.

Init() and DeInit() are always called, no matter which tasks need to be performed. Each entry function returns an integer specifying whether the function was successful or not. If a value equal 0 is returned, the function was successful and the flasher will continue with the remaining tasks to perform. If a value other than 0 is returned, the flasher aborts all tasks and directly calls DeInit() which should be used to put the target into a safe state.

Create new DevicePack

In Embedded Studio

  • If not installed, yet, install the Flasher DSK ES package FlasherDSK.emPackage using the Embedded Studio menu item Tools > Manually Install Packages or just double click on the package to install.
  • Create a new Embedded Studio project.
  • Select FlasherDSK Development Project for U-Flash Flash Loaders from Select new project template.
  • Select Next then Finish. You get a shiny new project containing two files, a skeleton PCode and Device Definition File.
  • Modify the template PCode and Device Definition File as needed.
  • Once you have completed any code modifications (the supplied template should compiler without error; to compile press F7) you can build the project (Open FlasherDSK_Pcode.c in ES and press Ctrl+F7)
  • The Device Package Builder (FlasherDSK Device Package Builder.exe) will on Validatereport any errors and ask for any missing data .
  • The user can now with Review and Test deploy the solution, so U-Flash can use it locally.
  • After a successful review the Device Package Builder can Create a redistributable Device package installer for distribution or Publish the package on SEGGER community marketplace to share the solution (coming soon).
  • The package is made available in U-Flash (V7.92 and later) whether it was deployed locally for testing and review or through the Device Package Installer or downloaded from the SEGGER Marketplace. Device packages are provided during the device selection dialog in the Flasher DSK tab.

Manually

  • Use template skeleton PCode and DDF to create your own set of files.
  • Use PCode Compiler for U-Flash (PCCU) to compile the PCode
  • Use the FlasherDSK Device Package Builder.exe to deploy your package
  • Use U-Flash to check for functionality during project configuration and download this configuration to Flasher.
  • Use the FlasherDSK Device Package Builder.exe to create a package for distribution or publishing.