别再乱调学习率了!用PyTorch的CosineAnnealingLR和WarmRestarts,让你的模型收敛又快又稳
2026/6/8 7:41:06
UniProton是鸿蒙操作系统面向工业控制领域的轻量级实时操作系统(RTOS),专为资源受限的嵌入式设备设计。作为鸿蒙生态的重要组成部分,UniProton提供了高效的实时任务调度、内存管理和IPC机制,满足工业控制场景对实时性和可靠性的严格要求。
UniProton采用分层架构设计,从下到上分为硬件抽象层、内核层和系统服务层。
┌─────────────────────────────────────────┐ │ 应用层 │ ├─────────────────────────────────────────┤ │ 系统服务层 │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │ 文件系统 │ │ 网络协议 │ │ 设备管理 │ │ │ └─────────┘ └─────────┘ └─────────┘ │ ├─────────────────────────────────────────┤ │ 内核层 │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │ 任务管理 │ │ 内存管理 │ │ IPC机制 │ │ │ └─────────┘ └─────────┘ └─────────┘ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │ 定时器 │ │ 中断管理 │ │ 错误处理 │ │ │ └─────────┘ └─────────┘ └─────────┘ │ ├─────────────────────────────────────────┤ │ 硬件抽象层 │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │ CPU抽象 │ │ 中断抽象 │ │ 内存抽象 │ │ │ └─────────┘ └─────────┘ └─────────┘ │ └─────────────────────────────────────────┘UniProton内核由五大子系统构成,各子系统的职责如下:
创建编译工具目录
mkdir-p /opt/buildtools&&chmod-R755/opt/buildtools安装编译器
# ARMv7-M编译器tar-xvf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2 -C /opt/buildtools# ARMv8编译器tar-xvf gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz -C /opt/buildtools安装CMake
tar-xvf cmake-3.20.5-Linux-x86_64.tar.gz -C /opt/buildtools下载代码
gitclone https://gitee.com/openeuler/UniProton.git下载依赖库
执行编译
cdUniProton python build.py m4# 编译ARMv7-M版本# 或python build.py armv8# 编译ARMv8版本拉取镜像
docker pull swr.cn-north-4.myhuaweicloud.com/openeuler-embedded/uniproton:v002创建并进入容器
docker run -it -v$(pwd):/home/uniproton swr.cn-north-4.myhuaweicloud.com/openeuler-embedded/uniproton:v002下载代码
gitclone https://gitee.com/openeuler/UniProton.git下载依赖库
执行编译
cdUniProton python build.py m4output/UniProton/lib/cortex_m4目录下output/libboundscheck/lib/cortex_m4目录下准备开发环境
创建应用项目
配置系统参数
编写应用代码
编译和链接
烧录和调试
UniProton提供了丰富的API接口,主要包括:
任务管理接口
内存管理接口
IPC接口
UniProton广泛应用于工业控制、物联网设备、智能家居、汽车电子等领域,特别适合对实时性要求高的场景:
工业自动化控制系统
物联网设备
智能家居
汽车电子
实时数据采集系统
| 一级目录 | 二级目录 | 三级目录 | 说明 |
|---|---|---|---|
| build | uniproton_ci_lib | 编译框架的公共脚本 | |
| uniproton_config | config_m4 | cortex_m4芯片的功能宏配置文件 | |
| cmake | common | build_auxiliary_script | 转换Kconfig文件为buildef.h脚本 |
| functions | cmake的公共功能函数 | ||
| tool_chain | 编译器和编译选项配置文件 | ||
| demos | helloworld | apps | 示例程序的main函数文件以及业务代码 |
| bsp | 板级驱动适配代码 | ||
| build | demo构建及链接脚本 | ||
| config | 用户配置文件,功能宏定制头文件 | ||
| include | src/include/uapi及posix目录下头文件拷贝目录 | ||
| libs | 源码编译静态库文件存放目录 | ||
| Hi3093 | Hi3093芯片示例 | ||
| RASPI4 | 树莓派4B示例 | ||
| doc | 项目配置、规范、协议等文档 | ||
| design | UniProton系统架构和特性说明 | ||
| platform | libboundscheck使用说明 | ||
| libboundscheck | libboundscheck预留目录,用户将下载的源码放在此目录下 | ||
| src | arch | cpu | cpu对应架构的功能适配代码 |
| include | cpu对应架构的头文件 | ||
| config | 用户main函数入口 | ||
| config | 用户配置功能宏开关 | ||
| core | ipc | 事件、队列、信号量等功能 | |
| kernel | 任务、中断、异常、软件定时器等功能 | ||
| fs | littlefs | littlefs适配层代码,不包含完整littlefs代码 | |
| vfs | 文件系统vfs层接口代码 | ||
| include | uapi | 对外头文件 | |
| posix | posix接口头文件 | ||
| mem | 内存管理基本功能 | ||
| fsc | 内存管理FSC算法代码 | ||
| include | 内存管理头文件 | ||
| net | lwip-2.1 | lwip适配层代码,不包含完整lwip代码 | |
| om | cpup | cpu占用率统计功能 | |
| err | 错误处理功能 | ||
| hook | 钩子函数功能 | ||
| include | 系统管理头文件 | ||
| osal | posix | posix功能实现源码 | |
| security | rnd | 随机化功能 | |
| utility | lib | 公共库函数 |
模块化设计
实时性保证
资源高效利用
可靠性设计
以下是一个简单的Hello World示例程序,展示如何使用UniProton创建任务并输出信息:
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<stdarg.h>#include"securec.h"#include"rtt_viewer.h"#include"prt_config.h"#include"prt_config_internal.h"#include"prt_clk.h"#include"test.h"voidhelloworld_task(U32 uwParam1,U32 uParam2,U32 uwParam3,U32 uwParam4){printf("hello world!\n");while(1){PRT_TaskDelay(10);}return;}U32PRT_AppInit(void){U32 ret;TskHandle taskPid;structTskInitParamstInitParam={helloworld_task,10,0,{0},0x500,"TaskA",0};ret=PRT_TaskCreate(&taskPid,&stInitParam);if(ret){returnret;}ret=PRT_TaskResume(taskPid);if(ret){returnret;}returnOS_OK;}U32PRT_HardDrvInit(void){RttViewerInit();RttViewerModeSet(0,RTT_VIEWER_MODE_BLOCK_IF_FIFO_FULL);returnOS_OK;}U32 g_testRandStackProtect;voidOsRandomSeedInit(void){#ifdefined(OS_OPTION_RND)U32 ret;U32 seed;seed=PRT_ClkGetCycleCount64();g_testRandStackProtect=rand_r(&seed);ret=PRT_SysSetRndNum(OS_SYS_RND_STACK_PROTECT,g_testRandStackProtect);#endif}voidOsGlobalDataInit(void){}voidPRT_HardBootInit(void){OsGlobalDataInit();OsRandomSeedInit();}U32PRT_Printf(constchar*format,...){va_list vaList;charbuff[0x200]={0};S32 count;U32 ret;va_start(vaList,format);count=vsprintf_s(buff,0x200,format,vaList);va_end(vaList);if(count==-1){returnOS_ERROR;}RttViewerWrite(0,buff,count);returncount;}S32main(void){returnOsConfigStart();}UniProton作为鸿蒙操作系统面向工业控制领域的轻量级实时操作系统,具有实时性强、可靠性高、资源占用少、模块化程度高等特点,广泛应用于工业控制、物联网设备、智能家居、汽车电子等领域。通过本文档的介绍,开发者可以了解UniProton的系统架构、模块功能、编译方法、使用方法和设计理念,为基于UniProton的应用开发提供指导。