[En-Nut-Discussion] Non reproduceable reboots on 1.3H

Daniel ziu82 at gmx.de
Mon Aug 31 19:25:29 CEST 2009


Hi Coleman,

After reading the API again, I see that you are right. I used the wrong 
buffer.

Thanks for the correction.

Regards,
Daniel


Coleman Brumley schrieb:
> I don't think you were using realloc correctly.
>
> Shouldn't that have been as follows?
>
> void LoadEEString(int offset, int length, char* buffer)
> {
>     buffer = realloc(buffer,length+1);
>     if(buffer)
>     {
>         memset(buffer,(char)0,length);
>         // Load from EEPROM
>         NutEnterCritical();
>         NutNvMemLoad(offset, buffer, length);
>         NutExitCritical();
>         // Get sure that we can use the buffer for I/O functions
>         buffer[length] = '\0';    
>     }
> }
>
>
>
> - Coleman
>
>   
>> -----Original Message-----
>> From: en-nut-discussion-bounces at egnite.de [mailto:en-nut-discussion-
>> bounces at egnite.de] On Behalf Of Daniel
>> Sent: Monday, August 31, 2009 11:00 AM
>> To: Ethernut User Chat (English)
>> Subject: Re: [En-Nut-Discussion] Non reproduceable reboots on 1.3H
>>
>> Hi,
>>
>> Thiago, thanks for the answer. But this was not the problem.
>>
>> For reading from eeprom i used following function:
>>
>> void LoadEEString(int offset, int length, char* buffer)
>> {
>>     realloc(buffer, length+1);
>>     memset(buffer, '\0', length+1);
>>
>>     // Load from EEPROM
>>     NutEnterCritical();
>>     NutNvMemLoad(offset, buffer, length);
>>     NutExitCritical();
>>     // Get sure that we can use the buffer for I/O functions
>>     buffer[length] = '\0';
>> }
>>
>> With this implementation my function shows the strange behaviour and
>> stucks after 3-5 times called.
>>
>> Now I stopped using "realloc" and everything works:
>>
>> void LoadEEString(int offset, int length, char* buffer)
>> {
>>     // Load from EEPROM
>>     NutEnterCritical();
>>     NutNvMemLoad(offset, buffer, length);
>>     NutExitCritical();
>>     // Get sure that we can use the buffer for I/O functions
>>     buffer[length] = '\0';
>> }
>>
>> Is there any know bug about "realloc" or do I have an error in usage of
>> this function?
>>
>> Best regards,
>> Daniel
>>
>> Thiago A. Corrêa schrieb:
>>     
>>> Hi,
>>>
>>> On Mon, Aug 31, 2009 at 8:47 AM, Daniel<ziu82 at gmx.de> wrote:
>>>
>>>       
>>>> Hi Thiago,
>>>>
>>>> Thanks for the fast reply. It's the onboard eeprom.
>>>>
>>>> You say "I haven't checked if ethernut does that, but I do that on
>>>>         
>> my
>>     
>>>> own code before calling ethernut functions.". Can you tell me the
>>>> functions for disabling/enabling interrupts? I found nothing in the
>>>>         
>> API.
>>     
>>>> So I can test if it works with disabled interrupts.
>>>>
>>>>
>>>>         
>>> NutEnterCritical and NutExitCritical disables and reenables
>>> interrupts, respectively. I've wrapped my code between those calls.
>>>
>>> Kind Regards,
>>>    Thiago A. Correa
>>> _______________________________________________
>>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>>
>>>
>>>       
>> _______________________________________________
>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>     
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>   




More information about the En-Nut-Discussion mailing list