1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
//*****************************************************************************
//
// bl_flash.h - Flash programming functions used by the boot loader.
//
// Copyright (c) 2006-2014 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
//
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
//
// This is part of revision 2.1.0.12573 of the Tiva Firmware Development Package.
//
//*****************************************************************************
#ifndef __BL_FLASH_H__
#define __BL_FLASH_H__
#include "driverlib/rom.h"
//*****************************************************************************
//
// Basic functions for erasing and programming internal flash.
//
//*****************************************************************************
extern void BLInternalFlashErase(uint32_t ui32Address);
extern void BLInternalFlashProgram(uint32_t ui32DstAddr, uint8_t *pui8SrcData,
uint32_t ui32Length);
extern uint32_t BLInternalFlashSizeGet(void);
extern uint32_t BLInternalFlashStartAddrCheck(uint32_t ui32Addr,
uint32_t ui32ImgSize);
extern uint32_t BLInternalFlashErrorCheck(void);
extern void BLInternalFlashErrorClear(void);
//*****************************************************************************
//
// If the user has not specified which flash programming functions to use,
// default to the basic, internal flash functions on Sandstorm, Fury and
// DustDevil parts or the ROM-resident function for Tempest-class parts.
//
//*****************************************************************************
#ifndef BL_FLASH_ERASE_FN_HOOK
#define BL_FLASH_ERASE_FN_HOOK(ui32Address) \
{ \
HWREG(FLASH_FMA) = (ui32Address); \
HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_ERASE; \
while(HWREG(FLASH_FMC) & FLASH_FMC_ERASE) \
{ \
} \
}
#else
extern void BL_FLASH_ERASE_FN_HOOK(uint32_t ui32Address);
#endif
#ifndef BL_FLASH_PROGRAM_FN_HOOK
#ifdef ROM_FlashProgram
#define BL_FLASH_PROGRAM_FN_HOOK(ui32DstAddr, pui8SrcData, ui32Length) \
ROM_FlashProgram((uint32_t *)pui8SrcData, ui32DstAddr, \
(((ui32Length) + 3) & ~3))
#else
#define BL_FLASH_PROGRAM_FN_HOOK(ui32DstAddr, pui8SrcData, ui32Length) \
{ \
uint32_t ui32FlashProgLoop; \
\
for(ui32FlashProgLoop = 0; ui32FlashProgLoop < (ui32Length); \
ui32FlashProgLoop += 4) \
{ \
HWREG(FLASH_FMA) = (ui32DstAddr) + ui32FlashProgLoop; \
HWREG(FLASH_FMD) = *(uint32_t *)((pui8SrcData) + \
ui32FlashProgLoop); \
HWREG(FLASH_FMC) = FLASH_FMC_WRKEY | FLASH_FMC_WRITE; \
while(HWREG(FLASH_FMC) & FLASH_FMC_WRITE) \
{ \
} \
} \
}
#endif
#else
extern uint32_t BL_FLASH_PROGRAM_FN_HOOK(uint32_t ui32DstAddr,
uint8_t *pui8SrcData,
uint32_t ui32Length);
#endif
#ifndef BL_FLASH_CL_ERR_FN_HOOK
#define BL_FLASH_CL_ERR_FN_HOOK() HWREG(FLASH_FCMISC) = FLASH_FCMISC_AMISC
#else
extern void BL_FLASH_CL_ERR_FN_HOOK(void);
#endif
#ifndef BL_FLASH_ERROR_FN_HOOK
#define BL_FLASH_ERROR_FN_HOOK() (HWREG(FLASH_FCRIS) & FLASH_FCRIS_ARIS)
#else
extern uint32_t BL_FLASH_ERROR_FN_HOOK(void);
#endif
#ifndef BL_FLASH_SIZE_FN_HOOK
#define BL_FLASH_SIZE_FN_HOOK() \
(((HWREG(SYSCTL_DC0) & SYSCTL_DC0_FLASHSZ_M) + 1) << 11)
#else
extern uint32_t BL_FLASH_SIZE_FN_HOOK(void);
#endif
#ifndef BL_FLASH_END_FN_HOOK
#define BL_FLASH_END_FN_HOOK() \
(((HWREG(SYSCTL_DC0) & SYSCTL_DC0_FLASHSZ_M) + 1) << 11)
#else
extern uint32_t BL_FLASH_END_FN_HOOK(void);
#endif
#ifndef BL_FLASH_AD_CHECK_FN_HOOK
#define BL_FLASH_AD_CHECK_FN_HOOK(ui32Addr, ui32Size) \
BLInternalFlashStartAddrCheck((ui32Addr), (ui32Size))
#else
extern uint32_t BL_FLASH_AD_CHECK_FN_HOOK(uint32_t ui32Address,
uint32_t ui32Length);
#endif
#endif // __BL_FLASH_H__
|