| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions | Variables
LPC18xx/43xx Internal FLASH programming algorithm for the DFU Utility
DFU USB programming algorithms

## Detailed Description

Example description
This programming algorithm allows upload and download of data to and from the internal FLASH storage on LPC18xx and LPC43xx devices.

More information on using the DFU Utility can be found at the following links:
DFU Utility information
DFU Utility production programming API

Special connection requirements
There are no special connection requirements for this example.

Build procedures:
LPC18xx/43xx example quickstart for Keil uVision4

Supported boards and board setup:
Although this example includes a build target for only the Keil 1857 board, it should run on all 18xx or 43xx boards.
Keil 1857 evaluation boards

Submitting LPCOpen issues:
Community support for LPCOpen

## Data Structures
struct | SECTOR_INFO_T

## Macros
#define | IAP_INIT 49
#define | IAP_PREP_SECS 50
#define | IAP_RAM_TO_FLASH 51
#define | IAP_ERASE_SECS 52
#define | IAP_BLANK_CHECK_SECS 53
#define | IAP_READ_PART_ID 54
#define | IAP_READ_BOOT_CODE_VER 55
#define | IAP_READ_DEV_SERIAL_NUM 58
#define | IAP_COMPARE 56
#define | IAP_REINVOKE_ISP 57
#define | IAP_ERASE_PAGE 59
#define | IAP_SET_ACTIVE_FLASH_BANK 60
#define | IAP_COMMAND_SUCCESS 0x00
#define | IAP_INVALID_COMMAND 0x01
#define | IAP_SRC_ADDR_ERROR 0x02
#define | IAP_DST_ADDR_ERROR 0x03
#define | IAP_SRC_ADDR_NOT_MAPPED 0x04
#define | IAP_DST_ADDR_NOT_MAPPED 0x05
#define | IAP_COUNT_ERROR 0x06
#define | IAP_INVALID_SECTOR 0x - 7
#define | IAP_SECTOR_NOT_BLANK 0x08
#define | IAP_SECTOR_NOT_PREPARED 0x09
#define | IAP_COMPARE_ERROR 0x0A
#define | IAP_BUSY 0x0B
#define | IAP_PARAM_ERROR 0x0C
#define | IAP_ADDR_ERROR 0x0D
#define | IAP_ADDR_NOT_MAPPED 0x0E
#define | IAP_CMD_LOCKED 0x0F
#define | IAP_INVALID_CODE 0x10
#define | IAP_INVALID_BAUD_RATE 0x11
#define | IAP_INVALID_STOP_BIT 0x12
#define | IAP_CRP_ENABLED 0x13
#define | IAP_INVALID_FLASH_UNIT 0x14
#define | IAP_USER_CODE_CHECKSUM 0x15
#define | IAP_ERROR_SETTING_ACTIVE_PART 0x16
#define | FLASHMAXSIZE (512 * 1024)
#define | CPUCLOCKFRQINKHZ 90000
#define | PAGE_SIZE 512
#define | IAP_LOCATION *((uint32_t *) 0x10400100);
#define | DFU_BUFF_PROG_SIZE PAGE_SIZE
#define | PROGRAM_REGIONS 2

## Typedefs
typedef void(* | IAP )(uint32_t *, uint32_t *)

## Functions
int32_t | progalgo_iflash_erase (uint32_t start, uint32_t size)
int32_t | progalgo_iflash_erase_all (void)
int32_t | progalgo_iflash_write (void *buff, uint32_t start, uint32_t size)
int32_t | progalgo_iflash_read (void *buff, uint32_t start, uint32_t size)
static int | progalgo_iflash_findbank (uint32_t addr)
static int | progalgo_iflash_progaddrvalid (uint32_t addr, uint32_t size)
static int | progalgo_iflash_find_sectorrange (uint32_t addr, uint32_t size, int *bank, uint32_t *secstart, uint32_t *secend, int *aligned)
static int | progalgo_iflash_prepwrite (uint32_t bank, uint32_t secstart, uint32_t secend)
static int | progalgo_iflash_erasesectors (uint32_t bank, uint32_t secstart, uint32_t secend)
static uint32_t | progalgo_iflash_getsize (int bank, uint32_t part_id2)
DFUPROG_REGION_T * | algo_flash_init (void)
| Initializes device programming capability.

## Variables
static const SECTOR_INFO_T | sectorinfo []
static IAP | iap_entry
static uint32_t | command [6]
static uint32_t | result [5]
static const PROGALGOS_T | palgos
static DFUPROG_REGZONE_T | pregions [PROGRAM_REGIONS]
static DFUPROG_REGION_T | dfuregion
static char | tempSTR [128]

## Macro Definition Documentation

#define CPUCLOCKFRQINKHZ 90000

Definition at line 113 of file dfuutil_programming_iflash_algorithm.c.

#define DFU_BUFF_PROG_SIZE PAGE_SIZE

Definition at line 158 of file dfuutil_programming_iflash_algorithm.c.

#define FLASHMAXSIZE (512 * 1024)

Definition at line 109 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_ADDR_ERROR 0x0D

Definition at line 97 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_ADDR_NOT_MAPPED 0x0E

Definition at line 98 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_BLANK_CHECK_SECS 53

Definition at line 74 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_BUSY 0x0B

Definition at line 95 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_CMD_LOCKED 0x0F

Definition at line 99 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_COMMAND_SUCCESS 0x00

Definition at line 84 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_COMPARE 56

Definition at line 78 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_COMPARE_ERROR 0x0A

Definition at line 94 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_COUNT_ERROR 0x06

Definition at line 90 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_CRP_ENABLED 0x13

Definition at line 103 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_DST_ADDR_ERROR 0x03

Definition at line 87 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_DST_ADDR_NOT_MAPPED 0x05

Definition at line 89 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_ERASE_PAGE 59

Definition at line 80 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_ERASE_SECS 52

Definition at line 73 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_ERROR_SETTING_ACTIVE_PART 0x16

Definition at line 106 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_INIT 49

Definition at line 70 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_INVALID_BAUD_RATE 0x11

Definition at line 101 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_INVALID_CODE 0x10

Definition at line 100 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_INVALID_COMMAND 0x01

Definition at line 85 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_INVALID_FLASH_UNIT 0x14

Definition at line 104 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_INVALID_SECTOR 0x - 7

Definition at line 91 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_INVALID_STOP_BIT 0x12

Definition at line 102 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_LOCATION *((uint32_t *) 0x10400100);

Definition at line 144 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_PARAM_ERROR 0x0C

Definition at line 96 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_PREP_SECS 50

Definition at line 71 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_RAM_TO_FLASH 51

Definition at line 72 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_READ_BOOT_CODE_VER 55

Definition at line 76 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_READ_DEV_SERIAL_NUM 58

Definition at line 77 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_READ_PART_ID 54

Definition at line 75 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_REINVOKE_ISP 57

Definition at line 79 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_SECTOR_NOT_BLANK 0x08

Definition at line 92 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_SECTOR_NOT_PREPARED 0x09

Definition at line 93 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_SET_ACTIVE_FLASH_BANK 60

Definition at line 81 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_SRC_ADDR_ERROR 0x02

Definition at line 86 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_SRC_ADDR_NOT_MAPPED 0x04

Definition at line 88 of file dfuutil_programming_iflash_algorithm.c.

#define IAP_USER_CODE_CHECKSUM 0x15

Definition at line 105 of file dfuutil_programming_iflash_algorithm.c.

#define PAGE_SIZE 512

Definition at line 140 of file dfuutil_programming_iflash_algorithm.c.

#define PROGRAM_REGIONS 2

Definition at line 169 of file dfuutil_programming_iflash_algorithm.c.

## Typedef Documentation

typedef void(* IAP)(uint32_t *, uint32_t *)

Definition at line 143 of file dfuutil_programming_iflash_algorithm.c.

## Function Documentation

DFUPROG_REGION_T* algo_flash_init | ( | void |  | ) |

Initializes device programming capability.

Returns
  A pointer to the programming info structure Initializes device programming capability. Returns a pointer to the programming buffer, the programming buffer size, and a pointer to the DFU programming region/API structure used by the DFU streamer.

Definition at line 588 of file dfuutil_programming_iflash_algorithm.c.

void dfuUtilSystemInit | ( | void |  | ) |

Very minor system initialization.

Returns
  none The DFU Utility setup does the minimum amount of setup as possible to be portable among different devices.

Definition at line 60 of file dfuutil_programming_iflash_systeminit.c.

static int32_t progalgo_iflash_erase | ( | uint32_t | start,
|  | uint32_t | size
| ) |  |

Definition at line 383 of file dfuutil_programming_iflash_algorithm.c.

static int32_t progalgo_iflash_erase_all | ( | void |  | ) |

Definition at line 440 of file dfuutil_programming_iflash_algorithm.c.

static int progalgo_iflash_erasesectors | ( | uint32_t | bank,
|  | uint32_t | secstart,
|  | uint32_t | secend
| ) |  |
| static

Definition at line 363 of file dfuutil_programming_iflash_algorithm.c.

static int progalgo_iflash_find_sectorrange | ( | uint32_t | addr,
|  | uint32_t | size,
|  | int * | bank,
|  | uint32_t * | secstart,
|  | uint32_t * | secend,
|  | int * | aligned
| ) |  |
| static

Definition at line 254 of file dfuutil_programming_iflash_algorithm.c.

static int progalgo_iflash_findbank | ( | uint32_t | addr | ) |
| static

Definition at line 201 of file dfuutil_programming_iflash_algorithm.c.

static uint32_t progalgo_iflash_getsize | ( | int | bank,
|  | uint32_t | part_id2
| ) |  |
| static

Definition at line 560 of file dfuutil_programming_iflash_algorithm.c.

static int progalgo_iflash_prepwrite | ( | uint32_t | bank,
|  | uint32_t | secstart,
|  | uint32_t | secend
| ) |  |
| static

Definition at line 344 of file dfuutil_programming_iflash_algorithm.c.

static int progalgo_iflash_progaddrvalid | ( | uint32_t | addr,
|  | uint32_t | size
| ) |  |
| static

Definition at line 220 of file dfuutil_programming_iflash_algorithm.c.

static int32_t progalgo_iflash_read | ( | void * | buff,
|  | uint32_t | start,
|  | uint32_t | size
| ) |  |

Definition at line 548 of file dfuutil_programming_iflash_algorithm.c.

static int32_t progalgo_iflash_write | ( | void * | buff,
|  | uint32_t | start,
|  | uint32_t | size
| ) |  |

Definition at line 466 of file dfuutil_programming_iflash_algorithm.c.

## Variable Documentation

uint32_t command[6]
| static

Definition at line 146 of file dfuutil_programming_iflash_algorithm.c.

DFUPROG_REGION_T dfuregion
| static

Initial value:
= {
0,
DFU_BUFF_PROG_SIZE,
&palgos,
pregions,
DFUPROG_VALIDVAL,
"Internal FLASH"
}

Definition at line 180 of file dfuutil_programming_iflash_algorithm.c.

IAP iap_entry
| static

Definition at line 145 of file dfuutil_programming_iflash_algorithm.c.

const PROGALGOS_T palgos
| static

Initial value:
= {
progalgo_iflash_erase,
progalgo_iflash_erase_all,
progalgo_iflash_write,
progalgo_iflash_read
}

Definition at line 161 of file dfuutil_programming_iflash_algorithm.c.

DFUPROG_REGZONE_T pregions[PROGRAM_REGIONS]
| static

Initial value:
= {
{0x00000000, 0x00000000},
{0x00000000, 0x00000000}
}

Definition at line 173 of file dfuutil_programming_iflash_algorithm.c.

uint32_t result[5]
| static

Definition at line 146 of file dfuutil_programming_iflash_algorithm.c.

const SECTOR_INFO_T sectorinfo[]
| static

Initial value:
= {
{0x00000000, 0x00002000},
{0x00002000, 0x00002000},
{0x00004000, 0x00002000},
{0x00006000, 0x00002000},
{0x00008000, 0x00002000},
{0x0000A000, 0x00002000},
{0x0000C000, 0x00002000},
{0x0000E000, 0x00002000},
{0x00010000, 0x00010000},
{0x00020000, 0x00010000},
{0x00030000, 0x00010000},
{0x00040000, 0x00010000},
{0x00050000, 0x00010000},
{0x00060000, 0x00010000},
{0x00070000, 0x00010000},
{0xFFFFFFFF, 0xFFFFFFFF}
}

Definition at line 120 of file dfuutil_programming_iflash_algorithm.c.

char tempSTR[128]
| static

Definition at line 190 of file dfuutil_programming_iflash_algorithm.c.