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

Go to the source code of this file.

Data Structures

struct  ambiqmicro_flash_bank
 

Macros

#define CHECK_STATUS(rc, msg)
 Check error, log error. More...
 
#define FLASH_ERASE_LIST_MAIN_PAGES_FROM_SRAM   0x08000065
 
#define FLASH_MASS_ERASE_MAIN_PAGES_FROM_SRAM   0x08000069
 
#define FLASH_PROGRAM_MAIN_FROM_SRAM   0x0800005d
 
#define FLASH_PROGRAM_OTP_FROM_SRAM   0x08000061
 
#define OTP_PROGRAM_KEY   (0x87655678)
 
#define PROGRAM_KEY   (0x12344321)
 

Functions

static int ambiqmicro_erase (struct flash_bank *bank, unsigned int first, unsigned int last)
 
static int ambiqmicro_exec_command (struct target *target, uint32_t command, uint32_t flash_return_address)
 
static int ambiqmicro_mass_erase (struct flash_bank *bank)
 
static int ambiqmicro_otp_program (struct flash_bank *bank, uint32_t offset, uint32_t count)
 
static int ambiqmicro_probe (struct flash_bank *bank)
 
static int ambiqmicro_protect (struct flash_bank *bank, int set, unsigned int first, unsigned int last)
 
static int ambiqmicro_protect_check (struct flash_bank *bank)
 
static int ambiqmicro_read_part_info (struct flash_bank *bank)
 
static int ambiqmicro_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int ambiqmicro_write_block (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 
static int check_flash_status (struct target *target, uint32_t address)
 Read flash status from bootloader. More...
 
 COMMAND_HANDLER (ambiqmicro_handle_mass_erase_command)
 
 COMMAND_HANDLER (ambiqmicro_handle_page_erase_command)
 
 COMMAND_HANDLER (ambiqmicro_handle_program_otp_command)
 Program the otp block. More...
 
 FLASH_BANK_COMMAND_HANDLER (ambiqmicro_flash_bank_command)
 
static int get_ambiqmicro_info (struct flash_bank *bank, struct command_invocation *cmd)
 

Variables

static char * ambiqmicro_classname [6]
 
static const struct command_registration ambiqmicro_command_handlers []
 
static const struct command_registration ambiqmicro_exec_command_handlers []
 
const struct flash_driver ambiqmicro_flash
 
struct {
   uint8_t   class
 
   const char *   partname
 
   uint8_t   partno
 
ambiqmicro_parts [6]
 
static const uint32_t apollo_flash_size []
 
static const uint32_t apollo_sram_size []
 

Macro Definition Documentation

◆ CHECK_STATUS

#define CHECK_STATUS (   rc,
  msg 
)
Value:
{ \
if (rc != ERROR_OK) { \
LOG_ERROR("status(%d):%s\n", rc, msg); } }
#define ERROR_OK
Definition: log.h:164

Check error, log error.

Definition at line 31 of file ambiqmicro.c.

◆ FLASH_ERASE_LIST_MAIN_PAGES_FROM_SRAM

#define FLASH_ERASE_LIST_MAIN_PAGES_FROM_SRAM   0x08000065

Definition at line 43 of file ambiqmicro.c.

◆ FLASH_MASS_ERASE_MAIN_PAGES_FROM_SRAM

#define FLASH_MASS_ERASE_MAIN_PAGES_FROM_SRAM   0x08000069

Definition at line 44 of file ambiqmicro.c.

◆ FLASH_PROGRAM_MAIN_FROM_SRAM

#define FLASH_PROGRAM_MAIN_FROM_SRAM   0x0800005d

Definition at line 41 of file ambiqmicro.c.

◆ FLASH_PROGRAM_OTP_FROM_SRAM

#define FLASH_PROGRAM_OTP_FROM_SRAM   0x08000061

Definition at line 42 of file ambiqmicro.c.

◆ OTP_PROGRAM_KEY

#define OTP_PROGRAM_KEY   (0x87655678)

Definition at line 39 of file ambiqmicro.c.

◆ PROGRAM_KEY

#define PROGRAM_KEY   (0x12344321)

Definition at line 38 of file ambiqmicro.c.

Function Documentation

◆ ambiqmicro_erase()

◆ ambiqmicro_exec_command()

static int ambiqmicro_exec_command ( struct target target,
uint32_t  command,
uint32_t  flash_return_address 
)
static

◆ ambiqmicro_mass_erase()

◆ ambiqmicro_otp_program()

◆ ambiqmicro_probe()

static int ambiqmicro_probe ( struct flash_bank bank)
static

◆ ambiqmicro_protect()

static int ambiqmicro_protect ( struct flash_bank bank,
int  set,
unsigned int  first,
unsigned int  last 
)
static

Definition at line 501 of file ambiqmicro.c.

References bank, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, LOG_INFO, and TARGET_HALTED.

◆ ambiqmicro_protect_check()

static int ambiqmicro_protect_check ( struct flash_bank bank)
static

◆ ambiqmicro_read_part_info()

◆ ambiqmicro_write()

static int ambiqmicro_write ( struct flash_bank bank,
const uint8_t *  buffer,
uint32_t  offset,
uint32_t  count 
)
static

Definition at line 611 of file ambiqmicro.c.

References ambiqmicro_write_block(), bank, buffer, count, ERROR_OK, LOG_ERROR, and offset.

◆ ambiqmicro_write_block()

static int ambiqmicro_write_block ( struct flash_bank bank,
const uint8_t *  buffer,
uint32_t  offset,
uint32_t  count 
)
static

◆ check_flash_status()

static int check_flash_status ( struct target target,
uint32_t  address 
)
static

Read flash status from bootloader.

Definition at line 264 of file ambiqmicro.c.

References ERROR_FLASH_OPERATION_FAILED, ERROR_OK, LOG_DEBUG, LOG_ERROR, and target_read_u32().

Referenced by ambiqmicro_exec_command().

◆ COMMAND_HANDLER() [1/3]

COMMAND_HANDLER ( ambiqmicro_handle_mass_erase_command  )

◆ COMMAND_HANDLER() [2/3]

COMMAND_HANDLER ( ambiqmicro_handle_page_erase_command  )

◆ COMMAND_HANDLER() [3/3]

COMMAND_HANDLER ( ambiqmicro_handle_program_otp_command  )

Program the otp block.

Definition at line 791 of file ambiqmicro.c.

◆ FLASH_BANK_COMMAND_HANDLER()

FLASH_BANK_COMMAND_HANDLER ( ambiqmicro_flash_bank_command  )

◆ get_ambiqmicro_info()

Variable Documentation

◆ ambiqmicro_classname

char* ambiqmicro_classname[6]
static
Initial value:
= {
"Unknown", "Apollo", "Apollo2", "Unknown", "Unknown", "Apollo"
}

Definition at line 110 of file ambiqmicro.c.

Referenced by get_ambiqmicro_info().

◆ ambiqmicro_command_handlers

const struct command_registration ambiqmicro_command_handlers[]
static
Initial value:
= {
{
.name = "ambiqmicro",
.mode = COMMAND_EXEC,
.help = "ambiqmicro flash command group",
.usage = "Support for Ambiq Micro parts.",
},
}
static const struct command_registration ambiqmicro_exec_command_handlers[]
Definition: ambiqmicro.c:817
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 791 of file ambiqmicro.c.

◆ ambiqmicro_exec_command_handlers

const struct command_registration ambiqmicro_exec_command_handlers[]
static
Initial value:
= {
{
.name = "mass_erase",
.usage = "<bank>",
.handler = ambiqmicro_handle_mass_erase_command,
.mode = COMMAND_EXEC,
.help = "Erase entire device",
},
{
.name = "page_erase",
.usage = "<bank> <first> <last>",
.handler = ambiqmicro_handle_page_erase_command,
.mode = COMMAND_EXEC,
.help = "Erase device pages",
},
{
.name = "program_otp",
.handler = ambiqmicro_handle_program_otp_command,
.mode = COMMAND_EXEC,
.usage = "<bank> <offset> <count>",
.help =
"Program OTP (assumes you have already written array starting at 0x10000010)",
},
}

Definition at line 791 of file ambiqmicro.c.

◆ ambiqmicro_flash

const struct flash_driver ambiqmicro_flash
Initial value:
= {
.name = "ambiqmicro",
.flash_bank_command = ambiqmicro_flash_bank_command,
.erase = ambiqmicro_erase,
.protect = ambiqmicro_protect,
.write = ambiqmicro_write,
.probe = ambiqmicro_probe,
.auto_probe = ambiqmicro_probe,
.erase_check = default_flash_blank_check,
.protect_check = ambiqmicro_protect_check,
.free_driver_priv = default_flash_free_driver_priv,
}
static int ambiqmicro_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Definition: ambiqmicro.c:501
static int ambiqmicro_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: ambiqmicro.c:611
static const struct command_registration ambiqmicro_command_handlers[]
Definition: ambiqmicro.c:842
static int ambiqmicro_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: ambiqmicro.c:400
static int ambiqmicro_protect_check(struct flash_bank *bank)
Definition: ambiqmicro.c:246
static int ambiqmicro_probe(struct flash_bank *bank)
Definition: ambiqmicro.c:624
static int get_ambiqmicro_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: ambiqmicro.c:139
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.

Definition at line 791 of file ambiqmicro.c.

◆ 

struct { ... } ambiqmicro_parts[6]
Initial value:
= {
{0xFF, 0x00, "Unknown"},
{0x01, 0x00, "Apollo"},
{0x02, 0x00, "Apollo2"},
{0x03, 0x00, "Unknown"},
{0x04, 0x00, "Unknown"},
{0x05, 0x00, "Apollo"},
}

Referenced by ambiqmicro_read_part_info().

◆ apollo_flash_size

const uint32_t apollo_flash_size[]
static
Initial value:
= {
1 << 15,
1 << 16,
1 << 17,
1 << 18,
1 << 19,
1 << 20,
1 << 21
}

Definition at line 47 of file ambiqmicro.c.

Referenced by ambiqmicro_read_part_info().

◆ apollo_sram_size

const uint32_t apollo_sram_size[]
static
Initial value:
= {
1 << 15,
1 << 16,
1 << 17,
1 << 18,
1 << 19,
1 << 20,
1 << 21
}

Definition at line 57 of file ambiqmicro.c.

Referenced by ambiqmicro_read_part_info().

◆ class

uint8_t class

Definition at line 98 of file ambiqmicro.c.

◆ partname

const char* partname

Definition at line 100 of file ambiqmicro.c.

◆ partno

uint8_t partno

Definition at line 99 of file ambiqmicro.c.