Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
messigogogo committed Nov 10, 2023
1 parent 25570f9 commit 7331bf5
Show file tree
Hide file tree
Showing 47 changed files with 838 additions and 1,369 deletions.
1 change: 1 addition & 0 deletions bsp/phytium/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
| E2000Q | 支持 | 支持SMP |
| E2000S | 支持 | |

- Phytium PI 上使用 RT-Thread 要注意读写操作不能影响 SD 卡的固件,具体使用方法可以[参考](./doc/use_phytium_pi_sd_image.md)

## 如何在Ubuntu/Windows 环境下使用此BSP

Expand Down
53 changes: 33 additions & 20 deletions bsp/phytium/aarch32/.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ CONFIG_RT_NAME_MAX=16
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
# CONFIG_RT_USING_SMART is not set
# CONFIG_RT_USING_AMP is not set
# CONFIG_RT_USING_SMP is not set
CONFIG_RT_CPUS_NR=1
CONFIG_RT_USING_SMP=y
CONFIG_RT_CPUS_NR=4
CONFIG_RT_ALIGN_SIZE=4
# CONFIG_RT_THREAD_PRIORITY_8 is not set
CONFIG_RT_THREAD_PRIORITY_32=y
Expand All @@ -24,6 +24,7 @@ CONFIG_RT_HOOK_USING_FUNC_PTR=y
CONFIG_RT_USING_IDLE_HOOK=y
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
CONFIG_IDLE_THREAD_STACK_SIZE=4096
CONFIG_SYSTEM_THREAD_STACK_SIZE=4096
CONFIG_RT_USING_TIMER_SOFT=y
CONFIG_RT_TIMER_THREAD_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=4096
Expand Down Expand Up @@ -186,15 +187,23 @@ CONFIG_RT_SERIAL_RB_BUFSZ=1024
# CONFIG_RT_USING_PIN is not set
# CONFIG_RT_USING_ADC is not set
# CONFIG_RT_USING_DAC is not set
# CONFIG_RT_USING_NULL is not set
# CONFIG_RT_USING_ZERO is not set
# CONFIG_RT_USING_RANDOM is not set
CONFIG_RT_USING_NULL=y
CONFIG_RT_USING_ZERO=y
CONFIG_RT_USING_RANDOM=y
# CONFIG_RT_USING_PWM is not set
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_SDIO is not set
CONFIG_RT_USING_RTC=y
# CONFIG_RT_USING_ALARM is not set
# CONFIG_RT_USING_SOFT_RTC is not set
CONFIG_RT_USING_SDIO=y
CONFIG_RT_SDIO_STACK_SIZE=4096
CONFIG_RT_SDIO_THREAD_PRIORITY=15
CONFIG_RT_MMCSD_STACK_SIZE=4096
CONFIG_RT_MMCSD_THREAD_PREORITY=22
CONFIG_RT_MMCSD_MAX_PARTITION=16
# CONFIG_RT_SDIO_DEBUG is not set
# CONFIG_RT_USING_SPI is not set
# CONFIG_RT_USING_WDT is not set
# CONFIG_RT_USING_AUDIO is not set
Expand Down Expand Up @@ -851,6 +860,7 @@ CONFIG_RT_USING_ADT_REF=y
# CONFIG_PKG_USING_ST7789 is not set
# CONFIG_PKG_USING_VS1003 is not set
# CONFIG_PKG_USING_X9555 is not set
# CONFIG_PKG_USING_SYSTEM_RUN_LED is not set
# CONFIG_PKG_USING_SPI_TOOLS is not set

#
Expand Down Expand Up @@ -1180,7 +1190,12 @@ CONFIG_RT_USING_UART1=y
# CONFIG_BSP_USING_ETH is not set
# CONFIG_BSP_USING_PWM is not set
# CONFIG_BSP_USING_I2C is not set
# CONFIG_BSP_USING_SDIF is not set
CONFIG_BSP_USING_SDIF=y
CONFIG_BSP_USING_SDCARD_FATFS=y
CONFIG_BSP_USING_SDCARD_PARTITION="sd1"
CONFIG_USING_SDIF0=y
# CONFIG_USING_SDIF1 is not set
# CONFIG_USING_EMMC is not set

#
# Board extended module Drivers
Expand All @@ -1196,15 +1211,14 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y
#
# Soc configuration
#
# CONFIG_TARGET_PHYTIUMPI is not set
CONFIG_TARGET_PHYTIUMPI=y
# CONFIG_TARGET_E2000Q is not set
CONFIG_TARGET_E2000D=y
# CONFIG_TARGET_E2000D is not set
# CONFIG_TARGET_E2000S is not set
# CONFIG_TARGET_FT2004 is not set
# CONFIG_TARGET_D2000 is not set
CONFIG_SOC_NAME="e2000"
CONFIG_TARGET_TYPE_NAME="d"
CONFIG_SOC_CORE_NUM=2
CONFIG_SOC_NAME="phytiumpi"
CONFIG_SOC_CORE_NUM=4
CONFIG_F32BIT_MEMORY_ADDRESS=0x80000000
CONFIG_F32BIT_MEMORY_LENGTH=0x80000000
CONFIG_F64BIT_MEMORY_ADDRESS=0x2000000000
Expand All @@ -1218,22 +1232,21 @@ CONFIG_DEFAULT_DEBUG_PRINT_UART1=y
#
# Board Configuration
#
CONFIG_E2000D_DEMO_BOARD=y
CONFIG_BOARD_NAME="demo"

#
# IO mux configuration when board start up
#
CONFIG_BOARD_NAME="firefly"
# CONFIG_USE_SPI_IOPAD is not set
# CONFIG_USE_GPIO_IOPAD is not set
# CONFIG_USE_CAN_IOPAD is not set
# CONFIG_USE_QSPI_IOPAD is not set
# CONFIG_USE_PWM_IOPAD is not set
# CONFIG_USE_ADC_IOPAD is not set
# CONFIG_USE_MIO_IOPAD is not set
# CONFIG_USE_TACHO_IOPAD is not set
# CONFIG_USE_UART_IOPAD is not set
# CONFIG_USE_THIRD_PARTY_IOPAD is not set
CONFIG_FIREFLY_DEMO_BOARD=y

#
# IO mux configuration when board start up
#
# CONFIG_CUS_DEMO_BOARD is not set

#
Expand Down
17 changes: 17 additions & 0 deletions bsp/phytium/aarch32/applications/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@

#include <board.h>

#define ASSERT_STATIC(expression) \
extern int assert_static[(expression) ? 1 : -1]

#define ASSERT_STATIC(expression) \
extern int assert_static[(expression) ? 1 : -1]

/* check if SMP related setting ok */
#ifndef RT_USING_SMP
ASSERT_STATIC(RT_CPUS_NR == 1U); /* please set RT_CPUS_NR = 1 when SMP off */
#else
#if defined(TARGET_E2000D)
ASSERT_STATIC(RT_CPUS_NR <= 2U); /* use 2 cores at most */
#elif defined(TARGET_E2000Q) || defined(TARGET_PHYTIUMPI)
ASSERT_STATIC(RT_CPUS_NR <= 4U); /* use 4 cores at most */
#endif
#endif

#ifdef RT_USING_SMP

struct rt_thread test_core[RT_CPUS_NR];
Expand Down
121 changes: 79 additions & 42 deletions bsp/phytium/aarch32/applications/mnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,8 @@
#include <dfs_fs.h>
#include <dfs_file.h>

#ifdef BSP_USING_SDCARD_FATFS
#define SD_DEIVCE_NAME "sd"
static int filesystem_mount(void)
static int ram_disk_mount(const char *mount_point)
{
while (rt_device_find(SD_DEIVCE_NAME) == RT_NULL)
{
rt_thread_mdelay(1);
}

if (dfs_mount(SD_DEIVCE_NAME, "/", "elm", 0, 0) == 0)
{
LOG_I("file system initialization done!\n");
}
else
{
LOG_E("[sd] File System on SD initialization failed!");
LOG_E("[sd] Please format SD Card as FAT32!!!...");
return -1;
}

mkdir("/ram", 0x777);

#ifdef RT_USING_DFS_RAMFS
extern struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size);

Expand All @@ -48,50 +28,107 @@ static int filesystem_mount(void)

pool = rt_malloc(size);
if (pool == RT_NULL)
{
LOG_E("Malloc fail!");

if (dfs_mount(RT_NULL, mount_point, "ram", 0, (const void *)dfs_ramfs_create(pool, size)) == 0)
LOG_I("RAM file system initializated!");
else
LOG_E("RAM file system initializate failed!");
#endif

return RT_EOK;
}

#ifdef BSP_USING_SDCARD_FATFS
extern void fsdif_change(void);
static int sd_disk_try_mount(char *device_name, char *mount_point, char *fs_type_name, int mkfs_count)
{
struct statfs fs_stat;
int rc = 0;

LOG_I("mount(\"%s\",\"%s\",\"%s\");", device_name, mount_point, fs_type_name);

if (rt_device_find(device_name) == NULL)
{
LOG_I("%s not find!!!", device_name);
return -RT_EIO;
}

if (dfs_mount(RT_NULL, "/ram", "ram", 0, (const void *)dfs_ramfs_create(pool, size)) == 0)
mkdir(mount_point, 0);
_remount:
rc = dfs_mount(device_name, mount_point, fs_type_name, 0, 0);
if (rc == 0)
{
LOG_I("RAM file system initializated!");
LOG_I("mounted %s on %s", device_name, mount_point);
if (dfs_statfs(mount_point, &fs_stat) >= 0)
{
LOG_I("%s size:%d, total: %d, free: %d", mount_point,
fs_stat.f_bsize, fs_stat.f_blocks, fs_stat.f_bfree);
}
}
else
{
LOG_E("RAM file system initializate failed!");
if (mkfs_count > 0)
{
/* LOG_I("[%s]try mkfs -t %s %s ", mkfs_count, fs_type_name, device_name);
dfs_mkfs(fs_type_name, device_name); */
mkfs_count--;
LOG_E("%s is not in %s, please format first !!!", device_name, fs_type_name);
goto _remount;
}

LOG_I("mount failed :%d ", rc);
return -RT_EIO;
}
#endif

return RT_EOK;
}
INIT_ENV_EXPORT(filesystem_mount);

#else
static int filesystem_mount(void)
static void sd_filesytem_task_entry(void *parameter)
{
#ifdef RT_USING_DFS_RAMFS
extern struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size);

rt_uint8_t *pool = RT_NULL;
rt_size_t size = 8 * 1024 * 1024;
int result;
LOG_D("sdio host change: %d", change);
mmcsd_wait_cd_changed(0); /* clear */
fsdif_change(); /* send cd change to host */

pool = rt_malloc(size);
if (pool == RT_NULL)
/* block until plug/unplug event happens */
result = mmcsd_wait_cd_changed(RT_WAITING_FOREVER);
if (result == MMCSD_HOST_PLUGED)
{
LOG_E("Malloc fail!");
rt_kprintf("mmcsd change pluged \n");
/* mount sdcard partition as / */
if (RT_EOK == sd_disk_try_mount(BSP_USING_SDCARD_PARTITION, "/", "elm", 0))
{
ram_disk_mount("/ram"); /* mount ramdisk if configured */
}
}
}

if (dfs_mount(RT_NULL, "/", "ram", 0, (const void *)dfs_ramfs_create(pool, size)) == 0)
int filesystem_mount(void)
{
rt_thread_t tid;
tid = rt_thread_create("sd_filesytem", sd_filesytem_task_entry,
RT_NULL,
4096,
RT_THREAD_PRIORITY_MAX - 2, 20);
if (tid != RT_NULL)
{
LOG_I("RAM file system initializated!");
rt_thread_startup(tid);
}
else
{
LOG_E("RAM file system initializate failed!");
LOG_E("create sd mount task error!");
}
#endif

return RT_EOK;
}
INIT_ENV_EXPORT(filesystem_mount);
INIT_APP_EXPORT(filesystem_mount);

#else
static int filesystem_mount(void)
{
return ram_disk_mount("/"); /* mount ramdisk as / */
}
INIT_APP_EXPORT(filesystem_mount);
#endif // #ifdef BSP_USING_SDCARD_FATFS
#endif // #if defined(RT_USING_DFS)
6 changes: 4 additions & 2 deletions bsp/phytium/aarch32/configs/e2000d_demo_rtsmart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ CONFIG_RT_NAME_MAX=16
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
CONFIG_RT_USING_SMART=y
# CONFIG_RT_USING_AMP is not set
# CONFIG_RT_USING_SMP is not set
CONFIG_RT_CPUS_NR=1
CONFIG_RT_USING_SMP=y
CONFIG_RT_CPUS_NR=2
CONFIG_RT_ALIGN_SIZE=4
# CONFIG_RT_THREAD_PRIORITY_8 is not set
CONFIG_RT_THREAD_PRIORITY_32=y
Expand All @@ -24,6 +24,7 @@ CONFIG_RT_HOOK_USING_FUNC_PTR=y
CONFIG_RT_USING_IDLE_HOOK=y
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
CONFIG_IDLE_THREAD_STACK_SIZE=4096
CONFIG_SYSTEM_THREAD_STACK_SIZE=4096
CONFIG_RT_USING_TIMER_SOFT=y
CONFIG_RT_TIMER_THREAD_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=4096
Expand Down Expand Up @@ -869,6 +870,7 @@ CONFIG_RT_USING_ADT_REF=y
# CONFIG_PKG_USING_ST7789 is not set
# CONFIG_PKG_USING_VS1003 is not set
# CONFIG_PKG_USING_X9555 is not set
# CONFIG_PKG_USING_SYSTEM_RUN_LED is not set
# CONFIG_PKG_USING_SPI_TOOLS is not set

#
Expand Down
4 changes: 3 additions & 1 deletion bsp/phytium/aarch32/configs/e2000d_demo_rtsmart.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

#define RT_NAME_MAX 16
#define RT_USING_SMART
#define RT_CPUS_NR 1
#define RT_USING_SMP
#define RT_CPUS_NR 2
#define RT_ALIGN_SIZE 4
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
Expand All @@ -19,6 +20,7 @@
#define RT_USING_IDLE_HOOK
#define RT_IDLE_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 4096
#define SYSTEM_THREAD_STACK_SIZE 4096
#define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 4096
Expand Down
6 changes: 4 additions & 2 deletions bsp/phytium/aarch32/configs/e2000d_demo_rtthread
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ CONFIG_RT_NAME_MAX=16
# CONFIG_RT_USING_ARCH_DATA_TYPE is not set
# CONFIG_RT_USING_SMART is not set
# CONFIG_RT_USING_AMP is not set
# CONFIG_RT_USING_SMP is not set
CONFIG_RT_CPUS_NR=1
CONFIG_RT_USING_SMP=y
CONFIG_RT_CPUS_NR=2
CONFIG_RT_ALIGN_SIZE=4
# CONFIG_RT_THREAD_PRIORITY_8 is not set
CONFIG_RT_THREAD_PRIORITY_32=y
Expand All @@ -24,6 +24,7 @@ CONFIG_RT_HOOK_USING_FUNC_PTR=y
CONFIG_RT_USING_IDLE_HOOK=y
CONFIG_RT_IDLE_HOOK_LIST_SIZE=4
CONFIG_IDLE_THREAD_STACK_SIZE=4096
CONFIG_SYSTEM_THREAD_STACK_SIZE=4096
CONFIG_RT_USING_TIMER_SOFT=y
CONFIG_RT_TIMER_THREAD_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=4096
Expand Down Expand Up @@ -851,6 +852,7 @@ CONFIG_RT_USING_ADT_REF=y
# CONFIG_PKG_USING_ST7789 is not set
# CONFIG_PKG_USING_VS1003 is not set
# CONFIG_PKG_USING_X9555 is not set
# CONFIG_PKG_USING_SYSTEM_RUN_LED is not set
# CONFIG_PKG_USING_SPI_TOOLS is not set

#
Expand Down
Loading

0 comments on commit 7331bf5

Please sign in to comment.