OpenOCD
numicro.c File Reference
Include dependency graph for numicro.c:

Go to the source code of this file.

Data Structures

struct  numicro_cpu_type
 
struct  numicro_flash_bank
 
struct  numicro_flash_bank_type
 

Macros

#define AHBCLK_ISP_EN   (1 << 2)
 
#define AHBCLK_SRAM_EN   (1 << 4)
 
#define AHBCLK_TICK_EN   (1 << 5)
 
#define CONFIG0_LOCK_MASK   (1 << 1)
 
#define IPRSTC1_CHIP_RST   (1 << 0)
 
#define IPRSTC1_CPU_RST   (1 << 1)
 
#define ISPCMD_CHIPERASE   0x26 /* Undocumented isp "Chip-Erase" command */
 
#define ISPCMD_ERASE   0x22
 
#define ISPCMD_READ   0x00
 
#define ISPCMD_READ_CID   0x0B
 
#define ISPCMD_READ_DID   0x0C
 
#define ISPCMD_READ_UID   0x04
 
#define ISPCMD_VECMAP   0x2E
 
#define ISPCMD_WRITE   0x21
 
#define ISPCON_APUEN   (1 << 3)
 
#define ISPCON_BS_AP   (0 << 1)
 
#define ISPCON_BS_LP   (1 << 1)
 
#define ISPCON_BS_MASK   (1 << 1)
 
#define ISPCON_CFGUEN   (1 << 4)
 
#define ISPCON_ISPEN   (1 << 0)
 
#define ISPCON_ISPFF   (1 << 6)
 
#define ISPCON_LDUEN   (1 << 5)
 
#define ISPTRG_ISPGO   (1 << 0)
 
#define NUMICRO_APROM_BASE   0x00000000
 
#define NUMICRO_BANKS_GENERAL(aprom_size, data_size, ldrom_size, config_size)
 
#define NUMICRO_CONFIG0   0x5000C000
 
#define NUMICRO_CONFIG1   0x5000C004
 
#define NUMICRO_CONFIG_BASE   0x00300000
 
#define NUMICRO_DATA_BASE   0x0001F000
 
#define NUMICRO_FLASH_BASE   0x5000C000
 
#define NUMICRO_FLASH_CHEAT   0x5000C01C /* Undocumented isp register(may be cheat register) */
 
#define NUMICRO_FLASH_ISPADR   0x5000C004
 
#define NUMICRO_FLASH_ISPCMD   0x5000C00C
 
#define NUMICRO_FLASH_ISPCON   0x5000C000
 
#define NUMICRO_FLASH_ISPDAT   0x5000C008
 
#define NUMICRO_FLASH_ISPTRG   0x5000C010
 
#define NUMICRO_LDROM_BASE   0x00100000
 
#define NUMICRO_MAX_FLASH_BANKS   4
 
#define NUMICRO_PAGESIZE   512
 
#define NUMICRO_SCS_AIRCR   0xE000ED0C
 
#define NUMICRO_SCS_BASE   0xE000E000
 
#define NUMICRO_SCS_DEMCR   0xE000EDFC
 
#define NUMICRO_SCS_DHCSR   0xE000EDF0
 
#define NUMICRO_SYS_BASE   0x50000000
 
#define NUMICRO_SYS_IPRSTC1   0x50000008
 
#define NUMICRO_SYS_WRPROT   0x50000100
 
#define NUMICRO_SYSCLK_AHBCLK   0x50000204
 
#define NUMICRO_SYSCLK_BASE   0x50000200
 
#define NUMICRO_SYSCLK_CLKDIV   0x50000218
 
#define NUMICRO_SYSCLK_CLKSEL0   0x50000210
 
#define NUMICRO_SYSCLK_PWRCON   0x50000200
 
#define PWRCON_OSC22M   (1 << 2)
 
#define PWRCON_XTL12M   (1 << 0)
 
#define REG_KEY1   0x59
 
#define REG_KEY2   0x16
 
#define REG_KEY3   0x88
 
#define REG_LOCK   0x00
 

Functions

 COMMAND_HANDLER (numicro_handle_chip_erase_command)
 
 COMMAND_HANDLER (numicro_handle_read_isp_command)
 
 COMMAND_HANDLER (numicro_handle_write_isp_command)
 
 FLASH_BANK_COMMAND_HANDLER (numicro_flash_bank_command)
 
static int numicro_auto_probe (struct flash_bank *bank)
 
static int numicro_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static uint32_t numicro_fmc_cmd (struct target *target, uint32_t cmd, uint32_t addr, uint32_t wdata, uint32_t *rdata)
 
static int numicro_get_arm_arch (struct target *target)
 
static int numicro_get_cpu_type (struct target *target, const struct numicro_cpu_type **cpu)
 
static int numicro_get_flash_size (struct flash_bank *bank, const struct numicro_cpu_type *cpu, uint32_t *flash_size)
 
static int numicro_init_isp (struct target *target)
 
static int numicro_probe (struct flash_bank *bank)
 
static int numicro_protect_check (struct flash_bank *bank)
 
static int numicro_reg_unlock (struct target *target)
 
static int numicro_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int numicro_writeblock (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 

Variables

static uint32_t m_address_bias_offset
 
static uint32_t m_page_size = NUMICRO_PAGESIZE
 
static const struct command_registration numicro_command_handlers []
 
static const struct command_registration numicro_exec_command_handlers []
 
const struct flash_driver numicro_flash
 
static const uint8_t numicro_flash_write_code []
 
static const uint8_t numicro_m4_flash_write_code []
 
static const struct numicro_cpu_type numicro_parts []
 

Macro Definition Documentation

◆ AHBCLK_ISP_EN

#define AHBCLK_ISP_EN   (1 << 2)

Definition at line 72 of file numicro.c.

◆ AHBCLK_SRAM_EN

#define AHBCLK_SRAM_EN   (1 << 4)

Definition at line 73 of file numicro.c.

◆ AHBCLK_TICK_EN

#define AHBCLK_TICK_EN   (1 << 5)

Definition at line 74 of file numicro.c.

◆ CONFIG0_LOCK_MASK

#define CONFIG0_LOCK_MASK   (1 << 1)

Definition at line 85 of file numicro.c.

◆ IPRSTC1_CHIP_RST

#define IPRSTC1_CHIP_RST   (1 << 0)

Definition at line 70 of file numicro.c.

◆ IPRSTC1_CPU_RST

#define IPRSTC1_CPU_RST   (1 << 1)

Definition at line 69 of file numicro.c.

◆ ISPCMD_CHIPERASE

#define ISPCMD_CHIPERASE   0x26 /* Undocumented isp "Chip-Erase" command */

Definition at line 91 of file numicro.c.

◆ ISPCMD_ERASE

#define ISPCMD_ERASE   0x22

Definition at line 90 of file numicro.c.

◆ ISPCMD_READ

#define ISPCMD_READ   0x00

Definition at line 88 of file numicro.c.

◆ ISPCMD_READ_CID

#define ISPCMD_READ_CID   0x0B

Definition at line 92 of file numicro.c.

◆ ISPCMD_READ_DID

#define ISPCMD_READ_DID   0x0C

Definition at line 93 of file numicro.c.

◆ ISPCMD_READ_UID

#define ISPCMD_READ_UID   0x04

Definition at line 94 of file numicro.c.

◆ ISPCMD_VECMAP

#define ISPCMD_VECMAP   0x2E

Definition at line 95 of file numicro.c.

◆ ISPCMD_WRITE

#define ISPCMD_WRITE   0x21

Definition at line 89 of file numicro.c.

◆ ISPCON_APUEN

#define ISPCON_APUEN   (1 << 3)

Definition at line 80 of file numicro.c.

◆ ISPCON_BS_AP

#define ISPCON_BS_AP   (0 << 1)

Definition at line 77 of file numicro.c.

◆ ISPCON_BS_LP

#define ISPCON_BS_LP   (1 << 1)

Definition at line 78 of file numicro.c.

◆ ISPCON_BS_MASK

#define ISPCON_BS_MASK   (1 << 1)

Definition at line 79 of file numicro.c.

◆ ISPCON_CFGUEN

#define ISPCON_CFGUEN   (1 << 4)

Definition at line 81 of file numicro.c.

◆ ISPCON_ISPEN

#define ISPCON_ISPEN   (1 << 0)

Definition at line 76 of file numicro.c.

◆ ISPCON_ISPFF

#define ISPCON_ISPFF   (1 << 6)

Definition at line 83 of file numicro.c.

◆ ISPCON_LDUEN

#define ISPCON_LDUEN   (1 << 5)

Definition at line 82 of file numicro.c.

◆ ISPTRG_ISPGO

#define ISPTRG_ISPGO   (1 << 0)

Definition at line 96 of file numicro.c.

◆ NUMICRO_APROM_BASE

#define NUMICRO_APROM_BASE   0x00000000

Definition at line 57 of file numicro.c.

◆ NUMICRO_BANKS_GENERAL

#define NUMICRO_BANKS_GENERAL (   aprom_size,
  data_size,
  ldrom_size,
  config_size 
)
Value:
.n_banks = 4, \
{{NUMICRO_APROM_BASE, (aprom_size)}, \
{NUMICRO_DATA_BASE, (data_size)}, \
{NUMICRO_LDROM_BASE, (ldrom_size)}, \
{NUMICRO_CONFIG_BASE, (config_size)}}
#define NUMICRO_DATA_BASE
Definition: numicro.c:58
#define NUMICRO_LDROM_BASE
Definition: numicro.c:59
#define NUMICRO_APROM_BASE
Definition: numicro.c:57
#define NUMICRO_CONFIG_BASE
Definition: numicro.c:60

Definition at line 124 of file numicro.c.

◆ NUMICRO_CONFIG0

#define NUMICRO_CONFIG0   0x5000C000

Definition at line 62 of file numicro.c.

◆ NUMICRO_CONFIG1

#define NUMICRO_CONFIG1   0x5000C004

Definition at line 63 of file numicro.c.

◆ NUMICRO_CONFIG_BASE

#define NUMICRO_CONFIG_BASE   0x00300000

Definition at line 60 of file numicro.c.

◆ NUMICRO_DATA_BASE

#define NUMICRO_DATA_BASE   0x0001F000

Definition at line 58 of file numicro.c.

◆ NUMICRO_FLASH_BASE

#define NUMICRO_FLASH_BASE   0x5000C000

Definition at line 44 of file numicro.c.

◆ NUMICRO_FLASH_CHEAT

#define NUMICRO_FLASH_CHEAT   0x5000C01C /* Undocumented isp register(may be cheat register) */

Definition at line 50 of file numicro.c.

◆ NUMICRO_FLASH_ISPADR

#define NUMICRO_FLASH_ISPADR   0x5000C004

Definition at line 46 of file numicro.c.

◆ NUMICRO_FLASH_ISPCMD

#define NUMICRO_FLASH_ISPCMD   0x5000C00C

Definition at line 48 of file numicro.c.

◆ NUMICRO_FLASH_ISPCON

#define NUMICRO_FLASH_ISPCON   0x5000C000

Definition at line 45 of file numicro.c.

◆ NUMICRO_FLASH_ISPDAT

#define NUMICRO_FLASH_ISPDAT   0x5000C008

Definition at line 47 of file numicro.c.

◆ NUMICRO_FLASH_ISPTRG

#define NUMICRO_FLASH_ISPTRG   0x5000C010

Definition at line 49 of file numicro.c.

◆ NUMICRO_LDROM_BASE

#define NUMICRO_LDROM_BASE   0x00100000

Definition at line 59 of file numicro.c.

◆ NUMICRO_MAX_FLASH_BANKS

#define NUMICRO_MAX_FLASH_BANKS   4

Definition at line 107 of file numicro.c.

◆ NUMICRO_PAGESIZE

#define NUMICRO_PAGESIZE   512

Definition at line 105 of file numicro.c.

◆ NUMICRO_SCS_AIRCR

#define NUMICRO_SCS_AIRCR   0xE000ED0C

Definition at line 53 of file numicro.c.

◆ NUMICRO_SCS_BASE

#define NUMICRO_SCS_BASE   0xE000E000

Definition at line 52 of file numicro.c.

◆ NUMICRO_SCS_DEMCR

#define NUMICRO_SCS_DEMCR   0xE000EDFC

Definition at line 55 of file numicro.c.

◆ NUMICRO_SCS_DHCSR

#define NUMICRO_SCS_DHCSR   0xE000EDF0

Definition at line 54 of file numicro.c.

◆ NUMICRO_SYS_BASE

#define NUMICRO_SYS_BASE   0x50000000

Definition at line 34 of file numicro.c.

◆ NUMICRO_SYS_IPRSTC1

#define NUMICRO_SYS_IPRSTC1   0x50000008

Definition at line 36 of file numicro.c.

◆ NUMICRO_SYS_WRPROT

#define NUMICRO_SYS_WRPROT   0x50000100

Definition at line 35 of file numicro.c.

◆ NUMICRO_SYSCLK_AHBCLK

#define NUMICRO_SYSCLK_AHBCLK   0x50000204

Definition at line 42 of file numicro.c.

◆ NUMICRO_SYSCLK_BASE

#define NUMICRO_SYSCLK_BASE   0x50000200

Definition at line 38 of file numicro.c.

◆ NUMICRO_SYSCLK_CLKDIV

#define NUMICRO_SYSCLK_CLKDIV   0x50000218

Definition at line 41 of file numicro.c.

◆ NUMICRO_SYSCLK_CLKSEL0

#define NUMICRO_SYSCLK_CLKSEL0   0x50000210

Definition at line 40 of file numicro.c.

◆ NUMICRO_SYSCLK_PWRCON

#define NUMICRO_SYSCLK_PWRCON   0x50000200

Definition at line 39 of file numicro.c.

◆ PWRCON_OSC22M

#define PWRCON_OSC22M   (1 << 2)

Definition at line 66 of file numicro.c.

◆ PWRCON_XTL12M

#define PWRCON_XTL12M   (1 << 0)

Definition at line 67 of file numicro.c.

◆ REG_KEY1

#define REG_KEY1   0x59

Definition at line 99 of file numicro.c.

◆ REG_KEY2

#define REG_KEY2   0x16

Definition at line 100 of file numicro.c.

◆ REG_KEY3

#define REG_KEY3   0x88

Definition at line 101 of file numicro.c.

◆ REG_LOCK

#define REG_LOCK   0x00

Definition at line 102 of file numicro.c.

Function Documentation

◆ COMMAND_HANDLER() [1/3]

COMMAND_HANDLER ( numicro_handle_chip_erase_command  )

◆ COMMAND_HANDLER() [2/3]

COMMAND_HANDLER ( numicro_handle_read_isp_command  )

◆ COMMAND_HANDLER() [3/3]

COMMAND_HANDLER ( numicro_handle_write_isp_command  )

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( numicro_flash_bank_command  )

Definition at line 1119 of file numicro.c.

References bank, CMD_ARGC, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, and LOG_DEBUG.

◆ numicro_auto_probe()

static int numicro_auto_probe ( struct flash_bank bank)
static

Definition at line 1109 of file numicro.c.

References bank, ERROR_OK, numicro_probe(), and numicro_flash_bank::probed.

◆ numicro_erase()

◆ numicro_fmc_cmd()

static uint32_t numicro_fmc_cmd ( struct target target,
uint32_t  cmd,
uint32_t  addr,
uint32_t  wdata,
uint32_t *  rdata 
)
static

◆ numicro_get_arm_arch()

◆ numicro_get_cpu_type()

static int numicro_get_cpu_type ( struct target target,
const struct numicro_cpu_type **  cpu 
)
static

◆ numicro_get_flash_size()

static int numicro_get_flash_size ( struct flash_bank bank,
const struct numicro_cpu_type cpu,
uint32_t *  flash_size 
)
static

◆ numicro_init_isp()

◆ numicro_probe()

◆ numicro_protect_check()

◆ numicro_reg_unlock()

static int numicro_reg_unlock ( struct target target)
static

◆ numicro_write()

◆ numicro_writeblock()

Variable Documentation

◆ m_address_bias_offset

◆ m_page_size

uint32_t m_page_size = NUMICRO_PAGESIZE
static

Definition at line 539 of file numicro.c.

Referenced by numicro_get_arm_arch(), numicro_probe(), and numicro_writeblock().

◆ numicro_command_handlers

const struct command_registration numicro_command_handlers[]
static
Initial value:
= {
{
.name = "numicro",
.mode = COMMAND_ANY,
.help = "numicro flash command group",
.usage = "",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_ANY
Definition: command.h:42
static const struct command_registration numicro_exec_command_handlers[]
Definition: numicro.c:1218

Definition at line 1192 of file numicro.c.

◆ numicro_exec_command_handlers

const struct command_registration numicro_exec_command_handlers[]
static
Initial value:
= {
{
.name = "read_isp",
.handler = numicro_handle_read_isp_command,
.usage = "address",
.mode = COMMAND_EXEC,
.help = "read flash through ISP.",
},
{
.name = "write_isp",
.handler = numicro_handle_write_isp_command,
.usage = "address value",
.mode = COMMAND_EXEC,
.help = "write flash through ISP.",
},
{
.name = "chip_erase",
.handler = numicro_handle_chip_erase_command,
.mode = COMMAND_EXEC,
.help = "chip erase through ISP.",
.usage = "",
},
}
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 1192 of file numicro.c.

◆ numicro_flash

const struct flash_driver numicro_flash
Initial value:
= {
.name = "numicro",
.flash_bank_command = numicro_flash_bank_command,
.erase = numicro_erase,
.write = numicro_write,
.probe = numicro_probe,
.auto_probe = numicro_auto_probe,
.erase_check = default_flash_blank_check,
.protect_check = numicro_protect_check,
.free_driver_priv = default_flash_free_driver_priv,
}
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
int default_flash_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Provides default read implementation for flash memory.
void default_flash_free_driver_priv(struct flash_bank *bank)
Deallocates bank->driver_priv.
static int numicro_probe(struct flash_bank *bank)
Definition: numicro.c:1066
static int numicro_protect_check(struct flash_bank *bank)
Definition: numicro.c:809
static int numicro_auto_probe(struct flash_bank *bank)
Definition: numicro.c:1109
static int numicro_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: numicro.c:926
static int numicro_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: numicro.c:855
static const struct command_registration numicro_command_handlers[]
Definition: numicro.c:1243

Definition at line 1192 of file numicro.c.

◆ numicro_flash_write_code

const uint8_t numicro_flash_write_code[]
static
Initial value:
= {
}

Definition at line 683 of file numicro.c.

Referenced by numicro_writeblock().

◆ numicro_m4_flash_write_code

const uint8_t numicro_m4_flash_write_code[]
static
Initial value:
= {
}

Definition at line 687 of file numicro.c.

Referenced by numicro_writeblock().

◆ numicro_parts

const struct numicro_cpu_type numicro_parts[]
static

Definition at line 1 of file numicro.c.

Referenced by numicro_get_cpu_type().