2020 */
2121
2222#include <stdint.h>
23+ #include <image.h>
2324/* STM32 F4 register configuration */
2425
2526/* Assembly helpers */
@@ -135,12 +136,12 @@ const uint32_t flash_sector[FLASH_SECTORS + 1] = {
135136 FLASH_TOP
136137};
137138
138- static void flash_set_waitstates (int waitstates )
139+ static void RAMFUNCTION flash_set_waitstates (int waitstates )
139140{
140141 FLASH_ACR |= waitstates | FLASH_ACR_ENABLE_DATA_CACHE | FLASH_ACR_ENABLE_INST_CACHE ;
141142}
142143
143- static void flash_wait_complete (void )
144+ static RAMFUNCTION void flash_wait_complete (void )
144145{
145146 while ((FLASH_SR & FLASH_SR_BSY ) == FLASH_SR_BSY )
146147 ;
@@ -155,7 +156,7 @@ static void mass_erase(void)
155156}
156157*/
157158
158- static void flash_erase_sector (uint32_t sec )
159+ static void RAMFUNCTION flash_erase_sector (uint32_t sec )
159160{
160161 uint32_t reg = FLASH_CR & (~(FLASH_CR_SNB_MASK << FLASH_CR_SNB_SHIFT ));
161162 FLASH_CR = reg | (sec & FLASH_CR_SNB_MASK ) << FLASH_CR_SNB_SHIFT ;
@@ -166,12 +167,12 @@ static void flash_erase_sector(uint32_t sec)
166167 FLASH_CR &= ~(FLASH_CR_SNB_MASK << FLASH_CR_SNB_SHIFT );
167168}
168169
169- static void clear_errors (void )
170+ static void RAMFUNCTION clear_errors (void )
170171{
171172 FLASH_SR |= ( FLASH_SR_PGSERR | FLASH_SR_PGPERR | FLASH_SR_PGAERR | FLASH_SR_WRPERR | FLASH_SR_OPERR | FLASH_SR_EOP );
172173}
173174
174- int hal_flash_write (uint32_t address , const uint8_t * data , int len )
175+ int RAMFUNCTION hal_flash_write (uint32_t address , const uint8_t * data , int len )
175176{
176177 int i ;
177178 uint32_t val ;
@@ -188,20 +189,20 @@ int hal_flash_write(uint32_t address, const uint8_t *data, int len)
188189 return 0 ;
189190}
190191
191- void hal_flash_unlock (void )
192+ void RAMFUNCTION hal_flash_unlock (void )
192193{
193194 FLASH_CR |= FLASH_CR_LOCK ;
194195 FLASH_KEYR = FLASH_KEY1 ;
195196 FLASH_KEYR = FLASH_KEY2 ;
196197}
197198
198- void hal_flash_lock (void )
199+ void RAMFUNCTION hal_flash_lock (void )
199200{
200201 FLASH_CR |= FLASH_CR_LOCK ;
201202}
202203
203204
204- int hal_flash_erase (uint32_t address , int len )
205+ int RAMFUNCTION hal_flash_erase (uint32_t address , int len )
205206{
206207 int start = -1 , end = -1 ;
207208 uint32_t end_address ;
0 commit comments