STM32 BBSRAM driver updated by David Sidrane
This commit is contained in:
parent
b17303e8ab
commit
5eba2afbd6
@ -85,8 +85,9 @@
|
|||||||
|
|
||||||
#define BBSRAM_HEADER_SIZE (sizeof(struct bbsramfh_s))
|
#define BBSRAM_HEADER_SIZE (sizeof(struct bbsramfh_s))
|
||||||
#define BBSRAM_CRCED_OFFSET (sizeof(((struct bbsramfh_s *)0)->crc))
|
#define BBSRAM_CRCED_OFFSET (sizeof(((struct bbsramfh_s *)0)->crc))
|
||||||
#define BBSRAM_CRCED_SIZE(l) (BBSRAM_HEADER_SIZE-BBSRAM_CRCED_OFFSET+(l))
|
#define BBSRAM_CRCED_SIZE(l) (BBSRAM_HEADER_SIZE-(BBSRAM_CRCED_OFFSET)+(l))
|
||||||
#define BBSRAM_ALIGNMENT (sizeof(((struct bbsramfh_s *)0)->crc))
|
#define BBSRAM_ALIGNMENT (sizeof(((struct bbsramfh_s *)0)->crc))
|
||||||
|
#define BBSRAM_ALIGNMENT_MASK (BBSRAM_ALIGNMENT-1)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
@ -657,13 +658,13 @@ static int stm32_bbsram_probe(int *ent, struct stm32_bbsram_s pdev[])
|
|||||||
|
|
||||||
if (size == -1)
|
if (size == -1)
|
||||||
{
|
{
|
||||||
size = avail - (BBSRAM_HEADER_SIZE + BBSRAM_ALIGNMENT);
|
size = avail - (BBSRAM_HEADER_SIZE + BBSRAM_ALIGNMENT_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add in header size and keep aligned */
|
/* Add in header size and keep aligned */
|
||||||
|
|
||||||
alloc = size + BBSRAM_HEADER_SIZE + BBSRAM_ALIGNMENT;
|
alloc = size + BBSRAM_HEADER_SIZE + BBSRAM_ALIGNMENT_MASK;
|
||||||
alloc &= ~(BBSRAM_ALIGNMENT-1);
|
alloc &= ~(BBSRAM_ALIGNMENT_MASK);
|
||||||
|
|
||||||
/* Does it fit? */
|
/* Does it fit? */
|
||||||
|
|
||||||
@ -806,6 +807,7 @@ int stm32_bbsram_savepanic(int fileno, uint8_t *context, int length)
|
|||||||
{
|
{
|
||||||
FAR struct bbsramfh_s *bbf;
|
FAR struct bbsramfh_s *bbf;
|
||||||
int fill;
|
int fill;
|
||||||
|
int ret = -ENOMEM;
|
||||||
|
|
||||||
/* on a bad day we could panic while panicking, (and we debug assert)
|
/* on a bad day we could panic while panicking, (and we debug assert)
|
||||||
* this is a potential feeble attempt at only writing the first
|
* this is a potential feeble attempt at only writing the first
|
||||||
@ -824,7 +826,13 @@ int stm32_bbsram_savepanic(int fileno, uint8_t *context, int length)
|
|||||||
|
|
||||||
DEBUGASSERT(bbf);
|
DEBUGASSERT(bbf);
|
||||||
|
|
||||||
if (bbf)
|
/* As once ensures we will keep the first dump checking the time for
|
||||||
|
* 0 protects from over writing a previous crash dump that has not
|
||||||
|
* been saved to long term storage and erased. The dreaded reboot
|
||||||
|
* loop.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (bbf && (bbf->lastwrite.tv_sec == 0 && bbf->lastwrite.tv_nsec == 0))
|
||||||
{
|
{
|
||||||
/* Clamp length if too big */
|
/* Clamp length if too big */
|
||||||
|
|
||||||
@ -851,10 +859,11 @@ int stm32_bbsram_savepanic(int fileno, uint8_t *context, int length)
|
|||||||
stm32_bbsram_internal_close(bbf);
|
stm32_bbsram_internal_close(bbf);
|
||||||
|
|
||||||
stm32_bbsram_lock();
|
stm32_bbsram_lock();
|
||||||
|
ret = length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return length;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user