1 Reply Latest reply on Mar 31, 2020 8:55 PM by ShifangZ_26

    locked memory: follow up

    PaVo_4660581

       

      this question goes back to "locked memory" question. There is supposed to be an easy way to link it, but I cannot seem to find it. Would the following code segment work for this case? I tried this on my development platform CY4531 EZ-PD eval kit and now I cannot connect to reprogram the device from either the MiniProg3 or the Configuration utility tool. Third Eval kit down the tubes.  I would like to verify this before I try it again.  This time I will be using my last CY4541 eval kit.  This code will go in main before the infinite loop using the default notebook configuration.

       

       

      uint8_t temp_buf[CCG_FLASH_ROW_SIZE] = {0};
      uint8_t userIdWord;

      userIdWord = *((uint8_t *)((CCG_APP_PRIORITY_ROW_NUM-1) << CCG_FLASH_ROW_SHIFT_NUM));
      SW_Tx_UART_1_PutString("before userIdWord ");
      SW_Tx_UART_1_PutHexByte(userIdWord);
      SW_Tx_UART_1_PutCRLF();

      /* Set APP Priority Field. */
      temp_buf[0] = 0xAD;
      if (CYRET_SUCCESS == CySysFlashWriteRow (CCG_APP_PRIORITY_ROW_NUM-1, temp_buf))
      {
          SW_Tx_UART_1_PutString("good write");
          SW_Tx_UART_1_PutCRLF();
      }
      else
      {
          SW_Tx_UART_1_PutString("fail write");
          SW_Tx_UART_1_PutCRLF();
      }
      SW_Tx_UART_1_PutString("after userIdWord ");
      SW_Tx_UART_1_PutHexByte(userIdWord);
      SW_Tx_UART_1_PutCRLF();

       

       

       

       

        • 1. Re: locked memory: follow up
          ShifangZ_26

          Hi Paul,

           

          Please do not write it like this way. You can initial the value to the Metadata, and then, the firmware will write the data into the latest row flash.

           

          By default:

           

          typedef struct __attribute__((__packed__))

          {

              uint8_t fw_checksum;                  /**< Offset 00: Single Byte FW Checksum. */

              uint32_t fw_entry;                    /**< Offset 01: FW Entry Address */

              uint16_t boot_last_row;               /**< Offset 05: Last Flash row of Bootloader or previous firmware. */

              uint8_t reserved1[2];                 /**< Offset 07: Reserved. */

              uint32_t fw_size;                     /**< Offset 09: Size of Firmware. */

              uint8_t reserved2[3];                 /**< Offset 0D: Reserved. */

              uint8_t active_boot_app;              /**< Offset 10: Creator specific field. Not used in this implementation. */

              uint8_t boot_app_ver_status;          /**< Offset 11: Creator specific field. Not used in this implementation. */

              uint16_t boot_app_version;            /**< Offset 12: Creator specific field. Not used in this implementation. */

              uint16_t boot_app_id;                 /**< Offset 14: Creator specific field. Not used in this implementation. */

              uint16_t metadata_valid;              /**< Offset 16: Metadata Valid field. Valid if contains "CY". */

              uint32_t fw_version;                  /**< Offset 18: Creator specific field. Not used in this implementation. */

              uint32_t boot_seq;                    /**< Offset 1C: Boot sequence number field. Boot-loader will load the valid

                                                         FW copy that has the higher sequence number associated with it. */

           

           

          } sys_fw_metadata_t;

           

          You could change to:

          typedef struct __attribute__((__packed__))

          {

              uint8_t fw_checksum;                  /**< Offset 00: Single Byte FW Checksum. */

              uint32_t fw_entry;                    /**< Offset 01: FW Entry Address */

              uint16_t boot_last_row;               /**< Offset 05: Last Flash row of Bootloader or previous firmware. */

              uint8_t reserved1[2];                 /**< Offset 07: Reserved. */

              uint32_t fw_size;                     /**< Offset 09: Size of Firmware. */

              uint8_t UserId_word;                 /**< Offset 0D: Reserved. */

              uint8_t reserved2[2];                 /**< Offset 0E: Reserved. */

              uint8_t active_boot_app;              /**< Offset 10: Creator specific field. Not used in this implementation. */

              uint8_t boot_app_ver_status;          /**< Offset 11: Creator specific field. Not used in this implementation. */

              uint16_t boot_app_version;            /**< Offset 12: Creator specific field. Not used in this implementation. */

              uint16_t boot_app_id;                 /**< Offset 14: Creator specific field. Not used in this implementation. */

              uint16_t metadata_valid;              /**< Offset 16: Metadata Valid field. Valid if contains "CY". */

              uint32_t fw_version;                  /**< Offset 18: Creator specific field. Not used in this implementation. */

              uint32_t boot_seq;                    /**< Offset 1C: Boot sequence number field. Boot-loader will load the valid

                                                         FW copy that has the higher sequence number associated with it. */

           

           

          } sys_fw_metadata_t;

           

          And then,

          You just update UserId_wordyou have been defined. And refer metadata update process. The address you could be refer is:

          #define CCG_BOOT_LOADER_LAST_ROW                (0x13)

           

          And the offset also need be considered.

           

          Best Regards,

          Lisa