Revision 367c0652
Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot/blt_conf.h | ||
---|---|---|
1 |
/************************************************************************************//** |
|
2 |
* \file Demo\ARMCM3_STM32_Olimex_STM32P103_GCC\Boot\blt_conf.h |
|
3 |
* \brief Bootloader configuration header file. |
|
4 |
* \ingroup Boot_ARMCM3_STM32_Olimex_STM32P103_GCC |
|
5 |
* \internal |
|
6 |
*---------------------------------------------------------------------------------------- |
|
7 |
* C O P Y R I G H T |
|
8 |
*---------------------------------------------------------------------------------------- |
|
9 |
* Copyright (c) 2012 by Feaser http://www.feaser.com All rights reserved |
|
10 |
* |
|
11 |
*---------------------------------------------------------------------------------------- |
|
12 |
* L I C E N S E |
|
13 |
*---------------------------------------------------------------------------------------- |
|
14 |
* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or |
|
15 |
* modify it under the terms of the GNU General Public License as published by the Free |
|
16 |
* Software Foundation, either version 3 of the License, or (at your option) any later |
|
17 |
* version. |
|
18 |
* |
|
19 |
* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
20 |
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
21 |
* PURPOSE. See the GNU General Public License for more details. |
|
22 |
* |
|
23 |
* You should have received a copy of the GNU General Public License along with OpenBLT. |
|
24 |
* If not, see <http://www.gnu.org/licenses/>. |
|
25 |
* |
|
26 |
* A special exception to the GPL is included to allow you to distribute a combined work |
|
27 |
* that includes OpenBLT without being obliged to provide the source code for any |
|
28 |
* proprietary components. The exception text is included at the bottom of the license |
|
29 |
* file <license.html>. |
|
30 |
* |
|
31 |
* \endinternal |
|
32 |
****************************************************************************************/ |
|
33 |
#ifndef BLT_CONF_H |
|
34 |
#define BLT_CONF_H |
|
35 |
|
|
36 |
/**************************************************************************************** |
|
37 |
* C P U D R I V E R C O N F I G U R A T I O N |
|
38 |
****************************************************************************************/ |
|
39 |
/* To properly initialize the baudrate clocks of the communication interface, typically |
|
40 |
* the speed of the crystal oscillator and/or the speed at which the system runs is |
|
41 |
* needed. Set these through configurables BOOT_CPU_XTAL_SPEED_KHZ and |
|
42 |
* BOOT_CPU_SYSTEM_SPEED_KHZ, respectively. To enable data exchange with the host that is |
|
43 |
* not dependent on the targets architecture, the byte ordering needs to be known. |
|
44 |
* Setting BOOT_CPU_BYTE_ORDER_MOTOROLA to 1 selects little endian mode and 0 selects |
|
45 |
* big endian mode. |
|
46 |
* |
|
47 |
* Set BOOT_CPU_USER_PROGRAM_START_HOOK to 1 if you would like a hook function to be |
|
48 |
* called the moment the user program is about to be started. This could be used to |
|
49 |
* de-initialize application specific parts, for example to stop blinking an LED, etc. |
|
50 |
*/ |
|
51 |
/** \brief Frequency of the external crystal oscillator. */ |
|
52 |
#define BOOT_CPU_XTAL_SPEED_KHZ (8000) |
|
53 |
/** \brief Desired system speed. */ |
|
54 |
#define BOOT_CPU_SYSTEM_SPEED_KHZ (72000) |
|
55 |
/** \brief Motorola or Intel style byte ordering. */ |
|
56 |
#define BOOT_CPU_BYTE_ORDER_MOTOROLA (0) |
|
57 |
/** \brief Enable/disable hook function call right before user program start. */ |
|
58 |
#define BOOT_CPU_USER_PROGRAM_START_HOOK (1) |
|
59 |
|
|
60 |
|
|
61 |
/**************************************************************************************** |
|
62 |
* B O O T L O A D E R O F M A I N D E V I C E |
|
63 |
****************************************************************************************/ |
|
64 |
/* It is important to initialize if the bootloader is part of the main device. In this |
|
65 |
* case some backdoor loops have to stay opened and backdoor loops of other bootloaders |
|
66 |
* have to be controlled by this bootloader. Additionally the bootloader should be able |
|
67 |
* to send program code of user programs for other devices. |
|
68 |
* Make sure that one of the communication interfaces is the gateway! |
|
69 |
*/ |
|
70 |
/** \brief Bootloader of main device. */ |
|
71 |
#define BOOTLOADER_OF_MAIN_DEVICE (1) |
|
72 |
|
|
73 |
|
|
74 |
/**************************************************************************************** |
|
75 |
* C O M M U N I C A T I O N I N T E R F A C E C O N F I G U R A T I O N |
|
76 |
****************************************************************************************/ |
|
77 |
/* The CAN communication interface is selected by setting the BOOT_COM_CAN_ENABLE |
|
78 |
* configurable to 1. Configurable BOOT_COM_CAN_BAUDRATE selects the communication speed |
|
79 |
* in bits/second. Two CAN messages are reserved for communication with the host. The |
|
80 |
* message identifier for sending data from the target to the host is configured with |
|
81 |
* BOOT_COM_CAN_TXMSG_ID. The one for receiving data from the host is configured with |
|
82 |
* BOOT_COM_CAN_RXMSG_ID. The maximum amount of data bytes in a message for data |
|
83 |
* transmission and reception is set through BOOT_COM_CAN_TX_MAX_DATA and |
|
84 |
* BOOT_COM_CAN_RX_MAX_DATA, respectively. It is common for a microcontroller to have more |
|
85 |
* than 1 CAN controller on board. The zero-based BOOT_COM_CAN_CHANNEL_INDEX selects the |
|
86 |
* CAN controller channel. |
|
87 |
* |
|
88 |
*/ |
|
89 |
/** \brief Enable/disable CAN transport layer. */ |
|
90 |
#define BOOT_GATE_CAN_ENABLE (1) |
|
91 |
/** \brief Configure the desired CAN baudrate. */ |
|
92 |
#define BOOT_COM_CAN_BAUDRATE (500000) |
|
93 |
/** \brief Configure CAN message ID target->host. */ |
|
94 |
#define BOOT_COM_CAN_TX_MSG_ID (0x700) //(0x7E1) |
|
95 |
/** \brief Configure number of bytes in the target->host CAN message. */ |
|
96 |
#define BOOT_COM_CAN_TX_MAX_DATA (255) |
|
97 |
/** \brief Configure CAN message ID host->target. */ |
|
98 |
#define BOOT_COM_CAN_RX_MSG_ID (0x600) //(0x667) |
|
99 |
/** \brief Configure number of bytes in the host->target CAN message. */ |
|
100 |
#define BOOT_COM_CAN_RX_MAX_DATA (255) |
|
101 |
/** \brief Select the desired CAN peripheral as a zero based index. */ |
|
102 |
#define BOOT_COM_CAN_CHANNEL_INDEX (0) |
|
103 |
|
|
104 |
/** \brief Configure device ID for communication (start with 1). */ |
|
105 |
#define BOOT_COM_DEVICE_ID (0x1) |
|
106 |
|
|
107 |
/* The UART communication interface is selected by setting the BOOT_COM_UART_ENABLE |
|
108 |
* configurable to 1. Configurable BOOT_COM_UART_BAUDRATE selects the communication speed |
|
109 |
* in bits/second. The maximum amount of data bytes in a message for data transmission |
|
110 |
* and reception is set through BOOT_COM_UART_TX_MAX_DATA and BOOT_COM_UART_RX_MAX_DATA, |
|
111 |
* respectively. It is common for a microcontroller to have more than 1 UART interface |
|
112 |
* on board. The zero-based BOOT_COM_UART_CHANNEL_INDEX selects the UART interface. |
|
113 |
* |
|
114 |
*/ |
|
115 |
/** \brief Enable/disable UART transport layer. */ |
|
116 |
#define BOOT_COM_UART_ENABLE (1) |
|
117 |
/** \brief Configure the desired communication speed. */ |
|
118 |
#define BOOT_COM_UART_BAUDRATE (115200) //(57600) |
|
119 |
/** \brief Configure number of bytes in the target->host data packet. */ |
|
120 |
#define BOOT_COM_UART_TX_MAX_DATA (255) //(64) |
|
121 |
/** \brief Configure number of bytes in the host->target data packet. */ |
|
122 |
#define BOOT_COM_UART_RX_MAX_DATA (255) //(64) |
|
123 |
/** \brief Select the desired UART peripheral as a zero based index. */ |
|
124 |
#define BOOT_COM_UART_CHANNEL_INDEX (0) |
|
125 |
/* Activate debugging with UART2 */ |
|
126 |
#define BOOT_DEBUGGING_UART2_ENABLE (0) |
|
127 |
|
|
128 |
|
|
129 |
/**************************************************************************************** |
|
130 |
* F I L E S Y S T E M I N T E R F A C E C O N F I G U R A T I O N |
|
131 |
****************************************************************************************/ |
|
132 |
/* The file system interface is selected by setting the BOOT_FILE_SYS_ENABLE configurable |
|
133 |
* to 1. This enables support for firmware updates from a file stored on a locally |
|
134 |
* attached file system such as an SD-card. Note that this interface can be enabled |
|
135 |
* together with one of the remote communication interfaces such as UART, CAN or USB. |
|
136 |
* |
|
137 |
* Set BOOT_FILE_LOGGING_ENABLE to 1 if you would like log messages to be created during |
|
138 |
* a firmware update. The hook function FileFirmwareUpdateLogHook() will be called each |
|
139 |
* time a new string formatted log entry is available. This could be used during testing |
|
140 |
* by outputting the string on UART or to create a log file on the file system itself. |
|
141 |
* |
|
142 |
* Set BOOT_FILE_ERROR_HOOK_ENABLE to 1 if you would like to be informed in case an error |
|
143 |
* occurs during the firmware update. This could for example be used to turn on an error |
|
144 |
* LED to inform the user that something went wrong. Inspecting the log messages provides |
|
145 |
* additional information on the error cause. |
|
146 |
* |
|
147 |
* Set BOOT_FILE_STARTED_HOOK_ENABLE to 1 if you would like to be informed when a new |
|
148 |
* firmware update is started by the bootloader. |
|
149 |
* |
|
150 |
* Set BOOT_FILE_COMPLETED_HOOK_ENABLE to 1 if you would like to be informed when a |
|
151 |
* firmware update is completed by the bootloader. |
|
152 |
*/ |
|
153 |
/** \brief Enable/disable support for firmware updates from a locally attached storage.*/ |
|
154 |
#define BOOT_FILE_SYS_ENABLE (0) |
|
155 |
/** \brief Enable/disable logging messages during firmware updates. */ |
|
156 |
#define BOOT_FILE_LOGGING_ENABLE (1) |
|
157 |
/** \brief Enable/disable a hook function that is called upon detection of an error. */ |
|
158 |
#define BOOT_FILE_ERROR_HOOK_ENABLE (1) |
|
159 |
/** \brief Enable/disable a hook function that is called at the start of the update. */ |
|
160 |
#define BOOT_FILE_STARTED_HOOK_ENABLE (1) |
|
161 |
/** \brief Enable/disable a hook function that is called at the end of the update. */ |
|
162 |
#define BOOT_FILE_COMPLETED_HOOK_ENABLE (1) |
|
163 |
|
|
164 |
|
|
165 |
/**************************************************************************************** |
|
166 |
* B A C K D O O R E N T R Y C O N F I G U R A T I O N |
|
167 |
****************************************************************************************/ |
|
168 |
/* It is possible to implement an application specific method to force the bootloader to |
|
169 |
* stay active after a reset. Such a backdoor entry into the bootloader is desired in |
|
170 |
* situations where the user program does not run properly and therefore cannot |
|
171 |
* reactivate the bootloader. By enabling these hook functions, the application can |
|
172 |
* implement the backdoor, which overrides the default backdoor entry that is programmed |
|
173 |
* into the bootloader. When desired for security purposes, these hook functions can |
|
174 |
* also be implemented in a way that disables the backdoor entry altogether. |
|
175 |
*/ |
|
176 |
/** \brief Enable/disable the backdoor override hook functions. */ |
|
177 |
#define BOOT_BACKDOOR_HOOKS_ENABLE (1) |
|
178 |
|
|
179 |
|
|
180 |
/**************************************************************************************** |
|
181 |
* N O N - V O L A T I L E M E M O R Y D R I V E R C O N F I G U R A T I O N |
|
182 |
****************************************************************************************/ |
|
183 |
/* The NVM driver typically supports erase and program operations of the internal memory |
|
184 |
* present on the microcontroller. Through these hook functions the NVM driver can be |
|
185 |
* extended to support additional memory types such as external flash memory and serial |
|
186 |
* eeproms. The size of the internal memory in kilobytes is specified with configurable |
|
187 |
* BOOT_NVM_SIZE_KB. If desired the internal checksum writing and verification method can |
|
188 |
* be overridden with a application specific method by enabling configuration switch |
|
189 |
* BOOT_NVM_CHECKSUM_HOOKS_ENABLE. |
|
190 |
*/ |
|
191 |
/** \brief Enable/disable the NVM hook function for supporting additional memory devices. */ |
|
192 |
#define BOOT_NVM_HOOKS_ENABLE (0) |
|
193 |
/** \brief Configure the size of the default memory device (typically flash EEPROM). */ |
|
194 |
#define BOOT_NVM_SIZE_KB (512) |
|
195 |
/** \brief Enable/disable hooks functions to override the user program checksum handling. */ |
|
196 |
#define BOOT_NVM_CHECKSUM_HOOKS_ENABLE (0) |
|
197 |
|
|
198 |
|
|
199 |
/**************************************************************************************** |
|
200 |
* W A T C H D O G D R I V E R C O N F I G U R A T I O N |
|
201 |
****************************************************************************************/ |
|
202 |
/* The COP driver cannot be configured internally in the bootloader, because its use |
|
203 |
* and configuration is application specific. The bootloader does need to service the |
|
204 |
* watchdog in case it is used. When the application requires the use of a watchdog, |
|
205 |
* set BOOT_COP_HOOKS_ENABLE to be able to initialize and service the watchdog through |
|
206 |
* hook functions. |
|
207 |
*/ |
|
208 |
/** \brief Enable/disable the hook functions for controlling the watchdog. */ |
|
209 |
#define BOOT_COP_HOOKS_ENABLE (0) |
|
210 |
|
|
211 |
|
|
212 |
/**************************************************************************************** |
|
213 |
* S E E D / K E Y S E C U R I T Y C O N F I G U R A T I O N |
|
214 |
****************************************************************************************/ |
|
215 |
/* A security mechanism can be enabled in the bootloader's XCP module by setting configu- |
|
216 |
* rable BOOT_XCP_SEED_KEY_ENABLE to 1. Before any memory erase or programming |
|
217 |
* operations can be performed, access to this resource need to be unlocked. |
|
218 |
* In the Microboot settings on tab "XCP Protection" you need to specify a DLL that |
|
219 |
* implements the unlocking algorithm. The demo programs are configured for the (simple) |
|
220 |
* algorithm in "FeaserKey.dll". The source code for this DLL is available so it can be |
|
221 |
* customized to your needs. |
|
222 |
* During the unlock sequence, Microboot requests a seed from the bootloader, which is in |
|
223 |
* the format of a byte array. Using this seed the unlock algorithm in the DLL computes |
|
224 |
* a key, which is also a byte array, and sends this back to the bootloader. The |
|
225 |
* bootloader then verifies this key to determine if programming and erase operations are |
|
226 |
* permitted. |
|
227 |
* After enabling this feature the hook functions XcpGetSeedHook() and XcpVerifyKeyHook() |
|
228 |
* are called by the bootloader to obtain the seed and to verify the key, respectively. |
|
229 |
*/ |
|
230 |
#define BOOT_XCP_SEED_KEY_ENABLE (0) |
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
/**************************************************************************************** |
|
235 |
* F L A S H I N G M O D E T I M E O U T |
|
236 |
****************************************************************************************/ |
|
237 |
/* Sets the timeout for being in flashing mode. The bootloader stays in flashing mode |
|
238 |
* after a connection has been closed. The timer will be reset with every new connection. |
|
239 |
*/ |
|
240 |
#define FLASHING_WITHOUT_CONNECTION_TIMEOUT_MS 30000 // 30 seconds |
|
241 |
|
|
242 |
|
|
243 |
#endif /* BLT_CONF_H */ |
|
244 |
/*********************************** end of blt_conf.h *********************************/ |
Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot/boot.dox | ||
---|---|---|
1 |
/** |
|
2 |
\defgroup Boot_ARMCM3_STM32_Olimex_STM32P103_GCC Bootloader |
|
3 |
\brief Bootloader. |
|
4 |
\ingroup ARMCM3_STM32_Olimex_STM32P103_GCC |
|
5 |
*/ |
|
6 |
|
|
7 |
|
Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot/cmd/build.bat | ||
---|---|---|
1 |
@echo off |
|
2 |
cs-make --directory=../ all |
Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot/cmd/clean.bat | ||
---|---|---|
1 |
@echo off |
|
2 |
cs-make --directory=../ clean |
Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot/cmd/debug.bat | ||
---|---|---|
1 |
"C:\Program Files (x86)\OpenOCD\0.4.0\bin\openocd.exe" -f debug.cfg |
Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot/cmd/debug.cfg | ||
---|---|---|
1 |
### |
|
2 |
# Description: starts the OpenOCD GDB server (localhost:3333) |
|
3 |
# once started use arm-elf-insight <program>.elf to start the debug session |
|
4 |
# Usage: openocd.exe" -f debug.cfg |
|
5 |
### |
|
6 |
source [find interface/olimex-arm-usb-tiny-h.cfg] |
|
7 |
source [find board/olimex_stm32_h103.cfg] |
|
8 |
|
|
9 |
jtag_khz 1000 |
|
10 |
init |
|
11 |
reset |
|
12 |
halt |
|
13 |
|
|
14 |
|
|
15 |
|
Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot/cmd/flash.bat | ||
---|---|---|
1 |
"C:\Program Files (x86)\OpenOCD\0.4.0\bin\openocd.exe" -f flash.cfg |
Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot/cmd/flash.cfg | ||
---|---|---|
1 |
### |
|
2 |
# Description: mass erases and flashes the binary with OpenOCD |
|
3 |
# Usage: openocd.exe" -f flash.cfg |
|
4 |
### |
|
5 |
|
|
6 |
source [find interface/olimex-arm-usb-tiny-h.cfg] |
|
7 |
source [find board/olimex_stm32_h103.cfg] |
|
8 |
|
|
9 |
jtag_khz 1000 |
|
10 |
|
|
11 |
init |
|
12 |
reset |
|
13 |
sleep 500 |
|
14 |
halt |
|
15 |
stm32x mass_erase 0 |
|
16 |
flash write_image ..\\bin\\openbtl_olimex_stm32p103.elf |
|
17 |
#flash write_image erase ..\\bin\\openbtl_olimex_stm32p103.elf |
|
18 |
reset run |
|
19 |
shutdown |
|
20 |
|
|
21 |
|
Target/Demo/ARMCM3_STM32F103_DiWheelDrive_GCC/Boot/hooks.c | ||
---|---|---|
1 |
/************************************************************************************//** |
|
2 |
* \file Demo\ARMCM3_STM32_Olimex_STM32P103_GCC\Boot\hooks.c |
|
3 |
* \brief Bootloader callback source file. |
|
4 |
* \ingroup Boot_ARMCM3_STM32_Olimex_STM32P103_GCC |
|
5 |
* \internal |
|
6 |
*---------------------------------------------------------------------------------------- |
|
7 |
* C O P Y R I G H T |
|
8 |
*---------------------------------------------------------------------------------------- |
|
9 |
* Copyright (c) 2012 by Feaser http://www.feaser.com All rights reserved |
|
10 |
* |
|
11 |
*---------------------------------------------------------------------------------------- |
|
12 |
* L I C E N S E |
|
13 |
*---------------------------------------------------------------------------------------- |
|
14 |
* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or |
|
15 |
* modify it under the terms of the GNU General Public License as published by the Free |
|
16 |
* Software Foundation, either version 3 of the License, or (at your option) any later |
|
17 |
* version. |
|
18 |
* |
|
19 |
* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
20 |
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
21 |
* PURPOSE. See the GNU General Public License for more details. |
|
22 |
* |
|
23 |
* You should have received a copy of the GNU General Public License along with OpenBLT. |
|
24 |
* If not, see <http://www.gnu.org/licenses/>. |
|
25 |
* |
|
26 |
* A special exception to the GPL is included to allow you to distribute a combined work |
|
27 |
* that includes OpenBLT without being obliged to provide the source code for any |
|
28 |
* proprietary components. The exception text is included at the bottom of the license |
|
29 |
* file <license.html>. |
|
30 |
* |
|
31 |
* \endinternal |
|
32 |
****************************************************************************************/ |
|
33 |
|
|
34 |
/**************************************************************************************** |
|
35 |
* Include files |
|
36 |
****************************************************************************************/ |
|
37 |
#include "boot.h" /* bootloader generic header */ |
|
38 |
#if (BOOT_FILE_LOGGING_ENABLE > 0) |
|
39 |
#include "stm32f10x.h" /* STM32 registers */ |
|
40 |
#include "stm32f10x_conf.h" /* STM32 peripheral drivers */ |
|
41 |
#endif |
|
42 |
|
|
43 |
/**************************************************************************************** |
|
44 |
* B A C K D O O R E N T R Y H O O K F U N C T I O N S |
|
45 |
****************************************************************************************/ |
|
46 |
|
|
47 |
#if (BOOT_BACKDOOR_HOOKS_ENABLE > 0) |
|
48 |
|
|
49 |
static blt_int32u backdoorOpenTime; |
|
50 |
#define BACKDOOR_ENTRY_TIMEOUT_MS 500 |
|
51 |
static blt_bool timeRanOut = BLT_FALSE; |
|
52 |
enum BOOT_STATE {BOOT_FLASH_CHECK, |
|
53 |
BOOT_FLASH_WAIT, |
|
54 |
BOOT_OS_SYNC, |
|
55 |
BOOT_OS_START |
|
56 |
} boot_state; |
|
57 |
|
|
58 |
#define SYS_PD_N_PIN GPIO_Pin_8 |
|
59 |
#define SYS_PD_N_GPIO GPIOC |
|
60 |
#define SYS_SYNC_N_PIN GPIO_Pin_1 |
|
61 |
#define SYS_SYNC_N_GPIO GPIOC |
|
62 |
|
|
63 |
/************************************************************************************//** |
|
64 |
** \brief Initializes the backdoor entry option. |
|
65 |
** \return none. |
|
66 |
** |
|
67 |
****************************************************************************************/ |
|
68 |
void BackDoorInitHook(void) |
|
69 |
{ |
|
70 |
backdoorOpenTime = TimerGet(); |
|
71 |
boot_state = BOOT_FLASH_CHECK; |
|
72 |
} /*** end of BackDoorInitHook ***/ |
|
73 |
|
|
74 |
|
|
75 |
/************************************************************************************//** |
|
76 |
** \brief Checks if it has to stay in backdoor. |
|
77 |
** \return BLT_TRUE if the backdoor entry is requested, BLT_FALSE otherwise. |
|
78 |
** |
|
79 |
****************************************************************************************/ |
|
80 |
blt_bool BackDoorEntryCheck(void) |
|
81 |
{ |
|
82 |
/* evaluate the fsm state */ |
|
83 |
switch (boot_state) { |
|
84 |
case BOOT_FLASH_CHECK: |
|
85 |
{ |
|
86 |
/* wait for a timeout */ |
|
87 |
if (timeRanOut == BLT_FALSE) { |
|
88 |
if (TimerGet() > backdoorOpenTime+BACKDOOR_ENTRY_TIMEOUT_MS) { |
|
89 |
timeRanOut = BLT_TRUE; |
|
90 |
boot_state = BOOT_FLASH_WAIT; |
|
91 |
GPIO_SetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
|
92 |
} |
|
93 |
} |
|
94 |
return BLT_TRUE; |
|
95 |
break; |
|
96 |
} |
|
97 |
case BOOT_FLASH_WAIT: |
|
98 |
{ |
|
99 |
/* wait for the SYS_SYNC_N signal to go up */ |
|
100 |
if (GPIO_ReadInputDataBit(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN) == Bit_RESET) { |
|
101 |
return BLT_TRUE; |
|
102 |
} else { |
|
103 |
boot_state = BOOT_OS_SYNC; |
|
104 |
return BLT_FALSE; |
|
105 |
} |
|
106 |
} |
|
107 |
default: |
|
108 |
return BLT_FALSE; |
|
109 |
break; |
|
110 |
} |
|
111 |
return BLT_FALSE; |
|
112 |
} /*** end of BackDoorEntryHook ***/ |
|
113 |
|
|
114 |
|
|
115 |
/************************************************************************************//** |
|
116 |
** \brief Checks if a backdoor entry is requested. |
|
117 |
** \return BLT_TRUE if the backdoor entry is requested, BLT_FALSE otherwise. |
|
118 |
** |
|
119 |
****************************************************************************************/ |
|
120 |
blt_bool BackDoorEntryHook(void) |
|
121 |
{ |
|
122 |
/* default implementation always activates the bootloader after a reset */ |
|
123 |
return BLT_TRUE; |
|
124 |
} /*** end of BackDoorEntryHook ***/ |
|
125 |
#endif /* BOOT_BACKDOOR_HOOKS_ENABLE > 0 */ |
|
126 |
|
|
127 |
|
|
128 |
/************************************************************************************//** |
|
129 |
** \brief Notice that there is still an open connection over COM |
|
130 |
** \return - |
|
131 |
** |
|
132 |
****************************************************************************************/ |
|
133 |
void BackDoorComIsConnected(void) |
|
134 |
{ |
|
135 |
backdoorOpenTime = TimerGet(); |
|
136 |
} |
|
137 |
|
|
138 |
|
|
139 |
/**************************************************************************************** |
|
140 |
* C P U D R I V E R H O O K F U N C T I O N S |
|
141 |
****************************************************************************************/ |
|
142 |
|
|
143 |
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0) |
|
144 |
/************************************************************************************//** |
|
145 |
** \brief Callback that gets called when the bootloader is about to exit and |
|
146 |
** hand over control to the user program. This is the last moment that |
|
147 |
** some final checking can be performed and if necessary prevent the |
|
148 |
** bootloader from activiting the user program. |
|
149 |
** \return BLT_TRUE if it is okay to start the user program, BLT_FALSE to keep |
|
150 |
** keep the bootloader active. |
|
151 |
** |
|
152 |
****************************************************************************************/ |
|
153 |
blt_bool CpuUserProgramStartHook(void) |
|
154 |
{ |
|
155 |
/* evaluate the fsm state */ |
|
156 |
switch (boot_state) { |
|
157 |
case BOOT_OS_SYNC: |
|
158 |
{ |
|
159 |
/* wait for the SYS_SYNC_N signal to go down */ |
|
160 |
|
|
161 |
if (GPIO_ReadInputDataBit(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN) == Bit_RESET) { |
|
162 |
boot_state = BOOT_OS_START; |
|
163 |
} |
|
164 |
return BLT_FALSE; |
|
165 |
break; |
|
166 |
} |
|
167 |
case BOOT_OS_START: |
|
168 |
{ |
|
169 |
/* pull down SYS_SYNC_N to indicate that the module is busy |
|
170 |
* note: This is optional at this point. The OS however MUST pull down SYS_SYNC_N until it is ready */ |
|
171 |
GPIO_ResetBits(SYS_SYNC_N_GPIO, SYS_SYNC_N_PIN); |
|
172 |
return BLT_TRUE; |
|
173 |
} |
|
174 |
default: |
|
175 |
return BLT_FALSE; |
|
176 |
break; |
|
177 |
} |
|
178 |
return BLT_FALSE; |
|
179 |
|
|
180 |
} /*** end of CpuUserProgramStartHook ***/ |
|
181 |
#endif /* BOOT_CPU_USER_PROGRAM_START_HOOK > 0 */ |
|
182 |
|
|
183 |
|
|
184 |
/**************************************************************************************** |
|
185 |
* N O N - V O L A T I L E M E M O R Y D R I V E R H O O K F U N C T I O N S |
|
186 |
****************************************************************************************/ |
|
187 |
|
|
188 |
#if (BOOT_NVM_HOOKS_ENABLE > 0) |
|
189 |
/************************************************************************************//** |
|
190 |
** \brief Callback that gets called at the start of the internal NVM driver |
|
191 |
** initialization routine. |
|
192 |
** \return none. |
|
193 |
** |
|
194 |
****************************************************************************************/ |
|
195 |
void NvmInitHook(void) |
|
196 |
{ |
|
197 |
} /*** end of NvmInitHook ***/ |
|
198 |
|
|
199 |
|
|
200 |
/************************************************************************************//** |
|
201 |
** \brief Callback that gets called at the start of the NVM driver write |
|
202 |
** routine. It allows additional memory to be operated on. If the address |
|
203 |
** is not within the range of the additional memory, then |
|
204 |
** BLT_NVM_NOT_IN_RANGE must be returned to indicate that the data hasn't |
|
205 |
** been written yet. |
|
206 |
** \param addr Start address. |
|
207 |
** \param len Length in bytes. |
|
208 |
** \param data Pointer to the data buffer. |
|
209 |
** \return BLT_NVM_OKAY if successful, BLT_NVM_NOT_IN_RANGE if the address is |
|
210 |
** not within the supported memory range, or BLT_NVM_ERROR is the write |
|
211 |
** operation failed. |
|
212 |
** |
|
213 |
****************************************************************************************/ |
|
214 |
blt_int8u NvmWriteHook(blt_addr addr, blt_int32u len, blt_int8u *data) |
|
215 |
{ |
|
216 |
return BLT_NVM_NOT_IN_RANGE; |
|
217 |
} /*** end of NvmWriteHook ***/ |
|
218 |
|
|
219 |
|
|
220 |
/************************************************************************************//** |
|
221 |
** \brief Callback that gets called at the start of the NVM driver erase |