2017-04-12 09:25:37 +08:00
|
|
|
/*
|
2018-10-16 13:00:37 +08:00
|
|
|
* Copyright (c) 2006-2018, RT-Thread Development Team
|
2017-04-12 09:25:37 +08:00
|
|
|
*
|
2018-10-16 13:00:37 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2017-04-12 09:25:37 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2009-01-05 Bernard the first version
|
|
|
|
* 2014-04-27 Bernard make code cleanup.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <board.h>
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <drivers/mtd_nand.h>
|
|
|
|
#include "finsh.h"
|
|
|
|
#include "time.h"
|
|
|
|
#ifdef RT_USING_DFS
|
|
|
|
/* dfs init */
|
2017-10-20 12:53:18 +08:00
|
|
|
|
2017-04-12 09:25:37 +08:00
|
|
|
/* dfs filesystem:ELM filesystem init */
|
|
|
|
#include <dfs_elm.h>
|
|
|
|
/* dfs Filesystem APIs */
|
|
|
|
#include <dfs_fs.h>
|
|
|
|
#include <dfs_posix.h>
|
2017-11-28 21:31:55 +08:00
|
|
|
|
|
|
|
#include <dfs_romfs.h>
|
2017-04-12 09:25:37 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_LWIP
|
|
|
|
#include <lwip/sys.h>
|
|
|
|
#include <lwip/api.h>
|
|
|
|
#include <netif/ethernetif.h>
|
2017-06-08 15:34:00 +08:00
|
|
|
#include "drv_eth.h"
|
2017-04-12 09:25:37 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RT_USING_GDB
|
|
|
|
#include <gdb_stub.h>
|
|
|
|
#endif
|
2017-06-08 15:34:00 +08:00
|
|
|
|
2018-03-03 16:34:01 +08:00
|
|
|
#ifdef PKG_USING_GUIENGINE
|
2017-06-08 15:34:00 +08:00
|
|
|
#include "rtgui_demo.h"
|
|
|
|
#include <rtgui/driver.h>
|
|
|
|
#endif
|
|
|
|
|
2017-04-12 09:25:37 +08:00
|
|
|
void rt_init_thread_entry(void* parameter)
|
|
|
|
{
|
|
|
|
/* initialization RT-Thread Components */
|
|
|
|
#ifdef RT_USING_COMPONENTS_INIT
|
|
|
|
rt_components_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* GDB STUB */
|
|
|
|
#ifdef RT_USING_GDB
|
|
|
|
gdb_set_device("uart6");
|
|
|
|
gdb_start();
|
|
|
|
#endif
|
2017-11-28 21:31:55 +08:00
|
|
|
|
|
|
|
#ifdef RT_USING_DFS
|
|
|
|
|
|
|
|
#ifdef RT_USING_DFS_ELMFAT
|
|
|
|
|
2017-04-12 09:25:37 +08:00
|
|
|
{
|
2017-11-28 21:31:55 +08:00
|
|
|
static const rt_uint8_t _romfs_root_readme_txt[] = {
|
|
|
|
0x52,0x54,0x2d,0x54,0x68,0x72,0x65,0x61,0x64,0x0d,0x0a,0x00
|
|
|
|
};
|
|
|
|
|
|
|
|
static const rt_uint8_t _romfs_root_sdcard_aaa_txt[] = {
|
|
|
|
0x52,0x54,0x2d,0x54,0x68,0x72,0x65,0x61,0x64,0x0d,0x0a,0x00
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct romfs_dirent _romfs_root_sdcard[] = {
|
|
|
|
{ROMFS_DIRENT_FILE, "aaa.txt", (rt_uint8_t *)_romfs_root_sdcard_aaa_txt, sizeof(_romfs_root_sdcard_aaa_txt)/sizeof(_romfs_root_sdcard_aaa_txt[0])}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const rt_uint8_t _romfs_root_spi_bbb_txt[] = {
|
|
|
|
0x52,0x54,0x2d,0x54,0x68,0x72,0x65,0x61,0x64,0x0d,0x0a,0x00
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct romfs_dirent _romfs_root_spi[] = {
|
|
|
|
{ROMFS_DIRENT_FILE, "bbb.txt", (rt_uint8_t *)_romfs_root_spi_bbb_txt, sizeof(_romfs_root_spi_bbb_txt)/sizeof(_romfs_root_spi_bbb_txt[0])}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct romfs_dirent _romfs_root[] = {
|
|
|
|
{ROMFS_DIRENT_FILE, "readme.txt", (rt_uint8_t *)_romfs_root_readme_txt, sizeof(_romfs_root_readme_txt)/sizeof(_romfs_root_readme_txt[0])},
|
|
|
|
{ROMFS_DIRENT_DIR, "sdcard", (rt_uint8_t *)_romfs_root_sdcard, sizeof(_romfs_root_sdcard)/sizeof(_romfs_root_sdcard[0])},
|
|
|
|
{ROMFS_DIRENT_DIR, "spi", (rt_uint8_t *)_romfs_root_spi, sizeof(_romfs_root_spi)/sizeof(_romfs_root_spi[0])}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct romfs_dirent romfs_root = {
|
|
|
|
ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root)/sizeof(_romfs_root[0])
|
|
|
|
};
|
|
|
|
|
|
|
|
if (dfs_mount(RT_NULL, "/", "rom", 0, &(romfs_root)) == 0)
|
|
|
|
{
|
|
|
|
rt_kprintf("ROM file system initializated!\n");
|
|
|
|
}
|
2017-04-12 09:25:37 +08:00
|
|
|
}
|
2017-11-28 21:31:55 +08:00
|
|
|
|
|
|
|
/* mount sd card fat partition 0 as root directory */
|
|
|
|
if (dfs_mount("W25Q256", "/spi", "elm", 0, 0) == 0)
|
2017-04-12 09:25:37 +08:00
|
|
|
{
|
2017-11-28 21:31:55 +08:00
|
|
|
rt_kprintf("spi flash mount to /spi !\n");
|
2017-04-12 09:25:37 +08:00
|
|
|
}
|
2017-11-28 21:31:55 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
rt_kprintf("spi flash mount to /spi failed!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mount sd card fat partition 0 as root directory */
|
|
|
|
if (dfs_mount("sd0", "/sdcard", "elm", 0, 0) == 0)
|
|
|
|
{
|
|
|
|
rt_kprintf("sd card mount to /sdcard!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rt_kprintf("sd card mount to /sdcard failed!\n");
|
|
|
|
}
|
|
|
|
#endif /* RT_USING_DFS_ELMFAT */
|
2017-04-12 09:25:37 +08:00
|
|
|
|
|
|
|
#endif /* DFS */
|
2017-06-08 15:34:00 +08:00
|
|
|
|
2018-03-03 16:34:01 +08:00
|
|
|
#ifdef PKG_USING_GUIENGINE
|
2017-06-08 15:34:00 +08:00
|
|
|
{
|
|
|
|
rt_device_t device;
|
2017-04-12 09:25:37 +08:00
|
|
|
|
2017-06-08 15:34:00 +08:00
|
|
|
device = rt_device_find("lcd");
|
|
|
|
/* re-set graphic device */
|
|
|
|
rtgui_graphic_set_device(device);
|
|
|
|
|
|
|
|
rt_gui_demo_init();
|
|
|
|
}
|
2017-04-12 09:25:37 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
int rt_application_init()
|
|
|
|
{
|
|
|
|
rt_thread_t tid;
|
|
|
|
|
|
|
|
|
|
|
|
tid = rt_thread_create("init",
|
|
|
|
rt_init_thread_entry, RT_NULL,
|
|
|
|
2048, RT_THREAD_PRIORITY_MAX/3, 20);
|
|
|
|
|
|
|
|
if (tid != RT_NULL)
|
|
|
|
rt_thread_startup(tid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|