diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000..42b522e --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,20 @@ +# Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if (ohos_kernel_type == "liteos_m") { + import("//kernel/liteos_m/liteos.gni") + module_name = get_path_info(rebase_path("."), "name") + module_group(module_name) { + modules = [ "esp32_wrover_ie" ] + } +} diff --git a/Kconfig.liteos_m.defconfig b/Kconfig.liteos_m.defconfig new file mode 100644 index 0000000..3557b7d --- /dev/null +++ b/Kconfig.liteos_m.defconfig @@ -0,0 +1,18 @@ +# Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +rsource "*/Kconfig.liteos_m.defconfig.series" + +config HALS_COMMUCATION_WIFI_LITE + bool "WIFI LITE" + default n \ No newline at end of file diff --git a/Kconfig.liteos_m.series b/Kconfig.liteos_m.series new file mode 100644 index 0000000..5e6587e --- /dev/null +++ b/Kconfig.liteos_m.series @@ -0,0 +1,14 @@ +# Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +rsource "*/Kconfig.liteos_m.series" diff --git a/Kconfig.liteos_m.soc b/Kconfig.liteos_m.soc new file mode 100644 index 0000000..f94294e --- /dev/null +++ b/Kconfig.liteos_m.soc @@ -0,0 +1,22 @@ +# Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config SOC_COMPANY_ESPRESSIF + bool + +if SOC_COMPANY_ESPRESSIF +config SOC_COMPANY + default "espressif" + +rsource "*/Kconfig.liteos_m.soc" +endif # SOC_COMPANY_ESPRESSIF \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4947287 --- /dev/null +++ b/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.md b/README.md index aabcc1a..9a3f493 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,152 @@ # device_espressif #### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} -#### 软件架构 -软件架构说明 +##### 目录 +``` +device/soc/espressif +├── esp32_wrover_ie # 芯片SOC名称 +├── ... # 芯片SOC名称 +├── Kconfig.liteos_m.defconfig # kconfig 默认宏配置 +├── Kconfig.liteos_m.series # bes系列soc配置宏 +└── Kconfig.liteos_m.soc # soc kconfig配置宏 +``` -#### 安装教程 +编译环境搭建包含如下几步: +1. 环境搭建 +2. 获取源码 +3. 源码构建 +4. 在开发板中运行镜像 -1. xxxx -2. xxxx -3. xxxx +## 1.环境搭建 -#### 使用说明 + 1. esp-idf安装 -1. xxxx -2. xxxx -3. xxxx + 使用安装指导请参考:(https://docs.espressif.com/projects/esp-idf/zh_CN/release-v4.1/get-started/index.html) -#### 参与贡献 + 2. esptool安装 -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request + ```shell + python -m pip install esptool + ``` + 3. hb工具安装 + a) 运行如下命令安装hb -#### 特技 + ``` + pip3 install build/lite + ``` + b) 设置环境变量 -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) + ``` + vim ~/.bashrc + ``` + + 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。 + + ``` + export PATH=~/.local/bin:$PATH + ``` + + 执行如下命令更新环境变量。 + + ``` + source ~/.bashrc + ``` + c) 执行"hb -h",有打印以下信息即表示安装成功: + + ``` + usage: hb + + OHOS build system + + positional arguments: + {build,set,env,clean} + build Build source code + set OHOS build settings + env Show OHOS build env + clean Clean output + + optional arguments: + -h, --help show this help message and exit + ``` + + 3. 编译镜像 + + a) 生成bootloader.bin + + ```shell + $ cd esp-idf + $ ./install.sh + $ ./export.sh + $ cd examples/get-started/hello_world + $ make menuconfig + (关掉 Partition Table -> [*] Generate an MD5 checksum for the partition table 选项) + $ make bootloader + ``` + + b) 生成分区表 + + 使用`gen_esp32part.py`脚本将用户自定义csv文件转换为对应bin文件,如: + ```shell + $ gen_esp32part.py partitions_user.csv partitions_user.bin --disable-md5sum + ``` + + esp32 csv文件可参考以下配置: + + ``` + nvs,data,nvs,0x9000,24K, + phy_init,data,phy,0xf000,4K, + factory,app,factory,0x10000,1M, + ``` + +## 2.获取源码 + +[代码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md) + +提示: 可以使用 `repo` 命令来获取源码。 + +## 3.源码构建 + + 1. 执行hb set命令并选择项目`esp32_wrover_ie_demo`。 + + 2. 执行hb clean && hb build命令构建产生 `OHOS_Image` 的可执行文件。 + + ```shell + $ hb set + $ hb clean && hb build + ``` + + 3. 在构建完成之后,对应的可执行文件在主目录下: + + ``` + out/esp32_devkitc_v4/esp32_wrover_ie_demo/ + ``` + + 4. 在主目录下执行以下命令生成bin文件: + + ```shell + esptool.py --chip esp32 elf2image --flash_mode dio --flash_freq 80m \ + --flash_size 4MB -o out/esp32_devkitc_v4/esp32_wrover_ie_demo/OHOS_Image.bin out/esp32_devkitc_v4/esp32_wrover_ie_demo/OHOS_Image + ``` + +## 4.在开发板中运行镜像 + + 1. 下载烧录工具 + + 烧录工具链接:https://www.espressif.com/sites/default/files/tools/flash_download_tool_v3.8.8.zip + + 2. 使用烧录工具 + + 使用参考 https://docs.ai-thinker.com/esp_download 中 “不支持OTA” 的FLASH地址配置方式: + + a) 配置bootloader.bin在地址0x1000,配置partition-table.bin在地址0x8000,配置OHOS_Image.bin在地址0x10000。 + + b) 配置SPI SPEED为40MHz,配置SPI MODE为DOUT,配置FLASH SIZE为8Mbit,波特率设置为115200。 + + c) 点击START开始下载。 + +注1:如果没有手动生成bootloader.bin和分区表,可以直接使用vendor/esp/esp32/image下的bootloader.bin和分区表。 + +注2:烧录用的bin文件需要按照4-4中的方法使用esptool.py工具生成。 diff --git a/esp32_wrover_ie/BUILD.gn b/esp32_wrover_ie/BUILD.gn new file mode 100644 index 0000000..52d9947 --- /dev/null +++ b/esp32_wrover_ie/BUILD.gn @@ -0,0 +1,21 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/lite/config/component/lite_component.gni") +import("//build/lite/config/subsystem/lite_subsystem.gni") +import("//kernel/liteos_m/liteos.gni") + +module_name = get_path_info(rebase_path("."), "name") +module_group(module_name) { + modules = [ "liteos_m" ] +} diff --git a/esp32_wrover_ie/Kconfig.liteos_m.defconfig.esp32_wrover_ie b/esp32_wrover_ie/Kconfig.liteos_m.defconfig.esp32_wrover_ie new file mode 100644 index 0000000..66ffbd2 --- /dev/null +++ b/esp32_wrover_ie/Kconfig.liteos_m.defconfig.esp32_wrover_ie @@ -0,0 +1,17 @@ +# Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config SOC + string + default "esp32_wrover_ie" + depends on SOC_ESP32 diff --git a/esp32_wrover_ie/Kconfig.liteos_m.defconfig.series b/esp32_wrover_ie/Kconfig.liteos_m.defconfig.series new file mode 100644 index 0000000..2f54e2d --- /dev/null +++ b/esp32_wrover_ie/Kconfig.liteos_m.defconfig.series @@ -0,0 +1,31 @@ +# Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if SOC_SERIES_ESP32 + +rsource "Kconfig.liteos_m.defconfig.esp32_wrover_ie" + +config SOC_SERIES + string + default "esp32_wrover_ie" + +config NUM_IRQS + int + default 1 + +config SYS_CLOCK_HW_CYCLES_PER_SEC + int + default 24000000 + +endif + diff --git a/esp32_wrover_ie/Kconfig.liteos_m.series b/esp32_wrover_ie/Kconfig.liteos_m.series new file mode 100644 index 0000000..b7c9866 --- /dev/null +++ b/esp32_wrover_ie/Kconfig.liteos_m.series @@ -0,0 +1,21 @@ +# Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config SOC_SERIES_ESP32 + bool "Espressif Series" + select XTENSA + select SOC_COMPANY_ESPRESSIF + select CPU_LX6 + help + Enable support for esp32_wrover_ie series + diff --git a/esp32_wrover_ie/Kconfig.liteos_m.soc b/esp32_wrover_ie/Kconfig.liteos_m.soc new file mode 100644 index 0000000..d43fe20 --- /dev/null +++ b/esp32_wrover_ie/Kconfig.liteos_m.soc @@ -0,0 +1,21 @@ +# Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +choice + prompt "Esp32_wrover_ie series SoC" + depends on SOC_SERIES_ESP32 + +config SOC_ESP32 + bool "SoC ESP32" + +endchoice diff --git a/esp32_wrover_ie/liteos_m/BUILD.gn b/esp32_wrover_ie/liteos_m/BUILD.gn new file mode 100644 index 0000000..918d416 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//kernel/liteos_m/liteos.gni") + +module_name = get_path_info(rebase_path("."), "name") +module_group(module_name) { + modules = [ + "sdk", + "components", + ] +} diff --git a/esp32_wrover_ie/liteos_m/components/BUILD.gn b/esp32_wrover_ie/liteos_m/components/BUILD.gn new file mode 100644 index 0000000..1ddf95b --- /dev/null +++ b/esp32_wrover_ie/liteos_m/components/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//drivers/adapter/khdf/liteos_m/hdf.gni") + +module_group("components") { + modules = [ + "drivers", + "fs", + "utils", + ] +} diff --git a/esp32_wrover_ie/liteos_m/components/drivers/BUILD.gn b/esp32_wrover_ie/liteos_m/components/drivers/BUILD.gn new file mode 100644 index 0000000..3719fee --- /dev/null +++ b/esp32_wrover_ie/liteos_m/components/drivers/BUILD.gn @@ -0,0 +1,21 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//drivers/adapter/khdf/liteos_m/hdf.gni") + +kernel_module("drivers") { + sources = [ "hal_watchdog.c" ] + + include_dirs = + [ "//device/soc/espressif/esp32_wrover_ie/liteos_m/sdk/include/watchdog" ] +} diff --git a/esp32_wrover_ie/liteos_m/components/drivers/hal_watchdog.c b/esp32_wrover_ie/liteos_m/components/drivers/hal_watchdog.c new file mode 100644 index 0000000..f7d3b1a --- /dev/null +++ b/esp32_wrover_ie/liteos_m/components/drivers/hal_watchdog.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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 "hal_watchdog.h" + +VOID WdtEnable(VOID) +{ + if (REG32_READ(RTC_WDT_CFG0) & (1 << RTC_CNTL_WDT_EN)) { + return; + } + + if (REG32_READ(RTC_WDT_PROTECT) != WDT_WRWITE_MASK) { + REG32_WRITE(RTC_WDT_PROTECT, WDT_WRWITE_MASK); + } + + REG32_WRITE(RTC_WDT_FEED, (1 << RTC_CNTL_WDT_FEED)); + REG32_WRITE(RTC_WDT_CFG0, (RTC_CNTL_WDT_SYS_RESET << RTC_CNTL_WDT_STG0)); + REG32_WRITE(RTC_WDT_CFG0, (RTC_CNTL_WDT_SYS_RESET_MASK << RTC_CNTL_WDT_SYS_RESET_LENGTH)); + REG32_WRITE(RTC_WDT_CFG0, (1 << RTC_CNTL_WDT_FLASHBOOT_MOD_EN)); + REG32_WRITE(RTC_WDT_CFG0, (1 << RTC_CNTL_WDT_FLASHBOOT_MOD_EN)); + REG32_WRITE(RTC_WDT_CFG0, (1 << RTC_CNTL_WDT_EN)); + REG32_WRITE(RTC_WDT_PROTECT, 0); +} + +VOID WdtDisable(VOID) +{ + if (REG32_READ(RTC_WDT_PROTECT) != WDT_WRWITE_MASK) { + REG32_WRITE(RTC_WDT_PROTECT, WDT_WRWITE_MASK); + } + REG32_WRITE(RTC_WDT_FEED, (1 << RTC_CNTL_WDT_FEED)); + REG32_WRITE(RTC_WDT_CFG0, ~(1 << RTC_CNTL_WDT_FLASHBOOT_MOD_EN)); + REG32_WRITE(RTC_WDT_CFG0, ~(1 << RTC_CNTL_WDT_FLASHBOOT_MOD_EN)); + REG32_WRITE(RTC_WDT_PROTECT, 0); +} + +VOID WdtFeed(VOID) +{ + if (REG32_READ(RTC_WDT_PROTECT) != WDT_WRWITE_MASK) { + REG32_WRITE(RTC_WDT_PROTECT, WDT_WRWITE_MASK); + } + REG32_WRITE(RTC_WDT_FEED, (1 << RTC_CNTL_WDT_FEED)); + REG32_WRITE(RTC_WDT_PROTECT, 0); +} + +void IoTWatchDogEnable(void) +{ + WdtEnable(); +} + +void IoTWatchDogKick(void) +{ + WdtFeed(); +} + +void IoTWatchDogDisable(void) +{ + WdtDisable(); +} diff --git a/esp32_wrover_ie/liteos_m/components/fs/BUILD.gn b/esp32_wrover_ie/liteos_m/components/fs/BUILD.gn new file mode 100644 index 0000000..1594ad8 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/components/fs/BUILD.gn @@ -0,0 +1,36 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//drivers/adapter/khdf/liteos_m/hdf.gni") + +config("public") { + include_dirs = [ "." ] +} + +hdf_driver("fs_adapter") { + sources = [ + "//utils/native/lite/file/src/file_impl_hal/file.c", + "fs_init.c", + "littlefs_hal.c", + ] + include_dirs = [ + ".", + "//utils/native/lite/hals/file", + "//utils/native/lite/include", + "//third_party/littlefs", + "//third_party/littlefs/bd", + "//device/soc/espressif/esp32/liteos_m/components/utils/include", + "//device/soc/espressif/esp32/liteos_m/sdk/rtos/liteos/liteos_m/libc", + ] + defines = [ "_GNU_SOURCE" ] +} diff --git a/esp32_wrover_ie/liteos_m/components/fs/fs_config.h b/esp32_wrover_ie/liteos_m/components/fs/fs_config.h new file mode 100644 index 0000000..ab4c903 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/components/fs/fs_config.h @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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. + */ + +#ifndef _FS_CONFIG_H +#define _FS_CONFIG_H + +#include "los_compiler.h" +#include "sys/socket.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +int *__errno_location(void); +#define errno (*__errno_location()) +#define LFS_NO_ASSERT 1 +#define FF_VOLUME_STRS "system", "inner", "update", "user" +#define FS_MAX_SS 512 + +#define FAT_MAX_OPEN_FILES 50 +#define LITTLEFS_MAX_LFN_LEN 120 + +#define O_SEARCH O_PATH +#define O_EXEC O_PATH +#define O_TTY_INIT 0 +#define ELIBBAD 80 + +#define O_ACCMODE (03|O_SEARCH) +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 +#define O_EXCL 0200 +#define O_NOCTTY 0400 +#define O_TRUNC 01000 +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_DSYNC 010000 +#define O_SYNC 04010000 +#define O_RSYNC 04010000 +#define O_DIRECTORY 040000 +#define O_NOFOLLOW 0100000 +#define O_CLOEXEC 02000000 + +#define O_ASYNC 020000 +#define O_DIRECT 0200000 +#define O_LARGEFILE 0400000 +#define O_NOATIME 01000000 +#define O_PATH 010000000 +#define O_TMPFILE 020040000 + +#define _FNDELAY O_NONBLOCK + +#define F_OFD_GETLK 36 +#define F_OFD_SETLK 37 +#define F_OFD_SETLKW 38 + +#define F_DUPFD 0 +#define F_GETFD 1 +#define F_SETFD 2 +#define F_GETFL 3 +#define F_SETFL 4 +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 +#define F_SETOWN 8 +#define F_GETOWN 9 +#define F_SETSIG 10 +#define F_GETSIG 11 + +#define F_SETOWN_EX 15 +#define F_GETOWN_EX 16 + +#define F_GETOWNER_UIDS 17 + +#define F_DUPFD_CLOEXEC 1030 + +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +#define FD_CLOEXEC 1 + +#define AT_FDCWD (-100) +#define AT_SYMLINK_NOFOLLOW 0x100 +#define AT_REMOVEDIR 0x200 +#define AT_SYMLINK_FOLLOW 0x400 +#define AT_EACCESS 0x200 + +#define POSIX_FADV_NORMAL 0 +#define POSIX_FADV_RANDOM 1 +#define POSIX_FADV_SEQUENTIAL 2 +#define POSIX_FADV_WILLNEED 3 +#ifndef POSIX_FADV_DONTNEED +#define POSIX_FADV_DONTNEED 4 +#define POSIX_FADV_NOREUSE 5 +#endif + +#undef SEEK_SET +#undef SEEK_CUR +#undef SEEK_END +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#ifndef S_IRUSR +#define S_ISUID 04000 +#define S_ISGID 02000 +#define S_ISVTX 01000 +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#define S_IXUSR 0100 +#define S_IRWXU 0700 +#define S_IRGRP 0040 +#define S_IWGRP 0020 +#define S_IXGRP 0010 +#define S_IRWXG 0070 +#define S_IROTH 0004 +#define S_IWOTH 0002 +#define S_IXOTH 0001 +#define S_IRWXO 0007 +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#define AT_NO_AUTOMOUNT 0x800 +#define AT_EMPTY_PATH 0x1000 +#define AT_STATX_SYNC_TYPE 0x6000 +#define AT_STATX_SYNC_AS_STAT 0x0000 +#define AT_STATX_FORCE_SYNC 0x2000 +#define AT_STATX_DONT_SYNC 0x4000 +#define AT_RECURSIVE 0x8000 + +#define FAPPEND O_APPEND +#define FFSYNC O_SYNC +#define FASYNC O_ASYNC +#define FNONBLOCK O_NONBLOCK +#define FNDELAY O_NDELAY + +#define F_OK 0 +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#define F_ULOCK 0 +#define F_LOCK 1 +#define F_TLOCK 2 +#define F_TEST 3 + +#define F_SETLEASE 1024 +#define F_GETLEASE 1025 +#define F_NOTIFY 1026 +#define F_CANCELLK 1029 +#define F_SETPIPE_SZ 1031 +#define F_GETPIPE_SZ 1032 +#define F_ADD_SEALS 1033 +#define F_GET_SEALS 1034 + +#define F_SEAL_SEAL 0x0001 +#define F_SEAL_SHRINK 0x0002 +#define F_SEAL_GROW 0x0004 +#define F_SEAL_WRITE 0x0008 +#define F_SEAL_FUTURE_WRITE 0x0010 + +#define F_GET_RW_HINT 1035 +#define F_SET_RW_HINT 1036 +#define F_GET_FILE_RW_HINT 1037 +#define F_SET_FILE_RW_HINT 1038 + +#define RWF_WRITE_LIFE_NOT_SET 0 +#define RWH_WRITE_LIFE_NONE 1 +#define RWH_WRITE_LIFE_SHORT 2 +#define RWH_WRITE_LIFE_MEDIUM 3 +#define RWH_WRITE_LIFE_LONG 4 +#define RWH_WRITE_LIFE_EXTREME 5 + +#define DN_ACCESS 0x00000001 +#define DN_MODIFY 0x00000002 +#define DN_CREATE 0x00000004 +#define DN_DELETE 0x00000008 +#define DN_RENAME 0x00000010 +#define DN_ATTRIB 0x00000020 +#define DN_MULTISHOT 0x80000000 +#endif + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif /* _FS_CONFIG_H */ diff --git a/esp32_wrover_ie/liteos_m/components/fs/fs_init.c b/esp32_wrover_ie/liteos_m/components/fs/fs_init.c new file mode 100644 index 0000000..63a9e32 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/components/fs/fs_init.c @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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 "fs_init.h" +#include "lfs.h" +#include "los_task.h" +#include "securec.h" +#include "utils_file.h" + + +#define FS_INIT_TASK_SIZE 0x1000 +#define FS_INIT_TASK_PRIORITY 2 + +static uint32_t g_taskId; + +static void FileSystemEntry(void) +{ + int ret; + struct lfs_config *littlefsConfig = LittlefsConfigGet(); + LittlefsDriverInit(0); + SetDefaultMountPath(0, "/littlefs"); + ret = mount(NULL, "/littlefs", "littlefs", 0, littlefsConfig); + if (ret != LOS_OK) { + printf("Littlefs init failed 0x%x.\n", ret); + return; + } + + ret = mkdir("/littlefs", 775); + if (ret != LOS_OK) { + printf("Mkdir failed 0x%x.\n", ret); + return; + } + printf("Littlefs init successed!\n"); +} + +void FileSystemInit(void) +{ + uint32_t ret; + TSK_INIT_PARAM_S taskInitParam; + + ret = memset_s(&taskInitParam, sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S)); + if (ret != EOK) { + return; + } + + taskInitParam.usTaskPrio = FS_INIT_TASK_PRIORITY; + taskInitParam.pcName = "FileSystemTask"; + taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)FileSystemEntry; + taskInitParam.uwStackSize = FS_INIT_TASK_SIZE; + ret = LOS_TaskCreate(&g_taskId, &taskInitParam); + if (ret != LOS_OK) { + printf("Create filesystem init task failed.\n"); + } +} diff --git a/esp32_wrover_ie/liteos_m/components/fs/fs_init.h b/esp32_wrover_ie/liteos_m/components/fs/fs_init.h new file mode 100644 index 0000000..7914711 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/components/fs/fs_init.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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. + */ + +#ifndef _FS_INIT_H +#define _FS_INIT_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +struct diskio_drv* FatfsConfigGet(void); +struct lfs_config* LittlefsConfigGet(void); + +void FileSystemInit(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif /* _FS_INIT_H */ diff --git a/esp32_wrover_ie/liteos_m/components/fs/littlefs_hal.c b/esp32_wrover_ie/liteos_m/components/fs/littlefs_hal.c new file mode 100644 index 0000000..78a58a8 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/components/fs/littlefs_hal.c @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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 +#include "los_memory.h" +#include "lfs_rambd.h" +#include "lfs.h" + +#define READ_SIZE 16 +#define PROG_SIZE 16 +#define BLOCK_SIZE 256 +#define BLOCK_COUNT 128 +#define CACHE_SIZE 16 +#define LOOKAHEAD_SIZE 16 +#define BLOCK_CYCLES 500 + +static int LittlefsRead(const struct lfs_config *cfg, lfs_block_t block, + lfs_off_t off, void *buffer, lfs_size_t size) +{ + (void)lfs_rambd_read(cfg, block, off, buffer, size); + + return LFS_ERR_OK; +} + +static int LittlefsProg(const struct lfs_config *cfg, lfs_block_t block, + lfs_off_t off, const void *buffer, lfs_size_t size) +{ + (void)lfs_rambd_prog(cfg, block, off, buffer, size); + + return LFS_ERR_OK; +} + +static int LittlefsErase(const struct lfs_config *cfg, lfs_block_t block) +{ + (void)lfs_rambd_erase(cfg, block); + + return LFS_ERR_OK; +} + +static int LittlefsSync(const struct lfs_config *cfg) +{ + return LFS_ERR_OK; +} + +static struct lfs_config g_lfsConfig = { + // block device operations + .context = NULL, + .read = LittlefsRead, + .prog = LittlefsProg, + .erase = LittlefsErase, + .sync = LittlefsSync, + + // block device configuration + .read_size = READ_SIZE, + .prog_size = PROG_SIZE, + .block_size = BLOCK_SIZE, + .block_count = BLOCK_COUNT, + .cache_size = CACHE_SIZE, + .lookahead_size = LOOKAHEAD_SIZE, + .block_cycles = BLOCK_CYCLES, + .read_buffer = NULL, + .prog_buffer = NULL, + .lookahead_buffer = NULL +}; + +void LittlefsDriverInit(int needErase) +{ + lfs_rambd_t *bd = (lfs_rambd_t *)LOS_MemAlloc(m_aucSysMem0, sizeof(lfs_rambd_t)); + (void)memset_s(bd, sizeof(lfs_rambd_t), 0, sizeof(lfs_rambd_t)); + g_lfsConfig.context = bd; + (void)lfs_rambd_create(&g_lfsConfig); +} + +struct lfs_config* LittlefsConfigGet(void) +{ + return &g_lfsConfig; +} diff --git a/esp32_wrover_ie/liteos_m/components/utils/BUILD.gn b/esp32_wrover_ie/liteos_m/components/utils/BUILD.gn new file mode 100644 index 0000000..e4ae09d --- /dev/null +++ b/esp32_wrover_ie/liteos_m/components/utils/BUILD.gn @@ -0,0 +1,33 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//drivers/adapter/khdf/liteos_m/hdf.gni") + +config("public") { + include_dirs = [ "include" ] +} + +kernel_module("sys_adapter") { + sources = [ + "src/dprintf.c", + "src/swap.c", + ] + + include_dirs = [ "include" ] + + include_dirs += [ + "//device/soc/espressif/esp32/liteos_m/sdk/include/board", + "//device/soc/espressif/esp32/liteos_m/sdk/include/watchdog", + ] + defines = [ "_GNU_SOURCE" ] +} diff --git a/esp32_wrover_ie/liteos_m/components/utils/src/dprintf.c b/esp32_wrover_ie/liteos_m/components/utils/src/dprintf.c new file mode 100644 index 0000000..cc56a79 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/components/utils/src/dprintf.c @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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 +#include +#include "los_interrupt.h" + +#define PLACEHOLDER_OFFSET 2 +#define HEXADECIMAL_NUM 16 +#define DECIMALISM_NUM 10 +#define BOUNDARY_NUM 9 + +VOID UartPutc(CHAR c) +{ + (VOID)uart_tx_one_char(c); +} + +VOID MatchedOut(CHAR data, va_list *ap) +{ + CHAR c = 0; + UINT32 v, n; + UINT32 val[100]; + CHAR *s = NULL; + INT32 i = 0; + INT32 j = 0; + + switch (data) { + case 'c': + c = va_arg(*ap, UINT32); + UartPutc(c); + break; + case 's': + s = va_arg(*ap, CHAR*); + while (*s) { + UartPutc(*s++); + } + break; + case 'd': + v = va_arg(*ap, UINT32); + i = 0; + while (v) { + n = v % DECIMALISM_NUM; + val[i] = n; + v = v / DECIMALISM_NUM; + i++; + } + if (i == 0) { + UartPutc('0'); + } + for (j = i - 1; j >= 0; j--) { + UartPutc('0' + val[j]); + } + break; + case 'x': + v = va_arg(*ap, UINT32); + i = 0; + if (v == 0) { + val[i] = 0; + i++; + } + while (v) { + n = v % HEXADECIMAL_NUM; + val[i] = n; + v = v / HEXADECIMAL_NUM; + i++; + } + if (i == 0) { + UartPutc('0'); + } + for (j = i - 1; j >= 0; j--) { + if (val[j] > BOUNDARY_NUM) { + UartPutc('a' + val[j] - DECIMALISM_NUM); + } else { + UartPutc('0' + val[j]); + } + } + break; + case 'p': + v = va_arg(*ap, UINT32); + i = 0; + if (v == 0) { + val[i] = 0; + i++; + } + while (v) { + n = v % HEXADECIMAL_NUM; + val[i] = n; + v = v / HEXADECIMAL_NUM; + i++; + } + UartPutc('0'); + UartPutc('x'); + if (i == 0) { + UartPutc('0'); + } + for (j = i - 1; j >= 0; j--) { + if (val[j] > BOUNDARY_NUM) { + UartPutc('a' + val[j] - DECIMALISM_NUM); + } else { + UartPutc('0' + val[j]); + } + } + break; + default: + break; + } +} + +INT32 printf(const CHAR *fmt, ...) +{ + va_list ap; + (VOID)va_start(ap, fmt); + while (*fmt != '\0') { + switch (*fmt) { + case '%': + MatchedOut(fmt[1], &ap); + fmt += PLACEHOLDER_OFFSET; + break; + case '\n': + UartPutc('\r'); + UartPutc('\n'); + fmt++; + break; + case '\r': + UartPutc('\r'); + UartPutc('\n'); + fmt++; + break; + default: + UartPutc(*fmt); + fmt++; + break; + } + } + (VOID)va_end(ap); + return 0; +} diff --git a/esp32_wrover_ie/liteos_m/components/utils/src/swap.c b/esp32_wrover_ie/liteos_m/components/utils/src/swap.c new file mode 100644 index 0000000..9140f61 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/components/utils/src/swap.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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 +#include + +unsigned int __builtin_bswap32(unsigned int a) +{ + return (a & 0xff) << 24 + | (a & 0xff00) << 8 + | (a & 0xff0000) >> 8 + | (a & 0xff000000) >> 24; +} diff --git a/esp32_wrover_ie/liteos_m/hals/utils/file/BUILD.gn b/esp32_wrover_ie/liteos_m/hals/utils/file/BUILD.gn new file mode 100644 index 0000000..2e56ffb --- /dev/null +++ b/esp32_wrover_ie/liteos_m/hals/utils/file/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/lite/config/component/lite_component.gni") + +static_library("hal_file_static") { + sources = [ "src/hal_file.c" ] + + include_dirs = [ + "//utils/native/lite/hals/file", + "//kernel/liteos_m", + ] +} + diff --git a/esp32_wrover_ie/liteos_m/hals/utils/file/src/hal_file.c b/esp32_wrover_ie/liteos_m/hals/utils/file/src/hal_file.c new file mode 100644 index 0000000..79ad315 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/hals/utils/file/src/hal_file.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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 +#include +#include +#include "errno.h" +#include "fcntl.h" +#include "sys/stat.h" +#include "lfs.h" +#include "lfs_rambd.h" +#include "fs_config.h" + +int HalFileOpen(const char* path, int oflag, int mode) +{ + char tmpPath[LITTLEFS_MAX_LFN_LEN] = {0}; + (void)snprintf_s(tmpPath, LITTLEFS_MAX_LFN_LEN, LITTLEFS_MAX_LFN_LEN, "/littlefs/%s", path); + return open(tmpPath, oflag, mode); +} + +int HalFileClose(int fd) +{ + return close(fd); +} + +int HalFileRead(int fd, char *buf, unsigned int len) +{ + return read(fd, buf, len); +} + +int HalFileWrite(int fd, const char *buf, unsigned int len) +{ + return write(fd, buf,len); +} + +int HalFileDelete(const char *path) +{ + char tmpPath[LITTLEFS_MAX_LFN_LEN] = {0}; + (void)snprintf_s(tmpPath, LITTLEFS_MAX_LFN_LEN, LITTLEFS_MAX_LFN_LEN, "/littlefs/%s", path); + return unlink(tmpPath); +} + +int HalFileStat(const char *path, unsigned int *fileSize) +{ + char tmpPath[LITTLEFS_MAX_LFN_LEN] = {0}; + struct stat halStat ; + int ret = 0; + (void)snprintf_s(tmpPath, LITTLEFS_MAX_LFN_LEN, LITTLEFS_MAX_LFN_LEN, "/littlefs/%s", path); + ret = stat(tmpPath, &halStat); + *fileSize = halStat.st_size; + return ret; +} + +int HalFileSeek(int fd, int offset, unsigned int whence) +{ + return lseek(fd, (off_t)offset, whence); +} + diff --git a/esp32_wrover_ie/liteos_m/sdk/BUILD.gn b/esp32_wrover_ie/liteos_m/sdk/BUILD.gn new file mode 100644 index 0000000..dbcb037 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/sdk/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//kernel/liteos_m/liteos.gni") + +module_name = "sdk" + +kernel_module(module_name) { + sources = [ + "rtos/liteos/liteos_m/main.c", + "rtos/liteos/liteos_m/test/task_demo.c", + ] + include_dirs = [ + "rtos/liteos/liteos_m", + "rtos/liteos/liteos_m/test", + "//device/soc/espressif/esp32_wrover_ie/liteos_m/components/fs", + "//device/soc/espressif/esp32_wrover_ie/liteos_m/sdk/include/board", + "//device/soc/espressif/esp32_wrover_ie/liteos_m/sdk/include/watchdog", + "//kernel/liteos_m/include", + ] +} + +config("public") { + include_dirs = [ + "rtos/liteos/liteos_m", + "rtos/liteos/liteos_m/test", + ] + ldflags = [ + "-Wl,-T" + rebase_path("scripts/link/ESP32.ld"), + "-nostdlib", + ] + libs = [ "gcc" ] +} diff --git a/esp32_wrover_ie/liteos_m/sdk/include/board/soc.h b/esp32_wrover_ie/liteos_m/sdk/include/board/soc.h new file mode 100644 index 0000000..aa27595 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/sdk/include/board/soc.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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 + * + * Description: Provide a task example. + */ + +#ifndef _SOC_H +#define _SOC_H + +#include "los_compiler.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +extern CHAR _sbss; +extern CHAR _ebss; +extern CHAR __init_stack_e; + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif /* _SOC_H */ diff --git a/esp32_wrover_ie/liteos_m/sdk/include/watchdog/hal_watchdog.h b/esp32_wrover_ie/liteos_m/sdk/include/watchdog/hal_watchdog.h new file mode 100644 index 0000000..57c8e6e --- /dev/null +++ b/esp32_wrover_ie/liteos_m/sdk/include/watchdog/hal_watchdog.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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. + */ + +#ifndef _HAL_WATCHDOG_H +#define _HAL_WATCHDOG_H + +#include "los_compiler.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#define WDT_WRWITE_MASK 0x50d83aa1 +#define RTC_CNTL 0x3ff48000 +#define RTC_WDT_PROTECT 0x3ff480a4 +#define RTC_WDT_CFG0 0x3ff4808c +#define RTC_WDT_FEED 0x3ff480a0 +#define TIMER_GROUP0 0x3ff5F000 +#define WDT_TIMER_GROUP0_CNTL 0x3ff5F048 +#define TIMER_GROUP1 0x3ff60000 +#define WDT_TIMER_GROUP1_CNTL 0x3ff60048 +#define RTC_CNTL_WDT_FEED (31) +#define RTC_CNTL_WDT_EN (31) +#define RTC_CNTL_WDT_STG0 (28) +#define RTC_CNTL_WDT_FLASHBOOT_MOD_EN (10) +#define RTC_CNTL_WDT_INT (1) +#define RTC_CNTL_WDT_CPU_RESET (2) +#define RTC_CNTL_WDT_SYS_RESET (3) +#define RTC_CNTL_WDT_RTC_RESET (4) +#define RTC_CNTL_WDT_SYS_RESET_MASK (7) +#define RTC_CNTL_WDT_SYS_RESET_LENGTH (11) + +#define REG32_READ(reg) (*(volatile UINT32*) (reg)) +#define REG32_WRITE(reg, value) (*(volatile UINT32*) (reg) = value) + +VOID WdtEnable(VOID); +VOID WdtDisable(VOID); +VOID WdtFeed(VOID); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif /* _HAL_WATCHDOG_H */ diff --git a/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/main.c b/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/main.c new file mode 100644 index 0000000..19b30fb --- /dev/null +++ b/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/main.c @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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 +#include +#include "task_demo.h" +#include "los_task.h" +#include "los_interrupt.h" +#include "hal_watchdog.h" +#include "soc.h" +#include "fs_init.h" + +VOID BssClean(VOID) +{ + CHAR *p = &_sbss; + for (INT32 i = 0; i < &_ebss - &_sbss; i++){ + *(p + i) = 0; + } +} + +INT32 main(VOID) +{ + TaskSample(); + return 0; +} + +VOID MainThreadCreate(VOID) +{ + UINT32 ret; + UINT32 taskID; + TSK_INIT_PARAM_S stTask = {0}; + + stTask.pfnTaskEntry = (TSK_ENTRY_FUNC)main; + stTask.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; + stTask.pcName = "main"; + stTask.usTaskPrio = 2; + ret = LOS_TaskCreate(&taskID, &stTask); + if (ret != LOS_OK) { + printf("Task1 create failed\n"); + } +} + +void board_main(void) +{ + UINT32 ret; + BssClean(); + WdtDisable(); + + __asm__ __volatile__("mov sp, %0" : : "r"(&__init_stack_e)); +#ifdef __FPU_PRESENT + __asm__ __volatile__("wsr %0, CPENABLE;rsync" : : "r"(1)); +#endif + ret = LOS_KernelInit(); + FileSystemInit(); + if (ret == LOS_OK) { + MainThreadCreate(); + (VOID)LOS_Start(); + } +} diff --git a/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/target_config.h b/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/target_config.h new file mode 100644 index 0000000..c9c35c3 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/target_config.h @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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. + */ + +#ifndef _TARGET_CONFIG_H +#define _TARGET_CONFIG_H + +#include "los_compiler.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +/*============================================================================= + System clock module configuration +=============================================================================*/ +#define OS_SYS_CLOCK 80000000 +#define LOSCFG_BASE_CORE_TICK_PER_SECOND (1000UL) +#define LOSCFG_BASE_CORE_TICK_HW_TIME 0 +#define LOSCFG_BASE_CORE_TICK_WTIMER 1 +#define LOSCFG_BASE_CORE_TICK_RESPONSE_MAX 80000 + +/*============================================================================= + Hardware interrupt module configuration +=============================================================================*/ +#define LOSCFG_PLATFORM_HWI 1 +#define OS_TICK_INT_NUM 6 +#define LOSCFG_PLATFORM_HWI_LIMIT 32 +/*============================================================================= + Task module configuration +=============================================================================*/ +#define LOSCFG_BASE_CORE_TSK_LIMIT 24 +#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE (0x1000U) +#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE (0x2000U) +#define LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE (0x1000U) +#define LOSCFG_BASE_CORE_TIMESLICE 1 +#define LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT 20000 +#define LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO 15 +/*============================================================================= + Semaphore module configuration +=============================================================================*/ +#define LOSCFG_BASE_IPC_SEM 1 +#define LOSCFG_BASE_IPC_SEM_LIMIT 48 +/*============================================================================= + Mutex module configuration +=============================================================================*/ +#define LOSCFG_BASE_IPC_MUX 1 +#define LOSCFG_BASE_IPC_MUX_LIMIT 24 +/*============================================================================= + Queue module configuration +=============================================================================*/ +#define LOSCFG_BASE_IPC_QUEUE 1 +#define LOSCFG_BASE_IPC_QUEUE_LIMIT 24 +/*============================================================================= + Software timer module configuration +=============================================================================*/ +#define LOSCFG_BASE_CORE_SWTMR 1 +#define LOSCFG_BASE_CORE_SWTMR_ALIGN 1 +#define LOSCFG_BASE_CORE_SWTMR_LIMIT 48 +/*============================================================================= + Memory module configuration +=============================================================================*/ +extern UINTPTR __heap_start; +#define LOSCFG_SYS_HEAP_ADDR (CHAR *)(UINTPTR)(&__heap_start) +#define LOSCFG_SYS_EXTERNAL_HEAP 1 +#define LOSCFG_SYS_HEAP_SIZE 0x24000 +#define LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK 0 +#define LOSCFG_BASE_MEM_NODE_SIZE_CHECK 1 +#define LOSCFG_MEM_MUL_POOL 1 +#define OS_SYS_MEM_NUM 20 +#define LOSCFG_KERNEL_MEM_SLAB 0 +/*============================================================================= + Exception module configuration +=============================================================================*/ +#define LOSCFG_PLATFORM_EXC 0 + +/*============================================================================= + TestSuite configuration +=============================================================================*/ +#define LOSCFG_TEST 0 + +#define LOSCFG_BACKTRACE_TYPE 4 +#define LOSCFG_KERNEL_PRINTF 1 +#define LOSCFG_KERNEL_PM 0 +#define LFS_NO_ASSERT 1 +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif /* _TARGET_CONFIG_H */ diff --git a/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/test/task_demo.c b/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/test/task_demo.c new file mode 100644 index 0000000..f88bbff --- /dev/null +++ b/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/test/task_demo.c @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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. + * + * Description: Provide a task example. + */ + +#include "task_demo.h" +#include "stdio.h" +#include "los_task.h" + +VOID TaskSampleEntry2(VOID) +{ + while (1) { + printf("TaskSampleEntry2 running...\n"); + (VOID)LOS_TaskDelay(2000); /* 2000 millisecond */ + } +} + +VOID TaskSampleEntry1(VOID) +{ + while (1) { + printf("TaskSampleEntry1 running...\n"); + (VOID)LOS_TaskDelay(2000); /* 2000 millisecond */ + } +} + +VOID TaskSample(VOID) +{ + UINT32 ret; + UINT32 taskID1; + UINT32 taskID2; + TSK_INIT_PARAM_S stTask = {0}; + + stTask.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskSampleEntry1; + stTask.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; + stTask.pcName = "TaskSampleEntry1"; + stTask.usTaskPrio = 2; /* Os task priority is 2 */ + ret = LOS_TaskCreate(&taskID2, &stTask); + if (ret != LOS_OK) { + printf("Task1 create failed\n"); + } + + stTask.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskSampleEntry2; + stTask.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; + stTask.pcName = "TaskSampleEntry2"; + stTask.usTaskPrio = 2; /* Os task priority is 2 */ + ret = LOS_TaskCreate(&taskID2, &stTask); + if (ret != LOS_OK) { + printf("Task2 create failed\n"); + } +} diff --git a/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/test/task_demo.h b/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/test/task_demo.h new file mode 100644 index 0000000..db0e156 --- /dev/null +++ b/esp32_wrover_ie/liteos_m/sdk/rtos/liteos/liteos_m/test/task_demo.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. 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. + * + * 3. 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 THE COPYRIGHT HOLDER OR + * CONTRIBUTORS 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 + * + * Description: Provide a task example. + */ + +#ifndef _TASK_DEMO_H +#define _TASK_DEMO_H + +#include "los_compiler.h" + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +VOID TaskSample(VOID); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif /* _TASK_DEMO_H */ diff --git a/esp32_wrover_ie/liteos_m/sdk/scripts/link/ESP32.ld b/esp32_wrover_ie/liteos_m/sdk/scripts/link/ESP32.ld new file mode 100644 index 0000000..43149cf --- /dev/null +++ b/esp32_wrover_ie/liteos_m/sdk/scripts/link/ESP32.ld @@ -0,0 +1,330 @@ +/**************************************************************************** + * device/qemu/esp32/ESP32.ld + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +MEMORY { + drom (r) : ORIGIN = 0x3f400010, LENGTH = 0x800000 + extmem (rwx) : ORIGIN = 0x3f800000, LENGTH = 0x400000 + dram (rw) : ORIGIN = 0x3ffb0000, LENGTH = 0x50000 + iram_0 (rx) : ORIGIN = 0x40080000, LENGTH = 0x20000 + iram_1 (rx) : ORIGIN = 0x400D0018, LENGTH = 0x330000 +} + +_eram = ORIGIN(dram) + LENGTH(dram); + +/* Default entry point: */ +ENTRY(board_main); + +SECTIONS +{ + /* Send .iram0 code to iram */ + + .iram0.vectors : + { + /* Vectors go to IRAM */ + + _init_start = ABSOLUTE(.); + + /* Vectors according to builds/RF-2015.2-win32/esp108_v1_2_s5_512int_2/config.html */ + . = 0x0; + KEEP(*(.WindowVectors.text)); + . = 0x180; + KEEP(*(.InterruptEntry2.text)); + . = 0x1c0; + KEEP(*(.InterruptEntry3.text)); + . = 0x200; + KEEP(*(.InterruptEntry4.text)); + . = 0x240; + KEEP(*(.InterruptEntry5.text)); + . = 0x280; + KEEP(*(.DebugExceptionHandler.text)); + . = 0x2c0; + KEEP(*(.NMIExceptionHandler.text)); + . = 0x300; + KEEP(*(.KernelExceptionHandler.text)); + . = 0x340; + KEEP(*(.UserExceptionHandler.text)); + . = 0x3C0; + KEEP(*(.DoubleExceptionHandler.text)); + . = 0x400; + *(.*_vector.literal) + + . = ALIGN (16); + *(.entry.text) + *(.init.literal) + *(.init) + _init_end = ABSOLUTE(.); + } > iram_0 + + .iram0.text : + { + /* Code marked as running out of IRAM */ + + _iram_text_start = ABSOLUTE(.); + *(.iram1 .iram1.*) + *librtc.a:(.literal .text .literal.* .text.*) + *libarch.a:esp32_spiflash.*(.literal .text .literal.* .text.*) + *(.wifirxiram .wifirxiram.*) + *(.wifi0iram .wifi0iram.*) + *(.wifislpiram .wifislpiram.*) + *(.wifislprxiram .wifislprxiram.*) + *(.phyiram .phyiram.*) + + _iram_text_end = ABSOLUTE(.); + + /* IRAM heap starts at the end of iram */ + + . = ALIGN (4); + _siramheap = ABSOLUTE(.); + } > iram_0 + + /* Shared RAM */ + + .dram0.bss (NOLOAD) : + { + /* .bss initialized on power-up */ + + . = ALIGN (8); + _sbss = ABSOLUTE(.); + *(.dynsbss) + *(.sbss) + *(.sbss.*) + *(.gnu.linkonce.sb.*) + *(.scommon) + *(.sbss2) + *(.sbss2.*) + *(.gnu.linkonce.sb2.*) + *(.dynbss) + KEEP (*(.bss)) + *(.bss.*) + *(.share.mem) + *(.gnu.linkonce.b.*) + *(COMMON) + *libarch.a:esp32_spiflash.*(.bss .bss.* COMMON) + . = ALIGN(8); + __init_stack_s = ABSOLUTE(.); + . += 0x1000; + __init_stack_e = ABSOLUTE(.); + _ebss = .; + . = ALIGN(8); + _ebss = ABSOLUTE(.); + } >dram + + .dram0.data : + { + /* .data initialized on power-up in ROMed configurations. */ + + _sdata = ABSOLUTE(.); + KEEP (*(.data)) + KEEP (*(.data.*)) + KEEP (*(.gnu.linkonce.d.*)) + KEEP (*(.data1)) + KEEP (*(.sdata)) + KEEP (*(.sdata.*)) + KEEP (*(.gnu.linkonce.s.*)) + KEEP (*(.sdata2)) + KEEP (*(.sdata2.*)) + KEEP (*(.gnu.linkonce.s2.*)) + KEEP (*(.jcr)) + *(.dram1 .dram1.*) + *libphy.a:(.rodata .rodata.*) + *libarch.a:esp32_spiflash.*(.rodata .rodata.*) + . = ALIGN(4); + _edata = ABSOLUTE(.); + + /* Heap starts at the end of .data */ + + __heap_start = ABSOLUTE(.); + . += 0x24000; + . = ALIGN(4); + __heap_end = ABSOLUTE(.); + } >dram + + /* External memory bss, from any global variable with EXT_RAM_ATTR attribute */ + + .extmem.bss (NOLOAD) : + { + _sbss_extmem = ABSOLUTE(.); + *(.extmem.bss .extmem.bss.*) + . = ALIGN(4); + _ebss_extmem = ABSOLUTE(.); + } > extmem + + .flash.rodata : + { + _srodata = ABSOLUTE(.); + *(.rodata) + *(.rodata.*) + *(.irom1.text) /* catch stray ICACHE_RODATA_ATTR */ + *(.gnu.linkonce.r.*) + *(.rodata1) + __XT_EXCEPTION_TABLE_ = ABSOLUTE(.); + *(.xt_except_table) + *(.gcc_except_table) + *(.gcc_except_table.*) + *(.gnu.linkonce.e.*) + *(.gnu.version_r) + *(.eh_frame) + + . = (. + 3) & ~ 3; + + /* C++ constructor and destructor tables, properly ordered: */ + + _sinit = ABSOLUTE(.); + KEEP (*crtbegin.o(.ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + _einit = ABSOLUTE(.); + KEEP (*crtbegin.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + + /* C++ exception handlers table: */ + + __XT_EXCEPTION_DESCS_ = ABSOLUTE(.); + *(.xt_except_desc) + *(.gnu.linkonce.h.*) + __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); + *(.xt_except_desc_end) + *(.dynamic) + *(.gnu.version_d) + _erodata = ABSOLUTE(.); + /* Literals are also RO data. */ + _lit4_start = ABSOLUTE(.); + *(*.lit4) + *(.lit4.*) + *(.gnu.linkonce.lit4.*) + _lit4_end = ABSOLUTE(.); + . = ALIGN(4); + } >drom + + .flash.text : + { + _stext = .; + __text_start = ABSOLUTE(.); + *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) + *(.irom0.text) /* catch stray ICACHE_RODATA_ATTR */ + *(.fini.literal) + *(.fini) + *(.gnu.version) + . = ALIGN(4); + __zinitcall_bsp_start = .; + KEEP (*(.zinitcall.bsp0.init)) + KEEP (*(.zinitcall.bsp1.init)) + KEEP (*(.zinitcall.bsp2.init)) + KEEP (*(.zinitcall.bsp3.init)) + KEEP (*(.zinitcall.bsp4.init)) + __zinitcall_bsp_end = .; + __zinitcall_device_start = .; + KEEP (*(.zinitcall.device0.init)) + KEEP (*(.zinitcall.device1.init)) + KEEP (*(.zinitcall.device2.init)) + KEEP (*(.zinitcall.device3.init)) + KEEP (*(.zinitcall.device4.init)) + __zinitcall_device_end = .; + __zinitcall_core_start = .; + KEEP (*(.zinitcall.core0.init)) + KEEP (*(.zinitcall.core1.init)) + KEEP (*(.zinitcall.core2.init)) + KEEP (*(.zinitcall.core3.init)) + KEEP (*(.zinitcall.core4.init)) + __zinitcall_core_end = .; + __zinitcall_sys_service_start = .; + KEEP (*(.zinitcall.sys.service0.init)) + KEEP (*(.zinitcall.sys.service1.init)) + KEEP (*(.zinitcall.sys.service2.init)) + KEEP (*(.zinitcall.sys.service3.init)) + KEEP (*(.zinitcall.sys.service4.init)) + __zinitcall_sys_service_end = .; + __zinitcall_sys_feature_start = .; + KEEP (*(.zinitcall.sys.feature0.init)) + KEEP (*(.zinitcall.sys.feature1.init)) + KEEP (*(.zinitcall.sys.feature2.init)) + KEEP (*(.zinitcall.sys.feature3.init)) + KEEP (*(.zinitcall.sys.feature4.init)) + __zinitcall_sys_feature_end = .; + __zinitcall_run_start = .; + KEEP (*(.zinitcall.run0.init)) + KEEP (*(.zinitcall.run1.init)) + KEEP (*(.zinitcall.run2.init)) + KEEP (*(.zinitcall.run3.init)) + KEEP (*(.zinitcall.run4.init)) + __zinitcall_run_end = .; + __zinitcall_app_service_start = .; + KEEP (*(.zinitcall.app.service0.init)) + KEEP (*(.zinitcall.app.service1.init)) + KEEP (*(.zinitcall.app.service2.init)) + KEEP (*(.zinitcall.app.service3.init)) + KEEP (*(.zinitcall.app.service4.init)) + __zinitcall_app_service_end = .; + __zinitcall_app_feature_start = .; + KEEP (*(.zinitcall.app.feature0.init)) + KEEP (*(.zinitcall.app.feature1.init)) + KEEP (*(.zinitcall.app.feature2.init)) + KEEP (*(.zinitcall.app.feature3.init)) + KEEP (*(.zinitcall.app.feature4.init)) + __zinitcall_app_feature_end = .; + __zinitcall_test_start = .; + KEEP (*(.zinitcall.test0.init)) + KEEP (*(.zinitcall.test1.init)) + KEEP (*(.zinitcall.test2.init)) + KEEP (*(.zinitcall.test3.init)) + KEEP (*(.zinitcall.test4.init)) + __zinitcall_test_end = .; + __zinitcall_exit_start = .; + KEEP (*(.zinitcall.exit0.init)) + KEEP (*(.zinitcall.exit1.init)) + KEEP (*(.zinitcall.exit2.init)) + KEEP (*(.zinitcall.exit3.init)) + KEEP (*(.zinitcall.exit4.init)) + __zinitcall_exit_end = .; + + __text_end = ABSOLUTE(.); + _etext = .; + } >iram_1 + +} + +PROVIDE ( uartAttach = 0x40008fd0 ); +PROVIDE ( uart_baudrate_detect = 0x40009034 ); +PROVIDE ( uart_buff_switch = 0x400093c0 ); +PROVIDE ( UartConnCheck = 0x40008738 ); +PROVIDE ( UartConnectProc = 0x40008a04 ); +PROVIDE ( UartDev = 0x3ffe019c ); +PROVIDE ( uart_div_modify = 0x400090cc ); +PROVIDE ( UartDwnLdProc = 0x40008ce8 ); +PROVIDE ( UartGetCmdLn = 0x40009564 ); +PROVIDE ( Uart_Init = 0x40009120 ); +PROVIDE ( UartRegReadProc = 0x40008a58 ); +PROVIDE ( UartRegWriteProc = 0x40008a14 ); +PROVIDE ( uart_rx_intr_handler = 0x40008f4c ); +PROVIDE ( uart_rx_one_char = 0x400092d0 ); +PROVIDE ( uart_rx_one_char_block = 0x400092a4 ); +PROVIDE ( uart_rx_readbuff = 0x40009394 ); +PROVIDE ( UartRxString = 0x400092fc ); +PROVIDE ( UartSetBaudProc = 0x40008aac ); +PROVIDE ( UartSpiAttachProc = 0x40008a6c ); +PROVIDE ( UartSpiReadProc = 0x40008a80 ); +PROVIDE ( uart_tx_flush = 0x40009258 ); +PROVIDE ( uart_tx_one_char = 0x40009200 ); +PROVIDE ( uart_tx_one_char2 = 0x4000922c ); +PROVIDE ( uart_tx_switch = 0x40009028 ); +PROVIDE ( uart_tx_wait_idle = 0x40009278 ); diff --git a/esp32_wrover_ie/pack_tools/bootloader.bin b/esp32_wrover_ie/pack_tools/bootloader.bin new file mode 100644 index 0000000..d43cbbc Binary files /dev/null and b/esp32_wrover_ie/pack_tools/bootloader.bin differ diff --git a/esp32_wrover_ie/pack_tools/partition-table.bin b/esp32_wrover_ie/pack_tools/partition-table.bin new file mode 100644 index 0000000..8e82653 Binary files /dev/null and b/esp32_wrover_ie/pack_tools/partition-table.bin differ diff --git a/esp32_wrover_ie/readme_zh.md b/esp32_wrover_ie/readme_zh.md new file mode 100644 index 0000000..515f5d7 --- /dev/null +++ b/esp32_wrover_ie/readme_zh.md @@ -0,0 +1,43 @@ +# ESP32_WROVER_IE + +* [简介]() + +* [目录]() + +* [相关仓]() + +# 简介 + +## 开发板概述 + +ESP32_DEVKITC_V4是乐鑫一款基于ESP32_WROVER_IE的小型开发板。单模组采用了ESP32系列的ESP32-D0WD-V3芯片(xtensa 32-bit LX6 双核处理器),CPU时钟频率可调节为80MHz到240MHz,配置4MB SPI flash和8MB SPI PSRAM,集成传统蓝牙、低功耗蓝牙和Wi-Fi。可以用于低功耗传感器网络和要求极高的任务,例如语音编码、音频流和 MP3 解码等。 + +# 目录 + +``` +device/soc/espressif +├── esp_wrover_ie # 芯片SOC名称 +│ ├── pack_tools # 打包烧录包工具目录 +│ └── liteos_m # 基于liteos_m的bsp适配目录 +│ ├── components # 组件服务层代码目录 +│ │ ├── drivers # 驱动适配目录 +│ │ ├── fs # 文件系统适配目录 +│ │ └── utils # 组件系统适配目录 +│ ├── hals # hals适配目录 +│ └── sdk # sdk模块的目录 +│ ├── include # 编译头文件目录 +│ ├── rtos # 系统启动代码目录 +│ └── scripts # 链接脚本目录 +├── Kconfig.liteos_m.defconfig.esp32 # esp32 kconfig 默认宏配置 +├── Kconfig.liteos_m.series # esp32_wrover_ie系列soc配置宏 +└── Kconfig.liteos_m.soc # soc kconfig配置宏 +``` + +# 说明 + +适配鸿蒙编译集成bsp的目录 + +# 相关仓 + +* [device/soc/espressif](https://gitee.com/openharmony-sig/device_soc_espressif) +