#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sysexits.h>
#include <ctype.h>
#include <unistd.h>
#include "dbg_msg.h"
#include "jt_arm.h"
#include "jt_flash.h"
#include "arm_gdbstub.h"
#include "arm_memory_mmap.h"
#include "arm_memory_workspace.h"
#include "convert.h"
#define SAM7_MC_FMR__FMCN | ( | _x_ | ) | (((_x_)&0xFF)<<16) |
#define SAM7_MC_FMR__FWS | ( | _x_ | ) | (((_x_)&0x3)<<8) |
#define SAM7_MC_FMR__NEBP | ( | _x_ | ) | (((_x_)&0x1)<<7) |
#define SAM7_MC_FCR__KEY (0x5A<<24) |
#define SAM7_MC_FCR__PAGEN | ( | _x_ | ) | (((_x_)&0x3FF)<<8) |
#define SAM7_MC_FCR__FCMD | ( | _x_ | ) | (((_x_)&0xF)) |
#define SAM7_MC_FCR__FCMD_WP 1 |
Referenced by atmelFlashErase(), atmelFlashEraseAndProgram(), and atmelFlashProgramOnly().
#define SAM7_MC_FCR__FCMD_SLB 2 |
Referenced by atmelFlashLock().
#define SAM7_MC_FCR__FCMD_WPL 3 |
#define SAM7_MC_FCR__FCMD_CLB 4 |
Referenced by atmelFlashUnlock().
#define SAM7_MC_FCR__FCMD_EA 8 |
#define SAM7_MC_FCR__FCMD_SGPB 11 |
Referenced by atmelFlashSetGPNVM().
#define SAM7_MC_FCR__FCMD_CGPB 13 |
Referenced by atmelFlashClearGPNVM().
#define SAM7_MC_FCR__FCMD_SSB 15 |
int atmelFlashEraseAndProgram | ( | uint32_t | addr, | |
int | pageNumber, | |||
int | pageSize, | |||
uint32_t * | data | |||
) |
Atmel SAM7 flash. erase and program one or more pages
(using commonVar.SAM7_frequence)
addr | Flash page address start | |
pageNumber | ||
pageSize | ||
data | Pointer to 32 bit source of data |
References memMap::baseAddr, convertDiffTimeToMsec, DBG_LEVEL_GDB_ARM_ERROR, DBG_LEVEL_GDB_ARM_INFO, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), getWorkSpace(), ICERT_REG_DCC_CONTROL, ICERT_REG_DCC_DATA, IF_DBG, jtag_arm_IceRT_RegRead(), jtag_arm_IceRT_RegRead_Once(), jtag_arm_IceRT_RegWrite(), jtag_arm_Mointor2DebugMode(), jtag_arm_PollDbgState(), jtag_arm_RunProgram(), memMap::memBufferType, memMap::MemBufferType::Workspace::offset, SAM7_MC_FCR__FCMD, SAM7_MC_FCR__FCMD_WP, SAM7_MC_FCR__KEY, SAM7_MC_FCR__PAGEN, SAM7_MC_FMR__FMCN, SAM7_MC_FMR__FWS, SAM7_MC_FMR__NEBP, useWorkspace(), memMap::MemBufferType::Workspace, and WORKSPACE_ALGO_FLASH_ATMEL.
int atmelFlashProgramOnly | ( | uint32_t | addr, | |
int | pageNumber, | |||
int | pageSize, | |||
uint32_t * | data | |||
) |
Atmel SAM7 flash. program one or more pages (without erasing it before)
(using commonVar.SAM7_frequence)
addr | Flash page address start | |
pageNumber | ||
pageSize | ||
data | Pointer to 32 bit source of data |
References memMap::baseAddr, convertDiffTimeToMsec, DBG_LEVEL_GDB_ARM_ERROR, DBG_LEVEL_GDB_ARM_INFO, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), getWorkSpace(), ICERT_REG_DCC_CONTROL, ICERT_REG_DCC_DATA, IF_DBG, jtag_arm_IceRT_RegRead(), jtag_arm_IceRT_RegRead_Once(), jtag_arm_IceRT_RegWrite(), jtag_arm_Mointor2DebugMode(), jtag_arm_PollDbgState(), jtag_arm_RunProgram(), memMap::memBufferType, memMap::MemBufferType::Workspace::offset, SAM7_MC_FCR__FCMD, SAM7_MC_FCR__FCMD_WP, SAM7_MC_FCR__KEY, SAM7_MC_FCR__PAGEN, SAM7_MC_FMR__FMCN, SAM7_MC_FMR__FWS, SAM7_MC_FMR__NEBP, useWorkspace(), memMap::MemBufferType::Workspace, and WORKSPACE_ALGO_FLASH_ATMEL.
Referenced by programFlashCB_write_sector().
int atmelFlashUnlock | ( | uint32_t | addr, | |
int | pageNumber | |||
) |
Atmel flash unlock.
(using commonVar.SAM7_frequence)
addr | Flash page address start | |
pageNumber |
0 | on success | |
>=1 | else errro number |
References memMap::baseAddr, convertDiffTimeToMsec, DBG_LEVEL_GDB_ARM_ERROR, DBG_LEVEL_GDB_ARM_INFO, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), getWorkSpace(), ICERT_REG_DCC_CONTROL, ICERT_REG_DCC_DATA, IF_DBG, jtag_arm_IceRT_RegRead(), jtag_arm_IceRT_RegRead_Once(), jtag_arm_IceRT_RegWrite(), jtag_arm_Mointor2DebugMode(), jtag_arm_PollDbgState(), jtag_arm_RunProgram(), memMap::memBufferType, memMap::MemBufferType::Workspace::offset, SAM7_MC_FCR__FCMD, SAM7_MC_FCR__FCMD_CLB, SAM7_MC_FCR__KEY, SAM7_MC_FCR__PAGEN, SAM7_MC_FMR__FMCN, SAM7_MC_FMR__FWS, SAM7_MC_FMR__NEBP, useWorkspace(), memMap::MemBufferType::Workspace, and WORKSPACE_ALGO_FLASH_ATMEL.
Referenced by eraseFlashCB_sector(), and programFlashCB_write_sector().
int atmelFlashLock | ( | uint32_t | addr, | |
int | pageNumber | |||
) |
Atmel flash lock.
(using commonVar.SAM7_frequence)
addr | Flash page address start | |
pageNumber |
0 | on success | |
>=1 | else errro number |
References memMap::baseAddr, convertDiffTimeToMsec, DBG_LEVEL_GDB_ARM_ERROR, DBG_LEVEL_GDB_ARM_INFO, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), getWorkSpace(), ICERT_REG_DCC_CONTROL, ICERT_REG_DCC_DATA, IF_DBG, jtag_arm_IceRT_RegRead(), jtag_arm_IceRT_RegRead_Once(), jtag_arm_IceRT_RegWrite(), jtag_arm_Mointor2DebugMode(), jtag_arm_PollDbgState(), jtag_arm_RunProgram(), memMap::memBufferType, memMap::MemBufferType::Workspace::offset, SAM7_MC_FCR__FCMD, SAM7_MC_FCR__FCMD_SLB, SAM7_MC_FCR__KEY, SAM7_MC_FCR__PAGEN, SAM7_MC_FMR__FMCN, SAM7_MC_FMR__FWS, SAM7_MC_FMR__NEBP, useWorkspace(), memMap::MemBufferType::Workspace, and WORKSPACE_ALGO_FLASH_ATMEL.
int atmelFlashSetGPNVM | ( | int | bitNumber | ) |
Atmel flash set GPNVM Bit.
(using commonVar.SAM7_frequence)
bitNumber |
0 | on success | |
>=1 | else errro number |
References memMap::baseAddr, convertDiffTimeToMsec, DBG_LEVEL_GDB_ARM_ERROR, DBG_LEVEL_GDB_ARM_INFO, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), getWorkSpace(), ICERT_REG_DCC_CONTROL, ICERT_REG_DCC_DATA, IF_DBG, jtag_arm_IceRT_RegRead(), jtag_arm_IceRT_RegRead_Once(), jtag_arm_IceRT_RegWrite(), jtag_arm_Mointor2DebugMode(), jtag_arm_PollDbgState(), jtag_arm_RunProgram(), memMap::memBufferType, memMap::MemBufferType::Workspace::offset, SAM7_MC_FCR__FCMD, SAM7_MC_FCR__FCMD_SGPB, SAM7_MC_FCR__KEY, SAM7_MC_FCR__PAGEN, SAM7_MC_FMR__FMCN, SAM7_MC_FMR__FWS, SAM7_MC_FMR__NEBP, useWorkspace(), memMap::MemBufferType::Workspace, and WORKSPACE_ALGO_FLASH_ATMEL.
Referenced by gdb_monitor_Rcmd().
int atmelFlashClearGPNVM | ( | int | bitNumber | ) |
Atmel flash clear GPNVM Bit.
(using commonVar.SAM7_frequence)
bitNumber |
0 | on success | |
>=1 | else errro number |
References memMap::baseAddr, convertDiffTimeToMsec, DBG_LEVEL_GDB_ARM_ERROR, DBG_LEVEL_GDB_ARM_INFO, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), getWorkSpace(), ICERT_REG_DCC_CONTROL, ICERT_REG_DCC_DATA, IF_DBG, jtag_arm_IceRT_RegRead(), jtag_arm_IceRT_RegRead_Once(), jtag_arm_IceRT_RegWrite(), jtag_arm_Mointor2DebugMode(), jtag_arm_PollDbgState(), jtag_arm_RunProgram(), memMap::memBufferType, memMap::MemBufferType::Workspace::offset, SAM7_MC_FCR__FCMD, SAM7_MC_FCR__FCMD_CGPB, SAM7_MC_FCR__KEY, SAM7_MC_FCR__PAGEN, SAM7_MC_FMR__FMCN, SAM7_MC_FMR__FWS, SAM7_MC_FMR__NEBP, useWorkspace(), memMap::MemBufferType::Workspace, and WORKSPACE_ALGO_FLASH_ATMEL.
Referenced by gdb_monitor_Rcmd().
int atmelFlashErase | ( | uint32_t | addr, | |
int | pageNumber | |||
) |
Atmel SAM7 flash.
(using commonVar.SAM7_frequence)
addr | Flash page address start | |
pageNumber |
0 | on success | |
>=1 | else errro number |
References memMap::baseAddr, convertDiffTimeToMsec, DBG_LEVEL_GDB_ARM_ERROR, DBG_LEVEL_GDB_ARM_INFO, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), getWorkSpace(), ICERT_REG_DCC_CONTROL, ICERT_REG_DCC_DATA, IF_DBG, jtag_arm_IceRT_RegRead(), jtag_arm_IceRT_RegRead_Once(), jtag_arm_IceRT_RegWrite(), jtag_arm_Mointor2DebugMode(), jtag_arm_PollDbgState(), jtag_arm_RunProgram(), memMap::memBufferType, memMap::MemBufferType::Workspace::offset, SAM7_MC_FCR__FCMD, SAM7_MC_FCR__FCMD_WP, SAM7_MC_FCR__KEY, SAM7_MC_FCR__PAGEN, SAM7_MC_FMR__FMCN, SAM7_MC_FMR__FWS, SAM7_MC_FMR__NEBP, useWorkspace(), memMap::MemBufferType::Workspace, and WORKSPACE_ALGO_FLASH_ATMEL.
Referenced by eraseFlashCB_sector(), and programFlashCB_write_sector().
uint32_t atmelFlashGetStatus | ( | uint32_t | addr | ) |
Atmel SAM7 flash. read AT91SAM7 Flash Status Register
addr | Flash page address start |
References jtag_arm_ReadWord().
Referenced by eraseFlashCB_sector(), and programFlashCB_write_sector().