本文主要是源码与编译——SDK目录结构分析的相关笔记,若笔记中有错误或者不合适的地方,欢迎批评指正😃。
 点击查看使用工具及版本 
              
                          | Windows版本 |         windows11 |     
            | Ubuntu版本 |         Ubuntu22.04的64位版本 |       
            | VMware® Workstation 16 Pro |         16.2.3 build-19376536 |       
            | 终端软件 |         MobaXterm(Professional Edition v23.0 Build 5042 (license)) |       
               
             
 点击查看本文参考资料 
              
             
 点击查看相关文件下载 
              
             
接下来我们们来学习一下AliOS-Things的源码目录的结构。
一、源码顶层根目录
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
   | hk@vm:~/AliOS-Things-SDK$ tree -L 2 . ├── application   # 应用代码 │   ├── example     ## 示例代码,官方提供给我们的示例代码 │   └── profile     ## 典型场景的应用方案:网关、天猫精灵 ├── build         # 编译构建相关工具和脚本 ├── components    # 功能组件  │   ├── dm          ## 设备管理组件 │   │   ├── bootloader │   │   ├── ota │   │   ├── ulog │   │   └── und │   ├── linkkit     ## 阿里云IoT连接套件(配套源码) │   ├── network     ## IP网络协议栈组件 │   │   ├── http │   │   ├── lwip │   │   └── netmgr │   ├── security    ## 安全类组件 │   │   └── mbedtls │   └── utility     ## 工具类组件 │       ├── cjson │       └── yloop ├── core          # 内核及相关组件 ├── include       # 组件对外的头文件 ├── platform      # 芯片平台支持和BSP │   ├── arch        ## 架构移植 │   ├── board       ## 板级支持 │   └── mcu         ## MCU, SoC 移植支持 └── projects     # 为不同开发环境提供的工程相关文件
   | 
 
二、application目录
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
   | hk@vm:~/AliOS-Things-SDK$ tree -a -L 2 application/ application/ ├── app_adapter     # 如果用户想自己实现一个appdemo时,可以参考这个目录进行修改 │   ├── aos.mk │   ├── Config.in │   ├── maintask.c │   └── README.md ├── Config.in      # kconfig的菜单文件 ├── example        # 示例代码 │   ├── blink_demo │   ├── coap_demo │   ├── Config.in │   ├── debug_demo │   ├── example_legacy  ## 遗留的示例代码 3.1版本做了很大的改动,这是3.1之前的示例代码 │   ├── hal_demo        ## 外设,硬件相关的示例代码 │   ├── helloworld_demo ## helloworld │   ├── http2_demo │   ├── http_demo │   ├── kernel_demo │   ├── knx_demo │   ├── linkkit_demo    ## 连接阿里云平台的demo  │   ├── linkkit_gateway_demo │   ├── lwm2m_demo │   ├── modbus_demo     ## modbusdemo │   ├── mqtt_demo │   ├── ota_demo │   ├── README.md │   ├── ulocation │   ├── ulog_demo │   ├── umesh2_demo │   ├── vfs_demo │   ├── yloop_demo │   └── yts_demo ├── .gitignore └── profile     # 我们暂时不需要关心     ├── Config.in     ├── gatewayapp     └── tmall_model
  27 directories, 9 files
   | 
 
三、components
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
   | hk@vm:~/AliOS-Things-SDK$ tree -a -L 2 components/ components/ ├── bus  # 总线  硬件总线协议的 │   ├── canopen       ## CAN总线协议代码 │   ├── knx │   ├── mbmaster      ## USB协议代码 │   └── usb ├── dm  # 我们的这个硬件的管理相关 │   ├── bootloader    ## 2ndboot │   ├── ota           ## ota │   ├── uagent │   ├── ulog │   └── und ├── fs  # 文件系统相关  针对硬件存储设备相关的代码 │   ├── cramfs │   ├── fatfs         ## fatfs │   ├── jffs2         ## 嵌入式 │   ├── ramfs │   ├── spiffs │   ├── uffs │   └── yaffs2         ## 嵌入式 ├── gui       # 图形用户界面 │   ├── freetype-2.5.3 ## 第三方的开源的图形用户界面库 │   └── littlevGL      ## 第三方的开源的图形用户界面库 ├── language  # 语言相关 跟脚本语言相关 │   ├── jsengine       ## JS(web开发)的引擎   │   └── micropython    ## python 解释器 ├── linkkit   # 阿里云IOT平台连接相关 │   ├── certs │   ├── Config.in │   ├── dev_model │   ├── dev_reset │   ├── dev_sign │   ├── dynamic_register │   ├── external │   ├── http2 │   ├── infra │   ├── iot_coap │   ├── iot_http │   ├── mqtt │   ├── ota │   ├── wifi_provision │   └── wrappers ├── network    # 一个基础网络通信的协议代码 │   ├── aos.mk │   ├── coap │   ├── Config.in │   ├── .gitignore │   ├── http     ## 互联网的通信协议http │   ├── httpdns │   ├── libsrtp │   ├── lwip     ## tcp/ip网络协议栈 │   ├── lwm2m    ## 物联网通信协议lwm2m │   ├── mal │   ├── netmgr │   ├── rtp      ## 视频推流协议 │   ├── sal │   ├── umesh2 │   └── websocket ├── peripherals # 外设  指的是 我们的产品,或者我们开发板对外连接驱动代码 │   ├── Config.in │   ├── .gitignore │   ├── .gitkeep │   ├── iot_comm_module │   ├── README.md │   └── sensor     ## 传感器驱动代码  这里适配了100多种传感器 ├── security    # 安全相关  解决明文传感器的不安全问题 │   ├── .gitignore │   ├── linksecurity  ## 阿里云自定义的安全协议 │   └── mbedtls       ## 一种开源的加密协议栈 ├── service     # 服务 │   ├── uai │   ├── udata │   └── ulocation     ## 定位相关 ├── utility     # 通用的功能 │   ├── at            ## AT指令集驱动 │   ├── cjson         ## json解析的C代码 │   ├── debug_tools   ## 调试相关的工具 │   ├── yloop         ## 事件驱动模型代码 │   └── zlib └── wireless    # 无线相关     ├── bluetooth     ## 蓝牙协议     └── lorawan       ## lora协议
  72 directories, 9 files
   | 
 
四、core
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
   | hk@vm:~/AliOS-Things-SDK$ tree -a -L 1 core/ core/ ├── cli       # 命令行工具 ├── Config.in ├── cplusplus # C++支持相关的 ├── debug     # 调试相关 ├── .gitignore ├── init      # 内核初始化相关的 ├── kv        # key value 存储  ├── libc      # C库 ├── mbins     # 多进程相关 ├── mk        # 多进程相关 ├── osal      # 操作系统抽象层 posix接口 cmsis aos ├── pwrmgmt   # 电源管理 ├── rbtree  ├── rhino     # 多任务调度内核 └── vfs       # 虚拟文件系统
  13 directories, 2 files
   | 
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
   | hk@vm:~/AliOS-Things-SDK$ tree -a -L 2 platform/ platform/ ├── arch    # 和芯片内核相关 │   ├── arm    ## mk3080 就是arm-cortex-m4架构 │   ├── csky │   ├── linux │   ├── mips │   ├── README.md │   ├── risc-v │   ├── rx600 │   └── xtensa ├── board │   ├── aaboard_demo │   ├── asr5501 │   ├── board_legacy │   ├── Config.in │   ├── esp8266  ## esp8266 │   ├── linuxhost │   ├── mk3072 │   ├── mk3080   ## mk3080 │   ├── README.md │   ├── stm32f103rb-nucleo  ## stm32 │   └── stm32f429zi-nucleo ├── Config.in ├── .gitignore └── mcu     ├── #......     ├── esp8266   ##esp8266     ├── #......     ├── rtl8710bn  ## mk3080开发板     ├── #...... 85 directories, 6 files
   | 
 
六、build
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
   | hk@vm:~/AliOS-Things-SDK$ tree -a -L 2 build/ build/ ├── aos.mk ├── build_rules  # 编译规则  aos make 会调用这些文件,进行编译处理 │   ├── aos_3rd_project.mk │   ├── aos_host_cmd.mk      ## 编译主机的命令  linux系统和window系统以及mac系统都不一样的 │   ├── aos_kconfig.mk       ## kconfig相关的编译规则 │   ├── aos_prebuild.mk │   ├── aos_target_build.mk │   ├── aos_target_config.mk ## 目标板相关编译规则 │   ├── obsoletes │   └── toolchain ├── check        # 检查 组件 工具链  │   ├── check_wrapper.py │   └── commands ├── cmd          # 跟操作系统相关的命令工具 │   ├── etc │   ├── linux32 │   ├── linux64 │   ├── osx │   ├── python │   └── win32 ├── compiler     # 编译工具链 │   ├── gcc-arm-none-eabi │   └── gcc-xtensa-lx106 ├── Config.in    # kconfig 菜单文件 ├── configs      # kconfig 默认配置文件 │   ├── aos.mk │   ├── # ...... │   ├── profile-linkkitapp_esp8266_defconfig │   ├── profile-linkkitapp_mk3060_defconfig │   ├── profile-linkkitapp_mk3080_defconfig │   ├── # ...... ├── external_config.py ├── external_config.pyc ├── .gitignore ├── kconfig      # kconfig 程序目录 │   └── Linux64 ├── Makefile     # makefile文件 根文件 ├── __pycache__ │   ├── external_config.cpython-35.pyc │   └── toolchain_config.cpython-35.pyc ├── scripts      # 脚本   aos在处理的时候,调用的脚本python │   ├── add_sensor_config_mk.py │   ├── aos_autoconf_convert.py │   ├── aos_autoconf_convert.pyc │   ├── # ...... │   ├── trans_remain_mk.sh │   └── xml_format.py ├── site_scons   # 脚本相关的 │   ├── debug │   ├── dummy.obj │   ├── gen_debug_configs.py │   ├── gen_upload_configs.py │   ├── jlink.py │   ├── README.md │   ├── scons_debug.py │   ├── scons_upload.py │   ├── scons_util.py │   ├── site_init.py │   ├── toolchain.py │   └── upload        ## 烧写工具 ├── toolchain_autodownload.config  # 工具链的自动下载 ├── toolchain_config.py ├── toolchain_config.pyc └── tools     ├── copyright     ├── fileformat.py     └── keil_iar_autobuild.sh
  28 directories, 124 files
   |