#include <rtems.h>
#include <rtems/shell.h>
#include <rtems/nvdisk.h>
#include <rtems/nvdisk-sram.h>
#include <stdlib.h>
#include <stdio.h>
rtems_nvdisk_device_desc rtems_nv_heap_device_descriptor[] =
{
{
.flags = 0,
.base = 0,
.size = 1024 * 1024,
.nv_ops = &rtems_nvdisk_sram_handlers
},
{
.flags = 0,
.base = 0,
.size = 1024 * 1024,
.nv_ops = &rtems_nvdisk_sram_handlers
}
};
const rtems_nvdisk_config rtems_nvdisk_configuration[] =
{
{
.block_size = 512,
.device_count = 2,
.devices = rtems_nv_heap_device_descriptor,
.flags = 0,
.info_level = 1
}
};
uint32_t rtems_nvdisk_configuration_size = 1;
static int create_nvdisk(void){
rtems_status_code sc;
for (uint32_t i = 0; i < rtems_nvdisk_configuration[0].device_count; ++i)
{
rtems_nv_heap_device_descriptor[i].base =
malloc (rtems_nv_heap_device_descriptor[i].size);
printf("nvdisk created\n");
if (!rtems_nv_heap_device_descriptor[i].base)
{
printf ("error: no memory for NV disk %u\n", i);
return 1;
}
printf("NV disk %u memory allocated (%u bytes)\n",
i, rtems_nv_heap_device_descriptor[i].size);
}
for (uint32_t i = 0; i < rtems_nvdisk_configuration[0].device_count; ++i) {
rtems_status_code sc = rtems_nvdisk_initialize(i, 0, NULL);
if (sc != RTEMS_SUCCESSFUL) {
printf("error: nvdisk driver not initialised for device %u: %s\n",
i, rtems_status_text(sc));
} else {
printf("nvdisk %u initialized successfully\n", i);
}
}
printf ("successful\n");
return 0;
}
static rtems_task Init(
rtems_task_argument ignored)
{
(void) ignored;
create_nvdisk();
rtems_shell_init(
"SHLL",
RTEMS_MINIMUM_STACK_SIZE * 4,
100,
"/dev/console",
false,
true,
NULL
);
rtems_task_exit();
}
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 10
#define CONFIGURE_MAXIMUM_DRIVERS 50
#define CONFIGURE_SHELL_COMMANDS_INIT
#define CONFIGURE_SHELL_COMMANDS_ALL
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 50
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
#define CONFIGURE_MAXIMUM_BLOCK_DEVICES 8
#define CONFIGURE_HEAP_SIZE (10*1024*1024)
#define CONFIGURE_POSIX_INIT
#define CONFIGURE_MAXIMUM_POSIX_THREADS 5
#define CONFIGURE_MAXIMUM_POSIX_KEYS 16
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
#include <rtems/shellconfig.h>
i am trying to create multiple nvdisk device and i am getting this error
prakhar@pop-os:~/rtems-mr/app/hello$ qemu-system-sparc -M leon3_generic -nographic -kernel build/sparc-rtems7-leon3/my_shell.exe
nvdisk created
NV disk 0 memory allocated (1048576 bytes)
nvdisk created
NV disk 1 memory allocated (1048576 bytes)
nvdisk 0 initialized successfully
nvdisk:error:disk create phy failed
error: nvdisk driver not initialised for device 1: RTEMS_UNSATISFIED
successful
RTEMS Shell on /dev/console. Use 'help' to list commands.
SHLL [/] # ls -la dev
total 4080
crwxr-xr-x 1 root root 0, 0 Jan 1 00:00 console
brwxr-xr-x 1 root root 2147483648, 538234544 Jan 1 00:00 nvda
what am i doing wrong here or this is the limitation ?
anyone’s help would be highly appreciated