jffs2 mount assert

Ярослав Лещинский midniwalker at gmail.com
Tue Sep 3 16:40:20 UTC 2019


Hello,

Now I'm struggling with mounting of jffs2 using my qspiflash driver.

main.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <fcntl.h>

#include <sched.h>
#include <rtems/jffs2.h>
#include <rtems/libio.h>

#include "config.h"
#include "user.h"
#include "spiflash.h"

#define SPIFLASH_BLOCK_SIZE (0x100)
#define SPIFLASH_SIZE (0x1000000)
#define BASE_FOR_TEST "/mnt"

static int flash_read(
    __attribute__((unused))rtems_jffs2_flash_control *super,
    uint32_t offset,
    unsigned char *buffer,
    size_t size)
{
    spiflash_read(offset, buffer, size);

    return 0;
}

static int flash_write(
    __attribute__((unused))rtems_jffs2_flash_control *super,
    uint32_t offset,
    const unsigned char *buffer,
    size_t size)
{
    spiflash_write(offset, buffer, size);

    return 0;
}

static int flash_erase(
    __attribute__((unused))rtems_jffs2_flash_control *super,
    uint32_t offset)
{
    spiflash_erase(offset);

    return 0;
}

static rtems_jffs2_flash_control spiflash_control =
{
    .block_size = SPIFLASH_BLOCK_SIZE,
    .flash_size = SPIFLASH_SIZE,
    .read = flash_read,
    .write = flash_write,
    .erase = flash_erase
};

static rtems_jffs2_compressor_control compressor_instance =
{
    .compress = rtems_jffs2_compressor_rtime_compress,
    .decompress = rtems_jffs2_compressor_rtime_decompress
};

static const rtems_jffs2_mount_data mount_data =
{
    .flash_control = &spiflash_control,
    .compressor_control = &compressor_instance
};

void *test_qspi(void *arg)
{
    int rv = 0;

    spiflash_init();
    spiflash_bulk_erase();

    rv = mkdir(BASE_FOR_TEST, S_IRWXU | S_IRWXG | S_IRWXO);
    assert(rv == 0);

    rv = mount(
        NULL,
        BASE_FOR_TEST,
        RTEMS_FILESYSTEM_TYPE_JFFS2,
        RTEMS_FILESYSTEM_READ_WRITE,
        &mount_data);

    assert(rv == 0);

    return NULL;
}

void* POSIX_Init(void *arg)
{
    printf("*QSPI*\r\n");

    pthread_t qspi_thread_id;
    pthread_create(&qspi_thread_id, NULL, test_qspi, NULL);

    pthread_exit(0);
}

Output is
*QSPI*
assertion "rv == 0" failed: file "main.c", line 88, function: test_qspi

*** FATAL ***
fatal source: 7 (RTEMS_FATAL_SOURCE_ASSERT)
fatal code: 536917808 (0x2000b730)
RTEMS version: 5.0.0.7dde723c08912abd647750d6f7a45eca20372b85-modified
RTEMS tools: 7.4.1 20190514 (RTEMS 5, RSB
2c264c1ed6195214de095bbb9e67d8d4bfe78fd0, Newlib 1d35a003f)
executing thread ID: 0x08b010002
executing thread name:

rv is equal to -1 after the try of mounting. Qspiflash driver was checked
separately for the write, read, erase operations.

Can someone suggest what to do here?

Thanks.

-- 
--
Kind regards,
*Yaroslav Leshchinsky*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20190903/cd0c807b/attachment-0002.html>


More information about the users mailing list