├── .gitignore ├── Makefile ├── README.md ├── cyhostboot ├── Makefile ├── host_bootloader_src │ ├── cybtldr_api.c │ ├── cybtldr_api.h │ ├── cybtldr_api2.c │ ├── cybtldr_api2.h │ ├── cybtldr_command.c │ ├── cybtldr_command.h │ ├── cybtldr_parse.c │ ├── cybtldr_parse.h │ ├── cybtldr_utils.h │ └── readme.txt └── src │ ├── cyhostboot.c │ └── cyhostboot.ggo ├── ihex2cyacd ├── Makefile ├── src │ ├── ihex2cyacd.c │ └── ihex2cyacd.ggo └── test │ ├── Striplight_bootloadable.cyacd │ └── Striplight_bootloadable.hex └── make └── Makefile.cypress /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | ihex2cyacd/ihex2cyacd 3 | cyhostboot/cyhostboot 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: 3 | $(MAKE) -C cyhostboot all 4 | $(MAKE) -C ihex2cyacd all 5 | 6 | install: all 7 | $(MAKE) -C cyhostboot install 8 | $(MAKE) -C ihex2cyacd install 9 | 10 | clean: 11 | $(MAKE) -C cyhostboot clean 12 | $(MAKE) -C ihex2cyacd clean 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # DISCLAIMER 3 | 4 | This work is absolutely **not related** to cypress in any way. 5 | I am not to be liable for direct, indirect or consequential damages of your devices. 6 | 7 | ## Introduction 8 | 9 | This repository holds an attempt to port some tools of cypress under Linux. 10 | It allows to compile and upload application to some cypress boards. 11 | It has only been successfully tested with a CY8CKIT-049 42xx kit. 12 | (http://www.cypress.com/documentation/development-kitsboards/psoc-4-cy8ckit-049-4xxx-prototyping-kits) 13 | 14 | The prerequisites are the following: 15 | - `gengetopt` 16 | - `make` 17 | - `wine` (to run `cyelftool` when using makefile) 18 | - An arm toolchain (arm-none-eabi-) 19 | 20 | In order to build and install these utilities: 21 | 22 | ``` 23 | make all 24 | sudo make install 25 | ``` 26 | 27 | ## Host bootloader 28 | 29 | The host bootloader has been replicating using cypress source code for host bootloader. 30 | The Cypress Host Bootloader Tool is available as a command line utility and support various command 31 | To build it, the `make` command should be sufficient. 32 | 33 | ### Usage 34 | 35 | ``` 36 | Usage: cyhostboot [options] 37 | 38 | cyhostboot is a cypress host bootloader for Linux 39 | 40 | -h, --help Print help and exit 41 | -V, --version Print version and exit 42 | -b, --baudrate=INT Bootloader baudrate (default=`115200') 43 | -f, --file=STRING cyacd file to flash 44 | -s, --serial=STRING Serial port to use (default=`/dev/ttyACM0') 45 | -a, --app_id=INT Application id to use (0 for no change, or 1 or 2) 46 | (default=`0') 47 | -k, --key=STRING Security key for unlocking the bootloader in hex string 48 | like 01268bcf347c 49 | 50 | Group: Action 51 | Action to perform (default=`program`) 52 | -p, --program Program the file 53 | -e, --erase Erase memory 54 | -v, --verify Verify file 55 | 56 | Group: Parity 57 | Parity bit used for communication (default=`noparity`) 58 | -N, --noparity Do not use parity bit 59 | -E, --even Parity bit is even 60 | -O, --odd Parity bit is odd 61 | 62 | ``` 63 | 64 | ## iHex to cyacd format 65 | 66 | Thanks from https://github.com/gv1/hex2cyacd, the format is well explained and it was possible to write a C tool. 67 | ihex2cyacd is a an utility to create cyacd files from ihex files. 68 | Using the Makefile.cypress will hide the usage. 69 | 70 | ### Usage 71 | 72 | ``` 73 | 74 | -h, --help Print help and exit 75 | -V, --version Print version and exit 76 | -i, --input=STRING Input ihex file 77 | -b, --bootloader_size=INT Bootloader text size file 78 | -o, --output=STRING Output cyacd file 79 | -c, --cpu=ENUM CPU type (possible values="CY8C41", "CY8C42" 80 | default=`CY8C42') 81 | ``` 82 | 83 | ## Makefiles 84 | 85 | A Makefile.cypress file is available in the repository in order to easily compile cydsn projects. 86 | Two variable are required to be set which are PSOC_CREATOR_DIR and PROJECT_DIR. 87 | Additionnally, An ARM toolchain is necessary. Code Sourcery ones are sufficient. 88 | The easiest way to use it is to create a Makefile with the following content 89 | 90 | ``` 91 | PSOC_CREATOR_DIR := Path_to_PSoC_Creator 92 | PROJECT_DIR := Path_to_project.cydsn 93 | 94 | include Makefile.cypress 95 | 96 | ``` 97 | `cyelftool` is still used though wine (not reversed yet). 98 | 99 | Then type `make` to compile the application. 100 | Note that some old generated files may be outdated and can't compile. 101 | This typically happens when you change the name of a PSoC component and rebuild the application. 102 | Simply remove these files in order to compile again. 103 | 104 | The output files will be in the `build` directory. 105 | The final cyacd file can be flashed using `cyhostboot`. 106 | 107 | 108 | ## Notes 109 | 110 | The `cyelftool` cypress utility has not yet been reversed. 111 | However thanks to wine, this utility can be used under Linux. 112 | -------------------------------------------------------------------------------- /cyhostboot/Makefile: -------------------------------------------------------------------------------- 1 | HOST_BOOTLOADER_DIR := ./host_bootloader_src 2 | BUILD_DIR := ./build 3 | SRC_DIR := ./src 4 | 5 | SRC_FILES := $(wildcard $(HOST_BOOTLOADER_DIR)/*.c) 6 | OBJ_FILES := $(subst $(HOST_BOOTLOADER_DIR),$(BUILD_DIR),$(patsubst %.c,%.o,$(SRC_FILES))) 7 | HDR_FILES := $(wildcard $(BUILD_DIR)/*.h) 8 | 9 | ifeq ($(SRC_FILES),) 10 | dummy := $(error Please copy the host bootloader sources into $(HOST_BOOTLOADER_DIR)) 11 | endif 12 | 13 | CFLAGS := -I$(HOST_BOOTLOADER_DIR) -I$(BUILD_DIR) -DCALL_CON= -g -Wall 14 | LFLAGS := -lrt 15 | 16 | all: cyhostboot 17 | 18 | $(BUILD_DIR)/cyhostboot_cmdline.c: $(SRC_DIR)/cyhostboot.ggo 19 | gengetopt -i $< -F cyhostboot_cmdline --output-dir=$(BUILD_DIR)/ --func-name=cyhostboot_cmdline_parser -a cyhostboot_args_info 20 | 21 | $(BUILD_DIR)/%.o: $(HOST_BOOTLOADER_DIR)/%.c 22 | @mkdir -p $(BUILD_DIR) 23 | $(CC) -c -o $@ $^ $(CFLAGS) 24 | 25 | $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c 26 | @mkdir -p $(BUILD_DIR) 27 | $(CC) -c -o $@ $^ $(CFLAGS) 28 | 29 | cyhostboot: $(OBJ_FILES) $(SRC_DIR)/cyhostboot.c $(BUILD_DIR)/cyhostboot_cmdline.o 30 | $(CC) -o $@ $^ $(CFLAGS) $(LFLAGS) 31 | 32 | clean: 33 | rm -rf cyhostboot $(BUILD_DIR) 34 | 35 | install: 36 | cp cyhostboot /bin/ 37 | 38 | -------------------------------------------------------------------------------- /cyhostboot/host_bootloader_src/cybtldr_api.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011-2012, Cypress Semiconductor Corporation. All rights reserved. 3 | * You may use this file only in accordance with the license, terms, conditions, 4 | * disclaimers, and limitations in the end user license agreement accompanying 5 | * the software package with which this file was provided. 6 | ********************************************************************************/ 7 | 8 | #include "cybtldr_command.h" 9 | #include "cybtldr_api.h" 10 | 11 | /* The highest number of memory arrays for any device. This includes flash and EEPROM arrays */ 12 | #define MAX_DEV_ARRAYS 0x80 13 | /* The default value if a flash array has not yet received data */ 14 | #define NO_FLASH_ARRAY_DATA 0 15 | /* The maximum number of flash arrays */ 16 | #define MAX_FLASH_ARRAYS 0x40 17 | /* The minimum array id for EEPROM arrays. */ 18 | #define MIN_EEPROM_ARRAY 0x40 19 | 20 | unsigned long g_validRows[MAX_FLASH_ARRAYS]; 21 | static CyBtldr_CommunicationsData* g_comm; 22 | 23 | int CyBtldr_TransferData(unsigned char* inBuf, int inSize, unsigned char* outBuf, int outSize) 24 | { 25 | int err = g_comm->WriteData(inBuf, inSize); 26 | 27 | if (CYRET_SUCCESS == err) 28 | err = g_comm->ReadData(outBuf, outSize); 29 | 30 | if (CYRET_SUCCESS != err) 31 | err |= CYRET_ERR_COMM_MASK; 32 | 33 | return err; 34 | } 35 | 36 | int CyBtldr_ValidateRow(unsigned char arrayId, unsigned short rowNum) 37 | { 38 | unsigned long inSize; 39 | unsigned long outSize; 40 | unsigned short minRow = 0; 41 | unsigned short maxRow = 0; 42 | unsigned char inBuf[MAX_COMMAND_SIZE]; 43 | unsigned char outBuf[MAX_COMMAND_SIZE]; 44 | unsigned char status = CYRET_SUCCESS; 45 | int err = CYRET_SUCCESS; 46 | 47 | if (arrayId < MAX_FLASH_ARRAYS) 48 | { 49 | if (NO_FLASH_ARRAY_DATA == g_validRows[arrayId]) 50 | { 51 | err = CyBtldr_CreateGetFlashSizeCmd(arrayId, inBuf, &inSize, &outSize); 52 | if (CYRET_SUCCESS == err) 53 | err = CyBtldr_TransferData(inBuf, inSize, outBuf, outSize); 54 | if (CYRET_SUCCESS == err) 55 | err = CyBtldr_ParseGetFlashSizeCmdResult(outBuf, outSize, &minRow, &maxRow, &status); 56 | if (CYRET_SUCCESS != status) 57 | err = status | CYRET_ERR_BTLDR_MASK; 58 | 59 | if (CYRET_SUCCESS == err) 60 | { 61 | if (CYRET_SUCCESS == status) 62 | g_validRows[arrayId] = (minRow << 16) + maxRow; 63 | else 64 | err = status | CYRET_ERR_BTLDR_MASK; 65 | } 66 | } 67 | if (CYRET_SUCCESS == err) 68 | { 69 | minRow = (unsigned short)(g_validRows[arrayId] >> 16); 70 | maxRow = (unsigned short)g_validRows[arrayId]; 71 | if (rowNum < minRow || rowNum > maxRow) 72 | err = CYRET_ERR_ROW; 73 | } 74 | } 75 | else 76 | err = CYRET_ERR_ARRAY; 77 | 78 | return err; 79 | } 80 | 81 | 82 | int CyBtldr_StartBootloadOperation(CyBtldr_CommunicationsData* comm, unsigned long expSiId, 83 | unsigned char expSiRev, unsigned long* blVer, const unsigned char* securityKeyBuf) 84 | { 85 | const unsigned long SUPPORTED_BOOTLOADER = 0x010000; 86 | const unsigned long BOOTLOADER_VERSION_MASK = 0xFF0000; 87 | unsigned long i; 88 | unsigned long inSize = 0; 89 | unsigned long outSize = 0; 90 | unsigned long siliconId = 0; 91 | unsigned char inBuf[MAX_COMMAND_SIZE]; 92 | unsigned char outBuf[MAX_COMMAND_SIZE]; 93 | unsigned char siliconRev = 0; 94 | unsigned char status = CYRET_SUCCESS; 95 | int err; 96 | 97 | g_comm = comm; 98 | for (i = 0; i < MAX_FLASH_ARRAYS; i++) 99 | g_validRows[i] = NO_FLASH_ARRAY_DATA; 100 | 101 | err = g_comm->OpenConnection(); 102 | if (CYRET_SUCCESS != err) 103 | err |= CYRET_ERR_COMM_MASK; 104 | 105 | if (CYRET_SUCCESS == err) { 106 | err = CyBtldr_CreateEnterBootLoaderCmd(inBuf, &inSize, &outSize, securityKeyBuf); 107 | } 108 | if (CYRET_SUCCESS == err) { 109 | err = CyBtldr_TransferData(inBuf, inSize, outBuf, outSize); 110 | } 111 | if (CYRET_SUCCESS == err) { 112 | err = CyBtldr_ParseEnterBootLoaderCmdResult(outBuf, outSize, &siliconId, &siliconRev, blVer, &status); 113 | if (!err) { 114 | printf("Got silicon id 0x%08lx, rev 0x%02x\n", siliconId, siliconRev); 115 | } 116 | } else if (CyBtldr_TryParseParketStatus(outBuf, outSize, &status) == CYRET_SUCCESS) { 117 | err = status | CYRET_ERR_BTLDR_MASK; //if the response we get back is a valid packet overide the err with the response's status 118 | } 119 | if (CYRET_SUCCESS == err) 120 | { 121 | if (CYRET_SUCCESS != status) 122 | err = status | CYRET_ERR_BTLDR_MASK; 123 | if (expSiId != siliconId || expSiRev != siliconRev) 124 | err = CYRET_ERR_DEVICE; 125 | else if ((*blVer & BOOTLOADER_VERSION_MASK) != SUPPORTED_BOOTLOADER) 126 | err = CYRET_ERR_VERSION; 127 | } 128 | 129 | return err; 130 | } 131 | 132 | int CyBtldr_GetApplicationStatus(unsigned char appID, unsigned char* isValid, unsigned char* isActive) 133 | { 134 | unsigned long inSize = 0; 135 | unsigned long outSize = 0; 136 | unsigned char inBuf[MAX_COMMAND_SIZE]; 137 | unsigned char outBuf[MAX_COMMAND_SIZE]; 138 | unsigned char status = CYRET_SUCCESS; 139 | int err; 140 | 141 | err = CyBtldr_CreateGetAppStatusCmd(appID, inBuf, &inSize, &outSize); 142 | if (CYRET_SUCCESS == err) 143 | err = CyBtldr_TransferData(inBuf, inSize, outBuf, outSize); 144 | if (CYRET_SUCCESS == err) 145 | err = CyBtldr_ParseGetAppStatusCmdResult(outBuf, outSize, isValid, isActive, &status); 146 | 147 | if (CYRET_SUCCESS == err) 148 | { 149 | if (CYRET_SUCCESS != status) 150 | err = status | CYRET_ERR_BTLDR_MASK; 151 | } 152 | 153 | return err; 154 | } 155 | 156 | int CyBtldr_SetApplicationStatus(unsigned char appID) 157 | { 158 | unsigned long inSize = 0; 159 | unsigned long outSize = 0; 160 | unsigned char inBuf[MAX_COMMAND_SIZE]; 161 | unsigned char outBuf[MAX_COMMAND_SIZE]; 162 | unsigned char status = CYRET_SUCCESS; 163 | int err; 164 | 165 | err = CyBtldr_CreateSetActiveAppCmd(appID, inBuf, &inSize, &outSize); 166 | if (CYRET_SUCCESS == err) 167 | err = CyBtldr_TransferData(inBuf, inSize, outBuf, outSize); 168 | if (CYRET_SUCCESS == err) 169 | err = CyBtldr_ParseSetActiveAppCmdResult(outBuf, outSize, &status); 170 | 171 | if (CYRET_SUCCESS == err) 172 | { 173 | if (CYRET_SUCCESS != status) 174 | err = status | CYRET_ERR_BTLDR_MASK; 175 | } 176 | 177 | return err; 178 | } 179 | 180 | int CyBtldr_EndBootloadOperation(void) 181 | { 182 | unsigned long inSize; 183 | unsigned long outSize; 184 | unsigned char inBuf[MAX_COMMAND_SIZE]; 185 | 186 | int err = CyBtldr_CreateExitBootLoaderCmd(inBuf, &inSize, &outSize); 187 | if (CYRET_SUCCESS == err) 188 | { 189 | err = g_comm->WriteData(inBuf, inSize); 190 | 191 | if (CYRET_SUCCESS == err) 192 | err = g_comm->CloseConnection(); 193 | 194 | if (CYRET_SUCCESS != err) 195 | err |= CYRET_ERR_COMM_MASK; 196 | } 197 | g_comm = NULL; 198 | 199 | return err; 200 | } 201 | 202 | int CyBtldr_ProgramRow(unsigned char arrayID, unsigned short rowNum, unsigned char* buf, unsigned short size) 203 | { 204 | const int TRANSFER_HEADER_SIZE = 11; 205 | 206 | unsigned char inBuf[MAX_COMMAND_SIZE]; 207 | unsigned char outBuf[MAX_COMMAND_SIZE]; 208 | unsigned long inSize; 209 | unsigned long outSize; 210 | unsigned long offset = 0; 211 | unsigned short subBufSize; 212 | unsigned char status = CYRET_SUCCESS; 213 | int err = CYRET_SUCCESS; 214 | 215 | if (arrayID < MAX_FLASH_ARRAYS) 216 | err = CyBtldr_ValidateRow(arrayID, rowNum); 217 | 218 | //Break row into pieces to ensure we don't send too much for the transfer protocol 219 | while ((CYRET_SUCCESS == err) && ((size - offset + TRANSFER_HEADER_SIZE) > g_comm->MaxTransferSize)) 220 | { 221 | subBufSize = (unsigned short)(g_comm->MaxTransferSize - TRANSFER_HEADER_SIZE); 222 | 223 | err = CyBtldr_CreateSendDataCmd(&buf[offset], subBufSize, inBuf, &inSize, &outSize); 224 | if (CYRET_SUCCESS == err) 225 | err = CyBtldr_TransferData(inBuf, inSize, outBuf, outSize); 226 | if (CYRET_SUCCESS == err) 227 | err = CyBtldr_ParseSendDataCmdResult(outBuf, outSize, &status); 228 | if (CYRET_SUCCESS != status) 229 | err = status | CYRET_ERR_BTLDR_MASK; 230 | 231 | offset += subBufSize; 232 | } 233 | 234 | if (CYRET_SUCCESS == err) 235 | { 236 | subBufSize = (unsigned short)(size - offset); 237 | 238 | err = CyBtldr_CreateProgramRowCmd(arrayID, rowNum, &buf[offset], subBufSize, inBuf, &inSize, &outSize); 239 | if (CYRET_SUCCESS == err) 240 | err = CyBtldr_TransferData(inBuf, inSize, outBuf, outSize); 241 | if (CYRET_SUCCESS == err) 242 | err = CyBtldr_ParseProgramRowCmdResult(outBuf, outSize, &status); 243 | if (CYRET_SUCCESS != status) 244 | err = status | CYRET_ERR_BTLDR_MASK; 245 | } 246 | 247 | return err; 248 | } 249 | 250 | int CyBtldr_EraseRow(unsigned char arrayID, unsigned short rowNum) 251 | { 252 | unsigned char inBuf[MAX_COMMAND_SIZE]; 253 | unsigned char outBuf[MAX_COMMAND_SIZE]; 254 | unsigned long inSize = 0; 255 | unsigned long outSize = 0; 256 | unsigned char status = CYRET_SUCCESS; 257 | int err = CYRET_SUCCESS; 258 | 259 | if (arrayID < MAX_FLASH_ARRAYS) 260 | err = CyBtldr_ValidateRow(arrayID, rowNum); 261 | if (CYRET_SUCCESS == err) 262 | err = CyBtldr_CreateEraseRowCmd(arrayID, rowNum, inBuf, &inSize, &outSize); 263 | if (CYRET_SUCCESS == err) 264 | err = CyBtldr_TransferData(inBuf, inSize, outBuf, outSize); 265 | if (CYRET_SUCCESS == err) 266 | err = CyBtldr_ParseEraseRowCmdResult(outBuf, outSize, &status); 267 | if (CYRET_SUCCESS != status) 268 | err = status | CYRET_ERR_BTLDR_MASK; 269 | 270 | return err; 271 | } 272 | 273 | int CyBtldr_VerifyRow(unsigned char arrayID, unsigned short rowNum, unsigned char checksum) 274 | { 275 | unsigned char inBuf[MAX_COMMAND_SIZE]; 276 | unsigned char outBuf[MAX_COMMAND_SIZE]; 277 | unsigned long inSize = 0; 278 | unsigned long outSize = 0; 279 | unsigned char rowChecksum = 0; 280 | unsigned char status = CYRET_SUCCESS; 281 | int err = CYRET_SUCCESS; 282 | 283 | if (arrayID < MAX_FLASH_ARRAYS) 284 | err = CyBtldr_ValidateRow(arrayID, rowNum); 285 | if (CYRET_SUCCESS == err) 286 | err = CyBtldr_CreateVerifyRowCmd(arrayID, rowNum, inBuf, &inSize, &outSize); 287 | if (CYRET_SUCCESS == err) 288 | err = CyBtldr_TransferData(inBuf, inSize, outBuf, outSize); 289 | if (CYRET_SUCCESS == err) 290 | err = CyBtldr_ParseVerifyRowCmdResult(outBuf, outSize, &rowChecksum, &status); 291 | if (CYRET_SUCCESS != status) 292 | err = status | CYRET_ERR_BTLDR_MASK; 293 | if ((CYRET_SUCCESS == err) && (rowChecksum != checksum)) 294 | err = CYRET_ERR_CHECKSUM; 295 | 296 | return err; 297 | } 298 | 299 | int CyBtldr_VerifyApplication() 300 | { 301 | unsigned char inBuf[MAX_COMMAND_SIZE]; 302 | unsigned char outBuf[MAX_COMMAND_SIZE]; 303 | unsigned long inSize = 0; 304 | unsigned long outSize = 0; 305 | unsigned char checksumValid = 0; 306 | unsigned char status = CYRET_SUCCESS; 307 | 308 | int err = CyBtldr_CreateVerifyChecksumCmd(inBuf, &inSize, &outSize); 309 | if (CYRET_SUCCESS == err) 310 | err = CyBtldr_TransferData(inBuf, inSize, outBuf, outSize); 311 | if (CYRET_SUCCESS == err) 312 | err = CyBtldr_ParseVerifyChecksumCmdResult(outBuf, outSize, &checksumValid, &status); 313 | if (CYRET_SUCCESS != status) 314 | err = status | CYRET_ERR_BTLDR_MASK; 315 | if ((CYRET_SUCCESS == err) && (!checksumValid)) 316 | err = CYRET_ERR_CHECKSUM; 317 | 318 | return err; 319 | } 320 | -------------------------------------------------------------------------------- /cyhostboot/host_bootloader_src/cybtldr_api.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clementleger/cypress_linux_tools/da19a9bc2f65d1641305e4d729a6b7f7a39c01a3/cyhostboot/host_bootloader_src/cybtldr_api.h -------------------------------------------------------------------------------- /cyhostboot/host_bootloader_src/cybtldr_api2.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011-2012, Cypress Semiconductor Corporation. All rights reserved. 3 | * You may use this file only in accordance with the license, terms, conditions, 4 | * disclaimers, and limitations in the end user license agreement accompanying 5 | * the software package with which this file was provided. 6 | ********************************************************************************/ 7 | 8 | #include 9 | #include "cybtldr_parse.h" 10 | #include "cybtldr_command.h" 11 | #include "cybtldr_api.h" 12 | #include "cybtldr_api2.h" 13 | 14 | unsigned char g_abort; 15 | 16 | int CyBtldr_RunAction(CyBtldr_Action action, const char* file, const unsigned char* securityKey, 17 | unsigned char appId, CyBtldr_CommunicationsData* comm, CyBtldr_ProgressUpdate* update) 18 | { 19 | const unsigned long BL_VER_SUPPORT_VERIFY = 0x010214; /* Support for full flash verify added in v2.20 of cy_boot */ 20 | const unsigned char INVALID_APP = 0xFF; 21 | 22 | unsigned long blVer = 0; 23 | unsigned long siliconId = 0; 24 | unsigned short rowNum = 0; 25 | unsigned short bufSize = 0; 26 | unsigned char siliconRev = 0; 27 | unsigned char chksumtype = SUM_CHECKSUM; 28 | unsigned char checksum = 0; 29 | unsigned char checksum2 = 0; 30 | unsigned char arrayId = 0; 31 | unsigned char isValid; 32 | unsigned char isActive; 33 | unsigned char buffer[MAX_BUFFER_SIZE]; 34 | char line[MAX_BUFFER_SIZE]; 35 | unsigned int lineLen; 36 | int err; 37 | unsigned char bootloaderEntered = 0; 38 | 39 | g_abort = 0; 40 | 41 | err = CyBtldr_OpenDataFile(file); 42 | if (CYRET_SUCCESS == err) 43 | { 44 | err = CyBtldr_ReadLine(&lineLen, line); 45 | if (CYRET_SUCCESS == err) 46 | err = CyBtldr_ParseHeader(lineLen, line, &siliconId, &siliconRev, &chksumtype); 47 | 48 | if (CYRET_SUCCESS == err) 49 | { 50 | CyBtldr_SetCheckSumType(chksumtype); 51 | err = CyBtldr_StartBootloadOperation(comm, siliconId, siliconRev, &blVer, securityKey); 52 | bootloaderEntered = 1; 53 | } 54 | 55 | appId -= 1; /* 1 and 2 are legal inputs to function. 0 and 1 are valid for bootloader component */ 56 | if (appId > 1) 57 | { 58 | appId = INVALID_APP; 59 | } 60 | 61 | if ((CYRET_SUCCESS == err) && (appId != INVALID_APP)) 62 | { 63 | /* This will return error if bootloader is for single app */ 64 | err = CyBtldr_GetApplicationStatus(appId, &isValid, &isActive); 65 | 66 | /* Active app can be verified, but not programmed or erased */ 67 | if (CYRET_SUCCESS == err && VERIFY != action && isActive) 68 | { 69 | /* This is multi app */ 70 | err = CYRET_ERR_ACTIVE; 71 | } 72 | else if (CYBTLDR_STAT_ERR_CMD == (err ^ (int)CYRET_ERR_BTLDR_MASK)) 73 | { 74 | /* Single app - restore previous CYRET_SUCCESS */ 75 | err = CYRET_SUCCESS; 76 | } 77 | } 78 | 79 | if (CYRET_SUCCESS == err) 80 | { 81 | while (CYRET_SUCCESS == err) 82 | { 83 | if (g_abort) 84 | { 85 | err = CYRET_ABORT; 86 | break; 87 | } 88 | 89 | err = CyBtldr_ReadLine(&lineLen, line); 90 | if (CYRET_SUCCESS == err) 91 | err = CyBtldr_ParseRowData(lineLen, line, &arrayId, &rowNum, buffer, &bufSize, &checksum); 92 | if (CYRET_SUCCESS == err) 93 | { 94 | switch (action) 95 | { 96 | case ERASE: 97 | err = CyBtldr_EraseRow(arrayId, rowNum); 98 | break; 99 | case PROGRAM: 100 | err = CyBtldr_ProgramRow(arrayId, rowNum, buffer, bufSize); 101 | if (CYRET_SUCCESS != err) 102 | break; 103 | /* Continue on to verify the row that was programmed */ 104 | case VERIFY: 105 | checksum2 = (unsigned char)(checksum + arrayId + rowNum + (rowNum >> 8) + bufSize + (bufSize >> 8)); 106 | err = CyBtldr_VerifyRow(arrayId, rowNum, checksum2); 107 | break; 108 | } 109 | if (CYRET_SUCCESS == err && NULL != update) 110 | update(arrayId, rowNum); 111 | } 112 | else if (CYRET_ERR_EOF == err) 113 | { 114 | err = CYRET_SUCCESS; 115 | break; 116 | } 117 | } 118 | 119 | if (CYRET_SUCCESS == err) 120 | { 121 | /* Set the active application to what was just programmed */ 122 | if ((PROGRAM == action) && (INVALID_APP != appId)) 123 | { 124 | err = CyBtldr_GetApplicationStatus(appId, &isValid, &isActive); 125 | 126 | if (CYRET_SUCCESS == err) 127 | { 128 | /* If valid set the active application to what was just programmed */ 129 | /* This is multi app */ 130 | err = (0 == isValid) 131 | ? CyBtldr_SetApplicationStatus(appId) 132 | : CYRET_ERR_CHECKSUM; 133 | } 134 | else if (CYBTLDR_STAT_ERR_CMD == (err ^ (int)CYRET_ERR_BTLDR_MASK)) 135 | { 136 | /* Single app - restore previous CYRET_SUCCESS */ 137 | err = CYRET_SUCCESS; 138 | } 139 | } 140 | 141 | /* Verify that the entire application is valid */ 142 | else if ((PROGRAM == action || VERIFY == action) && (blVer >= BL_VER_SUPPORT_VERIFY)) 143 | err = CyBtldr_VerifyApplication(); 144 | } 145 | 146 | CyBtldr_EndBootloadOperation(); 147 | } 148 | else if (CYRET_ERR_COMM_MASK != (CYRET_ERR_COMM_MASK & err) && bootloaderEntered) 149 | CyBtldr_EndBootloadOperation(); 150 | 151 | CyBtldr_CloseDataFile(); 152 | } 153 | 154 | return err; 155 | } 156 | 157 | int CyBtldr_Program(const char* file, const unsigned char* securityKey, unsigned char appId, 158 | CyBtldr_CommunicationsData* comm, CyBtldr_ProgressUpdate* update) 159 | { 160 | return CyBtldr_RunAction(PROGRAM, file, securityKey, appId, comm, update); 161 | } 162 | 163 | int CyBtldr_Erase(const char* file, const unsigned char* securityKey, CyBtldr_CommunicationsData* comm, 164 | CyBtldr_ProgressUpdate* update) 165 | { 166 | return CyBtldr_RunAction(ERASE, file, securityKey, 0, comm, update); 167 | } 168 | 169 | int CyBtldr_Verify(const char* file, const unsigned char* securityKey, CyBtldr_CommunicationsData* comm, 170 | CyBtldr_ProgressUpdate* update) 171 | { 172 | return CyBtldr_RunAction(VERIFY, file, securityKey, 0, comm, update); 173 | } 174 | 175 | int CyBtldr_Abort(void) 176 | { 177 | g_abort = 1; 178 | return CYRET_SUCCESS; 179 | } 180 | -------------------------------------------------------------------------------- /cyhostboot/host_bootloader_src/cybtldr_api2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clementleger/cypress_linux_tools/da19a9bc2f65d1641305e4d729a6b7f7a39c01a3/cyhostboot/host_bootloader_src/cybtldr_api2.h -------------------------------------------------------------------------------- /cyhostboot/host_bootloader_src/cybtldr_command.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011-2012, Cypress Semiconductor Corporation. All rights reserved. 3 | * You may use this file only in accordance with the license, terms, conditions, 4 | * disclaimers, and limitations in the end user license agreement accompanying 5 | * the software package with which this file was provided. 6 | ********************************************************************************/ 7 | 8 | #include "cybtldr_command.h" 9 | 10 | 11 | /* Variable used to store the currently selected packet checksum type */ 12 | CyBtldr_ChecksumType CyBtldr_Checksum = SUM_CHECKSUM; 13 | 14 | unsigned short CyBtldr_ComputeChecksum(unsigned char* buf, unsigned long size) 15 | { 16 | if (CyBtldr_Checksum == CRC_CHECKSUM) 17 | { 18 | unsigned short crc = 0xffff; 19 | unsigned short tmp; 20 | int i; 21 | 22 | if (size == 0) 23 | return (~crc); 24 | 25 | do 26 | { 27 | for (i = 0, tmp = 0x00ff & *buf++; i < 8; i++, tmp >>= 1) 28 | { 29 | if ((crc & 0x0001) ^ (tmp & 0x0001)) 30 | crc = (crc >> 1) ^ 0x8408; 31 | else 32 | crc >>= 1; 33 | } 34 | } 35 | while (--size); 36 | 37 | crc = ~crc; 38 | tmp = crc; 39 | crc = (crc << 8) | (tmp >> 8 & 0xFF); 40 | 41 | return crc; 42 | } 43 | else /* SUM_CHECKSUM */ 44 | { 45 | unsigned short sum = 0; 46 | while (size-- > 0) 47 | sum += *buf++; 48 | 49 | return (1 + ~sum); 50 | } 51 | } 52 | 53 | void CyBtldr_SetCheckSumType(CyBtldr_ChecksumType chksumType) 54 | { 55 | CyBtldr_Checksum = chksumType; 56 | } 57 | 58 | int CyBtldr_ParseDefaultCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* status) 59 | { 60 | int err = CYRET_SUCCESS; 61 | if (cmdSize != BASE_CMD_SIZE) 62 | err = CYRET_ERR_LENGTH; 63 | else if (cmdBuf[1] != CYRET_SUCCESS) 64 | err = CYRET_ERR_BTLDR_MASK | (*status = cmdBuf[1]); 65 | else if (cmdBuf[0] != CMD_START || cmdBuf[2] != 0 || cmdBuf[3] != 0 || cmdBuf[6] != CMD_STOP) 66 | err = CYRET_ERR_DATA; 67 | else 68 | *status = cmdBuf[1]; 69 | 70 | return err; 71 | } 72 | 73 | int CyBtldr_CreateEnterBootLoaderCmd(unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize, const unsigned char* securityKeyBuf) 74 | { 75 | const unsigned long RESULT_DATA_SIZE = 8; 76 | const unsigned long BOOTLOADER_SECURITY_KEY_SIZE = 6; 77 | unsigned long commandDataSize; 78 | unsigned long i; 79 | unsigned short checksum; 80 | 81 | *resSize = BASE_CMD_SIZE + RESULT_DATA_SIZE; 82 | if (securityKeyBuf != NULL) 83 | commandDataSize = BOOTLOADER_SECURITY_KEY_SIZE; 84 | else 85 | commandDataSize = 0; 86 | *cmdSize = BASE_CMD_SIZE + commandDataSize; 87 | cmdBuf[0] = CMD_START; 88 | cmdBuf[1] = CMD_ENTER_BOOTLOADER; 89 | cmdBuf[2] = (unsigned char)commandDataSize; 90 | cmdBuf[3] = (unsigned char)(commandDataSize >> 8); 91 | for (i = 0; i < commandDataSize; i++) 92 | cmdBuf[i + 4] = securityKeyBuf[i]; 93 | checksum = CyBtldr_ComputeChecksum(cmdBuf, (*cmdSize) - 3); 94 | cmdBuf[*cmdSize - 3] = (unsigned char)checksum; 95 | cmdBuf[*cmdSize - 2] = (unsigned char)(checksum >> 8); 96 | cmdBuf[*cmdSize - 1] = CMD_STOP; 97 | 98 | return CYRET_SUCCESS; 99 | } 100 | 101 | int CyBtldr_ParseEnterBootLoaderCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned long* siliconId, unsigned char* siliconRev, unsigned long* blVersion, unsigned char* status) 102 | { 103 | const unsigned long RESULT_DATA_SIZE = 8; 104 | const unsigned long RESULT_SIZE = BASE_CMD_SIZE + RESULT_DATA_SIZE; 105 | int err = CYRET_SUCCESS; 106 | 107 | if (cmdSize != RESULT_SIZE) 108 | err = CYRET_ERR_LENGTH; 109 | else if (cmdBuf[1] != CYRET_SUCCESS) 110 | err = CYRET_ERR_BTLDR_MASK | (*status = cmdBuf[1]); 111 | else if (cmdBuf[0] != CMD_START || cmdBuf[2] != RESULT_DATA_SIZE || cmdBuf[3] != (RESULT_DATA_SIZE >> 8) || cmdBuf[RESULT_SIZE - 1] != CMD_STOP) 112 | err = CYRET_ERR_DATA; 113 | else 114 | { 115 | *siliconId = (cmdBuf[7] << 24) | (cmdBuf[6] << 16) | (cmdBuf[5] << 8) | cmdBuf[4]; 116 | *siliconRev = cmdBuf[8]; 117 | *blVersion = (cmdBuf[11] << 16) | (cmdBuf[10] << 8) | cmdBuf[9]; 118 | *status = cmdBuf[1]; 119 | } 120 | 121 | return err; 122 | } 123 | 124 | int CyBtldr_CreateExitBootLoaderCmd(unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize) 125 | { 126 | unsigned short checksum; 127 | 128 | *resSize = BASE_CMD_SIZE; 129 | *cmdSize = BASE_CMD_SIZE; 130 | cmdBuf[0] = CMD_START; 131 | cmdBuf[1] = CMD_EXIT_BOOTLOADER; 132 | cmdBuf[2] = 0; 133 | cmdBuf[3] = 0; 134 | checksum = CyBtldr_ComputeChecksum(cmdBuf, BASE_CMD_SIZE - 3); 135 | cmdBuf[4] = (unsigned char)checksum; 136 | cmdBuf[5] = (unsigned char)(checksum >> 8); 137 | cmdBuf[6] = CMD_STOP; 138 | 139 | return CYRET_SUCCESS; 140 | } 141 | 142 | int CyBtldr_CreateProgramRowCmd(unsigned char arrayId, unsigned short rowNum, unsigned char* buf, unsigned short size, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize) 143 | { 144 | const unsigned long COMMAND_DATA_SIZE = 3; 145 | unsigned int checksum; 146 | unsigned long i; 147 | 148 | *resSize = BASE_CMD_SIZE; 149 | *cmdSize = BASE_CMD_SIZE + COMMAND_DATA_SIZE + size; 150 | cmdBuf[0] = CMD_START; 151 | cmdBuf[1] = CMD_PROGRAM_ROW; 152 | cmdBuf[2] = (unsigned char)(size + COMMAND_DATA_SIZE); 153 | cmdBuf[3] = (unsigned char)((size + COMMAND_DATA_SIZE) >> 8); 154 | cmdBuf[4] = arrayId; 155 | cmdBuf[5] = (unsigned char)rowNum; 156 | cmdBuf[6] = (unsigned char)(rowNum >> 8); 157 | for (i = 0; i < size; i++) 158 | cmdBuf[i + 7] = buf[i]; 159 | checksum = CyBtldr_ComputeChecksum(cmdBuf, (*cmdSize) - 3); 160 | cmdBuf[*cmdSize - 3] = (unsigned char)checksum; 161 | cmdBuf[*cmdSize - 2] = (unsigned char)(checksum >> 8); 162 | cmdBuf[*cmdSize - 1] = CMD_STOP; 163 | 164 | return CYRET_SUCCESS; 165 | } 166 | 167 | int CyBtldr_ParseProgramRowCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* status) 168 | { 169 | return CyBtldr_ParseDefaultCmdResult(cmdBuf, cmdSize, status); 170 | } 171 | 172 | int CyBtldr_CreateVerifyRowCmd(unsigned char arrayId, unsigned short rowNum, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize) 173 | { 174 | const unsigned long RESULT_DATA_SIZE = 1; 175 | const unsigned long COMMAND_DATA_SIZE = 3; 176 | const unsigned int COMMAND_SIZE = BASE_CMD_SIZE + COMMAND_DATA_SIZE; 177 | unsigned short checksum; 178 | 179 | *resSize = BASE_CMD_SIZE + RESULT_DATA_SIZE; 180 | *cmdSize = COMMAND_SIZE; 181 | cmdBuf[0] = CMD_START; 182 | cmdBuf[1] = CMD_VERIFY_ROW; 183 | cmdBuf[2] = (unsigned char)COMMAND_DATA_SIZE; 184 | cmdBuf[3] = (unsigned char)(COMMAND_DATA_SIZE >> 8); 185 | cmdBuf[4] = arrayId; 186 | cmdBuf[5] = (unsigned char)rowNum; 187 | cmdBuf[6] = (unsigned char)(rowNum >> 8); 188 | checksum = CyBtldr_ComputeChecksum(cmdBuf, COMMAND_SIZE - 3); 189 | cmdBuf[7] = (unsigned char)checksum; 190 | cmdBuf[8] = (unsigned char)(checksum >> 8); 191 | cmdBuf[9] = CMD_STOP; 192 | 193 | return CYRET_SUCCESS; 194 | } 195 | 196 | int CyBtldr_ParseVerifyRowCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* checksum, unsigned char* status) 197 | { 198 | const unsigned long RESULT_DATA_SIZE = 1; 199 | const unsigned long RESULT_SIZE = BASE_CMD_SIZE + RESULT_DATA_SIZE; 200 | int err = CYRET_SUCCESS; 201 | 202 | if (cmdSize != RESULT_SIZE) 203 | err = CYRET_ERR_LENGTH; 204 | else if (cmdBuf[1] != CYRET_SUCCESS) 205 | err = CYRET_ERR_BTLDR_MASK | (*status = cmdBuf[1]); 206 | else if (cmdBuf[0] != CMD_START || cmdBuf[2] != RESULT_DATA_SIZE || cmdBuf[3] != (RESULT_DATA_SIZE >> 8) || cmdBuf[RESULT_SIZE - 1] != CMD_STOP) 207 | err = CYRET_ERR_DATA; 208 | else 209 | { 210 | *checksum = cmdBuf[4]; 211 | *status = cmdBuf[1]; 212 | } 213 | 214 | return err; 215 | } 216 | 217 | int CyBtldr_CreateEraseRowCmd(unsigned char arrayId, unsigned short rowNum, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize) 218 | { 219 | const unsigned long COMMAND_DATA_SIZE = 3; 220 | const unsigned int COMMAND_SIZE = BASE_CMD_SIZE + COMMAND_DATA_SIZE; 221 | unsigned short checksum; 222 | 223 | *resSize = BASE_CMD_SIZE; 224 | *cmdSize = COMMAND_SIZE; 225 | cmdBuf[0] = CMD_START; 226 | cmdBuf[1] = CMD_ERASE_ROW; 227 | cmdBuf[2] = (unsigned char)COMMAND_DATA_SIZE; 228 | cmdBuf[3] = (unsigned char)(COMMAND_DATA_SIZE >> 8); 229 | cmdBuf[4] = arrayId; 230 | cmdBuf[5] = (unsigned char)rowNum; 231 | cmdBuf[6] = (unsigned char)(rowNum >> 8); 232 | checksum = CyBtldr_ComputeChecksum(cmdBuf, COMMAND_SIZE - 3); 233 | cmdBuf[7] = (unsigned char)checksum; 234 | cmdBuf[8] = (unsigned char)(checksum >> 8); 235 | cmdBuf[9] = CMD_STOP; 236 | 237 | return CYRET_SUCCESS; 238 | } 239 | 240 | int CyBtldr_ParseEraseRowCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* status) 241 | { 242 | return CyBtldr_ParseDefaultCmdResult(cmdBuf, cmdSize, status); 243 | } 244 | 245 | int CyBtldr_CreateVerifyChecksumCmd(unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize) 246 | { 247 | const unsigned long RESULT_DATA_SIZE = 1; 248 | unsigned short checksum; 249 | 250 | *resSize = BASE_CMD_SIZE + RESULT_DATA_SIZE; 251 | *cmdSize = BASE_CMD_SIZE; 252 | cmdBuf[0] = CMD_START; 253 | cmdBuf[1] = CMD_VERIFY_CHECKSUM; 254 | cmdBuf[2] = 0; 255 | cmdBuf[3] = 0; 256 | checksum = CyBtldr_ComputeChecksum(cmdBuf, BASE_CMD_SIZE - 3); 257 | cmdBuf[4] = (unsigned char)checksum; 258 | cmdBuf[5] = (unsigned char)(checksum >> 8); 259 | cmdBuf[6] = CMD_STOP; 260 | 261 | return CYRET_SUCCESS; 262 | } 263 | 264 | int CyBtldr_ParseVerifyChecksumCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* checksumValid, unsigned char* status) 265 | { 266 | const unsigned long RESULT_DATA_SIZE = 1; 267 | const unsigned long RESULT_SIZE = BASE_CMD_SIZE + RESULT_DATA_SIZE; 268 | int err = CYRET_SUCCESS; 269 | 270 | if (cmdSize != RESULT_SIZE) 271 | err = CYRET_ERR_LENGTH; 272 | else if (cmdBuf[1] != CYRET_SUCCESS) 273 | err = CYRET_ERR_BTLDR_MASK | (*status = cmdBuf[1]); 274 | else if (cmdBuf[0] != CMD_START || cmdBuf[2] != RESULT_DATA_SIZE || cmdBuf[3] != (RESULT_DATA_SIZE >> 8) || cmdBuf[RESULT_SIZE - 1] != CMD_STOP) 275 | err = CYRET_ERR_DATA; 276 | else 277 | { 278 | *checksumValid = cmdBuf[4]; 279 | *status = cmdBuf[1]; 280 | } 281 | 282 | return err; 283 | } 284 | 285 | int CyBtldr_CreateGetFlashSizeCmd(unsigned char arrayId, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize) 286 | { 287 | const unsigned long RESULT_DATA_SIZE = 4; 288 | const unsigned long COMMAND_DATA_SIZE = 1; 289 | const unsigned int COMMAND_SIZE = BASE_CMD_SIZE + COMMAND_DATA_SIZE; 290 | unsigned short checksum; 291 | 292 | *resSize = BASE_CMD_SIZE + RESULT_DATA_SIZE; 293 | *cmdSize = COMMAND_SIZE; 294 | cmdBuf[0] = CMD_START; 295 | cmdBuf[1] = CMD_GET_FLASH_SIZE; 296 | cmdBuf[2] = (unsigned char)COMMAND_DATA_SIZE; 297 | cmdBuf[3] = (unsigned char)(COMMAND_DATA_SIZE >> 8); 298 | cmdBuf[4] = arrayId; 299 | checksum = CyBtldr_ComputeChecksum(cmdBuf, COMMAND_SIZE - 3); 300 | cmdBuf[5] = (unsigned char)checksum; 301 | cmdBuf[6] = (unsigned char)(checksum >> 8); 302 | cmdBuf[7] = CMD_STOP; 303 | 304 | return CYRET_SUCCESS; 305 | } 306 | 307 | int CyBtldr_ParseGetFlashSizeCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned short* startRow, unsigned short* endRow, unsigned char* status) 308 | { 309 | const unsigned long RESULT_DATA_SIZE = 4; 310 | const unsigned long RESULT_SIZE = BASE_CMD_SIZE + RESULT_DATA_SIZE; 311 | int err = CYRET_SUCCESS; 312 | 313 | if (cmdSize != RESULT_SIZE) 314 | err = CYRET_ERR_LENGTH; 315 | else if (cmdBuf[1] != CYRET_SUCCESS) 316 | err = CYRET_ERR_BTLDR_MASK | (*status = cmdBuf[1]); 317 | else if (cmdBuf[0] != CMD_START || cmdBuf[2] != RESULT_DATA_SIZE || cmdBuf[3] != (RESULT_DATA_SIZE >> 8) || cmdBuf[RESULT_SIZE - 1] != CMD_STOP) 318 | err = CYRET_ERR_DATA; 319 | else 320 | { 321 | *startRow = (cmdBuf[5] << 8) | cmdBuf[4]; 322 | *endRow = (cmdBuf[7] << 8) | cmdBuf[6]; 323 | *status = cmdBuf[1]; 324 | } 325 | 326 | return err; 327 | } 328 | 329 | int CyBtldr_CreateSendDataCmd(unsigned char* buf, unsigned short size, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize) 330 | { 331 | unsigned short checksum; 332 | unsigned long i; 333 | 334 | *resSize = BASE_CMD_SIZE; 335 | *cmdSize = size + BASE_CMD_SIZE; 336 | cmdBuf[0] = CMD_START; 337 | cmdBuf[1] = CMD_SEND_DATA; 338 | cmdBuf[2] = (unsigned char)size; 339 | cmdBuf[3] = (unsigned char)(size >> 8); 340 | for (i = 0; i < size; i++) 341 | cmdBuf[i + 4] = buf[i]; 342 | checksum = CyBtldr_ComputeChecksum(cmdBuf, (*cmdSize) - 3); 343 | cmdBuf[(*cmdSize) - 3] = (unsigned char)checksum; 344 | cmdBuf[(*cmdSize) - 2] = (unsigned char)(checksum >> 8); 345 | cmdBuf[(*cmdSize) - 1] = CMD_STOP; 346 | 347 | return CYRET_SUCCESS; 348 | } 349 | 350 | int CyBtldr_ParseSendDataCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* status) 351 | { 352 | return CyBtldr_ParseDefaultCmdResult(cmdBuf, cmdSize, status); 353 | } 354 | 355 | int CyBtldr_CreateSyncBootLoaderCmd(unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize) 356 | { 357 | unsigned short checksum; 358 | 359 | *resSize = BASE_CMD_SIZE; 360 | *cmdSize = BASE_CMD_SIZE; 361 | cmdBuf[0] = CMD_START; 362 | cmdBuf[1] = CMD_SYNC; 363 | cmdBuf[2] = 0; 364 | cmdBuf[3] = 0; 365 | checksum = CyBtldr_ComputeChecksum(cmdBuf, BASE_CMD_SIZE - 3); 366 | cmdBuf[4] = (unsigned char)checksum; 367 | cmdBuf[5] = (unsigned char)(checksum >> 8); 368 | cmdBuf[6] = CMD_STOP; 369 | 370 | return CYRET_SUCCESS; 371 | } 372 | 373 | int CyBtldr_CreateGetAppStatusCmd(unsigned char appId, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize) 374 | { 375 | const unsigned long RESULT_DATA_SIZE = 2; 376 | const unsigned long COMMAND_DATA_SIZE = 1; 377 | const unsigned int COMMAND_SIZE = BASE_CMD_SIZE + COMMAND_DATA_SIZE; 378 | unsigned short checksum; 379 | 380 | *resSize = BASE_CMD_SIZE + RESULT_DATA_SIZE; 381 | *cmdSize = COMMAND_SIZE; 382 | cmdBuf[0] = CMD_START; 383 | cmdBuf[1] = CMD_GET_APP_STATUS; 384 | cmdBuf[2] = (unsigned char)COMMAND_DATA_SIZE; 385 | cmdBuf[3] = (unsigned char)(COMMAND_DATA_SIZE >> 8); 386 | cmdBuf[4] = appId; 387 | checksum = CyBtldr_ComputeChecksum(cmdBuf, COMMAND_SIZE - 3); 388 | cmdBuf[5] = (unsigned char)checksum; 389 | cmdBuf[6] = (unsigned char)(checksum >> 8); 390 | cmdBuf[7] = CMD_STOP; 391 | 392 | return CYRET_SUCCESS; 393 | } 394 | 395 | int CyBtldr_ParseGetAppStatusCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* isValid, unsigned char* isActive, unsigned char* status) 396 | { 397 | const unsigned long RESULT_DATA_SIZE = 2; 398 | const unsigned long RESULT_SIZE = BASE_CMD_SIZE + RESULT_DATA_SIZE; 399 | int err = CYRET_SUCCESS; 400 | 401 | if (cmdSize != RESULT_SIZE) 402 | err = CYRET_ERR_LENGTH; 403 | else if (cmdBuf[1] != CYRET_SUCCESS) 404 | err = CYRET_ERR_BTLDR_MASK | (*status = cmdBuf[1]); 405 | else if (cmdBuf[0] != CMD_START || cmdBuf[2] != RESULT_DATA_SIZE || cmdBuf[3] != (RESULT_DATA_SIZE >> 8) || cmdBuf[RESULT_SIZE - 1] != CMD_STOP) 406 | err = CYRET_ERR_DATA; 407 | else 408 | { 409 | *isValid = cmdBuf[4]; 410 | *isActive = cmdBuf[5]; 411 | *status = cmdBuf[1]; 412 | } 413 | 414 | return err; 415 | } 416 | 417 | int CyBtldr_CreateSetActiveAppCmd(unsigned char appId, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize) 418 | { 419 | const unsigned long COMMAND_DATA_SIZE = 1; 420 | const unsigned int COMMAND_SIZE = BASE_CMD_SIZE + COMMAND_DATA_SIZE; 421 | unsigned short checksum; 422 | 423 | *resSize = BASE_CMD_SIZE; 424 | *cmdSize = COMMAND_SIZE; 425 | cmdBuf[0] = CMD_START; 426 | cmdBuf[1] = CMD_SET_ACTIVE_APP; 427 | cmdBuf[2] = (unsigned char)COMMAND_DATA_SIZE; 428 | cmdBuf[3] = (unsigned char)(COMMAND_DATA_SIZE >> 8); 429 | cmdBuf[4] = appId; 430 | checksum = CyBtldr_ComputeChecksum(cmdBuf, COMMAND_SIZE - 3); 431 | cmdBuf[5] = (unsigned char)checksum; 432 | cmdBuf[6] = (unsigned char)(checksum >> 8); 433 | cmdBuf[7] = CMD_STOP; 434 | 435 | return CYRET_SUCCESS; 436 | } 437 | 438 | int CyBtldr_ParseSetActiveAppCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* status) 439 | { 440 | return CyBtldr_ParseDefaultCmdResult(cmdBuf, cmdSize, status); 441 | } 442 | 443 | //Try to parse a packet to determine its validity, if valid then return set the status param to the packet's status. 444 | //Used to generate useful error messages. return 1 on success 0 otherwise. 445 | int CyBtldr_TryParseParketStatus(unsigned char* packet, int packetSize, unsigned char* status) 446 | { 447 | unsigned short dataSize; 448 | if (packet == NULL || packetSize < BASE_CMD_SIZE || packet[0] != CMD_START) 449 | return CYBTLDR_STAT_ERR_UNK; 450 | *status = packet[1]; 451 | dataSize = packet[2] | (packet[3] << 8); 452 | 453 | unsigned short readChecksum = packet[dataSize + 4] | (packet[dataSize + 5] << 8); 454 | unsigned short computedChecksum = CyBtldr_ComputeChecksum(packet, BASE_CMD_SIZE + dataSize - 3); 455 | 456 | if (packet[dataSize + BASE_CMD_SIZE - 1] != CMD_STOP || readChecksum != computedChecksum) 457 | return CYBTLDR_STAT_ERR_UNK; 458 | 459 | return CYRET_SUCCESS; 460 | } 461 | -------------------------------------------------------------------------------- /cyhostboot/host_bootloader_src/cybtldr_command.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011-2012, Cypress Semiconductor Corporation. All rights reserved. 3 | * You may use this file only in accordance with the license, terms, conditions, 4 | * disclaimers, and limitations in the end user license agreement accompanying 5 | * the software package with which this file was provided. 6 | ********************************************************************************/ 7 | 8 | #ifndef __CYBTLDR_COMMAND_H__ 9 | #define __CYBTLDR_COMMAND_H__ 10 | 11 | #include "cybtldr_utils.h" 12 | 13 | /* Maximum number of bytes to allocate for a single command. */ 14 | #define MAX_COMMAND_SIZE 512 15 | 16 | 17 | //STANDARD PACKET FORMAT: 18 | // Multi byte entries are encoded in LittleEndian. 19 | /******************************************************************************* 20 | * [1-byte] [1-byte ] [2-byte] [n-byte] [ 2-byte ] [1-byte] 21 | * [ SOP ] [Command] [ Size ] [ Data ] [Checksum] [ EOP ] 22 | *******************************************************************************/ 23 | 24 | 25 | /* The first byte of any boot loader command. */ 26 | #define CMD_START 0x01 27 | /* The last byte of any boot loader command. */ 28 | #define CMD_STOP 0x17 29 | /* The minimum number of bytes in a bootloader command. */ 30 | #define BASE_CMD_SIZE 0x07 31 | 32 | /* Command identifier for verifying the checksum value of the bootloadable project. */ 33 | #define CMD_VERIFY_CHECKSUM 0x31 34 | /* Command identifier for getting the number of flash rows in the target device. */ 35 | #define CMD_GET_FLASH_SIZE 0x32 36 | /* Command identifier for getting info about the app status. This is only supported on multi app bootloader. */ 37 | #define CMD_GET_APP_STATUS 0x33 38 | /* Command identifier for reasing a row of flash data from the target device. */ 39 | #define CMD_ERASE_ROW 0x34 40 | /* Command identifier for making sure the bootloader host and bootloader are in sync. */ 41 | #define CMD_SYNC 0x35 42 | /* Command identifier for setting the active application. This is only supported on multi app bootloader. */ 43 | #define CMD_SET_ACTIVE_APP 0x36 44 | /* Command identifier for sending a block of data to the bootloader without doing anything with it yet. */ 45 | #define CMD_SEND_DATA 0x37 46 | /* Command identifier for starting the boot loader. All other commands ignored until this is sent. */ 47 | #define CMD_ENTER_BOOTLOADER 0x38 48 | /* Command identifier for programming a single row of flash. */ 49 | #define CMD_PROGRAM_ROW 0x39 50 | /* Command identifier for verifying the contents of a single row of flash. */ 51 | #define CMD_VERIFY_ROW 0x3A 52 | /* Command identifier for exiting the bootloader and restarting the target program. */ 53 | #define CMD_EXIT_BOOTLOADER 0x3B 54 | 55 | /* 56 | * This enum defines the different types of checksums that can be 57 | * used by the bootloader for ensuring data integrety. 58 | */ 59 | typedef enum 60 | { 61 | /* Checksum type is a basic inverted summation of all bytes */ 62 | SUM_CHECKSUM = 0x00, 63 | /* 16-bit CRC checksum using the CCITT implementation */ 64 | CRC_CHECKSUM = 0x01, 65 | } CyBtldr_ChecksumType; 66 | 67 | /******************************************************************************* 68 | * Function Name: CyBtldr_ComputeChecksum 69 | ******************************************************************************** 70 | * Summary: 71 | * Computes the 2byte checksum for the provided command data. The checksum is 72 | * the 2's complement of the 1-byte sum of all bytes. 73 | * 74 | * Parameters: 75 | * buf - The data to compute the checksum on 76 | * size - The number of bytes contained in buf. 77 | * 78 | * Returns: 79 | * The checksum for the provided data. 80 | * 81 | *******************************************************************************/ 82 | unsigned short CyBtldr_ComputeChecksum(unsigned char* buf, unsigned long size); 83 | 84 | /******************************************************************************* 85 | * Function Name: CyBtldr_SetCheckSumType 86 | ******************************************************************************** 87 | * Summary: 88 | * Updates what checksum algorithm is used when generating packets 89 | * 90 | * Parameters: 91 | * chksumType - The type of checksum to use when creating packets 92 | * 93 | * Returns: 94 | * NA 95 | * 96 | *******************************************************************************/ 97 | void CyBtldr_SetCheckSumType(CyBtldr_ChecksumType chksumType); 98 | 99 | /******************************************************************************* 100 | * Function Name: CyBtldr_ParseDefaultCmdResult 101 | ******************************************************************************** 102 | * Summary: 103 | * Parses the output from any command that returns the default result packet 104 | * data. The default result is just a status byte 105 | * 106 | * Parameters: 107 | * cmdBuf - The preallocated buffer to store command data in. 108 | * cmdSize - The number of bytes in the command. 109 | * status - The status code returned by the bootloader. 110 | * 111 | * Returns: 112 | * CYRET_SUCCESS - The command was constructed successfully 113 | * CYRET_ERR_LENGTH - The packet does not contain enough data 114 | * CYRET_ERR_DATA - The packet's contents are not correct 115 | * 116 | *******************************************************************************/ 117 | int CyBtldr_ParseDefaultCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* status); 118 | 119 | /******************************************************************************* 120 | * Function Name: CyBtldr_CreateEnterBootLoaderCmd 121 | ******************************************************************************** 122 | * Summary: 123 | * Creates the command used to startup the bootloader. 124 | * NB: This command must be sent before the bootloader will respond to any 125 | * other command. 126 | * 127 | * Parameters: 128 | * protect - The flash protection settings. 129 | * cmdBuf - The preallocated buffer to store command data in. 130 | * cmdSize - The number of bytes in the command. 131 | * resSize - The number of bytes expected in the bootloader's response packet. 132 | * securityKeyBuff - The 6 byte or null bootloader security key 133 | * 134 | * Returns: 135 | * CYRET_SUCCESS - The command was constructed successfully 136 | * 137 | *******************************************************************************/ 138 | EXTERN int CyBtldr_CreateEnterBootLoaderCmd(unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize, const unsigned char* securityKeyBuff); 139 | 140 | /******************************************************************************* 141 | * Function Name: CyBtldr_ParseEnterBootLoaderCmdResult 142 | ******************************************************************************** 143 | * Summary: 144 | * Parses the output from the EnterBootLoader command to get the resultant 145 | * data. 146 | * 147 | * Parameters: 148 | * cmdBuf - The buffer containing the output from the bootloader. 149 | * cmdSize - The number of bytes in cmdBuf. 150 | * siliconId - The silicon ID of the device being communicated with. 151 | * siliconRev - The silicon Revision of the device being communicated with. 152 | * blVersion - The bootloader version being communicated with. 153 | * status - The status code returned by the bootloader. 154 | * 155 | * Returns: 156 | * CYRET_SUCCESS - The command was constructed successfully 157 | * CYRET_ERR_LENGTH - The packet does not contain enough data 158 | * CYRET_ERR_DATA - The packet's contents are not correct 159 | * 160 | *******************************************************************************/ 161 | EXTERN int CyBtldr_ParseEnterBootLoaderCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned long* siliconId, unsigned char* siliconRev, unsigned long* blVersion, unsigned char* status); 162 | 163 | /******************************************************************************* 164 | * Function Name: CyBtldr_CreateExitBootLoaderCmd 165 | ******************************************************************************** 166 | * Summary: 167 | * Creates the command used to stop communicating with the boot loader and to 168 | * trigger the target device to restart, running the new bootloadable 169 | * application. 170 | * 171 | * Parameters: 172 | * cmdBuf - The preallocated buffer to store command data in. 173 | * cmdSize - The number of bytes in the command. 174 | * resSize - The number of bytes expected in the bootloader's response packet. 175 | * 176 | * Returns: 177 | * CYRET_SUCCESS - The command was constructed successfully 178 | * 179 | *******************************************************************************/ 180 | EXTERN int CyBtldr_CreateExitBootLoaderCmd(unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize); 181 | 182 | /******************************************************************************* 183 | * Function Name: CyBtldr_CreateProgramRowCmd 184 | ******************************************************************************** 185 | * Summary: 186 | * Creates the command used to program a single flash row. 187 | * 188 | * Parameters: 189 | * arrayId - The array id to program. 190 | * rowNum - The row number to program. 191 | * buf - The buffer of data to program into the flash row. 192 | * size - The number of bytes in data for the row. 193 | * cmdBuf - The preallocated buffer to store command data in. 194 | * cmdSize - The number of bytes in the command. 195 | * resSize - The number of bytes expected in the bootloader's response packet. 196 | * 197 | * Returns: 198 | * CYRET_SUCCESS - The command was constructed successfully 199 | * 200 | *******************************************************************************/ 201 | EXTERN int CyBtldr_CreateProgramRowCmd(unsigned char arrayId, unsigned short rowNum, unsigned char* buf, unsigned short size, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize); 202 | 203 | /******************************************************************************* 204 | * Function Name: CyBtldr_ParseProgramRowCmdResult 205 | ******************************************************************************** 206 | * Summary: 207 | * Parses the output from the ProgramRow command to get the resultant 208 | * data. 209 | * 210 | * Parameters: 211 | * cmdBuf - The preallocated buffer to store command data in. 212 | * cmdSize - The number of bytes in the command. 213 | * status - The status code returned by the bootloader. 214 | * 215 | * Returns: 216 | * CYRET_SUCCESS - The command was constructed successfully 217 | * CYRET_ERR_LENGTH - The packet does not contain enough data 218 | * CYRET_ERR_DATA - The packet's contents are not correct 219 | * 220 | *******************************************************************************/ 221 | EXTERN int CyBtldr_ParseProgramRowCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* status); 222 | 223 | /******************************************************************************* 224 | * Function Name: CyBtldr_CreateVerifyRowCmd 225 | ******************************************************************************** 226 | * Summary: 227 | * Creates the command used to verify that the contents of flash match the 228 | * provided row data. 229 | * 230 | * Parameters: 231 | * arrayId - The array id to verify. 232 | * rowNum - The row number to verify. 233 | * cmdBuf - The preallocated buffer to store command data in. 234 | * cmdSize - The number of bytes in the command. 235 | * resSize - The number of bytes expected in the bootloader's response packet. 236 | * 237 | * Returns: 238 | * CYRET_SUCCESS - The command was constructed successfully 239 | * 240 | *******************************************************************************/ 241 | EXTERN int CyBtldr_CreateVerifyRowCmd(unsigned char arrayId, unsigned short rowNum, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize); 242 | 243 | /******************************************************************************* 244 | * Function Name: CyBtldr_ParseVerifyRowCmdResult 245 | ******************************************************************************** 246 | * Summary: 247 | * Parses the output from the VerifyRow command to get the resultant 248 | * data. 249 | * 250 | * Parameters: 251 | * cmdBuf - The preallocated buffer to store command data in. 252 | * cmdSize - The number of bytes in the command. 253 | * checksum - The checksum from the row to verify. 254 | * status - The status code returned by the bootloader. 255 | * 256 | * Returns: 257 | * CYRET_SUCCESS - The command was constructed successfully 258 | * CYRET_ERR_LENGTH - The packet does not contain enough data 259 | * CYRET_ERR_DATA - The packet's contents are not correct 260 | * 261 | *******************************************************************************/ 262 | EXTERN int CyBtldr_ParseVerifyRowCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* checksum, unsigned char* status); 263 | 264 | /******************************************************************************* 265 | * Function Name: CyBtldr_CreateEraseRowCmd 266 | ******************************************************************************** 267 | * Summary: 268 | * Creates the command used to erase a single flash row. 269 | * 270 | * Parameters: 271 | * arrayId - The array id to erase. 272 | * rowNum - The row number to erase. 273 | * cmdBuf - The preallocated buffer to store command data in. 274 | * cmdSize - The number of bytes in the command. 275 | * resSize - The number of bytes expected in the bootloader's response packet. 276 | * 277 | * Returns: 278 | * CYRET_SUCCESS - The command was constructed successfully 279 | * 280 | *******************************************************************************/ 281 | EXTERN int CyBtldr_CreateEraseRowCmd(unsigned char arrayId, unsigned short rowNum, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize); 282 | 283 | /******************************************************************************* 284 | * Function Name: CyBtldr_ParseEraseRowCmdResult 285 | ******************************************************************************** 286 | * Summary: 287 | * Parses the output from the EraseRow command to get the resultant 288 | * data. 289 | * 290 | * Parameters: 291 | * cmdBuf - The preallocated buffer to store command data in. 292 | * cmdSize - The number of bytes in the command. 293 | * status - The status code returned by the bootloader. 294 | * 295 | * Returns: 296 | * CYRET_SUCCESS - The command was constructed successfully 297 | * CYRET_ERR_LENGTH - The packet does not contain enough data 298 | * CYRET_ERR_DATA - The packet's contents are not correct 299 | * 300 | *******************************************************************************/ 301 | EXTERN int CyBtldr_ParseEraseRowCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* status); 302 | 303 | /******************************************************************************* 304 | * Function Name: CyBtldr_CreateVerifyChecksumCmd 305 | ******************************************************************************** 306 | * Summary: 307 | * Creates the command used to verify that the checkusm value in flash matches 308 | * what is expected. 309 | * 310 | * Parameters: 311 | * cmdBuf - The preallocated buffer to store command data in. 312 | * cmdSize - The number of bytes in the command. 313 | * resSize - The number of bytes expected in the bootloader's response packet. 314 | * 315 | * Returns: 316 | * CYRET_SUCCESS - The command was constructed successfully 317 | * 318 | *******************************************************************************/ 319 | EXTERN int CyBtldr_CreateVerifyChecksumCmd(unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize); 320 | 321 | /******************************************************************************* 322 | * Function Name: CyBtldr_ParseVerifyChecksumCmdResult 323 | ******************************************************************************** 324 | * Summary: 325 | * Parses the output from the VerifyChecksum command to get the resultant 326 | * data. 327 | * 328 | * Parameters: 329 | * cmdBuf - The preallocated buffer to store command data in. 330 | * cmdSize - The number of bytes in the command. 331 | * checksumValid - Whether or not the full checksums match (1 = valid, 0 = invalid) 332 | * status - The status code returned by the bootloader. 333 | * 334 | * Returns: 335 | * CYRET_SUCCESS - The command was constructed successfully 336 | * CYRET_ERR_LENGTH - The packet does not contain enough data 337 | * CYRET_ERR_DATA - The packet's contents are not correct 338 | * 339 | *******************************************************************************/ 340 | EXTERN int CyBtldr_ParseVerifyChecksumCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* checksumValid, unsigned char* status); 341 | 342 | /******************************************************************************* 343 | * Function Name: CyBtldr_CreateGetFlashSizeCmd 344 | ******************************************************************************** 345 | * Summary: 346 | * Creates the command used to retreive the number of flash rows in the device. 347 | * 348 | * Parameters: 349 | * arrayId - The array ID to get the flash size of. 350 | * cmdBuf - The preallocated buffer to store command data in. 351 | * cmdSize - The number of bytes in the command. 352 | * resSize - The number of bytes expected in the bootloader's response packet. 353 | * 354 | * Returns: 355 | * CYRET_SUCCESS - The command was constructed successfully 356 | * 357 | *******************************************************************************/ 358 | EXTERN int CyBtldr_CreateGetFlashSizeCmd(unsigned char arrayId, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize); 359 | 360 | /******************************************************************************* 361 | * Function Name: CyBtldr_ParseGetFlashSizeCmdResult 362 | ******************************************************************************** 363 | * Summary: 364 | * Parses the output from the GetFlashSize command to get the resultant 365 | * data. 366 | * 367 | * Parameters: 368 | * cmdBuf - The preallocated buffer to store command data in. 369 | * cmdSize - The number of bytes in the command. 370 | * startRow - The first available row number in the flash array. 371 | * endRow - The last available row number in the flash array. 372 | * status - The status code returned by the bootloader. 373 | * 374 | * Returns: 375 | * CYRET_SUCCESS - The command was constructed successfully 376 | * CYRET_ERR_LENGTH - The packet does not contain enough data 377 | * CYRET_ERR_DATA - The packet's contents are not correct 378 | * 379 | *******************************************************************************/ 380 | EXTERN int CyBtldr_ParseGetFlashSizeCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned short* startRow, unsigned short* endRow, unsigned char* status); 381 | 382 | /******************************************************************************* 383 | * Function Name: CyBtldr_CreateSendDataCmd 384 | ******************************************************************************** 385 | * Summary: 386 | * Creates the command used to send a block of data to the target. 387 | * 388 | * Parameters: 389 | * buf - The buffer of data data to program into the flash row. 390 | * size - The number of bytes in data for the row. 391 | * cmdBuf - The preallocated buffer to store command data in. 392 | * cmdSize - The number of bytes in the command. 393 | * resSize - The number of bytes expected in the bootloader's response packet. 394 | * 395 | * Returns: 396 | * CYRET_SUCCESS - The command was constructed successfully 397 | * 398 | *******************************************************************************/ 399 | EXTERN int CyBtldr_CreateSendDataCmd(unsigned char* buf, unsigned short size, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize); 400 | 401 | /******************************************************************************* 402 | * Function Name: CyBtldr_ParseSendDataCmdResult 403 | ******************************************************************************** 404 | * Summary: 405 | * Parses the output from the SendData command to get the resultant 406 | * data. 407 | * 408 | * Parameters: 409 | * cmdBuf - The preallocated buffer to store command data in. 410 | * cmdSize - The number of bytes in the command. 411 | * status - The status code returned by the bootloader. 412 | * 413 | * Returns: 414 | * CYRET_SUCCESS - The command was constructed successfully 415 | * CYRET_ERR_LENGTH - The packet does not contain enough data 416 | * CYRET_ERR_DATA - The packet's contents are not correct 417 | * 418 | *******************************************************************************/ 419 | EXTERN int CyBtldr_ParseSendDataCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* status); 420 | 421 | /******************************************************************************* 422 | * Function Name: CyBtldr_CreateSyncBootLoaderCmd 423 | ******************************************************************************** 424 | * Summary: 425 | * Creates the command used to ensure that the host application is in sync 426 | * with the bootloader application. 427 | * 428 | * Parameters: 429 | * cmdBuf - The preallocated buffer to store command data in. 430 | * cmdSize - The number of bytes in the command. 431 | * resSize - The number of bytes expected in the bootloader's response packet. 432 | * 433 | * Returns: 434 | * CYRET_SUCCESS - The command was constructed successfully 435 | * 436 | *******************************************************************************/ 437 | EXTERN int CyBtldr_CreateSyncBootLoaderCmd(unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize); 438 | 439 | /******************************************************************************* 440 | * Function Name: CyBtldr_CreateGetAppStatusCmd 441 | ******************************************************************************** 442 | * Summary: 443 | * Creates the command used to get information about the application. This 444 | * command is only supported by the multi application bootloaader. 445 | * 446 | * Parameters: 447 | * appId - The id for the application to get status for 448 | * cmdBuf - The preallocated buffer to store command data in. 449 | * cmdSize - The number of bytes in the command. 450 | * resSize - The number of bytes expected in the bootloader's response packet. 451 | * 452 | * Returns: 453 | * CYRET_SUCCESS - The command was constructed successfully 454 | * 455 | *******************************************************************************/ 456 | EXTERN int CyBtldr_CreateGetAppStatusCmd(unsigned char appId, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize); 457 | 458 | /******************************************************************************* 459 | * Function Name: CyBtldr_ParseGetAppStatusCmdResult 460 | ******************************************************************************** 461 | * Summary: 462 | * Parses the output from the GetAppStatus command to get the resultant 463 | * data. 464 | * 465 | * Parameters: 466 | * cmdBuf - The preallocated buffer to store command data in. 467 | * cmdSize - The number of bytes in the command. 468 | * isValid - Is the application valid. 469 | * isActive- Is the application currently marked as active. 470 | * status - The status code returned by the bootloader. 471 | * 472 | * Returns: 473 | * CYRET_SUCCESS - The command was constructed successfully 474 | * CYRET_ERR_LENGTH - The packet does not contain enough data 475 | * CYRET_ERR_DATA - The packet's contents are not correct 476 | * 477 | *******************************************************************************/ 478 | EXTERN int CyBtldr_ParseGetAppStatusCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* isValid, unsigned char* isActive, unsigned char* status); 479 | 480 | /******************************************************************************* 481 | * Function Name: CyBtldr_CreateSetActiveAppCmd 482 | ******************************************************************************** 483 | * Summary: 484 | * Creates the command used to set the active application for the bootloader 485 | * to run. This command is only supported by the multi application 486 | * bootloaader. 487 | * 488 | * Parameters: 489 | * appId - The id for the application to get status for 490 | * cmdBuf - The preallocated buffer to store command data in. 491 | * cmdSize - The number of bytes in the command. 492 | * resSize - The number of bytes expected in the bootloader's response packet. 493 | * 494 | * Returns: 495 | * CYRET_SUCCESS - The command was constructed successfully 496 | * 497 | *******************************************************************************/ 498 | EXTERN int CyBtldr_CreateSetActiveAppCmd(unsigned char appId, unsigned char* cmdBuf, unsigned long* cmdSize, unsigned long* resSize); 499 | 500 | /******************************************************************************* 501 | * Function Name: CyBtldr_ParseSetActiveAppCmdResult 502 | ******************************************************************************** 503 | * Summary: 504 | * Parses the output from the SetActiveApp command to get the resultant 505 | * data. 506 | * 507 | * Parameters: 508 | * cmdBuf - The preallocated buffer to store command data in. 509 | * cmdSize - The number of bytes in the command. 510 | * status - The status code returned by the bootloader. 511 | * 512 | * Returns: 513 | * CYRET_SUCCESS - The command was constructed successfully 514 | * CYRET_ERR_LENGTH - The packet does not contain enough data 515 | * CYRET_ERR_DATA - The packet's contents are not correct 516 | * 517 | *******************************************************************************/ 518 | EXTERN int CyBtldr_ParseSetActiveAppCmdResult(unsigned char* cmdBuf, unsigned long cmdSize, unsigned char* status); 519 | 520 | /******************************************************************************* 521 | * Function Name: CyBtldr_TryParseParketStatus 522 | ******************************************************************************** 523 | * Summary: 524 | * Parses the output packet data 525 | * 526 | * Parameters: 527 | * packet - The preallocated buffer to store command data in. 528 | * packetSize - The number of bytes in the command. 529 | * status - The status code returned by the bootloader. 530 | * 531 | * Returns: 532 | * CYRET_SUCCESS - The packet is a valid packet 533 | * CYBTLDR_STAT_ERR_UNK - The packet is not a valid packet 534 | * 535 | *******************************************************************************/ 536 | int CyBtldr_TryParseParketStatus(unsigned char* packet, int packetSize, unsigned char* status); 537 | #endif 538 | -------------------------------------------------------------------------------- /cyhostboot/host_bootloader_src/cybtldr_parse.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011-2012, Cypress Semiconductor Corporation. All rights reserved. 3 | * You may use this file only in accordance with the license, terms, conditions, 4 | * disclaimers, and limitations in the end user license agreement accompanying 5 | * the software package with which this file was provided. 6 | ********************************************************************************/ 7 | 8 | #include 9 | #include "cybtldr_parse.h" 10 | 11 | /* Pointer to the *.cyacd file containing the data that is to be read */ 12 | static FILE* dataFile; 13 | 14 | unsigned char CyBtldr_FromHex(char value) 15 | { 16 | if ('0' <= value && value <= '9') 17 | return (unsigned char)(value - '0'); 18 | if ('a' <= value && value <= 'f') 19 | return (unsigned char)(10 + value - 'a'); 20 | if ('A' <= value && value <= 'F') 21 | return (unsigned char)(10 + value - 'A'); 22 | return 0; 23 | } 24 | 25 | int CyBtldr_FromAscii(unsigned int bufSize, unsigned char* buffer, unsigned short* rowSize, unsigned char* rowData) 26 | { 27 | unsigned short i; 28 | int err = CYRET_SUCCESS; 29 | 30 | if (bufSize & 1) // Make sure even number of bytes 31 | err = CYRET_ERR_LENGTH; 32 | else 33 | { 34 | for (i = 0; i < bufSize / 2; i++) 35 | { 36 | rowData[i] = (CyBtldr_FromHex(buffer[i * 2]) << 4) | CyBtldr_FromHex(buffer[i * 2 + 1]); 37 | } 38 | *rowSize = i; 39 | } 40 | 41 | return err; 42 | } 43 | 44 | int CyBtldr_ReadLine(unsigned int* size, char* buffer) 45 | { 46 | int err = CYRET_SUCCESS; 47 | unsigned int len = 0; 48 | 49 | if (NULL != dataFile && !feof(dataFile)) 50 | { 51 | if (NULL != fgets(buffer, MAX_BUFFER_SIZE, dataFile)) 52 | { 53 | len = strlen(buffer); 54 | 55 | while (len > 0 && ('\n' == buffer[len - 1] || '\r' == buffer[len - 1])) 56 | --len; 57 | } 58 | else 59 | err = CYRET_ERR_EOF; 60 | } 61 | else 62 | err = CYRET_ERR_FILE; 63 | 64 | *size = len; 65 | return err; 66 | } 67 | 68 | int CyBtldr_OpenDataFile(const char* file) 69 | { 70 | dataFile = fopen(file, "r"); 71 | 72 | return (NULL == dataFile) 73 | ? CYRET_ERR_FILE 74 | : CYRET_SUCCESS; 75 | } 76 | 77 | int CyBtldr_ParseHeader(unsigned int bufSize, unsigned char* buffer, unsigned long* siliconId, unsigned char* siliconRev, unsigned char* chksum) 78 | { 79 | const unsigned int LENGTH_ID = 5; //4-silicon id, 1-silicon rev 80 | const unsigned int LENGTH_CHKSUM = LENGTH_ID + 1; //1-checksum type 81 | 82 | unsigned short rowSize; 83 | unsigned char rowData[MAX_BUFFER_SIZE]; 84 | 85 | int err = CyBtldr_FromAscii(bufSize, buffer, &rowSize, rowData); 86 | 87 | if (CYRET_SUCCESS == err) 88 | { 89 | if (rowSize >= LENGTH_CHKSUM) 90 | *chksum = rowData[5]; 91 | if (rowSize >= LENGTH_ID) 92 | { 93 | *siliconId = (rowData[0] << 24) | (rowData[1] << 16) | (rowData[2] << 8) | (rowData[3]); 94 | *siliconRev = rowData[4]; 95 | } 96 | else 97 | err = CYRET_ERR_LENGTH; 98 | } 99 | 100 | return err; 101 | } 102 | 103 | int CyBtldr_ParseRowData(unsigned int bufSize, unsigned char* buffer, unsigned char* arrayId, unsigned short* rowNum, unsigned char* rowData, unsigned short* size, unsigned char* checksum) 104 | { 105 | const unsigned short MIN_SIZE = 6; //1-array, 2-addr, 2-size, 1-checksum 106 | const int DATA_OFFSET = 5; 107 | 108 | unsigned int i; 109 | unsigned short hexSize; 110 | unsigned char hexData[MAX_BUFFER_SIZE]; 111 | int err = CYRET_SUCCESS; 112 | 113 | if (bufSize <= MIN_SIZE) 114 | err = CYRET_ERR_LENGTH; 115 | else if (buffer[0] == ':') 116 | { 117 | err = CyBtldr_FromAscii(bufSize - 1, &buffer[1], &hexSize, hexData); 118 | 119 | *arrayId = hexData[0]; 120 | *rowNum = (hexData[1] << 8) | (hexData[2]); 121 | *size = (hexData[3] << 8) | (hexData[4]); 122 | *checksum = (hexData[hexSize - 1]); 123 | 124 | if ((*size + MIN_SIZE) == hexSize) 125 | { 126 | for (i = 0; i < *size; i++) 127 | { 128 | rowData[i] = (hexData[DATA_OFFSET + i]); 129 | } 130 | } 131 | else 132 | err = CYRET_ERR_DATA; 133 | } 134 | else 135 | err = CYRET_ERR_CMD; 136 | 137 | return err; 138 | } 139 | 140 | int CyBtldr_CloseDataFile(void) 141 | { 142 | int err = 0; 143 | if (NULL != dataFile) 144 | { 145 | err = fclose(dataFile); 146 | dataFile = NULL; 147 | } 148 | return (0 == err) 149 | ? CYRET_SUCCESS 150 | : CYRET_ERR_FILE; 151 | } 152 | -------------------------------------------------------------------------------- /cyhostboot/host_bootloader_src/cybtldr_parse.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011-2012, Cypress Semiconductor Corporation. All rights reserved. 3 | * You may use this file only in accordance with the license, terms, conditions, 4 | * disclaimers, and limitations in the end user license agreement accompanying 5 | * the software package with which this file was provided. 6 | ********************************************************************************/ 7 | 8 | #ifndef __CYBTLDR_PARSE_H__ 9 | #define __CYBTLDR_PARSE_H__ 10 | 11 | #include "cybtldr_utils.h" 12 | 13 | /* Maximum number of bytes to allocate for a single row. */ 14 | /* NB: Rows should have a max of 592 chars (2-arrayID, 4-rowNum, 4-len, 576-data, 2-checksum, 4-newline) */ 15 | #define MAX_BUFFER_SIZE 768 16 | 17 | /******************************************************************************* 18 | * Function Name: CyBtldr_FromHex 19 | ******************************************************************************** 20 | * Summary: 21 | * Converts the provided ASCII char into its hexadecimal numerical equivilant. 22 | * 23 | * Parameters: 24 | * value - the ASCII char to convert into a number 25 | * 26 | * Returns: 27 | * The hexadecimal numerical equivilant of the provided ASCII char. If the 28 | * provided char is not a valid ASCII char, it will return 0. 29 | * 30 | *******************************************************************************/ 31 | unsigned char CyBtldr_FromHex(char value); 32 | 33 | /******************************************************************************* 34 | * Function Name: CyBtldr_FromAscii 35 | ******************************************************************************** 36 | * Summary: 37 | * Converts the provided ASCII array into its hexadecimal numerical equivilant. 38 | * 39 | * Parameters: 40 | * bufSize - The length of the buffer to convert 41 | * buffer - The buffer of ASCII characters to convert 42 | * rowSize - The number of bytes of equivilant hex data generated 43 | * rowData - The hex data generated for the buffer 44 | * 45 | * Returns: 46 | * CYRET_SUCCESS - The buffer was converted successfully 47 | * CYRET_ERR_LENGTH - The buffer does not have an even number of chars 48 | * 49 | *******************************************************************************/ 50 | int CyBtldr_FromAscii(unsigned int bufSize, unsigned char* buffer, unsigned short* rowSize, unsigned char* rowData); 51 | 52 | /******************************************************************************* 53 | * Function Name: CyBtldr_ReadLine 54 | ******************************************************************************** 55 | * Summary: 56 | * Reads a single line from the open data file. This function will remove 57 | * any Windows, Linux, or Unix line endings from the data. 58 | * 59 | * Parameters: 60 | * size - The number of bytes of data read from the line and stored in buffer 61 | * file - The preallocated buffer, with MAX_BUFFER_SIZE bytes, to store the 62 | * read data in. 63 | * 64 | * Returns: 65 | * CYRET_SUCCESS - The file was opened successfully. 66 | * CYRET_ERR_FILE - An error occurred opening the provided file. 67 | * CYRET_ERR_EOF - The end of the file has been reached 68 | * 69 | *******************************************************************************/ 70 | EXTERN int CyBtldr_ReadLine(unsigned int* size, char* buffer); 71 | 72 | /******************************************************************************* 73 | * Function Name: CyBtldr_OpenDataFile 74 | ******************************************************************************** 75 | * Summary: 76 | * Opens the provided file for reading. Once open, it is expected that the 77 | * first call will be to ParseHeader() to read the first line of data. After 78 | * that, successive calls to ParseRowData() are possible to read each line 79 | * of data, one at a time, from the file. Once all data has been read from 80 | * the file, a call to CloseDataFile() should be made to release resources. 81 | * 82 | * Parameters: 83 | * file - The full canonical path to the *.cyacd file to open 84 | * 85 | * Returns: 86 | * CYRET_SUCCESS - The file was opened successfully. 87 | * CYRET_ERR_FILE - An error occurred opening the provided file. 88 | * 89 | *******************************************************************************/ 90 | EXTERN int CyBtldr_OpenDataFile(const char* file); 91 | 92 | /******************************************************************************* 93 | * Function Name: CyBtldr_ParseHeader 94 | ******************************************************************************** 95 | * Summary: 96 | * Parses the hader information from the *.cyacd file. The header information 97 | * is stored as the first line, so this method should only be called once, 98 | * and only immediatly after calling OpenDataFile and reading the first line. 99 | * 100 | * Parameters: 101 | * bufSize - The number of bytes contained within buffer 102 | * buffer - The buffer containing the header data to parse 103 | * siliconId - The silicon ID that the provided *.cyacd file is for 104 | * siliconRev - The silicon Revision that the provided *.cyacd file is for 105 | * chksum - The type of checksum to use for packet integrety check 106 | * 107 | * Returns: 108 | * CYRET_SUCCESS - The file was opened successfully. 109 | * CYRET_ERR_LENGTH - The line does not contain enough data 110 | * 111 | *******************************************************************************/ 112 | EXTERN int CyBtldr_ParseHeader(unsigned int bufSize, unsigned char* buffer, unsigned long* siliconId, unsigned char* siliconRev, unsigned char* chksum); 113 | 114 | /******************************************************************************* 115 | * Function Name: CyBtldr_ParseRowData 116 | ******************************************************************************** 117 | * Summary: 118 | * Parses the contents of the provided buffer which is expected to contain 119 | * the row data from the *.cyacd file. This is expected to be called multiple 120 | * times. Once for each row of the *.cyacd file, excluding the header row. 121 | * 122 | * Parameters: 123 | * bufSize - The number of bytes contained within buffer 124 | * buffer - The buffer containing the row data to parse 125 | * arrayId - The flash array that the row of data belongs in 126 | * rowNum - The flash row number that the data corresponds to 127 | * rowData - The preallocated buffer to store the flash row data 128 | * size - The number of bytes of rowData 129 | * checksum - The checksum value for the entire row (rowNum, size, rowData) 130 | * 131 | * Returns: 132 | * CYRET_SUCCESS - The file was opened successfully. 133 | * CYRET_ERR_LENGTH - The line does not contain enough data 134 | * CYRET_ERR_DATA - The line does not contain a full row of data 135 | * CYRET_ERR_CMD - The line does not start with the cmd identifier ':' 136 | * 137 | *******************************************************************************/ 138 | EXTERN int CyBtldr_ParseRowData(unsigned int bufSize, unsigned char* buffer, unsigned char* arrayId, unsigned short* rowNum, unsigned char* rowData, unsigned short* size, unsigned char* checksum); 139 | 140 | /******************************************************************************* 141 | * Function Name: CyBtldr_CloseDataFile 142 | ******************************************************************************** 143 | * Summary: 144 | * Closes the data file pointer. 145 | * 146 | * Parameters: 147 | * void. 148 | * 149 | * Returns: 150 | * CYRET_SUCCESS - The file was opened successfully. 151 | * CYRET_ERR_FILE - An error occured opening the provided file. 152 | * 153 | *******************************************************************************/ 154 | EXTERN int CyBtldr_CloseDataFile(void); 155 | 156 | #endif 157 | -------------------------------------------------------------------------------- /cyhostboot/host_bootloader_src/cybtldr_utils.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clementleger/cypress_linux_tools/da19a9bc2f65d1641305e4d729a6b7f7a39c01a3/cyhostboot/host_bootloader_src/cybtldr_utils.h -------------------------------------------------------------------------------- /cyhostboot/host_bootloader_src/readme.txt: -------------------------------------------------------------------------------- 1 | This directory contains the source files for the Cypress-provided Bootloader Host Tool, which is used test out the bootloader running on a PSoC chip. For more information about this tool, refer to the Bootloader Host Tool documentation (F1 from the application). For more information about the source code in this directory, refer to the Bootloader Component Datasheet." -------------------------------------------------------------------------------- /cyhostboot/src/cyhostboot.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | 17 | #ifdef DEBUG 18 | #define dbg_printf(fmt, args...) printf(fmt, ## args) 19 | #else 20 | #define dbg_printf(fmt, args...) /* Don't do anything in release builds */ 21 | #endif 22 | 23 | #define TRANSFER_SIZE 64 24 | #define KEY_BYTES 6 25 | 26 | static struct cyhostboot_args_info args_info; 27 | 28 | /** 29 | * No context for callback itnerface... use a shared var. 30 | */ 31 | static int g_serial_fd = -1; 32 | 33 | static unsigned long long timespec_milliseconds(struct timespec *a) 34 | { 35 | return a->tv_sec*1000 + a->tv_nsec/1000000; 36 | } 37 | 38 | static speed_t get_serial_speed(int baudrate) 39 | { 40 | switch (baudrate) { 41 | case 9600: return B9600; 42 | case 19200: return B19200; 43 | case 38400: return B38400; 44 | case 57600: return B57600; 45 | case 115200: return B115200; 46 | default: 47 | printf("Invalid baudrate %d\n", baudrate); 48 | exit(EXIT_FAILURE); 49 | }; 50 | } 51 | 52 | static int serial_open() 53 | { 54 | speed_t baudrate = get_serial_speed(args_info.baudrate_arg); 55 | 56 | g_serial_fd = open(args_info.serial_arg, O_RDWR); 57 | if (g_serial_fd < 0) { 58 | printf("Failed to open serial: %s\n", strerror(errno)); 59 | return 1; 60 | } 61 | // setting default baud rate and attributes 62 | struct termios port_settings; 63 | memset (&port_settings, 0, sizeof(port_settings)); 64 | cfsetispeed (&port_settings, baudrate); 65 | cfsetospeed (&port_settings, baudrate); 66 | if (args_info.odd_given) { 67 | printf ("odd parity\n"); 68 | port_settings.c_cflag |= PARENB; // enable parity 69 | port_settings.c_cflag |= PARODD; // enable odd parity => enable odd parity 70 | } else if (args_info.even_given) { 71 | printf ( "even parity\n"); 72 | port_settings.c_cflag |= PARENB; // enable parity 73 | port_settings.c_cflag &= ~PARODD; // disable odd parity => enable even parity 74 | } else { 75 | printf ("no parity\n"); 76 | port_settings.c_cflag &= ~PARENB; // disable parity 77 | } 78 | port_settings.c_cflag &= ~CSTOPB; // disable extra stop bit => one stop bit 79 | port_settings.c_cflag |= CS8; // 8 bits per byte 80 | port_settings.c_cflag &= ~CRTSCTS; // Disable RTS/CTS hardware flow control 81 | port_settings.c_cflag |= CREAD | CLOCAL; // turn on read and disable ctrl lines 82 | port_settings.c_lflag &= ~ICANON; // disable canonical mode 83 | port_settings.c_lflag &= ~(ECHO | ECHOE | ECHONL); // disable any kind of echo 84 | port_settings.c_lflag &= ~ISIG; // disable interruption of INTR, QUIT and SUSP 85 | port_settings.c_iflag &= ~(IXON | IXOFF | IXANY); // turn off sw flow control 86 | port_settings.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL); // Disable any special handling of received bytes 87 | port_settings.c_oflag &= ~(OPOST); // Prevent special interpretation of output bytes (e.g. newline chars) 88 | port_settings.c_oflag &= ~ONLCR; // Prevent conversion of newline to carriage return/line feed 89 | port_settings.c_cc[VTIME] = 0; // do not wait, return immediately 90 | port_settings.c_cc[VMIN] = 0; // return as soon as some data 91 | if (tcsetattr(g_serial_fd, TCSAFLUSH, &port_settings) != 0) { 92 | printf ("Error %i from tcsetattr: %s\n", errno, strerror(errno)); 93 | return 1; 94 | } 95 | 96 | return CYRET_SUCCESS; 97 | } 98 | 99 | static int serial_close() 100 | { 101 | dbg_printf("Closing serial\n"); 102 | close(g_serial_fd); 103 | 104 | return CYRET_SUCCESS; 105 | } 106 | 107 | static int serial_read(unsigned char *bytes, int size) 108 | { 109 | struct timespec tp; 110 | unsigned long long start_milli = 0, end_milli = 0; 111 | ssize_t read_bytes; 112 | struct pollfd fds[1]; 113 | int poll_ret, i; 114 | unsigned int cur_byte = 0; 115 | 116 | while(1) { 117 | fds[0].revents = 0; 118 | fds[0].events = POLLIN | POLLPRI; 119 | fds[0].fd = g_serial_fd; 120 | 121 | clock_gettime(CLOCK_MONOTONIC, &tp); 122 | end_milli = timespec_milliseconds(&tp); 123 | /* If we have read at least one value, start timer before ending read */ 124 | if (start_milli && (end_milli - start_milli) > 100) 125 | break; 126 | 127 | /* Check if there is data to read from serial */ 128 | poll_ret = poll(fds, 1, 0); 129 | if (poll_ret == 0) { 130 | continue; 131 | } else if (poll_ret < 0) { 132 | printf("Poll error: %s\n", strerror(errno)); 133 | return 1; 134 | } 135 | 136 | /* Ok, we read some data, start the stop timer */ 137 | clock_gettime(CLOCK_MONOTONIC, &tp); 138 | start_milli = timespec_milliseconds(&tp); 139 | 140 | read_bytes = read(g_serial_fd, &bytes[cur_byte++], 1); 141 | if (read_bytes != 1) { 142 | return 1; 143 | } 144 | } 145 | dbg_printf("Read %d bytes\n", cur_byte); 146 | for(i = 0; i < cur_byte; i++) 147 | dbg_printf(" 0x%02x ", bytes[i]); 148 | dbg_printf("\n"); 149 | 150 | return CYRET_SUCCESS; 151 | } 152 | 153 | static int serial_write(unsigned char *bytes, int size) 154 | { 155 | int i; 156 | ssize_t write_bytes; 157 | 158 | dbg_printf("Serial: writing %d bytes to bootloader\n", size); 159 | for(i = 0; i< size; i++) 160 | dbg_printf(" 0x%02x ", bytes[i]); 161 | dbg_printf("\n"); 162 | write_bytes = write(g_serial_fd, bytes, size); 163 | if (write_bytes != size) { 164 | printf("Error when writing bytes\n"); 165 | return 1; 166 | } 167 | 168 | return CYRET_SUCCESS; 169 | } 170 | 171 | 172 | static CyBtldr_CommunicationsData serial_coms = { 173 | .OpenConnection = serial_open, 174 | .CloseConnection = serial_close, 175 | .ReadData = serial_read, 176 | .WriteData = serial_write, 177 | .MaxTransferSize = 64, 178 | }; 179 | 180 | 181 | static void serial_progress_update(unsigned char arrayId, unsigned short rowNum) 182 | { 183 | printf("Progress: array_id %d, row_num %d\n", arrayId, rowNum); 184 | } 185 | 186 | unsigned char sec_key[KEY_BYTES]; 187 | 188 | int main(int argc, char **argv) 189 | { 190 | int ret, action = PROGRAM; 191 | const char *action_str = "programing"; 192 | unsigned char *key = NULL; 193 | 194 | if (cyhostboot_cmdline_parser(argc, argv, &args_info) != 0) { 195 | return EXIT_FAILURE; 196 | } 197 | 198 | if (args_info.erase_given) { 199 | action = ERASE; 200 | action_str = "erasing"; 201 | } else if (args_info.verify_given) { 202 | action = VERIFY; 203 | action_str = "verifying"; 204 | } 205 | 206 | if (action == PROGRAM) 207 | printf("Programing file %s\n", args_info.file_arg); 208 | 209 | if (args_info.key_given) { 210 | char *start = args_info.key_arg; 211 | for (int i=0; i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #define MAX_IHEX_FILE_LENGTH 1024 12 | #define MAX_IHEX_BIN_SIZE (1 << 16) 13 | 14 | #ifdef DEBUG 15 | #define dbg_printf(fmt, args...) printf(fmt, ## args) 16 | #else 17 | #define dbg_printf(fmt, args...) /* Don't do anything in release builds */ 18 | #endif 19 | 20 | struct cyacd_header_info { 21 | uint32_t silicon_id; 22 | uint8_t silicon_rev; 23 | uint16_t flash_row_size; 24 | }; 25 | 26 | static struct cyacd_header_info header_infos[] = 27 | { 28 | [cpu_arg_CY8C41] = {0x04161193, 0x11, 128}, 29 | [cpu_arg_CY8C42] = {0x04C81193, 0x11, 128}, 30 | }; 31 | 32 | static struct ihex2cyacd_args_info args_info; 33 | 34 | #define get_line_chars(__str, __out_str, __n) \ 35 | __out_str[__n] = 0; \ 36 | strncpy(__out_str, __str, __n); \ 37 | __str += __n; 38 | 39 | static int parse_ihex_line(const char *line, uint8_t *length, uint32_t *addr, uint8_t *type, uint8_t data[MAX_IHEX_FILE_LENGTH]) 40 | { 41 | char tmp_buf[MAX_IHEX_FILE_LENGTH]; 42 | int i; 43 | uint8_t crc, sum = 0; 44 | 45 | if(line[0] != ':') { 46 | printf("Missing field start\n"); 47 | return 1; 48 | } 49 | line++; 50 | 51 | get_line_chars(line, tmp_buf, 2); 52 | *length = strtol(tmp_buf, NULL, 16); 53 | sum += *length; 54 | 55 | get_line_chars(line, tmp_buf, 4); 56 | *addr = strtol(tmp_buf, NULL, 16); 57 | sum += ((uint8_t) ((*addr) & 0xFF)); 58 | sum += ((uint8_t) (((*addr) >> 8) & 0xFF)); 59 | 60 | get_line_chars(line, tmp_buf, 2); 61 | *type = strtol(tmp_buf, NULL, 16); 62 | sum += *type; 63 | 64 | for( i = 0; i < *length; i++) { 65 | get_line_chars(line, tmp_buf, 2); 66 | data[i] = strtol(tmp_buf, NULL, 16); 67 | sum += data[i]; 68 | } 69 | 70 | get_line_chars(line, tmp_buf, 2); 71 | crc = strtol(tmp_buf, NULL, 16); 72 | sum += crc; 73 | 74 | if (sum != 0) { 75 | printf("CRC failed\n"); 76 | return 1; 77 | } 78 | 79 | return 0; 80 | } 81 | 82 | int main(int argc, char **argv) 83 | { 84 | uint32_t bootloader_text_rows; 85 | char *line_ptr; 86 | uint8_t data[MAX_IHEX_FILE_LENGTH], length, type; 87 | uint32_t addr; 88 | FILE *input_hex, *output_cyacd; 89 | struct cyacd_header_info *infos; 90 | size_t line_length = MAX_IHEX_FILE_LENGTH; 91 | int ret, i, line_empty; 92 | uint32_t cur_row_num; 93 | uint8_t crc; 94 | uint8_t *all_data; 95 | uint32_t last_addr = 0; 96 | 97 | if (ihex2cyacd_cmdline_parser(argc, argv, &args_info) != 0) { 98 | return EXIT_FAILURE; 99 | } 100 | 101 | input_hex = fopen(args_info.input_arg, "r"); 102 | if (!input_hex) { 103 | printf("Failed to open input file %s\n", args_info.input_arg); 104 | return 1; 105 | } 106 | output_cyacd = fopen(args_info.output_arg, "w+"); 107 | if (!output_cyacd) { 108 | printf("Failed to open output file %s\n", args_info.output_arg); 109 | return 1; 110 | } 111 | line_ptr = malloc(MAX_IHEX_FILE_LENGTH); 112 | if(!line_ptr) { 113 | printf("Failed to allocate data to read file\n"); 114 | return 1; 115 | } 116 | 117 | all_data = calloc(1, MAX_IHEX_BIN_SIZE); 118 | if(!all_data) { 119 | printf("Failed to allocate all data\n"); 120 | return 1; 121 | } 122 | 123 | infos = &header_infos[args_info.cpu_arg]; 124 | 125 | while (getline(&line_ptr, &line_length, input_hex) > 0) { 126 | ret = parse_ihex_line(line_ptr, &length, &addr, &type, data); 127 | if (ret) { 128 | printf("Failed to parse ihex file\n"); 129 | return 1; 130 | } 131 | line_length = MAX_IHEX_FILE_LENGTH; 132 | 133 | /* Skip non relevant line and bootloader reserved space one */ 134 | if (type != 00 || addr < args_info.bootloader_size_arg) 135 | continue; 136 | 137 | for (i = 0; i < length; i++) 138 | all_data[addr + i] = data[i]; 139 | 140 | if (addr > last_addr) 141 | last_addr = addr + length; 142 | } 143 | /* Write the output file */ 144 | 145 | /* Add cyacd header */ 146 | fprintf(output_cyacd, "%08X%02X00\r\n", infos->silicon_id, infos->silicon_rev); 147 | 148 | bootloader_text_rows = args_info.bootloader_size_arg / infos->flash_row_size; 149 | /* The result is not an integer, add one row */ 150 | if (args_info.bootloader_size_arg % infos->flash_row_size) 151 | bootloader_text_rows++; 152 | 153 | cur_row_num = bootloader_text_rows; 154 | 155 | for (addr = cur_row_num * infos->flash_row_size; addr < last_addr; addr += infos->flash_row_size) { 156 | line_empty = 1; 157 | /* Is the line empty ? */ 158 | for (i = 0; i < infos->flash_row_size; i++) { 159 | if (all_data[addr + i] != 0) { 160 | line_empty = 0; 161 | break; 162 | } 163 | } 164 | 165 | /* If so, skip it */ 166 | if (line_empty) { 167 | cur_row_num++; 168 | continue; 169 | } 170 | 171 | fprintf(output_cyacd, ":00%04X%04X", cur_row_num, infos->flash_row_size); 172 | crc = cur_row_num & 0xFF; 173 | crc += (cur_row_num >> 8) & 0xFF; 174 | crc += infos->flash_row_size & 0xFF; 175 | crc += (infos->flash_row_size >> 8) & 0xFF; 176 | 177 | for (i = 0; i < infos->flash_row_size; i++) { 178 | crc += all_data[addr + i]; 179 | fprintf(output_cyacd, "%02X", all_data[addr + i]); 180 | } 181 | 182 | crc = ~crc + 1; 183 | fprintf(output_cyacd, "%02X\r\n", crc); 184 | cur_row_num++; 185 | } 186 | 187 | fclose(input_hex); 188 | fclose(output_cyacd); 189 | 190 | 191 | return 0; 192 | } 193 | -------------------------------------------------------------------------------- /ihex2cyacd/src/ihex2cyacd.ggo: -------------------------------------------------------------------------------- 1 | package "ihex2cyacd" 2 | version "0.1" 3 | purpose "Utility to create cyacd files from ihex files" 4 | usage "ihex2cyacd [options]" 5 | 6 | description "ihex2cyacd is a an utility to create cyacd files" 7 | 8 | option "input" i "Input ihex file" string required 9 | option "bootloader_size" b "Bootloader text size file" int required 10 | option "output" o "Output cyacd file" string required 11 | option "cpu" c "CPU type" values="CY8C41","CY8C42" enum default="CY8C42" optional 12 | 13 | -------------------------------------------------------------------------------- /ihex2cyacd/test/Striplight_bootloadable.cyacd: -------------------------------------------------------------------------------- 1 | 04C811931100 2 | :000022008000100020111100002D1400002D14000080B500AF024B83F3088800F08BF9C0460010002080B500AF104B104A12688021C9020A431A60182000F056FA0B4B0B4A12680B490A401A600A4B0B4A1A600B4B10221A600A4B802212061A60094B0A4A1A600A4B00221A60BD4680BD00010B40FFFFFBFF04010B40060000800C02024042 3 | :000023008008010B4000000240100000800C020B4080B582B000AF72B64B4B01221A70FB1D00221A7023E0FB1D1A78131C5B009B185B00464A9B183B603B681A78597809020A43997809040A43DB781B061343191C3B681A795B791B0213439BB2081C191C00F0AEF9FB1D1A78FB1D01321A70FB1D1B78012BD7D9364A364B101C191C00F09C 4 | :0000240080AFF9354B354A1A60354B364A1A60364B364A1A60364B00221A60364B00221A60354B992212041A60344B802212061A60334B992212041A60324B334A1A60334B992212041A60324B8C22D2041A60314B05221A60304B06221A60304A2F4B1B78DBB202210B43DBB213702D4A2C4B1B78DBB23C218B43DBB214210B43DBB21370E5 5 | :0000250080264A264B1B78DBB216210B43DBB21370244BA0221A60244B244A1A60244B20221A60244B7F221A60234B244A1A60244B3C221A60234B244A1A60FFF733FF00F08FF9BD4602B080BD1C700F402C21000038210000602100000000014000009930040001403333330308000140003333000C0001400803044000500F4008500F400B 6 | :000026008010500F4018500F4000001E1320500F4028500F402000004000800F4000700F4001700F4000000440080004400010C300180004400001044008010440B66D1B000002044008020440806D030010B5064C2378002B07D1054B002B02D0044800E000BF0123237010BDE8000020000000002821000008B5084B002B03D0074808490C 7 | :000027008000E000BF07480368002B00D108BD064B002BFBD09847F9E70000000028210000EC000020D00000200000000080B582B000AF00F0EDFA00F0D3FD002000F094FC194B1B6E181C00F03BFC62B600233B6026E000237B601DE0C04600F06DFB031EFBD0114B1B6E181C00F02AFC0E4AAE235B00D35879683A68081C111C1A1C00F066 8 | :000028008051FC012000F008FB322000F089FA7B6801337B607B680B2BDEDD3B6801333B603B680B2BD5DDD1E70C24000080B500AFFEE7C04680B586B000AF224B7B61224B3B61204B7B6135E03B691B68FB603B695B68BB603B699B683B6000237B600CE0FB681A68BB681A60BB680433BB60FB680433FB607B6804337B607A683B689A427E 9 | :0000290080EED13B69DB683B6000237B6008E0BB6800221A60BB680433BB607B6804337B607A683B689A42F2D13B6910333B617B69013B7B617B69002BC6D100F007FEFFF775FFFEE701000000F027000080B582B000AF00237B600FE07B68032B04D8134B7A689200D35800E0114B124A796889008B507B6801337B607B682F2BECD9FFF7AE 10 | :00002A008047FE0D4B00221A600C4B1B68002B02D10A4B00221A608023DB058022D205126801210A431A60BD4602B080BD001100002D14000000000020C8000020C000002080B582B000AF786039607A683B68101C00211A1C00F0E0FDBD4602B080BDC04680B586B000AF7860396000233B6100237B612FE07B699B007A68D3181B68BB6033 11 | :00002B00800F23FB18BA681A70BB68FF229343BB6018E03B695B003A68D3181B781A1CBB68D318191C3B695B003A68D3185B780B703B6901333B610F23FB181A780F23FB18013A1A700F23FB181B78002BE1D17B6901337B617B69092BCCD9BD4606B080BD80B500AFBD4680BD90B585B000AF78607B68022B00D8BBE07B68302B00D9B7E0BE 12 | :00002C00805E4B1B78DBB21A1E7B689A420AD35C4A0F23FB1812781A705A4A0E23FB1812781A703FE0584B1B78DBB21A1E7B689A420AD3564A0F23FB1812781A70544A0E23FB1812781A702DE0524B1B78DBB21A1E7B689A420AD3504A0F23FB1812781A704E4A0E23FB1812781A701BE04C4B1B78DBB21A1E7B689A420AD34A4A0F23FB1837 13 | :00002D008012781A70484A0E23FB1812781A7009E0464A0F23FB1812781A70454A0E23FB1812781A707B68DA1E0C23FB1841498A5C1A700B23FC1800F0F1FC031C23700C23FB181B782F2B0DD97B682A2B0AD93A4B19221A60052000F0D7FC0D23FB1819221A7007E0344B1B68DAB20D23FB183F210A401A700C23FA180D23FB1812781B78CD 14 | :00002E00809A4208D22C4B7A68033A2A498A5C1A60052000F0B9FC294B7A6825498C4662441278D2B21A60264B0F22BA1812781A60244B0E22BA1812781A60052000F014F90C23FA180D23FB1812781B789A4208D9194B7A68033A17498A5C1A60052000F093FC0B23FB181B78181C00F09BFC02E0002000F0CBF8BD4605B090BDC0F1FF0F49 15 | :00002F0080C1F1FF0FC2F1FF0FC3F1FF0FC4F1FF0FC5F1FF0FC6F1FF0FC7F1FF0FC8F1FF0FC9F1FF0FCAF1FF0FCBF1FF0FCCF1FF0FCDF1FF0FDC2300002CFF0B4028FF0B401CFF0B4020FF0B4080B584B000AF021C3960FB1D1A7080239B05FB60FB1D1B781F2B02D9002000F091F8FB1D1B7810339B00FA68D3181B68BB60FB1D1B781033B2 16 | :00003000809B00FA68D3183A681A60BB68181CBD4604B080BD90B587B000AF021CFB1D1A70BB1D0A1C1A70BB1D1B78032B02D9002000F06CF8FB1D1B781F2B02D9002000F065F8FB1D1B7803221340DB0006337B611323FC1800F022FC031C2370FB1D1B789B08DBB29B00144A944663441B68FB607B6903229A40131CDA43FB681340FB60D9 17 | :0000310080BB1D1A787B699A40131CFA681343FB60FB1D1B789B08DBB29B00074A94466344FA681A601323FB181B78181C00F0FAFBBD4607B090BDC04600E400E080B582B000AF021CFB1D1A70054BFA1D12781F210A40012191400A1C1A60BD4602B080BD00E100E080B582B000AF021CFB1D1A70054BFA1D12781F210A40012191400A1CFA 18 | :00003200801A60BD4602B080BD80E100E080B582B000AF021CFB1D1A7001BEBD4602B080BD80B582B000AF786009E00C4B1B68181C00F0AAFB7B680A4A944663447B607A6880231B029A42F0D8064B1B687A685343181C00F099FBBD4602B080BDE00000200080FFFFD800002080B582B000AF021CBB1D1A80BB1D1B88044A12785343181C98 19 | :000033008000F082FBBD4602B080BDC046DC00002080B500AF174B03221A70174B1D221A70164B18221A70164B0E221A70154B01221A700023181C00F043F9124B00221A70002000F0D5F9002000F08EF90E4B1B78002B0AD10C4B01221A700C4B181C00F0F5F90B4B181C00F049FA0A4B01221A60BD4680BD91000F4041000F4021000F4050 20 | :000034008031000F4072000F4004010020811B0000E11A00006C03002080B584B000AF78607B68002B05D01B4B00221A601A4B00221A70184B1A681949131C5B009B181B015B58FB60164B1B681A1CFB68D3401A1C144B1B681340FB60134BFA68D2B21A70FB681B0AFB60104BFA68D2B21A70FB681B0AFB600C4BFA68D2B21A700B4B012237 21 | :00003500801A600B4B19221A700A4B00221A60BD4604B080BD0C01002070000F4024010020680300206403002042000F400801002072000F406C03002080B500AF064B1B68002B04D0054B00221A70012300E00023181CBD4680BDC0466C03002072000F4080B500AF1E4B1B680B2B34D81D4B19681B4B1A68501C1A4B18601B480B1C5B00CF 22 | :00003600805B189B009B189B001A58184B1A60174B1A68174B1B68DA40164B1B681A40134B1A60154A114B1B68DBB213700F4B1B681A0A0E4B1A60104A0C4B1B68DBB213700A4B1B681A0A094B1A600B4A074B1B68DBB2137002E0094B11221A70BD4680BD080100200C0100202401002014010020680300206403002042000F4072000F40D5 23 | :000037008080B500AF244B21221A70244B1B685A1C224B1A60214B1B680B2B38D8204A1F4B1B68DBB213701D4B1A681E49131C5B009B181B015A581C4B1A601B4B1A681B4B1B68DA401A4B1B681A40174B1A60194A154B1B68DBB21370134B1B681A0A124B1A60144A104B1B68DBB213700E4B1B681A0A0D4B1A600F4A0B4B1B68DBB2137066 24 | :00003800800D4B01221A60044B09221A7002E00B4B01221A60BD4680BD72000F400C01002070000F402401002018010020680300206403002042000F40080100206C03002080B584B000AF78600023FB6021E00023BB6018E01249FA68131C5B009B189B00BA689B189B007A685A500D49FA68131C5B009B189B00BA689B189B007A685A50F2 25 | :0000390080BB680133BB60BB680B2BE3D9FB680133FB60FB680B2BDAD9BD4604B080BDC0462401002080B584B000AFF860B9607A60FB68002B13DBBB68002B10DBFB680B2B0DDCBB680B2B0ADC0649BA68131C5B009B189B00FA689B189B007A685A50BD4604B080BD2401002080B582B000AF78607B68022B0FD002D8012B05D020E0032BC6 26 | :00003A008010D0042B15D01BE0124B134A1A60134B01221A601BE00F4B114A1A600F4B02221A6014E00B4B0F4A1A600C4B03221A600DE0084B0C4A1A60084B04221A6006E0044B0A4A1A60054B00221A60C046BD4602B080BD640300207F7F7F00680300203F3F3F001F1F1F000F0F0F00FFFFFF0080B582B000AF78607B68002B0CD10E4B04 27 | :00003B00800E4A1A600E4B05221A600E4B07221A600D4B20221A600CE0074B084A1A60084B05221A60074B07221A60074B20221A60C046BD4602B080BD78030020EC250000700300207C0300207403002080B582B000AF786000F048F87B68181C00F008F8032000F011F800F035F8BD4602B080BD80B582B000AF7860024B7A681A64BD460D 28 | :00003C008002B080BD0000002090B585B000AF021CFB1D1A700623FB600B23FC1800F03EF9031C23700A4B0A4A1268C0218A43111CFA1D1078FA689040021C0A431A600B23FB181B78181C00F02DF9BD4605B090BD00E400E080B500AF024B01221A60BD4680BDC04600E100E080B500AF024B01221A60BD4680BDC04680E100E080B582B081 29 | :00003D008000AF786000F04AF87B68181C00F008F8032000F011F800F037F8BD4602B080BD80B582B000AF7860024B7A689A64BD4602B080BD0000002090B585B000AF021CFB1D1A701623FB600B23FC1800F0E6F8031C23700A4B0A4A12680A491140FA1D1078FA689040021C0A431A600B23FB181B78181C00F0D6F8BD4605B090BDC0469C 30 | :00003E008000E400E0FFFF3FFF80B500AF024B04221A60BD4680BDC04600E100E080B500AF024B04221A60BD4680BDC04680E100E080B500AF00F034F8BD4680BD80B500AF064B064A1268802109060A431A6000F019F800F01FF8BD4680BDC0460000074080B500AF064B1B78002B04D1FFF7E0FF034B01221A70FFF7E1FFBD4680BDC04613 31 | :00003F00801C01002080B500AF0B20FFF797FCBD4680BDC04680B500AF00F064F8BD4680BD80B500AF1D4B1E4A1A601E4B00221A601D4B01221A601D4B1D4A1A601D4B07221A601D4B00221A601C4B01221A601C4B174A1A601B4B00221A600B20FFF782FC0B200321FFF716FC174B0B20191CFFF7EBFB164B00221A60154B00221A60154BF1 32 | :000040008000221A60144B00221A60144B00221A60134B00221A60BD4680BDC046000007400B000002400007404800074000030740070000800403074010030740440007400002074004020740B1200000880E0740C80E0740480F0740080F0740C80F0740880F074080B500AF054B054A126805490A40902109040A431A60BD4680BDC04647 33 | :000041008000000140FFFF0FFF0230800804D0C0460138FDD1C046C046C0467047EFF3108072B6704780F310887047C046C046C04680B500AF044B1B68002B02D0024B1B689847BD4680BDC046200100200E4B70B500251E1C0D4CE41AA410A54204D0AB00F35898470135F8E700F070FB084B00251E1C084CE41AA410A54204D0AB00F3582F 34 | :000042008098470135F8E770BDD8270000D8270000D8270000E0270000031C8218934202D019700133FAE770470000000000300F40000400400F40000404000F4051300F402C310F4046320F404A330F4009400F4017410F4007420F4004430F4002600F40011811182114310C0108020F03070507070809090B060C040D020E0B0F0D1F0F36 35 | :0000430080200B22042407260828062A09300831013201330234023508360437043E553F55580459045B045F01800183018404850289048A10924093019403950896389706980899069A269B089F01A241A902AB04AE40B020B207B301B418B640B70EB808BE40BF04C035C501C652C80DC9FFCAFFCBFFCDA0D804D904DA04DC99DD09DF01A5 36 | :0000440080E040E140E2C0E4C0E6C0014002800514068007400D020E2810A816021701186019A01D3E1E0120022202232426882F0832803614374139553C203D023F0845084F8854105640574068A8695587048DA0C079C270C49ECA20CCF8CEEFD040D210E21000210102032009040A490B900E210F571289146D1612170818A419571A5A07 37 | :00004500801B081E49224925A0275F28102A022D0130C0323833C03407350F373038203A023B884032460C47EB483449FF4AFF4BFF580459045A045B045C995D095F0162C0644065018101820785018B018C078D019F01A007A402A605A806AA01B101B201B402B604BE54BF01D804D904DF01014002800410068107010D800E6810A8164847 38 | :000046008019841A041E681F1023402411258027082E402F1032803610370839553C113F8044804520468047085680570A5C805F1066056D026F01760A81028204858086048B528D0491559A409E829F01A0A8A122A280A340A501A614A708A810AB20AC01AE01B20AB440C0D9C2F0C45ECA50CC68CEBFD060D630D8C0E230E801EA40EC08F3 39 | :0000470080EE8063086F02730887208C02D840DA80DC20E2405080564058025A805F2064016608840186408A088E4098029B20A080A880AF02B308B704D4E0D6E0D880E250EA3054405B145C088F10D403D603E402AB04AC08B040EC0402011101030405060708090A0B0C0E0F101112131415161718191B1C1D1E1F20212223252627282943 40 | :00004800802A2B2E2F3031323334350000FFFF0000FFCC0000FF990000FF330000FF000000B3006600990099006600B3003300CC001919B3000033990000409900006699000099990000CC990000E6660000FF000033FF000066FF000080FF000099FF0000B2FF0000CCFF0000E5FF000000000000000055000000AA000000FF005500000096 41 | :0000490080550055005500AA005500FF00AA000000AA005500AA00AA00AA00FF00FF000000FF005500FF00AA00FF00FF0000550000005555000055AA000055FF0055550000555555005555AA005555FF00AA550000AA555500AA55AA00AA55FF00FF550000FF555500FF55AA00FF55FF0000AA000000AA550000AAAA0000AAFF0055AA0000B5 42 | :00004A008055AA550055AAAA0055AAFF00AAAA0000AAAA5500AAAAAA00AAAAFF00FFAA0000FFAA5500FFAAAA00FFAAFF0000FF000000FF550000FFAA0000FFFF0055FF000055FF550055FFAA0055FFFF00AAFF0000AAFF5500AAFFAA00AAFFFF00FFFF0000FFFF5500FFFFAA00FFFFFF00FF800000FF008000FF00FF008000FF000080FF0071 43 | :00004B008000FF8000FF0000002020200000002000000000100000000000000000000000000000000000000000000000000000FF000010F0000020E0000030D0000040C0000050B0000060A00000709000008080000090700000A0600000B0500000C0400000D0300000E0200000FF0000000000000000005F00000007000700147F147F1482 44 | :00004C0080242A7F2A12231308646236495522500005030000001C2241000041221C00082A1C2A0808083E080800503000000808080808006060000020100804023E5149453E00427F400042615149462141454B311814127F1027454545393C4A49493001710905033649494936064949291E003636000000563600000008142241141414B5 45 | :00004D0080141441221408000201510906324979413E7E1111117E7F494949363E414141227F4141221C7F494949417F090901013E414151327F0808087F00417F41002040413F017F081422417F404040407F0204027F7F0408107F3E4141413E7F090909063E4151215E7F09192946464949493101017F01013F4040403F1F2040201F7F01 46 | :00004E00802018207F63140814630304780403615149454300007F4141020408102041417F000004020102044040404040000102040020545454787F484444383844444420384444487F3854545418087E090102081454543C7F0804047800447D40002040443D00007F10284400417F40007C041804787C0804047838444444387C14141434 47 | :00004F008008081414187C7C080404084854545420043F4440203C4040207C1C2040201C3C4030403C44281028440C5050503C4464544C44000836410000007F0000004136080008082A1C08081C2A0808F8B5C046F8BC08BC9E46704775130000CD140000F8B5C046F8BC08BC9E4670474D13000000280000D000002018000000980200004A 48 | :00005000800000000000366E01C05D0000180000000000E02E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000048 49 | :0000FF008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C8111100002100000080170000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DE 50 | -------------------------------------------------------------------------------- /ihex2cyacd/test/Striplight_bootloadable.hex: -------------------------------------------------------------------------------- 1 | :400000000010002011000000B5030000B503000008B500F081FA00F0CFF90000F7B572B680220021D200554800F0EDFF802200215348D20000F0E7FF0023191C514C1859E1 2 | :400040001034C2B20192071CFF2297434A00A4180022019ED5B2AE4209D05500665D6519B446BC446D78664635700132F1E7C0B204330918102BE1D1434BC02292041A60F8 3 | :40008000424B99221A60424A00231360414A80211160414AC9031160404A40211160404AC021490311603F4A312113603E4B02221A603E4B802019603D4B3E491A60992317 4 | :4000C0001B040B603C49000608603C493C200B603B4B8021890519603A493B4B19603B4B19780A431A703A4A117881431420014311701A7816210A431A70364A8023116893 5 | :40010000DB020B431360344B141C1878334BC0B21978334BC9B21A78172A05D9314A58789978033B9342F6D12F4B192218602F4B052019602E4B1A6000F05EFD2D4B052061 6 | :400140001A782D4BD2B21A6000F09EFE22682B4B134023602A4A2B4B1A602B4B10221A602A4B20221A602A4B802212061A60294A294B1A60294A2A4B1A60F7BD00300F40BF 7 | :4001800000400F402410000004000140100001400C000140000004400800044000010440080104400803044000040440080404401804044000500F4004500F4010500F403F 8 | :4001C00018500F40100001002001054000700F4001700F4000010B40CCF1FF0FCDF1FF0FC9F1FF0FBDF1FF0F1CFF0B4020FF0B402CFF0B40E5F1FF0F28FF0B40FFFFFBFF57 9 | :400200000600008004010B40080202402002024008010B401000008000000240AF0400804000024010B5064C2378002B07D1054B002B02D0044800E000BF0123237010BDEC 10 | :40024000F0000020000000002010000008B5084B002B03D00748084900E000BF07480368002B03D0064B002B00D0984708BDC0460000000020100000F4000020D00000200F 11 | :400280000000000010B562B600F0ACFC00280ED16524012000F0E2FD00F0A4FC002806D1013CE4B2002CF4D1034B40221A6000F08BFC00F0DBFAFEE7C000002008B500F01E 12 | :4002C00015FB00F04DFB00F0B5FB08BD70B5054B0D1C161C0024C9B21C8000F09FFB3580201C70BD0C010020F0B50A275F4387B003900591151C00262D4CBE4219DA00F0E6 13 | :400300001DFB80B220802388002B0CD00220268800F0A4FD00F012FB80B220802388B6B2B342F3D807E00120013600F097FDB6B2E2E7052600E0002600272F802388002B4D 14 | :4003400033D023889BB2019301992B885A18059992B22A808A4221D2019ABB189BB2029302998F4209D07B1C9BB20493039BDF1900F0CAFA3870049FF2E772B62388019AF8 15 | :400380009B1A9BB2238062B6039A5318013B1B78172B08D0052000F061FD04E02B8000F0DFFA052601E0029FC8E7301C07B0F0BD0C010020FEE7000070B51048104B013895 16 | :4003C000421C15D01E685C689D680022A118AA4203D0B158A1500432F8E7DA680D1C4C1B944202D0002410C1F9E710330138E7E700F0DAFDFFF746FFFEE7C046010000003B 17 | :400400007410000008B500239A00032B02D80D49895800E00C490D4801338150302BF3D1FFF7FCFD0A4B00221A600A4B1A68002A00D11A608023DB051A6801210A431A60B7 18 | :4004400008BDC04600000000B503000000000020C8000020C0000020004770B5051C0E1C141C002802D0002000F0EAFC0020002C05D0013CAA19125D8318D8B2F7E770BD7A 19 | :40048000013808B509282AD8C901494200F078FD0507090B0D0F1614181B154B08E0154B12E0154B0DE0154B0EE0154B00E0154BC9180878C0B21AE0134B02E0134B00E0A0 20 | :4004C000134BC9180FE0134BC9180B7848788A780002120410431843CB781B0606E0002000F0AEFC00210B7848780002184308BDC07F0000C17F0000C57F0000C97F0000EF 21 | :40050000D07F0000D17F0000D67F0000D27F0000D47F0000D87F00000C4B10B51A6810231A400B4B00D11A601A68802A0DD100240220211C1C60FFF7A3FFA04205D0211C6B 22 | :400540000220FFF79DFFFFF787FF10BD00030B40C0000020F8B5051C291C0320FFF790FF291C041C0420FFF78BFF671CFF013F18291C0320FFF784FF00240130C001261C79 23 | :40058000B84209D203785A1ED2B2FD2A00D801261C19E4B20130F3E70120291CFFF770FF6442E4B20623844203D17242564176423340181CF8BD0000F0B5A44CA544FFF756 24 | :4005C0007DFE62B600260096002506AC03AE9621201C4900321CFF23FFF786FE0028F4D13188062900D88AE022780423012A54D1E778A2783F021743E2195679B44616796F 25 | :400600000196FE1D8E427FD89279172A45D1FB189BB2002B08D09CA98D4ECA1892191278013B801880B2F3E7019B614640420A0280B21A43082382422FD167E0342B00D040 26 | :400640009DE0009901295AD1032F58D151A80021802200F0D8FC802551A948192639ED19FA1EFF39ADB200F0C5FC832D49D1A079637900021843774B36021B6880191A68BB 27 | :4006800080B2D3099BB2560601D001339BB298427BD20127009700250A2300210120207068466A46437681766B4600200E32D8760B1D11809BB29CAFFE18654F013BF61954 28 | :4006C00036789BB2801980B2002BF4D19CAE624F7318DE194042614F80B23070DE19000A30705F4807311B181720187089B2201C9623FFF7EBFD68E7009E012E1BD0042315 29 | :40070000CBE70126009600250323C6E763782679181C31380A2801D90523BEE700F03AFCECFF1400FCFF8EFF3F00FCFF430054008EFF63008B00002FE1D1381CFFF70AFF35 30 | :4007400043424341237173E000980128D7D1012FD5D1002ED3D13F4B1B681B68DA0BD2B2DB09DBB2002A01D080235B0023711B0A6371FF23A3710023E37104218EE7009BA6 31 | :40078000012BBCD1022FBAD966E751A900F048FA002800D07DE701260096051C12E0009F012FACD110E7009E012EA8D19623EE195B009E42A8D851A948193A1C07A900F0C2 32 | :4007C00019FCB5B2002368E7002F98D104AB254A191C41CA41C107AA41CB41C2012600963B1C08215AE70098012888D1032F86D1A37962791B021A43310251180192C901C8 33 | :4008000000208022FFF729FE071C002E0ED10199FF290BD1311C0520FFF732FE311C3F1A0620FFF72DFEFFB23F1AFFB27F4227710023012132E70020FFF78CFE002802D179 34 | :40084000094B80221A6000F0FDFA58E78CFDFFFFA7FDFFFFD4000020ACFDFFFFADFDFFFFAEFDFFFF48100000C000002038B50020FFF770FE0025A84200D00625124C00209C 35 | :400880002368C0211A68C03AFFF7E7FD62681378181AC0B2984203D123681B68002B02D1002000F0CDFA094B19681A1C402901D0002D03D000231360FFF77EFE80221A6083 36 | :4008C00000F0C0FA38BDC046D4000020C000002008B5054B8022196812060A431A600A2000F09AFA08BDC0460000064010B5054C2378002B03D100F0BFF801232370FFF7AD 37 | :40090000E7FF10BD10010020094B0A4A1968136899420BD011684B1C4039481E814149420B400549C85C1360C0B200E000207047B0010020280100206C010020064B074ACB 38 | :400940001B6811688B4202D31068181A02E012684133981A7047C046B0010020280100200C4A0D4B002130B5106811601D68802464022C431C601D68084C2C401C60084BAB 39 | :400980001C68084B1C60084B19700849084B1960106030BDC80F064004030640FFFFFEFF28010020B0010020AD010020ED0F0000C00F0640124910B50A68531C3F3A541E44 40 | :4009C000A241524213400F4A1468A342FBD00C681268944208D10C4A14680F222240082A02D00A4B18600AE0094C02222260094CC0B2E0540B60084B19680A431A6010BD22 41 | :400A000024010020200100200802064040020640800F06402C010020880F064038B5041C4518AC4204D02078FFF7C4FF0134F8E738BD00000B4A0023116810B513600A4B55 42 | :400A400080201C684002204318601C68074820401860074B1868074B186002239943116010BDC046880F064004020640FFFFFEFF20010020240100201D4A1E4B10B51A60F0 43 | :400A80001D4B00241C601D4B01221A601C491D4B07200B601C4908601C490A200C601C490A601C4A13601C4B1C6000F0BFF90A20032100F091F919490A2000F081F9184BAE 44 | :400AC00004221C60174B1C60174B1C60174B1C60174B1A60174B1C60174B1C60174B1C60174B1C70174B1C60174B1C6010BDC0460B00000200000640400006404800064060 45 | :400B0000000306400700008004030640100306404400064000020640040206409D0E0000880E0640C80E0640480F0640080F0640C80F0640880F0640B00100202801002070 46 | :400B4000AD01002024010020200100200E4B8422D2041A601968802252020A431A600B490B4A0A60196819600A4BC32189001960094B00211960094B1C211960084B1A6087 47 | :400B8000084A094B1A60704700010540080105401027000024010540380105402801054014010540881300000C01054008B500F02DF8044B01211A680A431A6000F02AF858 48 | :400BC00008BDC0460000054010B5054C2378002B03D1FFF7BBFF01232370FFF7E7FF10BD18010020024B18680006C00F7047C04604000440000000000230800804D0C046B1 49 | :400C00000138FDD1C046C046C0467047EFF3108072B6704780F310887047C046C046C046F0B50024CBB0069404900794FF2800D9A4E0A14200D1A1E008AD8022281C00F06E 50 | :400C4000D9F9231C211C221C029498002858002802D01218014302930133202BF5D1002A05D1002900D08EE00191039102E0002001900390484F7F2328AE291C80222AA87D 51 | :400C80002897464C736000F0B5F9454A454B266013602168090F0A2903D022680F23134000E000230693069F002F69D1FFF7AEFF3D4A3E4B116807971960069B0590002B56 52 | :400CC00014D13B4A04982892289A01040A43289228AA22603249374A0A602268120F0A2A03D02E4B1A680F2313400693069F002F38D1019A002A35D0391C8022281C00F00F 53 | :400D000082F90298039A08A983005A50224B2AA8289380227F23736000F06CF9214820492660086023681B0F0A2B03D01B4B1F680F231F400697069B002B13D11E4A049871 54 | :400D40002892289A01040A43289215491B4A26600A602268120F0A2A03D0104B1A680F2313400693079B002B04D1104A0E481268026007930598FFF74DFF01E00423069343 55 | :400D800006984BB0F0BD02998B00E85801210390EA5001916EE7C046B6D7000008000040040000400400008008010B401C010020B6D8000005000080B6D900000600008055 56 | :400DC0001F2800D901BE034A80008318186819607047C0464000002038B5041C0D1E032D00D901BE1F2C00D901BEFFF70FFFA308084A9B009B18032214409440196806345C 57 | :400E0000A2409143A5400C1C2C431C60FFF702FF38BDC04600E400E01F23184001238340181C014B1860704700E100E01F23184001238340181C014B1860704780E100E0EC 58 | :400E400001BE7047034B04491A6892B20A431A607047C0460CED00E00400FA0510B5041C8022074B1202944205D91868FFF7C4FE044BE418F4E758686043FFF7BDFE10BD5B 59 | :400E8000DC0000200080FFFF08B5034B1B7A5843FFF7B2FE08BDC046DC000020274B10B51B68002B00D09847254B1B685A071DD5244B1B681A0716D0234B244A1868116868 60 | :400EC0004B1C40394C1EA14149420B40204909688B4203D11F4B20221A70E9E71E49C0B2C8541360E4E71D4B04221A601C4B1B689A0721D51B4B1A680F231340082B18D02B 61 | :400F0000194B1A4A1968136899420DD011684B1C3F39481E814149420B401549C85C1549C0B208601360E5E7134B02211A688A431A60124B02221A6010BDC0461401002099 62 | :400F4000CC0F06400803064040030640B001002028010020AD0100206C010020C00F06408C0F06400802064024010020200100202C01002040020640880F0640800F0640AE 63 | :400F800002B4714649084900095C49008E4402BC7047C04603B47146490840004900095E49008E4403BC704770B50E4B0E4D0024ED1AAD101E1CAC4204D0A300F358984765 64 | :400FC0000134F8E700F044F8084B094D0024ED1AAD101E1CAC4204D0A300F35898470134F8E770BD5C1000005C1000005C1000006410000010B50023934203D0CC5CC4548E 65 | :401000000133F9E710BD031C8218934202D019700133FAE770470000A8100000EE0000000000000001330F4003410F4004430F4002600F40E61062048E04D84018808C40AD 66 | :40104000C608E608020111019311C804111E0101F8B5C046F8BC08BC9E4670474D02000005040000F8B5C046F8BC08BC9E4670472502000088100000D0000020200000004B 67 | :40108000C80000000000000000000000181000001C1000000000E02EC05D00001800000000366E01000000000000000000000000000000000000000000000000000000002C 68 | :4010C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F0 69 | :4011000000100020111100002D1400002D14000080B500AF024B83F3088800F08BF9C0460010002080B500AF104B104A12688021C9020A431A60182000F056FA0B4B0B4A91 70 | :4011400012680B490A401A600A4B0B4A1A600B4B10221A600A4B802212061A60094B0A4A1A600A4B00221A60BD4680BD00010B40FFFFFBFF04010B40060000800C02024071 71 | :4011800008010B4000000240100000800C020B4080B582B000AF72B64B4B01221A70FB1D00221A7023E0FB1D1A78131C5B009B185B00464A9B183B603B681A785978090237 72 | :4011C0000A43997809040A43DB781B061343191C3B681A795B791B0213439BB2081C191C00F0AEF9FB1D1A78FB1D01321A70FB1D1B78012BD7D9364A364B101C191C00F026 73 | :40120000AFF9354B354A1A60354B364A1A60364B364A1A60364B00221A60364B00221A60354B992212041A60344B802212061A60334B992212041A60324B334A1A60334B25 74 | :40124000992212041A60324B8C22D2041A60314B05221A60304B06221A60304A2F4B1B78DBB202210B43DBB213702D4A2C4B1B78DBB23C218B43DBB214210B43DBB2137080 75 | :40128000264A264B1B78DBB216210B43DBB21370244BA0221A60244B244A1A60244B20221A60244B7F221A60234B244A1A60244B3C221A60234B244A1A60FFF733FF00F0D6 76 | :4012C0008FF9BD4602B080BD1C700F402C21000038210000602100000000014000009930040001403333330308000140003333000C0001400803044000500F4008500F40F6 77 | :4013000010500F4018500F4000001E1320500F4028500F402000004000800F4000700F4001700F4000000440080004400010C300180004400001044008010440B66D1B0053 78 | :401340000002044008020440806D030010B5064C2378002B07D1054B002B02D0044800E000BF0123237010BDE8000020000000002821000008B5084B002B03D00748084979 79 | :4013800000E000BF07480368002B00D108BD064B002BFBD09847F9E70000000028210000EC000020D00000200000000080B582B000AF00F0EDFA00F0D3FD002000F094FC7B 80 | :4013C000194B1B6E181C00F03BFC62B600233B6026E000237B601DE0C04600F06DFB031EFBD0114B1B6E181C00F02AFC0E4AAE235B00D35879683A68081C111C1A1C00F0AC 81 | :4014000051FC012000F008FB322000F089FA7B6801337B607B680B2BDEDD3B6801333B603B680B2BD5DDD1E70C24000080B500AFFEE7C04680B586B000AF224B7B61224B3C 82 | :401440003B61204B7B6135E03B691B68FB603B695B68BB603B699B683B6000237B600CE0FB681A68BB681A60BB680433BB60FB680433FB607B6804337B607A683B689A4202 83 | :40148000EED13B69DB683B6000237B6008E0BB6800221A60BB680433BB607B6804337B607A683B689A42F2D13B6910333B617B69013B7B617B69002BC6D100F007FEFFF7A8 84 | :4014C00075FFFEE701000000F027000080B582B000AF00237B600FE07B68032B04D8134B7A689200D35800E0114B124A796889008B507B6801337B607B682F2BECD9FFF7C7 85 | :4015000047FE0D4B00221A600C4B1B68002B02D10A4B00221A608023DB058022D205126801210A431A60BD4602B080BD001100002D14000000000020C8000020C00000201E 86 | :4015400080B582B000AF786039607A683B68101C00211A1C00F0E0FDBD4602B080BDC04680B586B000AF7860396000233B6100237B612FE07B699B007A68D3181B68BB60D5 87 | :401580000F23FB18BA681A70BB68FF229343BB6018E03B695B003A68D3181B781A1CBB68D318191C3B695B003A68D3185B780B703B6901333B610F23FB181A780F23FB180B 88 | :4015C000013A1A700F23FB181B78002BE1D17B6901337B617B69092BCCD9BD4606B080BD80B500AFBD4680BD90B585B000AF78607B68022B00D8BBE07B68302B00D9B7E074 89 | :401600005E4B1B78DBB21A1E7B689A420AD35C4A0F23FB1812781A705A4A0E23FB1812781A703FE0584B1B78DBB21A1E7B689A420AD3564A0F23FB1812781A70544A0E2394 90 | :40164000FB1812781A702DE0524B1B78DBB21A1E7B689A420AD3504A0F23FB1812781A704E4A0E23FB1812781A701BE04C4B1B78DBB21A1E7B689A420AD34A4A0F23FB1863 91 | :4016800012781A70484A0E23FB1812781A7009E0464A0F23FB1812781A70454A0E23FB1812781A707B68DA1E0C23FB1841498A5C1A700B23FC1800F0F1FC031C23700C235C 92 | :4016C000FB181B782F2B0DD97B682A2B0AD93A4B19221A60052000F0D7FC0D23FB1819221A7007E0344B1B68DAB20D23FB183F210A401A700C23FA180D23FB1812781B7832 93 | :401700009A4208D22C4B7A68033A2A498A5C1A60052000F0B9FC294B7A6825498C4662441278D2B21A60264B0F22BA1812781A60244B0E22BA1812781A60052000F014F9ED 94 | :401740000C23FA180D23FB1812781B789A4208D9194B7A68033A17498A5C1A60052000F093FC0B23FB181B78181C00F09BFC02E0002000F0CBF8BD4605B090BDC0F1FF0F1C 95 | :40178000C1F1FF0FC2F1FF0FC3F1FF0FC4F1FF0FC5F1FF0FC6F1FF0FC7F1FF0FC8F1FF0FC9F1FF0FCAF1FF0FCBF1FF0FCCF1FF0FCDF1FF0FDC2300002CFF0B4028FF0B4034 96 | :4017C0001CFF0B4020FF0B4080B584B000AF021C3960FB1D1A7080239B05FB60FB1D1B781F2B02D9002000F091F8FB1D1B7810339B00FA68D3181B68BB60FB1D1B7810333F 97 | :401800009B00FA68D3183A681A60BB68181CBD4604B080BD90B587B000AF021CFB1D1A70BB1D0A1C1A70BB1D1B78032B02D9002000F06CF8FB1D1B781F2B02D9002000F01E 98 | :4018400065F8FB1D1B7803221340DB0006337B611323FC1800F022FC031C2370FB1D1B789B08DBB29B00144A944663441B68FB607B6903229A40131CDA43FB681340FB607B 99 | :40188000BB1D1A787B699A40131CFA681343FB60FB1D1B789B08DBB29B00074A94466344FA681A601323FB181B78181C00F0FAFBBD4607B090BDC04600E400E080B582B06D 100 | :4018C00000AF021CFB1D1A70054BFA1D12781F210A40012191400A1C1A60BD4602B080BD00E100E080B582B000AF021CFB1D1A70054BFA1D12781F210A40012191400A1C4E 101 | :401900001A60BD4602B080BD80E100E080B582B000AF021CFB1D1A7001BEBD4602B080BD80B582B000AF786009E00C4B1B68181C00F0AAFB7B680A4A944663447B607A6884 102 | :4019400080231B029A42F0D8064B1B687A685343181C00F099FBBD4602B080BDE00000200080FFFFD800002080B582B000AF021CBB1D1A80BB1D1B88044A12785343181CD4 103 | :4019800000F082FBBD4602B080BDC046DC00002080B500AF174B03221A70174B1D221A70164B18221A70164B0E221A70154B01221A700023181C00F043F9124B00221A70CD 104 | :4019C000002000F0D5F9002000F08EF90E4B1B78002B0AD10C4B01221A700C4B181C00F0F5F90B4B181C00F049FA0A4B01221A60BD4680BD91000F4041000F4021000F4044 105 | :401A000031000F4072000F4004010020811B0000E11A00006C03002080B584B000AF78607B68002B05D01B4B00221A601A4B00221A70184B1A681949131C5B009B181B0194 106 | :401A40005B58FB60164B1B681A1CFB68D3401A1C144B1B681340FB60134BFA68D2B21A70FB681B0AFB60104BFA68D2B21A70FB681B0AFB600C4BFA68D2B21A700B4B012263 107 | :401A80001A600B4B19221A700A4B00221A60BD4604B080BD0C01002070000F4024010020680300206403002042000F400801002072000F406C03002080B500AF064B1B68A7 108 | :401AC000002B04D0054B00221A70012300E00023181CBD4680BDC0466C03002072000F4080B500AF1E4B1B680B2B34D81D4B19681B4B1A68501C1A4B18601B480B1C5B00E9 109 | :401B00005B189B009B189B001A58184B1A60174B1A68174B1B68DA40164B1B681A40134B1A60154A114B1B68DBB213700F4B1B681A0A0E4B1A60104A0C4B1B68DBB213709B 110 | :401B40000A4B1B681A0A094B1A600B4A074B1B68DBB2137002E0094B11221A70BD4680BD080100200C0100202401002014010020680300206403002042000F4072000F40FA 111 | :401B800080B500AF244B21221A70244B1B685A1C224B1A60214B1B680B2B38D8204A1F4B1B68DBB213701D4B1A681E49131C5B009B181B015A581C4B1A601B4B1A681B4B8F 112 | :401BC0001B68DA401A4B1B681A40174B1A60194A154B1B68DBB21370134B1B681A0A124B1A60144A104B1B68DBB213700E4B1B681A0A0D4B1A600F4A0B4B1B68DBB2137098 113 | :401C00000D4B01221A60044B09221A7002E00B4B01221A60BD4680BD72000F400C01002070000F402401002018010020680300206403002042000F40080100206C03002010 114 | :401C400080B584B000AF78600023FB6021E00023BB6018E01249FA68131C5B009B189B00BA689B189B007A685A500D49FA68131C5B009B189B00BA689B189B007A685A50A2 115 | :401C8000BB680133BB60BB680B2BE3D9FB680133FB60FB680B2BDAD9BD4604B080BDC0462401002080B584B000AFF860B9607A60FB68002B13DBBB68002B10DBFB680B2B6F 116 | :401CC0000DDCBB680B2B0ADC0649BA68131C5B009B189B00FA689B189B007A685A50BD4604B080BD2401002080B582B000AF78607B68022B0FD002D8012B05D020E0032B18 117 | :401D000010D0042B15D01BE0124B134A1A60134B01221A601BE00F4B114A1A600F4B02221A6014E00B4B0F4A1A600C4B03221A600DE0084B0C4A1A60084B04221A6006E067 118 | :401D4000044B0A4A1A60054B00221A60C046BD4602B080BD640300207F7F7F00680300203F3F3F001F1F1F000F0F0F00FFFFFF0080B582B000AF78607B68002B0CD10E4B5D 119 | :401D80000E4A1A600E4B05221A600E4B07221A600D4B20221A600CE0074B084A1A60084B05221A60074B07221A60074B20221A60C046BD4602B080BD78030020EC250000A2 120 | :401DC000700300207C0300207403002080B582B000AF786000F048F87B68181C00F008F8032000F011F800F035F8BD4602B080BD80B582B000AF7860024B7A681A64BD462C 121 | :401E000002B080BD0000002090B585B000AF021CFB1D1A700623FB600B23FC1800F03EF9031C23700A4B0A4A1268C0218A43111CFA1D1078FA689040021C0A431A600B2329 122 | :401E4000FB181B78181C00F02DF9BD4605B090BD00E400E080B500AF024B01221A60BD4680BDC04600E100E080B500AF024B01221A60BD4680BDC04680E100E080B582B018 123 | :401E800000AF786000F04AF87B68181C00F008F8032000F011F800F037F8BD4602B080BD80B582B000AF7860024B7A689A64BD4602B080BD0000002090B585B000AF021CC1 124 | :401EC000FB1D1A701623FB600B23FC1800F0E6F8031C23700A4B0A4A12680A491140FA1D1078FA689040021C0A431A600B23FB181B78181C00F0D6F8BD4605B090BDC0469C 125 | :401F000000E400E0FFFF3FFF80B500AF024B04221A60BD4680BDC04600E100E080B500AF024B04221A60BD4680BDC04680E100E080B500AF00F034F8BD4680BD80B500AF4D 126 | :401F4000064B064A1268802109060A431A6000F019F800F01FF8BD4680BDC0460000074080B500AF064B1B78002B04D1FFF7E0FF034B01221A70FFF7E1FFBD4680BDC04686 127 | :401F80001C01002080B500AF0B20FFF797FCBD4680BDC04680B500AF00F064F8BD4680BD80B500AF1D4B1E4A1A601E4B00221A601D4B01221A601D4B1D4A1A601D4B072284 128 | :401FC0001A601D4B00221A601C4B01221A601C4B174A1A601B4B00221A600B20FFF782FC0B200321FFF716FC174B0B20191CFFF7EBFB164B00221A60154B00221A60154B2E 129 | :4020000000221A60144B00221A60144B00221A60134B00221A60BD4680BDC046000007400B0000024000074048000740000307400700008004030740100307404400074060 130 | :402040000002074004020740B1200000880E0740C80E0740480F0740080F0740C80F0740880F074080B500AF054B054A126805490A40902109040A431A60BD4680BDC046A7 131 | :4020800000000140FFFF0FFF0230800804D0C0460138FDD1C046C046C0467047EFF3108072B6704780F310887047C046C046C04680B500AF044B1B68002B02D0024B1B68C7 132 | :4020C0009847BD4680BDC046200100200E4B70B500251E1C0D4CE41AA410A54204D0AB00F35898470135F8E700F070FB084B00251E1C084CE41AA410A54204D0AB00F35829 133 | :4021000098470135F8E770BDD8270000D8270000D8270000E0270000031C8218934202D019700133FAE770470000000000300F40000400400F40000404000F4051300F408C 134 | :402140002C310F4046320F404A330F4009400F4017410F4007420F4004430F4002600F40011811182114310C0108020F03070507070809090B060C040D020E0B0F0D1F0F6A 135 | :40218000200B22042407260828062A09300831013201330234023508360437043E553F55580459045B045F01800183018404850289048A109240930194039508963897067B 136 | :4021C000980899069A269B089F01A241A902AB04AE40B020B207B301B418B640B70EB808BE40BF04C035C501C652C80DC9FFCAFFCBFFCDA0D804D904DA04DC99DD09DF01EB 137 | :40220000E040E140E2C0E4C0E6C0014002800514068007400D020E2810A816021701186019A01D3E1E0120022202232426882F0832803614374139553C203D023F0845084D 138 | :402240004F8854105640574068A8695587048DA0C079C270C49ECA20CCF8CEEFD040D210E21000210102032009040A490B900E210F571289146D1612170818A419571A5A7A 139 | :402280001B081E49224925A0275F28102A022D0130C0323833C03407350F373038203A023B884032460C47EB483449FF4AFF4BFF580459045A045B045C995D095F0162C022 140 | :4022C000644065018101820785018B018C078D019F01A007A402A605A806AA01B101B201B402B604BE54BF01D804D904DF01014002800410068107010D800E6810A81648E6 141 | :4023000019841A041E681F1023402411258027082E402F1032803610370839553C113F8044804520468047085680570A5C805F1066056D026F01760A810282048580860421 142 | :402340008B528D0491559A409E829F01A0A8A122A280A340A501A614A708A810AB20AC01AE01B20AB440C0D9C2F0C45ECA50CC68CEBFD060D630D8C0E230E801EA40EC0892 143 | :40238000EE8063086F02730887208C02D840DA80DC20E2405080564058025A805F2064016608840186408A088E4098029B20A080A880AF02B308B704D4E0D6E0D880E25044 144 | :4023C000EA3054405B145C088F10D403D603E402AB04AC08B040EC0402011101030405060708090A0B0C0E0F101112131415161718191B1C1D1E1F202122232526272829C0 145 | :402400002A2B2E2F3031323334350000FFFF0000FFCC0000FF990000FF330000FF000000B3006600990099006600B3003300CC001919B3000033990000409900006699003D 146 | :402440000099990000CC990000E6660000FF000033FF000066FF000080FF000099FF0000B2FF0000CCFF0000E5FF000000000000000055000000AA000000FF005500000019 147 | :40248000550055005500AA005500FF00AA000000AA005500AA00AA00AA00FF00FF000000FF005500FF00AA00FF00FF0000550000005555000055AA000055FF005555000083 148 | :4024C000555555005555AA005555FF00AA550000AA555500AA55AA00AA55FF00FF550000FF555500FF55AA00FF55FF0000AA000000AA550000AAAA0000AAFF0055AA0000F3 149 | :4025000055AA550055AAAA0055AAFF00AAAA0000AAAA5500AAAAAA00AAAAFF00FFAA0000FFAA5500FFAAAA00FFAAFF0000FF000000FF550000FFAA0000FFFF0055FF000062 150 | :4025400055FF550055FFAA0055FFFF00AAFF0000AAFF5500AAFFAA00AAFFFF00FFFF0000FFFF5500FFFFAA00FFFFFF00FF800000FF008000FF00FF008000FF000080FF00CF 151 | :4025800000FF8000FF0000002020200000002000000000100000000000000000000000000000000000000000000000000000FF000010F0000020E0000030D0000040C0000E 152 | :4025C0000050B0000060A00000709000008080000090700000A0600000B0500000C0400000D0300000E0200000FF0000000000000000005F00000007000700147F147F1435 153 | :40260000242A7F2A12231308646236495522500005030000001C2241000041221C00082A1C2A0808083E080800503000000808080808006060000020100804023E514945A0 154 | :402640003E00427F400042615149462141454B311814127F1027454545393C4A49493001710905033649494936064949291E003636000000563600000008142241141414D5 155 | :40268000141441221408000201510906324979413E7E1111117E7F494949363E414141227F4141221C7F494949417F090901013E414151327F0808087F00417F4100204094 156 | :4026C000413F017F081422417F404040407F0204027F7F0408107F3E4141413E7F090909063E4151215E7F09192946464949493101017F01013F4040403F1F2040201F7F2E 157 | :402700002018207F63140814630304780403615149454300007F4141020408102041417F000004020102044040404040000102040020545454787F484444383844444420F0 158 | :40274000384444487F3854545418087E090102081454543C7F0804047800447D40002040443D00007F10284400417F40007C041804787C0804047838444444387C14141404 159 | :4027800008081414187C7C080404084854545420043F4440203C4040207C1C2040201C3C4030403C44281028440C5050503C4464544C44000836410000007F000000413615 160 | :4027C000080008082A1C08081C2A0808F8B5C046F8BC08BC9E46704775130000CD140000F8B5C046F8BC08BC9E4670474D13000000280000D00000201800000098020000F6 161 | :402800000000000000366E01C05D0000180000000000E02E0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B0 162 | :402840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000058 163 | :402880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018 164 | :4028C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D8 165 | :402900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000097 166 | :402940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000057 167 | :402980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017 168 | :4029C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D7 169 | :402A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096 170 | :402A40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000056 171 | :402A80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016 172 | :402AC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D6 173 | :402B00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000095 174 | :402B40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055 175 | :402B80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015 176 | :402BC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D5 177 | :402C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000094 178 | :402C40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000054 179 | :402C80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014 180 | :402CC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D4 181 | :402D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000093 182 | :402D40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000053 183 | :402D80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013 184 | :402DC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D3 185 | :402E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000092 186 | :402E40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000052 187 | :402E80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012 188 | :402EC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D2 189 | :402F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000091 190 | :402F40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000051 191 | :402F80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 192 | :402FC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D1 193 | :403000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090 194 | :403040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050 195 | :403080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 196 | :4030C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D0 197 | :40310000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008F 198 | :40314000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004F 199 | :40318000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F 200 | :4031C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CF 201 | :40320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008E 202 | :40324000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004E 203 | :40328000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E 204 | :4032C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CE 205 | :40330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008D 206 | :40334000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004D 207 | :40338000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D 208 | :4033C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CD 209 | :40340000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008C 210 | :40344000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004C 211 | :40348000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C 212 | :4034C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CC 213 | :40350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008B 214 | :40354000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004B 215 | :40358000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B 216 | :4035C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CB 217 | :40360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008A 218 | :40364000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004A 219 | :40368000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A 220 | :4036C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CA 221 | :403700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000089 222 | :403740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049 223 | :403780000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009 224 | :4037C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C9 225 | :403800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000088 226 | :403840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000048 227 | :403880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008 228 | :4038C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C8 229 | :403900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000087 230 | :403940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000047 231 | :403980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007 232 | :4039C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C7 233 | :403A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086 234 | :403A40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046 235 | :403A80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006 236 | :403AC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C6 237 | :403B00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000085 238 | :403B40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045 239 | :403B80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005 240 | :403BC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C5 241 | :403C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084 242 | :403C40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044 243 | :403C80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004 244 | :403CC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C4 245 | :403D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083 246 | :403D40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043 247 | :403D80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003 248 | :403DC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C3 249 | :403E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082 250 | :403E40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042 251 | :403E80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002 252 | :403EC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C2 253 | :403F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000081 254 | :403F40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041 255 | :403F80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 256 | :403FC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C1 257 | :404000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080 258 | :404040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040 259 | :404080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 260 | :4040C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0 261 | :40410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007F 262 | :40414000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003F 263 | :4041800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FF 264 | :4041C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000BF 265 | :40420000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007E 266 | :40424000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003E 267 | :4042800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FE 268 | :4042C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000BE 269 | :40430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007D 270 | :40434000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003D 271 | :4043800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FD 272 | :4043C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000BD 273 | :40440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007C 274 | :40444000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003C 275 | :4044800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FC 276 | :4044C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000BC 277 | :40450000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007B 278 | :40454000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003B 279 | :4045800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FB 280 | :4045C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000BB 281 | :40460000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007A 282 | :40464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003A 283 | :4046800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FA 284 | :4046C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000BA 285 | :404700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000079 286 | :404740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039 287 | :4047800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F9 288 | :4047C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B9 289 | :404800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078 290 | :404840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038 291 | :4048800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F8 292 | :4048C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B8 293 | :404900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000077 294 | :404940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037 295 | :4049800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F7 296 | :4049C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B7 297 | :404A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000076 298 | :404A40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000036 299 | :404A800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F6 300 | :404AC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B6 301 | :404B00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000075 302 | :404B40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035 303 | :404B800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F5 304 | :404BC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B5 305 | :404C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074 306 | :404C40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034 307 | :404C800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F4 308 | :404CC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B4 309 | :404D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073 310 | :404D40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000033 311 | :404D800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F3 312 | :404DC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B3 313 | :404E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000072 314 | :404E40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000032 315 | :404E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F2 316 | :404EC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B2 317 | :404F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000071 318 | :404F40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000031 319 | :404F800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F1 320 | :404FC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B1 321 | :405000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000070 322 | :405040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030 323 | :4050800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F0 324 | :4050C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B0 325 | :40510000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006F 326 | :40514000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002F 327 | :4051800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000EF 328 | :4051C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000AF 329 | :40520000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006E 330 | :40524000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002E 331 | :4052800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000EE 332 | :4052C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000AE 333 | :40530000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006D 334 | :40534000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002D 335 | :4053800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ED 336 | :4053C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000AD 337 | :40540000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006C 338 | :40544000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002C 339 | :4054800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000EC 340 | :4054C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000AC 341 | :40550000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006B 342 | :40554000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002B 343 | :4055800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000EB 344 | :4055C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000AB 345 | :40560000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006A 346 | :40564000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002A 347 | :4056800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000EA 348 | :4056C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000AA 349 | :405700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000069 350 | :405740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000029 351 | :4057800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E9 352 | :4057C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A9 353 | :405800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000068 354 | :405840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028 355 | :4058800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E8 356 | :4058C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A8 357 | :405900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000067 358 | :405940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000027 359 | :4059800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E7 360 | :4059C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A7 361 | :405A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066 362 | :405A40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026 363 | :405A800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E6 364 | :405AC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A6 365 | :405B00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000065 366 | :405B40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000025 367 | :405B800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E5 368 | :405BC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A5 369 | :405C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064 370 | :405C40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024 371 | :405C800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E4 372 | :405CC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A4 373 | :405D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000063 374 | :405D40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000023 375 | :405D800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E3 376 | :405DC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A3 377 | :405E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000062 378 | :405E40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022 379 | :405E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E2 380 | :405EC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A2 381 | :405F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000061 382 | :405F40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000021 383 | :405F800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E1 384 | :405FC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A1 385 | :406000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060 386 | :406040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020 387 | :4060800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E0 388 | :4060C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A0 389 | :40610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005F 390 | :40614000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001F 391 | :4061800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DF 392 | :4061C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009F 393 | :40620000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005E 394 | :40624000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001E 395 | :4062800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DE 396 | :4062C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009E 397 | :40630000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005D 398 | :40634000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001D 399 | :4063800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DD 400 | :4063C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009D 401 | :40640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005C 402 | :40644000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001C 403 | :4064800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DC 404 | :4064C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009C 405 | :40650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005B 406 | :40654000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001B 407 | :4065800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DB 408 | :4065C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009B 409 | :40660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005A 410 | :40664000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001A 411 | :4066800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DA 412 | :4066C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009A 413 | :406700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000059 414 | :406740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000019 415 | :4067800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D9 416 | :4067C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000099 417 | :406800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000058 418 | :406840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018 419 | :4068800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D8 420 | :4068C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000098 421 | :406900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000057 422 | :406940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017 423 | :4069800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D7 424 | :4069C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000097 425 | :406A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000056 426 | :406A40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016 427 | :406A800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D6 428 | :406AC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096 429 | :406B00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055 430 | :406B40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000015 431 | :406B800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D5 432 | :406BC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000095 433 | :406C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000054 434 | :406C40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014 435 | :406C800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D4 436 | :406CC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000094 437 | :406D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000053 438 | :406D40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013 439 | :406D800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D3 440 | :406DC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000093 441 | :406E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000052 442 | :406E40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012 443 | :406E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D2 444 | :406EC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000092 445 | :406F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000051 446 | :406F40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011 447 | :406F800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D1 448 | :406FC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000091 449 | :407000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050 450 | :407040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010 451 | :4070800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D0 452 | :4070C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090 453 | :40710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004F 454 | :40714000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F 455 | :4071800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CF 456 | :4071C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008F 457 | :40720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004E 458 | :40724000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E 459 | :4072800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CE 460 | :4072C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008E 461 | :40730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004D 462 | :40734000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D 463 | :4073800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CD 464 | :4073C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008D 465 | :40740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004C 466 | :40744000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C 467 | :4074800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CC 468 | :4074C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008C 469 | :40750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004B 470 | :40754000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000B 471 | :4075800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CB 472 | :4075C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008B 473 | :40760000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004A 474 | :40764000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000A 475 | :4076800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000CA 476 | :4076C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008A 477 | :407700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000049 478 | :407740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009 479 | :4077800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C9 480 | :4077C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000089 481 | :407800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000048 482 | :407840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008 483 | :4078800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C8 484 | :4078C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000088 485 | :407900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000047 486 | :407940000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007 487 | :4079800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C7 488 | :4079C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000087 489 | :407A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046 490 | :407A40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006 491 | :407A800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C6 492 | :407AC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086 493 | :407B00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045 494 | :407B40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005 495 | :407B800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C5 496 | :407BC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000085 497 | :407C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044 498 | :407C40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004 499 | :407C800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C4 500 | :407CC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084 501 | :407D00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000043 502 | :407D40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003 503 | :407D800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C3 504 | :407DC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083 505 | :407E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042 506 | :407E40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002 507 | :407E800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C2 508 | :407EC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000082 509 | :407F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041 510 | :407F40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 511 | :407F800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C1 512 | :407FC000C8111100002100000080170000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DE 513 | :0200000490303A 514 | :02000000686B2B 515 | :0200000490402A 516 | :20000000FFFFFFFF00000000000000000000000000000000000000000000000000000000E4 517 | :0200000490501A 518 | :0C000000000204C81193110004D479FE22 519 | :0200000490600A 520 | :0100000001FE 521 | :00000001FF -------------------------------------------------------------------------------- /make/Makefile.cypress: -------------------------------------------------------------------------------- 1 | 2 | # Add a entry here to define a new platform 3 | CY8C49_flash_size := 32768 4 | CY8C49_flash_array_size := 32768 5 | CY8C49_flash_row_size := 128 6 | CY8C49_mcpu := cortex-m0 7 | CY8C49_cpu_dir := CortexM0 8 | CY8C49_bootloader_size := 4352 9 | CY8C49_psoc_type := PSoC4 10 | 11 | PROJECT_DIR ?= $(error PROJECT_DIR must be defined) 12 | PROJECT_NAME = $(basename $(notdir $(PROJECT_DIR))) 13 | PSOC_CREATOR_DIR ?= $(error PSOC_CREATOR_DIR must be defined) 14 | CROSS_COMPILE := arm-none-eabi- 15 | CPU_TYPE ?= CY8C49 16 | 17 | RELEASE_TYPE ?= Debug 18 | 19 | # Special dir from cypress tools 20 | CYCOMPONENT_LIB_DIR := $(PSOC_CREATOR_DIR)/psoc/content/CyComponentLibrary/CyComponentLibrary.cylib/ 21 | 22 | CAPSENSE_LIB := $(CYCOMPONENT_LIB_DIR)/CapSense_CSD_P4_v2_30/$($(CPU_TYPE)_psoc_type)/Library/CapsenseP4Library_GCC.a 23 | CYCOMPONENT_LIB := $(CYCOMPONENT_LIB_DIR)/$($(CPU_TYPE)_cpu_dir)/ARM_GCC_493/$(RELEASE_TYPE)/CyComponentLibrary.a 24 | CYPRESS_LIBS := "$(CAPSENSE_LIB)" "$(CYCOMPONENT_LIB)" 25 | CYELFTOOL := $(PSOC_CREATOR_DIR)/bin/cyelftool.exe 26 | 27 | BUILD_DIR ?= ./build 28 | UPLOAD_BAUDRATE ?= 115200 29 | SERIAL_PORT ?= /dev/ttyACM0 30 | 31 | GEN_SRC_DIR := Generated_Source/$($(CPU_TYPE)_psoc_type)/ 32 | 33 | COMMON_FLAGS := -mcpu=$($(CPU_TYPE)_mcpu) -mthumb 34 | 35 | CFLAGS := $(COMMON_FLAGS) -Wno-main -ffunction-sections -ffat-lto-objects $(USER_CFLAGS) 36 | LFLAGS := -Wl,--gc-sections -Wl,-Map,$(BUILD_DIR)/$(PROJECT_NAME).map -L$(BUILD_DIR)/ -T $(PROJECT_DIR)/$(GEN_SRC_DIR)/cm0gcc.ld 37 | ASFLAGS := $(COMMON_FLAGS) 38 | INCLUDE_CFLAGS := -I$(PROJECT_DIR)/$(GEN_SRC_DIR) -I$(PROJECT_DIR)/ 39 | 40 | SRC_C_FILES := $(wildcard $(PROJECT_DIR)/$(GEN_SRC_DIR)/*.c $(PROJECT_DIR)/*.c) 41 | BOOTASM_GNU := $(PROJECT_DIR)/$(GEN_SRC_DIR)/CyBootAsmGnu.s 42 | 43 | OBJ_FILES := $(patsubst %.c,%.o,$(SRC_C_FILES)) $(subst .s,.o,$(BOOTASM_GNU)) 44 | OBJ_FILES := $(subst $(PROJECT_DIR),$(BUILD_DIR),$(OBJ_FILES)) 45 | 46 | all: $(BUILD_DIR)/$(PROJECT_NAME).cyacd 47 | 48 | $(BUILD_DIR)/%.o: $(PROJECT_DIR)/%.c 49 | @mkdir -p $(dir $@) 50 | $(CROSS_COMPILE)gcc $(CFLAGS) -o $@ -c $(INCLUDE_CFLAGS) $< 51 | 52 | $(BUILD_DIR)/%.o: $(PROJECT_DIR)/%.s 53 | @mkdir -p $(dir $@) 54 | $(CROSS_COMPILE)as $(ASFLAGS) $(INCLUDE_CFLAGS) -o $@ $< 55 | 56 | $(BUILD_DIR)/$(PROJECT_NAME).a: $(OBJ_FILES) 57 | @mkdir -p $(dir $@) 58 | $(CROSS_COMPILE)ar -rs $@ $(OBJ_FILES) 59 | 60 | $(BUILD_DIR)/$(PROJECT_NAME).elf: $(BUILD_DIR)/$(PROJECT_NAME).a 61 | @mkdir -p $(dir $@) 62 | $(CROSS_COMPILE)gcc -specs=nano.specs $(CFLAGS) -o $@ -Wl,--start-group $^ $(CYPRESS_LIBS) -Wl,--end-group $(LFLAGS) 63 | wine "$(CYELFTOOL)" -B $@ --flash_row_size $($(CPU_TYPE)_flash_row_size) --flash_size $($(CPU_TYPE)_flash_size) --flash_array_size $($(CPU_TYPE)_flash_array_size) 64 | wine "$(CYELFTOOL)" -S $@ 65 | 66 | $(BUILD_DIR)/$(PROJECT_NAME).hex: $(BUILD_DIR)/$(PROJECT_NAME).elf 67 | $(CROSS_COMPILE)objcopy -O ihex -v $^ $@ 68 | 69 | $(BUILD_DIR)/$(PROJECT_NAME).cyacd: $(BUILD_DIR)/$(PROJECT_NAME).hex 70 | ihex2cyacd -i $^ -o $@ -b $($(CPU_TYPE)_bootloader_size) 71 | 72 | clean: 73 | rm -rf $(BUILD_DIR) 74 | 75 | upload: $(BUILD_DIR)/$(PROJECT_NAME).cyacd 76 | cyhostboot -f $< -b $(UPLOAD_BAUDRATE) -s $(SERIAL_PORT) 77 | --------------------------------------------------------------------------------