summaryrefslogtreecommitdiff
path: root/bsp/nuvoton/numaker-m032ki/applications/mnt.c
blob: 680e5f2e8627ff0a2aa06a626b5dccde70c8cb50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**************************************************************************//**
*
* @copyright (C) 2019 Nuvoton Technology Corp. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date            Author       Notes
* 2020-1-16       Wayne        First version
*
******************************************************************************/

#include <rtthread.h>

#include <dfs_fs.h>
#include <dfs_file.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/statfs.h>

#if defined(RT_USING_FAL)
    #include <fal.h>
#endif

#if defined(BOARD_USING_STORAGE_SPIFLASH)
    #define MOUNT_POINT_SPIFLASH0 "/"
#endif

#if defined(BOARD_USING_STORAGE_SPIFLASH)

#if defined(RT_USB_DEVICE_MSTORAGE)
int mnt_init_spiflash0(void)
{
    rt_kprintf("Sorry, you enabled RT_USB_DEVICE_MSTORAGE option in menu, so we won't mount flash0 on /.\n");
    return 0;
}
#else

int mnt_init_spiflash0(void)
{
    if (dfs_mount("flash0", MOUNT_POINT_SPIFLASH0, "elm", 0, 0) != 0)
    {
        rt_kprintf("Failed to mount elm on %s.\n", MOUNT_POINT_SPIFLASH0);
        rt_kprintf("Try to execute 'mkfs -t elm flash0' first, then reboot.\n");
        goto exit_mnt_init_spiflash0;
    }
    rt_kprintf("mount flash0 with elmfat type: ok\n");

exit_mnt_init_spiflash0:

    return 0;
}
#endif
INIT_ENV_EXPORT(mnt_init_spiflash0);
#endif