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.

Startup error

Hi everyone,

I have a strange error in my SYS/BIOS project and I would like to know, what is going on (or isn't). 

When I call BIOS_start() from my main, somewhere in the initialization part of SYS/BIOS, an error is raised, which results in a call to the abort() function, where my software then stays forever.

Now I looked for ways to find some kind of logging, so I could see what goes wrong, and I found that in my .cfg file I can set a logger for common errors

.cfg file:

...

Error.common$.logger = loggerBuf;

...

where loggerBuf is a circular buffer, which I created before.

When starting the software and running it (so that the error occurs), I can see in my ROV, that there is an entry in my loggerBuf.

I attached y screenshot, where the entry can be seen.

Now, how should I read this? What does the eventId and the arguments tell me?

I was not able to find any documentation of this.

Can you help me with this?

Thanks!

  • I did some more debugging and I think there is an error with the HeapMem implementation:

    At line 307 of HeapMem.c (bios_6_34_02_18) it says:

    Error_raise(eb, HeapMem_E_memory, (IArg)obj, (IArg)reqSize);

    Ii can see, that eb equals 0, so in that Error_raise function, bios will halt and abort.

    In other implementations (like HeapBuf) I can see that the Error_raise-call is encapsulated in an if-clause, checking whether an error is actually to be raised, or not.

    Is it correct, that in HeapMem, there is no if-statement around the Error_raise call? Maybe a bug?

    Regarding my error, I'm not yet sure if that's what causes my trouble, I will investigate further. But I wanted to check with you (especially the TI guys), whether the above stated may be a bug.

  • Hi Kai,

    The code is correct. If you pass in a NULL Error_Block and an "error" happens, the program will terminate. The original reasoning was that it helps developers find error conditions quickly. Are you calling Memory_alloc with a NULL Error_Block?  To pass in an Error_Block, it must be initialized first

    Error_Block eb;
    Error_init(&eb);
    buffer = Memory_alloc(heap, size, align, &eb);

    Note there are two ways to check to see if there is a memory allocation failure:

    1. if buffer == NULL (standard way)

    2. Error_check(&eb). You can refer to http://rtsc.eclipse.org/docs-tip/Using_xdc.runtime_Errors/Example_5 or xdc.runtime.Error documenation for more details.

    Todd

  • Hi Todd,

    thanks your answer. 

    I think I was not completely clear. I am not calling the Error_raise function, the HeapMem-Implementation of the SYS/BIOS is doing that. 

    And when I backtrace through the call stack, I see that the HeapMem_alloc function itself is called with the eb parameter set to 0.

    At the moment I cannot tell you exactly, which function is the first one calling some function with eb=0, because I replaced the used heap by HeapBuf. That implementation checks first whether there is actually an error existing, and then calls (if necessary) the Error_raise function (of course with eb=0, but that is alright, because we actually have an error).

    So all in all:

    At the end of the HeapMem_alloc function it reads:

      Gate_leaveModule(key);

      Error_raise(eb, HeapMem_E_memory, (IArg)obj, (IArg)reqSize);

      return (NULL);

    }

    So you see, the implementation does not check, whether there is any error to raise at all.

    In contrast the HeapBuf implementation (HeapBuf_alloc, at the beginning):

    if (size > obj->blockSize) {
      Error_raise(eb, HeapBuf_E_size, (IArg)obj, (IArg)size);
      return (NULL);
    }

    So, it checks if there is an error, and depending on that, it raises the error.

    I hope I was a little more clear.

    The way I see it, there is definitely a bug in the HeapMem implementation. I just downloaded the most current release of SYS/BIOS, and it's the same in that release.

  • The HeapMem_alloc code only calls Error_raise if it could not find a block of memory that satisfied the request. Note the "return" in the while loop. It is this path that is taken when a block is found.

        while (curHeader != NULL) {
                ...
                /* Success, return the allocated memory */
                return ((Ptr)allocAddr);
                ...
        }

    You need to figure out who is calling Memory_alloc with the NULL Error_Block. The same thing will happen with HeapBuf if is runs out of memory and you are passing in a NULL Error_Block.

     Todd

  • Hi Todd,

    yes you're absolutely right. Thanky you! I wonder how that return statement slipped by me (must be the hours of working with that code and thus not being able to see the forest for the trees).

    Thanks!