Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
src/blfwk/Bootloader.h
1 /*
2  * Copyright (c) 2013-14, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef _Bootloader_h_
32 #define _Bootloader_h_
33 
34 #include "Command.h"
35 #include "Packetizer.h"
36 #include "Peripheral.h"
37 #include "Logging.h"
38 
39 #include <time.h>
40 
43 
44 namespace blfwk
45 {
53 {
54 public:
56  Bootloader();
57 
60 
62  virtual ~Bootloader();
63 
67  void inject(Command &cmd)
68  {
69  clock_t start = clock();
71  clock_t finish = clock();
72  Log::debug(" - took %2.3f seconds\n", (double)(finish - start) / CLOCKS_PER_SEC);
73  }
74 
76  void flush();
77 
79  void execute(uint32_t entry_point, uint32_t param = 0, uint32_t stack_pointer = 0);
80 
82  void reset();
83 
86 
88  uint32_t getSecurityState();
89 
91  void ping(int retries, unsigned int delay, int comSpeed);
92 
94 
95 
99 
100 protected:
103 };
104 
105 } // namespace blfwk
106 
108 
109 #endif // _Bootloader_h_
110 
112 // EOF
Interface class for packetization of commands and data.
Definition: Packetizer.h:59
Represents the host bootloader.
Definition: src/blfwk/Bootloader.h:52
Definition: BlfwkErrors.h:16
Represents a bootloader command.
Definition: Command.h:301
void execute(uint32_t entry_point, uint32_t param=0, uint32_t stack_pointer=0)
Execute the execute command.
Definition: src/blfwk/src/Bootloader.cpp:169
virtual void sendTo(Packetizer &packetizer)
Send command to packetizer and on to peripheral.
Definition: Command.h:370
void ping(int retries, unsigned int delay, int comSpeed)
Send a ping if applicable.
Definition: src/blfwk/src/Bootloader.cpp:245
Definition: qspi_config_block_generator.c:101
void reset()
Execute the reset command.
Definition: src/blfwk/src/Bootloader.cpp:187
Bootloader()
Default Constructor for Simulator.
Definition: src/blfwk/src/Bootloader.cpp:57
static void debug(const char *fmt,...)
Log a message with Logger::kDebug level.
Definition: src/blfwk/src/Logging.cpp:192
FileLogger * m_logger
Singleton logger instance.
Definition: src/blfwk/Bootloader.h:102
void flush()
Flush state.
Definition: src/blfwk/src/Bootloader.cpp:159
void inject(Command &cmd)
Inject a command into the bootloader.
Definition: src/blfwk/Bootloader.h:67
standard_version_t getVersion()
Execute the get-property(current-version) command.
Definition: src/blfwk/src/Bootloader.cpp:205
virtual ~Bootloader()
Destructor.
Definition: src/blfwk/src/Bootloader.cpp:149
Packetizer * getPacketizer() const
Get the host packetizer.
Definition: src/blfwk/Bootloader.h:97
uint32_t getSecurityState()
Execute the get-property(flash-security-state) command.
Definition: src/blfwk/src/Bootloader.cpp:225
Simple logger that writes to a file.
Definition: src/blfwk/Logging.h:266
Packetizer * m_hostPacketizer
Packet interface to send commands on.
Definition: src/blfwk/Bootloader.h:101
Definition: Peripheral.h:60