C
Platform Migration Guide to Qt for MCUs 2.0
Here are the changes to be aware of when porting a platform from Qt for MCUs 1.x to 2.0.
Architecture builds
Qt for MCUs now uses architecture-based builds, so it's important to specify the target platform's architecture. This can be done by using the QUL_PLATFORM_ARCHITECTURE
variable in cBoardDefaults.cmake. See Architecture and Platform-specific Build Settings for more information.
BoardDefaults.cmake
configuration variables
The following CMake configuration variables that are used in the BoardDefaults.cmake
, have been renamed:
Qt for MCUs 1.9 | Qt for MCUs 2.0 |
---|---|
QUL_DEFAULT_SCREEN_WIDTH | QUL_PLATFORM_DEFAULT_SCREEN_WIDTH |
QUL_DEFAULT_SCREEN_HEIGHT | QUL_PLATFORM_DEFAULT_SCREEN_HEIGHT |
QUL_DEFAULT_INTERNAL_ALPHA_OPTIONS | QUL_PLATFORM_DEFAULT_RESOURCE_ALPHA_OPTIONS |
OS | QUL_OS |
EXCLUDED_EXAMPLES | QUL_PLATFORM_EXCLUDED_EXAMPLES |
EXCLUDED_DEMOS | QUL_PLATFORM_EXCLUDED_DEMOS |
In addition, the QUL_PLATFORM_DEFAULT_RESOURCE_PIXEL_FORMAT_ALPHA and QUL_PLATFORM_DEFAULT_RESOURCE_PIXEL_FORMAT_OPAQUE variables should be set. See CMake API changes in 2.0 for more information.
Compile and link options for the platform
Rename the CompilationOptions.cmake
file, containing the compiler and linker flags specific to your platform, to platform.cmake
.
Linker script
Set the default linker script using the qul_platform_add_default_linker_script()
CMake function in the platform's BoardDefaults.cmake
file:
qul_platform_add_default_linker_script("${CMAKE_CURRENT_LIST_DIR}/example-platform.ld")
In the previous Qt for MCUs versions, this was done using the LINKER_SCRIPT
variable in LinkerScriptLoader.cmake
,
Platform kit configuration file
The envVar
attribute of the boardSdk
attributes are replaced by the cmakeCacheEntries
attribute. See the Creating the platform kit configuration file section for more information.
Platform target name
The platform target has been renamed from QuickUltralitePlatform
to Platform
. Update the target_sources
, target_include_directories
, target_compile_definitions
, and other relevant CMake commands to use the new target name.
Platform API
Move the implementation for the following fuctions into a sub-class of the Qul::Platform::PlatformContext class:
- initializeHardware
- initializeDisplay
- currentTimestamp
- exec
- rand
- scheduleEngineUpdate
- frameBufferingType
- beginFrame
- endFrame
- presentFrame
- availableScreens
- layerEngine
- waitUntilAsyncReadFinished
- flushCachesForAsyncRead
- memoryAllocator
- consoleWrite
Note: availableScreens
and frameBufferingType
should be const
member functions.
In addition, add the initializePlatform member function to perform any platform initialization that is not directly hardware related.
Finally, implement the Qul::Platform::getPlatformInstance() function and make it return a pointer to a singleton platform instance.
Resource preloading
QUL_STATIC_ASSET_SEGMENT
is no longer used. Instead, memory for preloaded assets is allocated using the memory allocator returned from Qul::Platform::PlatformContext.
Refer to Memory allocation in Qt Quick Ultralite platform abstraction for details about how preloading can be implemented.
Resource storage location
Instead of using QUL_STATIC_ASSET_SEGMENT
and QUL_STATIC_NO_PRELOAD_ASSET_SEGMENT
, now the resources are by default placed in the QulResourceData
, QulModuleResourceData
, and QulFontResourceData
segments. See Getting started for more information.
Available under certain Qt licenses.
Find out more.