#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <sys/time.h>
#include "dbg_msg.h"
#include "jt_arm.h"
#include "jt_instr.h"
#include "jt_flash.h"
#include "convert.h"
Flash support functions
#define STM32F10X_FLASH_BASE 0x40022000 |
#define STM32F10X_FLASH_ACR (STM32F10X_FLASH_BASE) |
Referenced by jt_stm32f10xSetupACR().
#define STM32F10X_FLASH_KEYR (STM32F10X_FLASH_BASE + 0x04) |
Referenced by jt_stm32f10xflashEraseSector().
#define STM32F10X_FLASH_OPTKEYR (STM32F10X_FLASH_BASE + 0x08) |
#define STM32F10X_FLASH_SR (STM32F10X_FLASH_BASE + 0x0C) |
Referenced by jt_stm32f10xflashEraseSector().
#define STM32F10X_FLASH_CR (STM32F10X_FLASH_BASE + 0x10) |
Referenced by jt_stm32f10xflashEraseSector().
#define STM32F10X_FLASH_AR (STM32F10X_FLASH_BASE + 0x14) |
Referenced by jt_stm32f10xflashEraseSector().
#define STM32F10X_FLASH_OBR (STM32F10X_FLASH_BASE + 0x1C) |
#define STM32F10X_FLASH_WRPR (STM32F10X_FLASH_BASE + 0x20) |
#define STM32F10X_KEY1 0x45670123 |
Referenced by jt_stm32f10xflashEraseSector().
#define STM32F10X_KEY2 0xCDEF89ab |
Referenced by jt_stm32f10xflashEraseSector().
#define STM32F10X_RDPTR_KEY 0xa5 |
int jt_stm32f10xflashEraseSector | ( | uint32_t | base_address, | |
uint32_t | address | |||
) |
Support Function to Erase a Sector within the Flash
base_address | First address of the Flash that has to be erased | |
address | Addres within the sector which has to to be erased |
0 | success | |
1 | error |
References convertDiffTimeToMsec, DBG_LEVEL_GDB_ARM_ERROR, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), jtag_arm_ReadWord(), jtag_arm_WriteWord(), STM32F10X_FLASH_AR, STM32F10X_FLASH_CR, STM32F10X_FLASH_KEYR, STM32F10X_FLASH_SR, STM32F10X_KEY1, STM32F10X_KEY2, transactionActivate(), transactionCreate(), transactionErase(), and transactionExecute().
Referenced by stm32FlashErase().
int jt_stm32f10xOptionByteflashProgHalfword | ( | uint32_t | base_address, | |
uint32_t | address, | |||
uint16_t | data, | |||
unsigned | wait | |||
) |
Support Function to write one Halfword to the OptionByte-Flash.
This is OK after an erase of a Sector.
base_address | flash base address | |
address | byte address to write | |
data | 16-bit data value | |
wait | if true wait for completion |
0 | success | |
1 | error |
References DBG_LEVEL_GDB_ARM_WARN, and dbgPrintf().
void jt_stm32f10xSetupACR | ( | int | clk_in_mhz | ) |
Support Function to Setup STM32F10x Flash controller
clk_in_mhz | System Clock (SYSCLK) in MHz |
References jtag_arm_ReadWord(), jtag_arm_WriteWord(), STM32F10X_FLASH_ACR, transactionActivate(), transactionCreate(), transactionErase(), and transactionExecute().