6 Replies Latest reply on Jul 16, 2020 10:29 PM by EktaN_26

    How can I program user FLASH from a *.hex file in PSOC4?

    DaGa_4378306

      I'm using user FLASH row to store some information on device testing, so the first image that is loaded onto the PSOC4 should erase that user info.  Is there a way to add that option to the *.hex file that you use with the Cypress programmer?

       

      All I can see on erasing user FLASH is using the CLI function, but I need something done in one step for manufacturing.

        • 1. Re: How can I program user FLASH from a *.hex file in PSOC4?
          NoriakiT_91

          You can declare the user FLASH row as a constant in the C source file like:

           

          volatile const CYCODE char eepromArray[EEPROM_SIZE]
              CY_SECTION(".EEPROMDATA")
              = "Hello World. Hello PSoC.\r\n";
          

           

          The data array is included in the HEX file when compiled.

           

           

          The section name ".EEPROMDATA" is declared in a custom linker script file like:

           

          INCLUDE cm0gcc.ld
          
          
          SECTIONS {
              .EEPROMDATA 0x00018000:
              {
                  KEEP (*(.EEPROMDATA))
              } > rom
          }
          

           

          The INCLUDE statement at the 1st line includes the default linker script generated by PSoC Creator.

           

          Regards,

          Noriaki

          • 2. Re: How can I program user FLASH from a *.hex file in PSOC4?
            DaGa_4378306

            By the way, this is for PSOC4 BLE, I'm not sure if that changes the interface

             

            I'm trying to initialize the first 12 bytes, but it doesn't seem to work for me.

             

            volatile const CYCODE uint8_t eepromArray[12] 

                CY_SECTION(".EEPROMDATA"

                = {0,0,0,0,0,0,0,0,0,0,0,0};

             

            Where did you find the actual base address of the USER rows? For PSOC4, I found 0xffff400 from a header file but it doesn't work for me?

             

                .EEPROMDATA 0x0ffff400

                { 

                    KEEP (*(.EEPROMDATA)) 

                } > rom 

             

             

            Build error: address 0xffff500 of *****.elf section `.EEPROMDATA' is not within region `rom'

            • 3. Re: How can I program user FLASH from a *.hex file in PSOC4?
              NoriakiT_91

              Do you mean this one in the cydevice_trm.h header file?

              #define CYREG_SFLASH_IMO_TRIM44 0x0ffff37cu
              #define CYREG_SFLASH_IMO_TRIM45 0x0ffff37du
              #define CYREG_SFLASH_MACRO_0_FREE_SFLASH0 0x0ffff400u
              #define CYFLD_SFLASH_BYTE_MEM__OFFSET 0x00000000u
              #define CYFLD_SFLASH_BYTE_MEM__SIZE 0x00000008u
              

               

              These MACROs are for the SFLASH area which is a Supervisory FLASH area written at the Cypress factory.  User cannot program these area.

               

              If you want to have a user-programmable FLASH area, you must allocate that area on the FLASH area.  The address of the FLASH area is 0x00000000-0x0003FFFF in case of PSoC 4 BLE with 256kB ROM.  Because my example is for the PSoC 4M with 128kB, the FLASH area is 0x00000000-0x0001FFFF and the last 32kB (0x00018000-0x0001FFFF) is assigned for the emulated EEPROM area.

               

              Regards,

              Noriaki

              • 4. Re: How can I program user FLASH from a *.hex file in PSOC4?
                DaGa_4378306

                So I do want to write to the SFLASH, there are the 4 rows (256-bytes) each of user definable space. This is the read method:

                 

                    val = *(reg8*)(CY_SFLASH_USERBASE+byte_index);

                 

                I can write to it in the code to make changes, but I just need defaults in the factory HEX image:

                 

                    // Write to FLASH

                    code = CySysSFlashWriteUserRow(row, write_data);

                • 5. Re: How can I program user FLASH from a *.hex file in PSOC4?
                  NoriakiT_91

                  OK, I understand you are going to program the "User SFlash" area using a HEX file.

                   

                  There is a programming specification document including the "User SFlash" programming.

                   

                  CY8C4xxx, CYBLxxxx Programming Specifications

                  https://www.cypress.com/documentation/programming-specifications/cy8c4xxx-cyblxxxx-programming-specifications

                   

                  In the document it was described that

                  user SFlash rows are not stored in the hex file. A vendor should define the programming process - during production, where to get the SFlash data from, and at which row/address to store it.

                  So, it is not available to use the data in the HEX file.

                   

                  I have checked if the PSoC Programmer has a function to program the SFlash area, but it seems that PSoC Programmer does not have such a feature.

                   

                  Regards,

                  Noriaki

                  • 6. Re: How can I program user FLASH from a *.hex file in PSOC4?
                    EktaN_26

                    Hello DaGa_4352226

                     

                    Please refer to the thread Re: Is it possible to clear SFLASH memory while programming in PSoC 4? which mentions two ways to clear the SFLASH, one ways which you are already aware of is to make use of the CySysSFlashWriteUserRow() API to write 0 to the desired SFLASH rows at the beginning of each program.

                     

                    The second way is to use the SFLASH Update tool which gets downloaded as a part of PSoC Programmer to program the SFLASH.

                     

                    As, mentioned by Noriaki user SFlash rows are not stored in the hex file. A vendor should define the programming process - during production, where to get the SFlash data from, and at which row/address to store it.

                     

                    In case you are planning to develop a programmer to program the SFLASH please refer to the CY8C4xxx, CYBLxxxx Programming Specifications : https://www.cypress.com/documentation/programming-specifications/cy8c4xxx-cyblxxxx-programming-specifications

                     

                    Please let us know if you have any further queries.

                     

                    Best Regards

                    Ekta