diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8d612b75a88a8a76dc21d5167ee0c28377c04e2c..85bf6698db6032e74727375dbeaac5bc7cbb006d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ stages: - pre_stage # 准备阶段 - compile_stage # 编译阶段 - test_stage # 测试阶段 + - report_stage # 测试报表生成阶段 - post_stage # 收尾阶段 # 所有soc覆盖编译启动 @@ -23,8 +24,10 @@ all_soc_compile: freertos_feature_compile: stage: compile_stage script: - - cd /home/gitlab-runner/auto_compile_tool/phytium-test-tools/test_tool - - python3 gitlab_pipeline_compile.py $CI_MERGE_REQUEST_PROJECT_PATH $CI_PROJECT_DIR $CI_PROJECT_DIR/example/freertos_feature + - cd /home3/gitlab_runner_workspace/auto_compile_tool + - python3 set_common_info.py /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool/config_info/common.json freertos + - cd /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool + - python3 gitlab_pipeline_compile.py $CI_PROJECT_DIR $CI_PROJECT_DIR/example/freertos_feature tags: - compile needs: ["all_soc_compile"] @@ -32,8 +35,10 @@ freertos_feature_compile: network_compile: stage: compile_stage script: - - cd /home/gitlab-runner/auto_compile_tool/phytium-test-tools/test_tool - - python3 gitlab_pipeline_compile.py $CI_MERGE_REQUEST_PROJECT_PATH $CI_PROJECT_DIR $CI_PROJECT_DIR/example/network + - cd /home3/gitlab_runner_workspace/auto_compile_tool + - python3 set_common_info.py /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool/config_info/common.json freertos + - cd /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool + - python3 gitlab_pipeline_compile.py $CI_PROJECT_DIR $CI_PROJECT_DIR/example/network tags: - compile needs: ["all_soc_compile"] @@ -41,8 +46,10 @@ network_compile: peripheral_compile: stage: compile_stage script: - - cd /home/gitlab-runner/auto_compile_tool/phytium-test-tools/test_tool - - python3 gitlab_pipeline_compile.py $CI_MERGE_REQUEST_PROJECT_PATH $CI_PROJECT_DIR $CI_PROJECT_DIR/example/peripheral + - cd /home3/gitlab_runner_workspace/auto_compile_tool + - python3 set_common_info.py /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool/config_info/common.json freertos + - cd /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool + - python3 gitlab_pipeline_compile.py $CI_PROJECT_DIR $CI_PROJECT_DIR/example/peripheral tags: - compile needs: ["all_soc_compile"] @@ -50,8 +57,10 @@ peripheral_compile: storage_compile: stage: compile_stage script: - - cd /home/gitlab-runner/auto_compile_tool/phytium-test-tools/test_tool - - python3 gitlab_pipeline_compile.py $CI_MERGE_REQUEST_PROJECT_PATH $CI_PROJECT_DIR $CI_PROJECT_DIR/example/storage + - cd /home3/gitlab_runner_workspace/auto_compile_tool + - python3 set_common_info.py /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool/config_info/common.json freertos + - cd /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool + - python3 gitlab_pipeline_compile.py $CI_PROJECT_DIR $CI_PROJECT_DIR/example/storage tags: - compile needs: ["all_soc_compile"] @@ -59,22 +68,35 @@ storage_compile: system_compile: stage: compile_stage script: - - cd /home/gitlab-runner/auto_compile_tool/phytium-test-tools/test_tool - - python3 gitlab_pipeline_compile.py $CI_MERGE_REQUEST_PROJECT_PATH $CI_PROJECT_DIR $CI_PROJECT_DIR/example/system + - cd /home3/gitlab_runner_workspace/auto_compile_tool + - python3 set_common_info.py /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool/config_info/common.json freertos + - cd /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool + - python3 gitlab_pipeline_compile.py $CI_PROJECT_DIR $CI_PROJECT_DIR/example/system tags: - compile needs: ["all_soc_compile"] -# 板级测试启动 -e2000d_board_test: +template_compile: + stage: compile_stage + script: + - cd /home3/gitlab_runner_workspace/auto_compile_tool + - python3 set_common_info.py /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool/config_info/common.json freertos + - cd /home3/gitlab_runner_workspace/auto_compile_tool/phytium-test-tools/test_tool + - python3 gitlab_pipeline_compile.py $CI_PROJECT_DIR $CI_PROJECT_DIR/example/template + tags: + - compile + needs: ["all_soc_compile"] + +# 各模块板级测试 +code_update: stage: test_stage script: - - echo "test on E2000d board is about to start..." + - echo "Code has been updated." tags: - test + allow_failure: true when: manual -# 各模块板级测试 freertos_feature_test: stage: test_stage script: @@ -84,8 +106,8 @@ freertos_feature_test: - python3 gitlab_pipeline_board_test.py $CI_PROJECT_DIR $CI_PROJECT_DIR/example/freertos_feature tags: - test - allow_failure: true - needs: ["e2000d_board_test"] + allow_failure: true + when: manual network_test: stage: test_stage @@ -96,8 +118,8 @@ network_test: - python3 gitlab_pipeline_board_test.py $CI_PROJECT_DIR $CI_PROJECT_DIR/example/network tags: - test - allow_failure: true - needs: ["e2000d_board_test"] + allow_failure: true + when: manual peripheral_test: stage: test_stage @@ -108,8 +130,8 @@ peripheral_test: - python3 gitlab_pipeline_board_test.py $CI_PROJECT_DIR $CI_PROJECT_DIR/example/peripheral tags: - test - allow_failure: true - needs: ["e2000d_board_test"] + allow_failure: true + when: manual storage_test: stage: test_stage @@ -120,8 +142,8 @@ storage_test: - python3 gitlab_pipeline_board_test.py $CI_PROJECT_DIR $CI_PROJECT_DIR/example/storage tags: - test - allow_failure: true - needs: ["e2000d_board_test"] + allow_failure: true + when: manual system_test: stage: test_stage @@ -132,5 +154,18 @@ system_test: - python3 gitlab_pipeline_board_test.py $CI_PROJECT_DIR $CI_PROJECT_DIR/example/system tags: - test - allow_failure: true - needs: ["e2000d_board_test"] \ No newline at end of file + allow_failure: true + when: manual + + # 测试报表生成 +update_report: + stage: report_stage + script: + - cd /home/gitlab-runner/test_tool/phytium-test-tools/test_tool + - python3 gitlab_pipeline_report_display.py freertos $CI_PROJECT_DIR + tags: + - test + when: manual + artifacts: + paths: + - report_for_gitlab_pipeline/ \ No newline at end of file diff --git a/README.md b/README.md index 83ab54904464ee1fd8f4ccb66ddf990d3fb7f161..a3d96ba510592c9b29ad565b58ad9268f02a6a2b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Phytium-FreeRTOS-SDK -**v1.0.0** [ReleaseNote](./docs/ChangeLog.md) +**v1.1.0** [ReleaseNote](./docs/ChangeLog.md) ## 1. 介绍 @@ -16,7 +16,7 @@ - 目前支持在Windows和Linux上使用SDK,支持在x86_64和arm aarch64设备上完成交叉编译 -![windows](./docs/fig/windows.png)![linux](./docs/fig/linux.png)![输入图片说明](./docs/fig/kylin.png) +![windows](./docs/fig/windows.png)![linux](./docs/fig/linux.png)![输入图片说明](./docs/fig/kylin.png)![phystudio](./docs/reference/ide/figs/phystudio_brand.png) - 参考如下说明搭建Phytium FreeRTOS SDK的软件环境 @@ -26,6 +26,9 @@ [Linux arm aarch64 快速入门](./docs/reference/usr/install_linux_aarch64.md) + [PhyStudio用户手册 无工程调试](./docs/reference/ide/debug_noproj.md) + ![](./docs/reference/ide/figs/noproj_debug.png) + - 参考[使用说明](./docs/reference/usr/usage.md), 新建Phytium FreeRTOS SDK的应用工程,与开发板建立连接 - 参考[例程](./example/template/), 新建Phytium FreeRTOS SDK的例程,在开发板上运行 diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 9ff3d5cffd67783add0a66f7e1bef18aa0489583..88fb9b4b53b2600a477dd53a46bc827ce8c22b79 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -1,3 +1,44 @@ +# Phytium FreeRTOS SDK 2024-10-15 v1.1.0 ChangeLog + +Change Log since 2024-10-12 + +## driver + +- fix QSPI example compilation issues + +## third-party + +- fix eMMC assert error +- fix wifi example iomux assert error + +# Phytium FreeRTOS SDK 2024-10-10 ChangeLog + +Change Log since 2024-10-10 + +## IDE + +- Added Phystudio related documents + +# Phytium FreeRTOS SDK 2024-09-25 ChangeLog + +Change Log since 2024-09-24 + +## driver + +- refine FREERTOS_WDT_CTRL_SET_TIMEOUT operation in FFreeRTOSWdtControl function + +## example + +- set the timeout unit to tick, use GenericTimerFrequecy + +# Phytium FreeRTOS SDK 2024-08-21 ChangeLog + +Change Log since 2024-08-12 + +## drivers + +- change i2c driver to adapt sdk change + # Phytium FreeRTOS SDK 2024-08-12 ChangeLog Change Log since 2024-08-05 @@ -473,16 +514,19 @@ Change Log since 2024-03-08 ## driver +- change gpio driver for adapting the sdk - change gpio driver for adapting the sdk # Phytium FreeRTOS SDK 2024-03-08 ChangeLog Change Log since 2024-02-29 +## example ## example - add ui example +## third -party ## third -party - change shell with echo ctrl @@ -493,6 +537,7 @@ Change Log since 2024-02-29 ## example +- add i2s example - add i2s example ## driver @@ -594,6 +639,7 @@ Change Log since 2023-12-25 ## driver - new standalone version adaptation of xmac and gmac. + ## example @@ -816,6 +862,7 @@ Change Log sinc 2023-09-06 # example +- change the i2s example to adapt the phytiumpi, modify some bugs - change the i2s example to adapt the phytiumpi, modify some bugs # driver @@ -827,6 +874,7 @@ Change Log sinc 2023-09-01 # example +- change the i2s example to adapt the phytiumpi, modify some bugs - change the i2s example to adapt the phytiumpi, modify some bugs # driver @@ -883,6 +931,7 @@ Change Log sinc 2023-08-30 ## third-party +- Change the fatfs src.mk and include.mk - Change the fatfs src.mk and include.mk # Phytium FreeRTOS SDK 2023-08-31 ChangeLog @@ -894,10 +943,12 @@ Change Log sinc 2023-08-29 ## example +- Change the peripheral makefile and Kconfig , compile the all example - Change the peripheral makefile and Kconfig , compile the all example ## third-party +- Change the lvgl , cherryusb and sdmmc makefile and Kconfig - Change the lvgl , cherryusb and sdmmc makefile and Kconfig - Change the third-party/include.mk , thirdparty.mk @@ -917,15 +968,18 @@ Change Log sinc 2023-08-28 Change Log sinc 2023-08-20 +## example ## example - adapt to new frameworks +- adapt feature, qspi, atomic - adapt feature, qspi, atomic # Phytium FreeRTOS SDK 2023-07-14 ChangeLog Change Log sinc 2023-07-10 +## example ## example - add template_new example to show new complier use @@ -959,6 +1013,7 @@ Change Log sinc 2023-07-02 ## third-party +- letter-shell adapt to new psci api - letter-shell adapt to new psci api # Phytium FreeRTOS SDK 2023-06-28 ChangeLog @@ -1050,6 +1105,7 @@ Change Log sinc 2023-3-16 - modify cherryusb (ready to merge to cherryusb baseline) - reconstruct xhci driver - modify usbh_bus usage to support use multiple usb controller + - modify enumration proccedure to support enumrate usb 3.0 device (e.g mass storage) - modify enumration proccedure to support enumrate usb 3.0 device (e.g mass storage) - implment for usb 3.0 hub @@ -1066,6 +1122,7 @@ Change Log sinc 2023-3-15 - driver/media add the multi-display driver +## example ## example - media add config and example for the multi-display @@ -1662,4 +1719,4 @@ Change Log sinc init - add simple bootloader for qemu application - import freertos v10.0.1 source code -- add ft20004/e2000/qemu port code +- add ft20004/e2000/qemu port code \ No newline at end of file diff --git a/docs/reference/ide/debug.md b/docs/reference/ide/debug.md new file mode 100644 index 0000000000000000000000000000000000000000..9fcad39cb401e4d27c71b7457dc8a727ee65fb4e --- /dev/null +++ b/docs/reference/ide/debug.md @@ -0,0 +1,139 @@ +## 调试教程 + +### 创建调试配置 + +* 点击调试按钮下拉框,进入Debug Configurations. + ![](pic/pic.png) + +* 单击左上角红框中图标,或者双击Phytium GDB OpenOCD Debugging,创建调试配置。 + ![](pic/pic1.png) + +* 选中工程,Main选项卡中C/C++ Application自动填充好工程编译后生成的同名二进制文件。 + ![](pic/pic3.png) + +* Debugger选项卡中,包含启动openocd和gdb的调试配置。Probe对应使用的调试适配器。选择不同的Probe会有不同的Config options启动脚本来启动openocd。 + ![](pic/pic2.png) + +* Startup选项卡,包括一些用于配置调试会话的openocd选项。 + ![](pic/pic4.png) + 上述字段会按照如下顺序生成命令发送给gdb: + +```csharp +monitor reset init +monitor halt +monitor arm semihosting enable +symbol-file ".../wdt/Debug/est.elf" +load ".../wdt/Debug/est.elf" +monitor gdb_breakpoint_override hardware +break main +monitor reset halt +monitor halt +``` + +* Common选项卡,选择调试配置保存的位置。选择Local file,即保存在本地工作区;选择Shared file,即保存在工程中。 + ![](pic/pic5.png) + +### 启动调试会话 + +* 启动调试会话前,确保: + + * 开发板具有JTAG接口,并且通过调试适配器将开发板的JTAG接口和主机的USB接口连接起来。 + + * 开发板上电。 + +* 选中工程,完成调试配置后,点击Debug按钮,启动调试,默认断点在main函数入口。 + ![](pic/pic6.png) + +* 如果需要再次启动同一工程的调试,可以点击Debug下拉图标,选择第一项,启动调试。 + ![](pic/pic7.png) + +* 注意:启动调试会话时,Phytium的视图会发生更改。 + +* 如果成功启动了调试会话,可以看到openocd和aarch-none-elf-gdb这两个进程。 + ![](pic/pic8.png) + +* 同时,PhyStudio中的视图会从Edit视图切换到Debug视图,Debug视图中会展示: + + * 函数调用堆栈。 + + * 源代码视图显示断点位置。 + + * Variables、Expressions、Breaks等视图也会处于打开状态。 + + * Console视图打开。 + + 如果是第一次在PhyStudio进入调试,可能会弹出一个确认视图切换的对话框,点击Switch按钮切换即可。 + ![](pic/pic9.png) + ![](pic/pic10.png) + + ### 调试应用 + +* 基本调试功能位于顶部的栏中。下图按钮从左至右依次为: + ![](pic/pic11.png) + + * Resume:继续执行程序;如果没有断点就一直执行,直到执行结束;如果运行过程中有断点,就跳转到该断点。 + + * Suspend:停止执行。 + + * Terminate:终止调试会话。 + + * Connect/Disconnect:断开调试连接,已禁用。 + + * Step Into:下一步,若下一步是函数,则会进入函数体内部执行。 + + * Step Over:下一步,不会进入函数体。 + + * Step Return:从进入的函数中跳出来或者跳转到所在函数中的下一个断点。 + +* Variables视图 + ![](pic/variables.png) + 该视图中自动填充调试程序的上下文中存在的变量。包含三列: + + * Name 变量名称。 + + * Type 变量数据类型。 + + * Value 变量的值。 + +* 注:该视图不允许添加或删除行,只允许自动填充变量。 + +* Breakpoints视图 + 显示当前所有断点信息。 + + ![](pic/breakpoint.png) + + 添加断点方式:在源代码区域。双击需要添加的断点的代码显示代码行数的位置。 + + ![](pic/pic12.png) + +* Disassembly视图 + + 点击红框中图标将会跳出Disassembly视图,可以查看对应执行的汇编指令。 + + ![](pic/pic13.png) + +* Console视图 + + 显示openocd进程执行情况。 + ![](pic/console.png) + +* Registers视图 + 显示所有寄存器的值。 + ![](pic/registers.png) + +* Problems视图 + 显示编译、运行和调试过程中产生的警告和错误信息。 + ![](pic/problems.png) + +* Executables视图 + ![](pic/executables.png) + +* Debugger Console视图 + 显示gdb调试信息。 + ![](pic/debugger.png) + 可添加需要监测的地址,监测该地址中的值的变化。 + ![](pic/memory.png) + +* Terminal视图 + 点击Window->Show View->Terminal,生成该视图,显示连接开发板的串口信息。 + ![](pic/terminal.png) \ No newline at end of file diff --git a/docs/reference/ide/debug_noproj.md b/docs/reference/ide/debug_noproj.md new file mode 100644 index 0000000000000000000000000000000000000000..9a217201d8ba812c76190f37ebed014e8dec8393 --- /dev/null +++ b/docs/reference/ide/debug_noproj.md @@ -0,0 +1,118 @@ +## 无工程调试教程 +PhyStudio支持无工程调试,顾名思义也就是在没有创建工程的情况下进行调试,这主要是针对只想使用PhyStudio调试功能的用户,用户选择一个外部的elf文件,然后导入PhyStudio进行调试 +### 1.1 创建调试配置 +- 点击工具栏的调试菜单下拉箭头->Debug Configurations.. + +![](./figs/add_noproj_debugconfig.png) + +- 在弹出的对话框中双击Phytium GDB OpenOCD No-Proj Debugging选项创建一个新的调试配置,输入名字,选择Aarch类型,然后选择需要调试的elf文件 + +![](./figs/edit_noproj_debugconfig.png) + +- Debugger选项卡中,包含启动openocd和gdb的调试配置。Probe对应使用的调试适配器。选择不同的Probe会有不同的Config options启动脚本来启动openocd + +![](pic/pic2.png) + +- Startup选项卡,包括一些用于配置调试会话的openocd选项。 + +![](pic/pic4.png) + +上述字段会按照如下顺序生成命令发送给gdb: + +```csharp +monitor reset init +monitor halt +monitor arm semihosting enable +symbol-file ".../wdt/Debug/est.elf" +load ".../wdt/Debug/est.elf" +monitor gdb_breakpoint_override hardware +break main +monitor reset halt +monitor halt +``` +### 1.2 启动调试会话 + +* 启动调试会话前,确保: + + * 开发板具有JTAG接口,并且通过调试适配器将开发板的JTAG接口和主机的USB接口连接起来。 + + * 开发板上电。 + +* 在调试配置框中点击Debug按钮进行调试 + +### 1.3 配置源码 +- 无工程调试启动后默认是没有关联源码的,需要手动添加,先从①处复制elf文件编译路径->点击Edit Source Lookup Path,按照下图所示步骤添加源码路径映射,把编译所在的源码路径和本机所在的源码路径关联起来,完成后就可以查看源码了,调试方式跟有工程调试一样 + +![](./figs/noproj_debug_source.png) +![](./figs/noproj_debug.png) +### 1.4 调试应用 + +* 基本调试功能位于顶部的栏中。下图按钮从左至右依次为: + ![](pic/pic11.png) + + * Resume:继续执行程序;如果没有断点就一直执行,直到执行结束;如果运行过程中有断点,就跳转到该断点。 + + * Suspend:停止执行。 + + * Terminate:终止调试会话。 + + * Connect/Disconnect:断开调试连接,已禁用。 + + * Step Into:下一步,若下一步是函数,则会进入函数体内部执行。 + + * Step Over:下一步,不会进入函数体。 + + * Step Return:从进入的函数中跳出来或者跳转到所在函数中的下一个断点。 + +* Variables视图 + ![](pic/variables.png) + 该视图中自动填充调试程序的上下文中存在的变量。包含三列: + + * Name 变量名称。 + + * Type 变量数据类型。 + + * Value 变量的值。 + +* 注:该视图不允许添加或删除行,只允许自动填充变量。 + +* Breakpoints视图 + 显示当前所有断点信息。 + + ![](pic/breakpoint.png) + + 添加断点方式:在源代码区域。双击需要添加的断点的代码显示代码行数的位置。 + + ![](pic/pic12.png) + +* Disassembly视图 + + 点击红框中图标将会跳出Disassembly视图,可以查看对应执行的汇编指令。 + + ![](pic/pic13.png) + +* Console视图 + + 显示openocd进程执行情况。 + ![](pic/console.png) + +* Registers视图 + 显示所有寄存器的值。 + ![](pic/registers.png) + +* Problems视图 + 显示编译、运行和调试过程中产生的警告和错误信息。 + ![](pic/problems.png) + +* Executables视图 + ![](pic/executables.png) + +* Debugger Console视图 + 显示gdb调试信息。 + ![](pic/debugger.png) + 可添加需要监测的地址,监测该地址中的值的变化。 + ![](pic/memory.png) + +* Terminal视图 + 点击Window->Show View->Terminal,生成该视图,显示连接开发板的串口信息。 + ![](pic/terminal.png) \ No newline at end of file diff --git a/docs/reference/ide/figs/add_debug_config.png b/docs/reference/ide/figs/add_debug_config.png new file mode 100644 index 0000000000000000000000000000000000000000..a54d1392171065e48cac0d2e6b2b2ec2a00e8c8f Binary files /dev/null and b/docs/reference/ide/figs/add_debug_config.png differ diff --git a/docs/reference/ide/figs/add_include.png b/docs/reference/ide/figs/add_include.png new file mode 100644 index 0000000000000000000000000000000000000000..e691f87a66d22833286ead6b50db7f9ae422cefe Binary files /dev/null and b/docs/reference/ide/figs/add_include.png differ diff --git a/docs/reference/ide/figs/add_noproj_debugconfig.png b/docs/reference/ide/figs/add_noproj_debugconfig.png new file mode 100644 index 0000000000000000000000000000000000000000..45904e019a514cda2b2aca2d53999a3f635e8dc2 Binary files /dev/null and b/docs/reference/ide/figs/add_noproj_debugconfig.png differ diff --git a/docs/reference/ide/figs/breakpoints.png b/docs/reference/ide/figs/breakpoints.png new file mode 100644 index 0000000000000000000000000000000000000000..c171ecf775da3ae6fdb9ae32e8cc42cadd7cf237 Binary files /dev/null and b/docs/reference/ide/figs/breakpoints.png differ diff --git a/docs/reference/ide/figs/build_done.png b/docs/reference/ide/figs/build_done.png new file mode 100644 index 0000000000000000000000000000000000000000..2f30a971c6d2d6afe2e6c594432f834db083bfe9 Binary files /dev/null and b/docs/reference/ide/figs/build_done.png differ diff --git a/docs/reference/ide/figs/build_elf.png b/docs/reference/ide/figs/build_elf.png new file mode 100644 index 0000000000000000000000000000000000000000..12ff71d94693764e5573bdb37142755a92538231 Binary files /dev/null and b/docs/reference/ide/figs/build_elf.png differ diff --git a/docs/reference/ide/figs/cmsis_dap_device.png b/docs/reference/ide/figs/cmsis_dap_device.png new file mode 100644 index 0000000000000000000000000000000000000000..ef1ebfb48992e4dd4ce31cb77aad2b5d7141cc6a Binary files /dev/null and b/docs/reference/ide/figs/cmsis_dap_device.png differ diff --git a/docs/reference/ide/figs/com_number.png b/docs/reference/ide/figs/com_number.png new file mode 100644 index 0000000000000000000000000000000000000000..c815bf87da218cca8ce60e635e5605b550bbba84 Binary files /dev/null and b/docs/reference/ide/figs/com_number.png differ diff --git a/docs/reference/ide/figs/config_tftp.png b/docs/reference/ide/figs/config_tftp.png new file mode 100644 index 0000000000000000000000000000000000000000..c8cfd9525a228869e1a2155ad6bc6bb743e7933f Binary files /dev/null and b/docs/reference/ide/figs/config_tftp.png differ diff --git a/docs/reference/ide/figs/debug_as.png b/docs/reference/ide/figs/debug_as.png new file mode 100644 index 0000000000000000000000000000000000000000..f9df327ae282dd19d2452c0648ca6f68f2f8e235 Binary files /dev/null and b/docs/reference/ide/figs/debug_as.png differ diff --git a/docs/reference/ide/figs/debug_config_menu.png b/docs/reference/ide/figs/debug_config_menu.png new file mode 100644 index 0000000000000000000000000000000000000000..0c4b1b0dd67ce592c368556a305a4f0cd95ee4cb Binary files /dev/null and b/docs/reference/ide/figs/debug_config_menu.png differ diff --git a/docs/reference/ide/figs/debug_info.png b/docs/reference/ide/figs/debug_info.png new file mode 100644 index 0000000000000000000000000000000000000000..0329afd73cd44853da9c1657e086c90ac6aae766 Binary files /dev/null and b/docs/reference/ide/figs/debug_info.png differ diff --git a/docs/reference/ide/figs/debug_output.png b/docs/reference/ide/figs/debug_output.png new file mode 100644 index 0000000000000000000000000000000000000000..feabd4d0e51750421ce0d7a8062fdff7176ea86e Binary files /dev/null and b/docs/reference/ide/figs/debug_output.png differ diff --git a/docs/reference/ide/figs/directory.png b/docs/reference/ide/figs/directory.png new file mode 100644 index 0000000000000000000000000000000000000000..a0933824a60cb311f33b49fe293bf41486f2b051 Binary files /dev/null and b/docs/reference/ide/figs/directory.png differ diff --git a/docs/reference/ide/figs/disassembly.png b/docs/reference/ide/figs/disassembly.png new file mode 100644 index 0000000000000000000000000000000000000000..d382d655575a44e2dc475bc344450a0fc47e89b3 Binary files /dev/null and b/docs/reference/ide/figs/disassembly.png differ diff --git a/docs/reference/ide/figs/e2000_terminal.png b/docs/reference/ide/figs/e2000_terminal.png new file mode 100644 index 0000000000000000000000000000000000000000..110178f6764980c4395f683c2290eaca2a5b76cc Binary files /dev/null and b/docs/reference/ide/figs/e2000_terminal.png differ diff --git a/docs/reference/ide/figs/edit_noproj_debugconfig.png b/docs/reference/ide/figs/edit_noproj_debugconfig.png new file mode 100644 index 0000000000000000000000000000000000000000..dbd34853d407b306a06657ffb8c79b723b45a070 Binary files /dev/null and b/docs/reference/ide/figs/edit_noproj_debugconfig.png differ diff --git a/docs/reference/ide/figs/git_addurl.png b/docs/reference/ide/figs/git_addurl.png new file mode 100644 index 0000000000000000000000000000000000000000..c85805505df5865dd91ca949e0c432c5f386ca90 Binary files /dev/null and b/docs/reference/ide/figs/git_addurl.png differ diff --git a/docs/reference/ide/figs/git_commit.png b/docs/reference/ide/figs/git_commit.png new file mode 100644 index 0000000000000000000000000000000000000000..d428d95d3b6505ed205180d832ed9c47f5d2d237 Binary files /dev/null and b/docs/reference/ide/figs/git_commit.png differ diff --git a/docs/reference/ide/figs/git_createfile.png b/docs/reference/ide/figs/git_createfile.png new file mode 100644 index 0000000000000000000000000000000000000000..1a95b4b2819a03c0d8cd7ecff74cdf5740d1d616 Binary files /dev/null and b/docs/reference/ide/figs/git_createfile.png differ diff --git a/docs/reference/ide/figs/git_createremote.png b/docs/reference/ide/figs/git_createremote.png new file mode 100644 index 0000000000000000000000000000000000000000..029e35677150e2d2653a5c959a65b221e5e3bfaa Binary files /dev/null and b/docs/reference/ide/figs/git_createremote.png differ diff --git a/docs/reference/ide/figs/git_perspective.png b/docs/reference/ide/figs/git_perspective.png new file mode 100644 index 0000000000000000000000000000000000000000..84d81afe9300c073ae106913c45325cfa032ca45 Binary files /dev/null and b/docs/reference/ide/figs/git_perspective.png differ diff --git a/docs/reference/ide/figs/git_push.png b/docs/reference/ide/figs/git_push.png new file mode 100644 index 0000000000000000000000000000000000000000..61956bd59bc524442f69149edd4fe049a840f9c4 Binary files /dev/null and b/docs/reference/ide/figs/git_push.png differ diff --git a/docs/reference/ide/figs/git_pushresult.png b/docs/reference/ide/figs/git_pushresult.png new file mode 100644 index 0000000000000000000000000000000000000000..49a109aef3929b45cb0fc094f246218575f27825 Binary files /dev/null and b/docs/reference/ide/figs/git_pushresult.png differ diff --git a/docs/reference/ide/figs/git_remotes.png b/docs/reference/ide/figs/git_remotes.png new file mode 100644 index 0000000000000000000000000000000000000000..56540c214f3bb097188255cd26122add04577344 Binary files /dev/null and b/docs/reference/ide/figs/git_remotes.png differ diff --git a/docs/reference/ide/figs/git_reposselect.png b/docs/reference/ide/figs/git_reposselect.png new file mode 100644 index 0000000000000000000000000000000000000000..544ca9d869d48744ca005cb35fa2e9748fe0a074 Binary files /dev/null and b/docs/reference/ide/figs/git_reposselect.png differ diff --git a/docs/reference/ide/figs/git_shareproj.png b/docs/reference/ide/figs/git_shareproj.png new file mode 100644 index 0000000000000000000000000000000000000000..83aa9be5e9ce3eba7dad815a3313cb175805cffd Binary files /dev/null and b/docs/reference/ide/figs/git_shareproj.png differ diff --git a/docs/reference/ide/figs/gitclone_branch.png b/docs/reference/ide/figs/gitclone_branch.png new file mode 100644 index 0000000000000000000000000000000000000000..567ecaa5bacc6ca45a0fd9146b1978ee851ced93 Binary files /dev/null and b/docs/reference/ide/figs/gitclone_branch.png differ diff --git a/docs/reference/ide/figs/gitclone_finish.png b/docs/reference/ide/figs/gitclone_finish.png new file mode 100644 index 0000000000000000000000000000000000000000..dd71b1e1216bda69f9e9932efcaa516cfd6bcad9 Binary files /dev/null and b/docs/reference/ide/figs/gitclone_finish.png differ diff --git a/docs/reference/ide/figs/gitclone_repository.png b/docs/reference/ide/figs/gitclone_repository.png new file mode 100644 index 0000000000000000000000000000000000000000..b4c605a1f907c5eb9aaddac5be09e92a8e0a5c96 Binary files /dev/null and b/docs/reference/ide/figs/gitclone_repository.png differ diff --git a/docs/reference/ide/figs/gitrepos_create.png b/docs/reference/ide/figs/gitrepos_create.png new file mode 100644 index 0000000000000000000000000000000000000000..2a159d36939ed4c267402595d66d1f82be80091c Binary files /dev/null and b/docs/reference/ide/figs/gitrepos_create.png differ diff --git a/docs/reference/ide/figs/gitview.png b/docs/reference/ide/figs/gitview.png new file mode 100644 index 0000000000000000000000000000000000000000..2c3afae78727a84478396e0550c8e398515c6713 Binary files /dev/null and b/docs/reference/ide/figs/gitview.png differ diff --git a/docs/reference/ide/figs/gpio_src.png b/docs/reference/ide/figs/gpio_src.png new file mode 100644 index 0000000000000000000000000000000000000000..d0fc2d55f58cfd64e6d90cc0c4bfc8e7a96db2ea Binary files /dev/null and b/docs/reference/ide/figs/gpio_src.png differ diff --git a/docs/reference/ide/figs/host_ip.png b/docs/reference/ide/figs/host_ip.png new file mode 100644 index 0000000000000000000000000000000000000000..08013e6df8f24e49ef8a1e213fdcd01620dddb03 Binary files /dev/null and b/docs/reference/ide/figs/host_ip.png differ diff --git a/docs/reference/ide/figs/import_makefile_project.png b/docs/reference/ide/figs/import_makefile_project.png new file mode 100644 index 0000000000000000000000000000000000000000..3b625d3b8b6257a7d7add11100efc09e12d726b1 Binary files /dev/null and b/docs/reference/ide/figs/import_makefile_project.png differ diff --git a/docs/reference/ide/figs/import_project.png b/docs/reference/ide/figs/import_project.png new file mode 100644 index 0000000000000000000000000000000000000000..7ae70aeaa8ee9a33a037d1676c38a78e5bbe8991 Binary files /dev/null and b/docs/reference/ide/figs/import_project.png differ diff --git a/docs/reference/ide/figs/install_dir.png b/docs/reference/ide/figs/install_dir.png new file mode 100644 index 0000000000000000000000000000000000000000..16986231f7aebb6dc6bb5f519dc9edc9d7d1de82 Binary files /dev/null and b/docs/reference/ide/figs/install_dir.png differ diff --git a/docs/reference/ide/figs/install_ide.png b/docs/reference/ide/figs/install_ide.png new file mode 100644 index 0000000000000000000000000000000000000000..ac7c27567c4fad73e0bea06a2acfc88b70e9405e Binary files /dev/null and b/docs/reference/ide/figs/install_ide.png differ diff --git a/docs/reference/ide/figs/install_ok.png b/docs/reference/ide/figs/install_ok.png new file mode 100644 index 0000000000000000000000000000000000000000..9da7a0dd80b1fdf7003b22193485ac9e8a9fbe4a Binary files /dev/null and b/docs/reference/ide/figs/install_ok.png differ diff --git a/docs/reference/ide/figs/installing.png b/docs/reference/ide/figs/installing.png new file mode 100644 index 0000000000000000000000000000000000000000..84f0cbabe9d564b85b9bb211fd21d35151ce22f4 Binary files /dev/null and b/docs/reference/ide/figs/installing.png differ diff --git a/docs/reference/ide/figs/license.png b/docs/reference/ide/figs/license.png new file mode 100644 index 0000000000000000000000000000000000000000..1737784684ae5b836f19e25cab4b2d036d7e548b Binary files /dev/null and b/docs/reference/ide/figs/license.png differ diff --git a/docs/reference/ide/figs/main_page.png b/docs/reference/ide/figs/main_page.png new file mode 100644 index 0000000000000000000000000000000000000000..46df675a4739e94af858633d73b10236af269663 Binary files /dev/null and b/docs/reference/ide/figs/main_page.png differ diff --git a/docs/reference/ide/figs/makefile_project.png b/docs/reference/ide/figs/makefile_project.png new file mode 100644 index 0000000000000000000000000000000000000000..ae31a84426f77276f374e787cc2116c96aa75fab Binary files /dev/null and b/docs/reference/ide/figs/makefile_project.png differ diff --git a/docs/reference/ide/figs/makefile_project_wizard.png b/docs/reference/ide/figs/makefile_project_wizard.png new file mode 100644 index 0000000000000000000000000000000000000000..1d92e9004a4283cba1d9bfacbcd8c953266f6014 Binary files /dev/null and b/docs/reference/ide/figs/makefile_project_wizard.png differ diff --git a/docs/reference/ide/figs/managedproj_config.png b/docs/reference/ide/figs/managedproj_config.png new file mode 100644 index 0000000000000000000000000000000000000000..33730033a5bcca795c2a69e1c2f92dd733f6550e Binary files /dev/null and b/docs/reference/ide/figs/managedproj_config.png differ diff --git a/docs/reference/ide/figs/memory.png b/docs/reference/ide/figs/memory.png new file mode 100644 index 0000000000000000000000000000000000000000..7cf4682312f09fd70e9437e90783a585ce4199fa Binary files /dev/null and b/docs/reference/ide/figs/memory.png differ diff --git a/docs/reference/ide/figs/new_file.png b/docs/reference/ide/figs/new_file.png new file mode 100644 index 0000000000000000000000000000000000000000..d239d98097468e7381664b9ca8cbec7f04fbe889 Binary files /dev/null and b/docs/reference/ide/figs/new_file.png differ diff --git a/docs/reference/ide/figs/new_file_wizard.png b/docs/reference/ide/figs/new_file_wizard.png new file mode 100644 index 0000000000000000000000000000000000000000..6bdbd1d0e1a2ef5931d7dd6c06a89ba9d728c568 Binary files /dev/null and b/docs/reference/ide/figs/new_file_wizard.png differ diff --git a/docs/reference/ide/figs/new_proj.png b/docs/reference/ide/figs/new_proj.png new file mode 100644 index 0000000000000000000000000000000000000000..80b40b59e320b4935fe6d38d68f68feb736edcf7 Binary files /dev/null and b/docs/reference/ide/figs/new_proj.png differ diff --git a/docs/reference/ide/figs/noproj_debug.png b/docs/reference/ide/figs/noproj_debug.png new file mode 100644 index 0000000000000000000000000000000000000000..c9ef20f1d1126f931f1c11717d011287865319f0 Binary files /dev/null and b/docs/reference/ide/figs/noproj_debug.png differ diff --git a/docs/reference/ide/figs/noproj_debug_source.png b/docs/reference/ide/figs/noproj_debug_source.png new file mode 100644 index 0000000000000000000000000000000000000000..34555519d6aec3983cf2884a6cf3a48bb4b656a5 Binary files /dev/null and b/docs/reference/ide/figs/noproj_debug_source.png differ diff --git a/docs/reference/ide/figs/open_new_terminal.png b/docs/reference/ide/figs/open_new_terminal.png new file mode 100644 index 0000000000000000000000000000000000000000..706f2114c6db38d61496a9d534cfbfa912d5f286 Binary files /dev/null and b/docs/reference/ide/figs/open_new_terminal.png differ diff --git a/docs/reference/ide/figs/phystudio_brand.png b/docs/reference/ide/figs/phystudio_brand.png new file mode 100644 index 0000000000000000000000000000000000000000..3b684643346596a6626a4e7c99e808cc5716ce80 Binary files /dev/null and b/docs/reference/ide/figs/phystudio_brand.png differ diff --git a/docs/reference/ide/figs/phystudio_main.png b/docs/reference/ide/figs/phystudio_main.png new file mode 100644 index 0000000000000000000000000000000000000000..111bb7f75d15626184cad0af431825ba19fb8a33 Binary files /dev/null and b/docs/reference/ide/figs/phystudio_main.png differ diff --git a/docs/reference/ide/figs/proj_explorer.png b/docs/reference/ide/figs/proj_explorer.png new file mode 100644 index 0000000000000000000000000000000000000000..5b1513ebaeba60cbb43379e16a3325ab9826ccd4 Binary files /dev/null and b/docs/reference/ide/figs/proj_explorer.png differ diff --git a/docs/reference/ide/figs/proj_folder.png b/docs/reference/ide/figs/proj_folder.png new file mode 100644 index 0000000000000000000000000000000000000000..bf436c376b1ddbb5816c14542e5e1d7ac3182e93 Binary files /dev/null and b/docs/reference/ide/figs/proj_folder.png differ diff --git a/docs/reference/ide/figs/project_wizard.png b/docs/reference/ide/figs/project_wizard.png new file mode 100644 index 0000000000000000000000000000000000000000..cf18bedb17b7efb0b0bc9309e4eaffb2e970bb25 Binary files /dev/null and b/docs/reference/ide/figs/project_wizard.png differ diff --git a/docs/reference/ide/figs/registers.png b/docs/reference/ide/figs/registers.png new file mode 100644 index 0000000000000000000000000000000000000000..fad32afad4a5346047f86978adc7c4af0fa2ff55 Binary files /dev/null and b/docs/reference/ide/figs/registers.png differ diff --git a/docs/reference/ide/figs/sdk_open_location.png b/docs/reference/ide/figs/sdk_open_location.png new file mode 100644 index 0000000000000000000000000000000000000000..beb3885fd61cc598d41101c7970fac0d0bec1b91 Binary files /dev/null and b/docs/reference/ide/figs/sdk_open_location.png differ diff --git a/docs/reference/ide/figs/sdk_path.png b/docs/reference/ide/figs/sdk_path.png new file mode 100644 index 0000000000000000000000000000000000000000..ce7442164171cb3ebcdaf30c1e2e490bdef4983b Binary files /dev/null and b/docs/reference/ide/figs/sdk_path.png differ diff --git a/docs/reference/ide/figs/sdk_path_change.png b/docs/reference/ide/figs/sdk_path_change.png new file mode 100644 index 0000000000000000000000000000000000000000..ed7364c0764bd8f01907a81a163a353481de03f7 Binary files /dev/null and b/docs/reference/ide/figs/sdk_path_change.png differ diff --git a/docs/reference/ide/figs/sdk_path_configprj.png b/docs/reference/ide/figs/sdk_path_configprj.png new file mode 100644 index 0000000000000000000000000000000000000000..f02a72e2fe5b38a456d4dc172b2fc580e9d98e54 Binary files /dev/null and b/docs/reference/ide/figs/sdk_path_configprj.png differ diff --git a/docs/reference/ide/figs/sdkconfig_menu.png b/docs/reference/ide/figs/sdkconfig_menu.png new file mode 100644 index 0000000000000000000000000000000000000000..92a3fa0cf04d27c162c38012d335420e15f6b833 Binary files /dev/null and b/docs/reference/ide/figs/sdkconfig_menu.png differ diff --git a/docs/reference/ide/figs/select_import_proj.png b/docs/reference/ide/figs/select_import_proj.png new file mode 100644 index 0000000000000000000000000000000000000000..a46e5b7fd50e45a93d63fba60b60762da0d0e083 Binary files /dev/null and b/docs/reference/ide/figs/select_import_proj.png differ diff --git a/docs/reference/ide/figs/serial_port.png b/docs/reference/ide/figs/serial_port.png new file mode 100644 index 0000000000000000000000000000000000000000..aa1459c637d04612af374ee3671c2c65e6af2786 Binary files /dev/null and b/docs/reference/ide/figs/serial_port.png differ diff --git a/docs/reference/ide/figs/set_tftp.png b/docs/reference/ide/figs/set_tftp.png new file mode 100644 index 0000000000000000000000000000000000000000..7297b5571fd761d7b9e4409a777c4c686f26de20 Binary files /dev/null and b/docs/reference/ide/figs/set_tftp.png differ diff --git a/docs/reference/ide/figs/step_debug.png b/docs/reference/ide/figs/step_debug.png new file mode 100644 index 0000000000000000000000000000000000000000..9e55b3f232ada790a45a3b97de4ce8e8c686f1a2 Binary files /dev/null and b/docs/reference/ide/figs/step_debug.png differ diff --git a/docs/reference/ide/figs/terminal_action.png b/docs/reference/ide/figs/terminal_action.png new file mode 100644 index 0000000000000000000000000000000000000000..54a7d22b3cea2bb1c14d71e45b22cde235d0fddb Binary files /dev/null and b/docs/reference/ide/figs/terminal_action.png differ diff --git a/docs/reference/ide/figs/terminal_addaction.png b/docs/reference/ide/figs/terminal_addaction.png new file mode 100644 index 0000000000000000000000000000000000000000..b9f26403b62892904db86d1483328da0e5d912a4 Binary files /dev/null and b/docs/reference/ide/figs/terminal_addaction.png differ diff --git a/docs/reference/ide/figs/terminal_tool.png b/docs/reference/ide/figs/terminal_tool.png new file mode 100644 index 0000000000000000000000000000000000000000..51ea17d6556cad7b61f9bc5830e27840f4a0fa8e Binary files /dev/null and b/docs/reference/ide/figs/terminal_tool.png differ diff --git a/docs/reference/ide/figs/tftp_file_list.png b/docs/reference/ide/figs/tftp_file_list.png new file mode 100644 index 0000000000000000000000000000000000000000..4eb642f3cac8e7cf3175b95894e75dcea442b5a0 Binary files /dev/null and b/docs/reference/ide/figs/tftp_file_list.png differ diff --git a/docs/reference/ide/figs/tftp_toolbar_started.png b/docs/reference/ide/figs/tftp_toolbar_started.png new file mode 100644 index 0000000000000000000000000000000000000000..d0b5047e5d3bcef178d48b9d6d71488552be7cda Binary files /dev/null and b/docs/reference/ide/figs/tftp_toolbar_started.png differ diff --git a/docs/reference/ide/figs/tftp_upload.png b/docs/reference/ide/figs/tftp_upload.png new file mode 100644 index 0000000000000000000000000000000000000000..25a9ff2229f9f4bfe79fe5cbf39dda205ab3e599 Binary files /dev/null and b/docs/reference/ide/figs/tftp_upload.png differ diff --git a/docs/reference/ide/figs/tftp_view.png b/docs/reference/ide/figs/tftp_view.png new file mode 100644 index 0000000000000000000000000000000000000000..52470b1069470814a92d1223a1a875c5b3c3644b Binary files /dev/null and b/docs/reference/ide/figs/tftp_view.png differ diff --git a/docs/reference/ide/figs/toggle_build.png b/docs/reference/ide/figs/toggle_build.png new file mode 100644 index 0000000000000000000000000000000000000000..d050f9fbdfbeba5a3c7985bf4f20419718be4095 Binary files /dev/null and b/docs/reference/ide/figs/toggle_build.png differ diff --git a/docs/reference/ide/figs/uninstall_ide.png b/docs/reference/ide/figs/uninstall_ide.png new file mode 100644 index 0000000000000000000000000000000000000000..486a070b09d349f7ef8dff85e6a40bb0f1661a87 Binary files /dev/null and b/docs/reference/ide/figs/uninstall_ide.png differ diff --git a/docs/reference/ide/figs/uninstall_ide_2.png b/docs/reference/ide/figs/uninstall_ide_2.png new file mode 100644 index 0000000000000000000000000000000000000000..9d3d48386818fc3ca658df116efa2d7b65c604c5 Binary files /dev/null and b/docs/reference/ide/figs/uninstall_ide_2.png differ diff --git a/docs/reference/ide/figs/use_dap_or_jlink.png b/docs/reference/ide/figs/use_dap_or_jlink.png new file mode 100644 index 0000000000000000000000000000000000000000..8f152cf3e11c35df2a24d6e9ddf086a9ff10efd0 Binary files /dev/null and b/docs/reference/ide/figs/use_dap_or_jlink.png differ diff --git a/docs/reference/ide/figs/welcome_page.png b/docs/reference/ide/figs/welcome_page.png new file mode 100644 index 0000000000000000000000000000000000000000..71d227cb5ba884323908e64c41e5d20dd74bec5b Binary files /dev/null and b/docs/reference/ide/figs/welcome_page.png differ diff --git a/docs/reference/ide/figs/workspace.png b/docs/reference/ide/figs/workspace.png new file mode 100644 index 0000000000000000000000000000000000000000..36e150c3afb4642afcae7805c2f72cc56948a45b Binary files /dev/null and b/docs/reference/ide/figs/workspace.png differ diff --git a/docs/reference/ide/ide.md b/docs/reference/ide/ide.md new file mode 100644 index 0000000000000000000000000000000000000000..1ed0037ddb13f143610d88145156e578609e957e --- /dev/null +++ b/docs/reference/ide/ide.md @@ -0,0 +1,416 @@ +# PhyStudio IDE 开发环境 + +- PhyStudio 基于 Eclipse CDT C/C++ 开发,可以便利开发人员在集成开发环境中开发面向 Phytium 系列 CPU 平台的 Standalone 应用程序。本开发环境集成了编辑、编译、网络下载和调试等基础功能,还有管理工程硬件平台、配置 SDK 和 TFTP 服务器等附加功能,可以简化开发工具的安装流程、提升开发调试体验、增加 Standalone 应用程序的开发体验 + +- PhyStudio 目前支持 Windows x64 操作系统 +- PhyStudio 目前支持 E2000 D/Q Demo 板(开发下载和调试)和飞腾派(开发和下载) + +- PhyStudio 集成了如下运行环境 + - `OpenJDK17`,开源的 JAVA SE 平台实现 + - `Python 3.8`,Python 平台支持 + - `Eclipse Embedded CDT 2023-03`,基于开源 Eclipse 环境进行了修改 + - `OpenOCD 0.12.0`, 本环境中的 openocd.exe 基于开源软件修改后编译,如果需要修改后的源码,可以联系 `opensource_embedded@phytium.com.cn` 获取 + - `xpack-aarch64-none-elf-gcc-11.3.1-1.2`, xpack 发布的[64位交叉编译链](https://github.com/xpack-dev-tools/aarch64-none-elf-gcc-xpack),用于 Windows 环境交叉编译 ARM64 目标码 + - `xpack-arm-none-eabi-gcc-12.2.1-1.2-win32-x64`,xpack 发布的[32位交叉编译链](https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack),用于 Windows 环境交叉编译 ARM32 目标码 + - `xpack-windows-build-tools-4.3.0-1`, xpack 发布的[Windows平台构建工具](xpack-windows-build-tools-4.3.0-1),包含 win32 平台的 make, busybox 工具 + - `Phytium Standalone SDK`,用于 Phytium 系列 CPU 的 嵌入式软件开发工具包 + +## 1. 快速开始 + +### 1.1 下载 PhyStudio 安装包 + +- 从下面的链接中下载开发环境安装包 + +- [PhyStudio_Setup_V0.1.4.exe](https://pan.baidu.com/s/1azuFUjzg0jZgilQB4r1OlA) +> 提取码: phyt + +### 1.2 安装/卸载 PhyStudio + +- 安装 PhyStudio 通过双击安装包 .exe 文件,安装界面如图所示 + +![](./figs/install_ide.png) + +![](./figs/license.png) + +![](./figs/directory.png) + +![](./figs/install_dir.png) + +![](./figs/installing.png) + +- 点击`安装`后,开始安装,等待安装完成后,勾选`运行 PhyStudio`,然后点击`完成`启动 PhyStudio + +![](./figs/install_ok.png) + +- 启动后会提示选择一个 workspace, 选择一个目录点击 `Launch`即可,勾选`Use this as the default and do not ask again`下次启动会记住这次选择不再询问 + +![](./figs/workspace.png) + +- 卸载 PhyStudio 通过双击安装目录下的 uninst.exe 完成 + +![](./figs/uninstall_ide.png) +![](./figs/uninstall_ide_2.png) + +- 卸载完成后手动删除安装目录即可 + +### 1.3 工作主界面介绍 + +- PhyStudio 基于 Eclipse 平台开发,界面风格继承自 Eclipse,启动后的欢迎界面如下图所示,从上至下,依次是使用文档中心,使用 issue 提交中心、管理 SDK 的入口,以及导入managed工程和makefile工程 + +![](./figs/welcome_page.png) + +- 创建/导入工程后进入工作主界面,如下图所示,主界面主要包括四大区域: + - 工程视图区 + - 编辑区 + - 透视图区 + - 信息输出区 + +- 其中,工程视图区顾名思义是管理特定工程项目的,通过在工程视图选中一个工程,在菜单栏可以进行编译、调试等操作,同时,一些常用操作会在工具栏以图标的形式提供快捷方式 +- 编辑区提供编码、调试视图等一系列特定功能,窗口可以移动、关闭、最大化和最小化 +- 透视图定义了当前界面呈现的菜单栏,工具栏,以及功能窗口集合及其布局,不同透视图提供了完成特定类型任务的功能集合,例如 C 透视图组合了项目开发,源文件编辑,项目构建等常用的开发功能窗口,菜单和功能按钮,调试透视图包含了调试项目程序常用的调试功能窗口,菜单和功能按钮 +- 信息输出区提供了各种信息的输出窗口,包括编译过程信息,调试过程信息、串口终端信息等 + +![](./figs/main_page.png) + +### 1.4 Phytium Standalone SDK管理 + 在PhyStudio中SDK可以分为全局SDK和工程SDK: + 1. 全局的SDK作用是在创建工程的时候提供模板示例工程,并初始化工程 + 2. 工程的SDK作用是提供头文件包含,组件文件链接等 + +#### 1.4.1 修改全局SDK路径 +- 在离线的情况下,可以提前下载好Phytium Standalone SDK,然后在工具栏点击SDK Manage下拉菜单->Config SDK Path配置新的SDK路径,点击`Apply and Close`后就会加载新的SDK模板工程,可能会耗时几分钟 + +![](./figs/sdk_path_change.png) + +#### 1.4.2 在线更新SDK +- 如果用户需要在现有的SDK上面进行更新,则需要按照上面步骤先找到SDK Path(默认是PhyStudio的安装路径) + +- 进入 Phytium Standalone SDK 的路径,通过 git 工具更新 SDK,需要注意的是可能会出现冲突 + +``` +cd ./phytium_standalone_sdk +git remote add pub https://gitee.com/phytium_embedded/phytium-standalone-sdk.git +git fetch pub +git pull +``` + +- 进入 `tools\export_ide` 目录,双击运行脚本 `gen_proj.bat`,将 Standalone SDK 的 example 转换为 PhyStudio 工程 + +- Phytium Standalone SDK 资源的详细介绍可以[参考](https://gitee.com/phytium_embedded/phytium-standalone-sdk) + +#### 1.4.3 修改工程的SDK路径 +- 全局的SDK主要是在创建工程的时候加载模板工程并给工程设置初始的SDK路径,对创建完成的工程不生效 +- 如果某个工程需要修改SDK的路径,选中工程右键点击Properties->Resource->Linked Resources->SDK_DIR,按照下图的操作进行修改 + +![](./figs/sdk_path_configprj.png) + +#### 1.4.4 打开工程的SDK路径 +- 通过选中工程,右键菜单选择`Open SDK Location`可以打开工程所在的SDK目录,如下图所示: + +![](./figs/sdk_open_location.png) + +### 1.5 导入或新建项目 +PhyStudio支持`Managed工程`和`makefile工程`两种类型,用户需要根据自己的使用场景和使用习惯进行选择,两者的区别如下: +- `Managed工程`通过界面配置,编译时会自动生成makefile文件,工程的用户文件保存在Workspace下面,通过文件链接的方式引用SDK +- `makefile工程`配置编译选项需要修改makefile文件,工程保存在SDK的example目录下面,使用灵活度较高 + +#### 1.5.1 Managed工程 +在PhyStudio中可以创建一个空的工程或者基于SDK的example导入工程此类工程,推荐通过导入的方式创建,以导入example工程为例: +- 点击 File > New > Import Phytium Project,可以导入现有的 Phytium Standalone SDK 工程 + +![](./figs/import_project.png) + +- 进入项目导入界面后,选择一个导入例程,选择运行平台,如 e2000d 和运行模式,如 aarch64,最后点击 Finish 开始导入 + +![](./figs/project_wizard.png) + +- 等待一段时间导入完成,然后可以通过工程浏览器查看文件 + +![](./figs/proj_explorer.png) + +![](./figs/proj_folder.png) + +- 如上图所示,其中 + - inc 和 src 是工程的头文件和源文件目录,文件存在在 workspace 的工程目录下 + - SDK 是工程依赖的 Standalone SDK 目录,以文件链接的方式存在,不在工程目录下 + - linkscripts 是工程编译依赖的链接脚本 + - README.md 和 fig 是工程的说明文档及相关图片 + - sdkconfig 是用于本工程的 SDK 配置 +- 配置编译和链接选项,选中工程右键点击Properties->C/C++ Build->Settings->Tool Settings,如果是配置汇编的选项则是在GNU Arm Cross Assembler下,C和C++同理,链接选项在Linker下面配置。以包含C的头文件路径为例,在GNU Arm Cross C Compiler下面进行配置,需要注意的是,在选择路径的时候可以选择Workspace或者File system,如果头文件路径是在工程内就选择Workspace,然后找到对应工程下面的文件夹: + +![](./figs/managedproj_config.png) + +- 此外,可以通过 File > New > Phytium Project,进入工程创建向导,创建一个新的项目 + +![](./figs/new_proj.png) + +- 创建完成后的工程与导入的工程类似 + + +#### 1.5.2 Makefile工程 +此工程类型需要用户自己管理makefile源文件以及头文件的编译,开发方式与命令行方式一样,适用于比较熟悉makefile的用户,目前支持通过SDK的示例工程导入,需要注意的是此类工程是完全链接SDK下的示例工程 + +- 点击 File > New > Import Phytium Makefile Project,可以导入现有的 Phytium Standalone SDK 工程 + +![](./figs/import_makefile_project.png) + +- 进入项目导入界面后,选择一个导入例程,选择运行平台,如 e2000d 和运行模式,如 aarch64,最后点击 Finish 开始导入 + +![](./figs/makefile_project_wizard.png) + +- 等待一段时间导入完成并初始化后,然后可以通过工程浏览器查看文件 + +![](./figs/makefile_project.png) + +- 如上图所示,其中 + - inc 和 src 是工程的头文件和源文件目录,文件存在于SDK的example目录下 + - SDK 是工程依赖的 Standalone SDK 目录,以文件链接的方式存在,不在工程目录下 + - linkscripts 是工程编译依赖的链接脚本 + - README.md 和 fig 是工程的说明文档及相关图片 + - sdkconfig 是用于本工程的 SDK 配置 + - makefile 用于编译的makefile,用户需要自己管理 + +- 配置编译链接选项可以直接修改makefile或者配置sdkconfig来实现,sdkconfig的配置方式将在后面章节中进行介绍 + +- 如果增加了新的头文件和源文件需要在makefile中进行添加,才能编译通过。如果增加了工程路径之外的源文件编译和头文件包含,除了在makefile中添加之外,还需要在工程中配置头文件的包含路径,才能在编辑器中找到符号表,右键选中工程点击Properties->C/C++ General->Paths and Symbols->选择为Assembly/C/C++添加头文件路径。配置宏定义和库文件路径分别是在Symbols和Library Paths下 + +![](./figs/add_include.png) + +### 1.6 配置和构建项目 + +#### 1.6.1 配置sdkconfig +PhyStudio支持通过sdkconfig配置工程,`Makefile工程`类型支持绝大多数的sdkconfig配置,而`Managed工程`目前仅支持配置组件,其他的一些配置通过sdkconfig可能不会生效,如编译选项,target类型等。 +- 双击工程浏览器(Project Explorer)中的 sdkconfig 进入 SDK 配置界面 + +![](./figs/sdkconfig_menu.png) + +- 在 SDK 配置界面可以按需要选择或者删除配置,例如,选中 Drivers configuration > Use gpio 和 Use FGPIO,然后按 Ctrl + S 保存配置后,工程会新增一个 fgpio 的路径,后面就可以使用 GPIO 驱动了 + +![](./figs/gpio_src.png) + +#### 1.6.2 构建项目 + +- 完成配置后选中编译的工程,点击工具栏的`Build`图标开始编译 + +![](./figs/toggle_build.png) + +![](./figs/build_done.png) + +- 编译完成后,生成的 ELF 文件保存在 Debug 目录下 + +![](./figs/build_elf.png) + +### 1.7 使用串口工具连接开发板 + +- 启动开发板,PhyStudio 所在的主机通过串口连接开发板 + +![](./figs/com_number.png) + +- 在 Windows > Show View > Terminal 中启动串口终端工具,通过`Open a Terminal` 启动一个新的串口终端, + +![](./figs/terminal_tool.png) +![](./figs/open_new_terminal.png) + +- 这里连接的是串口 COM5,点击`OK`连接成功后可以和开发板进行交互 + +![](./figs/com5.png) +![](./figs/e2000_terminal.png) +> 注意有些开发板启动后默认会进入 Linux 环境,要进行后续开发和调试,需要在 U-Boot 界面中修改 bootcmd 使得开发板启动后停留在 U-Boot 界面 + +- 串口视图支持命令快捷键,可以为一连串命令创建快捷键,在成功连接串口之后在底部点击右键->Add Action,在弹出的对话框中输入名称和命令,完成之后会在底部显示快捷键,点击快捷键按钮直接发送命令,编辑和删除的操作跟添加类似。 + +![](./figs/terminal_addaction.png) +![](./figs/terminal_action.png) + + +### 1.8 通过网络下载程序 + +- 对于有网口的开发板,可以使用 TFTP 直接将镜像加载到开发板上进行启动,首先需要用网线连接开发板,PhyStudio 主机侧连接开发板的网络需要配置好 ip 网段与开发板后续配置的 ip 配套 +- 如下图所示,进入连接开发板的网络适配器配置,PhyStudio 主机侧的 ip 地址设置为 `192.168.4.50`,子网掩码设置为 `255.255.255.0`,网关设置为 `192.168.4.1` + +![](./figs/host_ip.png) + +- 然后点击 PhyStudio 的 Window > Show View > TFTPServerView,配置 TFTP 服务 + +![](./figs/tftp_view.png) + +- 点击 `Config FTP Server` 进入配置界面 + +![](./figs/config_tftp.png) + +- 配置 `Listener Host` 为之前设置的主机 ip `192.168.4.50`,TFTP 服务的路径默认为安装路径下的tftp目录,也可以进行修改,配置完成后点击 `Apply and Close` 生效配置 + +![](./figs/set_tftp.png) + +- 配置完成之后点击`Start FTP server`按钮启动 TFTP 服务,启动成功之后按钮状态显示为这样![](./figs/tftp_toolbar_started.png),对工程进行编译,elf文件会自动拷贝到TFTP目录下面去,用户也可以手动拖拽elf文件到TFTP视图中去。*注意:如果启动失败,请检查网络配置、是否已经启动过TFTP服务了,或是端口被占用。* + +![](./figs/tftp_file_list.png) + + +- 在连接开发板的串口终端中,依次输入下列命令,配置开发板网络,加载并启动镜像 get-start.elf + +``` +setenv ipaddr 192.168.4.20 +setenv serverip 192.168.4.50 +setenv gatewayip 192.168.4.1 +tftpboot 0xa0100000 get-start.elf +bootelf -p 0xa0100000 +``` + +> 镜像的名字根据实际情况设置 + +![](./figs/tftp_upload.png) + +- 随后可以看到开发板的运行输出 + +### 1.9 启动程序调试运行 + +- 对于有 FJTAG 接口的开发板,可以使用调试运行功能,首先参考[jtag_debugging.md](../jtag_debugging/jtag_debugging.md)进行硬件连接 + +> 目前支持 FJTAG 调试的开发板包括 E2000 D/Q Demo 板 + +- 如果使用 CMSIS DAP/DAPLink 作为 JTAG 适配器,连接成功后,设备管理器上应该会看到枚举出的 HID 设备 + +> 具体设备类型取决于 CMSIS DAP 的生成厂家 + +![](./figs/cmsis_dap_device.png) + +- 如果使用 Jlink 作为适配器,连接成功后,设备管理器上应该会看到枚举出的 Bulk 设备 + +> 注意 PhyStudio 使用 OpenOCD 作为调试代理,用 Jlink 作为适配器时不能使用 Jlink 的官方驱动,必须用 libusb 将 Jlink 设备识别为 USB Bulk 设备,相关内容可以参考 [Using J-Link with OpenOCD](https://wiki.segger.com/OpenOCD),[解决 OpenOCD 不能识别 J-Link的方法](https://blog.csdn.net/weixin_45467056/article/details/119886361) + +- 用适配器连接 PhyStudio 主机和开发板后,在 PhyStudio 的工程中创建调试配置,通过 Debug Configurations 进入调试配置界面,双击 Phytium GDB OpenOCD Debug 创建一个调试配置 + +![](./figs/add_debug_config.png) + +![](./figs/debug_config_menu.png) + +- 进入调试配置界面,一般只需要选择适配器(Probe)是 Jlink 还是 DAP,其他配置可以参考 Eclipse OpenOCD 的[配置说明](https://eclipse-embed-cdt.github.io/debug/openocd/)修改,修改完成后点击`Apply`保存配置 + +![](./figs/use_dap_or_jlink.png) + +- 然后复位开发板,保证开发板停留在 U-Boot 界面,然后选中待调试的工程,点击 `Debug As` 启动调试 + +![](./figs/debug_as.png) + +- 启动调试后进入调试视图,默认会停在在 main 函数入口断点 + +![](./figs/debug_output.png) +- 如果启动后调试后没有显示符号表,可能是elf文件较大还在下载中,请耐心等待一会。或者是没有勾选sdkconfig中的Generate debug symbols选项,勾选之后重新编译即可 +- 在调试过程中,通过工具栏的`Step Into`、`Step Over` 和 `Continue` 等控制程序的运行 + +![](./figs/step_debug.png) + +- 通过`Variables`、`Breakpoints` 和 `Expressions` 等窗口进行调试观察 + +![](./figs/debug_info.png) + +![](./figs/breakpoints.png) + +- 通过 Windows > Show View > Disassembly 查看反汇编信息 + +![](./figs/disassembly.png) + +- 通过 Windows > Show View > Register 查看实时寄存器信息 + +![](./figs/registers.png) + +> 选择 Number Format > Hex 可以显示16进制的寄存器值 + +- 通过 Windows > Show View > Memory 查看运行实时内存 + +![](./figs/memory.png) +### 1.10 无工程调试 +PhyStudio支持无工程调试,顾名思义也就是在没有创建工程的情况下进行调试,这主要是针对只想使用PhyStudio调试功能的用户,用户选择一个外部的elf文件,然后导入PhyStudio进行调试 +#### 1.10.1 创建调试配置 +- 点击工具栏的调试菜单下拉箭头->Debug Configurations.. + +![](./figs/add_noproj_debugconfig.png) + +- 在弹出的对话框中双击Phytium GDB OpenOCD No-Proj Debugging选项创建一个新的调试配置,输入名字,选择Aarch类型,然后选择需要调试的elf文件,在Debugger页签选择好调试接口类型后点击Debug按钮进行调试 + +![](./figs/edit_noproj_debugconfig.png) +#### 1.10.2 配置源码 +- 无工程调试启动后默认是没有关联源码的,需要手动添加,先从①处复制elf文件编译路径->点击Edit Source Lookup Path,按照下图所示步骤添加源码路径映射,把编译所在的源码路径和本机所在的源码路径关联起来,完成后就可以查看源码了,调试方式跟有工程调试一样 + +![](./figs/noproj_debug_source.png) +![](./figs/noproj_debug.png) + +### 1.11 Git版本控制 +- PhyStudio加入了EGit插件,支持git版本控制,具体使用方法参照官方文档[EGit用户指导](https://wiki.eclipse.org/EGit/User_Guide "EGit用户指导"),这里介绍一些基本的用法 +#### 1.11.1 从远程仓库克隆 +- 点击右上角的按钮,切换到Git透视图,如下图所示,或者点击菜单栏的Window->Show View->Other..->Git->Git Repositories + +![](./figs/git_perspective.png) + +- 在Git视图中点击克隆远程仓库的按钮,输入仓库地址,输入用户名和密码,点击Next按钮 + +![](./figs/gitclone_repository.png) + +- 选择需要克隆的分支,然后点击Next按钮 + +![](./figs/gitclone_branch.png) + +- 选择目录,然后点击Finish按钮,等待克隆完成之后会在Git视图中显示 + +![](./figs/gitclone_finish.png) +![](./figs/gitview.png) + +#### 1.11.2 创建一个新的Git仓库 +- 在Git视图中点击创建Git新仓库按钮,选择仓库目录,点击`Create`按钮 + +![](./figs/gitrepos_create.png) + +- 创建完之后关联远程仓库,在仓库的Remotes节点上面右键点击`Create Remote..`按钮,然后在弹出的对话框中点击`Create`按钮 + +![](./figs/git_createremote.png) + +- 点击左侧的`Change..`按钮,在右侧输入仓库地址和用户名密码,点击`Finish`按钮,然后点击左侧的`Save`按钮 + +![](./figs/git_addurl.png) + +- 添加完成后在仓库下就能看见远程仓库,如果没有显示就点击一下Git视图的刷新按钮 + +![](./figs/git_remotes.png) + +#### 1.11.3 把代码推送到远程仓库 + +- 如果代码还没有加入到git仓库里面,需要右键点击工程->Team->Share Project.. + +![](./figs/git_shareproj.png) + +- 选择一个已有的仓库或者新建一个仓库然后选择,点击`Finish`按钮,此时工程代码已经被添加到了代码库。注意:如果代码已经添加到仓库了,直接忽略添加的步骤。 + +![](./figs/git_reposselect.png) + +- 右键选择工程->Team->Commit,把要提交的内容从Unstaged Changes加入到Staged Changes中去,然后输入提交信息,最后点击`Commit`按钮 + +![](./figs/git_commit.png) + +- 右键选择工程->Team->Push Branch 'master',在弹出的对话框中点击`Push`按钮进行推送。 +> 注意: 如果推送失败,有可能是远程分支上面的提交没有同步,此时可能需要fetch、pull或是merge之后才能进行推送 + +![](./figs/git_push.png) +![](./figs/git_pushresult.png) + + +### 1.12 开发技巧 +#### 1.12.1 常用快捷键 + Alt+/ 代码提示 + F3或者Ctrl+鼠标左键 查看定义或声明 + F4 查看继承关系 + Ctrl+Alt+H 选中函数,查看调用关系 + Ctrl+Shift+G 查看所有引用 + Ctrl+Shift+F 格式化代码(可能和其他应用的快捷键冲突) + Ctrl+H 全局搜索 + Ctrl+D 删除当前行 + Ctrl+Alt+ ↓或↑ 向下或者向上复制 + Ctrl+/ 注释当前行, 再按则取消注释 + Ctrl+Shift+/ 块注释 + Ctrl+Shift+\ 取消块注释 + Alt+ ←或→ 光标定位到前一个或者后一个位置 + Ctrl+Q 定位到最后编辑的地方 + Ctrl+K 参照选中的 Word 快速定位到下一个 + Ctrl+L 定位到某行 + Shift+Enter 在当前行的下一行插入空行 + diff --git a/docs/reference/ide/pic/breakpoint.png b/docs/reference/ide/pic/breakpoint.png new file mode 100644 index 0000000000000000000000000000000000000000..68c557c63bc4183360b99d009beb71c8f0b92e97 Binary files /dev/null and b/docs/reference/ide/pic/breakpoint.png differ diff --git a/docs/reference/ide/pic/console.png b/docs/reference/ide/pic/console.png new file mode 100644 index 0000000000000000000000000000000000000000..18593001d322b9ec06e6280c6e8ed3c8aa0ba65b Binary files /dev/null and b/docs/reference/ide/pic/console.png differ diff --git a/docs/reference/ide/pic/debugger.png b/docs/reference/ide/pic/debugger.png new file mode 100644 index 0000000000000000000000000000000000000000..0e684a911cb085f6ac7dceb27c5541e14c99e194 Binary files /dev/null and b/docs/reference/ide/pic/debugger.png differ diff --git a/docs/reference/ide/pic/executables.png b/docs/reference/ide/pic/executables.png new file mode 100644 index 0000000000000000000000000000000000000000..d4b69a36c59f2bf84656d3bb27898f2c501fd97c Binary files /dev/null and b/docs/reference/ide/pic/executables.png differ diff --git a/docs/reference/ide/pic/memory.png b/docs/reference/ide/pic/memory.png new file mode 100644 index 0000000000000000000000000000000000000000..36e04916d41a855abd6737f11e622bb47f044a5f Binary files /dev/null and b/docs/reference/ide/pic/memory.png differ diff --git a/docs/reference/ide/pic/pic.png b/docs/reference/ide/pic/pic.png new file mode 100644 index 0000000000000000000000000000000000000000..0613c26482891bcd57326de786961cd60a755625 Binary files /dev/null and b/docs/reference/ide/pic/pic.png differ diff --git a/docs/reference/ide/pic/pic1.png b/docs/reference/ide/pic/pic1.png new file mode 100644 index 0000000000000000000000000000000000000000..266b118083ed02b6057267e12cc9be2c515c880c Binary files /dev/null and b/docs/reference/ide/pic/pic1.png differ diff --git a/docs/reference/ide/pic/pic10.png b/docs/reference/ide/pic/pic10.png new file mode 100644 index 0000000000000000000000000000000000000000..aa6fbcab40828c3af4b8b0f69e242df27423f37c Binary files /dev/null and b/docs/reference/ide/pic/pic10.png differ diff --git a/docs/reference/ide/pic/pic11.png b/docs/reference/ide/pic/pic11.png new file mode 100644 index 0000000000000000000000000000000000000000..98800eb900d3f34f99ff9092c8ef3307cb09d888 Binary files /dev/null and b/docs/reference/ide/pic/pic11.png differ diff --git a/docs/reference/ide/pic/pic12.png b/docs/reference/ide/pic/pic12.png new file mode 100644 index 0000000000000000000000000000000000000000..1f25f175599710307165ff5d44d7b55e8e7d62ea Binary files /dev/null and b/docs/reference/ide/pic/pic12.png differ diff --git a/docs/reference/ide/pic/pic13.png b/docs/reference/ide/pic/pic13.png new file mode 100644 index 0000000000000000000000000000000000000000..6abf8ef8baf20cb70312a33134d950b19290ee44 Binary files /dev/null and b/docs/reference/ide/pic/pic13.png differ diff --git a/docs/reference/ide/pic/pic2.png b/docs/reference/ide/pic/pic2.png new file mode 100644 index 0000000000000000000000000000000000000000..df27eeefb36189f33eb6ea854cc7c4254e8fda6c Binary files /dev/null and b/docs/reference/ide/pic/pic2.png differ diff --git a/docs/reference/ide/pic/pic3.png b/docs/reference/ide/pic/pic3.png new file mode 100644 index 0000000000000000000000000000000000000000..c7f58b103bf4aa8839569e055f375b228d296ad6 Binary files /dev/null and b/docs/reference/ide/pic/pic3.png differ diff --git a/docs/reference/ide/pic/pic4.png b/docs/reference/ide/pic/pic4.png new file mode 100644 index 0000000000000000000000000000000000000000..43b6956c9dafae25289a2b7b344ffdd6519c8a86 Binary files /dev/null and b/docs/reference/ide/pic/pic4.png differ diff --git a/docs/reference/ide/pic/pic5.png b/docs/reference/ide/pic/pic5.png new file mode 100644 index 0000000000000000000000000000000000000000..81a5ca5eb373944f67e29c75f319be3185e79a3c Binary files /dev/null and b/docs/reference/ide/pic/pic5.png differ diff --git a/docs/reference/ide/pic/pic6.png b/docs/reference/ide/pic/pic6.png new file mode 100644 index 0000000000000000000000000000000000000000..e80aa5b56348d679a3fa427c428964f5e9d114c5 Binary files /dev/null and b/docs/reference/ide/pic/pic6.png differ diff --git a/docs/reference/ide/pic/pic7.png b/docs/reference/ide/pic/pic7.png new file mode 100644 index 0000000000000000000000000000000000000000..4b13da36f57a4b186e3aaf7710672bc71a1aa4ec Binary files /dev/null and b/docs/reference/ide/pic/pic7.png differ diff --git a/docs/reference/ide/pic/pic8.png b/docs/reference/ide/pic/pic8.png new file mode 100644 index 0000000000000000000000000000000000000000..7f796339aa69bf1d265e0d6f95aa0d8ba477d391 Binary files /dev/null and b/docs/reference/ide/pic/pic8.png differ diff --git a/docs/reference/ide/pic/pic9.png b/docs/reference/ide/pic/pic9.png new file mode 100644 index 0000000000000000000000000000000000000000..db91cc81d05c51704664b6c7bce39b07aefe2eee Binary files /dev/null and b/docs/reference/ide/pic/pic9.png differ diff --git a/docs/reference/ide/pic/problems.png b/docs/reference/ide/pic/problems.png new file mode 100644 index 0000000000000000000000000000000000000000..7438fb31b0b88eb627997efed86bb8f82e04b1c5 Binary files /dev/null and b/docs/reference/ide/pic/problems.png differ diff --git a/docs/reference/ide/pic/registers.png b/docs/reference/ide/pic/registers.png new file mode 100644 index 0000000000000000000000000000000000000000..e7fe508d3c118b546794907bd391f84a317b3159 Binary files /dev/null and b/docs/reference/ide/pic/registers.png differ diff --git a/docs/reference/ide/pic/terminal.png b/docs/reference/ide/pic/terminal.png new file mode 100644 index 0000000000000000000000000000000000000000..8934c0619185621a30fd1d1df9c284ebb2c5e923 Binary files /dev/null and b/docs/reference/ide/pic/terminal.png differ diff --git a/docs/reference/ide/pic/variables.png b/docs/reference/ide/pic/variables.png new file mode 100644 index 0000000000000000000000000000000000000000..061314873ea3c8560adc5fad3c6abbee79c44b7a Binary files /dev/null and b/docs/reference/ide/pic/variables.png differ diff --git a/drivers/i2c/fi2c_os.c b/drivers/i2c/fi2c_os.c index 35ae91d89ee2791201d0f68953f8af4b8d2f0b43..6da44ac5afb89926c43049fd010548ec97c6fca9 100644 --- a/drivers/i2c/fi2c_os.c +++ b/drivers/i2c/fi2c_os.c @@ -99,8 +99,6 @@ FFreeRTOSI2c *FFreeRTOSI2cInit(u32 instance_id, u32 work_mode, u32 slave_address const FMioConfig *mio_config_p ; FMioCtrl pctrl; - /*获取任意I2C控制器默认配置,作为MIO复用为I2C默认配置*/ - i2c_config = *FI2cLookupConfig(0); mio_config_p = FMioLookupConfig(instance_id); if (NULL == mio_config_p) @@ -119,13 +117,12 @@ FFreeRTOSI2c *FFreeRTOSI2cInit(u32 instance_id, u32 work_mode, u32 slave_address } /* Modify configuration */ - i2c_config.work_mode = work_mode; - i2c_config.slave_addr = slave_address; - i2c_config.speed_rate = speed_rate; + i2c_config.use_7bit_addr = TRUE; + i2c_config.irq_prority = 0; i2c_config.instance_id = pctrl.config.instance_id; i2c_config.base_addr = pctrl.config.func_base_addr; i2c_config.irq_num = pctrl.config.irq_num; - + i2c_config.ref_clk_hz = FMIO_CLK_FREQ_HZ; if (work_mode == FI2C_MASTER)/* 主机中断优先级高于从机接收 */ { i2c_config.irq_prority = I2C_MASTER_IRQ_PRORITY; @@ -141,6 +138,20 @@ FFreeRTOSI2c *FFreeRTOSI2cInit(u32 instance_id, u32 work_mode, u32 slave_address vPrintf("I2c Init failed.\r\n"); return NULL; } + /*set the i2c parameters */ + err = FI2cSetAddress(&os_i2c[instance_id].i2c_device, work_mode, slave_address); + if (FREERTOS_I2C_SUCCESS != err) + { + vPrintf("set mio slave parameters failed, ret: 0x%x\r\n", err); + return NULL; + } + err = FI2cSetSpeed(&os_i2c[instance_id].i2c_device, speed_rate, TRUE); + if (FREERTOS_I2C_SUCCESS != err) + { + vPrintf("set mio slave parameters failed, ret: 0x%x\r\n", err); + return NULL; + } + /* 从机模式,开中断接收数据 */ if (work_mode == FI2C_SLAVE) { diff --git a/drivers/qspi/fqspi/fqspi_os.c b/drivers/qspi/fqspi/fqspi_os.c index fcaaf64b1994c2329070aed080c918d4da7ed790..65d6439967d606ba28a8fa384a7859827d132e50 100644 --- a/drivers/qspi/fqspi/fqspi_os.c +++ b/drivers/qspi/fqspi/fqspi_os.c @@ -126,8 +126,18 @@ FError FFreeRTOSQspiTransfer(FFreeRTOSQspi *os_qspi_p, FFreeRTOSQspiMessage *mes { if (NULL != write_buf) { - /* write norflash data */ - ret = FQspiFlashWriteData(pctrl, cmd, flash_addr, write_buf, length); + /* read norflash data */ + if (pctrl->wr_cfg.wr_cmd != cmd) + { + ret |= FQspiFlashWriteDataConfig(pctrl, cmd); + if (FQSPI_SUCCESS != ret) + { + FQSPI_ERROR("Qspi write config failed."); + goto transfer_exit; + } + } + + ret = FQspiFlashWriteData(pctrl, flash_addr, write_buf, length); if (FQSPI_SUCCESS != ret) { FQSPI_ERROR("Qspi failed to write mem, result 0x%x", ret); diff --git a/drivers/spi/fspim/fspim_os.c b/drivers/spi/fspim/fspim_os.c index 352f8762407ef4d1b45187ebd9269184b2f1eb4b..6349a33f05ca2540e72ad0b27a41360b28f090e2 100644 --- a/drivers/spi/fspim/fspim_os.c +++ b/drivers/spi/fspim/fspim_os.c @@ -162,7 +162,7 @@ FFreeRTOSSpim *FFreeRTOSSpimInit(u32 id, const FFreeRTOSSpimConifg *input_config config.en_test = instance->config.inner_loopback; config.en_dma = instance->config.en_dma; config.irq_prority = FFREERTOS_SPIM_IRQ_PRIORITY; - config.freq_hz = FSPIM_OS_MAX_SPEED; + config.sclk_hz = FSPIM_OS_MAX_SPEED; FIOMuxInit(); FIOPadSetSpimMux(id); diff --git a/drivers/wdt/fwdt_os.c b/drivers/wdt/fwdt_os.c index 38adae4db9949f0412fe7371ff112f81f1725352..b81f619a8d148b3070f35266c19370b32a3b3f28 100644 --- a/drivers/wdt/fwdt_os.c +++ b/drivers/wdt/fwdt_os.c @@ -115,10 +115,6 @@ FError FFreeRTOSWdtControl(FFreeRTOSWdt *os_wdt_p, int cmd, void *args) case FREERTOS_WDT_CTRL_SET_TIMEOUT: os_wdt_p->timeout_value = *((u32 *)args); - if (os_wdt_p->timeout_value >= FWDT_MAX_TIMEOUT) - { - goto control_exit; - } ret = FWdtSetTimeout(pctrl, os_wdt_p->timeout_value); if (FWDT_SUCCESS != ret) { diff --git a/drivers/wdt/fwdt_os.h b/drivers/wdt/fwdt_os.h index 9f2bf0eec83525d6fa78bb2f7542a74fc27dfd67..08f55c20980724ba4e9b545b4e1ec8dd8f29fbd5 100644 --- a/drivers/wdt/fwdt_os.h +++ b/drivers/wdt/fwdt_os.h @@ -43,8 +43,8 @@ extern "C" /* freertos wdt interrupt priority */ #define FREERTOS_WDT_IRQ_PRIORITY IRQ_PRIORITY_VALUE_12 -#define FREERTOS_WDT_CTRL_GET_TIMEOUT (1) /* get timeout(in seconds) */ -#define FREERTOS_WDT_CTRL_SET_TIMEOUT (2) /* set timeout(in seconds) */ +#define FREERTOS_WDT_CTRL_GET_TIMEOUT (1) /* get timeout value in ticks */ +#define FREERTOS_WDT_CTRL_SET_TIMEOUT (2) /* set timeout value in ticks */ #define FREERTOS_WDT_CTRL_KEEPALIVE (4) /* refresh watchdog */ #define FREERTOS_WDT_CTRL_START (5) /* start watchdog */ diff --git a/example/peripheral/i2c/src/i2c_ms_example.c b/example/peripheral/i2c/src/i2c_ms_example.c index 63d3fdf7ffe898a6bccc05ea11121eb6a2858851..2b614e33a9f38e047b684755a82bd7e52af81a65 100644 --- a/example/peripheral/i2c/src/i2c_ms_example.c +++ b/example/peripheral/i2c/src/i2c_ms_example.c @@ -423,16 +423,15 @@ static void FFreeRTOSI2cLoopbackTask(void *pvParameters) BaseType_t xReturn = pdPASS; int task_res = I2C_MS_TEST_SUCCESS; FIOMuxInit(); - - ret = FFreeRTOSI2cInitSet(I2C_MS_TEST_MASTER_DEVICE, FI2C_MASTER, MASTER_SLAVE_ADDR); + ret = FFreeRTOSI2cInitSet(I2C_MS_TEST_SLAVE_DEVICE, FI2C_SLAVE, MASTER_SLAVE_ADDR); if (ret != FREERTOS_I2C_SUCCESS) { FI2C_ERROR("I2c FFreeRTOSI2cInitSet failed.\r\n"); task_res = I2C_MS_SET_FAILURE; goto task_exit; } - - ret = FFreeRTOSI2cInitSet(I2C_MS_TEST_SLAVE_DEVICE, FI2C_SLAVE, MASTER_SLAVE_ADDR); + + ret = FFreeRTOSI2cInitSet(I2C_MS_TEST_MASTER_DEVICE, FI2C_MASTER, MASTER_SLAVE_ADDR); if (ret != FREERTOS_I2C_SUCCESS) { FI2C_ERROR("I2c FFreeRTOSI2cInitSet failed.\r\n"); diff --git a/example/peripheral/media/lvgl_demo/main.c b/example/peripheral/media/lvgl_demo/main.c index fcada8ae1f17eb2651d964217a45ec8e9c57721b..78be7ed04974dc28796a7191a2579f2da2273211 100644 --- a/example/peripheral/media/lvgl_demo/main.c +++ b/example/peripheral/media/lvgl_demo/main.c @@ -23,15 +23,21 @@ * 1.1 Wangzq 2023/03/03 Add the multi-display config */ +#ifdef CONFIG_USE_LETTER_SHELL #include "shell.h" #include "shell_port.h" +#endif #include +#include "FreeRTOS.h" +#include "task.h" int main(void) { BaseType_t ret; +#ifdef CONFIG_USE_LETTER_SHELL ret = LSUserShellTask(); +#endif if (ret != pdPASS) { goto FAIL_EXIT; diff --git a/example/peripheral/media/lvgl_demo/sdkconfig b/example/peripheral/media/lvgl_demo/sdkconfig index 7342ecf51b4fe30ee4f493055b58d37c8efc3e6c..3bba792e141715a08fe645f72fafc584c01e5808 100644 --- a/example/peripheral/media/lvgl_demo/sdkconfig +++ b/example/peripheral/media/lvgl_demo/sdkconfig @@ -47,6 +47,7 @@ CONFIG_TARGET_PHYTIUMPI=y # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set # CONFIG_TARGET_PD2308 is not set +# CONFIG_TARGET_QEMU_VIRT is not set CONFIG_SOC_NAME="phytiumpi" CONFIG_SOC_CORE_NUM=4 CONFIG_F32BIT_MEMORY_ADDRESS=0x80000000 @@ -104,6 +105,7 @@ CONFIG_LOG_DEBUG=y CONFIG_USE_DEFAULT_INTERRUPT_CONFIG=y CONFIG_INTERRUPT_ROLE_MASTER=y # CONFIG_INTERRUPT_ROLE_SLAVE is not set +# CONFIG_INTERRUPT_ROLE_NONE is not set # end of Sdk common configuration # @@ -200,7 +202,7 @@ CONFIG_USE_COMPILE_CHAIN=y CONFIG_DEFAULT_LINKER_SCRIPT=y # CONFIG_USER_DEFINED_LD is not set CONFIG_IMAGE_LOAD_ADDRESS=0x80100000 -CONFIG_IMAGE_MAX_LENGTH=0x200000000 +CONFIG_IMAGE_MAX_LENGTH=0x1000000 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x400 # end of Linker Options @@ -301,17 +303,7 @@ CONFIG_FREERTOS_USE_MEDIA=y # Third-party configuration # # CONFIG_USE_LWIP is not set -CONFIG_USE_LETTER_SHELL=y - -# -# Letter Shell Configuration -# -CONFIG_LS_PL011_UART=y -CONFIG_DEFAULT_LETTER_SHELL_USE_UART1=y -# CONFIG_DEFAULT_LETTER_SHELL_USE_UART0 is not set -# CONFIG_DEFAULT_LETTER_SHELL_USE_UART2 is not set -# end of Letter Shell Configuration - +# CONFIG_USE_LETTER_SHELL is not set # CONFIG_USE_AMP is not set # CONFIG_USE_YMODEM is not set # CONFIG_USE_SFUD is not set diff --git a/example/peripheral/media/lvgl_demo/sdkconfig.h b/example/peripheral/media/lvgl_demo/sdkconfig.h index 28e899355822342737f3003ba49d4edfa1260ac0..641ae46c593d5c54e4b0041e6b782db739c265a2 100644 --- a/example/peripheral/media/lvgl_demo/sdkconfig.h +++ b/example/peripheral/media/lvgl_demo/sdkconfig.h @@ -44,6 +44,7 @@ /* CONFIG_TARGET_FT2004 is not set */ /* CONFIG_TARGET_D2000 is not set */ /* CONFIG_TARGET_PD2308 is not set */ +/* CONFIG_TARGET_QEMU_VIRT is not set */ #define CONFIG_SOC_NAME "phytiumpi" #define CONFIG_SOC_CORE_NUM 4 #define CONFIG_F32BIT_MEMORY_ADDRESS 0x80000000 @@ -96,6 +97,7 @@ #define CONFIG_USE_DEFAULT_INTERRUPT_CONFIG #define CONFIG_INTERRUPT_ROLE_MASTER /* CONFIG_INTERRUPT_ROLE_SLAVE is not set */ +/* CONFIG_INTERRUPT_ROLE_NONE is not set */ /* end of Sdk common configuration */ /* Drivers configuration */ @@ -181,7 +183,7 @@ #define CONFIG_DEFAULT_LINKER_SCRIPT /* CONFIG_USER_DEFINED_LD is not set */ #define CONFIG_IMAGE_LOAD_ADDRESS 0x80100000 -#define CONFIG_IMAGE_MAX_LENGTH 0x200000000 +#define CONFIG_IMAGE_MAX_LENGTH 0x1000000 #define CONFIG_HEAP_SIZE 1 #define CONFIG_STACK_SIZE 0x400 /* end of Linker Options */ @@ -265,15 +267,7 @@ /* Third-party configuration */ /* CONFIG_USE_LWIP is not set */ -#define CONFIG_USE_LETTER_SHELL - -/* Letter Shell Configuration */ - -#define CONFIG_LS_PL011_UART -#define CONFIG_DEFAULT_LETTER_SHELL_USE_UART1 -/* CONFIG_DEFAULT_LETTER_SHELL_USE_UART0 is not set */ -/* CONFIG_DEFAULT_LETTER_SHELL_USE_UART2 is not set */ -/* end of Letter Shell Configuration */ +/* CONFIG_USE_LETTER_SHELL is not set */ /* CONFIG_USE_AMP is not set */ /* CONFIG_USE_YMODEM is not set */ /* CONFIG_USE_SFUD is not set */ diff --git a/example/peripheral/media/lvgl_demo/src/cmd.c b/example/peripheral/media/lvgl_demo/src/cmd.c index 42d7358991538197e8e800bff7cc828193e440b4..34264da1e88dbe5e4c411a1446628b3edc171474 100644 --- a/example/peripheral/media/lvgl_demo/src/cmd.c +++ b/example/peripheral/media/lvgl_demo/src/cmd.c @@ -27,7 +27,9 @@ #include "strto.h" #include "sdkconfig.h" #include "FreeRTOS.h" -#include "../src/shell.h" +#ifdef CONFIG_USE_LETTER_SHELL +#include "shell.h" +#include "shell_port.h" #include "lv_demo_create.h" @@ -110,4 +112,5 @@ static int MediaCmdEntry(int argc, char *argv[]) return 0; } -SHELL_EXPORT_CMD((SHELL_TYPE_CMD_MAIN), Media, MediaCmdEntry, test media driver); \ No newline at end of file +SHELL_EXPORT_CMD((SHELL_TYPE_CMD_MAIN), Media, MediaCmdEntry, test media driver); +#endif \ No newline at end of file diff --git a/example/peripheral/media/lvgl_indev/main.c b/example/peripheral/media/lvgl_indev/main.c index fcada8ae1f17eb2651d964217a45ec8e9c57721b..0de4482c922791f55c9d90a50de94fd1918a4568 100644 --- a/example/peripheral/media/lvgl_indev/main.c +++ b/example/peripheral/media/lvgl_indev/main.c @@ -23,15 +23,20 @@ * 1.1 Wangzq 2023/03/03 Add the multi-display config */ +#ifdef CONFIG_USE_LETTER_SHELL #include "shell.h" #include "shell_port.h" +#endif #include +#include "FreeRTOS.h" +#include "task.h" int main(void) { BaseType_t ret; - +#ifdef CONFIG_USE_LETTER_SHELL ret = LSUserShellTask(); +#endif if (ret != pdPASS) { goto FAIL_EXIT; diff --git a/example/peripheral/media/lvgl_indev/sdkconfig b/example/peripheral/media/lvgl_indev/sdkconfig index 0844bbec2ae7bbabb207aedaaf45471e0e3a676a..6c6e79c1f09c303349e91d218a7364e0e4c4b276 100644 --- a/example/peripheral/media/lvgl_indev/sdkconfig +++ b/example/peripheral/media/lvgl_indev/sdkconfig @@ -47,6 +47,7 @@ CONFIG_TARGET_PHYTIUMPI=y # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set # CONFIG_TARGET_PD2308 is not set +# CONFIG_TARGET_QEMU_VIRT is not set CONFIG_SOC_NAME="phytiumpi" CONFIG_SOC_CORE_NUM=4 CONFIG_F32BIT_MEMORY_ADDRESS=0x80000000 @@ -104,6 +105,7 @@ CONFIG_LOG_DEBUG=y CONFIG_USE_DEFAULT_INTERRUPT_CONFIG=y CONFIG_INTERRUPT_ROLE_MASTER=y # CONFIG_INTERRUPT_ROLE_SLAVE is not set +# CONFIG_INTERRUPT_ROLE_NONE is not set # end of Sdk common configuration # @@ -301,17 +303,7 @@ CONFIG_FREERTOS_USE_MEDIA=y # Third-party configuration # # CONFIG_USE_LWIP is not set -CONFIG_USE_LETTER_SHELL=y - -# -# Letter Shell Configuration -# -CONFIG_LS_PL011_UART=y -CONFIG_DEFAULT_LETTER_SHELL_USE_UART1=y -# CONFIG_DEFAULT_LETTER_SHELL_USE_UART0 is not set -# CONFIG_DEFAULT_LETTER_SHELL_USE_UART2 is not set -# end of Letter Shell Configuration - +# CONFIG_USE_LETTER_SHELL is not set # CONFIG_USE_AMP is not set # CONFIG_USE_YMODEM is not set # CONFIG_USE_SFUD is not set diff --git a/example/peripheral/media/lvgl_indev/sdkconfig.h b/example/peripheral/media/lvgl_indev/sdkconfig.h index 658696135f303564d66be098fade655571e3e883..45ed91c254889d1260374f9713a1a00f52491523 100644 --- a/example/peripheral/media/lvgl_indev/sdkconfig.h +++ b/example/peripheral/media/lvgl_indev/sdkconfig.h @@ -44,6 +44,7 @@ /* CONFIG_TARGET_FT2004 is not set */ /* CONFIG_TARGET_D2000 is not set */ /* CONFIG_TARGET_PD2308 is not set */ +/* CONFIG_TARGET_QEMU_VIRT is not set */ #define CONFIG_SOC_NAME "phytiumpi" #define CONFIG_SOC_CORE_NUM 4 #define CONFIG_F32BIT_MEMORY_ADDRESS 0x80000000 @@ -96,6 +97,7 @@ #define CONFIG_USE_DEFAULT_INTERRUPT_CONFIG #define CONFIG_INTERRUPT_ROLE_MASTER /* CONFIG_INTERRUPT_ROLE_SLAVE is not set */ +/* CONFIG_INTERRUPT_ROLE_NONE is not set */ /* end of Sdk common configuration */ /* Drivers configuration */ @@ -265,15 +267,7 @@ /* Third-party configuration */ /* CONFIG_USE_LWIP is not set */ -#define CONFIG_USE_LETTER_SHELL - -/* Letter Shell Configuration */ - -#define CONFIG_LS_PL011_UART -#define CONFIG_DEFAULT_LETTER_SHELL_USE_UART1 -/* CONFIG_DEFAULT_LETTER_SHELL_USE_UART0 is not set */ -/* CONFIG_DEFAULT_LETTER_SHELL_USE_UART2 is not set */ -/* end of Letter Shell Configuration */ +/* CONFIG_USE_LETTER_SHELL is not set */ /* CONFIG_USE_AMP is not set */ /* CONFIG_USE_YMODEM is not set */ /* CONFIG_USE_SFUD is not set */ diff --git a/example/peripheral/media/lvgl_indev/src/cmd.c b/example/peripheral/media/lvgl_indev/src/cmd.c index 804a4bb48e88a54b94d135947d84477b3b589886..2b90e87e10e47de154aea714846854c6a8147518 100644 --- a/example/peripheral/media/lvgl_indev/src/cmd.c +++ b/example/peripheral/media/lvgl_indev/src/cmd.c @@ -27,7 +27,9 @@ #include "strto.h" #include "sdkconfig.h" #include "FreeRTOS.h" -#include "../src/shell.h" +#ifdef CONFIG_USE_LETTER_SHELL +#include "shell.h" +#include "shell_port.h" #include "fdc_common_hw.h" #include "fdcdp.h" @@ -167,4 +169,5 @@ static int MediaCmdEntry(int argc, char *argv[]) } -SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), Media, MediaCmdEntry, test freertos media driver); \ No newline at end of file +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), Media, MediaCmdEntry, test freertos media driver); +#endif \ No newline at end of file diff --git a/example/peripheral/media/lvgl_indev/src/lv_indev_port.c b/example/peripheral/media/lvgl_indev/src/lv_indev_port.c index b67975094e015fe487345833d86af993d6cd457c..bdf9eb4d42ef79754f8f139d80d7541edff7f011 100644 --- a/example/peripheral/media/lvgl_indev/src/lv_indev_port.c +++ b/example/peripheral/media/lvgl_indev/src/lv_indev_port.c @@ -154,7 +154,6 @@ static u8 const keycode2ascii[128][2] = { HID_KEYCODE_TO_ASCII }; static struct usbh_urb kbd_intin_urb; static uint8_t kbd_buffer[128] __attribute__((aligned(sizeof(unsigned long)))) = {0}; static struct usb_osal_timer *kbd_timer = NULL; -static QueueHandle_t xQueue = NULL; static char *keyborad_name = "/dev/input0"; static char *mouse_name = "/dev/input2"; diff --git a/example/peripheral/media/lvgl_ui/main.c b/example/peripheral/media/lvgl_ui/main.c index fcada8ae1f17eb2651d964217a45ec8e9c57721b..78be7ed04974dc28796a7191a2579f2da2273211 100644 --- a/example/peripheral/media/lvgl_ui/main.c +++ b/example/peripheral/media/lvgl_ui/main.c @@ -23,15 +23,21 @@ * 1.1 Wangzq 2023/03/03 Add the multi-display config */ +#ifdef CONFIG_USE_LETTER_SHELL #include "shell.h" #include "shell_port.h" +#endif #include +#include "FreeRTOS.h" +#include "task.h" int main(void) { BaseType_t ret; +#ifdef CONFIG_USE_LETTER_SHELL ret = LSUserShellTask(); +#endif if (ret != pdPASS) { goto FAIL_EXIT; diff --git a/example/peripheral/media/lvgl_ui/src/cmd.c b/example/peripheral/media/lvgl_ui/src/cmd.c index 804a4bb48e88a54b94d135947d84477b3b589886..2b90e87e10e47de154aea714846854c6a8147518 100644 --- a/example/peripheral/media/lvgl_ui/src/cmd.c +++ b/example/peripheral/media/lvgl_ui/src/cmd.c @@ -27,7 +27,9 @@ #include "strto.h" #include "sdkconfig.h" #include "FreeRTOS.h" -#include "../src/shell.h" +#ifdef CONFIG_USE_LETTER_SHELL +#include "shell.h" +#include "shell_port.h" #include "fdc_common_hw.h" #include "fdcdp.h" @@ -167,4 +169,5 @@ static int MediaCmdEntry(int argc, char *argv[]) } -SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), Media, MediaCmdEntry, test freertos media driver); \ No newline at end of file +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), Media, MediaCmdEntry, test freertos media driver); +#endif \ No newline at end of file diff --git a/example/peripheral/media/lvgl_ui/src/lv_indev_port.c b/example/peripheral/media/lvgl_ui/src/lv_indev_port.c index b67975094e015fe487345833d86af993d6cd457c..bdf9eb4d42ef79754f8f139d80d7541edff7f011 100644 --- a/example/peripheral/media/lvgl_ui/src/lv_indev_port.c +++ b/example/peripheral/media/lvgl_ui/src/lv_indev_port.c @@ -154,7 +154,6 @@ static u8 const keycode2ascii[128][2] = { HID_KEYCODE_TO_ASCII }; static struct usbh_urb kbd_intin_urb; static uint8_t kbd_buffer[128] __attribute__((aligned(sizeof(unsigned long)))) = {0}; static struct usb_osal_timer *kbd_timer = NULL; -static QueueHandle_t xQueue = NULL; static char *keyborad_name = "/dev/input0"; static char *mouse_name = "/dev/input2"; diff --git a/example/peripheral/media/lvgl_ui/src/lv_ui.c b/example/peripheral/media/lvgl_ui/src/lv_ui.c index 590c55799b7fa691aa514ac921121ca81e49de33..0fd893dc00439b33a66fc8ac48d29c1ac44e793f 100644 --- a/example/peripheral/media/lvgl_ui/src/lv_ui.c +++ b/example/peripheral/media/lvgl_ui/src/lv_ui.c @@ -24,7 +24,12 @@ #include "lv_ui.h" #include "lv_ui_helpers.h" -void ui_screen_screen_init(lv_obj_t *parent); +#ifdef CONFIG_USE_LETTER_SHELL +#include "shell.h" +#include "shell_port.h" +#endif + +extern void ui_screen_screen_init(lv_obj_t *parent); lv_obj_t *ui_screen; lv_obj_t *ui____initial_actions0; @@ -37,6 +42,7 @@ lv_obj_t *ui____initial_actions0; static lv_obj_t *tv; + void ui_init(void) { lv_disp_t *dispp = lv_disp_get_default(); @@ -46,8 +52,9 @@ void ui_init(void) ui_screen = lv_obj_create(NULL); lv_obj_clear_flag(ui_screen, LV_OBJ_FLAG_SCROLLABLE); /// Flags - +#ifdef CONFIG_USE_LETTER_SHELL ui_screen_screen_init(ui_screen); +#endif lv_disp_load_scr(ui_screen); ui____initial_actions0 = lv_obj_create(NULL); diff --git a/example/peripheral/media/lvgl_ui/src/lv_ui_screen.c b/example/peripheral/media/lvgl_ui/src/lv_ui_screen.c index 1dc2d775eee977b864b40b548156787071268f4a..00eccded4ee730de09726009902eb8d74c432452 100644 --- a/example/peripheral/media/lvgl_ui/src/lv_ui_screen.c +++ b/example/peripheral/media/lvgl_ui/src/lv_ui_screen.c @@ -24,7 +24,8 @@ #include #include #include -#include "shell_port.h" + + #include "finterrupt.h" #include "fpl011_os.h" #include "fdebug.h" @@ -44,9 +45,12 @@ static lv_obj_t *tv; lv_obj_t *ui_text_receive_message; lv_obj_t *ui_image_logo; -extern Shell shell_object; -static char data[64]; +static char data[64]; +#ifdef CONFIG_USE_LETTER_SHELL +#include "shell.h" +#include "shell_port.h" +extern Shell shell_object; /** * @brief LVGL用户shell写 * @@ -103,6 +107,7 @@ static void text_receive_event_cb(lv_event_t *e) shellHandler(&shell_object, indev->proc.types.keypad.last_key); } } +#endif void ui_screen_screen_init(lv_obj_t *parent) { diff --git a/example/peripheral/media/media_test/main.c b/example/peripheral/media/media_test/main.c index 5042be90a173f8bf2a95ab49cf83a1e31238c6ad..64a5b4c4f512f3c77257f29c9267ad83e36fc842 100644 --- a/example/peripheral/media/media_test/main.c +++ b/example/peripheral/media/media_test/main.c @@ -22,15 +22,21 @@ * 1.0 Wangzq 2022/12/20 Modify the format and establish the version */ +#ifdef CONFIG_USE_LETTER_SHELL #include "shell.h" #include "shell_port.h" +#endif #include +#include "FreeRTOS.h" +#include "task.h" int main(void) { BaseType_t ret; - + +#ifdef CONFIG_USE_LETTER_SHELL ret = LSUserShellTask(); +#endif if (ret != pdPASS) { goto FAIL_EXIT; diff --git a/example/peripheral/media/media_test/sdkconfig b/example/peripheral/media/media_test/sdkconfig index 7ecbab110bb18aeaecf872bbbc25ec998e081e21..75aeebc773fe355a96fea4916b4beb4769cc4dd4 100644 --- a/example/peripheral/media/media_test/sdkconfig +++ b/example/peripheral/media/media_test/sdkconfig @@ -47,6 +47,7 @@ CONFIG_TARGET_PHYTIUMPI=y # CONFIG_TARGET_FT2004 is not set # CONFIG_TARGET_D2000 is not set # CONFIG_TARGET_PD2308 is not set +# CONFIG_TARGET_QEMU_VIRT is not set CONFIG_SOC_NAME="phytiumpi" CONFIG_SOC_CORE_NUM=4 CONFIG_F32BIT_MEMORY_ADDRESS=0x80000000 @@ -104,6 +105,7 @@ CONFIG_LOG_DEBUG=y CONFIG_USE_DEFAULT_INTERRUPT_CONFIG=y CONFIG_INTERRUPT_ROLE_MASTER=y # CONFIG_INTERRUPT_ROLE_SLAVE is not set +# CONFIG_INTERRUPT_ROLE_NONE is not set # end of Sdk common configuration # @@ -301,17 +303,7 @@ CONFIG_FREERTOS_USE_MEDIA=y # Third-party configuration # # CONFIG_USE_LWIP is not set -CONFIG_USE_LETTER_SHELL=y - -# -# Letter Shell Configuration -# -CONFIG_LS_PL011_UART=y -CONFIG_DEFAULT_LETTER_SHELL_USE_UART1=y -# CONFIG_DEFAULT_LETTER_SHELL_USE_UART0 is not set -# CONFIG_DEFAULT_LETTER_SHELL_USE_UART2 is not set -# end of Letter Shell Configuration - +# CONFIG_USE_LETTER_SHELL is not set # CONFIG_USE_AMP is not set # CONFIG_USE_YMODEM is not set # CONFIG_USE_SFUD is not set diff --git a/example/peripheral/media/media_test/sdkconfig.h b/example/peripheral/media/media_test/sdkconfig.h index e74ceaeb99a796d1e7b5f841a177cb8ab44b56f5..cf8454b7519f39002bfb3d7ae08ffb830239eb72 100644 --- a/example/peripheral/media/media_test/sdkconfig.h +++ b/example/peripheral/media/media_test/sdkconfig.h @@ -44,6 +44,7 @@ /* CONFIG_TARGET_FT2004 is not set */ /* CONFIG_TARGET_D2000 is not set */ /* CONFIG_TARGET_PD2308 is not set */ +/* CONFIG_TARGET_QEMU_VIRT is not set */ #define CONFIG_SOC_NAME "phytiumpi" #define CONFIG_SOC_CORE_NUM 4 #define CONFIG_F32BIT_MEMORY_ADDRESS 0x80000000 @@ -96,6 +97,7 @@ #define CONFIG_USE_DEFAULT_INTERRUPT_CONFIG #define CONFIG_INTERRUPT_ROLE_MASTER /* CONFIG_INTERRUPT_ROLE_SLAVE is not set */ +/* CONFIG_INTERRUPT_ROLE_NONE is not set */ /* end of Sdk common configuration */ /* Drivers configuration */ @@ -265,15 +267,7 @@ /* Third-party configuration */ /* CONFIG_USE_LWIP is not set */ -#define CONFIG_USE_LETTER_SHELL - -/* Letter Shell Configuration */ - -#define CONFIG_LS_PL011_UART -#define CONFIG_DEFAULT_LETTER_SHELL_USE_UART1 -/* CONFIG_DEFAULT_LETTER_SHELL_USE_UART0 is not set */ -/* CONFIG_DEFAULT_LETTER_SHELL_USE_UART2 is not set */ -/* end of Letter Shell Configuration */ +/* CONFIG_USE_LETTER_SHELL is not set */ /* CONFIG_USE_AMP is not set */ /* CONFIG_USE_YMODEM is not set */ /* CONFIG_USE_SFUD is not set */ diff --git a/example/peripheral/media/media_test/src/cmd_media.c b/example/peripheral/media/media_test/src/cmd_media.c index 54357895a3864f30acd2673951a256edaa8011d0..ffb7c2239f000fa0cbb6eb7f9ea788abd988f126 100644 --- a/example/peripheral/media/media_test/src/cmd_media.c +++ b/example/peripheral/media/media_test/src/cmd_media.c @@ -27,7 +27,9 @@ #include "sdkconfig.h" #include "FreeRTOS.h" -#include "../src/shell.h" +#ifdef CONFIG_USE_LETTER_SHELL +#include "shell.h" +#include "shell_port.h" #include "fdc_common_hw.h" #include "media_example.h" @@ -90,4 +92,5 @@ static int MediaCmdEntry(int argc, char *argv[]) return 0; } -SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), Media, MediaCmdEntry, test freertos media driver); \ No newline at end of file +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), Media, MediaCmdEntry, test freertos media driver); +#endif \ No newline at end of file diff --git a/example/peripheral/wdt/src/wdt_example.c b/example/peripheral/wdt/src/wdt_example.c index 0b7f5d6a60d74cf413549b6eb908bf13a16a3943..c61b400e9771146d3cf10c2c1d351946e7d10250 100644 --- a/example/peripheral/wdt/src/wdt_example.c +++ b/example/peripheral/wdt/src/wdt_example.c @@ -123,10 +123,11 @@ static FError WdtExampleFeed(void) { FError ret = FWDT_SUCCESS; uint32_t notify_result; - u32 wdt_timeout = WDT_ONCE_TIMEOUT; /* 为了传入地址,重新赋值 */ + u32 wdt_timeout = 0; const TickType_t max_block_time = WDT_FEED_PERIOD; /* set wdt timeout value */ + wdt_timeout = (u32)(GenericTimerFrequecy() * WDT_ONCE_TIMEOUT); ret = FFreeRTOSWdtControl(os_wdt_ctrl_p, FREERTOS_WDT_CTRL_SET_TIMEOUT, &wdt_timeout); if (ret != FWDT_SUCCESS) { diff --git a/install.py b/install.py index 50b7d8938a2b83820340da7a6766551f0a126182..ecbbfed7df423edef545a0227f86e91f3c41afaa 100755 --- a/install.py +++ b/install.py @@ -36,7 +36,7 @@ freertos_sdk_path = install_path print("Standalone SDK at {}".format(freertos_sdk_path)) # Add standalone sdk -standalone_sdk_v="2ff7883c95cd312c636c9f35903b46ae74f8749d" +standalone_sdk_v="c38dcff60bf78f1612429c3d80c3e1bc962dd462" if (install_platform == windows_x64): standalone_path=freertos_sdk_path + '\\standalone' else: diff --git a/third-party/fsl_sdmmc/osa/fsl_sdmmc_osa.c b/third-party/fsl_sdmmc/osa/fsl_sdmmc_osa.c index 803089f655ef261e797db0f719b72351978467c0..ccb5b2e539be9d701d8a7393a51ef0479baa5061 100644 --- a/third-party/fsl_sdmmc/osa/fsl_sdmmc_osa.c +++ b/third-party/fsl_sdmmc/osa/fsl_sdmmc_osa.c @@ -12,7 +12,7 @@ /******************************************************************************* * Definitons ******************************************************************************/ -#define SDMMC_MEM_BUF_SIZE SZ_1M +#define SDMMC_MEM_BUF_SIZE SZ_2M /******************************************************************************* * Prototypes ******************************************************************************/ diff --git a/third-party/fsl_wifi/port/sdio/wifi_bt_config.c b/third-party/fsl_wifi/port/sdio/wifi_bt_config.c index ff29c143ca3451a86b861b16b946a82293ccf1bb..1c6fb93e6180e281d2edac11f08c127fc2b08481 100755 --- a/third-party/fsl_wifi/port/sdio/wifi_bt_config.c +++ b/third-party/fsl_wifi/port/sdio/wifi_bt_config.c @@ -104,6 +104,8 @@ void BOARD_WIFI_BT_Config(void *host, sdio_int_t cardInt) s_inst_config.sdioCardInt = cardInt; s_inst_config.sdioCardIntArg = NULL; + /*init iomux*/ + FIOMuxInit(); FIOPadSetSdMux(s_inst_config.hostId); if (kStatus_Success != SDIO_CfgInitialize(sdio_host, &s_inst_config)) { diff --git a/third-party/include.mk b/third-party/include.mk index b96171e27efb724ecfddaf382a38c87cfbe99b57..810c17e91c9825bb9033eba15f1425aa05f7d2db 100644 --- a/third-party/include.mk +++ b/third-party/include.mk @@ -1,4 +1,3 @@ - FREERTOS_SDK_DIR ?= $(SDK_DIR)/.. ifdef CONFIG_USE_BACKTRACE @@ -11,9 +10,7 @@ endif include $(FREERTOS_SDK_DIR)/third-party/freertos/include.mk -ifdef CONFIG_USE_TLSF include $(FREERTOS_SDK_DIR)/third-party/tlsf-3.1.0/include.mk -endif ifdef CONFIG_USE_FATFS_0_1_4 include $(FREERTOS_SDK_DIR)/third-party/fatfs-0.1.4/include.mk @@ -53,4 +50,4 @@ endif ifdef CONFIG_USE_CHERRY_USB include $(SDK_DIR)/third-party/cherryusb/include.mk -endif \ No newline at end of file +endif diff --git a/third-party/thirdparty.mk b/third-party/thirdparty.mk index e879656db17c9d8da7e5dbb9345130d0503797c1..e4b0b67900d4173998c00c067906a56cb387c86c 100644 --- a/third-party/thirdparty.mk +++ b/third-party/thirdparty.mk @@ -46,7 +46,6 @@ lib_fatfs_info: BAREMETAL_LIBS+= $(BUILD_OUT_PATH)/lib_fatfs.a endif -ifdef CONFIG_USE_TLSF $(BUILD_OUT_PATH)/lib_tlsf.a: lib_tlsf.a lib_tlsf.a: $(call rtos_invoke_make_in_dir,$(FREERTOS_SDK_DIR),third-party/tlsf-3.1.0,makefile,all,) @@ -55,7 +54,6 @@ lib_tlsf_debug: lib_tlsf_info: $(call rtos_invoke_make_in_dir,$(FREERTOS_SDK_DIR),third-party/tlsf-3.1.0,makefile,compiler_info,) BAREMETAL_LIBS+= $(BUILD_OUT_PATH)/lib_tlsf.a -endif ifdef CONFIG_USE_LWIP $(BUILD_OUT_PATH)/lib_lwip.a: lib_lwip.a diff --git a/third-party/tlsf-3.1.0/include.mk b/third-party/tlsf-3.1.0/include.mk index 31c8cc6f0cd333ec3da8f5f11b55f090e2a108cf..ee2e42383c8f6d1b2438d1d94e581011a6c2765a 100644 --- a/third-party/tlsf-3.1.0/include.mk +++ b/third-party/tlsf-3.1.0/include.mk @@ -1,5 +1,8 @@ -ifdef CONFIG_USE_TLSF + +BUILD_INC_PATH_DIR += $(SDK_DIR)/third-party/tlsf-3.1.0/src + +ifdef CONFIG_USE_FREERTOS BUILD_INC_PATH_DIR += $(FREERTOS_SDK_DIR)/third-party/tlsf-3.1.0/port - BUILD_INC_PATH_DIR += $(FREERTOS_SDK_DIR)/third-party/tlsf-3.1.0/src -endif \ No newline at end of file +endif + diff --git a/third-party/tlsf-3.1.0/src.mk b/third-party/tlsf-3.1.0/src.mk index 0492054fa2c1a583a36ba9e0d15c692bd7326907..2740831cc849cfd3e9e88c05d4a83ef65dd308e5 100644 --- a/third-party/tlsf-3.1.0/src.mk +++ b/third-party/tlsf-3.1.0/src.mk @@ -1,5 +1,11 @@ -ifdef CONFIG_USE_TLSF -CSRCS_RELATIVE_FILES += $(wildcard port/*.c) -CSRCS_RELATIVE_FILES += $(wildcard src/*.c) -endif \ No newline at end of file + +TLSF_RT_C_DIR = $(abspath $(SDK_DIR)/third-party/tlsf-3.1.0/) + +ABSOLUTE_CFILES += $(wildcard $(TLSF_RT_C_DIR)/src/*.c) + +ifdef CONFIG_USE_FREERTOS + CSRCS_RELATIVE_FILES += $(wildcard port/*.c) +endif + + diff --git a/third-party/tlsf-3.1.0/src/tlsf.c b/third-party/tlsf-3.1.0/src/tlsf.c deleted file mode 100644 index 7e6dd91990824da7425a9796fde55744baf5f33d..0000000000000000000000000000000000000000 --- a/third-party/tlsf-3.1.0/src/tlsf.c +++ /dev/null @@ -1,1292 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "ftypes.h" -#include "fassert.h" -#include "tlsf.h" - -#if defined(__cplusplus) - #define tlsf_decl inline -#else - #define tlsf_decl static -#endif - -/* -** Architecture-specific bit manipulation routines. -** -** TLSF achieves O(1) cost for malloc and free operations by limiting -** the search for a free block to a free list of guaranteed size -** adequate to fulfill the request, combined with efficient free list -** queries using bitmasks and architecture-specific bit-manipulation -** routines. -** -** Most modern processors provide instructions to count leading zeroes -** in a word, find the lowest and highest set bit, etc. These -** specific implementations will be used when available, falling back -** to a reasonably efficient generic implementation. -** -** NOTE: TLSF spec relies on ffs/fls returning value 0..31. -** ffs/fls return 1-32 by default, returning 0 for error. -*/ - -/* -** Detect whether or not we are building for a 32- or 64-bit (LP/LLP) -** architecture. There is no reliable portable method at compile-time. -*/ -#if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) \ - || defined (_WIN64) || defined (__LP64__) || defined (__LLP64__) \ - || defined (__aarch64__) - #define TLSF_64BIT -#endif - -/* -** gcc 3.4 and above have builtin support, specialized for architecture. -** Some compilers masquerade as gcc; patchlevel test filters them out. -*/ -#if defined (__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) \ - && defined (__GNUC_PATCHLEVEL__) - -#if defined (__SNC__) -/* SNC for Playstation 3. */ - -tlsf_decl int tlsf_ffs(unsigned int word) -{ - const unsigned int reverse = word & (~word + 1); - const int bit = 32 - __builtin_clz(reverse); - return bit - 1; -} - -#else - -tlsf_decl int tlsf_ffs(unsigned int word) -{ - return __builtin_ffs(word) - 1; -} - -#endif - -tlsf_decl int tlsf_fls(unsigned int word) -{ - const int bit = word ? 32 - __builtin_clz(word) : 0; - return bit - 1; -} - -#elif defined (_MSC_VER) && (_MSC_VER >= 1400) && (defined (_M_IX86) || defined (_M_X64)) -/* Microsoft Visual C++ support on x86/X64 architectures. */ - -#include - -#pragma intrinsic(_BitScanReverse) -#pragma intrinsic(_BitScanForward) - -tlsf_decl int tlsf_fls(unsigned int word) -{ - unsigned long index; - return _BitScanReverse(&index, word) ? index : -1; -} - -tlsf_decl int tlsf_ffs(unsigned int word) -{ - unsigned long index; - return _BitScanForward(&index, word) ? index : -1; -} - -#elif defined (_MSC_VER) && defined (_M_PPC) -/* Microsoft Visual C++ support on PowerPC architectures. */ - -#include - -tlsf_decl int tlsf_fls(unsigned int word) -{ - const int bit = 32 - _CountLeadingZeros(word); - return bit - 1; -} - -tlsf_decl int tlsf_ffs(unsigned int word) -{ - const unsigned int reverse = word & (~word + 1); - const int bit = 32 - _CountLeadingZeros(reverse); - return bit - 1; -} - -#elif defined (__ARMCC_VERSION) -/* RealView Compilation Tools for ARM */ - -tlsf_decl int tlsf_ffs(unsigned int word) -{ - const unsigned int reverse = word & (~word + 1); - const int bit = 32 - __clz(reverse); - return bit - 1; -} - -tlsf_decl int tlsf_fls(unsigned int word) -{ - const int bit = word ? 32 - __clz(word) : 0; - return bit - 1; -} - -#elif defined (__ghs__) -/* Green Hills support for PowerPC */ - -#include - -tlsf_decl int tlsf_ffs(unsigned int word) -{ - const unsigned int reverse = word & (~word + 1); - const int bit = 32 - __CLZ32(reverse); - return bit - 1; -} - -tlsf_decl int tlsf_fls(unsigned int word) -{ - const int bit = word ? 32 - __CLZ32(word) : 0; - return bit - 1; -} - -#else -/* Fall back to generic implementation. */ - -tlsf_decl int tlsf_fls_generic(unsigned int word) -{ - int bit = 32; - - if (!word) bit -= 1; - if (!(word & 0xffff0000)) - { - word <<= 16; - bit -= 16; - } - if (!(word & 0xff000000)) - { - word <<= 8; - bit -= 8; - } - if (!(word & 0xf0000000)) - { - word <<= 4; - bit -= 4; - } - if (!(word & 0xc0000000)) - { - word <<= 2; - bit -= 2; - } - if (!(word & 0x80000000)) - { - word <<= 1; - bit -= 1; - } - - return bit; -} - -/* Implement ffs in terms of fls. */ -tlsf_decl int tlsf_ffs(unsigned int word) -{ - return tlsf_fls_generic(word & (~word + 1)) - 1; -} - -tlsf_decl int tlsf_fls(unsigned int word) -{ - return tlsf_fls_generic(word) - 1; -} - -#endif - -/* Possibly 64-bit version of tlsf_fls. */ -#if defined (TLSF_64BIT) -tlsf_decl int tlsf_fls_sizet(size_t size) -{ - int high = (int)(size >> 32); - int bits = 0; - if (high) - { - bits = 32 + tlsf_fls(high); - } - else - { - bits = tlsf_fls((int)size & 0xffffffff); - - } - return bits; -} -#else -#define tlsf_fls_sizet tlsf_fls -#endif - -#undef tlsf_decl - -/* -** Constants. -*/ - -/* Public constants: may be modified. */ -enum tlsf_public -{ - /* log2 of number of linear subdivisions of block sizes. Larger - ** values require more memory in the control structure. Values of - ** 4 or 5 are typical. - */ - SL_INDEX_COUNT_LOG2 = 5, -}; - -/* Private constants: do not modify. */ -enum tlsf_private -{ -#if defined (TLSF_64BIT) - /* All allocation sizes and addresses are aligned to 8 bytes. */ - ALIGN_SIZE_LOG2 = 3, -#else - /* All allocation sizes and addresses are aligned to 4 bytes. */ - ALIGN_SIZE_LOG2 = 2, -#endif - ALIGN_SIZE = (1 << ALIGN_SIZE_LOG2), - - /* - ** We support allocations of sizes up to (1 << FL_INDEX_MAX) bits. - ** However, because we linearly subdivide the second-level lists, and - ** our minimum size granularity is 4 bytes, it doesn't make sense to - ** create first-level lists for sizes smaller than SL_INDEX_COUNT * 4, - ** or (1 << (SL_INDEX_COUNT_LOG2 + 2)) bytes, as there we will be - ** trying to split size ranges into more slots than we have available. - ** Instead, we calculate the minimum threshold size, and place all - ** blocks below that size into the 0th first-level list. - */ - -#if defined (TLSF_64BIT) - /* - ** TODO: We can increase this to support larger sizes, at the expense - ** of more overhead in the TLSF structure. - */ - FL_INDEX_MAX = 32, -#else - FL_INDEX_MAX = 30, -#endif - SL_INDEX_COUNT = (1 << SL_INDEX_COUNT_LOG2), - FL_INDEX_SHIFT = (SL_INDEX_COUNT_LOG2 + ALIGN_SIZE_LOG2), - FL_INDEX_COUNT = (FL_INDEX_MAX - FL_INDEX_SHIFT + 1), - - SMALL_BLOCK_SIZE = (1 << FL_INDEX_SHIFT), -}; - -/* -** Cast and min/max macros. -*/ - -#define tlsf_cast(t, exp) ((t) (exp)) -#define tlsf_min(a, b) ((a) < (b) ? (a) : (b)) -#define tlsf_max(a, b) ((a) > (b) ? (a) : (b)) - -#define tlsf_assert FASSERT -/* -** Set assert macro, if it has not been provided by the user. -*/ -#if !defined (tlsf_assert) - #define tlsf_assert assert -#endif - -/* -** Static assertion mechanism. -*/ - -#define _tlsf_glue2(x, y) x ## y -#define _tlsf_glue(x, y) _tlsf_glue2(x, y) -#define tlsf_static_assert(exp) \ - typedef char _tlsf_glue(static_assert, __LINE__) [(exp) ? 1 : -1] - -/* This code has been tested on 32- and 64-bit (LP/LLP) architectures. */ -tlsf_static_assert(sizeof(int) * CHAR_BIT == 32); -tlsf_static_assert(sizeof(size_t) * CHAR_BIT >= 32); -tlsf_static_assert(sizeof(size_t) * CHAR_BIT <= 64); - -/* SL_INDEX_COUNT must be <= number of bits in sl_bitmap's storage type. */ -tlsf_static_assert(sizeof(unsigned int) * CHAR_BIT >= SL_INDEX_COUNT); - -/* Ensure we've properly tuned our sizes. */ -tlsf_static_assert(ALIGN_SIZE == SMALL_BLOCK_SIZE / SL_INDEX_COUNT); - -/* -** Data structures and associated constants. -*/ - -/* -** Block header structure. -** -** There are several implementation subtleties involved: -** - The prev_phys_block field is only valid if the previous block is free. -** - The prev_phys_block field is actually stored at the end of the -** previous block. It appears at the beginning of this structure only to -** simplify the implementation. -** - The next_free / prev_free fields are only valid if the block is free. -*/ -typedef struct block_header_t -{ - /* Points to the previous physical block. */ - struct block_header_t *prev_phys_block; - - /* The size of this block, excluding the block header. */ - size_t size; - - /* Next and previous free blocks. */ - struct block_header_t *next_free; - struct block_header_t *prev_free; -} block_header_t; - -/* -** Since block sizes are always at least a multiple of 4, the two least -** significant bits of the size field are used to store the block status: -** - bit 0: whether block is busy or free -** - bit 1: whether previous block is busy or free -*/ -static const size_t block_header_free_bit = 1 << 0; -static const size_t block_header_prev_free_bit = 1 << 1; - -/* -** The size of the block header exposed to used blocks is the size field. -** The prev_phys_block field is stored *inside* the previous free block. -*/ -static const size_t block_header_overhead = sizeof(size_t); - -/* User data starts directly after the size field in a used block. */ -static const size_t block_start_offset = - offsetof(block_header_t, size) + sizeof(size_t); - -/* -** A free block must be large enough to store its header minus the size of -** the prev_phys_block field, and no larger than the number of addressable -** bits for FL_INDEX. -*/ -static const size_t block_size_min = - sizeof(block_header_t) - sizeof(block_header_t *); -static const size_t block_size_max = tlsf_cast(size_t, 1) << FL_INDEX_MAX; - - -/* The TLSF control structure. */ -typedef struct control_t -{ - /* Empty lists point at this block to indicate they are free. */ - block_header_t block_null; - - /* Bitmaps for free lists. */ - unsigned int fl_bitmap; - unsigned int sl_bitmap[FL_INDEX_COUNT]; - - /* Head of free lists. */ - block_header_t *blocks[FL_INDEX_COUNT][SL_INDEX_COUNT]; -} control_t; - -/* A type used for casting when doing pointer arithmetic. */ -typedef ptrdiff_t tlsfptr_t; - -/* -** block_header_t member functions. -*/ - -static size_t block_size(const block_header_t *block) -{ - return block->size & ~(block_header_free_bit | block_header_prev_free_bit); -} - -static void block_set_size(block_header_t *block, size_t size) -{ - const size_t oldsize = block->size; - block->size = size | (oldsize & (block_header_free_bit | block_header_prev_free_bit)); -} - -static int block_is_last(const block_header_t *block) -{ - return block_size(block) == 0; -} - -static int block_is_free(const block_header_t *block) -{ - return tlsf_cast(int, block->size & block_header_free_bit); -} - -static void block_set_free(block_header_t *block) -{ - block->size |= block_header_free_bit; -} - -static void block_set_used(block_header_t *block) -{ - block->size &= ~block_header_free_bit; -} - -static int block_is_prev_free(const block_header_t *block) -{ - return tlsf_cast(int, block->size & block_header_prev_free_bit); -} - -static void block_set_prev_free(block_header_t *block) -{ - block->size |= block_header_prev_free_bit; -} - -static void block_set_prev_used(block_header_t *block) -{ - block->size &= ~block_header_prev_free_bit; -} - -static block_header_t *block_from_ptr(const void *ptr) -{ - return tlsf_cast(block_header_t *, - tlsf_cast(unsigned char *, ptr) - block_start_offset); -} - -static void *block_to_ptr(const block_header_t *block) -{ - return tlsf_cast(void *, - tlsf_cast(unsigned char *, block) + block_start_offset); -} - -/* Return location of next block after block of given size. */ -static block_header_t *offset_to_block(const void *ptr, size_t size) -{ - return tlsf_cast(block_header_t *, tlsf_cast(tlsfptr_t, ptr) + size); -} - -/* Return location of previous block. */ -static block_header_t *block_prev(const block_header_t *block) -{ - tlsf_assert(block_is_prev_free(block) && "previous block must be free"); - return block->prev_phys_block; -} - -/* Return location of next existing block. */ -static block_header_t *block_next(const block_header_t *block) -{ - block_header_t *next = offset_to_block(block_to_ptr(block), - block_size(block) - block_header_overhead); - tlsf_assert(!block_is_last(block)); - return next; -} - -/* Link a new block with its physical neighbor, return the neighbor. */ -static block_header_t *block_link_next(block_header_t *block) -{ - block_header_t *next = block_next(block); - next->prev_phys_block = block; - return next; -} - -static void block_mark_as_free(block_header_t *block) -{ - /* Link the block to the next block, first. */ - block_header_t *next = block_link_next(block); - block_set_prev_free(next); - block_set_free(block); -} - -static void block_mark_as_used(block_header_t *block) -{ - block_header_t *next = block_next(block); - block_set_prev_used(next); - block_set_used(block); -} - -static size_t align_up(size_t x, size_t align) -{ - tlsf_assert(0 == (align & (align - 1)) && "must align to a power of two"); - return (x + (align - 1)) & ~(align - 1); -} - -static size_t align_down(size_t x, size_t align) -{ - tlsf_assert(0 == (align & (align - 1)) && "must align to a power of two"); - return x - (x & (align - 1)); -} - -static void *align_ptr(const void *ptr, size_t align) -{ - const tlsfptr_t aligned = - (tlsf_cast(tlsfptr_t, ptr) + (align - 1)) & ~(align - 1); - tlsf_assert(0 == (align & (align - 1)) && "must align to a power of two"); - return tlsf_cast(void *, aligned); -} - -/* -** Adjust an allocation size to be aligned to word size, and no smaller -** than internal minimum. -*/ -static size_t adjust_request_size(size_t size, size_t align) -{ - size_t adjust = 0; - if (size) - { - const size_t aligned = align_up(size, align); - - /* aligned sized must not exceed block_size_max or we'll go out of bounds on sl_bitmap */ - if (aligned < block_size_max) - { - adjust = tlsf_max(aligned, block_size_min); - } - } - return adjust; -} - -/* -** TLSF utility functions. In most cases, these are direct translations of -** the documentation found in the white paper. -*/ - -static void mapping_insert(size_t size, int *fli, int *sli) -{ - int fl, sl; - if (size < SMALL_BLOCK_SIZE) - { - /* Store small blocks in first list. */ - fl = 0; - sl = tlsf_cast(int, size) / (SMALL_BLOCK_SIZE / SL_INDEX_COUNT); - } - else - { - fl = tlsf_fls_sizet(size); - sl = tlsf_cast(int, size >> (fl - SL_INDEX_COUNT_LOG2)) ^ (1 << SL_INDEX_COUNT_LOG2); - fl -= (FL_INDEX_SHIFT - 1); - } - *fli = fl; - *sli = sl; -} - -/* This version rounds up to the next block size (for allocations) */ -static void mapping_search(size_t size, int *fli, int *sli) -{ - if (size >= SMALL_BLOCK_SIZE) - { - const size_t round = (1 << (tlsf_fls_sizet(size) - SL_INDEX_COUNT_LOG2)) - 1; - size += round; - } - mapping_insert(size, fli, sli); -} - -static block_header_t *search_suitable_block(control_t *control, int *fli, int *sli) -{ - int fl = *fli; - int sl = *sli; - - /* - ** First, search for a block in the list associated with the given - ** fl/sl index. - */ - unsigned int sl_map = control->sl_bitmap[fl] & (~0U << sl); - if (!sl_map) - { - /* No block exists. Search in the next largest first-level list. */ - const unsigned int fl_map = control->fl_bitmap & (~0U << (fl + 1)); - if (!fl_map) - { - /* No free blocks available, memory has been exhausted. */ - return 0; - } - - fl = tlsf_ffs(fl_map); - *fli = fl; - sl_map = control->sl_bitmap[fl]; - } - tlsf_assert(sl_map && "internal error - second level bitmap is null"); - sl = tlsf_ffs(sl_map); - *sli = sl; - - /* Return the first block in the free list. */ - return control->blocks[fl][sl]; -} - -/* Remove a free block from the free list.*/ -static void remove_free_block(control_t *control, block_header_t *block, int fl, int sl) -{ - block_header_t *prev = block->prev_free; - block_header_t *next = block->next_free; - tlsf_assert(prev && "prev_free field can not be null"); - tlsf_assert(next && "next_free field can not be null"); - next->prev_free = prev; - prev->next_free = next; - - /* If this block is the head of the free list, set new head. */ - if (control->blocks[fl][sl] == block) - { - control->blocks[fl][sl] = next; - - /* If the new head is null, clear the bitmap. */ - if (next == &control->block_null) - { - control->sl_bitmap[fl] &= ~(1U << sl); - - /* If the second bitmap is now empty, clear the fl bitmap. */ - if (!control->sl_bitmap[fl]) - { - control->fl_bitmap &= ~(1U << fl); - } - } - } -} - -/* Insert a free block into the free block list. */ -static void insert_free_block(control_t *control, block_header_t *block, int fl, int sl) -{ - block_header_t *current = control->blocks[fl][sl]; - tlsf_assert(current && "free list cannot have a null entry"); - tlsf_assert(block && "cannot insert a null entry into the free list"); - block->next_free = current; - block->prev_free = &control->block_null; - current->prev_free = block; - - tlsf_assert(block_to_ptr(block) == align_ptr(block_to_ptr(block), ALIGN_SIZE) - && "block not aligned properly"); - /* - ** Insert the new block at the head of the list, and mark the first- - ** and second-level bitmaps appropriately. - */ - control->blocks[fl][sl] = block; - control->fl_bitmap |= (1U << fl); - control->sl_bitmap[fl] |= (1U << sl); -} - -/* Remove a given block from the free list. */ -static void block_remove(control_t *control, block_header_t *block) -{ - int fl, sl; - mapping_insert(block_size(block), &fl, &sl); - remove_free_block(control, block, fl, sl); -} - -/* Insert a given block into the free list. */ -static void block_insert(control_t *control, block_header_t *block) -{ - int fl, sl; - mapping_insert(block_size(block), &fl, &sl); - insert_free_block(control, block, fl, sl); -} - -static int block_can_split(block_header_t *block, size_t size) -{ - return block_size(block) >= sizeof(block_header_t) + size; -} - -/* Split a block into two, the second of which is free. */ -static block_header_t *block_split(block_header_t *block, size_t size) -{ - /* Calculate the amount of space left in the remaining block. */ - block_header_t *remaining = - offset_to_block(block_to_ptr(block), size - block_header_overhead); - - const size_t remain_size = block_size(block) - (size + block_header_overhead); - - tlsf_assert(block_to_ptr(remaining) == align_ptr(block_to_ptr(remaining), ALIGN_SIZE) - && "remaining block not aligned properly"); - - tlsf_assert(block_size(block) == remain_size + size + block_header_overhead); - block_set_size(remaining, remain_size); - tlsf_assert(block_size(remaining) >= block_size_min && "block split with invalid size"); - - block_set_size(block, size); - block_mark_as_free(remaining); - - return remaining; -} - -/* Absorb a free block's storage into an adjacent previous free block. */ -static block_header_t *block_absorb(block_header_t *prev, block_header_t *block) -{ - tlsf_assert(!block_is_last(prev) && "previous block can't be last"); - /* Note: Leaves flags untouched. */ - prev->size += block_size(block) + block_header_overhead; - block_link_next(prev); - return prev; -} - -/* Merge a just-freed block with an adjacent previous free block. */ -static block_header_t *block_merge_prev(control_t *control, block_header_t *block) -{ - if (block_is_prev_free(block)) - { - block_header_t *prev = block_prev(block); - tlsf_assert(prev && "prev physical block can't be null"); - tlsf_assert(block_is_free(prev) && "prev block is not free though marked as such"); - block_remove(control, prev); - block = block_absorb(prev, block); - } - - return block; -} - -/* Merge a just-freed block with an adjacent free block. */ -static block_header_t *block_merge_next(control_t *control, block_header_t *block) -{ - block_header_t *next = block_next(block); - tlsf_assert(next && "next physical block can't be null"); - - if (block_is_free(next)) - { - tlsf_assert(!block_is_last(block) && "previous block can't be last"); - block_remove(control, next); - block = block_absorb(block, next); - } - - return block; -} - -/* Trim any trailing block space off the end of a block, return to pool. */ -static void block_trim_free(control_t *control, block_header_t *block, size_t size) -{ - tlsf_assert(block_is_free(block) && "block must be free"); - if (block_can_split(block, size)) - { - block_header_t *remaining_block = block_split(block, size); - block_link_next(block); - block_set_prev_free(remaining_block); - block_insert(control, remaining_block); - } -} - -/* Trim any trailing block space off the end of a used block, return to pool. */ -static void block_trim_used(control_t *control, block_header_t *block, size_t size) -{ - tlsf_assert(!block_is_free(block) && "block must be used"); - if (block_can_split(block, size)) - { - /* If the next block is free, we must coalesce. */ - block_header_t *remaining_block = block_split(block, size); - block_set_prev_used(remaining_block); - - remaining_block = block_merge_next(control, remaining_block); - block_insert(control, remaining_block); - } -} - -static block_header_t *block_trim_free_leading(control_t *control, block_header_t *block, size_t size) -{ - block_header_t *remaining_block = block; - if (block_can_split(block, size)) - { - /* We want the 2nd block. */ - remaining_block = block_split(block, size - block_header_overhead); - block_set_prev_free(remaining_block); - - block_link_next(block); - block_insert(control, block); - } - - return remaining_block; -} - -static block_header_t *block_locate_free(control_t *control, size_t size) -{ - int fl = 0, sl = 0; - block_header_t *block = 0; - - if (size) - { - mapping_search(size, &fl, &sl); - - /* - ** mapping_search can futz with the size, so for excessively large sizes it can sometimes wind up - ** with indices that are off the end of the block array. - ** So, we protect against that here, since this is the only callsite of mapping_search. - ** Note that we don't need to check sl, since it comes from a modulo operation that guarantees it's always in range. - */ - if (fl < FL_INDEX_COUNT) - { - block = search_suitable_block(control, &fl, &sl); - } - } - - if (block) - { - tlsf_assert(block_size(block) >= size); - remove_free_block(control, block, fl, sl); - } - - return block; -} - -static void *block_prepare_used(control_t *control, block_header_t *block, size_t size) -{ - void *p = 0; - if (block) - { - tlsf_assert(size && "size must be non-zero"); - block_trim_free(control, block, size); - block_mark_as_used(block); - p = block_to_ptr(block); - } - return p; -} - -/* Clear structure and point all empty lists at the null block. */ -static void control_construct(control_t *control) -{ - int i, j; - - control->block_null.next_free = &control->block_null; - control->block_null.prev_free = &control->block_null; - - control->fl_bitmap = 0; - for (i = 0; i < FL_INDEX_COUNT; ++i) - { - control->sl_bitmap[i] = 0; - for (j = 0; j < SL_INDEX_COUNT; ++j) - { - control->blocks[i][j] = &control->block_null; - } - } -} - -/* -** Debugging utilities. -*/ - -typedef struct integrity_t -{ - int prev_status; - int status; -} integrity_t; - -#define tlsf_insist(x) { tlsf_assert(x); if (!(x)) { status--; } } - -static void integrity_walker(void *ptr, size_t size, int used, void *user) -{ - block_header_t *block = block_from_ptr(ptr); - integrity_t *integ = tlsf_cast(integrity_t *, user); - const int this_prev_status = block_is_prev_free(block) ? 1 : 0; - const int this_status = block_is_free(block) ? 1 : 0; - const size_t this_block_size = block_size(block); - - int status = 0; - (void)used; - tlsf_insist(integ->prev_status == this_prev_status && "prev status incorrect"); - tlsf_insist(size == this_block_size && "block size incorrect"); - - integ->prev_status = this_status; - integ->status += status; -} - -int tlsf_check(tlsf_t tlsf) -{ - int i, j; - - control_t *control = tlsf_cast(control_t *, tlsf); - int status = 0; - - /* Check that the free lists and bitmaps are accurate. */ - for (i = 0; i < FL_INDEX_COUNT; ++i) - { - for (j = 0; j < SL_INDEX_COUNT; ++j) - { - const int fl_map = control->fl_bitmap & (1U << i); - const int sl_list = control->sl_bitmap[i]; - const int sl_map = sl_list & (1U << j); - const block_header_t *block = control->blocks[i][j]; - - /* Check that first- and second-level lists agree. */ - if (!fl_map) - { - tlsf_insist(!sl_map && "second-level map must be null"); - } - - if (!sl_map) - { - tlsf_insist(block == &control->block_null && "block list must be null"); - continue; - } - - /* Check that there is at least one free block. */ - tlsf_insist(sl_list && "no free blocks in second-level map"); - tlsf_insist(block != &control->block_null && "block should not be null"); - - while (block != &control->block_null) - { - int fli, sli; - tlsf_insist(block_is_free(block) && "block should be free"); - tlsf_insist(!block_is_prev_free(block) && "blocks should have coalesced"); - tlsf_insist(!block_is_free(block_next(block)) && "blocks should have coalesced"); - tlsf_insist(block_is_prev_free(block_next(block)) && "block should be free"); - tlsf_insist(block_size(block) >= block_size_min && "block not minimum size"); - - mapping_insert(block_size(block), &fli, &sli); - tlsf_insist(fli == i && sli == j && "block size indexed in wrong list"); - block = block->next_free; - } - } - } - - return status; -} - -#undef tlsf_insist - -static void default_walker(void *ptr, size_t size, int used, void *user) -{ - (void)user; - printf("\t%x %s size: %x (%x)\n", ptr, used ? "used" : "free", (unsigned int)size, block_from_ptr(ptr)); -} - -void tlsf_walk_pool(pool_t pool, tlsf_walker walker, void *user) -{ - tlsf_walker pool_walker = walker ? walker : default_walker; - block_header_t *block = - offset_to_block(pool, -(size_t)block_header_overhead); - - while (block && !block_is_last(block)) - { - pool_walker( - block_to_ptr(block), - block_size(block), - !block_is_free(block), - user); - block = block_next(block); - } -} - -size_t tlsf_block_size(void *ptr) -{ - size_t size = 0; - if (ptr) - { - const block_header_t *block = block_from_ptr(ptr); - size = block_size(block); - } - return size; -} - -int tlsf_check_pool(pool_t pool) -{ - /* Check that the blocks are physically correct. */ - integrity_t integ = { 0, 0 }; - tlsf_walk_pool(pool, integrity_walker, &integ); - - return integ.status; -} - -/* -** Size of the TLSF structures in a given memory block passed to -** tlsf_create, equal to the size of a control_t -*/ -size_t tlsf_size(void) -{ - return sizeof(control_t); -} - -size_t tlsf_align_size(void) -{ - return ALIGN_SIZE; -} - -size_t tlsf_block_size_min(void) -{ - return block_size_min; -} - -size_t tlsf_block_size_max(void) -{ - return block_size_max; -} - -/* -** Overhead of the TLSF structures in a given memory block passed to -** tlsf_add_pool, equal to the overhead of a free block and the -** sentinel block. -*/ -size_t tlsf_pool_overhead(void) -{ - return 2 * block_header_overhead; -} - -size_t tlsf_alloc_overhead(void) -{ - return block_header_overhead; -} - -pool_t tlsf_add_pool(tlsf_t tlsf, void *mem, size_t bytes) -{ - block_header_t *block; - block_header_t *next; - - const size_t pool_overhead = tlsf_pool_overhead(); - const size_t pool_bytes = align_down(bytes - pool_overhead, ALIGN_SIZE); - - if (((ptrdiff_t)mem % ALIGN_SIZE) != 0) - { - printf("tlsf_add_pool: Memory must be aligned by %u bytes.\n", - (unsigned int)ALIGN_SIZE); - return 0; - } - - if (pool_bytes < block_size_min || pool_bytes > block_size_max) - { -#if defined (TLSF_64BIT) - printf("tlsf_add_pool[64]: Memory size must be between 0x%x and 0x%x00 bytes. current %u\n", - (unsigned int)(pool_overhead + block_size_min), - (unsigned int)((pool_overhead + block_size_max) / 256), - pool_bytes); -#else - printf("tlsf_add_pool[32]: Memory size must be between %u and %u bytes. current %u\n", - (unsigned int)(pool_overhead + block_size_min), - (unsigned int)(pool_overhead + block_size_max), - pool_bytes); -#endif - return 0; - } - - /* - ** Create the main free block. Offset the start of the block slightly - ** so that the prev_phys_block field falls outside of the pool - - ** it will never be used. - */ - block = offset_to_block(mem, -(size_t)block_header_overhead); - block_set_size(block, pool_bytes); - block_set_free(block); - block_set_prev_used(block); - block_insert(tlsf_cast(control_t *, tlsf), block); - - /* Split the block to create a zero-size sentinel block. */ - next = block_link_next(block); - block_set_size(next, 0); - block_set_used(next); - block_set_prev_free(next); - - return mem; -} - -void tlsf_remove_pool(tlsf_t tlsf, pool_t pool) -{ - control_t *control = tlsf_cast(control_t *, tlsf); - block_header_t *block = offset_to_block(pool, -(size_t)block_header_overhead); - - int fl = 0, sl = 0; - - /* comment this lines because it asserted when memory leakage occurred, which should not happen */ - /*tlsf_assert(block_is_free(block) && "block should be free"); - tlsf_assert(!block_is_free(block_next(block)) && "next block should not be free"); - tlsf_assert(block_size(block_next(block)) == 0 && "next block size should be zero");*/ - - mapping_insert(block_size(block), &fl, &sl); - remove_free_block(control, block, fl, sl); -} - -/* -** TLSF main interface. -*/ - -#if _DEBUG -int test_ffs_fls() -{ - /* Verify ffs/fls work properly. */ - int rv = 0; - rv += (tlsf_ffs(0) == -1) ? 0 : 0x1; - rv += (tlsf_fls(0) == -1) ? 0 : 0x2; - rv += (tlsf_ffs(1) == 0) ? 0 : 0x4; - rv += (tlsf_fls(1) == 0) ? 0 : 0x8; - rv += (tlsf_ffs(0x80000000) == 31) ? 0 : 0x10; - rv += (tlsf_ffs(0x80008000) == 15) ? 0 : 0x20; - rv += (tlsf_fls(0x80000008) == 31) ? 0 : 0x40; - rv += (tlsf_fls(0x7FFFFFFF) == 30) ? 0 : 0x80; - -#if defined (TLSF_64BIT) - rv += (tlsf_fls_sizet(0x80000000) == 31) ? 0 : 0x100; - rv += (tlsf_fls_sizet(0x100000000) == 32) ? 0 : 0x200; - rv += (tlsf_fls_sizet(0xffffffffffffffff) == 63) ? 0 : 0x400; -#endif - - if (rv) - { - printf("test_ffs_fls: %x ffs/fls tests failed.\n", rv); - } - return rv; -} -#endif - -tlsf_t tlsf_create(void *mem) -{ -#if _DEBUG - if (test_ffs_fls()) - { - return 0; - } -#endif - - if (((tlsfptr_t)mem % ALIGN_SIZE) != 0) - { - printf("tlsf_create: Memory must be aligned to %u bytes.\n", - (unsigned int)ALIGN_SIZE); - return 0; - } - - control_construct(tlsf_cast(control_t *, mem)); - - return tlsf_cast(tlsf_t, mem); -} - -tlsf_t tlsf_create_with_pool(void *mem, size_t bytes) -{ - tlsf_t tlsf = tlsf_create(mem); - tlsf_add_pool(tlsf, (char *)mem + tlsf_size(), bytes - tlsf_size()); - return tlsf; -} - -void tlsf_destroy(tlsf_t tlsf) -{ - /* Nothing to do. */ - (void)tlsf; -} - -pool_t tlsf_get_pool(tlsf_t tlsf) -{ - return tlsf_cast(pool_t, (char *)tlsf + tlsf_size()); -} - -void *tlsf_malloc(tlsf_t tlsf, size_t size) -{ - control_t *control = tlsf_cast(control_t *, tlsf); - const size_t adjust = adjust_request_size(size, ALIGN_SIZE); - block_header_t *block = block_locate_free(control, adjust); - return block_prepare_used(control, block, adjust); -} - -void *tlsf_memalign(tlsf_t tlsf, size_t align, size_t size) -{ - control_t *control = tlsf_cast(control_t *, tlsf); - const size_t adjust = adjust_request_size(size, ALIGN_SIZE); - - /* - ** We must allocate an additional minimum block size bytes so that if - ** our free block will leave an alignment gap which is smaller, we can - ** trim a leading free block and release it back to the pool. We must - ** do this because the previous physical block is in use, therefore - ** the prev_phys_block field is not valid, and we can't simply adjust - ** the size of that block. - */ - const size_t gap_minimum = sizeof(block_header_t); - const size_t size_with_gap = adjust_request_size(adjust + align + gap_minimum, align); - - /* - ** If alignment is less than or equals base alignment, we're done. - ** If we requested 0 bytes, return null, as tlsf_malloc(0) does. - */ - const size_t aligned_size = (adjust && align > ALIGN_SIZE) ? size_with_gap : adjust; - - block_header_t *block = block_locate_free(control, aligned_size); - - /* This can't be a static assert. */ - tlsf_assert(sizeof(block_header_t) == block_size_min + block_header_overhead); - - if (block) - { - void *ptr = block_to_ptr(block); - void *aligned = align_ptr(ptr, align); - size_t gap = tlsf_cast(size_t, - tlsf_cast(tlsfptr_t, aligned) - tlsf_cast(tlsfptr_t, ptr)); - - /* If gap size is too small, offset to next aligned boundary. */ - if (gap && gap < gap_minimum) - { - const size_t gap_remain = gap_minimum - gap; - const size_t offset = tlsf_max(gap_remain, align); - const void *next_aligned = tlsf_cast(void *, - tlsf_cast(tlsfptr_t, aligned) + offset); - - aligned = align_ptr(next_aligned, align); - gap = tlsf_cast(size_t, - tlsf_cast(tlsfptr_t, aligned) - tlsf_cast(tlsfptr_t, ptr)); - } - - if (gap) - { - tlsf_assert(gap >= gap_minimum && "gap size too small"); - block = block_trim_free_leading(control, block, gap); - } - } - - return block_prepare_used(control, block, adjust); -} - -void tlsf_free(tlsf_t tlsf, void *ptr) -{ - /* Don't attempt to free a NULL pointer. */ - if (ptr) - { - control_t *control = tlsf_cast(control_t *, tlsf); - block_header_t *block = block_from_ptr(ptr); - tlsf_assert(!block_is_free(block) && "block already marked as free"); - block_mark_as_free(block); - block = block_merge_prev(control, block); - block = block_merge_next(control, block); - block_insert(control, block); - } -} - -/* -** The TLSF block information provides us with enough information to -** provide a reasonably intelligent implementation of realloc, growing or -** shrinking the currently allocated block as required. -** -** This routine handles the somewhat esoteric edge cases of realloc: -** - a non-zero size with a null pointer will behave like malloc -** - a zero size with a non-null pointer will behave like free -** - a request that cannot be satisfied will leave the original buffer -** untouched -** - an extended buffer size will leave the newly-allocated area with -** contents undefined -*/ -void *tlsf_realloc(tlsf_t tlsf, void *ptr, size_t size) -{ - control_t *control = tlsf_cast(control_t *, tlsf); - void *p = 0; - - /* Zero-size requests are treated as free. */ - if (ptr && size == 0) - { - tlsf_free(tlsf, ptr); - } - /* Requests with NULL pointers are treated as malloc. */ - else if (!ptr) - { - p = tlsf_malloc(tlsf, size); - } - else - { - block_header_t *block = block_from_ptr(ptr); - block_header_t *next = block_next(block); - - const size_t cursize = block_size(block); - const size_t combined = cursize + block_size(next) + block_header_overhead; - const size_t adjust = adjust_request_size(size, ALIGN_SIZE); - - tlsf_assert(!block_is_free(block) && "block already marked as free"); - - /* - ** If the next block is used, or when combined with the current - ** block, does not offer enough space, we must reallocate and copy. - */ - if (adjust > cursize && (!block_is_free(next) || adjust > combined)) - { - p = tlsf_malloc(tlsf, size); - if (p) - { - const size_t minsize = tlsf_min(cursize, size); - memcpy(p, ptr, minsize); - tlsf_free(tlsf, ptr); - } - } - else - { - /* Do we need to expand to the next block? */ - if (adjust > cursize) - { - block_merge_next(control, block); - block_mark_as_used(block); - } - - /* Trim the resulting block and return the original pointer. */ - block_trim_used(control, block, adjust); - p = ptr; - } - } - - return p; -} - diff --git a/third-party/tlsf-3.1.0/src/tlsf.h b/third-party/tlsf-3.1.0/src/tlsf.h deleted file mode 100644 index 5e39062651a045d6ecfe17d2c95f218a1ccc3568..0000000000000000000000000000000000000000 --- a/third-party/tlsf-3.1.0/src/tlsf.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef INCLUDED_tlsf -#define INCLUDED_tlsf - -/* -** Two Level Segregated Fit memory allocator, version 3.1. -** Written by Matthew Conte -** http://tlsf.baisoku.org -** -** Based on the original documentation by Miguel Masmano: -** http://www.gii.upv.es/tlsf/main/docs -** -** This implementation was written to the specification -** of the document, therefore no GPL restrictions apply. -** -** Copyright (c) 2006-2016, Matthew Conte -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of the copyright holder nor the -** names of its contributors may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL MATTHEW CONTE BE LIABLE FOR ANY -** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -/* tlsf_t: a TLSF structure. Can contain 1 to N pools. */ -/* pool_t: a block of memory that TLSF can manage. */ -typedef void *tlsf_t; -typedef void *pool_t; - -/* Create/destroy a memory pool. */ -tlsf_t tlsf_create(void *mem); -tlsf_t tlsf_create_with_pool(void *mem, size_t bytes); -void tlsf_destroy(tlsf_t tlsf); -pool_t tlsf_get_pool(tlsf_t tlsf); - -/* Add/remove memory pools. */ -pool_t tlsf_add_pool(tlsf_t tlsf, void *mem, size_t bytes); -void tlsf_remove_pool(tlsf_t tlsf, pool_t pool); - -/* malloc/memalign/realloc/free replacements. */ -void *tlsf_malloc(tlsf_t tlsf, size_t bytes); -void *tlsf_memalign(tlsf_t tlsf, size_t align, size_t bytes); -void *tlsf_realloc(tlsf_t tlsf, void *ptr, size_t size); -void tlsf_free(tlsf_t tlsf, void *ptr); - -/* Returns internal block size, not original request size */ -size_t tlsf_block_size(void *ptr); - -/* Overheads/limits of internal structures. */ -size_t tlsf_size(void); -size_t tlsf_align_size(void); -size_t tlsf_block_size_min(void); -size_t tlsf_block_size_max(void); -size_t tlsf_pool_overhead(void); -size_t tlsf_alloc_overhead(void); - -/* Debugging. */ -typedef void (*tlsf_walker)(void *ptr, size_t size, int used, void *user); -void tlsf_walk_pool(pool_t pool, tlsf_walker walker, void *user); -/* Returns nonzero if any internal consistency check fails. */ -int tlsf_check(tlsf_t tlsf); -int tlsf_check_pool(pool_t pool); - -#if defined(__cplusplus) -}; -#endif - -#endif