1 /***************************************************************************//** 2 * \file cy_serial_flash_prog.c 3 * 4 * \brief 5 * Provides variables necessary to inform programming tools how to program the 6 * attached serial flash memory. The variables used here must be placed at 7 * specific locations in order to be detected and used by programming tools 8 * to know that there is an attached memory and its characteristics. Uses the 9 * configuration provided as part of BSP. 10 * 11 ******************************************************************************** 12 * \copyright 13 * Copyright 2018-2019 Cypress Semiconductor Corporation 14 * SPDX-License-Identifier: Apache-2.0 15 * 16 * Licensed under the Apache License, Version 2.0 (the "License"); 17 * you may not use this file except in compliance with the License. 18 * You may obtain a copy of the License at 19 * 20 * http://www.apache.org/licenses/LICENSE-2.0 21 * 22 * Unless required by applicable law or agreed to in writing, software 23 * distributed under the License is distributed on an "AS IS" BASIS, 24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 * See the License for the specific language governing permissions and 26 * limitations under the License. 27 *******************************************************************************/ 28 29 /** 30 * \addtogroup group_serial_flash Serial Flash 31 * \{ 32 * Variables for informing programming tools that there is an attached memory device and what 33 * its characteristics are so it can be programmed just like the on-chip memory. 34 * 35 * \defgroup group_serial_flash_variables Variables 36 */ 37 38 #include <stdint.h> 39 #include "flash_qspi.h" 40 41 #if defined(__cplusplus) 42 extern "C" { 43 #endif 44 45 typedef struct 46 { 47 const cy_stc_smif_block_config_t * smifCfg; /* Pointer to SMIF top-level configuration */ 48 const uint32_t null_t; /* NULL termination */ 49 } stc_smif_ipblocks_arr_t; 50 51 /** 52 * \addtogroup group_serial_flash_variables 53 * \{ 54 */ 55 56 /** 57 * This data can be placed anywhere in the internal memory, but it must be at a location that 58 * can be determined and used for the calculation of the CRC16 checksum in the cyToc below. There 59 * are multiple ways this can be accomplished including: 60 * 1) Placing it in a dedicated memory block with a known address. (as done here) 61 * 2) Placing it at an absolute location via a the linker script 62 * 3) Using 'cymcuelftool -S' to recompute the checksum and patch the elf file after linking 63 */ 64 CY_SECTION(".cy_sflash_user_data") __attribute__( (used) ) 65 /* const stc_smif_ipblocks_arr_t smifIpBlocksArr = {&smifBlockConfig_sfdp, 0x00000000}; */ 66 /* if used zero-pointer to config, DAP link will use hardcoded config for CY8CPROTO-062-4343W */ 67 const stc_smif_ipblocks_arr_t smifIpBlocksArr = {0x00000000, 0x00000000}; 68 69 /** 70 * This data is used to populate the table of contents part 2. When present, it is used by the boot 71 * process and programming tools to determine key characteristics about the memory usage including 72 * where the boot process should start the application from and what external memories are connected 73 * (if any). This must consume a full row of flash memory row. The last entry is a checksum of the 74 * other values in the ToC which must be updated if any other value changes. This can be done manually 75 * or by running 'cymcuelftool -S' to recompute the checksum. 76 */ 77 CY_SECTION(".cy_toc_part2") __attribute__( (used) ) 78 const uint32_t cyToc[128] = 79 { 80 0x200-4, /* Offset=0x0000: Object Size, bytes */ 81 0x01211220, /* Offset=0x0004: Magic Number (TOC Part 2, ID) */ 82 0, /* Offset=0x0008: Key Storage Address */ 83 (int)&smifIpBlocksArr, /* Offset=0x000C: This points to a null terminated array of SMIF structures. */ 84 0x10000000u, /* Offset=0x0010: App image start address */ 85 /* Offset=0x0014-0x01F7: Reserved */ 86 [126] = 0x000002C2, /* Offset=0x01F8: Bits[ 1: 0] CLOCK_CONFIG (0=8MHz, 1=25MHz, 2=50MHz, 3=100MHz) 87 Bits[ 4: 2] LISTEN_WINDOW (0=20ms, 1=10ms, 2=1ms, 3=0ms, 4=100ms) 88 Bits[ 6: 5] SWJ_PINS_CTL (0/1/3=Disable SWJ, 2=Enable SWJ) 89 Bits[ 8: 7] APP_AUTHENTICATION (0/2/3=Enable, 1=Disable) 90 Bits[10: 9] FB_BOOTLOADER_CTL: UNUSED */ 91 [127] = 0x3BB30000 /* Offset=0x01FC: CRC16-CCITT (the upper 2 bytes contain the CRC and the lower 2 bytes are 0) */ 92 }; 93 94 /** \} group_serial_flash_variables */ 95 96 #if defined(__cplusplus) 97 } 98 #endif 99 100 /** \} group_serial_flash */ 101