Document number
205065
Version
Rev. N
Issue date
2019-02-04
Sirius OBC and TCM User Manual
Page
106
of
174
5.12.4.3. RTEMS application example
In order to use the system flash driver in the RTEMS environment, the following code
structure is suggested to be used:
Inclusion of
<fcntl.h>
and <unistd.h>
are required for using the POSIX functions
open
,
close
,
lseek
,
read
,
write
and
ioctl
functions for accessing driver.
Inclusion of
<errno.h>
is required for retrieving error values on failures.
Inclusion of <
bsp/system_flash_rtems.h>
is required for driver related definitions
.
Inclusion of <
bsp/bsp_confdefs.h>
is required to initialise the driver at boot up.
CONFIGURE_APPLICATION_NEEDS_SYSTEM_FLASH_DRIVER
must be defined for using
the driver. This will automatically initialise the driver at boot up.
5.12.5. Debug detect
Erasing blocks/programming pages to the first half of the flash memory (lower addresses)
only works when the debug detect signal is high (indicating debugger is connected). If
erase/program operations to that area are attempted when the debug detect signal is low
they will appear to succeed from a software perspective but the controller will not pass them
on to the flash chip.
5.12.6. Limitations
The system flash driver may only have one open file descriptor at a time.
The POSIX interface is modified to use an offset in pages instead of bytes.
#include <bsp.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <bsp/system_flash_rtems.h>
#define CONFIGURE_APPLICATION_NEEDS_SYSTEM_FLASH_DRIVER
.
.
#define CONFIGURE_INIT
rtems_task Init (rtems_task_argument argument);
#include <bsp/bsp_confdefs.h>
#include <rtems/confdefs.h>
rtems_task Init (rtems_task_argument ignored)
{
.
fd = open(SYSFLASH_DEVICE_NAME, O_RDWR);
.
}