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.

RTOS/CC1310: Assert_isTrue()

Part Number: CC1310

Tool/software: TI-RTOS

Hi,

I am implementing a bootloader and made a simple project to validate everything.

In that simple project I used the following verifications before writing to flash:

/* Check overall boundaries */
    Assert_isTrue((uint32_t)destAddr >= FLASH_APPLICATION_ADDR, 0);
    Assert_isTrue(((uint32_t)destAddr + nBytes) < (FLASH_APPLICATION_ADDR + FLASH_APPLICATION_SIZE), 1);

    /* Check that we do not cross a page boundary when FLASH_DATA_SIZE is more than one page */
    Assert_isTrue(((uint32_t)destAddr - pageStartAddr + nBytes) <= FLASH_PAGE_SIZE, 2);

    /*
     Make sure that the flash functions from driverlib are either located in ROM or SRAM,
     but not in FLASH. This is the normal case in TI-RTOS.
     */
    Assert_isTrue((uint32_t)&FlashProgram > (FLASH_BASE_ADDR + FLASH_SIZE), 3);

Now, I would like to keep that bootloader as smallest as possible. One of the modifications is remove the assert module.

I replaced the verifications as follows:

    /* Check overall boundaries */
    if((uint32_t)destAddr < FLASH_APPLICATION_ADDR)
    {
        while(1);
    }

    if(((uint32_t)destAddr + nBytes) > (FLASH_APPLICATION_ADDR + FLASH_APPLICATION_SIZE))
    {
        while(1);
    }

    /* Check that we do not cross a page boundary when FLASH_DATA_SIZE is more than one page */
    if(((uint32_t)destAddr - pageStartAddr + nBytes) > FLASH_PAGE_SIZE)
    {
        while(1);
    }

    /*
     Make sure that the flash functions from driverlib are either located in ROM or SRAM,
     but not in FLASH. This is the normal case in TI-RTOS.
     */
    if((uint32_t)&FlashProgram < (FLASH_BASE_ADDR + FLASH_SIZE))
    {
        while(1); <= THE PROGRAM STOPS HERE!
    }

The verification is failing in the point marked above.

What is the difference between "Assert_isTrue((uint32_t)&FlashProgram > (FLASH_BASE_ADDR + FLASH_SIZE), 3);" and "if((uint32_t)&FlashProgram < (FLASH_BASE_ADDR + FLASH_SIZE))"?

Best regards,

  • Assert_isTrue() requires that the module Assert is configured to enable asserts for a specific module or in general. See rtsc.eclipse.org/.../Assert.html
    The IDs that you are using for your asserts are usually constants from XDC files whose value is not known at the time you are writing your source code, so 0, 1, 2 and 3 are probably not the right values. Please check the linked documentation and verify that your config script is setting the right bits for asserts to work.
  • Hi Sasha,

    I don't think you understood the problem.

    Everything works fine when using the Assert_isTrue().

    The problem happens when I replace:

    Assert_isTrue((uint32_t)&FlashProgram > (FLASH_BASE_ADDR + FLASH_SIZE), 3);

    For:

    if((uint32_t)&FlashProgram < (FLASH_BASE_ADDR + FLASH_SIZE))
    {
        while(1); <= THE PROGRAM STOPS HERE!
    }
  • If Asserts are not configured properly, they are simply NOPs. Your FlashProgram address could be less than FLASH_BASE_ADDR + FLASH_SIZE, but an Assert is not going to be raised.
  • You are saying that the problem can be happening but the assert function is not getting it. Correct?

    In this case, I think the program should not work. But it is working. That is wierd.
  • What happens if you completely comment out that if check for FlashProgram?
  • The program works.

    The verification (which I got from a example) is that:

    /*
    
        Make sure that the flash functions from driverlib are either located in ROM or SRAM,
    
        but not in FLASH. This is the normal case in TI-RTOS.
    
        */

    In the .cfg file, the TI-RTOS is stored in ROM. So the "if((uint32_t)&FlashProgram < (FLASH_BASE_ADDR + FLASH_SIZE))" should not get any problem. But that is not what is happening.

    /* ================ ROM configuration ================ */
    /*
     * To use BIOS in flash, comment out the code block below.
     */
    var ROM = xdc.useModule('ti.sysbios.rom.ROM');
    if (Program.cpu.deviceName.match(/CC26/)) {
        ROM.romName = ROM.CC2650;
    }
    else if (Program.cpu.deviceName.match(/CC13/)) {
        ROM.romName = ROM.CC1350;
    }

  • That's a separate question. I just wanted to establish that Assert_isTrue is a NOP, and your program behaves the same with Assert_isTrue and with the 'if' check commented out. Did I get that right?

    As for the new problem, I am not familiar with ROM and FLASH addresses, but shouldn't your check be
    if ( (uint32_t)&FlashProgram > FLASH_BASE_ADDR && (uint32_t)&FlashProgram < (FLASH_BASE_ADDR + FLASH_SIZE))
  • I'm closing this thread out due to no recent activity.

    Todd