1 2 Previous Next 21 Replies Latest reply on Aug 22, 2016 4:16 AM by mark_kram

    How to prepare OpenOCD scripts for D2000 - System and Data flash.

    mark_kram

      Hi, I have a product based on D2000 board. I want to send it to 10 clients of main for tests but on 100% I'm sure that the program and informations in flash will be changed during tests (for example new features and new device parameters). I want to prepare two Open OCD scritps first to flash CODE (32KB - 0x00180000) and second to flash DATA Region (4KB - 0x00200000) memory.

      My question is how to prepare that kind of scripts for D2000 board?

        • 1. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
          PabloM_Intel

          Hi Mark,

           

          I’m not sure if you have followed the steps from the “Deploying a Project” section, if not I would suggest you to check this link first https://communities.intel.com/community/tech/microcontrollers/blog/2016/04/06/limitations-and-known-issues-in-intel-system-studio-2016-for-microcontroller, this includes some general information on limitations and known issues of System Studio for Microcontroller, once you’ve checked that click on the “Deploying a Project” hyperlink. In the first step you can see this file being compiled quark_d2000_onboard.cfg, I believe that’s the file that you need to edit to generate different OCD scripts for your clients.

           

          With the instructions from the second step you can start debugging your .elf file. So, take into account that the instructions from this section assume that you have already build this .elf file (accel.elf), if you haven’t done that yet you’ll need to open a third session to build it and then continue with the normal process.

           

          Regards,

          -Pablo

          1 of 1 people found this helpful
          • 2. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
            mark_kram

            Hi Pablo,

            thank you for your answer and support. As I mentioned in my frist post I had two problems: the first one was "how to flash the code flash memory" and second "how to flash the data flash memory".

             

             

            Thank you for the link about limitations attached to your post. I read it due to your instructions / as you suggest. In the meantime (at the weekend) I found an article: "Deploying a Project" and it was exactly what I looking for as far as my first question is conncerned. As you know the file is loaded into the memory via the "load" command (to 0x00180000 program space) and there is no possibility to load my own .bin file to the other memory space (for example 0x00200000 data flash space) using this command (additionally as far as I understand "load" command can work only with .elf files). Anyway as for me the first problem can be chceked as resolved because in the "Deploying a Project" article everything is described properly.

             

             

            The second problem, I mean "how to flash the data flash memory", is still an open question for me because I made couple tests during the weekend but non of them was finished successfuly. At the begining, when I read quark_d2000_onboard.cfg file (which is loaded to OpenOCD) I found the "flash_rom" procedure which uses load_image command (there is pleace for file and for addresss) I thought that this can resolve my problem with loading the device settings into the flash data memory. But it did not help (there was a problem with "verify_image_offset" so in the next step I commented it out but with no effect either). In the next step I used telnet and I did not recieve any errors so I thought that all is ok but the data wasn't stored in the memory. In the last step I tried to use "mww" command and when I read this address via "mdw" command all was great I mean data was stored properly. My next question is why the "load_image" doesn't work?

            • 3. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
              PabloM_Intel

              Hi Mark,

               

              We are still investigating your case. We will do some more research and will get back to you soon.

               

              Regards,

              Pablo

              • 4. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
                PabloM_Intel

                Hi Mark,

                 

                I’m wondering if you could provide your code here so we can take a look at it. If you can’t share it here in the Community for privacy matters, you can talk with your Intel representative and tell him to help you open an email ticket (a Quark email ticket), that way you can share your code without issues. We would like to see what you have done so far, it will be easier for us to help you that way.

                Once you have opened the ticket or if you have any questions regarding this process please let us know.

                 

                Regards,

                -Pablo

                • 5. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
                  mark_kram

                  Hi Pablo,

                  thank you for your answer and I'm very sorry for my delay but I was on BT last couple days. Reference to my last problem there is no source code because I want only write single .bin file (genereted form external program for example Neo Hex Editor) into flash data region (from address 0x00200000) I want to keep there device settings. I test mentioned commands "load_image" and "mww" from telnet command window

                  • 6. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
                    MichelleC_Intel

                    Hi Mark,

                     

                    With reference to the 'flash_rom' function this should not be changed as it is specific to flashing the ROM to the board.

                     

                    You could write a new function -- for example the below function will flash a .bin file to address 0x00180000

                     

                    proc flash_app { app_file { address 0x00180000 } } {

                      init

                      echo "Setup clock"

                      clk32M

                      echo "Start flash"

                      load_image $app_file $address

                      echo "Start verify"

                      verify_image $app_file $address

                      echo "Reset target"

                      reset halt

                      echo "All done"

                    }

                     

                    Here are the commands I use to initiate the flashing ...

                    • 7. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
                      mark_kram

                      Hi Miechelle,

                         thank you for fast response. Of Course you have right and I prepared and add new function for my "quark_d2000_onboard_cust.cfg" file it works very good. But I have also need to write my some dev settings into flash data region which starts from 0x00200000 address. But when I try to do this (I add another function with changed address) it doesn't work.

                       

                      one.jpg

                       

                      Of course this "dev_set.bin" it is file prepared by my self in Hex editor and it contains only 16B.

                      • 8. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
                        MichelleC_Intel

                        Hi Mark ,

                         

                        It looks like the Data flashed ok - Is the issue that you are unable to read it ?

                         

                        --Michelle.

                        • 9. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
                          mark_kram

                          Hi Miechelle :-),

                             yes I know that the logs looks ok but these 16B from this .bin file aren't saved in flash data region after this operation. I can read data from memory (for example from address 0x00200000, 0x00200004 etc) and send it on UART but they are not changed.

                          I can write a step-by-step what I'm doing maybe it will be helpful?

                           

                          Mark

                          • 10. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
                            MichelleC_Intel

                            Hi Mark ,

                             

                            Yes , please send on the steps you are doing so we can try to replicate.

                             

                            --Michelle

                            • 11. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
                              mark_kram

                              Hi Michelle,

                                  I'm very sorry for my delay but during the tests one of my application which is based on D2000 board I found some issue which need to be repaired very fast.

                              Anyway I just want to write that I will continue this topic in next few days. I'm verry sorry once again but I need to resolve this second much more important problem.

                              • 12. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
                                MichelleC_Intel

                                Hi Mark,

                                 

                                Did you erase the contents before you did the last load ---- 'del_flash0' ?

                                 

                                Have a look that the 'flash_access' example provided in ISSM -- are you able to read the DATA Flash OK id you write using that method ?

                                 

                                /* Flash physical address mappings */

                                #define QM_FLASH_REGION_DATA_0_BASE (0x00200000)

                                #define QM_FLASH_REGION_SYS_0_BASE (0x00180000)

                                #define QM_FLASH_REGION_OTP_0_BASE (0x00000000)

                                 

                                regards,

                                -- Michelle.

                                • 13. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
                                  MichelleC_Intel

                                  Just to note there is an updated 'flash_access' example in the ISSM Update 1 which can be downloaded from :

                                   

                                  Windows Download Link : https://registrationcenter.intel.com/en/forms/?productid=2795

                                  Linux Download Link : https://registrationcenter.intel.com/en/forms/?productid=2796

                                   

                                  regards,

                                  Michelle.

                                  • 14. Re: How to prepare OpenOCD scripts for D2000 - System and Data flash.
                                    mark_kram

                                    Dear Michelle,

                                        thnk you :-) I'll test it today. Before we will contiune our main topic I have some question about Flash Data region (It is directly connected with main problem of this thread of course) . In mentioned sample code (FLASH) I found  commentary as below:

                                    /*

                                    * For Quark Microcontroller D2000, there is 1 flash controller.

                                    * Controller 0:

                                    * |  Component         | Size           | System start address

                                    * |  System ROM      | 8KB             | 0x00000000

                                    * |  System Flash      | 32KB          | 0x00180000

                                    * |  Data region         | 4KB            | 0x00200000

                                    */

                                    so as far as I understand First 8KB from address 0x00000000 it is the ROM part. Second: it is a place for the application code 32KB starting from 0x00180000 and the last third part - it is 4KB (non-volatile memory) which is not cleared during the loading application code process. By following this thought I wrote a simple application which loads couple bytes (for example device address, serial number of device etc [code below] ) into the flash data region (starting from 0x00200000). The data are constantly connected to the device/board. In the next step I load the second application into my borad (this application will read and print parameters of the board written into "Data region" memory from the previolus application) and as far as I understand  this board parameters saved in the memmory region from 0x00200000 address should stay and can be readed by the second application propely? Am I right ?

                                     

                                     

                                    /*CODE OF FIRST APPLICATION - PARAMETERS LOADER*/

                                     

                                    #include "qm_flash.h"

                                    #include "qm_common.h"

                                    #include "qm_identification.h"

                                     

                                    #define NUM_DATA_WORDS (0x03)

                                    #define WR_FLASH_ADDR (0x101C) /*4096 */

                                    #define WR_FLASH_ADDR_IDNUM (0x00)

                                    #define SIZE 4

                                    #define FLASH_ADDR 0x00200000

                                    #define SWAP_UINT32(x) (((x) >> 24) | (((x) & 0x00FF0000) >> 8) | (((x) & 0x0000FF00) << 8) | ((x) << 24))

                                    #define FIRST_DATA_FLASH_PAGE (0x00)

                                    #define MASS_ERASE_INCLUDE_ROM (0x00)

                                    #define US_COUNT (0x20)

                                    #define WAIT_STATES (0x01)

                                     

                                    static uint32_t flash_page_buffer[QM_FLASH_PAGE_SIZE]; /*512 slow 32bit czyli 4kB*/

                                     

                                    typedef struct

                                    {

                                      uint32_t devAddress;

                                      uint8_t devSerNum[16];

                                      uint8_t secData[16];

                                      uint8_t thirdData[8];

                                      uint16_t secCnt;

                                      uint16_t cnt;

                                    } DeviceParams;

                                     

                                    int main(void)

                                    {

                                      qm_flash_config_t cfg_wr, cfg_rd;

                                     

                                    static DeviceParams DevAppParam =

                                    {

                                      .devAddress = 0x07,

                                      .devSerNum = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x10, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66},

                                      .secData = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x10, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66},

                                      .thirdData =     {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88},

                                      .secCnt = 123,

                                      .cnt = 321

                                    };

                                     

                                    DeviceParams ReadedData = {0};

                                     

                                      cfg_wr.us_count = US_COUNT;

                                      cfg_wr.wait_states = WAIT_STATES;

                                      cfg_wr.write_disable = QM_FLASH_WRITE_ENABLE;

                                      qm_flash_set_config(QM_FLASH_0, &cfg_wr);

                                     

                                      qm_flash_page_erase(QM_FLASH_0, QM_FLASH_REGION_DATA, FIRST_DATA_FLASH_PAGE);

                                     

                                      qm_flash_page_update(QM_FLASH_0, QM_FLASH_REGION_DATA, WR_FLASH_ADDR_IDNUM, flash_page_buffer, &DevAppParam, 0xC);

                                     

                                      /*Read and print to UART saved data*/

                                      uint8_t y =0;

                                      QM_PRINTF("*************************************************************\n");

                                      QM_PRINTF("Device config.:\n");

                                      QM_PRINTF("devAddress: \t\t %X \n", *(uint32_t *)0x00200000 );

                                      QM_PRINTF("devSerNum: \t\t %X-%X-%X-%X \n", SWAP_UINT32(*(uint32_t *)0x00200004), SWAP_UINT32(*(uint32_t *)0x00200008),

                                      SWAP_UINT32(*(uint32_t *)0x0020000C), SWAP_UINT32(*(uint32_t *)0x00200010));

                                      QM_PRINTF("secData: \t\t %X-%X-%X-%X \n", SWAP_UINT32(*(uint32_t *)0x00200014), SWAP_UINT32(*(uint32_t *)0x00200018),

                                      SWAP_UINT32(*(uint32_t *)0x0020001C), SWAP_UINT32(*(uint32_t *)0x00200020));

                                      QM_PRINTF("thirdData: \t\t\t %X-%X \n", SWAP_UINT32(*(uint32_t *)0x00200024), SWAP_UINT32(*(uint32_t *)0x00200028 ));

                                      QM_PRINTF("\nApp config.:\n");

                                      QM_PRINTF("cnt: \t\t %d (DEC) \n", *(uint16_t *)0x0020002C);

                                      QM_PRINTF("secCnt: \t %d (DEC)\n", *(uint32_t *)0x0020002C >> 16);

                                      QM_PRINTF("AppParams_t: \t\t %X \n", *(uint32_t *)0x0020002C );

                                      QM_PRINTF("*************************************************************\n");

                                     

                                      return QM_RC_OK;

                                    }

                                     

                                    /*

                                    ADDED -w to app.mk file in section "### Build C files in APP_DIR" as below:

                                     

                                    ### Build C files in APP_DIR

                                    $(APP_DIR)/$(BUILD)/$(SOC)/$(OBJ)/%.o: $(APP_DIR)/%.c libqmsi

                                      $(call mkdir, $(APP_DIR)/$(BUILD)/$(SOC)/$(OBJ))

                                      $(CC) $(CFLAGS) -c -w -o $@ $<

                                    */

                                    1 2 Previous Next