hi,
I am using the nrf52840DK board to test the LVGL file system reading function.
SDK version:ncs V2.5.1
test code:
/* * Copyright (c) 2018 Jan Van Winkel <[email protected]> * * SPDX-License-Identifier: Apache-2.0 */ #include <zephyr/device.h> #include <zephyr/kernel.h> #include <zephyr/devicetree.h> #include <zephyr/drivers/display.h> #include <zephyr/drivers/gpio.h> #include <lvgl.h> #include <stdio.h> #include <string.h> #include <zephyr/storage/disk_access.h> #include <zephyr/fs/fs.h> #include <ff.h> ////#include "../generated/gui_guider.h" //#include "../generated/events_init.h" #define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL #include <zephyr/logging/log.h> LOG_MODULE_REGISTER(app); /* * Note the fatfs library is able to mount only strings inside _VOLUME_STRS * in ffconf.h */ #define DISK_DRIVE_NAME "NAND" #define DISK_MOUNT_PT "/"DISK_DRIVE_NAME":" static FATFS fat_fs; /* mounting info */ static struct fs_mount_t mp = { .type = FS_FATFS, .fs_data = &fat_fs, }; static const char *disk_mount_pt = DISK_MOUNT_PT; #ifdef CONFIG_GPIO static struct gpio_dt_spec button_gpio = GPIO_DT_SPEC_GET_OR( DT_ALIAS(sw0), gpios, {0}); static struct gpio_callback button_callback; static void button_isr_callback(const struct device *port, struct gpio_callback *cb, uint32_t pins) { ARG_UNUSED(port); ARG_UNUSED(cb); ARG_UNUSED(pins); } #endif void lv_fs_test(void); u_int32_t count=0; lv_ui guider_ui; int main(void) { //static const char *disk_pdrv = DISK_DRIVE_NAME; const struct device *display_dev; display_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display)); if (!device_is_ready(display_dev)) { LOG_ERR("Device not ready, aborting test"); return 0; } mp.mnt_point = disk_mount_pt; int res = fs_mount(&mp); if (res == FR_OK) printk("Disk mounted.\n"); #ifdef CONFIG_GPIO if (gpio_is_ready_dt(&button_gpio)) { int err; err = gpio_pin_configure_dt(&button_gpio, GPIO_INPUT); if (err) { LOG_ERR("failed to configure button gpio: %d", err); return 0; } gpio_init_callback(&button_callback, button_isr_callback, BIT(button_gpio.pin)); err = gpio_add_callback(button_gpio.port, &button_callback); if (err) { LOG_ERR("failed to add button callback: %d", err); return 0; } err = gpio_pin_interrupt_configure_dt(&button_gpio, GPIO_INT_EDGE_TO_ACTIVE); if (err) { LOG_ERR("failed to enable button callback: %d", err); return 0; } } #endif //setup_ui(&guider_ui); // events_init(&guider_ui); // lv_task_handler(); // display_blanking_off(display_dev); while (1) { lv_fs_test(); // lv_task_handler(); k_sleep(K_MSEC(100)); } } void lv_fs_test(void) { lv_fs_file_t f; lv_fs_res_t res; res = lv_fs_open(&f, "/NAND:/image/home_background.bin", LV_FS_MODE_RD); if(res != LV_FS_RES_OK) { printf("Open fail:%d",res); } else { printf("Open OK\n"); uint32_t read_num; uint8_t buf[1344]; res = lv_fs_read(&f, buf, 1344, &read_num); printf("read: count:%d\n",count++); lv_fs_close(&f); } }
prj.conf:
CONFIG_MAIN_STACK_SIZE=20480
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=6000
CONFIG_HEAP_MEM_POOL_SIZE=32000
#CONFIG_LV_Z_MEM_POOL_HEAP_LIB_C=y
#CONFIG_LV_Z_MEM_POOL_SYS_HEAP=y
CONFIG_LV_Z_MEM_POOL_MIN_SIZE=4
CONFIG_LV_Z_MEM_POOL_MAX_SIZE=1024
CONFIG_LV_Z_MEM_POOL_NUMBER_BLOCKS=10
CONFIG_LV_IMG_CACHE_DEF_SIZE=1
CONFIG_LV_Z_POINTER_INPUT_MSGQ_COUNT=200
CONFIG_LV_COLOR_SCREEN_TRANSP=y
CONFIG_DISK_ACCESS=y
CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FS_FATFS_LFN=y
CONFIG_NORDIC_QSPI_NOR=y
# The mx25 erase page size
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_DISK_DRIVERS=y
CONFIG_DISK_DRIVER_FLASH=y
# There may be no files on internal SoC flash, so this Kconfig
# options has ben enabled to create some if listing does not
# find in the first place.
#CONFIG_FS_SAMPLE_CREATE_SOME_ENTRIES=y
error message:
Open OK
read: count:395
Open OK
read: count:396
Open OK
read: count:397
Open OK
read: count:398
Open OK
read: count:399
Open OK
read: count:400
Open fail:12Open fail:12Open fail:12Open fail:12Open fail:12Open fail:12Open fail:12Open fail:12Open fail:12Open fail:12