Convert Figma logo to code with AI

LiteOS logoLiteOS

code and manual

4,883
1,588
4,883
47

Top Related Projects

4,777

Arm Mbed OS is a platform operating system designed for the internet of things

11,327

RT-Thread is an open source IoT Real-Time Operating System (RTOS). https://rt-thread.github.io/rt-thread/

'Classic' FreeRTOS distribution. Started as Git clone of FreeRTOS SourceForge SVN repo. Submodules the kernel.

Contiki-NG: The OS for Next Generation IoT Devices

Quick Overview

LiteOS is an open-source, lightweight Internet of Things (IoT) operating system developed by Huawei. It is designed to provide a secure, efficient, and scalable platform for IoT devices with limited resources. LiteOS supports various connectivity protocols and offers a rich set of features for IoT development.

Pros

  • Lightweight and efficient, suitable for resource-constrained devices
  • Supports multiple architectures and chipsets
  • Provides a comprehensive set of IoT-specific features and protocols
  • Strong focus on security and reliability

Cons

  • Limited community support compared to more established IoT platforms
  • Documentation may be incomplete or outdated in some areas
  • Steeper learning curve for developers new to embedded systems
  • Some features may be specific to Huawei hardware ecosystems

Code Examples

  1. Task creation and management:
#include "los_task.h"

UINT32 g_taskId;

VOID TaskExample(VOID)
{
    while (1) {
        printf("Hello LiteOS!\n");
        LOS_TaskDelay(1000);
    }
}

UINT32 CreatTaskExample(VOID)
{
    UINT32 uwRet = LOS_OK;
    TSK_INIT_PARAM_S task_init_param;

    task_init_param.usTaskPrio = 4;
    task_init_param.pcName = "TaskExample";
    task_init_param.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskExample;
    task_init_param.uwStackSize = 0x200;

    uwRet = LOS_TaskCreate(&g_taskId, &task_init_param);
    if (uwRet != LOS_OK) {
        printf("Task creation failed\n");
    }
    return uwRet;
}
  1. Semaphore usage:
#include "los_sem.h"

UINT32 g_semId;

VOID SemaphoreExample(VOID)
{
    UINT32 uwRet = LOS_OK;

    uwRet = LOS_SemCreate(0, &g_semId);
    if (uwRet != LOS_OK) {
        printf("Semaphore creation failed\n");
        return;
    }

    uwRet = LOS_SemPend(g_semId, LOS_WAIT_FOREVER);
    if (uwRet == LOS_OK) {
        printf("Semaphore acquired\n");
    }

    LOS_SemPost(g_semId);
    printf("Semaphore released\n");

    LOS_SemDelete(g_semId);
}
  1. Timer usage:
#include "los_sys.h"
#include "los_tick.h"

VOID TimerCallback(UINT32 arg)
{
    printf("Timer callback executed\n");
}

VOID TimerExample(VOID)
{
    UINT32 uwTick;
    uwTick = LOS_MS2Tick(1000);
    LOS_SysTimerInit();
    LOS_SysTimerCreate(TimerCallback, uwTick, 0);
    LOS_TaskDelay(5000);
    LOS_SysTimerDelete();
}

Getting Started

To get started with LiteOS:

  1. Download the LiteOS source code from the GitHub repository.
  2. Set up the development environment according to the documentation.
  3. Choose a supported development board or emulator.
  4. Configure the project settings in the targets directory.
  5. Build the project using the provided build scripts.
  6. Flash the compiled binary to your target device.
  7. Start developing your IoT application using LiteOS APIs and features.

For detailed instructions, refer to the official LiteOS documentation and examples provided in the repository.

Competitor Comparisons

4,777

Arm Mbed OS is a platform operating system designed for the internet of things

Pros of mbed-os

  • Broader hardware support with extensive list of supported boards and MCUs
  • More comprehensive documentation and tutorials for developers
  • Larger and more active community, leading to better support and resources

Cons of mbed-os

  • Larger footprint and potentially higher resource usage
  • Steeper learning curve for beginners due to its extensive feature set
  • Less focus on real-time performance compared to LiteOS

Code Comparison

mbed-os example (main.cpp):

#include "mbed.h"

DigitalOut led(LED1);

int main() {
    while (true) {
        led = !led;
        ThisThread::sleep_for(500ms);
    }
}

LiteOS example (main.c):

#include "los_task.h"

VOID task(VOID) {
    while (1) {
        LOS_TaskDelay(500);
        // Toggle LED here
    }
}

int main(void) {
    UINT32 taskId;
    LOS_TaskCreate(&taskId, &task_params, task, "LED_Task");
    return 0;
}

Both examples demonstrate a simple LED blinking task, but mbed-os uses C++ and its built-in abstractions, while LiteOS uses C and its task management functions.

11,327

RT-Thread is an open source IoT Real-Time Operating System (RTOS). https://rt-thread.github.io/rt-thread/

Pros of RT-Thread

  • More active community with frequent updates and contributions
  • Extensive component ecosystem with over 250 software packages
  • Better documentation and learning resources for developers

Cons of RT-Thread

  • Slightly steeper learning curve for beginners
  • Less focus on security features compared to LiteOS

Code Comparison

RT-Thread example:

#include <rtthread.h>

static void thread_entry(void* parameter)
{
    while (1) {
        rt_kprintf("Hello, RT-Thread!\n");
        rt_thread_mdelay(1000);
    }
}

int main(void)
{
    rt_thread_t tid = rt_thread_create("test", thread_entry, RT_NULL, 1024, 25, 10);
    if (tid != RT_NULL) rt_thread_startup(tid);
    return 0;
}

LiteOS example:

#include "los_task.h"

VOID task1(VOID)
{
    while (1) {
        printf("Hello, LiteOS!\n");
        LOS_TaskDelay(1000);
    }
}

UINT32 creat_task1()
{
    UINT32 taskId;
    TSK_INIT_PARAM_S task1 = {0};
    task1.pfnTaskEntry = (TSK_ENTRY_FUNC)task1;
    task1.uwStackSize = 0x200;
    task1.pcName = "task1";
    task1.usTaskPrio = 10;
    return LOS_TaskCreate(&taskId, &task1);
}

Both RT-Thread and LiteOS provide similar RTOS functionalities, but RT-Thread offers a more extensive ecosystem and community support, while LiteOS focuses more on security and lightweight design.

'Classic' FreeRTOS distribution. Started as Git clone of FreeRTOS SourceForge SVN repo. Submodules the kernel.

Pros of FreeRTOS

  • Wider community support and more extensive documentation
  • Better portability across different hardware platforms
  • More comprehensive set of features and middleware

Cons of FreeRTOS

  • Larger memory footprint compared to LiteOS
  • Steeper learning curve for beginners
  • Less focus on IoT-specific features

Code Comparison

FreeRTOS task creation:

void vTaskFunction(void *pvParameters) {
    for (;;) {
        // Task code here
    }
}

xTaskCreate(vTaskFunction, "TaskName", STACK_SIZE, NULL, TASK_PRIORITY, NULL);

LiteOS task creation:

UINT32 Example_Task(VOID) {
    while (1) {
        // Task code here
    }
}

LOS_TaskCreate(&taskId, &taskInitParam);

Both operating systems use similar concepts for task creation, but FreeRTOS uses a more function-pointer-based approach, while LiteOS relies on a task creation API with a separate task function.

Contiki-NG: The OS for Next Generation IoT Devices

Pros of Contiki-ng

  • More active development and community support
  • Better documentation and examples
  • Wider range of supported hardware platforms

Cons of Contiki-ng

  • Steeper learning curve for beginners
  • Less focus on real-time capabilities
  • Larger memory footprint compared to LiteOS

Code Comparison

Contiki-ng (main.c):

#include "contiki.h"
#include "net/netstack.h"
#include "net/ipv6/simple-udp.h"

PROCESS(example_process, "Example Process");
AUTOSTART_PROCESSES(&example_process);

PROCESS_THREAD(example_process, ev, data)
{
  PROCESS_BEGIN();
  // Process logic here
  PROCESS_END();
}

LiteOS (main.c):

#include "los_base.h"
#include "los_task.h"

UINT32 Example_Task(VOID)
{
    while (1) {
        // Task logic here
    }
    return 0;
}

int main(void)
{
    UINT32 uwRet = LOS_OK;
    uwRet = LOS_KernelInit();
    if (uwRet != LOS_OK) {
        return LOS_NOK;
    }
    // Create and start tasks
    return LOS_OK;
}

Both operating systems provide lightweight solutions for IoT devices, but Contiki-ng offers a more event-driven approach with its process-based programming model, while LiteOS follows a more traditional RTOS task-based structure. Contiki-ng's code tends to be more modular and easier to extend, whereas LiteOS provides a simpler, more straightforward implementation for basic embedded systems.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Build Status

Huawei LiteOS简介

Huawei LiteOS是华为面向物联网领域开发的一个基于实时内核的轻量级操作系统。本项目属于华为物联网操作系统[Huawei LiteOS]源码,现有基础内核包括不可裁剪的极小内核和可裁剪的其他模块。极小内核包含任务管理、内存管理、异常管理、系统时钟和中断管理。可裁剪模块包括信号量、互斥锁、队列管理、事件管理、软件定时器等。除了基础内核,Huawei LiteOS还提供了扩展内核,包括C++支持、动态加载、低功耗以及维测模块。低功耗通过支持Tickless机制、run-stop休眠唤醒,可以大大降低系统功耗。维测部分包含了获取CPU占用率、支持串口执行Shell命令等功能。

Huawei LiteOS同时提供端云协同能力,集成了LwM2M、CoAP、mbedtls、LwIP全套IoT互联协议栈,且在LwM2M的基础上,提供了AgentTiny模块,用户只需关注自身的应用,而不必关注LwM2M实现细节,直接使用AgentTiny封装的接口即可简单快速实现与云平台安全可靠的连接。

Huawei LiteOS自开源社区发布以来,围绕NB-IoT物联网市场从技术、生态、解决方案、商用支持等多维度使能合作伙伴,构建开源的物联网生态。目前已经聚合了50+ MCU和解决方案合作伙伴,共同推出一批开源开发套件和行业解决方案,帮助众多行业客户快速推出物联网终端和服务,客户涵盖抄表、停车、路灯、环保、共享单车、物流等众多行业,为开发者提供 “一站式” 完整软件平台,可有效降低开发门槛、缩短开发周期。

LiteOS 代码导读

该文档描述的是LiteOS内核源代码的详细信息。通过此文档读者可以了解LiteOS的源代码结构,以及LiteOS的main()函数的功能。

LiteOS 移植指南

该文档基于STM32芯片平台,详细介绍如何快速移植LiteOS。

LiteOS 开发指南

该文档详细讲解了LiteOS各模块开发及其实现原理。用户可以通过阅读该文档学习各模块的使用。

LiteOS 编译介绍和开发工具

该文档介绍了LiteOS的编译框架,以及如何在Linux和Windows下编译LiteOS。

LiteOS 维测指南

该文档详细介绍了LiteOS具备的维测能力,包括内存调测方法、IPC通信调测方法、Trace、调度统计、获取CPU占用率等。

LiteOS Demos

LiteOS demos目录下包含了LiteOS提供的各模块Demo及其文档。文档详细介绍了Demo的功能以及运行方法。

LiteOS Shell

该文档详细讲解了在LiteOS如何定制用户自定义Shell命令,以及如何执行内置的Shell命令。

LiteOS 标准库

该文档列出了LiteOS支持的POSIX、CMSIS等接口。

LiteOS 支持的硬件

  • LiteOS开源项目目前支持ARM Cortex-M0,Cortex-M3,Cortex-M4,Cortex-M7,Cortex-A等芯片架构

  • LiteOS联合业界主流MCU厂家,通过开发者活动,目前已经适配了多种通用MCU开发套件

开源协议

LiteOS 代码贡献必读

该文档描述如何提交commit到LiteOS仓库,这是LiteOS开发必须遵守的commit规则,否则提交的commit会被驳回。请点链接了解详细信息。

该文档描述LiteOS的编程规范,此规范建立在业界通用的编程规范基础上。

该文档描述开发者如何创建自己的仓库,开发然后贡献代码到LiteOS仓库。请点链接了解详细信息。

加入我们

  • 欢迎提交issue对关心的问题发起讨论,欢迎提交PR参与特性建设
  • 如您有合作意向,希望加入Huawei LiteOS生态合作伙伴,请发邮件至liteos@huawei.com,或访问LiteOS官网,进一步了解详细信息