Add KBOOT.

This commit is contained in:
László Monda
2016-08-10 01:45:15 +02:00
commit e6c1fce5b4
9392 changed files with 3751375 additions and 0 deletions

1102
LA_OPT_Base_License.htm Normal file

File diff suppressed because it is too large Load Diff

24
LICENSE.txt Normal file
View File

@@ -0,0 +1,24 @@
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
o Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
o Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
o Neither the name of Freescale Semiconductor, Inc. nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,94 @@
Release Name: Kinetis Bootloader
Version: 2.0.0
Package - Kinetis Filename: FSL_Kinetis_Bootloader_2.0.0.zip
Bootloader
KSDK Peripheral Drivers Description: Peripheral drivers are designed for the
most common use cases identified for the underlying
hardware block.
Author: Freescale
version: 2.x.x
License: Open Source - BSD-3-Clause
Format: source code
Location: Kinetis_Bootloader/src/drivers
CMSIS Core header files Description: Industry-standard header files distributes
by ARM for cortex-M cores
Author: ARM
version: 4.3 (CMSIS Download 4.5)
License: Open Source - BSD-3-Clause
Format: source code
URL: http://silver.arm.com
Location: Kinetis_Bootloader/src/platform/CMSIS/Include
USB Description: Freescale USB stack. This is a version of
the USB stack that has been integrated with the Kinetis
SDK.
Author: Freescale
version: 1.0.0
License: Open Source - BSD-3-Clause
Format: source code
Location: Kinetis_Bootloader/src/usb
Bootloader Source Description: Software drivers for
Bootloaders and Flashloaders
Author: FSL
License: Open Source - BSD-3-Clause
Format: source code
Location: Kinetis_Bootloader/src
Host tools - Serial Description: Windows Serial peripheral support
support Author: Bus Pirate Project
License: Open Source - CC0-1.0 (Creative Commons Zero)
URL: http://code.google.com/p/the-bus-pirate/
Format: source code
Location:
Kinetis_Bootloader/src/blfwk/serial.h,
Kinetis_Bootloader/src/blfwk/src/serial.c
Host tools - USB HID Description: Windows USB HID support
support Author: HIDAPI
License: Open Source - BSD-3-Clause
URL: http://github.com/signal11/hidapi
Format: source code
Location:
Kinetis_Bootloader/src/blfwk/hidapi.h,
Kinetis_Bootloader/src/blfwk/src/hid-*.c
Host tools - JSON support Description: Windows JSON support
Author: JSONCPP
License: Open Source - MIT
Format: source code
Location:
Kinetis_Bootloader/src/blfwk/json.h,
Kinetis_Bootloader/src/blfwk/src/jsoncpp.cpp
Host tools - options Description: Command line parsing utility
support Author: bradapp@enteract.com
License: Open Source - MIT
URL:
http://www.bradapp.com
Format: source code
Location:
Kinetis_Bootloader/src/blfwk/options.h,
Kinetis_Bootloader/src/blfwk/src/options.cpp
Bootloader Source, Description: C++ interface to the Vincent Rijmen's Rijndael block cipher
Host Source - blfwk.lib Author: Szymon Stefanek (stefanek@tin.it)
License: Public Domain
URL:
http://www.pragmaware.net/software/rijndael/index.php
Format: source code
Location:
Kinetis_Bootloader/src/blfwk/rijndael.h,
Kinetis_Bootloader/src/blfwk/src/rijndael.cpp
Utility Source - elf.py Description: Python implementation of an ELF file reader.
Author: Chris Liechti (cliechti@gmx.net)
License: BSD License
URL:
http://bazaar.launchpad.net/~zsquareplusc/python-msp430-tools/trunk/view/head:/msp430/memory/elf.py
Format: source code
Location:
Kinetis_Bootloader/bin/elf.py

View File

@@ -0,0 +1,54 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KinetisFlashTool", "KinetisFlashTool\KinetisFlashTool.vcxproj", "{864CBA51-EAF2-491E-9C74-4791B49FE039}"
ProjectSection(ProjectDependencies) = postProject
{DE64A8C3-695A-491F-B3E3-24D6A3057A40} = {DE64A8C3-695A-491F-B3E3-24D6A3057A40}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blfwkdll", "..\common\blfwkdll\blfwkdll.vcxproj", "{426D14FE-6F2B-442D-893D-B5730DD6941F}"
ProjectSection(ProjectDependencies) = postProject
{DE64A8C3-695A-491F-B3E3-24D6A3057A40} = {DE64A8C3-695A-491F-B3E3-24D6A3057A40}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blfwk", "..\common\blfwkdll\blfwk.vcxproj", "{DE64A8C3-695A-491F-B3E3-24D6A3057A40}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{864CBA51-EAF2-491E-9C74-4791B49FE039}.Debug|x64.ActiveCfg = Debug|Win32
{864CBA51-EAF2-491E-9C74-4791B49FE039}.Debug|x64.Build.0 = Debug|Win32
{864CBA51-EAF2-491E-9C74-4791B49FE039}.Debug|x86.ActiveCfg = Debug|Win32
{864CBA51-EAF2-491E-9C74-4791B49FE039}.Debug|x86.Build.0 = Debug|Win32
{864CBA51-EAF2-491E-9C74-4791B49FE039}.Release|x64.ActiveCfg = Release|Win32
{864CBA51-EAF2-491E-9C74-4791B49FE039}.Release|x64.Build.0 = Release|Win32
{864CBA51-EAF2-491E-9C74-4791B49FE039}.Release|x86.ActiveCfg = Release|Win32
{864CBA51-EAF2-491E-9C74-4791B49FE039}.Release|x86.Build.0 = Release|Win32
{426D14FE-6F2B-442D-893D-B5730DD6941F}.Debug|x64.ActiveCfg = Debug|Win32
{426D14FE-6F2B-442D-893D-B5730DD6941F}.Debug|x64.Build.0 = Debug|Win32
{426D14FE-6F2B-442D-893D-B5730DD6941F}.Debug|x86.ActiveCfg = Debug|Win32
{426D14FE-6F2B-442D-893D-B5730DD6941F}.Debug|x86.Build.0 = Debug|Win32
{426D14FE-6F2B-442D-893D-B5730DD6941F}.Release|x64.ActiveCfg = Release|Win32
{426D14FE-6F2B-442D-893D-B5730DD6941F}.Release|x64.Build.0 = Release|Win32
{426D14FE-6F2B-442D-893D-B5730DD6941F}.Release|x86.ActiveCfg = Release|Win32
{426D14FE-6F2B-442D-893D-B5730DD6941F}.Release|x86.Build.0 = Release|Win32
{DE64A8C3-695A-491F-B3E3-24D6A3057A40}.Debug|x64.ActiveCfg = Debug|Win32
{DE64A8C3-695A-491F-B3E3-24D6A3057A40}.Debug|x64.Build.0 = Debug|Win32
{DE64A8C3-695A-491F-B3E3-24D6A3057A40}.Debug|x86.ActiveCfg = Debug|Win32
{DE64A8C3-695A-491F-B3E3-24D6A3057A40}.Debug|x86.Build.0 = Debug|Win32
{DE64A8C3-695A-491F-B3E3-24D6A3057A40}.Release|x64.ActiveCfg = Release|Win32
{DE64A8C3-695A-491F-B3E3-24D6A3057A40}.Release|x64.Build.0 = Release|Win32
{DE64A8C3-695A-491F-B3E3-24D6A3057A40}.Release|x86.ActiveCfg = Release|Win32
{DE64A8C3-695A-491F-B3E3-24D6A3057A40}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,210 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "afxwin.h"
#include <vector>
#include <array>
#include "../../common/blfwkdll/blfwkdll.h"
using namespace std;
/*!
* \brief Bootloader class.
*/
class Bootloader : public CWinThread
{
public:
/*!
* \brief TargetInformation struct contains devices information.
*/
struct TargetInformation
{
UINT32 targetVersion; //!< Bootloader version.
UINT32 procotolVersion; //!< Serial procotol version.
UINT32 securityState; //!< Security state.
UINT32 flashSize; //!< Flash memory size.
UINT32 flashSectorSize; //!< Flash memory sector size.
UINT32 ramSize; //!< RAM memory size.
UINT32 rsvRgnFlashStart; //!< Start address of flash reserved region.
UINT32 rsvRgnFlashEnd; //!< End address of flash reserved region.
UINT32 rsvRgnRamStart; //!< Start address of RAM reserved region.
UINT32 rsvRgnRamEnd; //!< End address of RAM reserved region.
UINT32 supportedCmd; //!< Current device supported command.
};
/*!
* \brief FlashFirmwareOption struct contains information for an update progress.
*/
struct FlashFirmwareOption
{
BOOL autoConnect; //!< Auto connect device after an update, if set TRUE.(Currently, not used)
BOOL doErasetoUnlock; //!< Execute flash-erase-all-unsecure to unlock the device.
BOOL useKeytoUnlock; //!< Execute flash-security-disable to unlock the device.
std::string backdoorkey; //!< Backdoor key
std::string imageFilePath; //!< Absolute path for image file.
uint32_t baseAddress; //!< Base address where image file is written to.(Only used for binary file.)
};
/*!
* \brief EraseOption struct contains information for an erase progress.
*/
struct EraseOption
{
enum ERASE_OPERATION
{
erase_region = 0, //!< Execute flash-erase-region.
erase_all = 1, //!< Execute flash-erase-all.
erase_all_and_unsecure = 2 //!< Execute flash-erase-all-unsecure.
};
ERASE_OPERATION option; //!< Erase operation..
uint32_t memoryID; //!< Memory ID used for flash-erase-all command.
uint32_t startAddress; //!< Start address to erase.
uint32_t length; //!< Length in bytes to erase.
};
/*!
* \brief ProgramOnceOption struct contains information for a program IFR progress.
*/
struct ProgramOnceOption
{
uint32_t index; //!< IFR index.
uint32_t byteCount; //!< IFR length( should be 4 or 8).
std::string data; //!< IFR data to write. 4 or 8 hex digits with on leading "0x".
};
public:
//! \brief Generated standard constructor.
Bootloader() { this->Open(); };
//! \brief Generated standard destructor.
virtual ~Bootloader() { this->Close(); };
//! \brief Overrides.
virtual BOOL InitInstance() { return CWinThread::InitInstance(); };
//! \brief Overrides.
virtual int ExitInstance() { return CWinThread::ExitInstance(); };
/*!
* \brief KibbleStatusCode struct contains two correct status code.
*/
enum KibbleStatusCode
{
KBL_Status_Success = 0x0, //!< Success status.
KBL_Status_AbortDataPhase = 0x2712, //!< AbortDataPhase. This status will be received when executing RESET or
//! EXECUTE command in a SB file successfully.
};
/*!
* \brief Return whether currently a new operation can be processed.
*/
bool CanRun();
/*!
* \brief Do initialization and create a child thread.
*/
DWORD Open();
/*!
* \brief Do deinitialization and wait for child thread exit.
*/
void Close();
/*!
* \brief the callback function to update the progress.
*/
static void progressCallback(int percentage, int segmentIndex, int segmentCount);
/*!
* \brief Wait an event to be triggered.
*/
DWORD WaitForEvents(DWORD time);
/*!
* \brief Reset the triggered event after the corresponding progress is done.
*/
void ResetEvents(DWORD events);
/*!
* \brief Triggered a ping even to text the connection.
*/
void Ping();
/*!
* \brief Triggered a reset even, and disconnect target device.
*/
void Reset();
/*!
* \brief Triggered a connect even, and try to connect target device.
*/
void Connect(blfwkdll::Updater::PeripheralConfig *config);
/*!
* \brief Triggered a updatestatue even to collect device information.
*/
void UpdateStatus();
/*!
* \brief Triggered a update even to do a update progress.
*/
void UpdateImage(blfwkdll::Updater::PeripheralConfig *config, FlashFirmwareOption *option);
/*!
* \brief Triggered an erase even.
*/
void Erase(EraseOption *option);
/*!
* \brief Triggered an programming ifr even.
*/
void ProgramOnce(ProgramOnceOption *option);
HANDLE m_pingEvent; //!< Ping event.
HANDLE m_statusEvent; //!< Update status event.
HANDLE m_resetEvent; //!< Reset event.
HANDLE m_connectEvent; //!< Connect event.
HANDLE m_updateEvent; //!< Update event.
HANDLE m_eraseEvent; //!< Erase event.
HANDLE m_programOnceEvent; //!< Program IFR event.
HANDLE m_exitEvent; //!< Exit event to let child thread exit.
CWinThread *m_pThread; //!< Pointer to child thread.
bool m_abort; //!< Flag is set to abort the update progress.
bool m_isRunning; //!< Flag is set when there is an operation under processing.
bool m_isExiting; //!< Flag is set to let child thread exit.
bool m_isConneted; //!< Flag is set when connect to a target device.
TargetInformation m_targetInfo; //!< Contains devices information.
FlashFirmwareOption m_firmwareConfig; //!< Contains information for a update operation.
EraseOption m_eraseOption; //!< Contains information for an erase operation.
ProgramOnceOption m_programOnceOption; //!< Contains information for a programming-IFR operation.
blfwkdll::Updater::PeripheralConfig m_config; //!< Contains information for peripheral configuration.
blfwkdll::Updater *m_updater; //!< Pointer to a blfwkdll::Updater.
};
extern Bootloader *g_pBootloader; //!< Global pointer for bootloader.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,113 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "../../common/blfwkdll/blfwkdll.h"
// BootloaderConfigDlg dialog
/*!
* \brief BootloaderConfigDlg class is the UI Dialog class for the
* bootloader configuration page
*/
class BootloaderConfigDlg : public CDialogEx
{
DECLARE_DYNAMIC(BootloaderConfigDlg)
public:
//! \brief Generated standard constructor.
BootloaderConfigDlg(CWnd *pParent = NULL); // standard constructor
//! \brief Custom constructor
//!
//! \param config A pointer to BCA data memory.
//! (Must be specified)
//!
//! \param file A file pointer to the binary image, used for CRC calculation.
//! (Must be specified.)
//!
//! \param pParent the father dialog pointer.
BootloaderConfigDlg(blfwkdll::BootloaderConfigureAreaData *config, CFile *file, CWnd *pParent = NULL)
: CDialogEx(IDD_DIALOG_BOOTLOADERCONFIG, pParent)
{
m_config = config;
m_cFile = file;
};
//! \brief Generated standard destructor.
virtual ~BootloaderConfigDlg();
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum
{
IDD = IDD_DIALOG_BOOTLOADERCONFIG
};
#endif
//! \brief Generated message map functions.
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
virtual void OnOK();
public:
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedCheckCrc();
afx_msg void OnBnClickedCheckI2cslaveAddress();
afx_msg void OnBnClickedCheckTimeout();
afx_msg void OnBnClickedCheckVid();
afx_msg void OnBnClickedCheckPid();
afx_msg void OnBnClickedCheckUsbstringPointer();
afx_msg void OnBnClickedCheckDisableHighspeed();
afx_msg void OnBnClickedCheckMmcauPointer();
afx_msg void OnBnClickedCheckOtfadPointer();
afx_msg void OnBnClickedCheckQspiPointer();
afx_msg void OnBnClickedCheckCantxid();
afx_msg void OnBnClickedCheckCanrxid();
afx_msg void OnBnClickedCheckCanspeed();
afx_msg void OnBnClickedRadioSpeedindex();
afx_msg void OnBnClickedReload();
afx_msg void OnBnClickedButtonConfigOk();
afx_msg void OnBnClickedButtonConfigCancel();
afx_msg void OnBnClickedButtonConfigGenerate();
public:
//! \brief Load BCA data to UI page.
void LoadBootloaderConfigureArea();
//! \brief Save UI config data to BCA.
//!
//! \return OnOK for success, OnCancel for failure.
int SaveBootloaderConfigureArea();
protected:
blfwkdll::BootloaderConfigureAreaData *m_config; //!< A pointer to BCA data.
CFile *m_cFile; //!< A pointer to the binary file, used for crc calculation.
};

View File

@@ -0,0 +1,199 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
char code_section1[] =
"/*\n\
* Copyright (c) 2013 - 15, Freescale Semiconductor, Inc.\n\
* All rights reserved\n\
*\n\
* Redistribution and use in source and binary forms, with or without modification,\n\
*are permitted provided that the following conditions are met :\n\
*\n\
* o Redistributions of source code must retain the above copyright notice, this list\n\
* of conditions and the following disclaimer.\n\
*\n\
* o Redistributions in binary form must reproduce the above copyright notice, this\n\
* list of conditions and the following disclaimer in the documentation and / or\n\
* other materials provided with the distribution.\n\
*\n\
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its\n\
* contributors may be used to endorse or promote products derived from this\n\
* software without specific prior written permission.\n\
*\n\
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n\
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n\
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n\
* DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\n\
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n\
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n\
*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n\
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n\
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\
*/\n\
\n\
/*!\n\
* @brief Device specific configuration file for Kinetis bootloader\n\
*\n\
* Provides a bootloader configuration structure and a global variable that\n\
* contains\n\
* the system bootloader configuration data.\n\
*/\n\
\n\
#include <stdint.h>\n\
\n\
/*!\n\
* @brief Defines the structure to set the Bootloader Configuration Area\n\
*\n\
* This type of variable is used to set the Bootloader Configuration Area\n\
* of the chip.\n\
*\n\
* Warning: some configuration may not work on the devices that donot support \n\
* corresponding feature.\n\
*/\n\
typedef struct BootloaderConfiguration\n\
{\n\
uint32_t tag; //!< [00:03] Magic number to verify bootloader configuration is\n\
//! valid. Must be set to 'kcfg'.\n\
uint32_t crcStartAddress; //!< [04:07] Start address for application image CRC\n\
//! check. If the bits are all set then Kinetis\n\
//! bootloader by default will not perform any CRC \n\
//! check.\n\
uint32_t crcByteCount; //!< [08:0b] Byte count for application image CRC\n\
//! check. If the bits are all set then Kinetis\n\
//! bootloader by default will not prform any CRC check.\n\
uint32_t crcExpectedValue; //!< [0c:0f] Expected CRC value for application CRC\n\
//! check. If the bits are all set then Kinetis\n\
//! bootloader by default will not perform any CRC\n\
//! check.\n\
uint8_t enabledPeripherals; //!< [10:10] Bitfield of peripherals to enable.\n\
//! bit 0 - LPUART, bit 1 - I2C, bit 2 - SPI,\n\
//! bit 3 - CAN, bit 4 - USB\n\
//! Kinetis bootloader will enable the peripheral if\n\
//! corresponding bit is set to 1.\n\
uint8_t i2cSlaveAddress; //!< [11:11] If not 0xFF, used as the 7-bit I2C slave\n\
//! address. If 0xFF, defaults to 0x10\n\
//! for I2C slave address.\n\
uint16_t peripheralDetectionTimeoutMs; //!< [12:13] Timeout in milliseconds\n\
//! for active peripheral detection. If\n\
//! 0xFFFF, defaults to 5 seconds.\n\
uint16_t usbVid; //!< [14:15] Sets the USB Vendor ID reported by the device\n\
//! during enumeration. If 0xFFFF, it defaults to 0x15A2.\n\
uint16_t usbPid; //!< [16:17] Sets the USB Product ID reported by the device\n\
//! during enumeration.\n\
uint32_t usbStringsPointer; //!< [18:1b] Sets the USB Strings reported by the\n\
//! device during enumeration.\n\
uint8_t clockFlags; //!< [1c:1c] The flags in the clockFlags configuration\n\
//! field are enabled if the corresponding bit is cleared (0).\n\
//! bit 0 - HighSpeed Enable high speed mode (i.e., 48 MHz).\n\
uint8_t clockDivider; //!< [1d:1d] Inverted value of the divider to use for\n\
//! core and bus clocks when in high speed mode.\n\
uint8_t bootFlags; //!< [1e:1e] If bit 0 is cleared, then Kinetis bootloader\n\
//! will jump to either Quad SPI Flash or internal flash\n\
//! image depending on FOPT BOOTSRC_SEL bits.\n\
//! If the bit is set, then Kinetis bootloader will prepare\n\
//! for host communication over serial peripherals.\n\
uint8_t pad0; //!< [1f:1f] Reserved, set to 0xFF\n\
uint32_t mmcauConfigPointer; //!< [20:23] A pointer to the MMCAU configuration\n\
//! structure in memory.\n\
uint32_t keyBlobPointer; //!< [24:27]Holds a pointer value to the key blob\n\
//! array used to configure OTFAD\n\
uint8_t pad1; //!< [28:28] reserved\n\
uint8_t canConfig1; //!< [29:29] ClkSel[1], PropSeg[3], SpeedIndex[4]\n\
uint16_t canConfig2; //!< [2a:2b] Pdiv[8], Pseg1[3], Pseg2[3], rjw[2]\n\
uint16_t canTxId; //!< [2c:2d] txId\n\
uint16_t canRxId; //!< [2e:2f] rxId\n\
uint32_t qspi_config_block_pointer; //!< [30:33] A pointer to the QSPI config\n\
//! block in internal flash array.\n\
uint32_t reserved[3]; //!<[34:3f] reserved\n\
} bootloader_config_t;\n\
\n\
/*\n\
* Warning: To enable bootloader configuration, User still needs two extra steps :\n\
*\n\
* Step1 : Enable BOOTLOADER_CONFIG.\n\
* Example : #define BOOTLOADER_CONFIG 1\n\
*\n\
* Step2 : Add configuration of the section \"BootloaderConfig\" to your\n\
* linker configuration file.\n\
* Example(IAR) :\n\
* define symbol __application_startaddress = 0; // User-defined\n\
* define symbol m_bootloader_config_start = __application_startaddress + 0x3C0;\n\
* define symbol m_bootloader_config_end = __application_startaddress + 0x3FF;\n\
* define region m_bootloader_config_region = mem:[from m_bootloader_config_start to m_bootloader_config_end];\n\
* place in m_bootloader_config_region{ section BootloaderConfig };\n\
*\n\
* Example(Keil) :\n\
* #define __application_startaddress = 0 // User-defined\n\
* #define m_bootloader_config_start __application_startaddress + 0x3C0\n\
* #define m_bootloader_config_size 0x00000040\n\
*\n\
* LR_m_bootloader_config m_bootloader_config_start m_bootloader_config_size{\n\
* ER_m_bootloader_config m_bootloader_config_start m_bootloader_config_size{ ; load address = execution address\n\
* * (BootloaderConfig)\n\
* }\n\
* }\n\
*\n\
* Example(ARM - GCC) :\n\
* MEMORY\n\
* {\n\
* m_bootloader_config(RX) : ORIGIN = 0x000003C0, LENGTH = 0x00000040\n\
* }\n\
* .bootloader_config :\n\
* {\n\
* . = ALIGN(4);\n\
* KEEP(*(.BootloaderConfig)) // Bootloader Configuration Area (BCA)\n\
* . = ALIGN(4);\n\
* } > m_bootloader_config\n\
*\n\
*/\n\
\n\
#ifdef BOOTLOADER_CONFIG\n\
/* Bootlader configuration area */\n\
#if defined(__IAR_SYSTEMS_ICC__)\n\
/* Pragma to place the Bootloader Configuration Array on correct location\n\
* defined in linker file. */\n\
#pragma language = extended\n\
#pragma location = \"BootloaderConfig\"\n\
__root const bootloader_config_t BootloaderConfig @\"BootloaderConfig\" =\n\
#elif defined(__GNUC__)\n\
__attribute__((section(\".BootloaderConfig\"))) const bootloader_config_t BootloaderConfig =\n\
#elif defined(__CC_ARM)\n\
__attribute__((section(\"BootloaderConfig\"))) const bootloader_config_t BootloaderConfig __attribute__((used)) =\n\
#else\n\
#error Unsupported compiler!\n\
#endif\n\
{";
char code_section2[] =
"\n };\n\
#endif";

View File

@@ -0,0 +1,399 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "stdafx.h"
#include "KinetisFlashTool.h"
#include "ConfigDlg.h"
#include "afxdialogex.h"
#include "HistoryData.h"
#include "utility.h"
#include "BootloaderConfigDlg.h"
extern void PrintLog(const wchar_t *format, ...);
// ConfigDlg dialog
IMPLEMENT_DYNAMIC(ConfigDlg, CDialogEx)
// See ConfigDlg.h for documentation of this method.
ConfigDlg::ConfigDlg(CWnd *pParent /*=NULL*/)
: CDialogEx(IDD_DIALOG_CONFIG, pParent)
, m_bcaData(NULL)
, m_bcaBinaries(_T(""))
{
}
// See ConfigDlg.h for documentation of this method.
ConfigDlg::~ConfigDlg()
{
if (m_bcaData != NULL)
{
free(m_bcaData);
}
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::DoDataExchange(CDataExchange *pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO_FILE2, m_ctrlImageFile);
DDX_Text(pDX, IDC_EDIT_BCA_BINARY, m_bcaBinaries);
}
BEGIN_MESSAGE_MAP(ConfigDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_BROWSE2, &ConfigDlg::OnBnClickedButtonBrowse)
ON_CBN_SELCHANGE(IDC_COMBO_FILE2, &ConfigDlg::OnSelchangeComboFile)
ON_BN_CLICKED(IDC_BUTTON_SAVE_BCA, &ConfigDlg::OnBnClickedButtonSaveBca)
ON_EN_CHANGE(IDC_EDIT_BCA_BINARY, &ConfigDlg::OnChangeEditBcaData)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_BUTTON_CONFIG_BCA, &ConfigDlg::OnBnClickedButtonConfigBca)
ON_CBN_KILLFOCUS(IDC_COMBO_FILE2, &ConfigDlg::OnKillfocusComboFile)
END_MESSAGE_MAP()
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::OnOK()
{
// CDialogEx::OnOK();
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::OnCancel()
{
// CDialogEx::OnCancel();
}
// See ConfigDlg.h for documentation of this method.
BOOL ConfigDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: Add extra initialization here
if (m_bcaData == NULL)
{
m_bcaData = (char *)malloc(64);
FillMemory(m_bcaData, 64, 0xFF);
}
// 128 for BCA characters,
// There are four lines of BCA characters
// 2*4 for four "\r\n" pairs.
((CEdit *)GetDlgItem(IDC_EDIT_BCA_BINARY))->SetLimitText(128 + 2 * 4);
// RefreshImageFileList();
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::RefreshImageFileList()
{
// Clear the contents
m_ctrlImageFile.ResetContent();
for (size_t i = 0; i < g_pHistoryData->GetFileCount(); i++)
{
m_ctrlImageFile.AddString(g_pHistoryData->GetFilePath(i));
}
bool enableSave = false;
if (g_pHistoryData->GetFileCount() > 0)
{
m_ctrlImageFile.SetCurSel(0);
if (g_pHistoryData->GetFileType(0) != HistoryData::FileType::kBinary)
{
PrintLog(_T("Warning: Currently, only binary file is supported!\r\n"));
enableSave = false;
}
else if (ReadBootloaderConfigureArea())
{
enableSave = true;
}
}
else
{
enableSave = false;
}
if (!enableSave)
{
ResetBootloaderConfigureArea();
}
GetDlgItem(IDC_BUTTON_SAVE_BCA)->EnableWindow(enableSave);
}
// See ConfigDlg.h for documentation of this method.
BOOL ConfigDlg::ReadBootloaderConfigureArea()
{
CString filePath;
m_ctrlImageFile.GetWindowTextW(filePath);
CFile *cFile = new CFile(filePath.GetBuffer(), CFile::modeReadWrite | CFile::typeBinary);
filePath.ReleaseBuffer();
ULONGLONG length = cFile->GetLength();
if (length < 0x400)
{
PrintLog(_T("Warning: File(%s) is smaller than 1K bytes, fill 0xFFs to extend it to 1K bytes."), filePath);
cFile->SeekToEnd();
while (length < 0x400)
{
cFile->Write("\xFF", 1);
length++;
}
cFile->Flush(); // Flush the 0xFFs to file.
}
cFile->Seek(0x3C0, CFile::begin);
cFile->Read(m_bcaData, 64);
PrintLog(_T("Read BCA data from image file."));
delete cFile;
UpdateDataOfBootloaderConfigureArea(FALSE);
return TRUE;
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::UpdateDataOfBootloaderConfigureArea(BOOL direction)
{
if (direction)
{
UpdateData(TRUE); // Update UI to CString m_bcaBinaries
int length = m_bcaBinaries.GetLength();
LPWSTR buffer = m_bcaBinaries.GetBuffer();
char tempHigh, tempLow;
int posBin = 0, posChar = 0;
while ((posBin < 64) && (posChar < length))
{
// Only convert legal characters.
if (isxdigit(buffer[posChar * 2]) && isxdigit(buffer[posChar * 2 + 1]))
{
tempHigh = buffer[posChar * 2] & 0xFF; // change TCHAR to char, abandon the high bits.
tempLow = buffer[posChar * 2 + 1] & 0xFF; // change TCHAR to char, abandon the high bits.
m_bcaData[posBin] = ((hex_to_int(tempHigh) & 0xFF) << 4) | (hex_to_int(tempLow) & 0xFF);
posBin++;
posChar++;
}
else
{
// Skip the illegal character pairs.
posChar++;
}
}
m_bcaBinaries.ReleaseBuffer();
}
else
{
LPTSTR buffer = m_bcaBinaries.GetBuffer(128 + 2 * 4 + 1); // 128 for 128 BCA characters
// 2 * 4 for enter characters("\r\n") each line
// 1 byte more for for terminator("\0")
int posBin = 0, posChar = 0;
for (; posBin < 64; posChar++, posBin++)
{
// 32 characters each line.
if ((!(posBin % 0x10)) && (posBin != 0))
{
// Add "\r\n" at the end of each line
buffer[posChar * 2] = '\r';
buffer[posChar * 2 + 1] = '\n';
posChar++;
}
buffer[posChar * 2] = int_to_hex(m_bcaData[posBin] >> 4);
buffer[posChar * 2 + 1] = int_to_hex(m_bcaData[posBin]);
}
buffer[posChar * 2] = '\0';
m_bcaBinaries.ReleaseBuffer();
UpdateData(FALSE); // Update CString m_bcaBinaries to UI
}
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::WriteBootloaderConfigureArea()
{
UpdateDataOfBootloaderConfigureArea(TRUE);
CString filePath;
m_ctrlImageFile.GetWindowTextW(filePath);
CFile *cFile = new CFile(filePath.GetBuffer(), CFile::modeWrite | CFile::typeBinary);
filePath.ReleaseBuffer();
cFile->Seek(0x3C0, CFile::begin);
cFile->Write(m_bcaData, 64);
cFile->Flush();
PrintLog(_T("Write new BCA data to image file."));
delete (cFile);
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::ResetBootloaderConfigureArea()
{
if (m_bcaData == NULL)
{
m_bcaData = (char *)malloc(64);
}
FillMemory(m_bcaData, 64, 0xFF);
UpdateDataOfBootloaderConfigureArea(FALSE);
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialogEx::OnShowWindow(bShow, nStatus);
// Image file list might be changed at other tab page.
// Refresh it when showing this tab page.
if (bShow)
{
RefreshImageFileList();
}
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::OnBnClickedButtonBrowse()
{
CFileDialog cFileDlg(TRUE);
cFileDlg.m_ofn.lpstrTitle = _T("Select the image file");
cFileDlg.m_ofn.lpstrFilter = _T("Supported files(*.bin)\0*.bin;\0All files(*.*)\0*.*\0\0");
if (IDOK == cFileDlg.DoModal())
{
CString fullPath = cFileDlg.GetPathName();
if (file_exists(fullPath))
{
g_pHistoryData->InsertFile(fullPath);
RefreshImageFileList();
}
else
{
PrintLog(_T("Invalid full path filename, or file doesn't exist.(%s)"), fullPath);
}
}
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::OnChangeEditBcaData()
{
// Update UI to string variable;
UpdateData(TRUE);
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::OnSelchangeComboFile()
{
// If a file is selected, bubble it to the head of a file list.
g_pHistoryData->BubbleSelectedFile(m_ctrlImageFile.GetCurSel());
RefreshImageFileList();
}
void ConfigDlg::OnKillfocusComboFile()
{
if (m_ctrlImageFile.GetCurSel() >= 0)
{
// If no change in the textbox, then return;
return;
}
CString filePath;
m_ctrlImageFile.GetWindowTextW(filePath);
// Test if the file exists
if (file_exists(filePath))
{
// File exists, add it to history file list, and refresh commbo box.
g_pHistoryData->InsertFile(filePath);
RefreshImageFileList();
}
else
{
// File doesn't exist.
if (!filePath.IsEmpty())
{
PrintLog(_T("Invalid full path filename, or file doesn't exist.(%s)"), filePath);
}
m_ctrlImageFile.SetCurSel(-1); // Set invalid selection.
ResetBootloaderConfigureArea(); // Reset configureArea to 0xFFs.
GetDlgItem(IDC_BUTTON_SAVE_BCA)->EnableWindow(false); // Disable save button.
}
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::OnBnClickedButtonConfigBca()
{
// BCA data in the UI page might be changed.
// Update it to memory region.
UpdateDataOfBootloaderConfigureArea(TRUE);
CString filePath;
m_ctrlImageFile.GetWindowTextW(filePath);
CFile *cFile = new CFile;
if (!cFile->Open(filePath, CFile::modeRead | CFile::typeBinary, NULL))
{
// If cannot open this file, transfer NULL to bootloader config dlg.
delete cFile;
cFile = NULL;
}
else
{
// Check if this file is binary file.
CString extension = PathFindExtension(filePath);
if (extension.CompareNoCase(_T(".bin")) != 0)
{
// If not binary file, close it and transfer NULL to bootloader config dlg.
cFile->Close();
delete cFile;
cFile = NULL;
}
}
BootloaderConfigDlg dlg((blfwkdll::BootloaderConfigureAreaData *)m_bcaData, cFile, this);
dlg.DoModal();
// Update the new BCA to UI page.
UpdateDataOfBootloaderConfigureArea(FALSE);
if (cFile != NULL)
{
cFile->Close();
delete cFile;
cFile = NULL;
}
}
// See ConfigDlg.h for documentation of this method.
void ConfigDlg::OnBnClickedButtonSaveBca()
{
WriteBootloaderConfigureArea();
}

View File

@@ -0,0 +1,100 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "afxwin.h"
// ConfigDlg Dialog
/*!
* \brief ConfigDlg class is the UI Dialog class for the
* BCA utilities tab page
*/
class ConfigDlg : public CDialogEx
{
DECLARE_DYNAMIC(ConfigDlg)
public:
//! \brief Generated standard constructor.
ConfigDlg(CWnd *pParent = NULL); // standard constructor
//! \brief Generated standard destructor.
virtual ~ConfigDlg();
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum
{
IDD = IDD_DIALOG_CONFIG
};
#endif
//! \brief Generated message map functions.
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
virtual void OnOK();
virtual void OnCancel();
public:
virtual BOOL OnInitDialog();
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
afx_msg void OnSelchangeComboFile();
afx_msg void OnKillfocusComboFile();
afx_msg void OnBnClickedButtonBrowse();
afx_msg void OnChangeEditBcaData();
afx_msg void OnBnClickedButtonConfigBca();
afx_msg void OnBnClickedButtonSaveBca();
public:
//! \brief Refresh the image file list.
void RefreshImageFileList();
//! \brief Read BCA data from image file to memory region(m_bcaData).
BOOL ReadBootloaderConfigureArea();
//! \brief Update BCA data between memory region and UI
//!
//! \param direction The update direction between UI and memory.
//! TRUE: from UI to memory
//! FALSE: from memory to UI
void UpdateDataOfBootloaderConfigureArea(BOOL direction);
//! \brief Write BCA data to image file.
void WriteBootloaderConfigureArea();
//! \brief Reset BCA data to all 0xFFs.
void ResetBootloaderConfigureArea();
public:
CComboBox m_ctrlImageFile; //!< A control variable for the Combox, IDC_COMBO_FILE2.
CString m_bcaBinaries; //!< A string variable for the Edit Control, IDC_EDIT_BCA_BINARY.
char *m_bcaData; //!< A pointer, pointing to a memory region that contains BCA binaries.
};

View File

@@ -0,0 +1,223 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "stdafx.h"
#include "KinetisFlashTool.h"
#include "FlashDlg.h"
#include "afxdialogex.h"
#include "Bootloader.h"
#include "utility.h"
// FlashDlg dialog
IMPLEMENT_DYNAMIC(FlashDlg, CDialogEx)
#define ERASE_REGION (_T("Erase Region"))
#define ERASE_ALL (_T("Erase All"))
#define ERASE_ALL_UNSECURE (_T("Erase All and Unsecure"))
#define INTERNAL_FLASH (_T("Internal Flash"))
#define QUADSPI_MEMORY (_T("QuadSPI 0 Memory"))
extern void PrintLog(const wchar_t *format, ...);
// See FlashDlg.h for documentation of this method.
FlashDlg::FlashDlg(CWnd *pParent /*=NULL*/)
: CDialogEx(IDD_DIALOG_FLASH, pParent)
{
}
// See FlashDlg.h for documentation of this method.
FlashDlg::~FlashDlg()
{
}
// See FlashDlg.h for documentation of this method.
void FlashDlg::DoDataExchange(CDataExchange *pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO_ERASE_OPT, m_comboEraseOpt);
DDX_Control(pDX, IDC_COMBO_ERASE_MEMORYID, m_comboMemoryID);
}
BEGIN_MESSAGE_MAP(FlashDlg, CDialogEx)
ON_CBN_SELCHANGE(IDC_COMBO_ERASE_OPT, &FlashDlg::OnSelchangeComboEraseOpt)
ON_BN_CLICKED(IDC_BUTTON_ERASE, &FlashDlg::OnBnClickedButtonErase)
ON_BN_CLICKED(IDC_BUTTON_IFR, &FlashDlg::OnBnClickedButtonIfr)
END_MESSAGE_MAP()
// See ConfigDlg.h for documentation of this method.
void FlashDlg::OnOK()
{
// CDialogEx::OnOK();
}
// See ConfigDlg.h for documentation of this method.
void FlashDlg::OnCancel()
{
// CDialogEx::OnCancel();
}
// See FlashDlg.h for documentation of this method.
BOOL FlashDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: Add extra initialization here
// Init the combo boxes
m_comboEraseOpt.AddString(ERASE_REGION);
m_comboEraseOpt.AddString(ERASE_ALL);
m_comboEraseOpt.AddString(ERASE_ALL_UNSECURE);
m_comboEraseOpt.SetCurSel(0);
GetDlgItem(IDC_STATIC_ERASE_ID)->EnableWindow(false);
GetDlgItem(IDC_COMBO_ERASE_MEMORYID)->EnableWindow(false);
m_comboMemoryID.AddString(INTERNAL_FLASH);
m_comboMemoryID.AddString(QUADSPI_MEMORY);
m_comboMemoryID.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
}
// See FlashDlg.h for documentation of this method.
void FlashDlg::OnSelchangeComboEraseOpt()
{
int eraseOpt = m_comboEraseOpt.GetCurSel();
// Memory ID combox only is enabled when erase-all command is selected.
GetDlgItem(IDC_STATIC_ERASE_ID)->EnableWindow(eraseOpt == 1);
GetDlgItem(IDC_COMBO_ERASE_MEMORYID)->EnableWindow(eraseOpt == 1);
// address and length only is enabled when erase-region command is selected.
GetDlgItem(IDC_STATIC_ERASE_ADDR)->EnableWindow(!eraseOpt);
GetDlgItem(IDC_EDIT_ERASE_ADDRESS)->EnableWindow(!eraseOpt);
GetDlgItem(IDC_STATIC_ERASE_LENGTH)->EnableWindow(!eraseOpt);
GetDlgItem(IDC_EDIT_ERASE_LENGTH)->EnableWindow(!eraseOpt);
}
// See FlashDlg.h for documentation of this method.
void FlashDlg::OnBnClickedButtonErase()
{
if (!g_pBootloader->m_isConneted)
{
PrintLog(_T("No device is connected!\r\nPlease press Connect button to connect the device first.\r\n"));
return;
}
Bootloader::EraseOption option;
ZeroMemory(&option, sizeof(Bootloader::EraseOption));
int eraseOpt = m_comboEraseOpt.GetCurSel();
if (eraseOpt == 0) // erase region
{
option.option = Bootloader::EraseOption::ERASE_OPERATION::erase_region;
CString startAddr;
GetDlgItem(IDC_EDIT_ERASE_ADDRESS)->GetWindowTextW(startAddr);
if (!cstringtoui(startAddr, option.startAddress))
{
PrintLog(_T("Error: Invalid Start Address.(%s)"), startAddr);
return;
}
CString length;
GetDlgItem(IDC_EDIT_ERASE_LENGTH)->GetWindowTextW(length);
if (!cstringtoui(length, option.length))
{
PrintLog(_T("Error: Invalid Length.(%s)"), length);
return;
}
}
else if (eraseOpt == 1) // flash-erase-all
{
int memoryId = m_comboMemoryID.GetCurSel();
if ((memoryId == 1) && (!(g_pBootloader->m_targetInfo.supportedCmd &
blfwkdll::Updater::COMMAND_MASK::kCommandMask_ConfigureQuadSpi)))
{
PrintLog(_T("Current Device doesn't support QuadSPI.\r\n"));
return;
}
option.option = Bootloader::EraseOption::ERASE_OPERATION::erase_all;
option.memoryID = static_cast<uint32_t>(memoryId);
}
else if (eraseOpt == 2) // flash-erase-all-unsecure
{
if (!(g_pBootloader->m_targetInfo.supportedCmd &
blfwkdll::Updater::COMMAND_MASK::kCommandMask_FlashEraseAllUnsecure))
{
PrintLog(_T("Current Device doesn't support FlashEraseAllUnsecure.\r\n"));
return;
}
option.option = Bootloader::EraseOption::ERASE_OPERATION::erase_all_and_unsecure;
}
g_pBootloader->Erase(&option);
}
// See FlashDlg.h for documentation of this method.
void FlashDlg::OnBnClickedButtonIfr()
{
if (!g_pBootloader->m_isConneted)
{
PrintLog(_T("No device is connected!\r\nPlease press Connect button to connect the device first.\r\n"));
return;
}
if (!(g_pBootloader->m_targetInfo.supportedCmd & blfwkdll::Updater::COMMAND_MASK::kCommandMask_FlashProgramOnce))
{
PrintLog(_T("Current Device doesn't support FlashProgramOnce.\r\n"));
return;
}
Bootloader::ProgramOnceOption option;
CString strW;
GetDlgItem(IDC_EDIT_IFR_INDEX)->GetWindowTextW(strW);
if (!cstringtoui(strW, option.index))
{
PrintLog(_T("Error: Invalid index.(%s)"), strW);
return;
}
GetDlgItem(IDC_EDIT_IFR_BYTECOUNT)->GetWindowTextW(strW);
if (!cstringtoui(strW, option.byteCount))
{
PrintLog(_T("Error: Invalid byteCount.(%s)"), strW);
return;
}
// Convert WCHAR to CHAR
GetDlgItem(IDC_EDIT_IFR_DATA)->GetWindowTextW(strW);
CStringA strA(strW.GetBuffer());
strW.ReleaseBuffer();
option.data = strA.GetBuffer();
strA.ReleaseBuffer();
g_pBootloader->ProgramOnce(&option);
}

View File

@@ -0,0 +1,75 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "afxwin.h"
// FlashDlg Dialog
/*!
* \brief FlashDlg class is the UI Dialog class for the
* Flash utilities tab page
*/
class FlashDlg : public CDialogEx
{
DECLARE_DYNAMIC(FlashDlg)
public:
//! \brief Generated standard constructor.
FlashDlg(CWnd *pParent = NULL); // standard constructor
//! \brief Generated standard destructor.
virtual ~FlashDlg();
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum
{
IDD = IDD_DIALOG_FLASH
};
#endif
protected:
//! \brief Generated message map functions.
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
virtual void OnOK();
virtual void OnCancel();
public:
//! \brief Generated message map functions.
virtual BOOL OnInitDialog();
afx_msg void OnSelchangeComboEraseOpt();
afx_msg void OnBnClickedButtonErase();
afx_msg void OnBnClickedButtonIfr();
CComboBox m_comboEraseOpt; //!< Control variable for erase option combox
CComboBox m_comboMemoryID; //!< Control variable for memory option combox
};

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2013-16, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "stdafx.h"
#include "HistoryData.h"
// See HistoryData.h for documentation of this variable.
HistoryData *g_pHistoryData;

View File

@@ -0,0 +1,383 @@
/*
* Copyright (c) 2013-16, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <vector>
#include <cstring>
/*!
* \brief HistoryData class stores the operation history.
* Save users operation steps.
*/
class HistoryData
{
public:
//! \brief Generated standard constructor.
HistoryData()
: m_currentDevice(-1)
, m_currentBaudRate(-1)
, m_imageAddress(0){};
//! \brief Generated standard destructor.
virtual ~HistoryData(){};
//! @brief File types.
enum FileType
{
kBinary, //!< Binary file.(.bin)
kSBFile, //!< SB file.(.sb)
kIntelHex, //!< Intel hex file.(.hex)
kSRecord, //!< Srecord file.(.srec, s19)
kUnsupported //!< Unsupported file type.
};
//! \brief Get current selected device index at device list.
//!
//! \return negative: no device is selected.
//! non-negative: current selected device index at device list.
int32_t GetCurrentDevice() { return m_currentDevice; };
//! \brief Change the index of current selected device.
//!
//! \param index at device list.
void SetCurrentDevice(int32_t index) { m_currentDevice = index; };
//! \brief Get the baud rate at the specified index.
//!
//! \param index of the list.
//!
//! \return the value of the baud rate.
int32_t GetBaudRate(size_t index) { return m_baudRate.at(index); };
//! \brief Get count of the baud rates in the list.
//!
//! \return the count.
size_t GetBaudRateCount() { return m_baudRate.size(); };
//! \brief Get current selected baud rate index at the list.
//!
//! \return negative: no baud rate is selected.
//! non-negative: current selected baud rate index at the list.
int32_t GetCurrentBaudRate() { return m_currentBaudRate; };
//! \brief Change the index of current selected baud rate.
//!
//! \param index at baud rate list.
void SetCurrentBaudRate(int32_t index) { m_currentBaudRate = index; };
//! \brief Append a new baud rate at the end of the list.
//!
//! \param the value of baud rate.
void AddBaudRate(int32_t baudrate)
{
// Find whether the new baudrate already exists in the list
for (std::vector<int32_t>::iterator it = m_baudRate.begin(); it != m_baudRate.end(); it++)
{
// If find the matched baud rate, return.
if (baudrate == *it)
{
return;
}
}
// If no matched, add it to end of list.
m_baudRate.push_back(baudrate);
};
//! \brief Insert a new baud rate, and change the current selected baud rate.
//! If the baud rate already exists in the list, only change the selected baud rate index
//!
//! \param the value of baud rate.
void InsertBaudRate(int32_t baudrate)
{
// If find index of the baud rate to insert.
for (std::vector<int32_t>::iterator it = m_baudRate.begin(); it != m_baudRate.end(); it++)
{
// Check next index.
if (baudrate > *it)
{
continue;
}
// The same baudrate in the list, just set it as current selected baud rate.
else if (baudrate == *it)
{
SetCurrentBaudRate(it - m_baudRate.begin());
return;
}
// Find the correct index, insert it and set it as current selected baud rate.
else
{
m_baudRate.insert(it, baudrate);
SetCurrentBaudRate(it - m_baudRate.begin());
return;
}
}
// If baudrate is bigger than any one in the list, add it to list back.
m_baudRate.push_back(baudrate);
SetCurrentBaudRate(GetBaudRateCount());
return;
};
//! \brief Get the VID at the specified index.
//!
//! \param index of the list.
//!
//! \return the value of the PID.
uint16_t GetVid(size_t index) { return m_vids.at(index); };
//! \brief Get count of the VID in the list .
//!
//! \return the count.
size_t GetVidCount() { return m_vids.size(); };
//! \brief Append a new VID at the end of the list.
//!
//! \param the value of VID.
void AddVid(uint16_t vid)
{
// Find whether the new vid already exists in the list.
for (std::vector<uint16_t>::iterator it = m_vids.begin(); it != m_vids.end(); it++)
{
// If find the matched vid, return.
if (vid == *it)
{
return;
}
}
// If no matched, add it to end of list.
m_vids.push_back(vid);
};
//! \brief Insert a VID at the head of the list.
//! If the VID already exists in the list, only bubble that VID to list head.
//!
//! \param the value of VID.
void InsertVid(uint16_t vid)
{
// Find whether the new vid already exists in the list.
for (std::vector<uint16_t>::iterator it = m_vids.begin(); it != m_vids.end(); it++)
{
// If find the matched vid, bubble it to the head of list. Then return.
if (vid == *it)
{
BubbleSelectedVid(it - m_vids.begin());
return;
}
}
// If no matched, add it to head of list.
m_vids.insert(m_vids.begin(), vid);
};
//! \brief bubble the VID at the specified index to the head of the VID list
//!
//! \param the index of VID.
void BubbleSelectedVid(size_t index)
{
uint16_t vid = m_vids.at(index);
m_vids.erase(m_vids.begin() + index);
m_vids.insert(m_vids.begin(), vid);
}
//! \brief Get the PID at the specified index.
//!
//! \param index of the list.
//!
//! \return the value of the PID.
uint16_t GetPid(size_t index) { return m_pids.at(index); };
//! \brief Get count of the PID in the list .
//!
//! \return the count.
size_t GetPidCount() { return m_pids.size(); };
//! \brief Append a new PID at the end of the list.
//!
//! \param the value of PID.
void AddPid(uint16_t pid)
{
// Find whether the new pid already exists in the list.
for (std::vector<uint16_t>::iterator it = m_pids.begin(); it != m_pids.end(); it++)
{
// If find the matched pid, return.
if (pid == *it)
{
return;
}
}
// If no matched, add it to end of list.
m_pids.push_back(pid);
};
//! \brief Insert a PID at the head of the list.
//! If the PID already exists in the list, only bubble it to list head.
//!
//! \param the value of PID.
void InsertPid(uint16_t pid)
{
// Find whether the new pid already exists in the list.
for (std::vector<uint16_t>::iterator it = m_pids.begin(); it != m_pids.end(); it++)
{
// If find the matched pid, bubble it to the head of list. Then return.
if (pid == *it)
{
BubbleSelectedPid(it - m_pids.begin());
return;
}
}
// If no matched, add it to head of list.
m_pids.insert(m_pids.begin(), pid);
};
//! \brief bubble the PID at the specified index to the head of the PID list
//!
//! \param the index of PID.
void BubbleSelectedPid(size_t index)
{
uint16_t pid = m_pids.at(index);
m_pids.erase(m_pids.begin() + index);
m_pids.insert(m_pids.begin(), pid);
}
//! \brief Get the file full path at the specified index of the file list.
//!
//! \param index of the list.
//!
//! \return full path string.
CString GetFilePath(int index) { return m_imageFile.at(index); };
//! \brief Get the file name at the specified index of the file list.
//!
//! \param index of the list.
//!
//! \return file name string.
CString GetFileName(int index)
{
CString fullPath = m_imageFile.at(index);
int pos = fullPath.ReverseFind(_T('\\'));
return fullPath.Right(fullPath.GetLength() - pos - 1);
};
//! \brief Get the file type of the file at the specified index of the file list.
//!
//! \param index of the list.
//!
//! \return file type.
FileType GetFileType(int index)
{
CString extension = PathFindExtension(m_imageFile.at(index));
if (extension.CompareNoCase(_T(".bin")) == 0)
{
return kBinary;
}
else if (extension.CompareNoCase(_T(".sb")) == 0)
{
return kSBFile;
}
else if (extension.CompareNoCase(_T(".hex")) == 0)
{
return kIntelHex;
}
else if ((extension.CompareNoCase(_T(".srec")) == 0) || (extension.CompareNoCase(_T(".s19")) == 0))
{
return kSRecord;
}
else
{
return kUnsupported;
}
}
//! \brief Get count of the files in the list .
//!
//! \return the count.
size_t GetFileCount() { return m_imageFile.size(); };
//! \brief Append a new file at the end of the list.
//!
//! \param the full path of the file.
void AddFile(CString fullPath)
{
// Find whether this file already exists in the file list.
for (std::vector<CString>::iterator it = m_imageFile.begin(); it != m_imageFile.end(); it++)
{
// If find the matched file, return.
if (fullPath.Compare(*it) == 0)
{
return;
}
}
// If no matched file, add it to end of file list.
m_imageFile.push_back(fullPath);
};
//! \brief Insert a file at the head of the list.
//! If the file already exists in the list, only bubble that file to list head.
//!
//! \param the full path of the file.
void InsertFile(CString fullPath)
{
// Find whether this file already exists in the file list.
for (std::vector<CString>::iterator it = m_imageFile.begin(); it != m_imageFile.end(); it++)
{
// If find the matched file, bubble it to the head of file list. Then return.
if (fullPath.Compare(*it) == 0)
{
BubbleSelectedFile(it - m_imageFile.begin());
return;
}
}
// If no matched file, add it to head of file list.
m_imageFile.insert(m_imageFile.begin(), fullPath);
};
//! \brief bubble the file at the specified index to the head of the file list
//!
//! \param the index of file.
void BubbleSelectedFile(int32_t index)
{
CString file = m_imageFile.at(index);
m_imageFile.erase(m_imageFile.begin() + index);
m_imageFile.insert(m_imageFile.begin(), file);
}
//! \brief Get image address previous used.
//!
//! \return value of the image address.
uint32_t GetImageAddress() { return m_imageAddress; };
//! \brief Change image address.
//!
//! \param value of the image address.
void SetImageAddress(uint32_t imageAddress) { m_imageAddress = imageAddress; };
//! \brief Get the string of backdoor key previous used.
//!
//! \return the string of backdoor key.
CString GetBackdoorKey() { return m_backdoorKey; }
//! \brief Change the string of backdoor key.
//!
//! \param the string of backdoor key.;
void SetBackdoorKey(CString backdoorKey) { m_backdoorKey = backdoorKey; };
private:
int32_t m_currentDevice; //!< current selected device at device list.
std::vector<int32_t> m_baudRate; //!< baud rate list.
int32_t m_currentBaudRate; //!< current selected baud rate.
std::vector<uint16_t> m_vids; //!< vid list.
std::vector<uint16_t> m_pids; //!< pid list.
std::vector<CString> m_imageFile; //!< image file list.
uint32_t m_imageAddress; //!< image address.
CString m_backdoorKey; //!< string of backdoor key.
};
extern HistoryData *g_pHistoryData; //!< Global point to HistoryData class.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// KinetisFlashTool.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// CKinetisFlashToolApp:
// See KinetisFlashTool.cpp for the implementation of this class
//
class CKinetisFlashToolApp : public CWinApp
{
public:
CKinetisFlashToolApp();
// Overrides
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
public:
//! \brief Parse init file to get the history information.
bool ParseIniFile(CString strFilename);
//! \brief Save history information to init file.
bool WriteIniFile(CString strFilename);
};
extern CKinetisFlashToolApp theApp;

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{864CBA51-EAF2-491E-9C74-4791B49FE039}</ProjectGuid>
<RootNamespace>KinetisFlashTool</RootNamespace>
<Keyword>MFCProj</Keyword>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Static</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(VC_IncludePath);$(WindowsSdk_71A_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\..\src;..\..\..\src\bm_usb</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<RegisterOutput>false</RegisterOutput>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>setupapi.lib</AdditionalDependencies>
<EnableUAC>true</EnableUAC>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>$(IntDir)KinetisFlashTool.tlb</TypeLibraryName>
<HeaderFileName>KinetisFlashTool_h.h</HeaderFileName>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\..\src;..\..\..\src\bm_usb</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<RegisterOutput>true</RegisterOutput>
<AdditionalDependencies>setupapi.lib</AdditionalDependencies>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
<ValidateAllParameters>true</ValidateAllParameters>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TypeLibraryName>$(IntDir)KinetisFlashTool.tlb</TypeLibraryName>
<HeaderFileName>KinetisFlashTool_h.h</HeaderFileName>
</Midl>
<ResourceCompile>
<Culture>0x0409</Culture>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Bootloader.h" />
<ClInclude Include="BootloaderConfigDlg.h" />
<ClInclude Include="BootloaderConfigText.h" />
<ClInclude Include="ConfigDlg.h" />
<ClInclude Include="FlashDlg.h" />
<ClInclude Include="KinetisFlashTool.h" />
<ClInclude Include="KinetisFlashToolDlg.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="SerialList.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="UpdateDlg.h" />
<ClInclude Include="HistoryData.h" />
<ClInclude Include="utility.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Bootloader.cpp" />
<ClCompile Include="BootloaderConfigDlg.cpp" />
<ClCompile Include="ConfigDlg.cpp" />
<ClCompile Include="FlashDlg.cpp" />
<ClCompile Include="KinetisFlashTool.cpp" />
<ClCompile Include="KinetisFlashToolDlg.cpp" />
<ClCompile Include="SerialList.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="UpdateDlg.cpp" />
<ClCompile Include="HistoryData.cpp" />
<ClCompile Include="utility.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="res\KinetisFlashTool.rc2" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="KinetisFlashTool.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="res\Freescale.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\common\blfwkdll\blfwkdll.vcxproj">
<Project>{426d14fe-6f2b-442d-893d-b5730dd6941f}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties RESOURCE_FILE="KinetisFlashTool.rc" />
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="KinetisFlashTool.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="KinetisFlashToolDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="UpdateDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="SerialList.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HistoryData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="utility.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Bootloader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ConfigDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BootloaderConfigDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FlashDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BootloaderConfigText.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="KinetisFlashTool.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="KinetisFlashToolDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="UpdateDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SerialList.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HistoryData.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="utility.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Bootloader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ConfigDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="BootloaderConfigDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FlashDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="res\KinetisFlashTool.rc2">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="KinetisFlashTool.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="res\Freescale.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,153 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// KinetisFlashToolDlg.h : header file
//
#pragma once
#include "afxwin.h"
#include "afxcmn.h"
#include <Setupapi.h>
#include "UpdateDlg.h"
#include "FlashDlg.h"
#include "ConfigDlg.h"
#include "../../common/blfwkdll/blfwkdll.h"
// class CKinetisFlashToolDlgAutoProxy;
// CKinetisFlashToolDlg dialog
/*!
* \brief CKinetisFlashToolDlg class is the UI Dialog class for the main page
*/
class CKinetisFlashToolDlg : public CDialogEx
{
DECLARE_DYNAMIC(CKinetisFlashToolDlg);
// friend class CKinetisFlashToolDlgAutoProxy;
// Construction
public:
//! \brief Generated standard constructor.
CKinetisFlashToolDlg(CWnd *pParent = NULL); // standard constructor
//! \brief Generated standard destructor.
virtual ~CKinetisFlashToolDlg();
// Dialog Data
enum
{
IDD = IDD_KINETISFLASHTOOL_DIALOG
};
protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
// Implementation
protected:
// CKinetisFlashToolDlgAutoProxy* m_pAutoProxy;
HICON m_hIcon;
BOOL CanExit();
//! \brief Generated message map functions.
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnClose();
virtual void OnOK();
virtual void OnCancel();
DECLARE_MESSAGE_MAP()
//! \brief Scan COM port and update it to UI.
void RefreshComPortList();
//! \brief Refresh baud rate list.
void RefreshBaudrateList();
//! \brief Refresh PID list.
void RefreshPidList();
//! \brief Refresh VID list.
void RefreshVidList();
//! \brief Append a new log string to the log textbox.
//!
//! \param Log string.
void AppendLog(CString log);
//! \brief Reset operation.
void Reset();
//! \brief Connect operation.
void Connect();
public:
//! \brief Generated message map functions.
afx_msg void OnBnClickedRadio();
afx_msg void OnCbnSelchangeComboPortVid();
afx_msg void OnCbnSelchangeComboBaudPid();
afx_msg void OnKillfocusComboPortVid();
afx_msg void OnKillfocusComboBaudPid();
afx_msg void OnClickedButtonCntReset();
afx_msg void OnTcnSelchangeTabFunc(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD_PTR dwData);
//! \brief User defined message map functions.
afx_msg LRESULT OnUpdateLog(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnChangeConnection(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnUpdateStatus(WPARAM wParam, LPARAM lParam);
//! \brief Get the PeripheralConfig of bootloader.
void GetPeripheralConfig(blfwkdll::Updater::PeripheralConfig *config);
//! \brief Register usb device interface.
void RegisterUsbDeviceInterface();
CComboBox m_comboPortOrVID; //!< Control variable for Com port/VID combox
CComboBox m_comboBaudOrPID; //!< Control variable for Baud rate/PID combox
CString m_bootloaderVersion; //!< Variable for device info
CString m_protoclVersion; //!< Variable for device info
CString m_securityState; //!< Variable for device info
CString m_flashSize; //!< Variable for device info
CString m_flashSector; //!< Variable for device info
CString m_ramSize; //!< Variable for device info
CString m_rsvRgnFlashStart; //!< Variable for device info
CString m_rsvRgnFlashEnd; //!< Variable for device info
CString m_rsvRgnRamStart; //!< Variable for device info
CString m_rsvRgnRamEnd; //!< Variable for device info
CTabCtrl m_tabFunc; //!< Control variable for tab control.
CString m_log; //!< Variable for log text box.
CEdit m_logCtrl; //!< Control variable for log textbox.
UpdateDlg m_updateDlg; //!< Variable for update tab page.
FlashDlg m_flashDlg; //!< Variable for flash utility tab page.
ConfigDlg m_bootloaderConfigDLg; //!< Variable for config tab page.
HDEVNOTIFY m_devNotify; //!< Handler for device change notify.
};

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "stdafx.h"
#include "SerialList.h"
#define KEY_SERIALCOMM_PATH _T("HARDWARE\\DEVICEMAP\\SERIALCOMM")
// See SerialList.h for documentation of this method.
SerialList *g_pAllComDevices;
// See SerialList.h for documentation of this method.
void SerialList::ScanSerialDevices()
{
if (m_serialDevices.size() != 0)
{
m_serialDevices.clear();
}
HKEY hKey;
int i = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, KEY_SERIALCOMM_PATH, NULL, KEY_READ, &hKey);
if (i == ERROR_SUCCESS)
{
int i = 0, status;
TCHAR Name[128], Data[32];
DWORD dNameLength, dDataLength;
do
{
dNameLength = sizeof(Name);
dDataLength = sizeof(Data);
status = ::RegEnumValue(hKey, i, Name, &dNameLength, NULL, NULL, (PUCHAR)Data, &dDataLength);
if ((status == ERROR_SUCCESS) && (dDataLength != 0))
{
m_serialDevices.push_back(SerialDevice(Data));
}
i++;
} while (status != ERROR_NO_MORE_ITEMS);
}
::RegCloseKey(hKey);
SortSerialDevices();
}
// See SerialList.h for documentation of this method.
void SerialList::SortSerialDevices()
{
size_t length = GetDeviceCount();
for (size_t i = 0; i < length; i++)
{
for (size_t j = i + 1; j < length; j++)
{
if (GetDevice(i).GetNum() > GetDevice(j).GetNum())
{
std::swap(m_serialDevices[i], m_serialDevices[j]);
}
}
}
}

View File

@@ -0,0 +1,111 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <vector>
#include <cstring>
/*!
* \brief SerialDevice class represent a COM port hardware on host
*/
class SerialDevice
{
public:
//! \brief Generated standard constructor.
SerialDevice()
: m_port(_T("")){};
//! \brief Generated standard constructor with a parameter.
SerialDevice(LPCTSTR port)
: m_port(port){};
//! \brief Generated standard destructor.
virtual ~SerialDevice(){};
//! \brief Get the string containing COM port.(COMxx)
virtual CString GetString() { return (m_port); };
//! \brief Get the port number only.
virtual uint32_t GetNum() { return _ttoi(m_port.Mid(3)); };
private:
CString m_port; //!< A string variable contains COM port string.
};
/*!
* \brief SerialList class contains all serial devices on host
*/
class SerialList
{
public:
//! \brief Generated standard constructor.
SerialList(){};
//! \brief Generated standard destructor.
virtual ~SerialList(){};
//! \brief Get SerialDevice variable at specified index.
SerialDevice GetDevice(int index) { return m_serialDevices.at(index); };
//! \brief Get the number of devices in the list.
size_t GetDeviceCount() { return m_serialDevices.size(); };
//! \brief Find whether the specified device is in the list.
int FindSerialDevice(SerialDevice device)
{
std::vector<SerialDevice>::iterator it;
for (it = m_serialDevices.begin(); it != m_serialDevices.end(); it++)
{
// Check next index.
if (device.GetNum() > it->GetNum())
{
continue;
}
// The same COM device in the list, return the index
else if (device.GetNum() == it->GetNum())
{
return it - m_serialDevices.begin();
}
// No matched, return negative.
else
{
return -1;
}
}
return -1;
}
//! \brief Scan all COM port hardware on the host.
void ScanSerialDevices();
//! \brief Sort all devices in the list as ascending order
void SortSerialDevices();
private:
std::vector<SerialDevice> m_serialDevices; //!< Serial Device list.
};
extern SerialList *g_pAllComDevices; //!< Global point to SerialList class.

View File

@@ -0,0 +1,377 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "stdafx.h"
#include "KinetisFlashTool.h"
#include "UpdateDlg.h"
#include "afxdialogex.h"
#include "Bootloader.h"
#include "HistoryData.h"
#include "utility.h"
#include "KinetisFlashToolDlg.h"
extern void PrintLog(const wchar_t *format, ...);
extern CKinetisFlashToolDlg *g_pMainDlg;
// UpdateDlg Dialog
IMPLEMENT_DYNAMIC(UpdateDlg, CDialogEx)
// See UpdateDlg.h for documentation of this method.
UpdateDlg::UpdateDlg(CWnd *pParent /*=NULL*/)
: CDialogEx(IDD_DIALOG_UPDATE, pParent)
, m_address(_T(""))
, m_backdoorKey(_T(""))
, m_doErasetoUnlock(false)
, m_useKeytoUnlock(false)
{
}
// See UpdateDlg.h for documentation of this method.
UpdateDlg::~UpdateDlg()
{
}
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::DoDataExchange(CDataExchange *pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_ADDRESS, m_address);
DDX_Control(pDX, IDC_COMBO_FILE, m_ctrlImageFile);
DDX_Text(pDX, IDC_EDIT_KEY, m_backdoorKey);
DDX_Control(pDX, IDC_PROGRESS_BAR, m_progressCtrl);
}
BEGIN_MESSAGE_MAP(UpdateDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_UPDATE, &UpdateDlg::OnBnClickedButtonUpdate)
ON_BN_CLICKED(IDC_BUTTON_BROWSE, &UpdateDlg::OnBnClickedButtonBrowse)
ON_BN_CLICKED(IDC_RADIO_ERASE, &UpdateDlg::OnBnClickedRadioErase)
ON_BN_CLICKED(IDC_RADIO_UNLOCK, &UpdateDlg::OnBnClickedRadioUnlock)
ON_EN_CHANGE(IDC_EDIT_ADDRESS, &UpdateDlg::OnChangeEdit)
ON_EN_CHANGE(IDC_EDIT_KEY, &UpdateDlg::OnChangeEdit)
ON_CBN_SELCHANGE(IDC_COMBO_FILE, &UpdateDlg::OnSelchangeComboFile)
ON_CBN_KILLFOCUS(IDC_COMBO_FILE, &UpdateDlg::OnKillfocusComboFile)
ON_WM_SHOWWINDOW()
// User defined message
ON_MESSAGE(USER_MS_UPDATA_PROGRESS, &UpdateDlg::OnUpdateProgress)
END_MESSAGE_MAP()
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::OnOK()
{
// CDialogEx::OnOK();
}
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::OnCancel()
{
// CDialogEx::OnCancel();
}
// See UpdateDlg.h for documentation of this method.
BOOL UpdateDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: Add extra initialization here
// Init the image file list
RefreshImageFileList();
// Load saved image address.
m_address = format_cstring(_T("0x%08X"), g_pHistoryData->GetImageAddress());
// Max num of characters is 10, including "0x" leading
((CEdit *)GetDlgItem(IDC_EDIT_ADDRESS))->SetLimitText(10);
// Disable check of auto connect
// This control only takes effect when connected.
((CButton *)GetDlgItem(IDC_CHECK_AUTOCNT))->SetCheck(false);
// Init values are false.
((CButton *)GetDlgItem(IDC_RADIO_ERASE))->SetCheck(m_doErasetoUnlock);
((CButton *)GetDlgItem(IDC_RADIO_UNLOCK))->SetCheck(m_useKeytoUnlock);
GetDlgItem(IDC_STATIC_KEY)->EnableWindow(false);
GetDlgItem(IDC_EDIT_KEY)->EnableWindow(false);
m_progressCtrl.SetRange(0, 100);
// Load save backdoor key
m_backdoorKey = g_pHistoryData->GetBackdoorKey();
// Max num of characters is 16. Must hex digits without "0x" leading.
((CEdit *)GetDlgItem(IDC_EDIT_KEY))->SetLimitText(16);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialogEx::OnShowWindow(bShow, nStatus);
if (bShow)
{
// Config page might change the image file list.
// Need refreshing every time open the update page.
RefreshImageFileList();
}
}
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::RefreshImageFileList()
{
// Clear the content.
m_ctrlImageFile.ResetContent();
for (size_t i = 0; i < g_pHistoryData->GetFileCount(); i++)
{
m_ctrlImageFile.AddString(g_pHistoryData->GetFilePath(i));
}
if (g_pHistoryData->GetFileCount() > 0)
{
m_ctrlImageFile.SetCurSel(0);
if (g_pHistoryData->GetFileType(0) == HistoryData::FileType::kBinary)
{
// Enable image address if a binary file is selected.
GetDlgItem(IDC_STATIC_ADDRESS)->EnableWindow(true);
GetDlgItem(IDC_EDIT_ADDRESS)->EnableWindow(true);
}
else
{
GetDlgItem(IDC_STATIC_ADDRESS)->EnableWindow(false);
GetDlgItem(IDC_EDIT_ADDRESS)->EnableWindow(false);
}
GetDlgItem(IDC_BUTTON_UPDATE)->EnableWindow(true);
}
else
{
GetDlgItem(IDC_BUTTON_UPDATE)->EnableWindow(false);
}
}
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::OnBnClickedButtonBrowse()
{
CFileDialog cFileDlg(TRUE);
cFileDlg.m_ofn.lpstrTitle = _T("Select the image file");
cFileDlg.m_ofn.lpstrFilter =
_T("Supported files(*.bin, *.sb, *.srec, *.s19, ")
_T("*.hex)\0*.bin;*.sb;*.srec;*.s19;*.hex\0All files(*.*)\0*.*\0\0");
if (IDOK == cFileDlg.DoModal())
{
CString fullPath = cFileDlg.GetPathName().GetBuffer();
if (file_exists(fullPath))
{
g_pHistoryData->InsertFile(fullPath);
RefreshImageFileList();
}
else
{
PrintLog(_T("Invalid full path filename, or file doesn't exist.(%s)"), fullPath);
}
}
}
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::OnSelchangeComboFile()
{
g_pHistoryData->BubbleSelectedFile(m_ctrlImageFile.GetCurSel());
RefreshImageFileList();
}
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::OnKillfocusComboFile()
{
if (m_ctrlImageFile.GetCurSel() >= 0)
{
// If no change in the textbox, then return;
return;
}
CString filePath;
m_ctrlImageFile.GetWindowTextW(filePath);
// Test if the file exists
if (file_exists(filePath))
{
// File exists, add it to history file list, and refresh commbo box.
g_pHistoryData->InsertFile(filePath);
RefreshImageFileList();
}
else
{
// File doesn't exist.
if (!filePath.IsEmpty())
{
PrintLog(_T("Invalid full path filename, or file doesn't exist.(%s)"), filePath);
}
m_ctrlImageFile.SetCurSel(-1); // Set invalid selection.
GetDlgItem(IDC_BUTTON_UPDATE)->EnableWindow(false);
}
}
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::OnBnClickedRadioErase()
{
// Invert the state, and update the UI
m_doErasetoUnlock = !m_doErasetoUnlock;
((CButton *)GetDlgItem(IDC_RADIO_ERASE))->SetCheck(m_doErasetoUnlock);
if (m_doErasetoUnlock)
{
// if check the flash-erase-all-unsecure, disable backdoor key text input.
GetDlgItem(IDC_STATIC_KEY)->EnableWindow(false);
GetDlgItem(IDC_EDIT_KEY)->EnableWindow(false);
// And uncheck flash-security-disable.
m_useKeytoUnlock = false;
((CButton *)GetDlgItem(IDC_RADIO_UNLOCK))->SetCheck(false);
}
#ifdef _DEBUG
PrintLog(_T("Erase = %s, Unlock = %s"), m_doErasetoUnlock ? _T("True") : _T("False"),
m_useKeytoUnlock ? _T("True") : _T("False"));
#endif
}
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::OnBnClickedRadioUnlock()
{
// Invert the state, and update the UI
m_useKeytoUnlock = !m_useKeytoUnlock;
((CButton *)GetDlgItem(IDC_RADIO_UNLOCK))->SetCheck(m_useKeytoUnlock);
if (m_useKeytoUnlock)
{
// if check the flash-security-disable, enable backdoor key text input.
GetDlgItem(IDC_STATIC_KEY)->EnableWindow(true);
GetDlgItem(IDC_EDIT_KEY)->EnableWindow(true);
// And uncheck flash-erase-all-unsecure.
m_doErasetoUnlock = false;
((CButton *)GetDlgItem(IDC_RADIO_ERASE))->SetCheck(false);
}
else
{
// if uncheck the flash-erase-all-unsecure, disable backdoor key text input.
GetDlgItem(IDC_STATIC_KEY)->EnableWindow(false);
GetDlgItem(IDC_EDIT_KEY)->EnableWindow(false);
}
#ifdef _DEBUG
PrintLog(_T("Erase = %s, Unlock = %s"), m_doErasetoUnlock ? _T("True") : _T("False"),
m_useKeytoUnlock ? _T("True") : _T("False"));
#endif
}
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::OnChangeEdit()
{
// update UI to variables(m_address and m_backdoorKey)
UpdateData(true);
}
// See UpdateDlg.h for documentation of this method.
void UpdateDlg::OnBnClickedButtonUpdate()
{
#ifdef DISABLE_QUICK_UPDATE
if (!g_pBootloader->m_isConneted)
{
PrintLog(_T("No device is connected!\r\nTry to connect device first.\r\n"));
}
#endif
Bootloader::FlashFirmwareOption config;
// Convert CString to std::string.
CString wFullPath;
m_ctrlImageFile.GetWindowTextW(wFullPath);
CStringA tFullPath(wFullPath.GetBuffer());
wFullPath.ReleaseBuffer();
config.imageFilePath = tFullPath.GetBuffer();
tFullPath.ReleaseBuffer();
CString extension = PathFindExtension(wFullPath);
if (extension.CompareNoCase(_T(".bin")) == 0)
{
if (!cstringtoui(m_address, config.baseAddress))
{
PrintLog(_T("Error: Invalid address input.(%s)"), m_address);
return;
}
}
else
{
config.baseAddress = 0;
}
config.doErasetoUnlock = m_doErasetoUnlock && (g_pBootloader->m_targetInfo.securityState != 0);
config.useKeytoUnlock = m_useKeytoUnlock && (g_pBootloader->m_targetInfo.securityState != 0);
CStringA tBackdoorkey(m_backdoorKey.GetBuffer());
config.backdoorkey = tBackdoorkey.GetBuffer();
// For normal update, kill timer when autocnt button is not checked.
if (((CButton *)GetDlgItem(IDC_CHECK_AUTOCNT))->GetCheck() != BST_CHECKED)
{
g_pMainDlg->KillTimer(1);
}
else
{
g_pMainDlg->SetTimer(1, 1000, NULL);
}
#ifndef DISABLE_QUICK_UPDATE
if (g_pBootloader->m_isConneted)
{
#endif
g_pBootloader->UpdateImage(NULL, &config);
#ifndef DISABLE_QUICK_UPDATE
}
else
{
blfwkdll::Updater::PeripheralConfig peripheralConfig;
g_pMainDlg->GetPeripheralConfig(&peripheralConfig);
g_pBootloader->UpdateImage(&peripheralConfig, &config);
}
#endif
}
// See UpdateDlg.h for documentation of this method.
LRESULT UpdateDlg::OnUpdateProgress(WPARAM wParam, LPARAM lParam)
{
int percentage = m_progressCtrl.GetPos();
if (percentage != (int)wParam)
{
percentage = (int)wParam;
GetDlgItem(IDC_STATIC_PROGRESS_BAR)->SetWindowTextW(format_cstring(_T("%2d%%"), percentage));
m_progressCtrl.SetPos(percentage);
}
return 0;
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "afxwin.h"
#include "afxcmn.h"
// UpdateDlg dialog
/*!
* \brief UpdateDlg class is the UI Dialog class for the
* Update tab page
*/
class UpdateDlg : public CDialogEx
{
DECLARE_DYNAMIC(UpdateDlg)
public:
//! \brief Generated standard constructor.
UpdateDlg(CWnd *pParent = NULL); // standard constructor
//! \brief Generated standard destructor.
virtual ~UpdateDlg();
// Dialog Data
#ifdef AFX_DESIGN_TIME
enum
{
IDD = IDD_DIALOG_UPDATE
};
#endif
protected:
//! \brief Generated message map functions.
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
virtual void OnOK();
virtual void OnCancel();
public:
//! \brief Generated message map functions.
virtual BOOL OnInitDialog();
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
afx_msg void OnSelchangeComboFile();
afx_msg void OnKillfocusComboFile();
afx_msg void OnBnClickedButtonBrowse();
afx_msg void OnBnClickedRadioErase();
afx_msg void OnBnClickedRadioUnlock();
afx_msg void OnChangeEdit();
afx_msg void OnBnClickedButtonUpdate();
afx_msg LRESULT OnUpdateProgress(WPARAM wParam, LPARAM lParam);
//! \brief Refresh the image file list.
void RefreshImageFileList();
CComboBox m_ctrlImageFile; //!< A control variable for the Combox, IDC_COMBO_FILE.
CString m_address; //!< A control variable for the Edit Control, IDC_EDIT_ADDRESS.
CString m_backdoorKey; //!< A control variable for the Edit Control, IDC_EDIT_KEY.
BOOL m_doErasetoUnlock; //!< A variable for whether do
//! flash-erase-all-unsecure command when updating.
BOOL m_useKeytoUnlock; //!< A variable for whether do flash-security-disable
//! command when updating.
CProgressCtrl m_progressCtrl;
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// stdafx.cpp : source file that includes just the standard includes
// KinetisFlashTool.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,102 @@
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h> // MFC support for ribbons and control bars
// This macro is the same as IMPLEMENT_OLECREATE, except it passes TRUE
// for the bMultiInstance parameter to the COleObjectFactory constructor.
// We want a separate instance of this application to be launched for
// each automation proxy object requested by automation controllers.
#ifndef IMPLEMENT_OLECREATE2
#define IMPLEMENT_OLECREATE2(class_name, external_name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
AFX_DATADEF COleObjectFactory class_name::factory(class_name::guid, RUNTIME_CLASS(class_name), TRUE, \
_T(external_name)); \
const AFX_DATADEF GUID class_name::guid = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } };
#endif // IMPLEMENT_OLECREATE2
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment( \
linker, \
"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment( \
linker, \
"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment( \
linker, \
"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
#define USER_MS_UPDATA_LOG WM_USER + 100
#define USER_MS_CONNECTION_CHANGE WM_USER + 101
#define USER_MS_UPDATA_STATUS WM_USER + 102
#define USER_MS_UPDATA_PROGRESS WM_USER + 103
#include <InitGuid.h>
// GUID interface for COM port device (86E0D1E0-8089-11D0-9CE4-08003E301F73)
DEFINE_GUID(GUID_DEVINTERFACE_COMPORT, 0x86E0D1E0, 0x8089, 0x11D0, 0x9C, 0xE4, 0x08, 0x00, 0x3E, 0x30, 0x1F, 0x73);
// GUID interface for USB device (A5DCBF10-6530-11D2-901F-00C04FB951ED)
DEFINE_GUID(GUID_DEVINTERFACE_USB_DEVICE, 0xA5DCBF10, 0x6530, 0x11D2, 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED);
// GUID device class for ports (4d36E978-E325-11CE-BFC1-08002BE10318)
DEFINE_GUID(GUID_DEVCLASS_PORTS, 0x4d36E978, 0xE325, 0x11CE, 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18);
// GUID device class for USB (36FC9E60-C465-11CF-8056-444553540000)
DEFINE_GUID(GUID_DEVCLASS_USB, 0x36FC9E60, 0xC465, 0x11CF, 0x80, 0x56, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00);

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>

View File

@@ -0,0 +1,201 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "stdafx.h"
#include "utility.h"
#include <stdio.h>
#include <stdarg.h>
#include <stdexcept>
#include <string.h>
#include <stdlib.h>
//! Size of the temporary buffer to hold the formatted output string.
#define WIN32_FMT_BUF_LEN (512)
/*!
* \brief Simple template class to free a pointer.
*/
template <typename T>
class free_ptr
{
public:
//! \brief Constructor.
free_ptr(T ptr)
: m_p(ptr)
{
}
//! \brief Destructor.
~free_ptr()
{
if (m_p)
{
free(m_p);
}
}
protected:
T m_p; //!< The value to free.
};
// See utility.h for documentation of this method.
CString format_cstring(const wchar_t *format, ...)
{
LPWSTR buffer;
va_list args;
int len;
int result = -1;
va_start(args, format);
len = _vsctprintf(format, args) + 1;
buffer = (LPWSTR)malloc(len * sizeof(WCHAR));
if (buffer)
{
result = std::vswprintf(buffer, len, format, args);
}
va_end(args);
if (result != -1 && buffer)
{
free_ptr<LPWSTR> freebuf(buffer);
return CString(buffer);
}
return _T("");
}
// See utility.h for documentation of this method.
bool cstringtoi(const CString &s, INT32 &number)
{
if (s.IsEmpty())
return false;
TCHAR *p;
INT64 temp;
temp = _tcstoll(s, &p, 0);
if ((temp > INT32_MAX) || (temp < INT32_MIN))
{
return false;
}
number = static_cast<INT32>(temp);
return (p != NULL) && (*p == 0);
}
// See utility.h for documentation of this method.
bool cstringtoui(const CString &s, UINT32 &number)
{
if (s.IsEmpty())
return false;
if (s[0] == '-')
return false;
TCHAR *p;
UINT64 temp;
temp = _tcstoull(s, &p, 0);
if (temp > UINT32_MAX)
{
return false;
}
number = static_cast<UINT32>(temp);
return (p != NULL) && (*p == 0);
}
// See utility.h for documentation of this method.
CString scale_bytes(UINT64 sizeInBytes)
{
double originalSize = (double)sizeInBytes;
double scaledSize = 0;
scaledSize = originalSize / (1024 * 1024 * 1024);
if (scaledSize >= 1.0) // GB
{
if (sizeInBytes % (1024 * 1024 * 1024))
return format_cstring(_T("%.3f GB"), scaledSize);
else
return format_cstring(_T("%.f GB"), scaledSize);
}
scaledSize = originalSize / (1024 * 1024);
if (scaledSize >= 1.0) // MB
{
if (sizeInBytes % (1024 * 1024))
return format_cstring(_T("%.3f MB"), scaledSize);
else
return format_cstring(_T("%.f MB"), scaledSize);
}
scaledSize = originalSize / 1024;
if (scaledSize >= 1.0) // KB
{
if (sizeInBytes % 1024)
return format_cstring(_T("%.3f KB"), scaledSize);
else
return format_cstring(_T("%.f KB"), scaledSize);
}
else // bytes
{
return format_cstring(_T("%d bytes"), sizeInBytes);
}
} // scale_bytes()
// See utility.h for documentation of this method.
unsigned char hex_to_int(char hex)
{
if (isdigit(hex))
return hex - '0';
else if (hex >= 'a' && hex <= 'f')
return 10 + hex - 'a';
else if (hex >= 'A' && hex <= 'F')
return 10 + hex - 'A';
// unknow char
return 0;
}
// See utility.h for documentation of this method.
char int_to_hex(unsigned char digit)
{
digit &= 0xF;
if (digit < 10)
return digit + '0';
else
return digit - 10 + 'A';
}
// See utility.h for documentation of this method.
bool file_exists(CString fullPath)
{
// Do not use PathFileExists here. folder names should not be acceptable.
CFile testFileExist;
if (!testFileExist.Open(fullPath, CFile::modeRead, NULL))
{
return false;
}
testFileExist.Close();
return true;
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
//! \brief Get a formated CString.
CString format_cstring(const wchar_t *fmt, ...);
//! \brief Convert a CString to int.
//!
//! \return false for an error occurred during the conversion.
//! true for success.
bool cstringtoi(const CString &s, INT32 &number);
//! \brief Convert a CString to unsigned int.
//!
//! \return false for an error occurred during the conversion.
//! true for success.
bool cstringtoui(const CString &s, UINT32 &number);
//! \brief Convert unsigned int to formated size string.
CString scale_bytes(UINT64 sizeInBytes);
//! \brief Convert an ASICII hex text to an integer.
unsigned char hex_to_int(char hex);
//! \brief Convert an integer to an ASICII hex.
char int_to_hex(unsigned char digit);
//! \brief Test whether the file exists.
bool file_exists(CString fullPath);

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="QCBGenerator" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/QCBGenerator" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/QCBGenerator" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="../../src/qspi_config_block_generator.c">
<Option compilerVar="CC" />
</Unit>
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
<File name="..\..\src\qspi_config_block_generator.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="13410" topLine="231" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QCBGenerator", "QCBGenerator.vcxproj", "{E88CB90B-9F89-43AF-9F1E-94DD52591F47}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E88CB90B-9F89-43AF-9F1E-94DD52591F47}.Debug|Win32.ActiveCfg = Debug|Win32
{E88CB90B-9F89-43AF-9F1E-94DD52591F47}.Debug|Win32.Build.0 = Debug|Win32
{E88CB90B-9F89-43AF-9F1E-94DD52591F47}.Release|Win32.ActiveCfg = Release|Win32
{E88CB90B-9F89-43AF-9F1E-94DD52591F47}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\qspi_config_block_generator.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E88CB90B-9F89-43AF-9F1E-94DD52591F47}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>QCBGenerator</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>Full</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>No</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\qspi_config_block_generator.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,105 @@
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
const qspi_config_t qspi_config_block = {
.tag = kQspiConfigTag,
.version = {.version = kQspiVersionTag },
.lengthInBytes = 512,
.sflash_A1_size = 0x1000000, // 16MB
.sclk_freq = kQspiSerialClockFreq_High, // High frequency, 96MHz/4 = 24MHz
.sflash_type = kQspiFlashPad_Quad, // SPI Flash devices work under quad-pad mode
.sflash_port = kQspiPort_EnablePortA, // Only QSPI0A is enabled.
.busy_bit_offset = 0, // Busy offset is 0, polarity: 1 means busy
.ddr_mode_enable = 1, // Enable DDR mode
.data_hold_time = 1, // Data aligned with 2x serial flash half clock
.ddrsmp = 0,
.dqs_enable = 0, // Disable DQS feature
.dqs_loopback = 0,
.pagesize = 256, // Page Size : 256 bytes
.sectorsize = 0x1000, // Sector Size: 4KB
.ips_command_second_divider = 0,
.device_mode_config_en = 1, // Configure the device to 4-byte address mode
.device_cmd = 0, // Not needed.
.write_cmd_ipcr = 5UL << 24, // Seq5 for setting address type to 4 bytes
.look_up_table =
{
// Seq0 : 4x I/O DTR Read (maximum supported freq: 54MHz)
/*
CMD_DDR: 0xED - Quad Read, Single pad
ADDR_DDR: 0x18 - 24bit address, Quad pads
DUMMY: 0x06 - 6 dummy cycles, Quad pads
READ_DDR: 0x80 - Read 128 bytes, Quad pads
JUMP_ON_CS: 0
*/
[0] = 0x2A1804ED, [1] = 0x3A800E06, [2] = 0x2400,
// Seq1: Write Enable (maximum supported freq: 120MHz)
/*
CMD: 0x06 - Write Enable, Single pad
*/
[4] = 0x406,
// Seq2: Erase All (maximum supported freq: 120MHz)
/*
CMD: 0xC7 - Erase All chip, Single pad
*/
[8] = 0x04C7,
// Seq3: Read Status (maximum supported freq: 120MHz)
/*
CMD: 0x05 - Read Flag Status, single pad
READ: 0x01 - Read 1 bytes
*/
[12] = 0x1c010405,
// Seq4: Page Program (maximum supported freq: 120MHz)
/*
CMD: 0x02 - Page Program, Single pad
ADDR: 0x18 - 24bit address, Single pad
WRITE: 0x40 - Write 64 bytes at one pass, Single Pad
*/
[16] = 0x08180402, [17] = 0x2040,
// Seq5: Enable Quad mode
/*
CMD: 0x01 - Write Status Register
CMD: 0x40 - Treat write value as command, enable Quad mode
*/
[20] = 0x04400401,
// Seq7: Erase Sector
/*
CMD: 0x20 - Sector Erase, single pad
ADDR: 0x18 - 24 bit address, single pad
*/
[28] = 0x08180420,
},
};

View File

@@ -0,0 +1,113 @@
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// This is the QCB for the case that two MX25U3235F are connected to QuadSPI0A and QuadSPI0B ports.
// Work at continous read mode
const qspi_config_t qspi_config_block = {
.tag = kQspiConfigTag,
.version = {.version = kQspiVersionTag },
4.lengthInBytes = 512,
.sflash_A1_size = 0x400000, // 4MB
.sflash_B1_size = 0x400000, // 4MB
.sclk_freq = kQspiSerialClockFreq_Mid, // Mid frequency, in K82-256, it means 96MHz / 2 = 48MHz
.sflash_type = kQspiFlashPad_Quad, // SPI Flash devices work under quad-pad mode
.sflash_port = kQspiPort_EnableBothPorts, // Both QSPI0A and QSPI0B are enabled.
.busy_bit_offset = 0, // Busy offset is 0
.ddr_mode_enable = 0, // disable DDR mode
.dqs_enable = 0, // Disable DQS feature
.parallel_mode_enable = 0, // QuadSPI module work under serial mode
.pagesize = 256, // Page Size : 256 bytes
.sectorsize = 0x1000, // Sector Size: 4KB
.device_mode_config_en = 1, // configure quad mode for spi flash
.device_cmd = 0x40, // Enable quad mode via setting the bit6 in status register to 1
.write_cmd_ipcr = 0x05000000U, // IPCR indicating the seqid for Quad Mode Enable (5<<24)
.ips_command_second_divider = 3, // Set second divider for QSPI serial clock to 3
.look_up_table =
{
// Seq0 : Quad Read (maximum supported freq: 104MHz)
/*
CMD: 0xEB - Quad Read, Single pad
ADDR: 0x18 - 24bit address, Quad pads
MODE: 0xA5 - Continuous read mode, Quad Pads
DUMMY: 0x04 - 4 clock cycles, Quad pads
READ: 0x80 - Read 128 bytes, Quad pads
JUMP_ON_CS: 1
*/
[0] = 0x0A1804EB, [1] = 0x0E04012A5, [2] = 0x24011E80,
// Seq1: Write Enable (maximum supported freq: 104MHz)
/*
CMD: 0x06 - Write Enable, Single pad
*/
[4] = 0x406,
// Seq2: Erase All (maximum supported freq: 104MHz)
/*
CMD: 0x60 - Erase All chip, Single pad
*/
[8] = 0x460,
// Seq3: Read Status (maximum supported freq: 104MHz)
/*
CMD: 0x05 - Read Status, single pad
READ: 0x01 - Read 1 byte
*/
[12] = 0x1c010405,
// Seq4: 4 I/O Page Program (maximum supported freq: 104MHz)
/*
CMD: 0x38 - 4 I/O Page Program, Single pad
ADDR: 0x18 - 24bit address, Quad pads
WRITE: 0x40 - Write 64 bytes at one pass, Quad pads
(0x40 is ignored, as it will be overwritten by page size)
*/
[16] = 0x0A180438, [17] = 0x2240,
// Seq5: Write status register to enable quad mode
/*
CMD: 0x01 - Write Status Register, single pad
WRITE: 0x01 - Write 1 byte of data, single pad
*/
[20] = 0x20010401,
// Seq7: Erase Sector
/*
CMD: 0x20 - Sector Erase, single pad
ADDR: 0x18 - 24 bit address, single pad
*/
[28] = 0x08180420,
// Seq8: Dummy
/*
CMD: 0xFF - Dummy command, used to force SPI flash to exit continuous read mode.
*/
[32] = 0x04FF,
},
};

View File

@@ -0,0 +1,113 @@
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// This is the QCB for the case that two MX25U3235F are connected to QuadSPI0A and QuadSPI0B ports.
// Work under parallel mode
const qspi_config_t qspi_config_block = {
.tag = kQspiConfigTag,
.version = {.version = kQspiVersionTag },
.lengthInBytes = 512,
.sflash_A1_size = 0x400000, // 4MB
.sflash_B1_size = 0x400000, // 4MB
.sclk_freq = kQspiSerialClockFreq_High, // High frequency
.sflash_type = kQspiFlashPad_Quad, // SPI Flash devices work under quad-pad mode
.sflash_port = kQspiPort_EnableBothPorts, // Both QSPI0A and QSPI0B are enabled.
.busy_bit_offset = 0, // Busy offset is 0
.ddr_mode_enable = 0, // disable DDR mode
.dqs_enable = 0, // Disable DQS feature
.parallel_mode_enable = 1, // QuadSPI module work under parallel mode
.pagesize = 512, // Page Size : 256 *2 = 512 bytes
.sectorsize = 0x2000, // Sector Size: 4KB * 2 = 8KB
.device_mode_config_en = 1, // configure quad mode for spi flash
.device_cmd = 0x40, // Enable quad mode
.write_cmd_ipcr = 0x05000000U, // IPCR indicating enable seqid (5<<24)
.ips_command_second_divider = 3, // Set second divider for QSPI serial clock to 3
.look_up_table =
{
// Seq0 : Quad Read (maximum supported freq: 104MHz)
/*
CMD: 0xEB - Quad Read, Single pad
ADDR: 0x18 - 24bit address, Quad pads
DUMMY: 0x06 - 6 clock cycles, Quad pads
READ: 0x80 - Read 128 bytes, Quad pads
JUMP_ON_CS: 0
*/
[0] = 0x0A1804EB, [1] = 0x1E800E06, [2] = 0x2400,
// Seq1: Write Enable (maximum supported freq: 104MHz)
/*
CMD: 0x06 - Write Enable, Single pad
*/
[4] = 0x406,
// Seq2: Erase All (maximum supported freq: 104MHz)
/*
CMD: 0x60 - Erase All chip, Single pad
*/
[8] = 0x460,
// Seq3: Read Status (maximum supported freq: 104MHz)
/*
CMD: 0x05 - Read Status, single pad
READ: 0x01 - Read 1 byte
*/
[12] = 0x1c010405,
// Seq4: Page Program (maximum supported freq: 104MHz)
/*
CMD: 0x02 - Page Program, Single pad
ADDR: 0x18 - 24bit address, Single pad
WRITE: 0x40 - Write 64 bytes at one pass, Single pad
(0x40 is ignored, as it will be overwritten by page size)
*/
[16] = 0x08180402, [17] = 0x2040,
// Seq5: Write status register to enable quad mode
/*
CMD: 0x01 - Write Status Register, single pad
WRITE: 0x01 - Write 1 byte of data, single pad
*/
[20] = 0x20010401,
// Seq7: Erase Sector
/*
CMD: 0x20 - Sector Erase, single pad
ADDR: 0x18 - 24 bit address, single pad
*/
[28] = 0x08180420,
// Seq8: Dummy
/*
CMD: 0 - Dummy command, used to force SPI flash to exit continuous read mode.
unecessary here because the continous read mode isn't enabled.
*/
[32] = 0,
},
};

View File

@@ -0,0 +1,104 @@
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
const qspi_config_t qspi_config_block = {
.tag = kQspiConfigTag,
.version = {.version = kQspiVersionTag },
.lengthInBytes = 512,
.sflash_A1_size = 0x2000000, // 32MB
.sclk_freq = kQspiSerialClockFreq_High, // High frequency, 96MHz/4 = 24MHz
.sflash_type = kQspiFlashPad_Quad, // SPI Flash devices work under quad-pad mode
.sflash_port = kQspiPort_EnablePortA, // Only QSPI0A is enabled.
.busy_bit_offset = 0, // Busy offset is 0, polarity: 1 means busy
.ddr_mode_enable = 1, // Enable DDR mode
.data_hold_time = 1, // Data aligned with 2x serial flash half clock
.ddrsmp = 0,
.dqs_enable = 0, // Disable DQS feature
.dqs_loopback = 0,
.pagesize = 256, // Page Size : 256 bytes
.sectorsize = 0x1000, // Sector Size: 4KB
.ips_command_second_divider = 0,
.device_mode_config_en = 1, // Configure the device to 4-byte address mode
.device_cmd = 0, // Not needed.
.write_cmd_ipcr = 5UL << 24, // Seq5 for setting address type to 4 bytes
.look_up_table =
{
// Seq0 : Quad Read (maximum supported freq: 108MHz)
/*
CMD_DDR: 0xED - Quad Read, Single pad
ADDR_DDR: 0x20 - 32bit address, Quad pads
DUMMY: 0x08 - 8 dummy cycles, Quad pads
READ_DDR: 0x80 - Read 128 bytes, Quad pads
JUMP_ON_CS: 0
*/
[0] = 0x2A2004ED, [1] = 0x3A800E08, [2] = 0x2400,
// Seq1: Write Enable (maximum supported freq: 108MHz)
/*
CMD: 0x06 - Write Enable, Single pad
*/
[4] = 0x406,
// Seq2: Erase All (maximum supported freq: 108MHz)
/*
CMD: 0xC7 - Erase All chip, Single pad
*/
[8] = 0x04C7,
// Seq3: Read Status (maximum supported freq: 108MHz)
/*
CMD: 0x05 - Read Status, single pad
READ: 0x01 - Read 1 bytes
*/
[12] = 0x1c010405,
// Seq4: Page Program (maximum supported freq: 108MHz)
/*
CMD: 0x02 - Page Program, Single pad
ADDR: 0x20 - 32bit address, Single pad
WRITE: 0x40 - Write 64 bytes at one pass, Single Pad
*/
[16] = 0x08200402, [17] = 0x2040,
// Seq5: Enter 4-byte address mode
/*
CMD: 0xB7 - Enter 4-byte address mode
*/
[20] = 0x04B7,
// Seq7: Erase Sector
/*
CMD: 0x20 - Sector Erase, single pad
ADDR: 0x20 - 32 bit address, single pad
*/
[28] = 0x08200420,
},
};

View File

@@ -0,0 +1,112 @@
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// This is the QCB for the case that one S25FL129P is connected to QuadSPI0A port.
const qspi_config_t qspi_config_block = {
.tag = kQspiConfigTag,
.version = {.version = kQspiVersionTag },
.lengthInBytes = 512,
.sflash_A1_size = 0x1000000, // 16MB
.sclk_freq = kQspiSerialClockFreq_Mid, // Mid frequency 96MHz / 2 = 48MHz
.sflash_type = kQspiFlashPad_Quad, // SPI Flash devices work under quad-pad mode
.sflash_port = kQspiPort_EnablePortA, // Only QuadSPI0A is enabled.
.busy_bit_offset = 0, // Busy offset is 0
.ddr_mode_enable = 0, // disable DDR mode
.dqs_enable = 0, // Disable DQS feature
.parallel_mode_enable = 0, // QuadSPI module work under serial mode
.pagesize = 256, // Page Size : 256 bytes
.sectorsize = 0x1000, // Sector Size: 8KB
.device_mode_config_en = 1, // configure quad mode for spi flash
.device_cmd = 0x0200, // Enable quad mode
.write_cmd_ipcr = 0x05000000U, // IPCR indicating enable seqid (5<<24)
.ips_command_second_divider = 3, // Set second divider for QSPI serial clock to 3
.look_up_table =
{
// Seq0 : Quad Read (maximum supported freq: 80MHz)
/*
CMD: 0xEB - Quad Read, Single pad
ADDR: 0x18 - 24bit address, Quad pads
MODE: 0xB5 - Non continuous read mode
DUMMY: 0x04 - 4 clock cycles, Quad pads
READ: 0x80 - Read 128 bytes, Quad pads
JUMP_ON_CS: 0 - Jump to address phase
*/
[0] = 0x0A1804EB, [1] = 0x1E800E06, [2] = 0x2400,
// Seq1: Write Enable (maximum supported freq: 80MHz)
/*
CMD: 0x06 - Write Enable, Single pad
*/
[4] = 0x406,
// Seq2: Erase All (maximum supported freq: 80MHz)
/*
CMD: 0x60 - Erase All chip, Single pad
*/
[8] = 0x460,
// Seq3: Read Status (maximum supported freq: 80MHz)
/*
CMD: 0x05 - Read Status, single pad
READ: 0x01 - Read 1 byte
*/
[12] = 0x1c010405,
// Seq4: Quad Page Program (maximum supported freq: 80MHz)
/*
CMD: 0x32 - Quad Page Program, Single pad
ADDR: 0x18 - 24bit address, Single pad
WRITE: 0x40 - Write 64 bytes at one pass, Quad pads
(0x40 is ignored, as it will be overwritten by page size)
*/
[16] = 0x08180432, [17] = 0x2040,
// Seq5: Write status register to enable quad mode
/*
CMD: 0x01 - Write Status Register, single pad
WRITE: 0x02 - Write 2 bytes of data, single pad
*/
[20] = 0x20010402,
// Seq7: Erase Sector
/*
CMD: 0xD8 - Sector Erase, single pad
ADDR: 0x18 - 24 bit address, single pad
*/
[28] = 0x081804D8,
// Seq8: Dummy
/*
CMD: 0 - Dummy command, single pad
Not necessary, as the SPI flash device isn't work at continuous read mode.
*/
[32] = 0,
},
};

View File

@@ -0,0 +1,98 @@
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// This is the QCB for the case that one S26KS128S is connected to QuadSPI0A port.
const qspi_config_t qspi_config_block = {
.tag = kQspiConfigTag,
.version = {.version = kQspiVersionTag },
.lengthInBytes = 512,
.word_addressable = 1,
.data_hold_time = 1,
.sflash_A1_size = 0x1000000, // 16MB
.sclk_freq = kQspiSerialClockFreq_High, // High frequency, in DDR mode, it means 96MHz/4 = 24MHz
.busy_bit_offset =
0x0001000F, // bit 15 represent busy bit, polarity of this bit is 0, namely busy bit is 0 if device is busy.
.sflash_type = kQspiFlashPad_Octal, // Serial Nor Flash works under octal-pad mode
.sflash_port = kQspiPort_EnablePortA, // Only PortA are enabled
.ddr_mode_enable = 1,
.dqs_enable = 1, // DQS function is enabled.
.look_up_table =
{
// Seq0 : Read
[0] = 0x2B1847A0, // Read command with continuous burst type
[1] = 0x0F104F10, // 16bit column address, 16 dummy cycles
[2] = 0x03003B80, // Read 128bytes and STOP.
// Seq1: Write Enable
[4] = 0x2B184700, [5] = 0x47004F10, [6] = 0x4755,
// Seq2: Erase All
[8] = 0x2B184700, [9] = 0x47004F10, [10] = 0x4710,
// Seq3: Read Status
[12] = 0x2B1847A0, // Read command with continuous burst type
[13] = 0x0F104F10, // 16bit column address, 16 dummy cycles
[14] = 0x3B02, // Read 2bytes and stop.
// Seq4: 8 I/O Page Program
[16] = 0x2B184700, [17] = 0x3F804F10,
// Seq6: Pre Erase
[24] = 0x2B184700, [25] = 0x47004F10, [26] = 0x4780,
// Seq7: Erase Sector
[28] = 0x2B184700, [29] = 0x47004F10, [30] = 0x24004730,
// Seq9: PreWriteEnable
[36] = 0x2B184700, [37] = 0x47004F10, [38] = 0x47AA,
// Seq10: PrePageProgram
[40] = 0x2B184700, [41] = 0x47004F10, [42] = 0x47A0,
// Seq11: PreReadStatus
[44] = 0x2B184700, [45] = 0x47004F10, [46] = 0x4770,
},
.column_address_space = 3,
.differential_clock_pin_enable = 1, // Differential clock is enabled.
.dqs_latency_enable = 1, // External DQS input signal is used.
.dqs_fa_delay_chain_sel = 0x10,
.pagesize = 512, // Page Size : 512 bytes
.sectorsize = 0x40000, // Sector Size: 256KB
.ips_command_second_divider = 4, // Set second divider for QSPI serial clock to 16
.need_multi_phases = 1, // multiple phases are needed for Erase, Program, etc.
.is_spansion_hyperflash = 1, // This device belongs to HyperFlash family.
.pre_read_status_cmd_address_offset = 0x555 << 1,
.pre_unlock_cmd_address_offset = 0x555 << 1,
.unlock_cmd_address_offset = 0x2AA << 1,
.pre_program_cmd_address_offset = 0x555 << 1,
.pre_erase_cmd_address_offset = 0x555 << 1,
.erase_all_cmd_address_offset = 0x555 << 1,
};

View File

@@ -0,0 +1,292 @@
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
/*!
* @addtogroup qspi_driver
* @{
*/
////////////////////////////////////////////////////////////////////////////////
// Definitions
////////////////////////////////////////////////////////////////////////////////
#define QSPI_LUT_MAX_ENTRIES 64
#define QSPI_PRE_CMD_CNT 4 //!< the max number of pre commands
#define QSPI_FEATURE_ENABLE 1
#define QSPI_VERSION_NAME 'Q'
//! @brief Build a 32-bit code from four character values.
//!
//! The resulting value is built with a byte order such that the string
//! being readable in expected order when viewed in a hex editor, if the value
//! is treated as a 32-bit little endian value.
#define FOUR_CHAR_CODE(a, b, c, d) (((d) << 24) | ((c) << 16) | ((b) << 8) | ((a)))
enum __qspi_config_block_tags
{
//! @brief Tag value used to validate the qspi config block.
kQspiConfigTag = FOUR_CHAR_CODE('k', 'q', 'c', 'f'),
kQspiVersionTag = FOUR_CHAR_CODE(0, 1, 1, 'Q'),
};
//! @brief QSPI Flash mode options
typedef enum _qspiflash_mode_option
{
kQspiFlashMode_Serial = 0, //!< Serial mode
kQspiFlashMode_Parallel = 1 //!< Parallel mode
} qspiflash_mode_option_t;
//! @brief External spi flash pad definition
typedef enum _qspiflash_pad
{
kQspiFlashPad_Single = 0, //!< Single-pad spi flash
kQspiFlashPad_Dual = 1, //!< Dual-pad spi flash
kQspiFlashPad_Quad = 2, //!< Quad-pad spi flash
kQspiFlashPad_Octal = 3 //!< Octal-pad spi flash
} qspiflash_pad_t;
//! @brief QSPI Serial Clock Frequency options
typedef enum _qspi_serial_clock_freq
{
kQspiSerialClockFreq_Low = 0, //!< QuadSPI module works at low frequency
kQspiSerialClockFreq_Mid = 1, //!< QuadSPI module works at mid frequency
kQspiSerialClockFreq_High = 2 //!< QuadSPI module works at high frequency
} qspi_serial_clock_freq_t;
//! @brief Port Enablement Option
typedef enum _qspi_port_enable
{
kQspiPort_EnablePortA = 0U, //!< Only PORTA is enabled
kQspiPort_EnableBothPorts = 1, //!< Enable Both PoartA and PortB
} qspi_port_enable_t;
//! @brief Definition for AHB data tranfer size
typedef enum _qspi_ahb_data_transfer_size
{
kQspiAHBDataTransferSize_64Bytes = 8U, //!< AHB data transfer size is 64bytes
kQspiAHBDataTransferSize_256Bytes = 32U, //!< AHB data transfer size is 256bytes
} qspi_ahb_data_transfer_size_t;
typedef union BootloaderVersion
{
struct
{
uint32_t bugfix : 8; //!< bugfix version [7:0]
uint32_t minor : 8; //!< minor version [15:8]
uint32_t major : 8; //!< major version [23:16]
uint32_t name : 8; //!< name [31:24]
} B;
uint32_t version; //!< combined version numbers
} standard_version_t;
//! @brief QuadSPI Config block structure
#pragma pack(1)
typedef struct __sflash_configuration_parameter
{
uint32_t tag; //!< Set to magic number of 'kqcf'
standard_version_t version; //!< version of config struct
uint32_t lengthInBytes; //!< Total length of strcut in bytes
uint32_t dqs_loopback; //!< Sets DQS LoopBack Mode to enable Dummy Pad MCR[24]
uint32_t data_hold_time; //!< Serial Flash data hold time, valid value: 0/1/2
uint32_t reserved0[2]; //!< Reserved for K80
uint32_t device_mode_config_en; //!< Determine if it is required to config working mode of external spi flash.
uint32_t device_cmd; //!< Command to be tranferred to device
uint32_t write_cmd_ipcr; //!< IPCR value of Write command
uint32_t word_addressable; //!< Determine if the serial flash is word addressable
uint32_t cs_hold_time; //!< CS hold time in terms of serial clock.(for example 1 serial clock cyle)
uint32_t cs_setup_time; //!< CS setup time in terms of serial clock.(for example 1 serial clock cyle)
uint32_t sflash_A1_size; //!< Size of flash connected on QSPI0A Ports and QSPI0A_SS0, in terms of Bytes
uint32_t sflash_A2_size; //!< Size of flash connected on QSPI0A Ports and QSPI0A_SS1, in terms of Bytes
uint32_t sflash_B1_size; //!< Size of flash connected on QSPI0B Ports and QSPI0B_SS0, in terms of Bytes
uint32_t sflash_B2_size; //!< Size of flash connected on QSPI0B Ports and QSPI0B_SS1, in terms of Bytes
uint32_t sclk_freq; //!< In 00 - 24MHz, 01 - 48MHz, 10 - 96MHz,(only for SDR Mode)
uint32_t busy_bit_offset; //!< Flash device busy bit offset in status register
uint32_t sflash_type; //!< SPI flash type: 0-Single,1--Dual 2--Quad, 3-- Octal
uint32_t sflash_port; //!< 0--Only Port-A, 1--Both PortA and PortB
uint32_t ddr_mode_enable; //!< Enable DDR mode if set to TRUE
uint32_t dqs_enable; //!< Enable DQS mode if set to TRUE.
uint32_t parallel_mode_enable; //!< Enable Individual or parrallel mode.
uint32_t portA_cs1; //!< Enable PORTA CS1
uint32_t portB_cs1; //!< Enable PORTB CS1
uint32_t fsphs; //!< Full speed delay selection for SDR instructions
uint32_t fsdly; //!< Full speed phase selection for SDR instructions
uint32_t ddrsmp; //!< Select the sampling point for incomming data when serial flash is in DDR mdoe
uint32_t
look_up_table[QSPI_LUT_MAX_ENTRIES]; //!< Set of seq to perform optimum read on SFLASH as as per vendor SFLASH
uint32_t column_address_space; //!< The width of the column address
uint32_t config_cmd_en; //!< Enable config commands
uint32_t config_cmds[QSPI_PRE_CMD_CNT]; //!< Config comands, used to configure nor flash
uint32_t config_cmds_args[QSPI_PRE_CMD_CNT]; //!< Config commands arguments
uint32_t differential_clock_pin_enable; //!< Differential flash clock pins enable
uint32_t flash_CK2_clock_pin_enable; //!< Flash CK2 clock pin enable
uint32_t dqs_inverse_sel; //!< Select clock source for internal DQS generation
uint32_t dqs_latency_enable; //!< DQS Latency Enable
uint32_t dqs_loopback_internal; //!< 0: dqs loopback from pad, 1: dqs loopback internally
uint32_t dqs_phase_sel; //!< dqs phase sel
uint32_t dqs_fa_delay_chain_sel; //!< dqs fa delay chain selection
uint32_t dqs_fb_delay_chain_sel; //!< dqs fb delay chain selection
uint32_t reserved1[2]; //!< reserved
uint32_t pagesize; //!< page Size of Serial Flash
uint32_t sectorsize; //!< sector Size of Serial Flash
uint32_t timeout_milliseconds; //!< timeout in terms of millisecond in case of infinite loop in qspi driver
//!< 0 represents disabling timeout check. This value is valid since version 1.1.0
uint32_t ips_command_second_divider; //!< second devider for all IPS commands.
uint32_t need_multi_phases; //!< Determine if multiple hases command are needed.
uint32_t is_spansion_hyperflash; //!< Determine if connected spi flash device belongs to Hyperflash family
uint32_t pre_read_status_cmd_address_offset; //!< Address for PreReadStatus command
uint32_t pre_unlock_cmd_address_offset; //!< Address for PreWriteEnable command
uint32_t unlock_cmd_address_offset; //!< Address for WriteEnable command
uint32_t pre_program_cmd_address_offset; //!< Address for PreProgram command
uint32_t pre_erase_cmd_address_offset; //!< Address for PreErase command
uint32_t erase_all_cmd_address_offset; //!< Address for EraseAll command
uint32_t reserved2[3]; //!< Reserved words to make sure qspi config block is page-aligend.
} qspi_config_t, *SFLASH_CONFIGURATION_PARAM_PTR;
#pragma pack()
int main(void)
{
const qspi_config_t qspi_config_block = {
.tag = kQspiConfigTag, // Fixed value, do not change
.version = {.version = kQspiVersionTag }, // Fixed value, do not change
.lengthInBytes = 512, // Fixed value, do not change
.sflash_A1_size = 0x400000, // 4MB
.sflash_B1_size = 0x400000, // 4MB
.sclk_freq = kQspiSerialClockFreq_High, // High frequency, in K82-256, it means 96MHz/1 = 96MHz
.sflash_type = kQspiFlashPad_Quad, // SPI Flash devices work under quad-pad mode
.sflash_port = kQspiPort_EnableBothPorts, // Both QSPI0A and QSPI0B are enabled.
.busy_bit_offset = 0, // Busy offset is 0
.ddr_mode_enable = 0, // disable DDR mode
.dqs_enable = 0, // Disable DQS feature
.parallel_mode_enable = 0, // QuadSPI module work under serial mode
.pagesize = 256, // Page Size : 256 bytes
.sectorsize = 0x1000, // Sector Size: 4KB
.device_mode_config_en = 1, // Enable quad mode for SPI flash
.device_cmd = 0x40, // Enable quad mode via set bit 6 in status register to 1
.write_cmd_ipcr = 0x05000000U, // IPCR indicating seq id for Quad Mode Enable (5<<24)
.ips_command_second_divider = 3, // Set second divider for QSPI serial clock to 3
.look_up_table =
{
// Seq0 : Quad Read (maximum supported freq: 104MHz)
/*
CMD: 0xEB - Quad Read, Single pad
ADDR: 0x18 - 24bit address, Quad pads
DUMMY: 0x06 - 6 clock cycles, Quad pads
READ: 0x80 - Read 128 bytes, Quad pads
JUMP_ON_CS: 0
*/
[0] = 0x0A1804EB, [1] = 0x1E800E06, [2] = 0x2400,
// Seq1: Write Enable (maximum supported freq: 104MHz)
/*
CMD: 0x06 - Write Enable, Single pad
*/
[4] = 0x406,
// Seq2: Erase All (maximum supported freq: 104MHz)
/*
CMD: 0x60 - Erase All chip, Single pad
*/
[8] = 0x460,
// Seq3: Read Status (maximum supported freq: 104MHz)
/*
CMD: 0x05 - Read Status, single pad
READ: 0x01 - Read 1 byte
*/
[12] = 0x1c010405,
// Seq4: 4 I/O Page Program (maximum supported freq: 104MHz)
/*
CMD: 0x38 - 4 I/O Page Program, Single pad
ADDR: 0x18 - 24bit address, Quad pad
WRITE: 0x40 - Write 64 bytes at one pass, Quad pad
*/
[16] = 0x0A180438, [17] = 0x2240,
// Seq5: Write status register to enable quad mode
/*
CMD: 0x01 - Write Status Register, single pad
WRITE: 0x01 - Write 1 byte of data, single pad
*/
[20] = 0x20010401,
// Seq7: Erase Sector
/*
CMD: 0x20 - Sector Erase, single pad
ADDR: 0x18 - 24 bit address, single pad
*/
[28] = 0x08180420,
// Seq8: Dummy
/*
CMD: 0 - Dummy command, used to force SPI flash to exit continuous read mode.
unnecessary here because the continuous read mode is not enabled.
*/
[32] = 0,
},
};
// Generate QSPI config block
const char *filePath = "qspi_config_block.bin";
FILE *fp = fopen(filePath, "wb+");
if (fp == NULL)
{
printf("Cannot open/create %s\n", filePath);
}
else
{
size_t write_size = sizeof(qspi_config_block);
size_t actual_write_size;
actual_write_size = fwrite(&qspi_config_block, 1, write_size, fp);
fclose(fp);
if (actual_write_size == write_size)
{
printf("Generated %s successfully.\n\n", filePath);
}
else
{
printf("Failed to generate %s \n\n", filePath);
}
}
system("pause");
return 0;
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<workspace>
<batchBuild><batchDefinition><name>all</name><member><project>buspal_tower</project><configuration>Release</configuration></member><member><project>buspal_tower</project><configuration>Debug</configuration></member></batchDefinition><batchDefinition><name>Release</name><member><project>buspal_tower</project><configuration>Release</configuration></member></batchDefinition><batchDefinition><name>Debug</name><member><project>buspal_tower</project><configuration>Debug</configuration></member></batchDefinition></batchBuild>
<project><path>$WS_DIR$/iar/buspal_tower/buspal_tower.ewp</path></project></workspace>

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,143 @@
/*
* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__BUS_PAL_HARDWARE_H__)
#define __BUS_PAL_HARDWARE_H__
#include "dspi/fsl_dspi.h"
#include "i2c/fsl_i2c.h"
#include "bl_peripheral.h"
/*!
* @brief user config from host for i2c
*/
typedef struct _i2c_user_config
{
uint8_t slaveAddress;
uint16_t baudRate_kbps;
} i2c_user_config_t;
/*!
* @brief user config from host for spi
*/
typedef struct _dspi_user_config
{
dspi_clock_polarity_t polarity; /*!< Clock polarity */
dspi_clock_phase_t phase; /*!< Clock phase */
dspi_shift_direction_t direction; /*!< MSB or LSB */
uint32_t baudRate_Bps; /*!< Baud Rate for SPI in Hz */
uint32_t clock_Hz;
} dspi_user_config_t;
/*!
* @brief hardware initialization
*/
void init_hardware(void);
//! @brief sending host bytes command process
void write_bytes_to_host(uint8_t *src, uint32_t length);
//! @brief receiving host start command process
void host_start_command_rx(uint8_t *dest, uint32_t length);
//! @brief receiving host stop command process
void host_stop_command_rx(void);
//! @brief receiving host get bytes command process
uint32_t get_bytes_received_from_host(void);
//! @brief spi config speed process
void configure_spi_speed(uint32_t speedkhz);
//! @brief spi config settings process
void configure_spi_settings(dspi_clock_polarity_t polarity, dspi_clock_phase_t phase, dspi_shift_direction_t direction);
//! @brief i2c config address process
void configure_i2c_address(uint8_t address);
//! @brief i2c config speed process
void configure_i2c_speed(uint32_t speedkhz);
//! @brief spi send data process
void send_spi_data(uint8_t *src, uint32_t writeLength);
//! @brief spi receiving data process
void receive_spi_data(uint8_t *dest, uint32_t readLength);
//! @brief flexCAN config speed process
void configure_can_speed(uint32_t speed);
//! @brief flexCAN config txid
void configure_can_txid(uint32_t txid);
//! @brief flexCAN config rxid
void configure_can_rxid(uint32_t rxid);
//! @brief flexCAN sending data process
void send_can_data(uint8_t *src, uint32_t writeLength);
//! @brief flexCAN receiving data process
void receive_can_data(uint8_t data, uint32_t instance);
//! @brief flexCAN read data process
void read_can_data(uint8_t *dest, uint32_t readLength);
//! @brief flexCAN reset buffer process
void reset_can_buffer(void);
//! @brief i2c sending data process
status_t send_i2c_data(uint8_t *src, uint32_t writeLength);
//! @brief i2c receiving data process
status_t receive_i2c_data(uint8_t *dest, uint32_t readLength);
//! @brief GPIO config processing
void configure_gpio(uint8_t port, uint8_t pinNum, uint8_t muxVal);
//! @brief GPIO set up function
void set_gpio(uint8_t port, uint8_t pinNum, uint8_t level);
//! @brief fpga clock set function
void set_fpga_clock(uint32_t clock);
bool scuart_poll_for_activity();
bool usb_hid_poll_for_activity(const peripheral_descriptor_t *self);
status_t usb_hid_packet_init(const peripheral_descriptor_t *self);
status_t usb_hid_packet_read(const peripheral_descriptor_t *self,
uint8_t **packet,
uint32_t *packetLength,
packet_type_t packetType);
status_t usb_hid_packet_write(const peripheral_descriptor_t *self,
const uint8_t *packet,
uint32_t byteCount,
packet_type_t packetType);
#endif // __BUS_PAL_HARDWARE_H__
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,132 @@
/*
* Copyright (c) 2013, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _command_h
#define _command_h
//! @addtogroup command
//! @{
////////////////////////////////////////////////////////////////////////////////
// Definitions
////////////////////////////////////////////////////////////////////////////////
//! @brief Command state machine states.
enum _command_state
{
kCommandState_CommandPhase,
kCommandState_DataPhase,
kCommandState_DataPhaseRead,
kCommandState_DataPhaseWrite
};
typedef enum _buspal_state
{
kBuspal_Idle,
kBuspal_I2c,
kBuspal_Spi,
kBuspal_FlexCAN,
kBuspal_MsCAN
} buspal_state_t;
typedef struct ConfigI2cCmdPacket
{
command_packet_t commandPacket; //!< header
uint32_t address; //!< Parameter 0: i2c slave address.
uint32_t speed; //!< Parameter 1: i2c speed in kHz
} config_i2c_cmd_packet_t;
//! @brief Format of command handler entry.
typedef struct CommandHandlerEntry
{
void (*handleCommand)(uint8_t *packet, uint32_t packetLength);
status_t (*handleData)(bool *hasMoreData);
} command_handler_entry_t;
//! @brief Command processor data format.
typedef struct CommandProcessorData
{
int32_t state; //!< Current state machine state
uint8_t *packet; //!< Pointer to packet in process
uint32_t packetLength; //!< Length of packet in process
struct DataPhase
{
uint8_t *data; //!< Data for data phase
uint32_t count; //!< Remaining count to produce/consume
uint32_t address; //!< Address for data phase
uint32_t dataBytesAvailable; //!< Number of bytes available at data pointer
uint8_t commandTag; //!< Tag of command running data phase
uint8_t option; //!< option for special command
} dataPhase;
const command_handler_entry_t *handlerEntry; //! Pointer to handler table entry for packet in process
} command_processor_data_t;
//! @brief Interface to command processor operations.
typedef struct CommandInterface
{
status_t (*init)(void);
status_t (*pump)(void);
const command_handler_entry_t *handlerTable;
command_processor_data_t *stateData;
} command_interface_t;
////////////////////////////////////////////////////////////////////////////////
// Externals
////////////////////////////////////////////////////////////////////////////////
//! @brief Default command interface.
extern command_interface_t g_commandInterface;
////////////////////////////////////////////////////////////////////////////////
// Prototypes
////////////////////////////////////////////////////////////////////////////////
#if defined(__cplusplus)
extern "C" {
#endif // __cplusplus
//! @brief Initialize the command processor component.
status_t bootloader_command_init(void);
//! @brief Pump the command state machine.
//!
//! Executes one command or data phase transaction.
status_t bootloader_command_pump(void);
#if defined(__cplusplus)
}
#endif // __cplusplus
//! @}
#endif // _command.h_
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<workspace>
<batchBuild><batchDefinition><name>all</name><member><project>buspal_freedom</project><configuration>Release</configuration></member><member><project>buspal_freedom</project><configuration>Debug</configuration></member></batchDefinition><batchDefinition><name>Release</name><member><project>buspal_freedom</project><configuration>Release</configuration></member></batchDefinition><batchDefinition><name>Debug</name><member><project>buspal_freedom</project><configuration>Debug</configuration></member></batchDefinition></batchBuild>
<project><path>$WS_DIR$/iar/buspal_freedom/buspal_freedom.ewp</path></project></workspace>

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,110 @@
/*
* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__BUS_PAL_HARDWARE_H__)
#define __BUS_PAL_HARDWARE_H__
#include "spi/fsl_spi.h"
#include "i2c/fsl_i2c.h"
/*!
* @brief user config from host for i2c
*/
typedef struct _i2c_user_config
{
uint8_t slaveAddress;
uint16_t baudRate_kbps;
} i2c_user_config_t;
/*!
* @brief user config from host for spi
*/
typedef struct _spi_user_config
{
spi_clock_polarity_t polarity; /*!< Clock polarity */
spi_clock_phase_t phase; /*!< Clock phase */
spi_shift_direction_t direction; /*!< MSB or LSB */
uint32_t baudRate_Bps; /*!< Baud Rate for SPI in Hz */
uint32_t clock_Hz;
} spi_user_config_t;
/*!
* @brief hardware initialization
*/
void init_hardware(void);
//! @brief sending host bytes command process
void write_bytes_to_host(uint8_t *src, uint32_t length);
//! @brief receiving host start command process
void host_start_command_rx(uint8_t *dest, uint32_t length);
//! @brief receiving host stop command process
void host_stop_command_rx(void);
//! @brief receiving host get bytes command process
uint32_t get_bytes_received_from_host(void);
//! @brief spi config speed process
void configure_spi_speed(uint32_t speedkhz);
//! @brief spi config settings process
void configure_spi_settings(spi_clock_polarity_t polarity, spi_clock_phase_t phase, spi_shift_direction_t direction);
//! @brief i2c config address process
void configure_i2c_address(uint8_t address);
//! @brief i2c config speed process
void configure_i2c_speed(uint32_t speedkhz);
//! @brief spi send data process
void send_spi_data(uint8_t *src, uint32_t writeLength);
//! @brief spi receiving data process
void receive_spi_data(uint8_t *dest, uint32_t readLength);
//! @brief i2c sending data process
status_t send_i2c_data(uint8_t *src, uint32_t writeLength);
//! @brief i2c receiving data process
status_t receive_i2c_data(uint8_t *dest, uint32_t readLength);
//! @brief GPIO config processing
void configure_gpio(uint8_t port, uint8_t pinNum, uint8_t muxVal);
//! @brief GPIO set up function
void set_gpio(uint8_t port, uint8_t pinNum, uint8_t level);
//! @brief fpga clock set function
void set_fpga_clock(uint32_t clock);
#endif // __BUS_PAL_HARDWARE_H__
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<workspace>
<batchBuild><batchDefinition><name>all</name><member><project>buspal_tower</project><configuration>Release</configuration></member><member><project>buspal_tower</project><configuration>Debug</configuration></member></batchDefinition><batchDefinition><name>Release</name><member><project>buspal_tower</project><configuration>Release</configuration></member></batchDefinition><batchDefinition><name>Debug</name><member><project>buspal_tower</project><configuration>Debug</configuration></member></batchDefinition></batchBuild>
<project><path>$WS_DIR$/iar/buspal_tower/buspal_tower.ewp</path></project></workspace>

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,131 @@
/*
* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__BUS_PAL_HARDWARE_H__)
#define __BUS_PAL_HARDWARE_H__
#include "dspi/fsl_dspi.h"
#include "i2c/fsl_i2c.h"
/*!
* @brief user config from host for i2c
*/
typedef struct _i2c_user_config
{
uint8_t slaveAddress;
uint16_t baudRate_kbps;
} i2c_user_config_t;
/*!
* @brief user config from host for spi
*/
typedef struct _dspi_user_config
{
dspi_clock_polarity_t polarity; /*!< Clock polarity */
dspi_clock_phase_t phase; /*!< Clock phase */
dspi_shift_direction_t direction; /*!< MSB or LSB */
uint32_t baudRate_Bps; /*!< Baud Rate for SPI in Hz */
uint32_t clock_Hz;
} dspi_user_config_t;
/*!
* @brief hardware initialization
*/
void init_hardware(void);
//! @brief sending host bytes command process
void write_bytes_to_host(uint8_t *src, uint32_t length);
//! @brief receiving host start command process
void host_start_command_rx(uint8_t *dest, uint32_t length);
//! @brief receiving host stop command process
void host_stop_command_rx(void);
//! @brief receiving host get bytes command process
uint32_t get_bytes_received_from_host(void);
//! @brief spi config speed process
void configure_spi_speed(uint32_t speedkhz);
//! @brief spi config settings process
void configure_spi_settings(dspi_clock_polarity_t polarity, dspi_clock_phase_t phase, dspi_shift_direction_t direction);
//! @brief i2c config address process
void configure_i2c_address(uint8_t address);
//! @brief i2c config speed process
void configure_i2c_speed(uint32_t speedkhz);
//! @brief spi send data process
void send_spi_data(uint8_t *src, uint32_t writeLength);
//! @brief spi receiving data process
void receive_spi_data(uint8_t *dest, uint32_t readLength);
//! @brief flexCAN config speed process
void configure_can_speed(uint32_t speed);
//! @brief flexCAN config txid
void configure_can_txid(uint32_t txid);
//! @brief flexCAN config rxid
void configure_can_rxid(uint32_t rxid);
//! @brief flexCAN sending data process
void send_can_data(uint8_t *src, uint32_t writeLength);
//! @brief flexCAN receiving data process
void receive_can_data(uint8_t data, uint32_t instance);
//! @brief flexCAN read data process
void read_can_data(uint8_t *dest, uint32_t readLength);
//! @brief flexCAN reset buffer process
void reset_can_buffer(void);
//! @brief i2c sending data process
status_t send_i2c_data(uint8_t *src, uint32_t writeLength);
//! @brief i2c receiving data process
status_t receive_i2c_data(uint8_t *dest, uint32_t readLength);
//! @brief GPIO config processing
void configure_gpio(uint8_t port, uint8_t pinNum, uint8_t muxVal);
//! @brief GPIO set up function
void set_gpio(uint8_t port, uint8_t pinNum, uint8_t level);
//! @brief fpga clock set function
void set_fpga_clock(uint32_t clock);
#endif // __BUS_PAL_HARDWARE_H__
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,41 @@
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*/
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
/*-Specials-*/
define symbol __ICFEDIT_intvec_start__ = 0x00000000;
/*-Memory Regions-*/
define symbol __ICFEDIT_region_ROM_start__ = 0x00000000;
define symbol __ICFEDIT_region_ROM_end__ = 0x0001ffff;
define symbol __ICFEDIT_region_RAM_start__ = 0x1ffff000;
define symbol __ICFEDIT_region_RAM_end__ = 0x1fffffff;
/*-Sizes-*/
define symbol __ICFEDIT_size_cstack__ = 0x800;
define symbol __ICFEDIT_size_heap__ = 0;
/**** End of ICF editor section. ###ICF###*/
define symbol __region_RAM2_start__ = 0x20000000;
define symbol __region_RAM2_end__ = 0x20002fff;
define symbol __FlashConfig_start__ = 0x00000400;
define symbol __FlashConfig_end__ = 0x0000040f;
define exported symbol __VECTOR_TABLE = __ICFEDIT_intvec_start__;
define exported symbol __VECTOR_RAM = __ICFEDIT_region_RAM_start__;
define symbol __VECTOR_TABLE_END = __FlashConfig_start__;
define memory mem with size = 4G;
define region FlashConfig_region = mem:[from __FlashConfig_start__ to __FlashConfig_end__];
define region ROM_region = mem:[from (__FlashConfig_end__+1) to __ICFEDIT_region_ROM_end__];
define region RAM_region = mem:[from (__ICFEDIT_region_RAM_start__+__VECTOR_TABLE_END) to __ICFEDIT_region_RAM_end__]
| mem:[from __region_RAM2_start__ to __region_RAM2_end__];
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
initialize by copy { readwrite, section .textrw };
do not initialize { section .noinit };
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in FlashConfig_region { section FlashConfig };
place in ROM_region { readonly };
place in RAM_region { readwrite, block CSTACK, block HEAP };

View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 2014, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __BUSPAL_CONFIG_H__
#define __BUSPAL_CONFIG_H__
////////////////////////////////////////////////////////////////////////////////
// Definitions
////////////////////////////////////////////////////////////////////////////////
//
// Bootloader configuration options
//
//! @name Peripheral configuration macros
//@{
#if !defined(BL_CONFIG_UART)
#define BL_CONFIG_UART (1)
#endif
#if !defined(BL_CONFIG_SCUART)
#define BL_CONFIG_SCUART (1)
#endif
#if !defined(BL_CONFIG_LPUART)
#define BL_CONFIG_LPUART (1)
#endif
#if !defined(BL_CONFIG_CAN)
#define BL_CONFIG_CAN (1)
#endif
#if !defined(BL_CONFIG_SPI)
#define BL_CONFIG_SPI (1)
#endif
#if !defined(BL_CONFIG_USB_HID)
#define BL_CONFIG_USB_HID (1)
#endif
#if !defined(BL_CONFIG_USB_MSC)
#define BL_CONFIG_USB_MSC (0)
#endif
#if !defined(BL_CONFIG_HS_USB_HID)
#define BL_CONFIG_HS_USB_HID (0) // For TOWER and FRDM boards
#endif
#if !defined(BL_CONFIG_HS_USB_MSC)
#define BL_CONFIG_HS_USB_MSC (0) // For TOWER and FRDM boards
#endif
//@}
#endif // __BUSPAL_CONFIG_H__
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __command_handle_H__
#define __command_handle_H__
#include <stdio.h>
////////////////////////////////////////////////////////////////////////////////
// Definitions
////////////////////////////////////////////////////////////////////////////////
// @brief Handle the commands receied from host
void handle_command(void);
#endif /* __command_handle_H__ */

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__FPGA_CLOCK_REGISTERS_H__)
#define __FPGA_CLOCK_REGISTERS_H__
#define CY22393_ADDR 0x69
// REG
#define CY22393_REG_CLKA_DIVIDE (0x08) // divsel:0
#define CY22393_REG_CLKB_DIVIDE (0x0A) // divsel:0
#define CY22393_REG_CLKC_DIVIDE (0x0C) // CLKC
#define CY22393_REG_CLKD_DIVIDE (0x0D) // CLKD
#define CY22393_REG_SOURCE 0x0E
#define CY22393_REG_AC 0x0F
#define CY22393_REG_DC 0x10
#define CY22393_REG_CLKA_DIV 0x08
#define CY22393_REG_PLL3Q 0x14
#define CY22393_REG_PLL3P 0x15
#define CY22393_REG_PLL3E 0x16
// This is the low register value of the lower bank
#define CY22393_REG_LOW 0x08
// This is the high register value of the high bank
#define CY22393_REG_HIGH 0x17
#define CY22393_AC 0x55
#define CY22393_DC 0x55
#define CY22393_DIVIDE_OFF 0 // close clk ouput
// Maximum post div value when using VCO frequency above 333 MHZ
#define CY22393_POSTDIV_MAX_VAL 31
// Reference clock to cypress chip
#define CY22393_REF_CLK 24000000
// This is the minimum value that Reference divided by Q can be equal to
#define CY22393_MIN_REF_DIV_Q 250000
// Max clock frequency the chip supports, for CY22393 it is 200Mhz
#define CY22393_MAX_OUTPUT_CLK 200000000
// Max VCO clock frequency the chip supports, for CY22393 it is 375Mhz
#define CY22393_MAX_VCO_CLK 375000000
#endif // __FPGA_CLOCK_REGISTERS_H__

52
apps/bus_pal/src/main.c Normal file
View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "command_handle.h"
#include "bus_pal_hardware.h"
/*FUNCTION**********************************************************************
*
* Function Name : main
* Description : bus pal main function
*
*END**************************************************************************/
int main()
{
init_hardware();
while (1)
{
handle_command();
}
}
////////////////////////////////////////////////////////////////////////////////
// EOF
////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\blfwk\AESCounter.h" />
<ClInclude Include="..\..\..\src\blfwk\AESKey.h" />
<ClInclude Include="..\..\..\src\blfwk\BlfwkErrors.h" />
<ClInclude Include="..\..\..\src\blfwk\Blob.h" />
<ClInclude Include="..\..\..\src\blfwk\Bootloader.h" />
<ClInclude Include="..\..\..\src\blfwk\BusPal.h" />
<ClInclude Include="..\..\..\src\blfwk\BusPalPeripheral.h" />
<ClInclude Include="..\..\..\src\blfwk\Command.h" />
<ClInclude Include="..\..\..\src\blfwk\DataSource.h" />
<ClInclude Include="..\..\..\src\blfwk\DataSourceImager.h" />
<ClInclude Include="..\..\..\src\blfwk\DataTarget.h" />
<ClInclude Include="..\..\..\src\blfwk\ELF.h" />
<ClInclude Include="..\..\..\src\blfwk\ELFSourceFile.h" />
<ClInclude Include="..\..\..\src\blfwk\EndianUtilities.h" />
<ClInclude Include="..\..\..\src\blfwk\ExcludesListMatcher.h" />
<ClInclude Include="..\..\..\src\blfwk\format_string.h" />
<ClInclude Include="..\..\..\src\blfwk\GHSSecInfo.h" />
<ClInclude Include="..\..\..\src\blfwk\GlobMatcher.h" />
<ClInclude Include="..\..\..\src\blfwk\HexValues.h" />
<ClInclude Include="..\..\..\src\blfwk\hidapi.h" />
<ClInclude Include="..\..\..\src\blfwk\host_types.h" />
<ClInclude Include="..\..\..\src\blfwk\IntelHexSourceFile.h" />
<ClInclude Include="..\..\..\src\blfwk\int_size.h" />
<ClInclude Include="..\..\..\src\blfwk\json.h" />
<ClInclude Include="..\..\..\src\blfwk\Logging.h" />
<ClInclude Include="..\..\..\src\blfwk\OptionContext.h" />
<ClInclude Include="..\..\..\src\blfwk\options.h" />
<ClInclude Include="..\..\..\src\blfwk\Packetizer.h" />
<ClInclude Include="..\..\..\src\blfwk\Peripheral.h" />
<ClInclude Include="..\..\..\src\blfwk\Random.h" />
<ClInclude Include="..\..\..\src\blfwk\rijndael.h" />
<ClInclude Include="..\..\..\src\blfwk\RijndaelCTR.h" />
<ClInclude Include="..\..\..\src\blfwk\SBSourceFile.h" />
<ClInclude Include="..\..\..\src\blfwk\SearchPath.h" />
<ClInclude Include="..\..\..\src\blfwk\serial.h" />
<ClInclude Include="..\..\..\src\blfwk\SerialPacketizer.h" />
<ClInclude Include="..\..\..\src\blfwk\smart_ptr.h" />
<ClInclude Include="..\..\..\src\blfwk\SourceFile.h" />
<ClInclude Include="..\..\..\src\blfwk\SRecordSourceFile.h" />
<ClInclude Include="..\..\..\src\blfwk\stdafx.h" />
<ClInclude Include="..\..\..\src\blfwk\StELFFile.h" />
<ClInclude Include="..\..\..\src\blfwk\StExecutableImage.h" />
<ClInclude Include="..\..\..\src\blfwk\StIntelHexFile.h" />
<ClInclude Include="..\..\..\src\blfwk\StringMatcher.h" />
<ClInclude Include="..\..\..\src\blfwk\StSRecordFile.h" />
<ClInclude Include="..\..\..\src\blfwk\UartPeripheral.h" />
<ClInclude Include="..\..\..\src\blfwk\Updater.h" />
<ClInclude Include="..\..\..\src\blfwk\UsbHidPacketizer.h" />
<ClInclude Include="..\..\..\src\blfwk\UsbHidPeripheral.h" />
<ClInclude Include="..\..\..\src\blfwk\utils.h" />
<ClInclude Include="..\..\..\src\blfwk\Value.h" />
<ClInclude Include="..\..\..\src\crc\crc16.h" />
<ClInclude Include="..\..\..\src\crc\crc32.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\blfwk\src\AESCounter.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\AESKey.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Blob.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Bootloader.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\BusPal.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\BusPalPeripheral.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Command.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\DataSource.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\DataSourceImager.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\DataTarget.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\ELFSourceFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\ExcludesListMatcher.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\format_string.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\GHSSecInfo.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\GlobMatcher.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\HexValues.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\hid-windows.c" />
<ClCompile Include="..\..\..\src\blfwk\src\IntelHexSourceFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\jsoncpp.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Logging.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\options.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Random.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\rijndael.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\RijndaelCTR.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\SBSourceFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\SearchPath.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\serial.c" />
<ClCompile Include="..\..\..\src\blfwk\src\SerialPacketizer.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\SourceFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\SRecordSourceFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\StELFFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\StExecutableImage.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\StIntelHexFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\StSRecordFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\UartPeripheral.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Updater.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\UsbHidPacketizer.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\UsbHidPeripheral.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\utils.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Value.cpp" />
<ClCompile Include="..\..\..\src\crc\src\crc16.c" />
<ClCompile Include="..\..\..\src\crc\src\crc32.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{DE64A8C3-695A-491F-B3E3-24D6A3057A40}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>blfw</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BOOTLOADER_HOST;WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../src;../../../src/include;../../../src/drivers/common;../../../src/bm_usb</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<CompileAs>CompileAsCpp</CompileAs>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<AdditionalDependencies>setupapi.lib</AdditionalDependencies>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BOOTLOADER_HOST;WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../src;../../../src/include;../../../src/drivers/common;../../../src/bm_usb</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Lib>
<AdditionalDependencies>setupapi.lib</AdditionalDependencies>
</Lib>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,308 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Target Header Files">
<UniqueIdentifier>{fb17e7f8-107f-4583-b9ff-f467d2a37db4}</UniqueIdentifier>
</Filter>
<Filter Include="Target Source Files">
<UniqueIdentifier>{01992201-ccdd-4a18-b77f-85d5c5353cd0}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\crc\crc16.h">
<Filter>Target Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Packetizer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Peripheral.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\SBSourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\SearchPath.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\serial.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\SerialPacketizer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\smart_ptr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\SourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\SRecordSourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\StELFFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\StExecutableImage.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\StringMatcher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\StSRecordFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\UartPeripheral.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Updater.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\UsbHidPacketizer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\UsbHidPeripheral.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Value.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\BlfwkErrors.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Blob.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Bootloader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\BusPal.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\BusPalPeripheral.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Command.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\DataSource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\DataTarget.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\ELF.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\ELFSourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\EndianUtilities.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\format_string.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\GHSSecInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\hidapi.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\host_types.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\int_size.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\json.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Logging.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\OptionContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\options.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\crc\crc32.h">
<Filter>Target Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\AESKey.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\AESCounter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\GlobMatcher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\HexValues.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\DataSourceImager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\ExcludesListMatcher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\rijndael.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\RijndaelCTR.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Random.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\IntelHexSourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\StIntelHexFile.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\crc\src\crc16.c">
<Filter>Target Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\hid-windows.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\jsoncpp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Logging.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\SBSourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\SearchPath.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\serial.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\SerialPacketizer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\SourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\SRecordSourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\StELFFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\StExecutableImage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\StSRecordFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\UartPeripheral.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Updater.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\UsbHidPacketizer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\UsbHidPeripheral.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Value.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Bootloader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\BusPal.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\BusPalPeripheral.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Command.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\DataSource.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\DataTarget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\ELFSourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\format_string.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\GHSSecInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\options.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\crc\src\crc32.c">
<Filter>Target Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\AESKey.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Blob.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\AESCounter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\GlobMatcher.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\HexValues.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\DataSourceImager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\ExcludesListMatcher.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\rijndael.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\RijndaelCTR.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Random.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\IntelHexSourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\StIntelHexFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:blfwk.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>39613C90-D3FD-466B-B9D9-DC666880F859</string>
<key>IDESourceControlProjectName</key>
<string>blfwk</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>B0D5F4B3-E512-4A54-9F8A-89FE66DEC76C</key>
<string>ssh://sw-git.freescale.net/git/sw_git/repos/mcu-boot.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>apps/common/blfwk/blfwk.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>B0D5F4B3-E512-4A54-9F8A-89FE66DEC76C</key>
<string>../../../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://sw-git.freescale.net/git/sw_git/repos/mcu-boot.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>B0D5F4B3-E512-4A54-9F8A-89FE66DEC76C</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>B0D5F4B3-E512-4A54-9F8A-89FE66DEC76C</string>
<key>IDESourceControlWCCName</key>
<string>mcu-boot</string>
</dict>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,206 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\blfwk\AESCounter.h" />
<ClInclude Include="..\..\..\src\blfwk\AESKey.h" />
<ClInclude Include="..\..\..\src\blfwk\BlfwkErrors.h" />
<ClInclude Include="..\..\..\src\blfwk\Blob.h" />
<ClInclude Include="..\..\..\src\blfwk\Bootloader.h" />
<ClInclude Include="..\..\..\src\blfwk\BusPal.h" />
<ClInclude Include="..\..\..\src\blfwk\BusPalPeripheral.h" />
<ClInclude Include="..\..\..\src\blfwk\Command.h" />
<ClInclude Include="..\..\..\src\blfwk\Crc.h" />
<ClInclude Include="..\..\..\src\blfwk\DataSource.h" />
<ClInclude Include="..\..\..\src\blfwk\DataSourceImager.h" />
<ClInclude Include="..\..\..\src\blfwk\DataTarget.h" />
<ClInclude Include="..\..\..\src\blfwk\ELF.h" />
<ClInclude Include="..\..\..\src\blfwk\ELFSourceFile.h" />
<ClInclude Include="..\..\..\src\blfwk\EndianUtilities.h" />
<ClInclude Include="..\..\..\src\blfwk\ExcludesListMatcher.h" />
<ClInclude Include="..\..\..\src\blfwk\format_string.h" />
<ClInclude Include="..\..\..\src\blfwk\GHSSecInfo.h" />
<ClInclude Include="..\..\..\src\blfwk\GlobMatcher.h" />
<ClInclude Include="..\..\..\src\blfwk\HexValues.h" />
<ClInclude Include="..\..\..\src\blfwk\hidapi.h" />
<ClInclude Include="..\..\..\src\blfwk\host_types.h" />
<ClInclude Include="..\..\..\src\blfwk\IntelHexSourceFile.h" />
<ClInclude Include="..\..\..\src\blfwk\int_size.h" />
<ClInclude Include="..\..\..\src\blfwk\json.h" />
<ClInclude Include="..\..\..\src\blfwk\Logging.h" />
<ClInclude Include="..\..\..\src\blfwk\OptionContext.h" />
<ClInclude Include="..\..\..\src\blfwk\options.h" />
<ClInclude Include="..\..\..\src\blfwk\Packetizer.h" />
<ClInclude Include="..\..\..\src\blfwk\Peripheral.h" />
<ClInclude Include="..\..\..\src\blfwk\Random.h" />
<ClInclude Include="..\..\..\src\blfwk\rijndael.h" />
<ClInclude Include="..\..\..\src\blfwk\RijndaelCTR.h" />
<ClInclude Include="..\..\..\src\blfwk\SBSourceFile.h" />
<ClInclude Include="..\..\..\src\blfwk\SearchPath.h" />
<ClInclude Include="..\..\..\src\blfwk\serial.h" />
<ClInclude Include="..\..\..\src\blfwk\SerialPacketizer.h" />
<ClInclude Include="..\..\..\src\blfwk\smart_ptr.h" />
<ClInclude Include="..\..\..\src\blfwk\SourceFile.h" />
<ClInclude Include="..\..\..\src\blfwk\SRecordSourceFile.h" />
<ClInclude Include="..\..\..\src\blfwk\stdafx.h" />
<ClInclude Include="..\..\..\src\blfwk\StELFFile.h" />
<ClInclude Include="..\..\..\src\blfwk\StExecutableImage.h" />
<ClInclude Include="..\..\..\src\blfwk\StIntelHexFile.h" />
<ClInclude Include="..\..\..\src\blfwk\StringMatcher.h" />
<ClInclude Include="..\..\..\src\blfwk\StSRecordFile.h" />
<ClInclude Include="..\..\..\src\blfwk\UartPeripheral.h" />
<ClInclude Include="..\..\..\src\blfwk\Updater.h" />
<ClInclude Include="..\..\..\src\blfwk\UsbHidPacketizer.h" />
<ClInclude Include="..\..\..\src\blfwk\UsbHidPeripheral.h" />
<ClInclude Include="..\..\..\src\blfwk\utils.h" />
<ClInclude Include="..\..\..\src\blfwk\Value.h" />
<ClInclude Include="..\..\..\src\bootloader\bootloader.h" />
<ClInclude Include="..\..\..\src\bootloader\command.h" />
<ClInclude Include="..\..\..\src\crc\crc16.h" />
<ClInclude Include="..\..\..\src\crc\crc32.h" />
<ClInclude Include="..\..\..\src\include\bootloader_common.h" />
<ClInclude Include="..\..\..\src\packet\serial_packet.h" />
<ClInclude Include="..\..\..\src\property\property.h" />
<ClInclude Include="..\..\..\src\usb_device\bootloader_hid_report_ids.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\blfwk\src\AESCounter.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\AESKey.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Blob.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Bootloader.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\BusPal.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\BusPalPeripheral.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Command.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Crc.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\DataSource.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\DataSourceImager.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\DataTarget.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\ELFSourceFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\ExcludesListMatcher.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\format_string.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\GHSSecInfo.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\GlobMatcher.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\HexValues.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\hid-windows.c" />
<ClCompile Include="..\..\..\src\blfwk\src\IntelHexSourceFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\jsoncpp.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Logging.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\options.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Random.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\rijndael.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\RijndaelCTR.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\SBSourceFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\SearchPath.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\serial.c" />
<ClCompile Include="..\..\..\src\blfwk\src\SerialPacketizer.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\SourceFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\SRecordSourceFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\StELFFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\StExecutableImage.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\StIntelHexFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\StSRecordFile.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\UartPeripheral.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Updater.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\UsbHidPacketizer.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\UsbHidPeripheral.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\utils.cpp" />
<ClCompile Include="..\..\..\src\blfwk\src\Value.cpp" />
<ClCompile Include="..\..\..\src\crc\src\crc16.c" />
<ClCompile Include="..\..\..\src\crc\src\crc32.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{DE64A8C3-695A-491F-B3E3-24D6A3057A40}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>blfw</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(ProjectDir)$(ProjectName)-$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)$(ProjectName)-$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(ProjectDir)$(ProjectName)-$(Configuration)\</OutDir>
<IntDir>$(ProjectDir)$(ProjectName)-$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BOOTLOADER_HOST;WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../src;../../../src/include;../../../src/drivers/common;../../../src/bm_usb</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<CompileAs>CompileAsCpp</CompileAs>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Lib>
<AdditionalDependencies>setupapi.lib</AdditionalDependencies>
</Lib>
<Bscmake>
<PreserveSbr>true</PreserveSbr>
</Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BOOTLOADER_HOST;WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../src;../../../src/include;../../../src/drivers/common;../../../src/bm_usb</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Lib>
<AdditionalDependencies>setupapi.lib</AdditionalDependencies>
</Lib>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,332 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Target Header Files">
<UniqueIdentifier>{fb17e7f8-107f-4583-b9ff-f467d2a37db4}</UniqueIdentifier>
</Filter>
<Filter Include="Target Source Files">
<UniqueIdentifier>{01992201-ccdd-4a18-b77f-85d5c5353cd0}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\include\bootloader_common.h">
<Filter>Target Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\usb_device\bootloader_hid_report_ids.h">
<Filter>Target Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\bootloader\command.h">
<Filter>Target Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\packet\serial_packet.h">
<Filter>Target Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\crc\crc16.h">
<Filter>Target Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\property\property.h">
<Filter>Target Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\bootloader\bootloader.h">
<Filter>Target Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Packetizer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Peripheral.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\SBSourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\SearchPath.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\serial.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\SerialPacketizer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\smart_ptr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\SourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\SRecordSourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\StELFFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\StExecutableImage.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\StringMatcher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\StSRecordFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\UartPeripheral.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Updater.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\UsbHidPacketizer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\UsbHidPeripheral.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\utils.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Value.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\BlfwkErrors.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Blob.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Bootloader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\BusPal.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\BusPalPeripheral.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Command.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\DataSource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\DataTarget.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\ELF.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\ELFSourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\EndianUtilities.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\format_string.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\GHSSecInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\hidapi.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\host_types.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\int_size.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\json.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Logging.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\OptionContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\options.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\crc\crc32.h">
<Filter>Target Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\AESKey.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\AESCounter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\GlobMatcher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\HexValues.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\DataSourceImager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\ExcludesListMatcher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\rijndael.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\RijndaelCTR.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Random.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\IntelHexSourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\StIntelHexFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\blfwk\Crc.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\crc\src\crc16.c">
<Filter>Target Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\hid-windows.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\jsoncpp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Logging.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\SBSourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\SearchPath.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\serial.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\SerialPacketizer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\SourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\SRecordSourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\StELFFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\StExecutableImage.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\StSRecordFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\UartPeripheral.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Updater.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\UsbHidPacketizer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\UsbHidPeripheral.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Value.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Bootloader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\BusPal.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\BusPalPeripheral.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Command.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\DataSource.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\DataTarget.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\ELFSourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\format_string.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\GHSSecInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\options.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\crc\src\crc32.c">
<Filter>Target Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\AESKey.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Blob.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\AESCounter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\GlobMatcher.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\HexValues.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\DataSourceImager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\ExcludesListMatcher.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\rijndael.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\RijndaelCTR.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Random.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\IntelHexSourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\StIntelHexFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\blfwk\src\Crc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@@ -0,0 +1,245 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "blfwkdll.h"
#include "blfwk/Bootloader.h"
#include "blfwk/Updater.h"
#include "blfwk/SerialPacketizer.h"
#include "blfwk/Crc.h"
namespace blfwkdll
{
// See blfwkdll.h for documentation of this method.
Updater::Updater(PeripheralConfig *config)
{
blfwk::Peripheral::PeripheralConfigData *pinnedConfig = (blfwk::Peripheral::PeripheralConfigData *)config;
updater = NULL;
try
{
updater = new blfwk::Updater(*pinnedConfig);
}
catch (exception e)
{
throw e;
}
}
// See blfwkdll.h for documentation of this method.
Updater::~Updater()
{
// Clean up unmanaged code.
if (updater != NULL)
{
delete (blfwk::Updater *)updater;
updater = NULL;
}
}
// See blfwkdll.h for documentation of this method.
void Updater::registerCallback(void (*progress)(int, int, int), bool *abort)
{
((blfwk::Updater *)updater)->registerCallback(progress, abort);
}
// See blfwkdll.h for documentation of this method.
void Updater::eraseAllUnsecure()
{
try
{
((blfwk::Updater *)updater)->eraseAllUnsecure();
}
catch (const std::exception &e)
{
throw e;
}
}
// See blfwkdll.h for documentation of this method.
void Updater::unlockWithKey(const std::string &backdoorKey)
{
try
{
((blfwk::Updater *)updater)->unlock(backdoorKey);
}
catch (const std::exception &e)
{
throw e;
}
}
/* clang-format off */
/* the for each statement is non-standard and not supported by clang format */
// See blfwkdll.h for documentation of this method.
bool Updater::isCommandSupported(const std::string &command)
{
try
{
for each(blfwk::cmd_t var in blfwk::kCommands)
{
if (command.compare(var.name) == 0)
{
return ((blfwk::Updater *)updater)->isCommandSupported(var);
}
}
return false;
}
catch (const std::exception &e)
{
throw e;
}
}
/* clang-format on */
// See blfwkdll.h for documentation of this method.
uint32_t Updater::flashFirmware(std::string *filename, uint32_t baseAddress)
{
try
{
uint32_t status;
status = ((blfwk::Updater *)updater)->flashFirmware(filename->c_str(), baseAddress);
return status;
}
catch (const std::exception &e)
{
throw e;
}
}
// See blfwkdll.h for documentation of this method.
void Updater::reset()
{
try
{
((blfwk::Updater *)updater)->reset();
// delete updater;
// updater = NULL;
}
catch (const std::exception &e)
{
// delete this;
throw e;
}
}
// See blfwkdll.h for documentation of this method.
uint32_t Updater::getSerialProtocolVersion()
{
try
{
return ((blfwk::Updater *)updater)->getPacketizer()->getVersion().version;
}
catch (const std::exception &e)
{
throw e;
}
}
// See blfwkdll.h for documentation of this method.
void Updater::getProperty(PROPERTY_TAG tag, uint32_t *responseWords)
{
blfwk::property_t propertytag = blfwk::kProperties.at(tag);
std::vector<uint32_t> value = ((blfwk::Updater *)updater)->getProperty(propertytag);
for (size_t i = 0; i < value.size(); i++)
{
responseWords[i] = value.at(i);
}
}
// See blfwkdll.h for documentation of this method.
uint32_t Updater::getSectorSize()
{
return ((blfwk::Updater *)updater)->getSectorSize();
}
// See blfwkdll.h for documentation of this method.
uint32_t Updater::getFlshSize()
{
return ((blfwk::Updater *)updater)->getFlshSize();
}
// See blfwkdll.h for documentation of this method.
void Updater::ping(int32_t retries, uint32_t delay, uint32_t comSpeed)
{
try
{
((blfwk::Updater *)updater)->ping(retries, delay, comSpeed);
}
catch (const std::exception &e)
{
throw e;
}
}
// See blfwkdll.h for documentation of this method.
void Updater::eraseFlashRegion(uint32_t start, uint32_t length)
{
try
{
((blfwk::Updater *)updater)->eraseFlashRegion(start, length);
}
catch (const std::exception &e)
{
throw e;
}
}
// See blfwkdll.h for documentation of this method.
void Updater::eraseFlashAll(uint32_t memoryId)
{
try
{
((blfwk::Updater *)updater)->eraseFlashAll(memoryId);
}
catch (const std::exception &e)
{
throw e;
}
}
// See blfwkdll.h for documentation of this method.
void Updater::programOnce(uint32_t index, uint32_t byteCount, const std::string &data)
{
try
{
((blfwk::Updater *)updater)->programOnce(index, byteCount, data);
}
catch (const std::exception &e)
{
throw e;
}
}
// See blfwkdll.h for documentation of this method.
uint32_t Crc::calculate_application_crc32(const uint8_t *start, uint32_t length)
{
return blfwk::Crc::calculate_application_crc32(start, length);
}
} // namespace blfwkdll;

View File

@@ -0,0 +1,404 @@
/*
* Copyright (c) 2013-15, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef BLFWKDLL_EXPORTS
#define BLFWKDLL_API __declspec(dllexport)
#else
#define BLFWKDLL_API __declspec(dllimport)
#endif
#pragma once
#include <string>
#include <vector>
//! @brief Tag value used to validate the bootloader configuration data.
#define kBootloaderConfigAreaTag (('k' << 0) | ('c' << 8) | ('f' << 16) | ('g' << 24))
//! @brief Peripheral type bit mask definitions.
#define kPeripheralMaskUart (1 << 0)
#define kPeripheralMaskI2c (1 << 1)
#define kPeripheralMaskSpi (1 << 2)
#define kPeripheralMaskCan (1 << 3)
#define kPeripheralMaskUsb (1 << 4)
#define kPeripheralMask \
(kPeripheralMaskUart | kPeripheralMaskI2c | kPeripheralMaskSpi | kPeripheralMaskCan | kPeripheralMaskUsb)
//! @brief Bit positions for boot flags in configuration data
#define kBootFlagDirectBoot (1 << 0)
//! @brief Bit positions for clock flags in configuration data.
#define kClockFlagHighSpeed (1 << 0)
// Copy from src/bootloader/src/flexcan_peripheral_interface.c
// config1 8 bit
#define FLEXCAN_SPEED_MASK 0x0F // bit[3:0]
#define FLEXCAN_SPEED_SPEC_MASK 0x08 // bit[3:3]
#define FLEXCAN_SPEED_INDEX_MASK 0x07 // bit[2:0]
#define FLEXCAN_CLKSEL_MASK 0x80 // bit[7:7]
#define FLEXCAN_PROPSEG_MASK 0x70 // bit[6:4]
#define FLEXCAN_PROPSEG_SHIFT 4
// config2 16 bit
#define FLEXCAN_PRESCALER_MASK 0xFF00 // bit[15:8]
#define FLEXCAN_PRESCALER_SHIFT 8
#define FLEXCAN_PSEG1_MASK 0x00E0 // bit[7:5]
#define FLEXCAN_PSEG1_SHIFT 5
#define FLEXCAN_PSEG2_MASK 0x001C // bit[4:2]
#define FLEXCAN_PSEG2_SHIFT 2
#define FLEXCAN_RJW_MASK 0x0003 // bit[1:0]
#define FLEXCAN_RJW_SHIFT 0
#define FLEXCAN_SPEED_125K 0x00 // bit[2:0]
#define FLEXCAN_SPEED_250K 0x01 // bit[2:0]
#define FLEXCAN_SPEED_500K 0x02 // bit[2:0]
#define FLEXCAN_SPEED_1M 0x04 // bit[2:0]
namespace blfwkdll
{
// Copy from src/property/property.c
//! @brief Format of bootloader configuration data on Flash.
struct BLFWKDLL_API BootloaderConfigureAreaData
{
uint32_t tag; //!< [00:03] Magic number to verify bootloader configuration is valid. Must be set to 'kcfg'.
uint32_t crcStartAddress; //!< [04:07] Start address for application image CRC check. If the bits are all set then
//! Kinetis bootloader by default will not perform any CRC check.
uint32_t crcByteCount; //!< [08:0b] Byte count for application image CRC check. If the bits are all set then Kinetis
//! bootloader by default will not prform any CRC check.
uint32_t crcExpectedValue; //!< [0c:0f] Expected CRC value for application CRC check. If the bits are all set then
//! Kinetis bootloader by default will not perform any CRC check.
uint8_t enabledPeripherals; //!< [10:10] Bitfield of peripherals to enable.
//! bit 0 - LPUART, bit 1 - I2C, bit 2 - SPI, bit 3 - CAN, bit 4 - USB
//! Kinetis bootloader will enable the peripheral if corresponding bit is set to 1.
uint8_t i2cSlaveAddress; //!< [11:11] If not 0xFF, used as the 7-bit I2C slave address. If 0xFF, defaults to 0x10
//! for I2C slave address.
uint16_t peripheralDetectionTimeoutMs; //!< [12:13] Timeout in milliseconds for active peripheral detection. If
//! 0xFFFF, defaults to 5 seconds.
uint16_t usbVid; //!< [14:15] Sets the USB Vendor ID reported by the device during enumeration. If 0xFFFF, it
//! defaults to 0x15A2.
uint16_t usbPid; //!< [16:17] Sets the USB Product ID reported by the device during enumeration.
uint32_t usbStringsPointer; //!< [18:1b] Sets the USB Strings reported by the device during enumeration.
uint8_t clockFlags; //!< [1c:1c] The flags in the clockFlags configuration field are enabled if the corresponding
//! bit is cleared (0).
//! bit 0 - HighSpeed Enable high speed mode (i.e., 48 MHz).
uint8_t
clockDivider; //!< [1d:1d] Inverted value of the divider to use for core and bus clocks when in high speed mode.
uint8_t bootFlags; //!< [1e:1e] If bit 0 is cleared, then Kinetis bootloader will jump to either Quad SPI Flash or
//! internal flash image depending on FOPT BOOTSRC_SEL bits.
//! If the bit is set, then Kinetis bootloader will prepare for host communication over serial peripherals.
uint8_t pad0; //!< [1f:1f] Reserved, set to 0xFF
uint32_t mmcauConfigPointer; //!< [20:23] A pointer to the MMCAU configuration structure in memory.
uint32_t keyBlobPointer; //!< [24:27]Holds a pointer value to the key blob array used to configure OTFAD
uint8_t pad1; //!< [28:28] reserved
uint8_t canConfig1; //!< [29:29] ClkSel[1], PropSeg[3], SpeedIndex[4]
uint16_t canConfig2; //!< [2a:2b] Pdiv[8], Pseg1[3], Pseg2[3], rjw[2]
uint16_t canTxId; //!< [2c:2d] txId
uint16_t canRxId; //!< [2e:2f] rxId
uint32_t qspi_config_block_pointer; //!< [30:33] A pointer to the QSPI config block in internal flash array.
uint32_t reserved[3]; //!<[34:3f] reserved
};
/*!
* \brief Update class contains the functionality necessary to update the
* firmware on a device running Bootloader.
*
* The purpose of this class is to provide a common interface for
* updating any device running the Kinetis Bootloader from several different file formats.
*/
class BLFWKDLL_API Updater
{
public:
//! @brief Bootloader Transports.
enum HOST_PERIPHERAL_TYPE_TAG
{
kHostPeripheralType_None,
kHostPeripheralType_UART,
kHostPeripheralType_BUSPAL_UART,
kHostPeripheralType_USB_HID,
kHostPeripheralType_SIM
};
//! @brief BusPal Transports.
enum BUS_PAL_TYPE
{
kBusPalFunction_None,
kBusPalFunction_SPI,
kBusPalFunction_I2C,
kBusPalFunction_CAN,
kBusPalFunction_GPIO_CONFIG,
kBusPalFunction_GPIO_SET,
kBusPalFunction_FPGA_CLOCK_SET
};
//! @brief SPI clock polarity configuration.
enum SPI_CLOCK_POLARITY
{
kSpiClockPolarity_ActiveHigh = 0, //!< Active-high SPI clock (idles low).
kSpiClockPolarity_ActiveLow = 1 //!< Active-low SPI clock (idles high).
};
//! @brief SPI clock phase configuration.
enum SPI_CLOCK_PHASE
{
kSpiClockPhase_FirstEdge =
0, //!< First edge on SPSCK occurs at the middle of the first cycle of a data transfer.
kSpiClockPhase_SecondEdge =
1 //!< First edge on SPSCK occurs at the start of the first cycle of a data transfer.
};
//! @brief SPI data shifter direction options.
enum SPI_SHIFT_DIRECTION
{
kSpiMsbFirst = 0, //!< Data transfers start with most significant bit.
kSpiLsbFirst = 1 //!< Data transfers start with least significant bit.
};
//! @brief BusPal configuration data.
struct BusPalConfig
{
BUS_PAL_TYPE function;
uint32_t spiSpeedKHz;
SPI_CLOCK_POLARITY spiPolarity;
SPI_CLOCK_PHASE spiPhase;
SPI_SHIFT_DIRECTION spiDirection;
uint8_t i2cAddress;
uint32_t i2cSpeedKHz;
uint32_t canSpeed;
uint32_t canTxid;
uint32_t canRxid;
uint8_t gpioPort;
uint8_t gpioPinNum;
uint8_t gpioLevel;
uint8_t gpioMux;
uint32_t fpgaClockMhz;
};
//! @brief Peripheral configuration data.
struct PeripheralConfig
{
HOST_PERIPHERAL_TYPE_TAG peripheralType;
std::string comPortName;
long comPortSpeed;
uint32_t packetTimeoutMs;
unsigned short usbHidVid;
unsigned short usbHidPid;
std::string usbHidSerialNumber;
bool ping;
BusPalConfig busPalConfig;
};
//! @brief Bootloader command mask.
enum COMMAND_MASK
{
kCommandMask_FlashEraseAll = 0x00000001,
kCommandMask_ReadMemory = 0x00000004,
kCommandMask_WriteMemory = 0x00000008,
kCommandMask_FillMemory = 0x00000010,
kCommandMask_FlashSecurityDisable = 0x00000020,
kCommandMask_GetProperty = 0x00000040,
kCommandMask_ReceiveSBFile = 0x00000080,
kCommandMask_Execute = 0x00000100,
kCommandMask_Call = 0x00000200,
kCommandMask_Reset = 0x00000400,
kCommandMask_SetProperty = 0x00000800,
kCommandMask_FlashEraseAllUnsecure = 0x00001000,
kCommandMask_FlashProgramOnce = 0x00002000,
kCommandMask_FlashReadOnce = 0x00004000,
kCommandMask_FlashReadResource = 0x00008000,
kCommandMask_ConfigureQuadSpi = 0x00010000,
};
//! @brief Bootloader property.
enum PROPERTY_TAG
{
kPropertyTag_ListProperties = 0x00,
kPropertyTag_BootloaderVersion = 0x01,
kPropertyTag_AvailablePeripherals = 0x02,
kPropertyTag_FlashStartAddress = 0x03,
kPropertyTag_FlashSizeInBytes = 0x04,
kPropertyTag_FlashSectorSize = 0x05,
kPropertyTag_FlashBlockCount = 0x06,
kPropertyTag_AvailableCommands = 0x07,
kPropertyTag_CrcCheckStatus = 0x08,
kPropertyTag_Reserved9 = 0x09,
kPropertyTag_VerifyWrites = 0x0a,
kPropertyTag_MaxPacketSize = 0x0b,
kPropertyTag_ReservedRegions = 0x0c,
kPropertyTag_Reserved13 = 0x0d,
kPropertyTag_RAMStartAddress = 0x0e,
kPropertyTag_RAMSizeInBytes = 0x0f,
kPropertyTag_SystemDeviceId = 0x10,
kPropertyTag_FlashSecurityState = 0x11,
kPropertyTag_UniqueDeviceId = 0x12,
kPropertyTag_FacSupport = 0x13,
kPropertyTag_FlashAccessSegmentSize = 0x14,
kPropertyTag_FlashAccessSegmentCount = 0x15,
kPropertyTag_FlashReadMargin = 0x16,
kPropertyTag_QspiInitStatus = 0x17,
kPropertyTag_TargetVersion = 0x18,
kPropertyTag_ExternalMemoryAttributes = 0x19,
kPropertyTag_InvalidProperty = 0xFF,
};
private:
// Due to the reason that MFC project must include this headfile to use blfwkdll,
// while cannot include blfwk/Updater.h.
// So use a void pointer here
void *updater; //!< A pointer to blfwk::Updater.
public:
//! \brief Default constructor.
Updater(PeripheralConfig *config);
//! \brief Destructor.
~Updater();
//! \brief register callback function
//!
//! \param progress Progress callback function
//!
//! \param abort The variable to abort the data phase.
void registerCallback(void (*progress)(int, int, int), bool *abort);
//! \brief Erase all flash blocks and release MCU security
//!
//! \exception Raised if the FlashEraseAllUnsecure command does not return success.
//! Raised if the FlashEraseAllUnsecure command is not supported.
void eraseAllUnsecure();
//! \brief Release security using BackdoorKey
//!
//! \exception Raised if the FlashSecurityDisable command does not return success.
//! Raised if the FlashSecurityDisable command is not supported.
//! Raised if the parameter is illegal
//! \param backdoor_key The 16 hex digitals used to release the security
void unlockWithKey(const std::string &backdoorKey);
//! \brief Checks if Kinetis Bootloader device supports a given command.
//!
//! \exception Thrown if an error occurred while sending the
//! GetProperty(kProperty_AvailableCommands) bootloader command.
//!
//! \param command The command to check.
//!
//! \return true if command is supported, false if not.
bool isCommandSupported(const std::string &command);
//! \brief Program flash on the device.
//!
//! \exception Raised if the file could not be opened successfully.
//!
//! \param filename The file to program into the device.
//! \param base_address The address on the device where the file wiill be written.
//! (for hex,srec and sb file, the param can be any value.)
uint32_t flashFirmware(std::string *filename, uint32_t baseAddress);
//! \brief Execute the reset command.
//!
//! \exception Raised if the reset command is failed.
void reset();
//! @brief Get the serial protocol version.
//!
//! \exception Raised if the operation is failed.
uint32_t getSerialProtocolVersion();
//! \brief get Device's property by using get-property command.
//!
//! \exception Thrown if an error occurred while sending the
//! GetProperty(property) bootloader command.
//!
//! \param property tag
//!
//! \param pointer of the response values.
void getProperty(PROPERTY_TAG tag, uint32_t *responseWords);
//! \brief get Device's flash sector size.
//!
//! \return the value of sector size.
uint32_t getSectorSize();
//! \brief get Device's flash size.
//!
//! \return the value of flash size.
uint32_t getFlshSize();
//! \brief Send a ping if applicable.
//!
//! \exception Raised if ping response is not received successfully.
void ping(int32_t retries, uint32_t delay, uint32_t comSpeed);
//! \brief Execute the FlashEraseRegion bootloader command.
//!
//! \exception Thrown if an error occurred while sending the
//! FlashEraseRegion(start, length) bootloader command.
//!
//! \param start The beginning address of the memory region to be erased.
//! \param length The length in bytes of the memory region to be erased.
void eraseFlashRegion(uint32_t start, uint32_t length);
//! \brief Execute the FlashEraseAll bootloader command.
//!
//! \exception Thrown if an error occurred while sending the
//! FlashEraseAll bootloader command.
void eraseFlashAll(uint32_t memoryId);
//! \brief Execute the FlashProgramOnce bootloader command.
//!
//! \exception Thrown if an error occurred while sending the
//! FlashEraseAll bootloader command.
//!
//! \param index The index of a specific program once field.
//!
//! \param byteCount The length in bytes of a specific program once field.
//!
//! \param data The 8/16 hex digitals to write.
void programOnce(uint32_t index, uint32_t byteCount, const std::string &data);
};
/*!
* \brief Crc class contains the functionality about crc ccalculation.
*/
class BLFWKDLL_API Crc
{
public:
//! \brief Default constructor.
Crc(){};
//! \brief Destructor.
virtual ~Crc(){};
//! \brief calculate crc32 for a given memory region
//!
//! \param start The start address of a memory region that contains the data
//! \
//! \param length Length in bytes to calculate
//! \
//! \return calculated result
static uint32_t calculate_application_crc32(const uint8_t *start, uint32_t length);
};
} // namespace blfwkdll

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{426D14FE-6F2B-442D-893D-B5730DD6941F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>blfwkdll</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<ProjectName>blfwkdll</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>false</CLRSupport>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>false</LinkIncremental>
<IgnoreImportLibrary>true</IgnoreImportLibrary>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BOOTLOADER_HOST;WIN32;_DEBUG;_WINDOWS;_USRDLL;BLFWKDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../;..\..\..\src;..\..\..\src\include;../../../src/drivers/common;../../../src/bm_usb</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProjectDir)blfwk-$(Configuration)</AdditionalLibraryDirectories>
<AdditionalDependencies>blfwk.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;BLFWKDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BOOTLOADER_HOST;WIN32;NDEBUG;_WINDOWS;_USRDLL;BLFWKDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>../;..\..\..\src;..\..\..\src\include;../../../src/drivers/common;../../../src/bm_usb</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(ProjectDir)blfwk-$(Configuration)</AdditionalLibraryDirectories>
<AdditionalDependencies>blfwk.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;BLFWKDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="blfwkdll.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="blfwkdll.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="blfwk.vcxproj">
<Project>{de64a8c3-695a-491f-b3e3-24d6a3057a40}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="blfwkdll.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="blfwkdll.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@@ -0,0 +1 @@
00112233445566778899aabbccddeeff

View File

@@ -0,0 +1,28 @@
# No source file needed, keep this block empty
sources {
}
# The section block specifies the sequence of boot commands to be written to the SB file.
section (0) {
# Use the 'load ifr' statement to program the SB key to IFR memory.
# The SB key occupies IFR index 0x30-0x33.
# The SB key is 128-bit specifies as 4 little-endian long-word values.
# SB Key = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}
load ifr 0x33221100 > 0x30;
load ifr 0x77665544 > 0x31;
load ifr 0xbbaa9988 > 0x32;
load ifr 0xffeeddcc > 0x33;
# Use the 'load ifr' statement to program the OTFAD KEK to IFR memory.
# The KEK is used to unwrap(decrypt) the keyblob at boot time in order to correctly set up the OTFAD engine.
# The key is specified as 4 little-endian values, with the "least significant" key word going into the lowest IFR index
# KEK = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}
load ifr 0x0f0e0d0c > 0x20;
load ifr 0x0b0a0908 > 0x21;
load ifr 0x07060504 > 0x22;
load ifr 0x03020100 > 0x23;
# Reset target in order to let these keys take effect.
reset;
}

View File

@@ -0,0 +1,35 @@
# The sources block assigns file names to identifiers
sources {
# SREC File path
mySrecFile = "led_demo_qspi_0000.srec";
# QCB file path
qspiConfigBlock = "qspi_config_block.bin";
}
# The section block specifies the sequence of boot commands to be written to
# the SB file
section (0) {
#1. Erase the vector table and flash config field.
erase 0..0x800;
# Step 2 and Step 3 are optional if the QuadSPI is configured at startup.
#2. Load the QCB to RAM
load qspiConfigBlock > 0x20000000;
#3. Configure QuadSPI with the QCB above
enable qspi 0x20000000;
#4. Erase the QuadSPI memory region before programming.
erase 0x68000000..0x68004000;
#5.Load the QCB above to the start address of QuadSPI memory
load qspiConfigBlock > 0x68000000;
#6,7. Load all the RO data from srec file, including vector table, flash config field and codes.
load mySrecFile;
#8. Reset target.
reset;
}

View File

@@ -0,0 +1,35 @@
# The sources block assigns file names to identifiers
sources {
# SREC File path
mySrecFile = "led_demo_qspi_a000.srec";
# QCB file path
qspiConfigBlock = "qspi_config_block.bin";
}
# The section block specifies the sequence of boot commands to be written to
# the SB file
section (0) {
#1. Erase the vector table and flash config field.
erase 0xa000..0xa800;
# Step 2 and Step 3 are optional if the QuadSPI is configured at startup.
#2. Load the QCB to RAM
load qspiConfigBlock > 0x20000000;
#3. Configure QuadSPI with the QCB above
enable qspi 0x20000000;
#4. Erase the QuadSPI memory region before programming.
erase 0x68000000..0x68004000;
#5.Load the QCB above to the start address of QuadSPI memory
load qspiConfigBlock > 0x68000000;
#6,7. Load all the RO data from srec file, including vector table, flash config field and codes.
load mySrecFile;
#8. Reset target.
reset;
}

View File

@@ -0,0 +1,35 @@
# The sources block assigns file names to identifiers
sources {
# SREC File path
mySrecFile = "led_demo_qspi_alias_a000.srec";
# QCB file path
qspiConfigBlock = "qspi_config_block.bin";
}
# The section block specifies the sequence of boot commands to be written to
# the SB file
section (0) {
#1. Erase the vector table and flash config field.
erase 0xa000..0xa800;
# Step 2 and Step 3 are optional if the QuadSPI is configured at startup.
#2. Load the QCB to RAM
load qspiConfigBlock > 0x20000000;
#3. Configure QuadSPI with the QCB above
enable qspi 0x20000000;
#4. Erase the QuadSPI memory region before programming.
erase 0x04000000..0x04004000;
#5.Load the QCB above to the start address of QuadSPI memory
load qspiConfigBlock > 0x68000000;
#6. Load all boot_to_qspi_alias_memory applcation
load mySrecFile;
#7. Reset target.
reset;
}

View File

@@ -0,0 +1,70 @@
# The sources block assigns file names to identifiers
sources {
# SREC File path
mySrecFile = "boot_to_qspi_alias_memory_rom.srec";
# QCB file path
qspiConfigBlock = "qspi_config_block.bin";
# Alias QSPI image file path
myBinFile = "led_demo_qspi_alias_rom.bin";
}
# The keyblob creates a structure with up to 4 keyblob entries.
# The empty parentheses syntax specifies an entry of all zeros (no encryption)
# Each entry consists of 4 parameters:
# start - start address of encrypted block.
# end - end address of encrypted block.
# key - AES-CTR mode encryption key for this range.
# counter - initial counter value for AES-CTR encryption for this range.
keyblob (0) {
(
start=0x68001000,
end = 0x68001fff,
key="000102030405060708090a0b0c0d0e0f",
counter="0123456789abcdef"
)
()
()
()
}
# The section block specifies the sequence of boot commands to be written to
# the SB file
section (0) {
#1. Erase the vector table and flash config field.
erase 0..0x800;
# Step 2 and Step 3 are optional if the QuadSPI is configured at startup.
#2. Load the QCB to RAM
load qspiConfigBlock > 0x20000000;
#3. Configure QuadSPI with the QCB above
enable qspi 0x20000000;
#4. Erase the QuadSPI memory region before programming.
erase 0x68000000..0x68004000;
#5.Load the QCB above to the start address of QuadSPI memory
load qspiConfigBlock > 0x68000000;
#6. Load all boot_to_qspi_alias_memory applcation
load mySrecFile;
#7. The encrypt argument (0) specifies the keyblob parameters range of one of the keyblob entries are left unencrypted.
encrypt(0) {
# Load alias QSPI image
load myBinFile > 0x68001000;
}
#8. Load the encrypted keyblob block to specified location.
# The keywrap statement wraps (encrypts) the keyblob specified in the argument (0) using the specified Key Encryption Key (KEK) and loads the keyblob to internal flas.
# The load destination (0x1000, which is defined via keyBlobPointer in BCA) must match the defualt location (0x410) or the keyblob pointer in the Bootloader Configuraion Area(BCA) contained in the SREC image.
# Make sure the sector at 0x1000 has not been written by the srec file load above, otherwise it will need to be erased again.
keywrap (0) {
load {{000102030405060708090a0b0c0d0e0f}} > 0x1000;
}
#9. Reset target.
reset;
}

View File

@@ -0,0 +1,40 @@
# The sources block assigns file names to identifiers
sources {
# SREC File path
mySrecFile = "boot_to_qspi_alias_memory_rom.srec";
# QCB file path
qspiConfigBlock = "qspi_config_block.bin";
# Alias QSPI image file path
myBinFile = "led_demo_qspi_alias_rom.bin";
}
# The section block specifies the sequence of boot commands to be written to
# the SB file
section (0) {
#1. Erase the vector table and flash config field.
erase 0..0x800;
# Step 2 and Step 3 are optional if the QuadSPI is configured at startup.
#2. Load the QCB to RAM
load qspiConfigBlock > 0x20000000;
#3. Configure QuadSPI with the QCB above
enable qspi 0x20000000;
#4. Erase the QuadSPI memory region before programming.
erase 0x68000000..0x68004000;
#5.Load the QCB above to the start address of QuadSPI memory
load qspiConfigBlock > 0x68000000;
#. Load all boot_to_qspi_alias_memory applcation
load mySrecFile;
#7. Load Alias QSPI image
load myBinFile > 0x68001000;
#8. Reset target.
reset;
}

Some files were not shown because too many files have changed in this diff Show More