C
Qt Quick Ultralite fileloading Example
// Copyright (C) 2025 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial // #include "fatfs/fatfsfilesystem.h" #include "board_config.h" #include "ff.h" #include "ff_gen_drv.h" #include <platforminterface/log.h> #include <qul/application.h> #include <platform/mem.h> #include "stm32u5_emmc.h" static DSTATUS u5_initialize(BYTE) { return RES_OK; } static DSTATUS u5_status(BYTE) { return RES_OK; } static DRESULT u5_read(BYTE, BYTE *buff, DWORD sector, UINT count) { if (!Qul::Platform::Private::readBlockFromDevice(0 /*blockDeviceIndex*/, sector, count, buff)) return RES_ERROR; return RES_OK; } const Diskio_drvTypeDef u5_driver = {u5_initialize, u5_status, u5_read}; void ConfigureBoard() { static FatFsFilesystem filesystem; static FATFS stmFatFs; static char stmPath[4]; // eMMC_init is supposed to be called from the platform init already. if (FATFS_LinkDriver(&u5_driver, stmPath) != 0) { Qul::PlatformInterface::log("FATFS_LinkDriver failed\r\n"); return; } if (f_mount(&stmFatFs, stmPath, 0) != 0) { Qul::PlatformInterface::log("Mounting filesystem failed!\r\n"); return; } Qul::Application::addFilesystem(&filesystem); } extern "C" { void *ff_memalloc(UINT msize) { return Qul::Platform::qul_malloc(msize); } void ff_memfree(void *ptr) { Qul::Platform::qul_free(ptr); } }