This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LINKING problem with OAD



Hello everybody,

I have a problem linking my project.

Error[e104]: Failed to fit all segments into specified ranges. Problem discovered in segment CSTART. Unable to place 22 block(s) (0x79e byte(s) total) in 0x752 byte(s) of memory. The problem occurred while processing the segment placement command "-P(CODE)CSTART,BANK_RELAYS,RCODE,DIFUNCT,NEAR_CODE=_CODE_START-_CODE_END", where at the moment of placement the available memory ranges were "CODE:ae-7ff"

I am changing the boot code to adapt to my custom board, that have a external memory but is Atmel memory and not numonyx.

In this adapt process i have changed memory access and no more. when I changed the code , the linker shows the error.

I think that I need to change link features but i don't know how to do!

Can anybody help me?

Regards

  • I was in this situation as well.

    I think you need to get your code to fit in the section or  let the boot code occupy two sectors.  If you do the latter you'll also have to make changes to the application code.

    I ended up tightening up my code so that it would it fit in the 0x00ae - 0x07FFF region.

    -Michael

     

  • Hello Michael,

    I can not fit the boot code. I don't know how can i do to fit it! can you help me?

    I have changed the HalSPIRead & HalSPIWrite functions because in my design I have other external Flash memory.

    Can you tell me what can i remove to fit the code?

    ( if you need more information, please tell me and I would try to give you! ) 

     

     

  • Xabier,

     

    Possibly you could post the the changes you made and I could offer some ways to reduce your code size.

     

    -Michael

  • Xabier,

    I believe you will need to change -D_CODE_END=0x07FF to -D_CODE_END=0x0FFF. This should give you enough room for future expansion (remember page size on 2530 is 2048 bytes). Then in interrupt_stubs.a51 you will need to change the offset to 0x1000 instead of 0x0800.

    Hope this helps.

  • Double 0,

    I have changed the code as you say but when I am debugging I have found another problem:

    The debugg session stops and shows this messages in the log:


    Fri Apr 15 10:07:44 2011: No verification errors found during download. 

    Fri Apr 15 10:07:44 2011: Download completed and verification successful. 

    Fri Apr 15 10:07:44 2011: Loaded debugee: C:\Users\Xabi\Desktop\Nueva carpeta\ZStack-CC2530-2.4.0-1.4.0 - OAD\Projects\zstack\Utilities\OAD\CC2530DB\OAD-Boot\Exe\Boot.d51 

    Fri Apr 15 10:07:44 2011: Target reset 
    Fri Apr 15 10:07:51 2011: Program exit reached. 

    Fri Apr 15 10:07:51 2011: The stack 'XdataStack' is filled to 100% (256 bytes used out of 256). The warning threshold is set to 90.% 

    Can you tell me what is this and how can i solve it?

  • Double 0,

    First of all i have to say that the last post's error has dissapeared. maybe was the IAR that it was working wrong.

    But well, now I have the OTA project working properly.

    My next step is to add this OTA project in my own application. For that, I have modified my project.

    After modification the IAR shows me this message when I link the code:

    Fatal Error[e72]: Segment LOCK_BITS_ADDRESS_SPACE must be defined in a segment definition option (-Z, -b or -P) 

    I don't know if the last changes affect and I have to change something in the project too.

    Can you tell me something to solve it?

    Thanks

  • Check that you placed the

    MAKE_CRC_SHDW

    in C/C++ Compiler->Preprocessor->Defined Symbols

    If you leave it out or mistype it, you will get this error.

    -Michael

     

  • Hell Michael,

    I have added this Define and now the Linker shows me this error:

    Fatal Error[e72]: Segment CRC must be defined in a segment definition option (-Z, -b or -P) 

    Can you tell me anything now?
    Thanks, 

  • Hi again,

    I have looked at the ota.xcl file and I think that there are things that we need to change!

     

    -D_CODE_START=0x0800

    I think that this have to be changed to 0x1000

     

    -Z(CODE)CRC=0x0888-0x088B

    -Z(CODE)PREAMBLE=0x088C-0x0897

    those CRC and Preamble definitons are in boot size and I think that I have to change, but what is the best definition value?

     

    -P(CODE)BANKED_CODE=0x0800-0x7FFF,0x18000-0x1FFFF,0x28000-0x2FFFF,0x38000-0x3FFFF,0x48000-0x4FFFF,\

    0x58000-0x5FFFF,0x68000-0x6FFFF,0x78000-0x7C7FF

    In this line I think that i have to chage 0x0800, like in the first definition.

     

    Please tell me if those changes are the solution, and in the CRC and PREAMBLE defines, please tell me the best value.

    Regards,

  • I believe you are correct. Basically doing a global replacement for 0x800 should do the trick. For example, -Z(CODE)CRC=0x1088-0x108B instead of the original values.

  • I am back already.

    I have solved Linker problem! ( I have reduced the code)

    After reduce the code I have found another problemm and it is in upgrade process.

    The process starts correctly and the OTA console sends well the image, but after complete the send the image, the device don't send the COMMAND UPGRADE END REQUEST.

    I read the Attributes and the Upgrade Status is COmplete (0x02).

    The problem is that if the device don't send this Upgradre end command, the device stop and it doesn't upgrade.

    Can anybody tell me anything?

    Regards

  • Hello,

    I have debugged the code and I have found two things:

    1- Sometimes at the end of the OTA process, the COMMAND_UPGRADE_END_REQ doesn't  send and the process is stopped.

    2- Everytime when the OTA process arrive to zclOTA_UpgradeComplete, the device doesn't send the  this menssage:

          pMsg->hdr.event = ZCL_OTA_CALLBACK_IND;

          pMsg->hdr.status = status;

          pMsg->ota_event = ZCL_OTA_DL_COMPLETE_CALLBACK;

          osal_msg_send(zclOTA_AppTask, (uint8*) pMsg);

     

    and the device is dissapeared by the zigbee net.

  • Can you attach a Ubilogix trace of the whole process? This would be helpful in troubleshooting the problem.

  • Hello Double 0,

    I can't send you Ubilogix traces, because i don't use this program. I use Texas Instruments SmartRF Packet Sniffer. I can send you traces with this but do you want it?

  • 6278.OTA process.psd

    This is the OTA process traces file. 

    I have used the Texas Instruments sniffer and the OTA process is in the 0x6ab3.

    (the ota console shows me : "Download Completed succesfully" )

    Tell me something please!

  • Did you change the values in hal_ota.h to reflect your new linker file placements?

    // Placement controlled by ota.xcl.
    #define HAL_OTA_RC_START           0x0800
    #define HAL_OTA_CRC_ADDR           0x0888

    Should be changed to

    // Placement controlled by ota.xcl.
    #define HAL_OTA_RC_START           0x1000
    #define HAL_OTA_CRC_ADDR           0x1088

    My guess is that the crc check is failing because crc is being pulled from the wrong location. You could debug this by download the bootcode separately (make sure to uncheck erase flash option).

  • Hello "Double 0",

    I have advanced a little bit in the OTA process and I want to explain you my news.

    I have obtained to fit the code in the boot size. (0x0800)
    My first advance is about the SPI WRITE and READ in OTA Boot process.
    During the OTA process the new Code image is sent to the device. Depending on the image size the user can to use the internal flash or need to use a external memory.
    In my case I have to use the external size because the image size is more than the midle of the internal size.

    Well, I have used the OTA console to send the ".zigbee" file and I think that the process to send the image is correct. I think it because, first the OtaConsole shows me the menssage "Download Completed Succesfully".Second I have looked at the external memory and the image's code is into ( I don't compare the internal code with the ".zigbee" file, but the size is correct and apparently this image doesn't have any estrange things.)

    After send the image, the OTA Boot process code reads the CRC by the internal Flash. This CRC has 2 values and if they are the same this boot process finishes. If the values are different, start the process.
    Depending on the difference, the process is different (this is the code).

        if (OTA_crcControl.crc[0] == OTA_crcControl.crc[1])
        {
          break;
        }
        else if ((OTA_crcControl.crc[0] != 0) && (OTA_crcControl.crc[0] == crcCalc()))
        {
          OTA_crcControl.crc[1] = OTA_crcControl.crc[0];
          HalFlashWrite((HAL_OTA_CRC_ADDR / HAL_FLASH_WORD_SIZE), (uint8 *)OTA_crcControl.crc, 1);
        }
        else
        {
          dl2rc();
        }
    When the OTA process is  enabled, the function "dl2rc" is called8372.OTA process.psd. You can asnwer Why?
    Well, when the new image is sent, the OTA process write the first crc value to cero. this is done in this fucntion "HalOTAInvRC();". After do it, the next step is reset the code. you can look at this here:
      case ZCL_OTA_DL_COMPLETE_CALLBACK:
        if (pMsg->hdr.status == ZSuccess)
        {
          // Reset the CRC Shadow and reboot.  The bootloader will see the 
          // CRC shadow has been cleared and switch to the new image
          HalOTAInvRC();
          SystemReset();
        }
     void HalOTAInvRC(void)
    {
      uint16 crc[2] = {0,0xFFFF};
      HalFlashWrite((HAL_OTA_CRC_ADDR / HAL_FLASH_WORD_SIZE), (uint8 *)crc, 1);
    }

    The restart is well and I think that the Boot code works but i don't know if it works well.
    I have attached OTAProcess traces to understand better the process (this traces are the same that you can find in the forum post).

    In this traces you can see that after to send all the image the device who receives the new code wait 60 seconds aprox. ( this is the Countdown time who is ordered by the OtaConsole)
    After this wait time, the device's traces doesn't exist. I think that the upgraded image is incorrect and for this reason is out of the zigbee net. ( Is one idea!)

    As you can see, I have advanced in the OTA process.

    Well I want your opinion and advices about this error, but I wanto to say you my opinion.

    I think that the OTAconsole send well the image and the device save this code correctly.
    The process steps are well and the Device is reseted.
    After reset, the device is started with the boot code and the device compares the CRC values.
    ( this part of the comparison is a supposition, because I can't debug it! If you know any form to debug it please tell me!)
    The CRC-s are different and start the dl2rc process.

    static void dl2rc(void)
    {
      uint32 oset;
      OTA_SubElementHdr_t subElement;
      OTA_ImageHeader_t header;
      uint16 addr = HAL_OTA_RC_START / HAL_FLASH_WORD_SIZE;
      uint8 buf[4];

      // Determine the length and starting point of the upgrade image
      HalOTARead(0, (uint8 *)&header, sizeof(OTA_ImageHeader_t), HAL_OTA_DL);
      HalOTARead(header.headerLength, (uint8*)&subElement, OTA_SUB_ELEMENT_HDR_LEN, HAL_OTA_DL);

      for (oset = 0; oset < subElement.length; oset += HAL_FLASH_WORD_SIZE)
      {
        HalOTARead(oset + header.headerLength + OTA_SUB_ELEMENT_HDR_LEN, buf, HAL_FLASH_WORD_SIZE, HAL_OTA_DL);
        if ((addr % (HAL_FLASH_PAGE_SIZE / HAL_FLASH_WORD_SIZE)) == 0)
        {
          HalFlashErase(addr / (HAL_FLASH_PAGE_SIZE / HAL_FLASH_WORD_SIZE));
        }
        HalFlashWrite(addr++, buf, 1);
      }
    }
    In this process the device reads the code and save it in the internal Flash.

    Well in this process, maybe the read function is wrong! but I don't know how to verify it! I can't debug this code!

    The other problem maybe is the sent code. I don't know if when this code is moved into the flash ( the new code), the boot loader code is erased! Can you tell me if in this process the bootloader code is erased? Do I have to add the bootcode in the new image?
    I say the last, because after all the process the device don't work well and when you download and debug only the code ( without bootload) the device doesn't work well!!
    Or can be because when I write the new image, I write it in a specific place of the memory not the first address.  but all the image is sended well!! and I would be very strange!

    Please tell me something!!