diff --git a/.gitignore b/.gitignore index 14abf374b63ebf2cdf3f74c3dc36c6077b581ae3..7382682ac76b9365236a197a81f9796d983b4651 100644 --- a/.gitignore +++ b/.gitignore @@ -62,7 +62,16 @@ dkms.conf /tools/gcc-* /tools/gdb-* +#pyc files +*.pyc +.vscode + # Standalone sdk standalone sdk -phytium-standalone-sdk \ No newline at end of file +phytium-standalone-sdk + + + +#vim +tags \ No newline at end of file diff --git a/.gitlab/README_TEMPLATE.zh-CN.md b/.gitlab/README_TEMPLATE.zh-CN.md index 547b70118eb7b5db78d6ba9746fd496d736e7503..05d67f0d83b7aa92ca7098fdbc2e542fd3e2d67b 100644 --- a/.gitlab/README_TEMPLATE.zh-CN.md +++ b/.gitlab/README_TEMPLATE.zh-CN.md @@ -1,16 +1,26 @@ + # XXX ## 1. 例程介绍 diff --git a/.gitlab/merge_request_templates/PULL_REQUEST_TEMPLATE.md b/.gitlab/merge_request_templates/PULL_REQUEST_TEMPLATE.md index 55b8b555888777ab6b276977c78c62f2ad97c4d1..0c9823b535e95670b616d6cb36992d19acb95653 100644 --- a/.gitlab/merge_request_templates/PULL_REQUEST_TEMPLATE.md +++ b/.gitlab/merge_request_templates/PULL_REQUEST_TEMPLATE.md @@ -1,16 +1,3 @@ - ## 拉取/合并请求描述: [ diff --git a/Kconfig b/Kconfig index d22317f33de30a07e420cbee4adb760cd841f023..1ea89052497f9849211da9ce6c3ad8fde9d5fbcc 100644 --- a/Kconfig +++ b/Kconfig @@ -19,6 +19,8 @@ endmenu menu "Building Option" source "$(STANDALONE_DIR)/common/Kconfig" source "$(FREERTOS_SDK_ROOT)/make/ld/Kconfig" + source "$(FREERTOS_SDK_ROOT)/make/Kconfig" + endmenu menu "Component Configuration" diff --git a/LICENSE b/LICENSE index 261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64..30bd97be52ed4087906faa129dcaac47fe493d1f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,201 +1,28 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ + + Phytium Public License 1.0 (PPL-1.0) - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +UNLESS IT HAS ITS OWN COPYRIGHT/LICENSE EMBEDDED IN ITS BODY, EACH FILE IS SUBJECT TO THE FOLLOWING LICENSE TERMS - 1. Definitions. +Copyright (C) 2022, Phytium Technology Co., Ltd. +All Rights Reserved. - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. +Redistribution and use in source and binary forms, with or without modification, are permitted provided that +the following conditions are met: - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the +following disclaimer. - "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. +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. - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. +3. If the name of phytium or the names of its contributors are needed to endorse or promote products +derived from this software ,Prior written permission should be required. - "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 - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. +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. \ No newline at end of file diff --git a/README.md b/README.md index fcb1ef871b1bdc6ca05277dcdbdba7ffe5320ea6..c8fa1163359fa20fee0e507a9809f60146e4eeb8 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,26 @@ + # Phytium-FreeRTOS-SDK ## 1. 介绍 @@ -92,8 +102,10 @@ zhugengyu@phytium.com.cn wangxiaodong1030@phytium.com.cn +liushengming1118@phytium.com.cn + --- ## 6. 许可协议 -Apache-2.0 \ No newline at end of file +Phytium Public License 1.0 (PPL-1.0) \ No newline at end of file diff --git a/docs/Changlog.md b/docs/Changlog.md index 70b22bbb03d64b063310ffd996d6c74349982522..2a64c543741e53dafff2a47a9aac3fb0c9817ecd 100644 --- a/docs/Changlog.md +++ b/docs/Changlog.md @@ -1,16 +1,62 @@ +# Phytium FreeRTOS SDK 0.0.7 ChangeLog + +Change Log sinc 2022-03-21,2022-04-20 + +## example + +- adapt to the new standalone sdk v0.1.17 + +- add Linux OpenAMP example for freertos + +## make + +- Modified some variable positions and added some configuration related variables + + +# Phytium FreeRTOS SDK 2022-03-21 ChangeLog + +Change Log sinc 0.0.6, 2022.03.21 + +## example + +- adapt to the new standalone sdk v0.1.16 + +- add OpenAMP for FreeRTOS + +## third-party + +- add OpenAMP for freertos application +- add Letter_shell for freertos + +## LICENSE + +- replace LICENSE with Phytium Public License 1.0 (PPL-1.0) +- update file COPYRIGHT declaration with PPL-1.0 + + + # Phytium FreeRTOS SDK v0.0.6 ChangeLog Change Log sinc 0.0.5, 2021.12.23 diff --git a/docs/reference/usr/install_linux_aarch64.md b/docs/reference/usr/install_linux_aarch64.md index 8abaf3271bc73fc0974b561938ea5abbf7a7d332..cc46e19222abfac0ee4cf15e3dc8ecfc5a386caf 100644 --- a/docs/reference/usr/install_linux_aarch64.md +++ b/docs/reference/usr/install_linux_aarch64.md @@ -1,20 +1,30 @@ + # 1. Linux arm aarch64 SDK安装方法 -Linux arm aarch64下通过下载SDK开发工具包完成安装,运行脚本`./setup_dev.py`完成安装,安装前请先确认当前设备属于`Linux arm aarch64` +Linux arm aarch64下通过下载SDK开发工具包完成安装,运行脚本`source ./setup_dev.sh`完成安装,安装前请先确认当前设备属于`Linux arm aarch64` ![linux-aarch64](https://images.gitee.com/uploads/images/2021/1019/171438_af96408a_8736513.png "linux-aarch64.png") diff --git a/docs/reference/usr/install_linux_x86_64.md b/docs/reference/usr/install_linux_x86_64.md index ce1fb727da28dcf4efd77e9b03c13c21d2834191..4a078cea2744ef0afe698439f7608e0dac651d9f 100644 --- a/docs/reference/usr/install_linux_x86_64.md +++ b/docs/reference/usr/install_linux_x86_64.md @@ -1,20 +1,30 @@ + # 1. Linux x86_64 SDK安装方法 -Linux x86_64下通过下载SDK开发工具包完成安装,运行脚本`./setup_dev.py`完成安装,安装前请先确认当前设备属于`Linux x86_64` +Linux x86_64下通过下载SDK开发工具包完成安装,运行脚本`source ./setup_dev.sh`完成安装,安装前请先确认当前设备属于`Linux x86_64` ![linux-x86_64](https://images.gitee.com/uploads/images/2021/1019/095533_a960e2a6_8736513.png "linux-x86_64.png") diff --git a/docs/reference/usr/install_windows.md b/docs/reference/usr/install_windows.md index e5c29f02792314c9ffba5dd3b4b8300a68acb11c..749fdeec3708a51f8502fc18bac1fed233b46454 100644 --- a/docs/reference/usr/install_windows.md +++ b/docs/reference/usr/install_windows.md @@ -1,16 +1,26 @@ + # 1. Windows10 SDK安装方法 Windows 10 SDK开发环境集成了, diff --git a/docs/reference/usr/usage.md b/docs/reference/usr/usage.md index 0be6754aa259bb1cd2833d4ec3e220de32a1d145..53a1255c271d81c4e1d03507ba7d471933405cd2 100644 --- a/docs/reference/usr/usage.md +++ b/docs/reference/usr/usage.md @@ -1,17 +1,27 @@ + # 1. 使用方法 ## 1.1 新建一个 freertos 应用工程 diff --git a/drivers/drivers.mk b/drivers/drivers.mk index ddbefdda7e48a2485310ec320f1c3919e5d88205..b4e375b8a291158c70413d3f0903e3127284eced 100644 --- a/drivers/drivers.mk +++ b/drivers/drivers.mk @@ -1,3 +1,6 @@ +OS_DRIVER_CUR_DIR := $(FREERTOS_SDK_ROOT)/drivers + ifdef CONFIG_FREERTOS_USE_UART - + SRC_DIR += $(OS_DRIVER_CUR_DIR)/serial/fpl011 + INC_DIR += $(OS_DRIVER_CUR_DIR)/serial/fpl011 endif \ No newline at end of file diff --git a/drivers/ft_os_uart.c b/drivers/serial/fpl011/fpl011_os.c similarity index 32% rename from drivers/ft_os_uart.c rename to drivers/serial/fpl011/fpl011_os.c index 674ac4c698f6c7b0d29267b361cea345c23a12cc..d6dfdda27495eb914a60944bc3025483665a3909 100644 --- a/drivers/ft_os_uart.c +++ b/drivers/serial/fpl011/fpl011_os.c @@ -1,19 +1,29 @@ /* - * @ : Copyright (c) 2020 Phytium Information Technology, Inc. - * The right to copy, distribute, modify, or otherwise make use - * of this software may be licensed only pursuant to the terms - * of an applicable Phytium license agreement. - * @Date: 2021-04-07 09:53:07 - * @LastEditTime: 2021-04-07 15:40:07 - * @Description:  This files is for + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * * - * @Modify History: + * FilePath: fpl011_os.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 16:59:51 + * Description:  This file is for + * + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ -#include "ft_os_uart.h" -#include "pl011_uart.h" +#include "fpl011_os.h" +#include "fpl011.h" +#include "fpl011_hw.h" #include "interrupt.h" #include "ft_types.h" #include "ft_assert.h" @@ -23,81 +33,113 @@ #ifdef CONFIG_FREERTOS_USE_UART /* Callback events */ + + +static void FPl011IrqClearReciveTimeOut(FPl011 *uart_p) +{ + u32 reg_temp; + reg_temp = FPl011GetInterruptMask(uart_p); + reg_temp &= ~FPL011MIS_RTMIS; + FPl011SetInterruptMask(uart_p, reg_temp); +} + +static void FPl011IrqEnableReciveTimeOut(FPl011 *uart_p) +{ + u32 reg_temp; + reg_temp = FPl011GetInterruptMask(uart_p); + reg_temp |= FPL011MIS_RTMIS; + FPl011SetInterruptMask(uart_p, reg_temp); +} + static void FtFreeRtosUartCallback(void *args, u32 event, u32 event_data) { + FtFreertosUart *uart_p = (FtFreertosUart *)args; BaseType_t xhigher_priority_task_woken = pdFALSE; BaseType_t x_result = pdFALSE; - if (FUART_EVENT_RECV_DATA == event || FUART_EVENT_RECV_TOUT == event) + if (FPL011_EVENT_RECV_DATA == event || FPL011_EVENT_RECV_TOUT == event) { x_result = xEventGroupSetBitsFromISR(uart_p->rx_event, RTOS_UART_COMPLETE, &xhigher_priority_task_woken); } - else if (FUART_EVENT_RECV_ERROR == event) + else if (FPL011_EVENT_RECV_ERROR == event) { x_result = xEventGroupSetBitsFromISR(uart_p->rx_event, RTOS_UART_RECV_ERROR, &xhigher_priority_task_woken); } - else if (FUART_EVENT_SENT_DATA == event) + else if (FPL011_EVENT_SENT_DATA == event) { - - x_result = xEventGroupSetBitsFromISR(uart_p->tx_event, RTOS_UART_RECV_ERROR, &xhigher_priority_task_woken); + x_result = xEventGroupSetBitsFromISR(uart_p->tx_event, RTOS_UART_COMPLETE, &xhigher_priority_task_woken); } - else if (FUART_EVENT_PARE_FRAME_BRKE == event) + else if (FPL011_EVENT_PARE_FRAME_BRKE == event) { x_result = xEventGroupSetBitsFromISR(uart_p->rx_event, RTOS_UART_RECV_ERROR, &xhigher_priority_task_woken); } - else if (FUART_EVENT_RECV_ORERR == event) + else if (FPL011_EVENT_RECV_ORERR == event) { } - if (FUART_EVENT_SENT_DATA == event) + if (FPL011_EVENT_SENT_DATA == event) { } else { - Pl011IrqClearReciveTimeOut(&uart_p->bsp_uart); + FPl011IrqClearReciveTimeOut(&uart_p->bsp_uart); } if (x_result != pdFAIL) { portYIELD_FROM_ISR(xhigher_priority_task_woken); } -} -static void FtFreertosUartIrq(s32 vector, void *param) -{ - Pl011InterruptHandler(param); } void FtFreertosUartInit(FtFreertosUart *uart_p, FtFreertosUartConfig *config_p) { - Pl011 *bsp_uart_p = NULL; - ft_error_t ret; - FT_ASSERTVOID(uart_p != NULL); - FT_ASSERTVOID(config_p != NULL); + FPl011 *bsp_uart_p = NULL; + FError ret; + u32 intr_mask; + FPl011Config driver_config; + FASSERT(uart_p != NULL); + FASSERT(config_p != NULL); bsp_uart_p = &uart_p->bsp_uart; - ret = Pl011CfgInitialize(bsp_uart_p, Pl011LookupConfig(config_p->uart_instance)); - FT_ASSERTVOID(FT_SUCCESS == ret); - Pl011SetHandler(bsp_uart_p, FtFreeRtosUartCallback, uart_p); - FT_ASSERTVOID((uart_p->rx_semaphore = xSemaphoreCreateMutex()) != NULL); - FT_ASSERTVOID((uart_p->tx_semaphore = xSemaphoreCreateMutex()) != NULL); - FT_ASSERTVOID((uart_p->tx_event = xEventGroupCreate()) != NULL); - FT_ASSERTVOID((uart_p->rx_event = xEventGroupCreate()) != NULL); - InterruptSetPriority(bsp_uart_p->config.irq_num, 0xd0); - InterruptInstall(bsp_uart_p->config.irq_num, FtFreertosUartIrq, bsp_uart_p, "uart1"); + uart_p->config = *config_p; + driver_config = *FPl011LookupConfig(config_p->uart_instance); + ret = FPl011CfgInitialize(bsp_uart_p, &driver_config); + FASSERT(FT_SUCCESS == ret); + FPl011SetHandler(bsp_uart_p, FtFreeRtosUartCallback, uart_p); + FASSERT((uart_p->rx_semaphore = xSemaphoreCreateMutex()) != NULL); + FASSERT((uart_p->tx_semaphore = xSemaphoreCreateMutex()) != NULL); + FASSERT((uart_p->tx_event = xEventGroupCreate()) != NULL); + FASSERT((uart_p->rx_event = xEventGroupCreate()) != NULL); + + + FPl011SetRxFifoThreadhold(bsp_uart_p,FPL011IFLS_RXIFLSEL_1_4); + FPl011SetTxFifoThreadHold(bsp_uart_p,FPL011IFLS_TXIFLSEL_1_2); + intr_mask = config_p->isr_event_mask; + FPl011SetInterruptMask(bsp_uart_p,intr_mask); + FPl011SetOptions(bsp_uart_p, FPL011_OPTION_UARTEN | FPL011_OPTION_RXEN | FPL011_OPTION_TXEN | FPL011_OPTION_FIFOEN); + + + InterruptSetPriority(bsp_uart_p->config.irq_num, config_p->isr_priority); + InterruptInstall(bsp_uart_p->config.irq_num, FPl011InterruptHandler, bsp_uart_p, "uart1"); InterruptUmask(bsp_uart_p->config.irq_num); - Pl011SetOptions(bsp_uart_p, FUART_OPTION_UARTEN | FUART_OPTION_RXEN | FUART_OPTION_TXEN | FUART_OPTION_FIFOEN); } -s32 FtFreertosUartReceiveBuffer(FtFreertosUart *uart_p, u8 *buffer, u32 length, u32 *received_length) +FError FtFreertosUartReceiveBuffer(FtFreertosUart *uart_p, u8 *buffer, u32 length, u32 *received_length) { u32 get_length; - ft_error_t ret = FT_SUCCESS; - Pl011 *bsp_uart_p = NULL; + FError ret = FT_SUCCESS; + FPl011 *bsp_uart_p = NULL; EventBits_t ev; - FT_ASSERTNONVOID(NULL != uart_p); - FT_ASSERTNONVOID(NULL != buffer); + FASSERT(NULL != uart_p); + FASSERT(NULL != buffer); bsp_uart_p = &uart_p->bsp_uart; + if(length == 0) + { + *received_length = 0; + return FT_SUCCESS; + } + /* New transfer can be performed only after current one is finished */ if (pdFALSE == xSemaphoreTake(uart_p->rx_semaphore, portMAX_DELAY)) { @@ -105,41 +147,52 @@ s32 FtFreertosUartReceiveBuffer(FtFreertosUart *uart_p, u8 *buffer, u32 length, ret = FREERTOS_UART_SEM_ERROR; } - get_length = Pl011Receive(bsp_uart_p, buffer, length); - if (get_length > 0) - { - *received_length = get_length; - ret = FT_SUCCESS; - } - else - { - Pl011IrqEnableReciveTimeOut(bsp_uart_p); - ev = xEventGroupWaitBits(uart_p->rx_event, - RTOS_UART_COMPLETE | RTOS_UART_HARDWARE_BUFFER_OVERRUN | RTOS_UART_RECV_ERROR, - pdTRUE, pdFALSE, portMAX_DELAY); - if (ev & RTOS_UART_HARDWARE_BUFFER_OVERRUN) - { - ret = FREERTOS_UART_FIFO_ERROR; - *received_length = 0; - } - else if (ev & RTOS_UART_COMPLETE) + if(uart_p->config.isr_event_mask & (RTOS_UART_ISR_RTIM_MASK|RTOS_UART_ISR_RXIM_MASK) ) + { + get_length = FPl011Receive(bsp_uart_p, buffer, length); + if (get_length > 0) { + *received_length = get_length; ret = FT_SUCCESS; - *received_length = bsp_uart_p->receive_buffer.requested_bytes - bsp_uart_p->receive_buffer.remaining_bytes; - } - else if (ev & RTOS_UART_RECV_ERROR) - { - ret = FREERTOS_UART_RECV_ERROR; - *received_length = 0; } else { - ret = FREERTOS_UART_INVAILD_PARAM; - *received_length = 0; + FPl011IrqEnableReciveTimeOut(bsp_uart_p); + + ev = xEventGroupWaitBits(uart_p->rx_event, + RTOS_UART_COMPLETE | RTOS_UART_HARDWARE_BUFFER_OVERRUN | RTOS_UART_RECV_ERROR, + pdTRUE, pdFALSE, portMAX_DELAY); + + if (ev & RTOS_UART_HARDWARE_BUFFER_OVERRUN) + { + ret = FREERTOS_UART_FIFO_ERROR; + *received_length = 0; + } + else if (ev & RTOS_UART_COMPLETE) + { + ret = FT_SUCCESS; + *received_length = bsp_uart_p->receive_buffer.requested_bytes - bsp_uart_p->receive_buffer.remaining_bytes; + } + else if (ev & RTOS_UART_RECV_ERROR) + { + ret = FREERTOS_UART_RECV_ERROR; + *received_length = 0; + } + else + { + ret = FREERTOS_UART_INVAILD_PARAM; + *received_length = 0; + } } } + else + { + buffer[0] = FPl011BlockReceive(bsp_uart_p); + *received_length = 1; + ret = FT_SUCCESS; + } /* Enable next transfer. Current one is finished */ if (pdFALSE == xSemaphoreGive(uart_p->rx_semaphore)) @@ -152,25 +205,36 @@ s32 FtFreertosUartReceiveBuffer(FtFreertosUart *uart_p, u8 *buffer, u32 length, return ret; } -s32 FtFreertosUartBlcokingSend(FtFreertosUart *uart_p, u8 *buffer, u32 length) +FError FtFreertosUartBlcokingSend(FtFreertosUart *uart_p, u8 *buffer, u32 length) { - ft_error_t ret = FT_SUCCESS; - Pl011 *bsp_uart_p = NULL; + FError ret = FT_SUCCESS; + FPl011 *bsp_uart_p = NULL; EventBits_t ev; - FT_ASSERTNONVOID(NULL == uart_p); - FT_ASSERTNONVOID(NULL == buffer); + u32 send_length; + FASSERT(NULL != uart_p); + FASSERT(NULL != buffer); bsp_uart_p = &uart_p->bsp_uart; if (pdFALSE == xSemaphoreTake(uart_p->tx_semaphore, portMAX_DELAY)) { return FREERTOS_UART_SEM_ERROR; } - Pl011Send(bsp_uart_p, buffer, length); - ev = xEventGroupWaitBits(uart_p->tx_event, RTOS_UART_COMPLETE, pdTRUE, pdFALSE, portMAX_DELAY); - if (!(ev & RTOS_UART_COMPLETE)) + if(uart_p->config.isr_event_mask & RTOS_UART_ISR_TXIM_MASK) + { + send_length = FPl011Send(bsp_uart_p, buffer, length); + if(send_length != length) + { + ev = xEventGroupWaitBits(uart_p->tx_event, RTOS_UART_COMPLETE, pdTRUE, pdFALSE, portMAX_DELAY); + if (!(ev & RTOS_UART_COMPLETE)) + { + ret = FREERTOS_UART_EVENT_ERROR; + } + } + } + else { - ret = FREERTOS_UART_EVENT_ERROR; + FPl011BlockSend(bsp_uart_p,buffer,length); } if (pdFALSE == xSemaphoreGive(uart_p->tx_semaphore)) diff --git a/drivers/ft_os_uart.h b/drivers/serial/fpl011/fpl011_os.h similarity index 44% rename from drivers/ft_os_uart.h rename to drivers/serial/fpl011/fpl011_os.h index 7c75ccdc1c6ee3dce1347be4a61df7f4a9c3daaf..7a66543ab81e0dff7a7b78ab31e59d89490c6e6c 100644 --- a/drivers/ft_os_uart.h +++ b/drivers/serial/fpl011/fpl011_os.h @@ -1,25 +1,36 @@ /* - * @ : Copyright (c) 2020 Phytium Information Technology, Inc. - * The right to copy, distribute, modify, or otherwise make use - * of this software may be licensed only pursuant to the terms - * of an applicable Phytium license agreement. - * @Date: 2021-04-07 09:53:07 - * @LastEditTime: 2021-04-07 15:40:12 - * @Description:  This files is for + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * * - * @Modify History: + * FilePath: fpl011_os.h + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 16:59:58 + * Description:  This file is for + * + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ -#ifndef FT_OS_UART_H -#define FT_OS_UART_H + +#ifndef DRIVERS_SERIAL_FPL011_H +#define DRIVERS_SERIAL_FPL011_H #include #include #include #include "ft_error_code.h" -#include "pl011_uart.h" +#include "fpl011.h" +#include "fpl011_hw.h" #include "ft_types.h" #define FREERTOS_UART_SEM_ERROR FT_CODE_ERR(ErrModPort, 0, 0x1) @@ -28,10 +39,10 @@ #define FREERTOS_UART_RECV_ERROR FT_CODE_ERR(ErrModPort, 0, 0x4) #define FREERTOS_UART_INVAILD_PARAM FT_CODE_ERR(ErrModPort, 0, 0x5) -#define UART0_ID FT_UART0_ID -#define UART1_ID FT_UART1_ID -#define UART2_ID FT_UART2_ID -#define UART3_ID FT_UART3_ID +#define UART0_ID FUART0_ID +#define UART1_ID FUART1_ID +#define UART2_ID FUART2_ID +#define UART3_ID FUART3_ID /*! * @cond RTOS_PRIVATE @@ -49,16 +60,26 @@ /*@}*/ +#define RTOS_UART_ISR_OEIM_MASK FPL011IMSC_OEIM /* Overrun error interrupt mask. */ +#define RTOS_UART_ISR_BEIM_MASK FPL011IMSC_BEIM /* Break error interrupt mask */ +#define RTOS_UART_ISR_PEIM_MASK FPL011IMSC_PEIM /* Parity error interrupt mask. */ +#define RTOS_UART_ISR_FEIM_MASK FPL011IMSC_FEIM /* Framing error interrupt mask. */ +#define RTOS_UART_ISR_RTIM_MASK FPL011IMSC_RTIM /* Receive timeout interrupt mask. */ +#define RTOS_UART_ISR_TXIM_MASK FPL011IMSC_TXIM /* Transmit interrupt mask. */ +#define RTOS_UART_ISR_RXIM_MASK FPL011IMSC_RXIM /* Receive interrupt mask. */ + typedef struct { u32 uart_instance; /* select uart global object */ u32 isr_priority; /* irq Priority */ + u32 isr_event_mask; /* followed by RTOS_UART_ISR_XX */ } FtFreertosUartConfig; typedef struct { - // Ft_Uart UartObj; /* Uart Object */ - Pl011 bsp_uart; + /* Uart Object */ + FPl011 bsp_uart; + FtFreertosUartConfig config; SemaphoreHandle_t rx_semaphore; /*!< RX semaphore for resource sharing */ SemaphoreHandle_t tx_semaphore; /*!< TX semaphore for resource sharing */ EventGroupHandle_t rx_event; /*!< RX completion event */ @@ -66,7 +87,7 @@ typedef struct } FtFreertosUart; void FtFreertosUartInit(FtFreertosUart *uart_p, FtFreertosUartConfig *config_p); -s32 FtFreertosUartBlcokingSend(FtFreertosUart *uart_p, u8 *buffer, u32 length); -s32 FtFreertosUartReceiveBuffer(FtFreertosUart *uart_p, u8 *buffer, u32 length, u32 *received_length); +FError FtFreertosUartBlcokingSend(FtFreertosUart *uart_p, u8 *buffer, u32 length); +FError FtFreertosUartReceiveBuffer(FtFreertosUart *uart_p, u8 *buffer, u32 length, u32 *received_length); #endif // ! diff --git a/example/amp/openamp/README.md b/example/amp/openamp/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1187ef6c34a51cd72bb5c739b23e7f2be2efcb86 --- /dev/null +++ b/example/amp/openamp/README.md @@ -0,0 +1,188 @@ +# OPENAMP 测试 + +## 1. 例程介绍 + +>介绍例程的用途,使用场景,相关基本概念,描述用户可以使用例程完成哪些工作
+ +- OpenAMP(Open Asymmetric Multi-processing) 是一个软件架构,为多核之间非对称运行提供软件支持 。 + +- OpenAMP 提供了以下关键特性: + +1. 提供生命周期管理 + +2. 兼容裸跑、RTOS等不同的软件环境 + +3. 兼容linux系统中的 remoteproc, rpmsg and VirtIO 模块 + +- 本例程基于开源openamp项目 +[OpenAMP](https://github.com/OpenAMP/open-amp.git) + +- 本例程主要提供了D2000/FT2004 裸机与裸机之间的测试例程 ,D2000裸机 与 linux kernel 的例程 + +## 2. 如何使用例程 + +>描述开发平台准备,使用例程配置,构建和下载镜像的过程
+ + +### 2.1 硬件配置方法 + +>哪些硬件平台是支持的,需要哪些外设,例程与开发板哪些IO口相关等(建议附录开发板照片,展示哪些IO口被引出)
+ +1. 准备一块ft2000/4 或者d2000 开发板 +2. 将串口连接好电脑,波特率设为 115200-8-1-N + +### 2.2 SDK配置方法 + +>依赖哪些驱动、库和第三方组件,如何完成配置(列出需要使能的关键配置项)
+- 本例子已经提供好具体的编译指令,以下进行介绍: + 1. make core0 将./core0 目录下的工程进行编译 + 2. make core1 将./core1 目录下的工程进行编译 + 3. make clean_core0 将./core0 目录下的工程进行清理 + 4. make clean_core1 将./core1 目录下的工程进行清理 + 5. make boot_core0 将./core0 目录下的编译后的elf 复制到目标地址 + 6. make boot_core1 将./core1 目录下的编译后的elf 复制到目标地址 + 7. make config_amp_d2000_aarch64 将预设64bit d2000 下的配置分别加载至 ./core0 ./core1 + 8. make config_amp_d2000_aarch32 将预设32bit d2000 下的配置分别加载至 ./core0 ./core1 + 9. make config_amp_ft2004_aarch64 将预设64bit ft2004 下的配置分别加载至 ./core0 ./core1 + 10. make config_amp_ft2004_aarch32 将预设32bit ft2004 下的配置分别加载至 ./core0 ./core1 + 11. make menuconfig_core0 配置./core0 目录下的配置变量 + 12. make menuconfig_core1 配置./core1 目录下的配置变量 + 13. make all 编译./core0 ./core1 下的项目工程 + 14. make clean 清理./core0 ./core1 下的编译结果 + 15. make boot 将 ./core0 ./core1 下的目标elf 复制到目标路径下 + +- 具体使用方法为: + - 在 //example/amp/openamp 下 + - 使用以上指令 + +### 2.3 构建和下载 + +>描述构建、烧录下载镜像的过程,列出相关的命令
+ +#### OpenAMP 配置 +![OpenAMP配置](./figs/OpenAmpConfig.png) + +#### core0 构建配置 +![core0配置2](./figs/Core0Openampconfig.png) + +#### core1 构建配置 +![core1配置2](./figs/Core1Openampconfig.png) + + + +- Remoteproc use ipi : 使用ipi 中断模式进行提醒 +- Openamp resource address : OpenAMP 中共享资源表中地址 +- Vring tx address : 共享发送缓冲区的起始地址,同时也是共享buffer 区域的起始地址 +- Vring rx address : 共享接收缓冲区的起始地址 +- table of base physical address of each of the pages in the I/O region : 用于核心间提醒机制的共享内存初始点 + +- DEBUG_CODE : 增加裸跑shell 功能 +- Destination CPU communication mask : 主核心用于唤醒从核的掩码 +- Destination IPI mask : ipi 中断中,用于唤醒其他核心的掩码 +- Spin-lock shared memory : 互斥锁中关注的共享内存 + +- Select mem default attribute : 提供内存属性选择 + +### 2.4 输出与实验现象 + +>描述输入输出情况,列出存在哪些输入,对应的输出是什么(建议附录相关现象图片)
+ +#### D2000/FT2004 aarch32 裸跑程序测试 (裸机间) + +1. 在编译环境下,切换至 phytium-standalone-sdk/baremetal/example/system/amp/openamp 目录 +1.1 输入 'make config_amp_d2000_aarch32' 加载默认D2000配置信息,或者输入 'make config_amp_ft2004_aarch32' 加载默认ft2004配置信息 +1.2 输入 'make all' 编译core0 / core1 代码,并且生成对应的elf 文件 +1.3 先将 ./core0/makefile 与 ./core1/makefile 中 的 USR_BOOT_DIR 修改为您的tftp 所覆盖的目录 +1.4 输入 'make boot' 将生成的elf 拷贝至 tftp 的目录下 + +2. 使用串口连接D2000/FT2004 开发板 ,并且打开串口终端工具 +2.1 复位开发板之后,将D2000/FT2004 开发板的网络与tftp 服务器在同一局域网中 +2.2 在中断工具下输入以下命令 + +``` + setenv ipaddr 192.168.4.20 + setenv serverip 192.168.4.50 + setenv gatewayip 192.168.4.1 + tftpboot f0000000 openamp_core0.elf + tftpboot f1000000 openamp_core1.elf + bootelf -p f0000000 +``` +2.3 会显示如下内容 + +![](./figs/d2000_aarch32_openamp_startup.png) + + +2.4 输入 'loadelf -p f1000000' 加载从核程序 +2.5 输入 'rpmsg_echo_task' 运行openamp 测试程序 +2.6 结果显示为 + +![](./figs/d2000_aarch32_openamp_reault.png) + + +#### D2000/FT2004 aarch64 裸跑程序测试 (裸机间) + +1. 在编译环境下,切换至 phytium-standalone-sdk/baremetal/example/system/amp/openamp 目录 +1.1 输入 'make config_amp_d2000_aarch64' 加载默认配置信息,或输入 'make config_amp_ft2004_aarch64' 加载默认配置信息 +1.2 输入 'make all' 编译core0 / core1 代码,并且生成对应的elf 文件 +1.3 先将 ./core0/makefile 与 ./core1/makefile 中 的 USR_BOOT_DIR 修改为您的tftp 所覆盖的目录 +1.4 输入 'make boot' 将生成的elf 拷贝至 tftp 的目录下 + +2. 使用串口连接D2000/FT2004 开发板 ,并且打开串口终端工具 +2.1 复位开发板之后,将D2000/FT2004 开发板的网络与tftp 服务器在同一局域网中 +2.2 在中断工具下输入以下命令 + +``` + setenv ipaddr 192.168.4.20 + setenv serverip 192.168.4.50 + setenv gatewayip 192.168.4.1 + tftpboot f0000000 openamp_core0.elf + tftpboot f1000000 openamp_core1.elf + bootelf -p f0000000 +``` +2.3 会显示如下内容 + +![](./figs/d2000_aarch64_openamp_startup.png) + + +2.4 输入 'loadelf -p f1000000' 加载从核程序 +2.5 输入 'rpmsg_echo_task' 运行openamp 测试程序 +2.6 结果显示为 + +![](./figs/d2000_aarch64_openamp_reault.png) + + + +#### D2000 aarch32 裸机程序测试 (与linux) + +1. 进入amp/openamp 目录 +2. 进入core0 下 ,输入 make load_d2000_aarch32 ,加载预先配置信息 +3. 输入make menuconfig ,在 Project Configuration → AMP Config 下 取消 DEBUG_CODE +![](./figs/freertos_openamp_d2000_config.png) +4. 在 Third-Party Configuration → Use Asymmetric Multi-processing → OpenAmp 下,选择 Skip local rvdev->shbuf_io ,并选择Use the Vring definition in the master +![](./figs/freertos_openamp_d2000_aarch32_ampconfig.png) +5. 进入core0 目录下输入 "make clean" "make" ,生成elf 文件之后,将其拷贝至linux 指定目录下 +![](./figs/d2000_linux_reasult.png) + + +#### D2000 aarch64 裸机程序测试 (与linux) + +1. 进入amp/openamp 目录 +2. 进入core0 下 ,输入 make load_d2000_aarch64 ,加载预先配置信息 +3. 输入make menuconfig ,在 Project Configuration → AMP Config 下 取消 DEBUG_CODE +![](./figs/baremetal_openamp_d2000_config.png) +4. 在 Third-Party Configuration → Use Asymmetric Multi-processing → OpenAmp 下,选择 Skip local rvdev->shbuf_io ,并选择Use the Vring definition in the master +![](./figs/freertos_openamp_d2000_aarch32_ampconfig.png) +5. 进入core0 目录下输入 "make clean" "make" ,生成elf 文件之后,将其拷贝至linux 指定目录下 +![](./figs/d2000_linux_reasult.png) + + + +## 3. 如何解决问题 (Q&A) + +>主要记录使用例程中可能会遇到的问题,给出相应的解决方案
+ +## 4. 修改历史记录 + +>记录例程的重大修改记录,标明修改发生的版本号
+ +- 2021-03-21 :v0.1.0 初始化项目 diff --git a/example/amp/openamp/core0/Kconfig b/example/amp/openamp/core0/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..954e3d3c2bca8e0f352f2339fc3e523bc8a55d47 --- /dev/null +++ b/example/amp/openamp/core0/Kconfig @@ -0,0 +1,59 @@ +# +# For a description of the syntax of this configuration file, +# see tools/kconfiglib/kconfig-language.txt. +# + + +mainmenu "Phytium Freertos Configuration" + + menu "Project Configuration" + + menu " Freertos Configuration" + config TARGET_NAME + string "Build Target Name" + default "libmetal_core0" + help + Build Target name for the demo + + config SHM_BASE_ADDR + hex "Share memory address set" + default 0xc0000000 + + endmenu + + + menu "AMP Config" + + config IPI_IRQ_NUM + int "Communication interruption number between multiple cores" + default 0 + + config IPI_IRQ_NUM_PRIORITY + int "Priority of internuclear communication interruption" + default 16 + + config SPIN_MEM + hex "Spin-lock shared memory" + default 0x80000000 + + config TARGET_CPU_ID + int "Destination CPU communication mask" + default 1 + + config IPI_CHN_BITMASK + int "Destination IPI mask" + default 1 + + config DEBUG_CODE + bool + prompt "DEBUG_CODE" + default 1 + + endmenu + +endmenu + + + +source "$(FREERTOS_SDK_ROOT)/Kconfig" + diff --git a/example/amp/openamp/core0/README.md b/example/amp/openamp/core0/README.md new file mode 100644 index 0000000000000000000000000000000000000000..0e562133c5b687d562e2943b8d761f8161675e7a --- /dev/null +++ b/example/amp/openamp/core0/README.md @@ -0,0 +1,142 @@ + + +# lwip base on freertos + +## 1. 例程介绍 + +本例程示范了freertos环境下的lwip移植。 +本例程目前支持在freertos下,移植lwip,使网络能够ping通,freertos的cpu状态信息任务正常运行。 + +## 2. 如何使用例程 + +本例程需要用到 +- Phytium开发板(FT2000-4/D2000) +- [Phytium freeRTOS SDK](https://gitee.com/phytium_embedded/phytium-free-rtos-sdk) +- [Phytium standalone SDK](https://gitee.com/phytium_embedded/phytium-standalone-sdk) +### 2.1 硬件配置方法 + +本例程支持的硬件平台包括 + +- FT2000-4 +- D2000 + +对应的配置项是, + +- CONFIG_TARGET_F2000_4 +- CONFIG_TARGET_D2000 + +### 2.2 SDK配置方法 + +本例程需要, + +- 使能LWIP + +对应的配置项是, + +- Use LWIP + +本例子已经提供好具体的编译指令,以下进行介绍: +- make 将目录下的工程进行编译 +- make clean 将目录下的工程进行清理 +- make boot 将目录下的工程进行编译,并将生成的elf 复制到目标地址 +- make load_d2000_aarch64 将预设64bit d2000 下的配置加载至工程中 +- make load_d2000_aarch32 将预设32bit d2000 下的配置加载至工程中 +- make load_ft2004_aarch64 将预设64bit ft2004 下的配置加载至工程中 +- make load_ft2004_aarch32 将预设32bit ft2004 下的配置加载至工程中 +- make menuconfig 配置目录下的参数变量 +- make backup_kconfig 将目录下的sdkconfig 备份到./configs下 + +具体使用方法为: +- 在当前目录下 +- 执行以上指令 + +### 2.3 构建和下载 + +#### 2.3.1 构建过程 + +- 在host侧完成配置 +>配置成ft2004,对于其它平台,使用对于的默认配置,如D2000 `make load_d2000_aarch32` + +- 选择目标平台 +``` +make load_ft2004_aarch32 +``` + +- 选择例程需要的配置 +``` +make menuconfig +``` + +- 进行编译 +``` +make +``` + +- 将编译出的镜像放置到tftp目录下 +``` +make boot +``` + +#### 2.3.2 下载过程 + +- host侧设置重启host侧tftp服务器 +``` +sudo service tftpd-hpa restart +``` + +- 开发板侧使用bootelf命令跳转 +``` +setenv ipaddr 192.168.4.20 +setenv serverip 192.168.4.50 +setenv gatewayip 192.168.4.1 +tftpboot 0x90100000 freertos.elf +bootelf -p 0x90100000 +``` + +### 2.4 输出与实验现象 + +- 启动进入后,cpu状态任务打印状态信息 + +![cpu状态打印任务](./pic/cpu_status.png "cpu_status.png") + +#### 2.4.1 使用网线连接计算机和开发板网口0,ping 192.168.4.20命令进行网络测试 + +![ping](./pic/ping.png "ping.png") + + +## 3. 如何解决问题 + +Q: 程序运行过程中queue.c的debug信息报错 + +A: 考虑自身任务创建时分配的栈空间大小,考虑tcpip_thread任务的栈空间大小TCPIP_THREAD_STACKSIZE + +Q: 程序运行过程中ping大包异常 + +A: 考虑以下两个宏的大小:PBUF_POOL_SIZE定义缓冲池的个数,PBUF_POOL_BUFSIZE定义单个缓冲区的大小 + +## 4. 修改历史记录 + +v0.0.4 初次合入lwip + + diff --git a/example/amp/openamp/core0/configs/d2000_aarch32_eg_configs b/example/amp/openamp/core0/configs/d2000_aarch32_eg_configs new file mode 100644 index 0000000000000000000000000000000000000000..6ddf67c8471ba5299f7be502727cdc418568b6eb --- /dev/null +++ b/example/amp/openamp/core0/configs/d2000_aarch32_eg_configs @@ -0,0 +1,174 @@ + +# +# Project Configuration +# + +# +# Freertos Configuration +# +CONFIG_TARGET_NAME="openamp_core0" +CONFIG_SHM_BASE_ADDR=0xc0000000 +# end of Freertos Configuration + +# +# AMP Config +# +CONFIG_IPI_IRQ_NUM=9 +CONFIG_IPI_IRQ_NUM_PRIORITY=16 +CONFIG_SPIN_MEM=0x80000000 +CONFIG_TARGET_CPU_ID=2 +CONFIG_IPI_CHN_BITMASK=255 +CONFIG_DEBUG_CODE=y +# end of AMP Config +# end of Project Configuration + +# +# Standalone Setting +# +CONFIG_USE_FREERTOS=y + +# +# Arch Configuration +# +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +# CONFIG_USE_L3CACHE is not set +CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +CONFIG_USE_AARCH64_L1_TO_AARCH32=y +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_ENABLE_GICV3=y +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +# CONFIG_USE_ETH is not set +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set +# end of Components Configuration + +CONFIG_USE_NEW_LIBC=y +# end of Standalone Setting + +# +# Building Option +# + +# +# Linker Options +# +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0xb0100000 +CONFIG_ROM_SIZE_MB=2 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0xb0300000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=1 +CONFIG_SVC_STACK_SIZE=0x1000 +CONFIG_SYS_STACK_SIZE=0x1000 +CONFIG_IRQ_STACK_SIZE=0x1000 +CONFIG_ABORT_STACK_SIZE=0x1000 +CONFIG_FIQ_STACK_SIZE=0x1000 +CONFIG_UNDEF_STACK_SIZE=0x1000 +# end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options + +# CONFIG_LOG_VERBOS is not set +# CONFIG_LOG_DEBUG is not set +# CONFIG_LOG_INFO is not set +# CONFIG_LOG_WARN is not set +CONFIG_LOG_ERROR=y +# CONFIG_LOG_NONE is not set +# end of Building Option + +# +# Component Configuration +# + +# +# Freertos Drivers +# +CONFIG_FREERTOS_USE_UART=y +# end of Freertos Drivers +# end of Component Configuration + +# +# FreeRTOS Setting +# +# CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +CONFIG_USE_AMP=y +CONFIG_USE_LIBMETAL=y + +# +# OpenAmp +# +CONFIG_USE_OPENAMP=y +CONFIG_USE_OPENAMP_IPI=y +CONFIG_OPENAMP_RESOURCES_ADDR=0xc0000000 +CONFIG_VRING_TX_ADDR=0xc0020000 +CONFIG_VRING_RX_ADDR=0xc0024000 +CONFIG_VRING_SIZE=0x100 +CONFIG_POLL_BASE_ADDR=0xc0224000 +# CONFIG_SKIP_SHBUF_IO_WRITE is not set +# CONFIG_USE_MASTER_VRING_DEFINE is not set + +# +# Baremetal config +# +CONFIG_MEM_NO_CACHE=y +# CONFIG_MEM_WRITE_THROUGH is not set +# CONFIG_MEM_NORMAL is not set +# end of Baremetal config +# end of OpenAmp + +CONFIG_USE_LETTER_SHELL=y + +# +# Letter Shell Configuration +# +CONFIG_LS_PL011_UART=y +# end of Letter Shell Configuration +# end of FreeRTOS Setting diff --git a/example/amp/openamp/core0/configs/d2000_aarch64_eg_configs b/example/amp/openamp/core0/configs/d2000_aarch64_eg_configs new file mode 100644 index 0000000000000000000000000000000000000000..aa0b991c9871ec2332bbd0ab414c75ca49ef6398 --- /dev/null +++ b/example/amp/openamp/core0/configs/d2000_aarch64_eg_configs @@ -0,0 +1,169 @@ + +# +# Project Configuration +# + +# +# Freertos Configuration +# +CONFIG_TARGET_NAME="openamp_core0" +CONFIG_SHM_BASE_ADDR=0xc0000000 +# end of Freertos Configuration + +# +# AMP Config +# +CONFIG_IPI_IRQ_NUM=9 +CONFIG_IPI_IRQ_NUM_PRIORITY=16 +CONFIG_SPIN_MEM=0x80000000 +CONFIG_TARGET_CPU_ID=2 +CONFIG_IPI_CHN_BITMASK=255 +CONFIG_DEBUG_CODE=y +# end of AMP Config +# end of Project Configuration + +# +# Standalone Setting +# +CONFIG_USE_FREERTOS=y + +# +# Arch Configuration +# +# CONFIG_TARGET_ARMV8_AARCH32 is not set +CONFIG_TARGET_ARMV8_AARCH64=y +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +# CONFIG_USE_L3CACHE is not set +CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +# CONFIG_MMU_DEBUG_PRINTS is not set +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_ENABLE_GICV3=y +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +# CONFIG_USE_ETH is not set +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set +# end of Components Configuration + +CONFIG_USE_NEW_LIBC=y +# end of Standalone Setting + +# +# Building Option +# + +# +# Linker Options +# +# CONFIG_AARCH32_RAM_LD is not set +CONFIG_AARCH64_RAM_LD=y +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0xb0100000 +CONFIG_ROM_SIZE_MB=2 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0xb0300000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=1 +CONFIG_STACK_SIZE=0x100000 +# end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options + +CONFIG_LOG_VERBOS=y +# CONFIG_LOG_DEBUG is not set +# CONFIG_LOG_INFO is not set +# CONFIG_LOG_WARN is not set +# CONFIG_LOG_ERROR is not set +# CONFIG_LOG_NONE is not set +# end of Building Option + +# +# Component Configuration +# + +# +# Freertos Drivers +# +CONFIG_FREERTOS_USE_UART=y +# end of Freertos Drivers +# end of Component Configuration + +# +# FreeRTOS Setting +# +# CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +CONFIG_USE_AMP=y +CONFIG_USE_LIBMETAL=y + +# +# OpenAmp +# +CONFIG_USE_OPENAMP=y +CONFIG_USE_OPENAMP_IPI=y +CONFIG_OPENAMP_RESOURCES_ADDR=0xc0000000 +CONFIG_VRING_TX_ADDR=0xc0020000 +CONFIG_VRING_RX_ADDR=0xc0024000 +CONFIG_VRING_SIZE=0x100 +CONFIG_POLL_BASE_ADDR=0xc0224000 +# CONFIG_SKIP_SHBUF_IO_WRITE is not set +# CONFIG_USE_MASTER_VRING_DEFINE is not set + +# +# Baremetal config +# +CONFIG_MEM_NO_CACHE=y +# CONFIG_MEM_WRITE_THROUGH is not set +# CONFIG_MEM_NORMAL is not set +# end of Baremetal config +# end of OpenAmp + +CONFIG_USE_LETTER_SHELL=y + +# +# Letter Shell Configuration +# +CONFIG_LS_PL011_UART=y +# end of Letter Shell Configuration +# end of FreeRTOS Setting diff --git a/example/amp/openamp/core0/configs/ft2004_aarch32_eg_configs b/example/amp/openamp/core0/configs/ft2004_aarch32_eg_configs new file mode 100644 index 0000000000000000000000000000000000000000..b9f719b58c888e61e8be5ff3fb78216f2d5cf0b6 --- /dev/null +++ b/example/amp/openamp/core0/configs/ft2004_aarch32_eg_configs @@ -0,0 +1,174 @@ + +# +# Project Configuration +# + +# +# Freertos Configuration +# +CONFIG_TARGET_NAME="openamp_core0" +CONFIG_SHM_BASE_ADDR=0xc0000000 +# end of Freertos Configuration + +# +# AMP Config +# +CONFIG_IPI_IRQ_NUM=9 +CONFIG_IPI_IRQ_NUM_PRIORITY=16 +CONFIG_SPIN_MEM=0x80000000 +CONFIG_TARGET_CPU_ID=2 +CONFIG_IPI_CHN_BITMASK=255 +CONFIG_DEBUG_CODE=y +# end of AMP Config +# end of Project Configuration + +# +# Standalone Setting +# +CONFIG_USE_FREERTOS=y + +# +# Arch Configuration +# +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +# CONFIG_USE_L3CACHE is not set +CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +CONFIG_USE_AARCH64_L1_TO_AARCH32=y +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +CONFIG_TARGET_F2000_4=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_ENABLE_GICV3=y +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +# CONFIG_USE_ETH is not set +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set +# end of Components Configuration + +CONFIG_USE_NEW_LIBC=y +# end of Standalone Setting + +# +# Building Option +# + +# +# Linker Options +# +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0xb0100000 +CONFIG_ROM_SIZE_MB=2 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0xb0300000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=1 +CONFIG_SVC_STACK_SIZE=0x1000 +CONFIG_SYS_STACK_SIZE=0x1000 +CONFIG_IRQ_STACK_SIZE=0x1000 +CONFIG_ABORT_STACK_SIZE=0x1000 +CONFIG_FIQ_STACK_SIZE=0x1000 +CONFIG_UNDEF_STACK_SIZE=0x1000 +# end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options + +# CONFIG_LOG_VERBOS is not set +# CONFIG_LOG_DEBUG is not set +# CONFIG_LOG_INFO is not set +# CONFIG_LOG_WARN is not set +CONFIG_LOG_ERROR=y +# CONFIG_LOG_NONE is not set +# end of Building Option + +# +# Component Configuration +# + +# +# Freertos Drivers +# +CONFIG_FREERTOS_USE_UART=y +# end of Freertos Drivers +# end of Component Configuration + +# +# FreeRTOS Setting +# +# CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +CONFIG_USE_AMP=y +CONFIG_USE_LIBMETAL=y + +# +# OpenAmp +# +CONFIG_USE_OPENAMP=y +CONFIG_USE_OPENAMP_IPI=y +CONFIG_OPENAMP_RESOURCES_ADDR=0xc0000000 +CONFIG_VRING_TX_ADDR=0xc0020000 +CONFIG_VRING_RX_ADDR=0xc0024000 +CONFIG_VRING_SIZE=0x100 +CONFIG_POLL_BASE_ADDR=0xc0224000 +# CONFIG_SKIP_SHBUF_IO_WRITE is not set +# CONFIG_USE_MASTER_VRING_DEFINE is not set + +# +# Baremetal config +# +CONFIG_MEM_NO_CACHE=y +# CONFIG_MEM_WRITE_THROUGH is not set +# CONFIG_MEM_NORMAL is not set +# end of Baremetal config +# end of OpenAmp + +CONFIG_USE_LETTER_SHELL=y + +# +# Letter Shell Configuration +# +CONFIG_LS_PL011_UART=y +# end of Letter Shell Configuration +# end of FreeRTOS Setting diff --git a/example/amp/openamp/core0/configs/ft2004_aarch64_eg_configs b/example/amp/openamp/core0/configs/ft2004_aarch64_eg_configs new file mode 100644 index 0000000000000000000000000000000000000000..ac32338011a54f35916bed4b4437886408b75ce4 --- /dev/null +++ b/example/amp/openamp/core0/configs/ft2004_aarch64_eg_configs @@ -0,0 +1,169 @@ + +# +# Project Configuration +# + +# +# Freertos Configuration +# +CONFIG_TARGET_NAME="openamp_core0" +CONFIG_SHM_BASE_ADDR=0xc0000000 +# end of Freertos Configuration + +# +# AMP Config +# +CONFIG_IPI_IRQ_NUM=9 +CONFIG_IPI_IRQ_NUM_PRIORITY=16 +CONFIG_SPIN_MEM=0x80000000 +CONFIG_TARGET_CPU_ID=2 +CONFIG_IPI_CHN_BITMASK=255 +CONFIG_DEBUG_CODE=y +# end of AMP Config +# end of Project Configuration + +# +# Standalone Setting +# +CONFIG_USE_FREERTOS=y + +# +# Arch Configuration +# +# CONFIG_TARGET_ARMV8_AARCH32 is not set +CONFIG_TARGET_ARMV8_AARCH64=y +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +# CONFIG_USE_L3CACHE is not set +CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +# CONFIG_MMU_DEBUG_PRINTS is not set +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +CONFIG_TARGET_F2000_4=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_ENABLE_GICV3=y +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +# CONFIG_USE_ETH is not set +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set +# end of Components Configuration + +CONFIG_USE_NEW_LIBC=y +# end of Standalone Setting + +# +# Building Option +# + +# +# Linker Options +# +# CONFIG_AARCH32_RAM_LD is not set +CONFIG_AARCH64_RAM_LD=y +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0xb0100000 +CONFIG_ROM_SIZE_MB=2 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0xb0300000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=1 +CONFIG_STACK_SIZE=0x100000 +# end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options + +CONFIG_LOG_VERBOS=y +# CONFIG_LOG_DEBUG is not set +# CONFIG_LOG_INFO is not set +# CONFIG_LOG_WARN is not set +# CONFIG_LOG_ERROR is not set +# CONFIG_LOG_NONE is not set +# end of Building Option + +# +# Component Configuration +# + +# +# Freertos Drivers +# +CONFIG_FREERTOS_USE_UART=y +# end of Freertos Drivers +# end of Component Configuration + +# +# FreeRTOS Setting +# +# CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +CONFIG_USE_AMP=y +CONFIG_USE_LIBMETAL=y + +# +# OpenAmp +# +CONFIG_USE_OPENAMP=y +CONFIG_USE_OPENAMP_IPI=y +CONFIG_OPENAMP_RESOURCES_ADDR=0xc0000000 +CONFIG_VRING_TX_ADDR=0xc0020000 +CONFIG_VRING_RX_ADDR=0xc0024000 +CONFIG_VRING_SIZE=0x100 +CONFIG_POLL_BASE_ADDR=0xc0224000 +# CONFIG_SKIP_SHBUF_IO_WRITE is not set +# CONFIG_USE_MASTER_VRING_DEFINE is not set + +# +# Baremetal config +# +CONFIG_MEM_NO_CACHE=y +# CONFIG_MEM_WRITE_THROUGH is not set +# CONFIG_MEM_NORMAL is not set +# end of Baremetal config +# end of OpenAmp + +CONFIG_USE_LETTER_SHELL=y + +# +# Letter Shell Configuration +# +CONFIG_LS_PL011_UART=y +# end of Letter Shell Configuration +# end of FreeRTOS Setting diff --git a/example/amp/openamp/core0/main.c b/example/amp/openamp/core0/main.c new file mode 100644 index 0000000000000000000000000000000000000000..ffe60fc907705e0b3c2d1a0374f604ac5e8718bf --- /dev/null +++ b/example/amp/openamp/core0/main.c @@ -0,0 +1,80 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: main.c + * Date: 2022-02-24 16:56:46 + * LastEditTime: 2022-03-21 17:00:56 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + + +#include "ft_types.h" +#include "psci.h" +#include "shell.h" +#include "fsleep.h" +#include "f_printk.h" +#include "ft_debug.h" +#include "shell_port.h" + +#define OPENAMP_MAIN_DEBUG_TAG "OPENAMP_MAIN" +#define OPENAMP_MAIN_DEBUG_I(format, ...) FT_DEBUG_PRINT_I(OPENAMP_MAIN_DEBUG_TAG, format, ##__VA_ARGS__) +#define OPENAMP_MAIN_DEBUG_W(format, ...) FT_DEBUG_PRINT_W(OPENAMP_MAIN_DEBUG_TAG, format, ##__VA_ARGS__) +#define OPENAMP_MAIN_DEBUG_E(format, ...) FT_DEBUG_PRINT_E(OPENAMP_MAIN_DEBUG_TAG, format, ##__VA_ARGS__) + +extern void TestLetterShell() ; +extern int rpmsg_echo(int argc, char *argv[]) ; + +#ifdef CONFIG_DEBUG_CODE + + +int main(void) +{ + BaseType_t ret; + + ret = LSUserShellTask() ; + if(ret != pdPASS) + goto FAIL_EXIT; + + vTaskStartScheduler(); /* 启动任务,开启调度 */ + while (1); /* 正常不会执行到这里 */ + +FAIL_EXIT: + printf("failed 0x%x \r\n", ret); + return 0; +} + +#else + +extern int rpmsg_echo_task(int argc, char *argv[]); + + +int main(void) +{ + BaseType_t ret; + f_printk("freertos %s ,%s \r\n",__DATE__, __TIME__) ; + + rpmsg_echo_task(0, NULL); + vTaskStartScheduler(); /* 启动任务,开启调度 */ + while (1); /* 正常不会执行到这里 */ + +FAIL_EXIT: + printf("failed 0x%x \r\n", ret); + return 0; +} + +#endif + diff --git a/example/amp/openamp/core0/makefile b/example/amp/openamp/core0/makefile new file mode 100644 index 0000000000000000000000000000000000000000..1abdc14915f2dece9bb9099c582b24fe5f3c6176 --- /dev/null +++ b/example/amp/openamp/core0/makefile @@ -0,0 +1,30 @@ +export PROJECT_DIR ?= $(shell pwd) + +export USR_SRC_DIR = $(PROJECT_DIR) +export USR_INC_DIR = $(PROJECT_DIR) + +# 用户定义的编译目标文件上传路径 +ifeq ($(OS),Windows_NT) + USR_BOOT_DIR ?= $(subst \,/, $(PHYTIUM_DEV_PATH))/tftp +else + USR_BOOT_DIR ?= /mnt/d/tftboot +endif + +# 设置启动镜像名 +USER_BOOT_IMAGE ?= openamp_core0 + + +# 设置启动镜像名 +BOOT_IMG_NAME ?= openamp_core0 + +# 指定编译freertos项目使用的makefile +include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk + +# 完成编译 +boot: + make + cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf + +scp: + scp ./openamp_core0.elf root@192.168.2.198:/lib/firmware + diff --git a/example/amp/openamp/core0/rpmsg-echo_os.c b/example/amp/openamp/core0/rpmsg-echo_os.c new file mode 100644 index 0000000000000000000000000000000000000000..1a707b0069767ae7c00f4e9db88798a043e1b2fa --- /dev/null +++ b/example/amp/openamp/core0/rpmsg-echo_os.c @@ -0,0 +1,209 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: rpmsg-echo_os.c + * Date: 2022-02-25 09:12:07 + * LastEditTime: 2022-02-25 09:12:19 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + + +/* This is a sample demonstration application that showcases usage of rpmsg +This application is meant to run on the remote CPU running baremetal code. +This application echoes back data that was sent to it by the master core. */ + +/***************************** Include Files *********************************/ + +#include +#include +#include +#include +#include +#include "platform_info.h" +#include "rpmsg-echo.h" +#include +#include "rsc_table.h" +#include "FreeRTOS.h" +#include "task.h" +#include "shell.h" +#include "interrupt.h" +#include "cache.h" +#include "psci.h" + + +/************************** Constant Definitions *****************************/ + +/**************************** Type Definitions *******************************/ + +/************************** Variable Definitions *****************************/ + +/***************** Macros (Inline Functions) Definitions *********************/ + +#define SHUTDOWN_MSG 0xEF56A55A + +#define LPRINTF(format, ...) printf(format, ##__VA_ARGS__) +#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__) + +static struct rpmsg_endpoint lept; +static int shutdown_req = 0; + +/************************** Function Prototypes ******************************/ + +/*-----------------------------------------------------------------------------* + * RPMSG endpoint callbacks + *-----------------------------------------------------------------------------*/ +static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len, uint32_t src, void *priv) +{ + (void)priv; + (void)src; + /* On reception of a shutdown we signal the application to terminate */ + if ((*(unsigned int *)data) == SHUTDOWN_MSG) { + LPRINTF("shutdown message is received.\r\n"); + shutdown_req = 1; + return RPMSG_SUCCESS; + } + +#ifdef CONFIG_MEM_NORMAL + FCacheDCacheInvalidateRange((intptr)data, len); +#endif + + /* Send data back to master */ + if (rpmsg_send(ept, data, len) < 0) + LPERROR("rpmsg_send failed\r\n"); + + return RPMSG_SUCCESS; +} + +static void rpmsg_service_unbind(struct rpmsg_endpoint *ept) +{ + (void)ept; + LPRINTF("unexpected Remote endpoint destroy\r\n"); + shutdown_req = 1; +} + +/*-----------------------------------------------------------------------------* + * Application + *-----------------------------------------------------------------------------*/ +int app(struct rpmsg_device *rdev, void *priv) +{ + int ret; + + /* Initialize RPMSG framework */ + LPRINTF("Try to create rpmsg endpoint.\r\n"); + + ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME, 0, RPMSG_ADDR_ANY, rpmsg_endpoint_cb, rpmsg_service_unbind); + if (ret) { + LPERROR("Failed to create endpoint. %d \r\n", ret); + return -1; + } + + LPRINTF("Successfully created rpmsg endpoint.\r\n"); + + while (1) + { + platform_poll(priv); + /* we got a shutdown request, exit */ + if (shutdown_req) + break; + } + + rpmsg_destroy_ept(&lept); + + return 0; +} + + + +/*-----------------------------------------------------------------------------* + * Application entry point + *-----------------------------------------------------------------------------*/ +int rpmsg_echo(int argc, char *argv[]) +{ + void *platform; + struct rpmsg_device *rpdev; + int ret; + + LPRINTF("openamp lib version: %s (", openamp_version()); + LPRINTF("Major: %d, ", openamp_version_major()); + LPRINTF("Minor: %d, ", openamp_version_minor()); + LPRINTF("Patch: %d)\r\n", openamp_version_patch()); + + LPRINTF("libmetal lib version: %s (", metal_ver()); + LPRINTF("Major: %d, ", metal_ver_major()); + LPRINTF("Minor: %d, ", metal_ver_minor()); + LPRINTF("Patch: %d)\r\n", metal_ver_patch()); + + LPRINTF("Starting application...\r\n"); + + /* Initialize platform */ + ret = platform_init(argc, argv, &platform); + if (ret) { + LPERROR("Failed to initialize platform.\r\n"); + ret = -1; + } else { + #ifdef CONFIG_DEBUG_CODE + LPERROR("CONFIG_TARGET_CPU_ID is %x \r\n",CONFIG_TARGET_CPU_ID); + PsciCpuOn(CONFIG_TARGET_CPU_ID,(uintptr_t)0xe0100000) ; + #endif + rpdev = platform_create_rpmsg_vdev(platform, 0, VIRTIO_DEV_SLAVE, NULL, NULL); + if (!rpdev) { + LPERROR("Failed to create rpmsg virtio device.\r\n"); + ret = -1; + } else { + app(rpdev, platform); + + platform_release_rpmsg_vdev(rpdev, platform); + ret = 0; + } + } + + LPRINTF("Stopping application...\r\n"); + platform_cleanup(platform); + + return ret; +} + + +void RpmsgEchoTask( void * args ) +{ + rpmsg_echo(0, NULL); + vTaskDelete(NULL); +} + +int rpmsg_echo_task(int argc, char *argv[]) +{ + BaseType_t ret; + + ret = xTaskCreate((TaskFunction_t )RpmsgEchoTask, /* 任务入口函数 */ + (const char* )"RpmsgEchoTask",/* 任务名字 */ + (uint16_t )4096, /* 任务栈大小 */ + (void* )NULL,/* 任务入口函数参数 */ + (UBaseType_t )1, /* 任务的优先级 */ + NULL); /* 任务控制块指针 */ + + if(ret != pdPASS) + { + // task_is_valid = 0; + LPERROR("Failed to create a rpmsg_echo task "); + return -1; + } + + return 0; +} + + +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), rpmsg_echo_task, rpmsg_echo_task, rpmsg_echo_task); \ No newline at end of file diff --git a/example/amp/openamp/core0/sdkconfig b/example/amp/openamp/core0/sdkconfig new file mode 100644 index 0000000000000000000000000000000000000000..b9f719b58c888e61e8be5ff3fb78216f2d5cf0b6 --- /dev/null +++ b/example/amp/openamp/core0/sdkconfig @@ -0,0 +1,174 @@ + +# +# Project Configuration +# + +# +# Freertos Configuration +# +CONFIG_TARGET_NAME="openamp_core0" +CONFIG_SHM_BASE_ADDR=0xc0000000 +# end of Freertos Configuration + +# +# AMP Config +# +CONFIG_IPI_IRQ_NUM=9 +CONFIG_IPI_IRQ_NUM_PRIORITY=16 +CONFIG_SPIN_MEM=0x80000000 +CONFIG_TARGET_CPU_ID=2 +CONFIG_IPI_CHN_BITMASK=255 +CONFIG_DEBUG_CODE=y +# end of AMP Config +# end of Project Configuration + +# +# Standalone Setting +# +CONFIG_USE_FREERTOS=y + +# +# Arch Configuration +# +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +# CONFIG_USE_L3CACHE is not set +CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +CONFIG_USE_AARCH64_L1_TO_AARCH32=y +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +CONFIG_TARGET_F2000_4=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_ENABLE_GICV3=y +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +# CONFIG_USE_ETH is not set +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set +# end of Components Configuration + +CONFIG_USE_NEW_LIBC=y +# end of Standalone Setting + +# +# Building Option +# + +# +# Linker Options +# +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0xb0100000 +CONFIG_ROM_SIZE_MB=2 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0xb0300000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=1 +CONFIG_SVC_STACK_SIZE=0x1000 +CONFIG_SYS_STACK_SIZE=0x1000 +CONFIG_IRQ_STACK_SIZE=0x1000 +CONFIG_ABORT_STACK_SIZE=0x1000 +CONFIG_FIQ_STACK_SIZE=0x1000 +CONFIG_UNDEF_STACK_SIZE=0x1000 +# end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options + +# CONFIG_LOG_VERBOS is not set +# CONFIG_LOG_DEBUG is not set +# CONFIG_LOG_INFO is not set +# CONFIG_LOG_WARN is not set +CONFIG_LOG_ERROR=y +# CONFIG_LOG_NONE is not set +# end of Building Option + +# +# Component Configuration +# + +# +# Freertos Drivers +# +CONFIG_FREERTOS_USE_UART=y +# end of Freertos Drivers +# end of Component Configuration + +# +# FreeRTOS Setting +# +# CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +CONFIG_USE_AMP=y +CONFIG_USE_LIBMETAL=y + +# +# OpenAmp +# +CONFIG_USE_OPENAMP=y +CONFIG_USE_OPENAMP_IPI=y +CONFIG_OPENAMP_RESOURCES_ADDR=0xc0000000 +CONFIG_VRING_TX_ADDR=0xc0020000 +CONFIG_VRING_RX_ADDR=0xc0024000 +CONFIG_VRING_SIZE=0x100 +CONFIG_POLL_BASE_ADDR=0xc0224000 +# CONFIG_SKIP_SHBUF_IO_WRITE is not set +# CONFIG_USE_MASTER_VRING_DEFINE is not set + +# +# Baremetal config +# +CONFIG_MEM_NO_CACHE=y +# CONFIG_MEM_WRITE_THROUGH is not set +# CONFIG_MEM_NORMAL is not set +# end of Baremetal config +# end of OpenAmp + +CONFIG_USE_LETTER_SHELL=y + +# +# Letter Shell Configuration +# +CONFIG_LS_PL011_UART=y +# end of Letter Shell Configuration +# end of FreeRTOS Setting diff --git a/example/amp/openamp/core0/sdkconfig.h b/example/amp/openamp/core0/sdkconfig.h new file mode 100644 index 0000000000000000000000000000000000000000..1bbe850446c1d117376128159874c3841c6bccc2 --- /dev/null +++ b/example/amp/openamp/core0/sdkconfig.h @@ -0,0 +1,154 @@ +#ifndef SDK_CONFIG_H__ +#define SDK_CONFIG_H__ + +/* Project Configuration */ + +/* Freertos Configuration */ + +#define CONFIG_TARGET_NAME "openamp_core0" +#define CONFIG_SHM_BASE_ADDR 0xc0000000 +/* end of Freertos Configuration */ + +/* AMP Config */ + +#define CONFIG_IPI_IRQ_NUM 9 +#define CONFIG_IPI_IRQ_NUM_PRIORITY 16 +#define CONFIG_SPIN_MEM 0x80000000 +#define CONFIG_TARGET_CPU_ID 2 +#define CONFIG_IPI_CHN_BITMASK 255 +#define CONFIG_DEBUG_CODE +/* end of AMP Config */ +/* end of Project Configuration */ + +/* Standalone Setting */ + +#define CONFIG_USE_FREERTOS + +/* Arch Configuration */ + +#define CONFIG_TARGET_ARMV8_AARCH32 +/* CONFIG_TARGET_ARMV8_AARCH64 is not set */ +/* CONFIG_TARGET_ARMV7 is not set */ +#define CONFIG_USE_CACHE +/* CONFIG_USE_L3CACHE is not set */ +#define CONFIG_USE_MMU +/* CONFIG_USE_SYS_TICK is not set */ +#define CONFIG_USE_AARCH64_L1_TO_AARCH32 +/* end of Arch Configuration */ + +/* Board Configuration */ + +/* CONFIG_TARGET_F2000_4 is not set */ +#define CONFIG_TARGET_F2000_4 +/* CONFIG_TARGET_E2000Q is not set */ +/* CONFIG_TARGET_E2000D is not set */ +/* CONFIG_TARGET_E2000S is not set */ +/* end of Board Configuration */ + +/* Components Configuration */ + +/* CONFIG_USE_SPI is not set */ +/* CONFIG_USE_QSPI is not set */ +#define CONFIG_USE_GIC +#define CONFIG_ENABLE_GICV3 +#define CONFIG_USE_SERIAL + +/* Usart Configuration */ + +#define CONFIG_ENABLE_Pl011_UART +/* end of Usart Configuration */ +/* CONFIG_USE_GPIO is not set */ +/* CONFIG_USE_IOMUX is not set */ +/* CONFIG_USE_ETH is not set */ +/* CONFIG_USE_CAN is not set */ +/* CONFIG_USE_I2C is not set */ +/* CONFIG_USE_TIMER is not set */ +/* CONFIG_USE_SDMMC is not set */ +/* CONFIG_USE_PCIE is not set */ +/* CONFIG_USE_WDT is not set */ +/* CONFIG_USE_DMA is not set */ +/* CONFIG_USE_NAND is not set */ +/* CONFIG_USE_RTC is not set */ +/* CONFIG_USE_SATA is not set */ +/* CONFIG_USE_USB is not set */ +/* end of Components Configuration */ +#define CONFIG_USE_NEW_LIBC +/* end of Standalone Setting */ + +/* Building Option */ + +/* Linker Options */ + +#define CONFIG_AARCH32_RAM_LD +/* CONFIG_AARCH64_RAM_LD is not set */ +/* CONFIG_USER_DEFINED_LD is not set */ +#define CONFIG_LINK_SCRIPT_ROM +#define CONFIG_ROM_START_UP_ADDR 0xb0100000 +#define CONFIG_ROM_SIZE_MB 2 +#define CONFIG_LINK_SCRIPT_RAM +#define CONFIG_RAM_START_UP_ADDR 0xb0300000 +#define CONFIG_RAM_SIZE_MB 64 +#define CONFIG_HEAP_SIZE 1 +#define CONFIG_SVC_STACK_SIZE 0x1000 +#define CONFIG_SYS_STACK_SIZE 0x1000 +#define CONFIG_IRQ_STACK_SIZE 0x1000 +#define CONFIG_ABORT_STACK_SIZE 0x1000 +#define CONFIG_FIQ_STACK_SIZE 0x1000 +#define CONFIG_UNDEF_STACK_SIZE 0x1000 +/* end of Linker Options */ + +/* Compiler Options */ + +#define CONFIG_DON_T_BINARY_OUTPUT +/* end of Compiler Options */ +/* CONFIG_LOG_VERBOS is not set */ +/* CONFIG_LOG_DEBUG is not set */ +/* CONFIG_LOG_INFO is not set */ +/* CONFIG_LOG_WARN is not set */ +#define CONFIG_LOG_ERROR +/* CONFIG_LOG_NONE is not set */ +/* end of Building Option */ + +/* Component Configuration */ + +/* Freertos Drivers */ + +#define CONFIG_FREERTOS_USE_UART +/* end of Freertos Drivers */ +/* end of Component Configuration */ + +/* FreeRTOS Setting */ + +/* CONFIG_USE_LWIP is not set */ +#define CONFIG_USE_BACKTRACE +#define CONFIG_USE_AMP +#define CONFIG_USE_LIBMETAL + +/* OpenAmp */ + +#define CONFIG_USE_OPENAMP +#define CONFIG_USE_OPENAMP_IPI +#define CONFIG_OPENAMP_RESOURCES_ADDR 0xc0000000 +#define CONFIG_VRING_TX_ADDR 0xc0020000 +#define CONFIG_VRING_RX_ADDR 0xc0024000 +#define CONFIG_VRING_SIZE 0x100 +#define CONFIG_POLL_BASE_ADDR 0xc0224000 +/* CONFIG_SKIP_SHBUF_IO_WRITE is not set */ +/* CONFIG_USE_MASTER_VRING_DEFINE is not set */ + +/* Baremetal config */ + +#define CONFIG_MEM_NO_CACHE +/* CONFIG_MEM_WRITE_THROUGH is not set */ +/* CONFIG_MEM_NORMAL is not set */ +/* end of Baremetal config */ +/* end of OpenAmp */ +#define CONFIG_USE_LETTER_SHELL + +/* Letter Shell Configuration */ + +#define CONFIG_LS_PL011_UART +/* end of Letter Shell Configuration */ +/* end of FreeRTOS Setting */ + +#endif diff --git a/example/amp/openamp/core1/Kconfig b/example/amp/openamp/core1/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..1a36de571d0fa69d39dd1d12311685e8aca9c4c7 --- /dev/null +++ b/example/amp/openamp/core1/Kconfig @@ -0,0 +1,55 @@ +# +# For a description of the syntax of this configuration file, +# see tools/kconfiglib/kconfig-language.txt. +# + + +mainmenu "Phytium Freertos Configuration" + + menu "Project Configuration" + + menu " Baremetal Configuration" + config TARGET_NAME + string "Build Target Name" + default "libmetal_core0" + help + Build Target name for the demo + + config SHM_BASE_ADDR + hex "Share memory address set" + default 0xc0000000 + + endmenu + + + menu "Amp Config" + + + config IPI_IRQ_NUM + int "Communication interruption number between multiple cores" + default 0 + + config IPI_IRQ_NUM_PRIORITY + int "Priority of internuclear communication interruption" + default 16 + + config SPIN_MEM + hex "Spin-lock shared memory" + default 0x80000000 + + config TARGET_CPU_ID + int "Destination CPU communication mask" + default 2 + + config IPI_CHN_BITMASK + int "Destination IPI mask" + default 2 + + endmenu + +endmenu + + + +source "$(FREERTOS_SDK_ROOT)/Kconfig" + diff --git a/example/amp/openamp/core1/configs/d2000_aarch32_eg_configs b/example/amp/openamp/core1/configs/d2000_aarch32_eg_configs new file mode 100644 index 0000000000000000000000000000000000000000..37c7eecef899af1058527125786ae5a3cdd6f43b --- /dev/null +++ b/example/amp/openamp/core1/configs/d2000_aarch32_eg_configs @@ -0,0 +1,168 @@ + +# +# Project Configuration +# + +# +# Baremetal Configuration +# +CONFIG_TARGET_NAME="openamp_core1" +CONFIG_SHM_BASE_ADDR=0xc0000000 +# end of Baremetal Configuration + +# +# Amp Config +# +CONFIG_IPI_IRQ_NUM=9 +CONFIG_IPI_IRQ_NUM_PRIORITY=16 +CONFIG_SPIN_MEM=0x80000000 +CONFIG_TARGET_CPU_ID=1 +CONFIG_IPI_CHN_BITMASK=1 +CONFIG_WITH_BAREMETAL=y +# end of Amp Config +# end of Project Configuration + +# +# Standalone Setting +# +CONFIG_USE_FREERTOS=y + +# +# Arch Configuration +# +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +# CONFIG_USE_L3CACHE is not set +CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +# CONFIG_USE_AARCH64_L1_TO_AARCH32 is not set +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_ENABLE_GICV3=y +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +# CONFIG_USE_ETH is not set +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set +# end of Components Configuration + +CONFIG_USE_NEW_LIBC=y +# end of Standalone Setting + +# +# Building Option +# + +# +# Linker Options +# +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0xe0100000 +CONFIG_ROM_SIZE_MB=2 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0xe0300000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=1 +CONFIG_SVC_STACK_SIZE=0x1000 +CONFIG_SYS_STACK_SIZE=0x1000 +CONFIG_IRQ_STACK_SIZE=0x1000 +CONFIG_ABORT_STACK_SIZE=0x1000 +CONFIG_FIQ_STACK_SIZE=0x1000 +CONFIG_UNDEF_STACK_SIZE=0x1000 +# end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options + +CONFIG_LOG_VERBOS=y +# CONFIG_LOG_DEBUG is not set +# CONFIG_LOG_INFO is not set +# CONFIG_LOG_WARN is not set +# CONFIG_LOG_ERROR is not set +# CONFIG_LOG_NONE is not set +# end of Building Option + +# +# Component Configuration +# + +# +# Freertos Drivers +# +CONFIG_FREERTOS_USE_UART=y +# end of Freertos Drivers +# end of Component Configuration + +# +# FreeRTOS Setting +# +# CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +CONFIG_USE_AMP=y +CONFIG_USE_LIBMETAL=y + +# +# OpenAmp +# +CONFIG_USE_OPENAMP=y +CONFIG_USE_OPENAMP_IPI=y +CONFIG_OPENAMP_RESOURCES_ADDR=0xc0000000 +CONFIG_VRING_TX_ADDR=0xc0020000 +CONFIG_VRING_RX_ADDR=0xc0024000 +CONFIG_VRING_SIZE=0x100 +CONFIG_POLL_BASE_ADDR=0xc0224000 +# CONFIG_SKIP_SHBUF_IO_WRITE is not set +# CONFIG_USE_MASTER_VRING_DEFINE is not set + +# +# Baremetal config +# +CONFIG_MEM_NO_CACHE=y +# CONFIG_MEM_WRITE_THROUGH is not set +# CONFIG_MEM_NORMAL is not set +# end of Baremetal config +# end of OpenAmp + +# CONFIG_USE_LETTER_SHELL is not set +# end of FreeRTOS Setting diff --git a/example/amp/openamp/core1/configs/d2000_aarch64_eg_configs b/example/amp/openamp/core1/configs/d2000_aarch64_eg_configs new file mode 100644 index 0000000000000000000000000000000000000000..0ddad6e880105143b34a7f35470c6755a307c149 --- /dev/null +++ b/example/amp/openamp/core1/configs/d2000_aarch64_eg_configs @@ -0,0 +1,161 @@ + +# +# Project Configuration +# + +# +# Baremetal Configuration +# +CONFIG_TARGET_NAME="openamp_core1" +CONFIG_SHM_BASE_ADDR=0xc0000000 +# end of Baremetal Configuration + +# +# Amp Config +# +CONFIG_IPI_IRQ_NUM=9 +CONFIG_IPI_IRQ_NUM_PRIORITY=16 +CONFIG_SPIN_MEM=0x80000000 +CONFIG_TARGET_CPU_ID=1 +CONFIG_IPI_CHN_BITMASK=1 +# end of Amp Config +# end of Project Configuration + +# +# Standalone Setting +# +CONFIG_USE_FREERTOS=y + +# +# Arch Configuration +# +# CONFIG_TARGET_ARMV8_AARCH32 is not set +CONFIG_TARGET_ARMV8_AARCH64=y +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +# CONFIG_USE_L3CACHE is not set +CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +# CONFIG_MMU_DEBUG_PRINTS is not set +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_ENABLE_GICV3=y +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +# CONFIG_USE_ETH is not set +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set +# end of Components Configuration + +CONFIG_USE_NEW_LIBC=y +# end of Standalone Setting + +# +# Building Option +# +CONFIG_LOG_VERBOS=y +# CONFIG_LOG_DEBUG is not set +# CONFIG_LOG_INFO is not set +# CONFIG_LOG_WARN is not set +# CONFIG_LOG_ERROR is not set +# CONFIG_LOG_NONE is not set + +# +# Linker Options +# +# CONFIG_AARCH32_RAM_LD is not set +CONFIG_AARCH64_RAM_LD=y +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0xe0100000 +CONFIG_ROM_SIZE_MB=2 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0xe0300000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=1 +CONFIG_STACK_SIZE=0x100000 +# end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options +# end of Building Option + +# +# Component Configuration +# + +# +# Freertos Drivers +# +CONFIG_FREERTOS_USE_UART=y +# end of Freertos Drivers +# end of Component Configuration + +# +# FreeRTOS Setting +# +# CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +CONFIG_USE_AMP=y +CONFIG_USE_LIBMETAL=y + +# +# OpenAmp +# +CONFIG_USE_OPENAMP=y +CONFIG_USE_OPENAMP_IPI=y +CONFIG_OPENAMP_RESOURCES_ADDR=0xc0000000 +CONFIG_VRING_TX_ADDR=0xc0020000 +CONFIG_VRING_RX_ADDR=0xc0024000 +CONFIG_VRING_SIZE=0x100 +CONFIG_POLL_BASE_ADDR=0xc0224000 +# CONFIG_SKIP_SHBUF_IO_WRITE is not set +# CONFIG_USE_MASTER_VRING_DEFINE is not set + +# +# Baremetal config +# +CONFIG_MEM_NO_CACHE=y +# CONFIG_MEM_WRITE_THROUGH is not set +# CONFIG_MEM_NORMAL is not set +# end of Baremetal config +# end of OpenAmp + +# CONFIG_USE_LETTER_SHELL is not set +# end of FreeRTOS Setting diff --git a/example/amp/openamp/core1/configs/ft2004_aarch32_eg_configs b/example/amp/openamp/core1/configs/ft2004_aarch32_eg_configs new file mode 100644 index 0000000000000000000000000000000000000000..5e58d0e87d6313a268d46156ccdd4ed28c7c2c7f --- /dev/null +++ b/example/amp/openamp/core1/configs/ft2004_aarch32_eg_configs @@ -0,0 +1,168 @@ + +# +# Project Configuration +# + +# +# Baremetal Configuration +# +CONFIG_TARGET_NAME="openamp_core1" +CONFIG_SHM_BASE_ADDR=0xc0000000 +# end of Baremetal Configuration + +# +# Amp Config +# +CONFIG_IPI_IRQ_NUM=9 +CONFIG_IPI_IRQ_NUM_PRIORITY=16 +CONFIG_SPIN_MEM=0x80000000 +CONFIG_TARGET_CPU_ID=1 +CONFIG_IPI_CHN_BITMASK=1 +CONFIG_WITH_BAREMETAL=y +# end of Amp Config +# end of Project Configuration + +# +# Standalone Setting +# +CONFIG_USE_FREERTOS=y + +# +# Arch Configuration +# +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +# CONFIG_USE_L3CACHE is not set +CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +# CONFIG_USE_AARCH64_L1_TO_AARCH32 is not set +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +CONFIG_TARGET_F2000_4=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_ENABLE_GICV3=y +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +# CONFIG_USE_ETH is not set +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set +# end of Components Configuration + +CONFIG_USE_NEW_LIBC=y +# end of Standalone Setting + +# +# Building Option +# + +# +# Linker Options +# +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0xe0100000 +CONFIG_ROM_SIZE_MB=2 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0xe0300000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=1 +CONFIG_SVC_STACK_SIZE=0x1000 +CONFIG_SYS_STACK_SIZE=0x1000 +CONFIG_IRQ_STACK_SIZE=0x1000 +CONFIG_ABORT_STACK_SIZE=0x1000 +CONFIG_FIQ_STACK_SIZE=0x1000 +CONFIG_UNDEF_STACK_SIZE=0x1000 +# end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options + +CONFIG_LOG_VERBOS=y +# CONFIG_LOG_DEBUG is not set +# CONFIG_LOG_INFO is not set +# CONFIG_LOG_WARN is not set +# CONFIG_LOG_ERROR is not set +# CONFIG_LOG_NONE is not set +# end of Building Option + +# +# Component Configuration +# + +# +# Freertos Drivers +# +CONFIG_FREERTOS_USE_UART=y +# end of Freertos Drivers +# end of Component Configuration + +# +# FreeRTOS Setting +# +# CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +CONFIG_USE_AMP=y +CONFIG_USE_LIBMETAL=y + +# +# OpenAmp +# +CONFIG_USE_OPENAMP=y +CONFIG_USE_OPENAMP_IPI=y +CONFIG_OPENAMP_RESOURCES_ADDR=0xc0000000 +CONFIG_VRING_TX_ADDR=0xc0020000 +CONFIG_VRING_RX_ADDR=0xc0024000 +CONFIG_VRING_SIZE=0x100 +CONFIG_POLL_BASE_ADDR=0xc0224000 +# CONFIG_SKIP_SHBUF_IO_WRITE is not set +# CONFIG_USE_MASTER_VRING_DEFINE is not set + +# +# Baremetal config +# +CONFIG_MEM_NO_CACHE=y +# CONFIG_MEM_WRITE_THROUGH is not set +# CONFIG_MEM_NORMAL is not set +# end of Baremetal config +# end of OpenAmp + +# CONFIG_USE_LETTER_SHELL is not set +# end of FreeRTOS Setting diff --git a/example/amp/openamp/core1/configs/ft2004_aarch64_eg_configs b/example/amp/openamp/core1/configs/ft2004_aarch64_eg_configs new file mode 100644 index 0000000000000000000000000000000000000000..16cc6178461f2170759d2a5d24aad9e0607fc442 --- /dev/null +++ b/example/amp/openamp/core1/configs/ft2004_aarch64_eg_configs @@ -0,0 +1,161 @@ + +# +# Project Configuration +# + +# +# Baremetal Configuration +# +CONFIG_TARGET_NAME="openamp_core1" +CONFIG_SHM_BASE_ADDR=0xc0000000 +# end of Baremetal Configuration + +# +# Amp Config +# +CONFIG_IPI_IRQ_NUM=9 +CONFIG_IPI_IRQ_NUM_PRIORITY=16 +CONFIG_SPIN_MEM=0x80000000 +CONFIG_TARGET_CPU_ID=1 +CONFIG_IPI_CHN_BITMASK=1 +# end of Amp Config +# end of Project Configuration + +# +# Standalone Setting +# +CONFIG_USE_FREERTOS=y + +# +# Arch Configuration +# +# CONFIG_TARGET_ARMV8_AARCH32 is not set +CONFIG_TARGET_ARMV8_AARCH64=y +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +# CONFIG_USE_L3CACHE is not set +CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +# CONFIG_MMU_DEBUG_PRINTS is not set +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +CONFIG_TARGET_F2000_4=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_ENABLE_GICV3=y +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +# CONFIG_USE_ETH is not set +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set +# end of Components Configuration + +CONFIG_USE_NEW_LIBC=y +# end of Standalone Setting + +# +# Building Option +# +CONFIG_LOG_VERBOS=y +# CONFIG_LOG_DEBUG is not set +# CONFIG_LOG_INFO is not set +# CONFIG_LOG_WARN is not set +# CONFIG_LOG_ERROR is not set +# CONFIG_LOG_NONE is not set + +# +# Linker Options +# +# CONFIG_AARCH32_RAM_LD is not set +CONFIG_AARCH64_RAM_LD=y +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0xe0100000 +CONFIG_ROM_SIZE_MB=2 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0xe0300000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=1 +CONFIG_STACK_SIZE=0x100000 +# end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options +# end of Building Option + +# +# Component Configuration +# + +# +# Freertos Drivers +# +CONFIG_FREERTOS_USE_UART=y +# end of Freertos Drivers +# end of Component Configuration + +# +# FreeRTOS Setting +# +# CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +CONFIG_USE_AMP=y +CONFIG_USE_LIBMETAL=y + +# +# OpenAmp +# +CONFIG_USE_OPENAMP=y +CONFIG_USE_OPENAMP_IPI=y +CONFIG_OPENAMP_RESOURCES_ADDR=0xc0000000 +CONFIG_VRING_TX_ADDR=0xc0020000 +CONFIG_VRING_RX_ADDR=0xc0024000 +CONFIG_VRING_SIZE=0x100 +CONFIG_POLL_BASE_ADDR=0xc0224000 +# CONFIG_SKIP_SHBUF_IO_WRITE is not set +# CONFIG_USE_MASTER_VRING_DEFINE is not set + +# +# Baremetal config +# +CONFIG_MEM_NO_CACHE=y +# CONFIG_MEM_WRITE_THROUGH is not set +# CONFIG_MEM_NORMAL is not set +# end of Baremetal config +# end of OpenAmp + +# CONFIG_USE_LETTER_SHELL is not set +# end of FreeRTOS Setting diff --git a/example/amp/openamp/core1/main.c b/example/amp/openamp/core1/main.c new file mode 100644 index 0000000000000000000000000000000000000000..75927bb56c81bb19b12e954891e6cb251de5d553 --- /dev/null +++ b/example/amp/openamp/core1/main.c @@ -0,0 +1,61 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: main.c + * Date: 2022-02-25 13:25:14 + * LastEditTime: 2022-03-21 17:01:03 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + + +#include "ft_types.h" +#include "psci.h" +// #include "shell.h" +#include "fsleep.h" +#include "f_printk.h" +#include "ft_debug.h" +#include "FreeRTOS.h" +#include "task.h" +// #include "shell_port.h" + +#define OPENAMP_MAIN_DEBUG_TAG "OPENAMP_MAIN" +#define OPENAMP_MAIN_DEBUG_I(format, ...) FT_DEBUG_PRINT_I(OPENAMP_MAIN_DEBUG_TAG, format, ##__VA_ARGS__) +#define OPENAMP_MAIN_DEBUG_W(format, ...) FT_DEBUG_PRINT_W(OPENAMP_MAIN_DEBUG_TAG, format, ##__VA_ARGS__) +#define OPENAMP_MAIN_DEBUG_E(format, ...) FT_DEBUG_PRINT_E(OPENAMP_MAIN_DEBUG_TAG, format, ##__VA_ARGS__) + +extern void TestLetterShell() ; +extern int rpmsg_echo(int argc, char *argv[]) ; +extern int rpmsg_echo_task(void); + +int main(void) +{ + BaseType_t ret; + + // ret = LSUserShellTask() ; + // if(ret != pdPASS) + // goto FAIL_EXIT; + rpmsg_echo_task(); + + vTaskStartScheduler(); /* 启动任务,开启调度 */ + while (1); /* 正常不会执行到这里 */ + +FAIL_EXIT: + printf("failed 0x%x \r\n", ret); + return 0; +} + + diff --git a/example/amp/openamp/core1/makefile b/example/amp/openamp/core1/makefile new file mode 100644 index 0000000000000000000000000000000000000000..508a83855f4ad52ca11af950307444fcf435f87e --- /dev/null +++ b/example/amp/openamp/core1/makefile @@ -0,0 +1,59 @@ +export PROJECT_DIR ?= $(shell pwd) + +export USR_SRC_DIR = $(PROJECT_DIR) \ + $(PROJECT_DIR)/../src +export USR_INC_DIR = $(PROJECT_DIR) \ + $(PROJECT_DIR)/../src + +# 用户定义的编译目标文件上传路径 +ifeq ($(OS),Windows_NT) + USR_BOOT_DIR ?= $(subst \,/, $(PHYTIUM_DEV_PATH))/tftp +else + USR_BOOT_DIR ?= /mnt/d/tftboot +endif + +# 设置启动镜像名 +USER_BOOT_IMAGE ?= openamp_core1 + +# prepare output dir and start make +include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk + +.PHONY: rebuild boot config_amp_d2000_aarch64 backup_kconfig +load_amp_d2000_aarch64_config: + @cp $(PROJECT_DIR)/../configs/d2000_amp_core0_aarch64_defconfig \ + ./$(KCONFIG_CONFIG) -f + +load_amp_d2000_aarch32_config: + @cp $(PROJECT_DIR)/../configs/d2000_amp_core0_aarch32_defconfig \ + ./$(KCONFIG_CONFIG) -f + +rebuild: + make clean + make + +# 完成编译 +boot: + make -j + @cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(USER_BOOT_IMAGE).elf + @ls $(USR_BOOT_DIR)/$(USER_BOOT_IMAGE).elf -l + +config_amp_d2000_aarch64: load_amp_d2000_aarch64_config genconfig clean +config_amp_d2000_aarch32: load_amp_d2000_aarch32_config genconfig clean + + +ifdef CONFIG_TARGET_ARMV8_AARCH32 + USR_CONFIGS := $(USR_CONFIGS_AARCH32) +endif + +ifdef CONFIG_TARGET_ARMV8_AARCH64 + USR_CONFIGS := $(USR_CONFIGS_AARCH64) +endif + + + +ifdef CONFIG_TARGET_ARMV8_AARCH64 +ifdef CONFIG_TARGET_D2000 + cp -f sdkconfig ./configs/d2000_aarch64_eg_configs +endif +endif + diff --git a/example/amp/openamp/core1/rpmsg-ping_os.c b/example/amp/openamp/core1/rpmsg-ping_os.c new file mode 100644 index 0000000000000000000000000000000000000000..8731af53da49122e921b005d7fa9f66c29efdfd0 --- /dev/null +++ b/example/amp/openamp/core1/rpmsg-ping_os.c @@ -0,0 +1,241 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* This is a sample demonstration application that showcases usage of rpmsg +This application is meant to run on the remote CPU running baremetal code. +This application echoes back data that was sent to it by the master core. */ + +/***************************** Include Files *********************************/ + +#include +#include +#include +#include +#include +#include +#include "ft_types.h" +#include "platform_info.h" +#include "rpmsg-echo.h" +#include "FreeRTOS.h" +#include "task.h" + +/***************** Macros (Inline Functions) Definitions *********************/ + +#define LPRINTF(format, ...) printf(format, ##__VA_ARGS__) +#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__) + +/**************************** Type Definitions *******************************/ + +struct _payload { + unsigned long num; + unsigned long size; + unsigned char data[]; +}; + +static int err_cnt; +static char flg_cnt; + +#define PAYLOAD_MIN_SIZE 1 + + +/************************** Variable Definitions *****************************/ + +/* Globals */ +static struct rpmsg_endpoint lept; +static struct _payload *i_payload; +static int rnum = 0; +static int err_cnt = 0; +static int ept_deleted = 0; + +/************************** Function Prototypes ******************************/ + +/*-----------------------------------------------------------------------------* + * RPMSG endpoint callbacks + *-----------------------------------------------------------------------------*/ +static int rpmsg_endpoint_cb(struct rpmsg_endpoint *ept, void *data, size_t len, + uint32_t src, void *priv) +{ + int i; + struct _payload *r_payload = (struct _payload *)data; + + (void)ept; + (void)src; + (void)priv; +#ifdef CONFIG_MEM_NORMAL + FCacheDCacheInvalidateRange((intptr)data, len); +#endif + + if (r_payload->size == 0) { + LPERROR(" Invalid size of package is received.\r\n"); + err_cnt++; + return RPMSG_SUCCESS; + } + /* Validate data buffer integrity. */ + for (i = 0; i < (int)r_payload->size; i++) { + if (r_payload->data[i] != flg_cnt) { + LPRINTF("Data corruption at index %d\r\n", i); + LPRINTF("Want data is %d\r\n", flg_cnt); + LPRINTF("Get data is %d\r\n", r_payload->data[i]); + err_cnt++; + break; + } + } + rnum = r_payload->num + 1; + return RPMSG_SUCCESS; +} + +static void rpmsg_service_unbind(struct rpmsg_endpoint *ept) +{ + (void)ept; + rpmsg_destroy_ept(&lept); + LPRINTF("echo test: service is destroyed\r\n"); + ept_deleted = 1; +} + +static void rpmsg_name_service_bind_cb(struct rpmsg_device *rdev, + const char *name, uint32_t dest) +{ + LPRINTF("new endpoint notification is received.\r\n"); + if (strcmp(name, RPMSG_SERVICE_NAME)) + LPERROR("Unexpected name service %s.\r\n", name); + else + (void)rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME, + RPMSG_ADDR_ANY, dest, + rpmsg_endpoint_cb, + rpmsg_service_unbind); + +} + +/*-----------------------------------------------------------------------------* + * Application + *-----------------------------------------------------------------------------*/ +int app (struct rpmsg_device *rdev, void *priv) +{ + int ret; + int i; + int size, max_size, num_payloads; + int expect_rnum = 0; + + LPRINTF(" 1 - Send data to remote core, retrieve the echo"); + LPRINTF(" and validate its integrity ..\r\n"); + + max_size = rpmsg_virtio_get_buffer_size(rdev); + if (max_size < 0) { + LPERROR("No avaiable buffer size.\r\n"); + return -1; + } + max_size -= sizeof(struct _payload); + num_payloads = max_size - PAYLOAD_MIN_SIZE + 1; + i_payload = + (struct _payload *)metal_allocate_memory(2 * sizeof(unsigned long) + + max_size); + + if (!i_payload) { + LPERROR("memory allocation failed.\r\n"); + return -1; + } + + /* Create RPMsg endpoint */ + ret = rpmsg_create_ept(&lept, rdev, RPMSG_SERVICE_NAME, + RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, + rpmsg_endpoint_cb, rpmsg_service_unbind); + + if (ret) { + LPERROR("Failed to create RPMsg endpoint.\r\n"); + metal_free_memory(i_payload); + return ret; + } + while (!is_rpmsg_ept_ready(&lept)) + platform_poll(priv); + + LPRINTF("RPMSG endpoint is binded with remote.\r\n"); + for (i = 0, size = PAYLOAD_MIN_SIZE; i < num_payloads; i++, size++) { + i_payload->num = i; + i_payload->size = size; + flg_cnt++; + /* Mark the data buffer. */ + memset(&(i_payload->data[0]), flg_cnt, size); + + ret = rpmsg_send(&lept, i_payload, + (2 * sizeof(unsigned long)) + size); + + if (ret < 0) { + LPERROR("Failed to send data...\r\n"); + break; + } + + expect_rnum++; + do { + platform_poll(priv); + } while ((rnum < expect_rnum) && !err_cnt && !ept_deleted); + + } + + LPRINTF("**********************************\r\n"); + LPRINTF(" Test Results: Error count = %d \r\n", err_cnt); + LPRINTF("**********************************\r\n"); + /* Destroy the RPMsg endpoint */ + rpmsg_destroy_ept(&lept); + LPRINTF("Quitting application .. Echo test end\r\n"); + + metal_free_memory(i_payload); + return 0; +} + + +static void rpmsg_ping(void *args) +{ + void *platform; + struct rpmsg_device *rpdev; + int ret = 0; + /* Initialize platform */ + ret = platform_init(0, NULL, &platform); + if (ret) { + LPERROR("Failed to initialize platform.\r\n"); + } + else + { + rpdev = platform_create_rpmsg_vdev(platform, 0, + VIRTIO_DEV_MASTER, + NULL, + rpmsg_name_service_bind_cb); + if (!rpdev) { + LPERROR("Failed to create platform_create_rpmsg_vdev\r\n"); + } + else + { + app(rpdev, platform); + platform_release_rpmsg_vdev(rpdev, platform); + } + } + + LPRINTF("Stopping application...\r\n"); + platform_cleanup(platform); + // PsciCpuOff(); + vTaskDelete(NULL); +} + + + + +int rpmsg_echo_task(void) +{ + BaseType_t ret; + + ret = xTaskCreate((TaskFunction_t )rpmsg_ping, /* 任务入口函数 */ + (const char* )"rpmsg_ping",/* 任务名字 */ + (uint16_t )4096, /* 任务栈大小 */ + (void* )NULL,/* 任务入口函数参数 */ + (UBaseType_t )1, /* 任务的优先级 */ + NULL); /* 任务控制块指针 */ + + if(ret != pdPASS) + { + LPERROR("Failed to create a rpmsg_echo task "); + return -1; + } + + return 0; +} + diff --git a/example/amp/openamp/core1/sdkconfig b/example/amp/openamp/core1/sdkconfig new file mode 100644 index 0000000000000000000000000000000000000000..5e58d0e87d6313a268d46156ccdd4ed28c7c2c7f --- /dev/null +++ b/example/amp/openamp/core1/sdkconfig @@ -0,0 +1,168 @@ + +# +# Project Configuration +# + +# +# Baremetal Configuration +# +CONFIG_TARGET_NAME="openamp_core1" +CONFIG_SHM_BASE_ADDR=0xc0000000 +# end of Baremetal Configuration + +# +# Amp Config +# +CONFIG_IPI_IRQ_NUM=9 +CONFIG_IPI_IRQ_NUM_PRIORITY=16 +CONFIG_SPIN_MEM=0x80000000 +CONFIG_TARGET_CPU_ID=1 +CONFIG_IPI_CHN_BITMASK=1 +CONFIG_WITH_BAREMETAL=y +# end of Amp Config +# end of Project Configuration + +# +# Standalone Setting +# +CONFIG_USE_FREERTOS=y + +# +# Arch Configuration +# +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set +# CONFIG_TARGET_ARMV7 is not set +CONFIG_USE_CACHE=y +# CONFIG_USE_L3CACHE is not set +CONFIG_USE_MMU=y +# CONFIG_USE_SYS_TICK is not set +# CONFIG_USE_AARCH64_L1_TO_AARCH32 is not set +# end of Arch Configuration + +# +# Board Configuration +# +# CONFIG_TARGET_F2000_4 is not set +CONFIG_TARGET_F2000_4=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set +# end of Board Configuration + +# +# Components Configuration +# +# CONFIG_USE_SPI is not set +# CONFIG_USE_QSPI is not set +CONFIG_USE_GIC=y +CONFIG_ENABLE_GICV3=y +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + +# CONFIG_USE_GPIO is not set +# CONFIG_USE_IOMUX is not set +# CONFIG_USE_ETH is not set +# CONFIG_USE_CAN is not set +# CONFIG_USE_I2C is not set +# CONFIG_USE_TIMER is not set +# CONFIG_USE_SDMMC is not set +# CONFIG_USE_PCIE is not set +# CONFIG_USE_WDT is not set +# CONFIG_USE_DMA is not set +# CONFIG_USE_NAND is not set +# CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set +# end of Components Configuration + +CONFIG_USE_NEW_LIBC=y +# end of Standalone Setting + +# +# Building Option +# + +# +# Linker Options +# +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set +# CONFIG_USER_DEFINED_LD is not set +CONFIG_LINK_SCRIPT_ROM=y +CONFIG_ROM_START_UP_ADDR=0xe0100000 +CONFIG_ROM_SIZE_MB=2 +CONFIG_LINK_SCRIPT_RAM=y +CONFIG_RAM_START_UP_ADDR=0xe0300000 +CONFIG_RAM_SIZE_MB=64 +CONFIG_HEAP_SIZE=1 +CONFIG_SVC_STACK_SIZE=0x1000 +CONFIG_SYS_STACK_SIZE=0x1000 +CONFIG_IRQ_STACK_SIZE=0x1000 +CONFIG_ABORT_STACK_SIZE=0x1000 +CONFIG_FIQ_STACK_SIZE=0x1000 +CONFIG_UNDEF_STACK_SIZE=0x1000 +# end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options + +CONFIG_LOG_VERBOS=y +# CONFIG_LOG_DEBUG is not set +# CONFIG_LOG_INFO is not set +# CONFIG_LOG_WARN is not set +# CONFIG_LOG_ERROR is not set +# CONFIG_LOG_NONE is not set +# end of Building Option + +# +# Component Configuration +# + +# +# Freertos Drivers +# +CONFIG_FREERTOS_USE_UART=y +# end of Freertos Drivers +# end of Component Configuration + +# +# FreeRTOS Setting +# +# CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +CONFIG_USE_AMP=y +CONFIG_USE_LIBMETAL=y + +# +# OpenAmp +# +CONFIG_USE_OPENAMP=y +CONFIG_USE_OPENAMP_IPI=y +CONFIG_OPENAMP_RESOURCES_ADDR=0xc0000000 +CONFIG_VRING_TX_ADDR=0xc0020000 +CONFIG_VRING_RX_ADDR=0xc0024000 +CONFIG_VRING_SIZE=0x100 +CONFIG_POLL_BASE_ADDR=0xc0224000 +# CONFIG_SKIP_SHBUF_IO_WRITE is not set +# CONFIG_USE_MASTER_VRING_DEFINE is not set + +# +# Baremetal config +# +CONFIG_MEM_NO_CACHE=y +# CONFIG_MEM_WRITE_THROUGH is not set +# CONFIG_MEM_NORMAL is not set +# end of Baremetal config +# end of OpenAmp + +# CONFIG_USE_LETTER_SHELL is not set +# end of FreeRTOS Setting diff --git a/example/amp/openamp/core1/sdkconfig.h b/example/amp/openamp/core1/sdkconfig.h new file mode 100644 index 0000000000000000000000000000000000000000..5ece8e72c2a0f3872ff52c48234eba7354535a84 --- /dev/null +++ b/example/amp/openamp/core1/sdkconfig.h @@ -0,0 +1,149 @@ +#ifndef SDK_CONFIG_H__ +#define SDK_CONFIG_H__ + +/* Project Configuration */ + +/* Baremetal Configuration */ + +#define CONFIG_TARGET_NAME "openamp_core1" +#define CONFIG_SHM_BASE_ADDR 0xc0000000 +/* end of Baremetal Configuration */ + +/* Amp Config */ + +#define CONFIG_IPI_IRQ_NUM 9 +#define CONFIG_IPI_IRQ_NUM_PRIORITY 16 +#define CONFIG_SPIN_MEM 0x80000000 +#define CONFIG_TARGET_CPU_ID 1 +#define CONFIG_IPI_CHN_BITMASK 1 +#define CONFIG_WITH_BAREMETAL +/* end of Amp Config */ +/* end of Project Configuration */ + +/* Standalone Setting */ + +#define CONFIG_USE_FREERTOS + +/* Arch Configuration */ + +#define CONFIG_TARGET_ARMV8_AARCH32 +/* CONFIG_TARGET_ARMV8_AARCH64 is not set */ +/* CONFIG_TARGET_ARMV7 is not set */ +#define CONFIG_USE_CACHE +/* CONFIG_USE_L3CACHE is not set */ +#define CONFIG_USE_MMU +/* CONFIG_USE_SYS_TICK is not set */ +/* CONFIG_USE_AARCH64_L1_TO_AARCH32 is not set */ +/* end of Arch Configuration */ + +/* Board Configuration */ + +/* CONFIG_TARGET_F2000_4 is not set */ +#define CONFIG_TARGET_F2000_4 +/* CONFIG_TARGET_E2000Q is not set */ +/* CONFIG_TARGET_E2000D is not set */ +/* CONFIG_TARGET_E2000S is not set */ +/* end of Board Configuration */ + +/* Components Configuration */ + +/* CONFIG_USE_SPI is not set */ +/* CONFIG_USE_QSPI is not set */ +#define CONFIG_USE_GIC +#define CONFIG_ENABLE_GICV3 +#define CONFIG_USE_SERIAL + +/* Usart Configuration */ + +#define CONFIG_ENABLE_Pl011_UART +/* end of Usart Configuration */ +/* CONFIG_USE_GPIO is not set */ +/* CONFIG_USE_IOMUX is not set */ +/* CONFIG_USE_ETH is not set */ +/* CONFIG_USE_CAN is not set */ +/* CONFIG_USE_I2C is not set */ +/* CONFIG_USE_TIMER is not set */ +/* CONFIG_USE_SDMMC is not set */ +/* CONFIG_USE_PCIE is not set */ +/* CONFIG_USE_WDT is not set */ +/* CONFIG_USE_DMA is not set */ +/* CONFIG_USE_NAND is not set */ +/* CONFIG_USE_RTC is not set */ +/* CONFIG_USE_SATA is not set */ +/* CONFIG_USE_USB is not set */ +/* end of Components Configuration */ +#define CONFIG_USE_NEW_LIBC +/* end of Standalone Setting */ + +/* Building Option */ + +/* Linker Options */ + +#define CONFIG_AARCH32_RAM_LD +/* CONFIG_AARCH64_RAM_LD is not set */ +/* CONFIG_USER_DEFINED_LD is not set */ +#define CONFIG_LINK_SCRIPT_ROM +#define CONFIG_ROM_START_UP_ADDR 0xe0100000 +#define CONFIG_ROM_SIZE_MB 2 +#define CONFIG_LINK_SCRIPT_RAM +#define CONFIG_RAM_START_UP_ADDR 0xe0300000 +#define CONFIG_RAM_SIZE_MB 64 +#define CONFIG_HEAP_SIZE 1 +#define CONFIG_SVC_STACK_SIZE 0x1000 +#define CONFIG_SYS_STACK_SIZE 0x1000 +#define CONFIG_IRQ_STACK_SIZE 0x1000 +#define CONFIG_ABORT_STACK_SIZE 0x1000 +#define CONFIG_FIQ_STACK_SIZE 0x1000 +#define CONFIG_UNDEF_STACK_SIZE 0x1000 +/* end of Linker Options */ + +/* Compiler Options */ + +#define CONFIG_DON_T_BINARY_OUTPUT +/* end of Compiler Options */ +#define CONFIG_LOG_VERBOS +/* CONFIG_LOG_DEBUG is not set */ +/* CONFIG_LOG_INFO is not set */ +/* CONFIG_LOG_WARN is not set */ +/* CONFIG_LOG_ERROR is not set */ +/* CONFIG_LOG_NONE is not set */ +/* end of Building Option */ + +/* Component Configuration */ + +/* Freertos Drivers */ + +#define CONFIG_FREERTOS_USE_UART +/* end of Freertos Drivers */ +/* end of Component Configuration */ + +/* FreeRTOS Setting */ + +/* CONFIG_USE_LWIP is not set */ +#define CONFIG_USE_BACKTRACE +#define CONFIG_USE_AMP +#define CONFIG_USE_LIBMETAL + +/* OpenAmp */ + +#define CONFIG_USE_OPENAMP +#define CONFIG_USE_OPENAMP_IPI +#define CONFIG_OPENAMP_RESOURCES_ADDR 0xc0000000 +#define CONFIG_VRING_TX_ADDR 0xc0020000 +#define CONFIG_VRING_RX_ADDR 0xc0024000 +#define CONFIG_VRING_SIZE 0x100 +#define CONFIG_POLL_BASE_ADDR 0xc0224000 +/* CONFIG_SKIP_SHBUF_IO_WRITE is not set */ +/* CONFIG_USE_MASTER_VRING_DEFINE is not set */ + +/* Baremetal config */ + +#define CONFIG_MEM_NO_CACHE +/* CONFIG_MEM_WRITE_THROUGH is not set */ +/* CONFIG_MEM_NORMAL is not set */ +/* end of Baremetal config */ +/* end of OpenAmp */ +/* CONFIG_USE_LETTER_SHELL is not set */ +/* end of FreeRTOS Setting */ + +#endif diff --git a/example/amp/openamp/figs/Core0Openampconfig.png b/example/amp/openamp/figs/Core0Openampconfig.png new file mode 100644 index 0000000000000000000000000000000000000000..e1d4711185046681dcb8173d4ba5bdfc220ca934 Binary files /dev/null and b/example/amp/openamp/figs/Core0Openampconfig.png differ diff --git a/example/amp/openamp/figs/Core1Openampconfig.png b/example/amp/openamp/figs/Core1Openampconfig.png new file mode 100644 index 0000000000000000000000000000000000000000..dd4e445bb261cf637b03afcdb6e1fcf4e611d9e7 Binary files /dev/null and b/example/amp/openamp/figs/Core1Openampconfig.png differ diff --git a/example/amp/openamp/figs/OpenAmpConfig.png b/example/amp/openamp/figs/OpenAmpConfig.png new file mode 100644 index 0000000000000000000000000000000000000000..3b3ba3cb7357e99f98c13ed4f5b25a34c83cfebe Binary files /dev/null and b/example/amp/openamp/figs/OpenAmpConfig.png differ diff --git a/example/amp/openamp/figs/d2000_aarch32_openamp_reault.png b/example/amp/openamp/figs/d2000_aarch32_openamp_reault.png new file mode 100644 index 0000000000000000000000000000000000000000..6a362bfd29dd6ddb4d84e6a636d3fa7ff4e94d99 Binary files /dev/null and b/example/amp/openamp/figs/d2000_aarch32_openamp_reault.png differ diff --git a/example/amp/openamp/figs/d2000_aarch32_openamp_startup.png b/example/amp/openamp/figs/d2000_aarch32_openamp_startup.png new file mode 100644 index 0000000000000000000000000000000000000000..903e8bf322283f725c860448b254b527282e0fe2 Binary files /dev/null and b/example/amp/openamp/figs/d2000_aarch32_openamp_startup.png differ diff --git a/example/amp/openamp/figs/d2000_aarch64_openamp_reault.png b/example/amp/openamp/figs/d2000_aarch64_openamp_reault.png new file mode 100644 index 0000000000000000000000000000000000000000..6a362bfd29dd6ddb4d84e6a636d3fa7ff4e94d99 Binary files /dev/null and b/example/amp/openamp/figs/d2000_aarch64_openamp_reault.png differ diff --git a/example/amp/openamp/figs/d2000_aarch64_openamp_startup.png b/example/amp/openamp/figs/d2000_aarch64_openamp_startup.png new file mode 100644 index 0000000000000000000000000000000000000000..1e632b129a45b68482b7575bb15f0192f16f884f Binary files /dev/null and b/example/amp/openamp/figs/d2000_aarch64_openamp_startup.png differ diff --git a/example/amp/openamp/figs/d2000_linux_reasult.png b/example/amp/openamp/figs/d2000_linux_reasult.png new file mode 100644 index 0000000000000000000000000000000000000000..9c41c4cc1c6f93800ce9ad1c28ba7a14cab51eb8 Binary files /dev/null and b/example/amp/openamp/figs/d2000_linux_reasult.png differ diff --git a/example/amp/openamp/figs/freertos_openamp_d2000_aarch32_ampconfig.png b/example/amp/openamp/figs/freertos_openamp_d2000_aarch32_ampconfig.png new file mode 100644 index 0000000000000000000000000000000000000000..139f8c3f92553fd3070fc2dd960502ab4d8e11a6 Binary files /dev/null and b/example/amp/openamp/figs/freertos_openamp_d2000_aarch32_ampconfig.png differ diff --git a/example/amp/openamp/figs/freertos_openamp_d2000_aarch32_config.png b/example/amp/openamp/figs/freertos_openamp_d2000_aarch32_config.png new file mode 100644 index 0000000000000000000000000000000000000000..f834e64ba3a844578f505b4d8b47ac9070fd208f Binary files /dev/null and b/example/amp/openamp/figs/freertos_openamp_d2000_aarch32_config.png differ diff --git a/example/amp/openamp/makefile b/example/amp/openamp/makefile new file mode 100644 index 0000000000000000000000000000000000000000..c91470fc05676481e3c61adb5a7224dae1ef4b29 --- /dev/null +++ b/example/amp/openamp/makefile @@ -0,0 +1,63 @@ +# Compiling for specific instance + +.PHONY: all clean boot core0 core1 menuconfig_core0 menuconfig_core1 autobuild + + +core0: + $(MAKE) -C ./core0 -j + +core1: + $(MAKE) -C ./core1 -j + +clean_core0: + $(MAKE) -C ./core0 clean + +clean_core1: + $(MAKE) -C ./core1 clean + +boot_core0: + $(MAKE) -C ./core0 boot + +boot_core1: + $(MAKE) -C ./core1 boot + +config_amp_d2000_aarch64_core0: + $(MAKE) -C ./core0 load_d2000_aarch64 + +config_amp_d2000_aarch64_core1: + $(MAKE) -C ./core1 load_d2000_aarch64 + +config_amp_d2000_aarch32_core0: + $(MAKE) -C ./core0 load_d2000_aarch32 + +config_amp_d2000_aarch32_core1: + $(MAKE) -C ./core1 load_d2000_aarch32 + +config_amp_ft2004_aarch64_core0: + $(MAKE) -C ./core0 load_ft2004_aarch64 + +config_amp_ft2004_aarch64_core1: + $(MAKE) -C ./core1 load_ft2004_aarch64 + +config_amp_ft2004_aarch32_core0: + $(MAKE) -C ./core0 load_ft2004_aarch32 + +config_amp_ft2004_aarch32_core1: + $(MAKE) -C ./core1 load_ft2004_aarch32 + +menuconfig_core0: + $(MAKE) -C ./core0 menuconfig + +menuconfig_core1: + $(MAKE) -C ./core1 menuconfig + +all: core0 core1 +clean: clean_core0 clean_core1 +boot: boot_core0 boot_core1 +config_amp_d2000_aarch64: config_amp_d2000_aarch64_core0 config_amp_d2000_aarch64_core1 +config_amp_d2000_aarch32: config_amp_d2000_aarch32_core0 config_amp_d2000_aarch32_core1 +config_amp_ft2004_aarch64: config_amp_ft2004_aarch64_core0 config_amp_ft2004_aarch64_core1 +config_amp_ft2004_aarch32: config_amp_ft2004_aarch32_core0 config_amp_ft2004_aarch32_core1 + + + diff --git a/example/freertos_test/README.md b/example/freertos_test/README.md index 59086c1da707c1bd3578d9c93bb95ad0b6fb3ee1..972b16cefa6c217e564db67ef00621f5649a979c 100644 --- a/example/freertos_test/README.md +++ b/example/freertos_test/README.md @@ -1,16 +1,26 @@ + # function test base on freertos ## 1. 例程介绍 diff --git a/example/freertos_test/configs/d2000_aarch32_eg_configs b/example/freertos_test/configs/d2000_aarch32_eg_configs index 0dfaa7ac2369850dfd9af7c301f59aca89ff411f..311dd1d91ef9a63a86447691d9cb05099205b4cb 100644 --- a/example/freertos_test/configs/d2000_aarch32_eg_configs +++ b/example/freertos_test/configs/d2000_aarch32_eg_configs @@ -29,8 +29,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -40,7 +42,14 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -70,24 +79,16 @@ CONFIG_ENABLE_FWDT=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -115,6 +116,12 @@ CONFIG_ABORT_STACK_SIZE=0x1000 CONFIG_FIQ_STACK_SIZE=0x1000 CONFIG_UNDEF_STACK_SIZE=0x1000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -132,4 +139,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/freertos_test/configs/d2000_aarch64_eg_configs b/example/freertos_test/configs/d2000_aarch64_eg_configs index f83c5237390d139dc4e454bc74f63302238e8480..ca6275911c622b0a31248d9b9464c590c3a1c781 100644 --- a/example/freertos_test/configs/d2000_aarch64_eg_configs +++ b/example/freertos_test/configs/d2000_aarch64_eg_configs @@ -21,15 +21,18 @@ CONFIG_TARGET_ARMV8_AARCH64=y CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y -# CONFIG_USE_SYS_TICK is not set +CONFIG_USE_SYS_TICK=y +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -39,7 +42,14 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -69,24 +79,16 @@ CONFIG_ENABLE_FWDT=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -109,6 +111,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -126,4 +134,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/freertos_test/configs/ft2004_aarch32_eg_configs b/example/freertos_test/configs/ft2004_aarch32_eg_configs index 0f8e8d966965f2bfe4d08edb3419f62e5de374c2..a4d10dad439f55c4424d21848e2fda709c59128b 100644 --- a/example/freertos_test/configs/ft2004_aarch32_eg_configs +++ b/example/freertos_test/configs/ft2004_aarch32_eg_configs @@ -29,8 +29,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y # Board Configuration # CONFIG_TARGET_F2000_4=y -# CONFIG_TARGET_E2000 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -40,7 +42,14 @@ CONFIG_TARGET_F2000_4=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -70,24 +79,16 @@ CONFIG_ENABLE_FWDT=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -115,6 +116,12 @@ CONFIG_ABORT_STACK_SIZE=0x1000 CONFIG_FIQ_STACK_SIZE=0x1000 CONFIG_UNDEF_STACK_SIZE=0x1000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -132,4 +139,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/freertos_test/configs/ft2004_aarch64_eg_configs b/example/freertos_test/configs/ft2004_aarch64_eg_configs index 273b87420b590a3e55ed293be8621baaccfdf7c0..870a8e862d49f5eee5f0bcbe728b5caaf0eb30d3 100644 --- a/example/freertos_test/configs/ft2004_aarch64_eg_configs +++ b/example/freertos_test/configs/ft2004_aarch64_eg_configs @@ -22,14 +22,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y CONFIG_USE_SYS_TICK=y +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # CONFIG_TARGET_F2000_4=y -# CONFIG_TARGET_E2000 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -39,7 +42,14 @@ CONFIG_TARGET_F2000_4=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -69,24 +79,16 @@ CONFIG_ENABLE_FWDT=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -109,6 +111,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -126,4 +134,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/freertos_test/unity.h b/example/freertos_test/inc/unity.h similarity index 100% rename from example/freertos_test/unity.h rename to example/freertos_test/inc/unity.h diff --git a/example/freertos_test/unity_internals.h b/example/freertos_test/inc/unity_internals.h similarity index 100% rename from example/freertos_test/unity_internals.h rename to example/freertos_test/inc/unity_internals.h diff --git a/example/freertos_test/main.c b/example/freertos_test/main.c index 69c2be1259c562e5bd4c985a23478b396ae9d801..15a3fb417e76a55fe6788ac0257423dae51e7ee6 100644 --- a/example/freertos_test/main.c +++ b/example/freertos_test/main.c @@ -1,16 +1,26 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-09 08:08:39 - * @LastEditTime: 2021-08-25 18:40:20 - * @Description:  This files is for freertos test + * FilePath: main.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:01:13 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include "parameters.h" #include "ft_types.h" diff --git a/example/freertos_test/makefile b/example/freertos_test/makefile index d8b858a95db430b15d9dec91957b2d01981d1198..0d410a80d72c1fff5cf6d420171b98176766c389 100644 --- a/example/freertos_test/makefile +++ b/example/freertos_test/makefile @@ -1,10 +1,10 @@ # 指定工程项目根目录为当前(只能指定一个目录) -export PROJECT_DIR ?= . +export PROJECT_DIR ?= $(shell pwd) # 用户添加的源文件夹和头文件夹(可以指定多个) -export USR_SRC_DIR ?= . \ - ./src -export USR_INC_DIR ?= . \ - ./inc +export USR_SRC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/src +export USR_INC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/inc # 用户定义的编译目标文件上传路径 ifeq ($(OS),Windows_NT) @@ -23,6 +23,5 @@ include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk # 完成编译 boot: make -# @echo tar $(CONFIG_TARGET_NAME) -# @echo img $(BOOT_IMG_NAME) cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf + diff --git a/example/freertos_test/sdkconfig b/example/freertos_test/sdkconfig index f83c5237390d139dc4e454bc74f63302238e8480..ca6275911c622b0a31248d9b9464c590c3a1c781 100644 --- a/example/freertos_test/sdkconfig +++ b/example/freertos_test/sdkconfig @@ -21,15 +21,18 @@ CONFIG_TARGET_ARMV8_AARCH64=y CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y -# CONFIG_USE_SYS_TICK is not set +CONFIG_USE_SYS_TICK=y +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -39,7 +42,14 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -69,24 +79,16 @@ CONFIG_ENABLE_FWDT=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -109,6 +111,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -126,4 +134,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/freertos_test/sdkconfig.h b/example/freertos_test/sdkconfig.h index 0db78ce5d1b4116aa7f0218d1fef3be0168ad701..b4dd5ab22b6a0453888d2c37d9881d201812f14a 100644 --- a/example/freertos_test/sdkconfig.h +++ b/example/freertos_test/sdkconfig.h @@ -20,14 +20,17 @@ #define CONFIG_USE_CACHE #define CONFIG_USE_L3CACHE #define CONFIG_USE_MMU -/* CONFIG_USE_SYS_TICK is not set */ +#define CONFIG_USE_SYS_TICK +/* CONFIG_MMU_DEBUG_PRINTS is not set */ /* end of Arch Configuration */ /* Board Configuration */ /* CONFIG_TARGET_F2000_4 is not set */ -/* CONFIG_TARGET_E2000 is not set */ #define CONFIG_TARGET_D2000 +/* CONFIG_TARGET_E2000Q is not set */ +/* CONFIG_TARGET_E2000D is not set */ +/* CONFIG_TARGET_E2000S is not set */ /* end of Board Configuration */ /* Components Configuration */ @@ -36,7 +39,12 @@ /* CONFIG_USE_QSPI is not set */ #define CONFIG_USE_GIC #define CONFIG_ENABLE_GICV3 -/* CONFIG_USE_SERIAL is not set */ +#define CONFIG_USE_SERIAL + +/* Usart Configuration */ + +#define CONFIG_ENABLE_Pl011_UART +/* end of Usart Configuration */ /* CONFIG_USE_GPIO is not set */ /* CONFIG_USE_IOMUX is not set */ #define CONFIG_USE_ETH @@ -62,19 +70,14 @@ /* CONFIG_USE_DMA is not set */ /* CONFIG_USE_NAND is not set */ /* CONFIG_USE_RTC is not set */ +/* CONFIG_USE_SATA is not set */ +/* CONFIG_USE_USB is not set */ /* end of Components Configuration */ -#define CONFIG_USE_G_LIBC -/* CONFIG_USE_NEW_LIBC is not set */ +#define CONFIG_USE_NEW_LIBC /* end of Standalone Setting */ /* Building Option */ -/* Cross-Compiler Setting */ - -#define CONFIG_COMPILER_NO_STD_STARUP -#define CONFIG_GCC_OPTIMIZE_LEVEL 0 -/* CONFIG_USE_EXT_COMPILER is not set */ -/* end of Cross-Compiler Setting */ /* CONFIG_LOG_VERBOS is not set */ /* CONFIG_LOG_DEBUG is not set */ #define CONFIG_LOG_INFO @@ -94,8 +97,13 @@ #define CONFIG_RAM_START_UP_ADDR 0x81000000 #define CONFIG_RAM_SIZE_MB 64 #define CONFIG_HEAP_SIZE 1 -#define CONFIG_STACK_SIZE 0x400 +#define CONFIG_STACK_SIZE 0x100000 /* end of Linker Options */ + +/* Compiler Options */ + +#define CONFIG_DON_T_BINARY_OUTPUT +/* end of Compiler Options */ /* end of Building Option */ /* Component Configuration */ @@ -109,6 +117,9 @@ /* FreeRTOS Setting */ /* CONFIG_USE_LWIP is not set */ +#define CONFIG_USE_BACKTRACE +/* CONFIG_USE_AMP is not set */ +/* CONFIG_USE_LETTER_SHELL is not set */ /* end of FreeRTOS Setting */ #endif diff --git a/example/freertos_test/float_in_isr.c b/example/freertos_test/src/float_in_isr.c similarity index 77% rename from example/freertos_test/float_in_isr.c rename to example/freertos_test/src/float_in_isr.c index a1ec04b8689eb4f0814646da0bf926ca62bcf6c1..f8b849187ec9688fe688420aa87ac83f79c284d3 100644 --- a/example/freertos_test/float_in_isr.c +++ b/example/freertos_test/src/float_in_isr.c @@ -1,17 +1,27 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 10:28:22 - * @LastEditTime: 2021-07-22 09:05:53 - * @Description:  This files is for + * FilePath: float_in_isr.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:01:06 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include #include diff --git a/example/freertos_test/freertos_backported_functions.c b/example/freertos_test/src/freertos_backported_functions.c similarity index 83% rename from example/freertos_test/freertos_backported_functions.c rename to example/freertos_test/src/freertos_backported_functions.c index 5362ed2b5fd736e814d201fdbc390e06b77b142c..2aab2d1988bd25945857abdbe35d0d81d2473cdf 100644 --- a/example/freertos_test/freertos_backported_functions.c +++ b/example/freertos_test/src/freertos_backported_functions.c @@ -114,16 +114,16 @@ void QueueFuncTest(void) QueueHandle_t handle = xQueueCreateStatic(NO_OF_ITEMS, ITEM_SIZE,(uint8_t*) &queue_storage_area, &queue_buffer); - FT_ASSERTVOID(pdTRUE==xQueueSendToBack(handle, &queue_item_to_send, DELAY_TICKS)); + FASSERT(pdTRUE==xQueueSendToBack(handle, &queue_item_to_send, DELAY_TICKS)); vTaskDelay(1); - FT_ASSERTVOID(pdTRUE==xQueueReceive(handle, queue_item_received, DELAY_TICKS)); + FASSERT(pdTRUE==xQueueReceive(handle, queue_item_received, DELAY_TICKS)); vTaskDelay(1); for(i = 0; i < ITEM_SIZE; i++) { /*Check received contents are correct*/ - FT_ASSERTVOID(queue_item_to_send[i]==queue_item_received[i]); + FASSERT(queue_item_to_send[i]==queue_item_received[i]); } /*Technically not needed as deleting static queue/semphr doesn't clear static memory*/ @@ -133,10 +133,10 @@ void QueueFuncTest(void) handle = xSemaphoreCreateBinaryStatic(&queue_buffer); /*Queue and Semphr handles are the same*/ - FT_ASSERTVOID(pdTRUE==xSemaphoreGive(handle)); + FASSERT(pdTRUE==xSemaphoreGive(handle)); vTaskDelay(1); - FT_ASSERTVOID(pdTRUE==xSemaphoreTake(handle, DELAY_TICKS)); + FASSERT(pdTRUE==xSemaphoreTake(handle, DELAY_TICKS)); vTaskDelay(1); vSemaphoreDelete(handle); @@ -145,48 +145,48 @@ void QueueFuncTest(void) handle = xSemaphoreCreateCountingStatic(NO_OF_ITEMS, 0, &queue_buffer); for(i = 0; i < NO_OF_ITEMS; i++) { - FT_ASSERTVOID(pdTRUE==xSemaphoreGive(handle)); + FASSERT(pdTRUE==xSemaphoreGive(handle)); } vTaskDelay(1); /*Test uxSemaphoreGetCount()*/ - FT_ASSERTVOID(NO_OF_ITEMS== uxSemaphoreGetCount(handle)); + FASSERT(NO_OF_ITEMS== uxSemaphoreGetCount(handle)); for(i = 0; i < NO_OF_ITEMS; i++) { - FT_ASSERTVOID(pdTRUE==xSemaphoreTake(handle, DELAY_TICKS)); + FASSERT(pdTRUE==xSemaphoreTake(handle, DELAY_TICKS)); } vTaskDelay(1); - FT_ASSERTVOID(0==uxSemaphoreGetCount(handle)); + FASSERT(0==uxSemaphoreGetCount(handle)); vSemaphoreDelete(handle); /*Test static mutex*/ handle = xSemaphoreCreateMutexStatic(&queue_buffer); - FT_ASSERTVOID(pdTRUE==xSemaphoreTake(handle, DELAY_TICKS)); + FASSERT(pdTRUE==xSemaphoreTake(handle, DELAY_TICKS)); vTaskDelay(1); /*Current task should now hold mutex*/ - FT_ASSERTVOID(((void *)xTaskGetCurrentTaskHandle()) == xSemaphoreGetMutexHolder(handle)); - FT_ASSERTVOID(pdTRUE==xSemaphoreGive(handle)); + FASSERT(((void *)xTaskGetCurrentTaskHandle()) == xSemaphoreGetMutexHolder(handle)); + FASSERT(pdTRUE==xSemaphoreGive(handle)); vTaskDelay(1); /*Mutex should have been released*/ - FT_ASSERTVOID(NULL==xSemaphoreGetMutexHolder(handle)); + FASSERT(NULL==xSemaphoreGetMutexHolder(handle)); vSemaphoreDelete(handle); /*Test static mutex recursive*/ handle = xSemaphoreCreateRecursiveMutexStatic(&queue_buffer); for(i = 0; i < NO_OF_ITEMS; i++) { - FT_ASSERTVOID(pdTRUE==xSemaphoreTakeRecursive(handle, DELAY_TICKS)); + FASSERT(pdTRUE==xSemaphoreTakeRecursive(handle, DELAY_TICKS)); } vTaskDelay(1); /*Current task should hold mutex*/ - FT_ASSERTVOID(((void *)xTaskGetCurrentTaskHandle())==xSemaphoreGetMutexHolder(handle)); + FASSERT(((void *)xTaskGetCurrentTaskHandle())==xSemaphoreGetMutexHolder(handle)); for(i = 0; i < NO_OF_ITEMS; i++) { - FT_ASSERTVOID(pdTRUE==xSemaphoreGiveRecursive(handle)); + FASSERT(pdTRUE==xSemaphoreGiveRecursive(handle)); } vTaskDelay(1); /*Mutex should have been released*/ - FT_ASSERTVOID(NULL==xSemaphoreGetMutexHolder(handle)); + FASSERT(NULL==xSemaphoreGetMutexHolder(handle)); vSemaphoreDelete(handle); while(1) @@ -222,8 +222,8 @@ void StaticTaskCreateTest(void) vTaskDelay(5); /*Allow for static task to run, delete, and idle to clean up*/ - FT_ASSERTVOID(NULL!= handle); /*Check static task was successfully allocated*/ - FT_ASSERTVOID(has_run); /*Check static task has run*/ + FASSERT(NULL!= handle); /*Check static task was successfully allocated*/ + FASSERT(has_run); /*Check static task has run*/ while(1) { @@ -246,7 +246,7 @@ void StaticEventGroupTest(void) { eg_handle = xEventGroupCreateStatic((StaticEventGroup_t *)&event_group); xEventGroupSetBits(eg_handle, WAIT_BITS); - FT_ASSERTVOID(WAIT_BITS==xEventGroupWaitBits(eg_handle, WAIT_BITS, pdTRUE, pdTRUE, portMAX_DELAY)); + FASSERT(WAIT_BITS==xEventGroupWaitBits(eg_handle, WAIT_BITS, pdTRUE, pdTRUE, portMAX_DELAY)); /*Cleanup static event*/ vEventGroupDelete(eg_handle); } diff --git a/example/freertos_test/freertos_debug_functions.c b/example/freertos_test/src/freertos_debug_functions.c similarity index 100% rename from example/freertos_test/freertos_debug_functions.c rename to example/freertos_test/src/freertos_debug_functions.c diff --git a/example/freertos_test/freertos_eventgroups.c b/example/freertos_test/src/freertos_eventgroups.c similarity index 100% rename from example/freertos_test/freertos_eventgroups.c rename to example/freertos_test/src/freertos_eventgroups.c diff --git a/example/freertos_test/freertos_get_state.c b/example/freertos_test/src/freertos_get_state.c similarity index 100% rename from example/freertos_test/freertos_get_state.c rename to example/freertos_test/src/freertos_get_state.c diff --git a/example/freertos_test/freertos_mutex.c b/example/freertos_test/src/freertos_mutex.c similarity index 100% rename from example/freertos_test/freertos_mutex.c rename to example/freertos_test/src/freertos_mutex.c diff --git a/example/freertos_test/freertos_scheduling_time.c b/example/freertos_test/src/freertos_scheduling_time.c similarity index 100% rename from example/freertos_test/freertos_scheduling_time.c rename to example/freertos_test/src/freertos_scheduling_time.c diff --git a/example/freertos_test/freertos_task_delay_until.c b/example/freertos_test/src/freertos_task_delay_until.c similarity index 100% rename from example/freertos_test/freertos_task_delay_until.c rename to example/freertos_test/src/freertos_task_delay_until.c diff --git a/example/freertos_test/freertos_task_delete.c b/example/freertos_test/src/freertos_task_delete.c similarity index 100% rename from example/freertos_test/freertos_task_delete.c rename to example/freertos_test/src/freertos_task_delete.c diff --git a/example/freertos_test/freertos_task_notify.c b/example/freertos_test/src/freertos_task_notify.c similarity index 100% rename from example/freertos_test/freertos_task_notify.c rename to example/freertos_test/src/freertos_task_notify.c diff --git a/example/freertos_test/freertos_trace_utilities.c b/example/freertos_test/src/freertos_trace_utilities.c similarity index 100% rename from example/freertos_test/freertos_trace_utilities.c rename to example/freertos_test/src/freertos_trace_utilities.c diff --git a/example/freertos_test/get_cpu_stats.c b/example/freertos_test/src/get_cpu_stats.c similarity index 78% rename from example/freertos_test/get_cpu_stats.c rename to example/freertos_test/src/get_cpu_stats.c index 1e6c3ab342e3dfd90630fa852f27d6aa4144db40..d3de3270bb68d73072c4b2e9eb36925a3e3216ad 100644 --- a/example/freertos_test/get_cpu_stats.c +++ b/example/freertos_test/src/get_cpu_stats.c @@ -1,17 +1,27 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 10:28:22 - * @LastEditTime: 2021-07-22 09:05:53 - * @Description:  This files is for + * FilePath: get_cpu_stats.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:01:09 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include #include "FreeRTOS.h" diff --git a/example/freertos_test/test_isr_latency.c b/example/freertos_test/src/test_isr_latency.c similarity index 100% rename from example/freertos_test/test_isr_latency.c rename to example/freertos_test/src/test_isr_latency.c diff --git a/example/freertos_test/test_legacy_hooks.c b/example/freertos_test/src/test_legacy_hooks.c similarity index 100% rename from example/freertos_test/test_legacy_hooks.c rename to example/freertos_test/src/test_legacy_hooks.c diff --git a/example/freertos_test/test_newlib_reent.c b/example/freertos_test/src/test_newlib_reent.c similarity index 100% rename from example/freertos_test/test_newlib_reent.c rename to example/freertos_test/src/test_newlib_reent.c diff --git a/example/freertos_test/test_panic.c b/example/freertos_test/src/test_panic.c similarity index 100% rename from example/freertos_test/test_panic.c rename to example/freertos_test/src/test_panic.c diff --git a/example/freertos_test/test_queuesets.c b/example/freertos_test/src/test_queuesets.c similarity index 100% rename from example/freertos_test/test_queuesets.c rename to example/freertos_test/src/test_queuesets.c diff --git a/example/freertos_test/test_stream_buffers.c b/example/freertos_test/src/test_stream_buffers.c similarity index 100% rename from example/freertos_test/test_stream_buffers.c rename to example/freertos_test/src/test_stream_buffers.c diff --git a/example/freertos_test/test_task_priorities.c b/example/freertos_test/src/test_task_priorities.c similarity index 100% rename from example/freertos_test/test_task_priorities.c rename to example/freertos_test/src/test_task_priorities.c diff --git a/example/freertos_test/test_thread_local.c b/example/freertos_test/src/test_thread_local.c similarity index 99% rename from example/freertos_test/test_thread_local.c rename to example/freertos_test/src/test_thread_local.c index 517ae7e810f09680680c2a9e7bca1f93c56b9fe7..f78568347d16b752578f0e918a2233bf51d3204b 100644 --- a/example/freertos_test/test_thread_local.c +++ b/example/freertos_test/src/test_thread_local.c @@ -101,7 +101,7 @@ void ThreadLocalStorageTest(void) 3, s_stack, &s_task); /*Check static task was successfully allocated*/ - FT_ASSERTVOID(NULL!= handle); + FASSERT(NULL!= handle); /* Make sure idle task can clean up s_task, before it goes out of scope */ vTaskDelay(10); diff --git a/example/freertos_test/test_timers.c b/example/freertos_test/src/test_timers.c similarity index 100% rename from example/freertos_test/test_timers.c rename to example/freertos_test/src/test_timers.c diff --git a/example/freertos_test/unity.c b/example/freertos_test/src/unity.c similarity index 100% rename from example/freertos_test/unity.c rename to example/freertos_test/src/unity.c diff --git a/example/freertos_test/wdt_isr.c b/example/freertos_test/src/wdt_isr.c similarity index 79% rename from example/freertos_test/wdt_isr.c rename to example/freertos_test/src/wdt_isr.c index 6453e7ad3b2efdbc57c60a129a9808adb389d224..ac39c9ab0b1d9ee3ba012a29796afa7bdb5b97b3 100644 --- a/example/freertos_test/wdt_isr.c +++ b/example/freertos_test/src/wdt_isr.c @@ -1,16 +1,26 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-09 08:08:39 - * @LastEditTime: 2021-07-09 13:55:27 - * @Description:  This files is for + * FilePath: wdt_isr.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:01:23 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include #include diff --git a/example/function_test/Readme.md b/example/function_test/Readme.md index 90c24b0ffae7827ab3263e3b0d0b3ff26f29ed05..202e63aa63874af9ba0583dac03db70727e050ea 100644 --- a/example/function_test/Readme.md +++ b/example/function_test/Readme.md @@ -1,17 +1,27 @@ + # host侧设置 - 重启host侧tftp服务器 ``` diff --git a/example/function_test/configs/d2000_aarch32_eg_configs b/example/function_test/configs/d2000_aarch32_eg_configs index 474c4a220ce036fcbe0742a8c8f624a6d6a6fd9c..7be054e5011244d39bfb1c27ba18bae27d681714 100644 --- a/example/function_test/configs/d2000_aarch32_eg_configs +++ b/example/function_test/configs/d2000_aarch32_eg_configs @@ -27,8 +27,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -68,24 +70,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -113,6 +107,12 @@ CONFIG_ABORT_STACK_SIZE=0x1000 CONFIG_FIQ_STACK_SIZE=0x1000 CONFIG_UNDEF_STACK_SIZE=0x1000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -130,4 +130,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/function_test/configs/d2000_aarch64_eg_configs b/example/function_test/configs/d2000_aarch64_eg_configs index 5e3e88df83e286f635bb2ebbb8bd2c015d9a6482..787f24ddb988dca43363ca67e6fe91ac693348da 100644 --- a/example/function_test/configs/d2000_aarch64_eg_configs +++ b/example/function_test/configs/d2000_aarch64_eg_configs @@ -20,14 +20,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y # CONFIG_USE_SYS_TICK is not set +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -67,24 +70,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -107,6 +102,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -124,4 +125,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/function_test/configs/ft2004_aarch32_eg_configs b/example/function_test/configs/ft2004_aarch32_eg_configs index dcc38b232fb654346c396c799906eb6125f7bb60..dc58cfd77f526b5892541ce6b0654b107b810d7e 100644 --- a/example/function_test/configs/ft2004_aarch32_eg_configs +++ b/example/function_test/configs/ft2004_aarch32_eg_configs @@ -27,8 +27,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y # Board Configuration # CONFIG_TARGET_F2000_4=y -# CONFIG_TARGET_E2000 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -68,24 +70,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -113,6 +107,12 @@ CONFIG_ABORT_STACK_SIZE=0x1000 CONFIG_FIQ_STACK_SIZE=0x1000 CONFIG_UNDEF_STACK_SIZE=0x1000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -130,4 +130,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/function_test/configs/ft2004_aarch64_eg_configs b/example/function_test/configs/ft2004_aarch64_eg_configs index ffdfab4162c4f46a676226a500a9cd5023cb359a..af81779b892d9dade88ea6cec86382b33137133d 100644 --- a/example/function_test/configs/ft2004_aarch64_eg_configs +++ b/example/function_test/configs/ft2004_aarch64_eg_configs @@ -20,14 +20,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y CONFIG_USE_SYS_TICK=y +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # CONFIG_TARGET_F2000_4=y -# CONFIG_TARGET_E2000 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -67,24 +70,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -107,6 +102,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -124,4 +125,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/function_test/main.c b/example/function_test/main.c index d2bda41acf6686ba0153bb7d2045612e56866f74..7fb3304c44e2faa474d4ce277b0463f6ac4c1d85 100644 --- a/example/function_test/main.c +++ b/example/function_test/main.c @@ -1,16 +1,26 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-09 08:08:39 - * @LastEditTime: 2021-12-15 16:57:31 - * @Description:  This files is for + * FilePath: main.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:01:28 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include "FreeRTOS.h" #include "task.h" diff --git a/example/function_test/makefile b/example/function_test/makefile index d8b858a95db430b15d9dec91957b2d01981d1198..5495bf3ab30e1282a773104dedfe1c0891b0c6c8 100644 --- a/example/function_test/makefile +++ b/example/function_test/makefile @@ -1,10 +1,10 @@ # 指定工程项目根目录为当前(只能指定一个目录) -export PROJECT_DIR ?= . +export PROJECT_DIR ?= $(shell pwd) # 用户添加的源文件夹和头文件夹(可以指定多个) -export USR_SRC_DIR ?= . \ - ./src -export USR_INC_DIR ?= . \ - ./inc +export USR_SRC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/src +export USR_INC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/inc # 用户定义的编译目标文件上传路径 ifeq ($(OS),Windows_NT) @@ -26,3 +26,5 @@ boot: # @echo tar $(CONFIG_TARGET_NAME) # @echo img $(BOOT_IMG_NAME) cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf + + diff --git a/example/function_test/sdkconfig b/example/function_test/sdkconfig index 5e3e88df83e286f635bb2ebbb8bd2c015d9a6482..787f24ddb988dca43363ca67e6fe91ac693348da 100644 --- a/example/function_test/sdkconfig +++ b/example/function_test/sdkconfig @@ -20,14 +20,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y # CONFIG_USE_SYS_TICK is not set +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -67,24 +70,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -107,6 +102,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -124,4 +125,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/function_test/sdkconfig.h b/example/function_test/sdkconfig.h index b789a4f85f52714ef88bd191135d2a35a8f35240..1599395e64bee536398116265c2d45bd08e374fa 100644 --- a/example/function_test/sdkconfig.h +++ b/example/function_test/sdkconfig.h @@ -19,13 +19,16 @@ #define CONFIG_USE_L3CACHE #define CONFIG_USE_MMU /* CONFIG_USE_SYS_TICK is not set */ +/* CONFIG_MMU_DEBUG_PRINTS is not set */ /* end of Arch Configuration */ /* Board Configuration */ /* CONFIG_TARGET_F2000_4 is not set */ -/* CONFIG_TARGET_E2000 is not set */ #define CONFIG_TARGET_D2000 +/* CONFIG_TARGET_E2000Q is not set */ +/* CONFIG_TARGET_E2000D is not set */ +/* CONFIG_TARGET_E2000S is not set */ /* end of Board Configuration */ /* Components Configuration */ @@ -60,19 +63,14 @@ /* CONFIG_USE_DMA is not set */ /* CONFIG_USE_NAND is not set */ /* CONFIG_USE_RTC is not set */ +/* CONFIG_USE_SATA is not set */ +/* CONFIG_USE_USB is not set */ /* end of Components Configuration */ -#define CONFIG_USE_G_LIBC -/* CONFIG_USE_NEW_LIBC is not set */ +#define CONFIG_USE_NEW_LIBC /* end of Standalone Setting */ /* Building Option */ -/* Cross-Compiler Setting */ - -#define CONFIG_COMPILER_NO_STD_STARUP -#define CONFIG_GCC_OPTIMIZE_LEVEL 0 -/* CONFIG_USE_EXT_COMPILER is not set */ -/* end of Cross-Compiler Setting */ /* CONFIG_LOG_VERBOS is not set */ /* CONFIG_LOG_DEBUG is not set */ #define CONFIG_LOG_INFO @@ -92,8 +90,13 @@ #define CONFIG_RAM_START_UP_ADDR 0x81000000 #define CONFIG_RAM_SIZE_MB 64 #define CONFIG_HEAP_SIZE 1 -#define CONFIG_STACK_SIZE 0x400 +#define CONFIG_STACK_SIZE 0x100000 /* end of Linker Options */ + +/* Compiler Options */ + +#define CONFIG_DON_T_BINARY_OUTPUT +/* end of Compiler Options */ /* end of Building Option */ /* Component Configuration */ @@ -107,6 +110,9 @@ /* FreeRTOS Setting */ /* CONFIG_USE_LWIP is not set */ +#define CONFIG_USE_BACKTRACE +/* CONFIG_USE_AMP is not set */ +/* CONFIG_USE_LETTER_SHELL is not set */ /* end of FreeRTOS Setting */ #endif diff --git a/example/function_test/src/get_cpu_stats.c b/example/function_test/src/get_cpu_stats.c index 1a250751501952e31ef27d800acbee7d5bdb063a..36e545715dd28b5b1635eb3ad8962f4f27d072bc 100644 --- a/example/function_test/src/get_cpu_stats.c +++ b/example/function_test/src/get_cpu_stats.c @@ -1,17 +1,27 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 10:28:22 - * @LastEditTime: 2021-07-22 09:05:53 - * @Description:  This files is for + * FilePath: get_cpu_stats.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:01:39 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include #include "FreeRTOS.h" diff --git a/example/function_test/src/test_msg_queue.c b/example/function_test/src/test_msg_queue.c index 11720151be574fe211754bced2a2074582e69a8d..dd270af180dab7ee558216fee818f74243f3cf54 100644 --- a/example/function_test/src/test_msg_queue.c +++ b/example/function_test/src/test_msg_queue.c @@ -1,16 +1,26 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 13:24:16 - * @LastEditTime: 2021-07-22 09:18:21 - * @Description:  This files is for + * FilePath: test_msg_queue.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:01:43 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include #include "FreeRTOS.h" @@ -40,7 +50,7 @@ static void AppTaskCreate(void) Test_Queue = xQueueCreate((UBaseType_t ) QUEUE_LEN, /* 消息队列的长度 */ (UBaseType_t ) QUEUE_SIZE);/* 消息的大小 */ - FT_ASSERTVOID(NULL != Test_Queue); + FASSERT(NULL != Test_Queue); /* 创建任务 */ xReturn = xTaskCreate((TaskFunction_t )Receive_Task, /* 任务入口函数 */ @@ -50,7 +60,7 @@ static void AppTaskCreate(void) (UBaseType_t )2, /* 任务的优先级 */ (TaskHandle_t* )&Receive_Task_Handle);/* 任务控制块指针 */ - FT_ASSERTVOID(pdPASS == xReturn); + FASSERT(pdPASS == xReturn); xReturn = xTaskCreate((TaskFunction_t )Send_Task, /* 任务入口函数 */ (const char* )"Send_Task",/* 任务名字 */ @@ -59,7 +69,7 @@ static void AppTaskCreate(void) (UBaseType_t )2, /* 任务的优先级 */ (TaskHandle_t* )&Send_Task_Handle);/* 任务控制块指针 */ - FT_ASSERTVOID(pdPASS == xReturn); + FASSERT(pdPASS == xReturn); vTaskDelete(AppTaskCreate_Handle); //删除 AppTaskCreate 任务 diff --git a/example/function_test/src/test_uart.c b/example/function_test/src/test_uart.c index d1ab31d9a7c76165793f9959f061d557a642995f..c34bb8eebb2c3a7ef89e2b58a8a1dc242f57b0c0 100644 --- a/example/function_test/src/test_uart.c +++ b/example/function_test/src/test_uart.c @@ -1,16 +1,26 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 13:48:25 - * @LastEditTime: 2021-12-15 15:58:22 - * @Description:  This files is for + * FilePath: test_uart.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:01:47 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include "ft_types.h" #include "fpl011.h" diff --git a/example/hello_world/Readme.md b/example/hello_world/Readme.md index 90c24b0ffae7827ab3263e3b0d0b3ff26f29ed05..3d624031c5a9825ac912e457e473a91a4b50d6c4 100644 --- a/example/hello_world/Readme.md +++ b/example/hello_world/Readme.md @@ -1,17 +1,27 @@ + # host侧设置 - 重启host侧tftp服务器 ``` diff --git a/example/hello_world/configs/d2000_aarch32_eg_configs b/example/hello_world/configs/d2000_aarch32_eg_configs index e509730045117e53767767c33e1974c35b4e4aa9..bfba859b216ea9d4878539a56afb09a22e8cf3e4 100644 --- a/example/hello_world/configs/d2000_aarch32_eg_configs +++ b/example/hello_world/configs/d2000_aarch32_eg_configs @@ -32,8 +32,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -43,7 +45,14 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -66,24 +75,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -111,6 +112,12 @@ CONFIG_ABORT_STACK_SIZE=0x1000 CONFIG_FIQ_STACK_SIZE=0x1000 CONFIG_UNDEF_STACK_SIZE=0x1000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -128,4 +135,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/hello_world/configs/d2000_aarch64_eg_configs b/example/hello_world/configs/d2000_aarch64_eg_configs index 49b6b8cf5da8d655bda1979bf28255c1cf822988..f099abac6034cf1e8fe8c8adadbb4cde502331be 100644 --- a/example/hello_world/configs/d2000_aarch64_eg_configs +++ b/example/hello_world/configs/d2000_aarch64_eg_configs @@ -25,14 +25,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y # CONFIG_USE_SYS_TICK is not set +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -42,7 +45,14 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -65,24 +75,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -105,6 +107,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -122,4 +130,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/hello_world/configs/ft2004_aarch32_eg_configs b/example/hello_world/configs/ft2004_aarch32_eg_configs index e66146c79951e75ee5ae3953def992ab54f276d2..45305bfd438eb2a2a9c9507f6f95b8ed237ed4e3 100644 --- a/example/hello_world/configs/ft2004_aarch32_eg_configs +++ b/example/hello_world/configs/ft2004_aarch32_eg_configs @@ -32,8 +32,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y # Board Configuration # CONFIG_TARGET_F2000_4=y -# CONFIG_TARGET_E2000 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -73,24 +75,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -118,6 +112,12 @@ CONFIG_ABORT_STACK_SIZE=0x1000 CONFIG_FIQ_STACK_SIZE=0x1000 CONFIG_UNDEF_STACK_SIZE=0x1000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -135,4 +135,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/hello_world/configs/ft2004_aarch64_eg_configs b/example/hello_world/configs/ft2004_aarch64_eg_configs index 827547a4db079b5b94fbc389c842dd1eee9bddb2..52b4de9835866349072fe0c318b3b9f9b4f3c6a4 100644 --- a/example/hello_world/configs/ft2004_aarch64_eg_configs +++ b/example/hello_world/configs/ft2004_aarch64_eg_configs @@ -25,14 +25,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y CONFIG_USE_SYS_TICK=y +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # CONFIG_TARGET_F2000_4=y -# CONFIG_TARGET_E2000 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -72,24 +75,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -112,6 +107,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -129,4 +130,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/hello_world/makefile b/example/hello_world/makefile index 17dc4729dac953dbab35c736e5e6eb4a232b1295..f9711a7ba98c36d75eab9ece9a9bbcfdf18c1292 100644 --- a/example/hello_world/makefile +++ b/example/hello_world/makefile @@ -1,10 +1,10 @@ # 指定工程项目根目录为当前(只能指定一个目录) -export PROJECT_DIR ?= . +export PROJECT_DIR ?= $(shell pwd) # 用户添加的源文件夹和头文件夹(可以指定多个) -export USR_SRC_DIR ?= . \ - ./src -export USR_INC_DIR ?= . \ - ./inc +export USR_SRC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/src +export USR_INC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/inc # 用户定义的编译目标文件上传路径 ifeq ($(OS),Windows_NT) diff --git a/example/hello_world/sdkconfig b/example/hello_world/sdkconfig index 8180c819b3bb86ff8b85ca8aa1218ef2d8c1d9cf..f099abac6034cf1e8fe8c8adadbb4cde502331be 100644 --- a/example/hello_world/sdkconfig +++ b/example/hello_world/sdkconfig @@ -25,14 +25,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y # CONFIG_USE_SYS_TICK is not set +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -42,7 +45,14 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -65,24 +75,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -103,8 +105,14 @@ CONFIG_LINK_SCRIPT_RAM=y CONFIG_RAM_START_UP_ADDR=0x81000000 CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 -CONFIG_STACK_SIZE=0x400 +CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -122,4 +130,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/hello_world/sdkconfig.h b/example/hello_world/sdkconfig.h index 42217ca25543ce67614199716660bf00b8aafbe2..ed9703ffed67084facb095f650a2010257315bda 100644 --- a/example/hello_world/sdkconfig.h +++ b/example/hello_world/sdkconfig.h @@ -22,13 +22,16 @@ #define CONFIG_USE_L3CACHE #define CONFIG_USE_MMU /* CONFIG_USE_SYS_TICK is not set */ +/* CONFIG_MMU_DEBUG_PRINTS is not set */ /* end of Arch Configuration */ /* Board Configuration */ /* CONFIG_TARGET_F2000_4 is not set */ -/* CONFIG_TARGET_E2000 is not set */ #define CONFIG_TARGET_D2000 +/* CONFIG_TARGET_E2000Q is not set */ +/* CONFIG_TARGET_E2000D is not set */ +/* CONFIG_TARGET_E2000S is not set */ /* end of Board Configuration */ /* Components Configuration */ @@ -37,7 +40,12 @@ /* CONFIG_USE_QSPI is not set */ #define CONFIG_USE_GIC #define CONFIG_ENABLE_GICV3 -/* CONFIG_USE_SERIAL is not set */ +#define CONFIG_USE_SERIAL + +/* Usart Configuration */ + +#define CONFIG_ENABLE_Pl011_UART +/* end of Usart Configuration */ /* CONFIG_USE_GPIO is not set */ /* CONFIG_USE_IOMUX is not set */ #define CONFIG_USE_ETH @@ -58,19 +66,14 @@ /* CONFIG_USE_DMA is not set */ /* CONFIG_USE_NAND is not set */ /* CONFIG_USE_RTC is not set */ +/* CONFIG_USE_SATA is not set */ +/* CONFIG_USE_USB is not set */ /* end of Components Configuration */ -#define CONFIG_USE_G_LIBC -/* CONFIG_USE_NEW_LIBC is not set */ +#define CONFIG_USE_NEW_LIBC /* end of Standalone Setting */ /* Building Option */ -/* Cross-Compiler Setting */ - -#define CONFIG_COMPILER_NO_STD_STARUP -#define CONFIG_GCC_OPTIMIZE_LEVEL 0 -/* CONFIG_USE_EXT_COMPILER is not set */ -/* end of Cross-Compiler Setting */ /* CONFIG_LOG_VERBOS is not set */ /* CONFIG_LOG_DEBUG is not set */ #define CONFIG_LOG_INFO @@ -90,8 +93,13 @@ #define CONFIG_RAM_START_UP_ADDR 0x81000000 #define CONFIG_RAM_SIZE_MB 64 #define CONFIG_HEAP_SIZE 1 -#define CONFIG_STACK_SIZE 0x400 +#define CONFIG_STACK_SIZE 0x100000 /* end of Linker Options */ + +/* Compiler Options */ + +#define CONFIG_DON_T_BINARY_OUTPUT +/* end of Compiler Options */ /* end of Building Option */ /* Component Configuration */ @@ -105,6 +113,9 @@ /* FreeRTOS Setting */ /* CONFIG_USE_LWIP is not set */ +#define CONFIG_USE_BACKTRACE +/* CONFIG_USE_AMP is not set */ +/* CONFIG_USE_LETTER_SHELL is not set */ /* end of FreeRTOS Setting */ #endif diff --git a/example/lwip_test/README.md b/example/lwip_test/README.md index 8705d69bb4fc7fcfdbf93bbc004b8a59aa93f454..fcd9c9164bac36b15bce2d4bdfd7aeb2320e97c7 100644 --- a/example/lwip_test/README.md +++ b/example/lwip_test/README.md @@ -1,16 +1,26 @@ + # lwip base on freertos ## 1. 例程介绍 diff --git a/example/lwip_test/configs/d2000_aarch32_eg_configs b/example/lwip_test/configs/d2000_aarch32_eg_configs index 66efcb4e3e6c2c91aff73b5fa2e3c70c7ed987c0..42b429c08521fafa2a51d47920996855174d691f 100644 --- a/example/lwip_test/configs/d2000_aarch32_eg_configs +++ b/example/lwip_test/configs/d2000_aarch32_eg_configs @@ -29,8 +29,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -40,7 +42,14 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -63,24 +72,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -108,6 +109,12 @@ CONFIG_ABORT_STACK_SIZE=0x1000 CONFIG_FIQ_STACK_SIZE=0x1000 CONFIG_UNDEF_STACK_SIZE=0x1000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -131,4 +138,8 @@ CONFIG_USE_LWIP=y # CONFIG_LWIP_F_GMAC=y # end of LWIP Configuration + +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/lwip_test/configs/d2000_aarch64_eg_configs b/example/lwip_test/configs/d2000_aarch64_eg_configs index 2f0570a80213e08cce9c1d1357d0f7cbafd2cf4c..f850409496c7a9c636973d2a3975f030f11c7a37 100644 --- a/example/lwip_test/configs/d2000_aarch64_eg_configs +++ b/example/lwip_test/configs/d2000_aarch64_eg_configs @@ -22,14 +22,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y CONFIG_USE_SYS_TICK=y +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -39,7 +42,14 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -62,24 +72,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -102,6 +104,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -125,4 +133,8 @@ CONFIG_USE_LWIP=y # CONFIG_LWIP_F_GMAC=y # end of LWIP Configuration + +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/lwip_test/configs/ft2004_aarch32_eg_configs b/example/lwip_test/configs/ft2004_aarch32_eg_configs index a7827f8239b8021b9c3b7fc0b928573b3b0c104f..6b829d83032718a540e73903e18c023f59f7dd4e 100644 --- a/example/lwip_test/configs/ft2004_aarch32_eg_configs +++ b/example/lwip_test/configs/ft2004_aarch32_eg_configs @@ -29,8 +29,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y # Board Configuration # CONFIG_TARGET_F2000_4=y -# CONFIG_TARGET_E2000 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -70,24 +72,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set # CONFIG_LOG_INFO is not set @@ -115,6 +109,12 @@ CONFIG_ABORT_STACK_SIZE=0x1000 CONFIG_FIQ_STACK_SIZE=0x1000 CONFIG_UNDEF_STACK_SIZE=0x1000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -138,4 +138,8 @@ CONFIG_USE_LWIP=y # CONFIG_LWIP_F_GMAC=y # end of LWIP Configuration + +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/lwip_test/configs/ft2004_aarch64_eg_configs b/example/lwip_test/configs/ft2004_aarch64_eg_configs index 02db22b66022cd81c06ab98656a4ae66ff8d26e6..342d5fc72eb26aef9227249c7597ba2b7cddec39 100644 --- a/example/lwip_test/configs/ft2004_aarch64_eg_configs +++ b/example/lwip_test/configs/ft2004_aarch64_eg_configs @@ -22,14 +22,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y CONFIG_USE_SYS_TICK=y +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # CONFIG_TARGET_F2000_4=y -# CONFIG_TARGET_E2000 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -69,24 +72,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set # CONFIG_LOG_INFO is not set @@ -109,6 +104,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -132,4 +133,8 @@ CONFIG_USE_LWIP=y # CONFIG_LWIP_F_GMAC=y # end of LWIP Configuration + +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/lwip_test/get_cpu_stats.c b/example/lwip_test/get_cpu_stats.c index 8c2281d37fce382d9ed5874d1eb3d2c85aabecab..87756e05382517187278d179f7a4aff67cb6725a 100644 --- a/example/lwip_test/get_cpu_stats.c +++ b/example/lwip_test/get_cpu_stats.c @@ -1,17 +1,27 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 10:28:22 - * @LastEditTime: 2021-07-22 09:05:53 - * @Description:  This files is for + * FilePath: get_cpu_stats.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:01:54 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include #include "FreeRTOS.h" diff --git a/example/lwip_test/main.c b/example/lwip_test/main.c index d77c7218add38e9f26f3b36f25ac0fdf527c249a..b569b490f5f2461d7f826930d1d89a4ea26a6599 100644 --- a/example/lwip_test/main.c +++ b/example/lwip_test/main.c @@ -1,16 +1,26 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-09 08:08:39 - * @LastEditTime: 2021-08-25 18:40:20 - * @Description:  This files is for + * FilePath: main.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:01:57 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include "parameters.h" #include "ft_types.h" #include "FreeRTOS.h" diff --git a/example/lwip_test/makefile b/example/lwip_test/makefile index d8b858a95db430b15d9dec91957b2d01981d1198..5495bf3ab30e1282a773104dedfe1c0891b0c6c8 100644 --- a/example/lwip_test/makefile +++ b/example/lwip_test/makefile @@ -1,10 +1,10 @@ # 指定工程项目根目录为当前(只能指定一个目录) -export PROJECT_DIR ?= . +export PROJECT_DIR ?= $(shell pwd) # 用户添加的源文件夹和头文件夹(可以指定多个) -export USR_SRC_DIR ?= . \ - ./src -export USR_INC_DIR ?= . \ - ./inc +export USR_SRC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/src +export USR_INC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/inc # 用户定义的编译目标文件上传路径 ifeq ($(OS),Windows_NT) @@ -26,3 +26,5 @@ boot: # @echo tar $(CONFIG_TARGET_NAME) # @echo img $(BOOT_IMG_NAME) cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf + + diff --git a/example/lwip_test/sdkconfig b/example/lwip_test/sdkconfig index 2f0570a80213e08cce9c1d1357d0f7cbafd2cf4c..f850409496c7a9c636973d2a3975f030f11c7a37 100644 --- a/example/lwip_test/sdkconfig +++ b/example/lwip_test/sdkconfig @@ -22,14 +22,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y CONFIG_USE_SYS_TICK=y +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -39,7 +42,14 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -62,24 +72,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -102,6 +104,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -125,4 +133,8 @@ CONFIG_USE_LWIP=y # CONFIG_LWIP_F_GMAC=y # end of LWIP Configuration + +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/lwip_test/sdkconfig.h b/example/lwip_test/sdkconfig.h index 31ff1a56b16de8ba74a009fd664172513b7d146a..796406cffee896421a6ebf7f37be0fe16984d553 100644 --- a/example/lwip_test/sdkconfig.h +++ b/example/lwip_test/sdkconfig.h @@ -21,13 +21,16 @@ #define CONFIG_USE_L3CACHE #define CONFIG_USE_MMU #define CONFIG_USE_SYS_TICK +/* CONFIG_MMU_DEBUG_PRINTS is not set */ /* end of Arch Configuration */ /* Board Configuration */ /* CONFIG_TARGET_F2000_4 is not set */ -/* CONFIG_TARGET_E2000 is not set */ #define CONFIG_TARGET_D2000 +/* CONFIG_TARGET_E2000Q is not set */ +/* CONFIG_TARGET_E2000D is not set */ +/* CONFIG_TARGET_E2000S is not set */ /* end of Board Configuration */ /* Components Configuration */ @@ -36,7 +39,12 @@ /* CONFIG_USE_QSPI is not set */ #define CONFIG_USE_GIC #define CONFIG_ENABLE_GICV3 -/* CONFIG_USE_SERIAL is not set */ +#define CONFIG_USE_SERIAL + +/* Usart Configuration */ + +#define CONFIG_ENABLE_Pl011_UART +/* end of Usart Configuration */ /* CONFIG_USE_GPIO is not set */ /* CONFIG_USE_IOMUX is not set */ #define CONFIG_USE_ETH @@ -57,19 +65,14 @@ /* CONFIG_USE_DMA is not set */ /* CONFIG_USE_NAND is not set */ /* CONFIG_USE_RTC is not set */ +/* CONFIG_USE_SATA is not set */ +/* CONFIG_USE_USB is not set */ /* end of Components Configuration */ -#define CONFIG_USE_G_LIBC -/* CONFIG_USE_NEW_LIBC is not set */ +#define CONFIG_USE_NEW_LIBC /* end of Standalone Setting */ /* Building Option */ -/* Cross-Compiler Setting */ - -#define CONFIG_COMPILER_NO_STD_STARUP -#define CONFIG_GCC_OPTIMIZE_LEVEL 0 -/* CONFIG_USE_EXT_COMPILER is not set */ -/* end of Cross-Compiler Setting */ /* CONFIG_LOG_VERBOS is not set */ /* CONFIG_LOG_DEBUG is not set */ #define CONFIG_LOG_INFO @@ -89,8 +92,13 @@ #define CONFIG_RAM_START_UP_ADDR 0x81000000 #define CONFIG_RAM_SIZE_MB 64 #define CONFIG_HEAP_SIZE 1 -#define CONFIG_STACK_SIZE 0x400 +#define CONFIG_STACK_SIZE 0x100000 /* end of Linker Options */ + +/* Compiler Options */ + +#define CONFIG_DON_T_BINARY_OUTPUT +/* end of Compiler Options */ /* end of Building Option */ /* Component Configuration */ @@ -109,6 +117,9 @@ #define CONFIG_LWIP_F_GMAC /* end of LWIP Configuration */ +#define CONFIG_USE_BACKTRACE +/* CONFIG_USE_AMP is not set */ +/* CONFIG_USE_LETTER_SHELL is not set */ /* end of FreeRTOS Setting */ #endif diff --git a/example/lwip_test/test_lwip.c b/example/lwip_test/test_lwip.c index a9f75863c32e9dc5b9717cdf972bf9f2103e6cec..24fe1a1eee23807ffa39c74af9069c402ad720b9 100644 --- a/example/lwip_test/test_lwip.c +++ b/example/lwip_test/test_lwip.c @@ -1,16 +1,26 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-08-16 17:24:29 - * @LastEditTime: 2021-08-26 10:27:32 - * @Description:  This files is for + * FilePath: test_lwip.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:02:05 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include #include "sdkconfig.h" diff --git a/example/start_up/Readme.md b/example/start_up/Readme.md index 90c24b0ffae7827ab3263e3b0d0b3ff26f29ed05..810ce16e1332bc836a59d209ab9dc4a183b0c547 100644 --- a/example/start_up/Readme.md +++ b/example/start_up/Readme.md @@ -1,50 +1,60 @@ - - -# host侧设置 -- 重启host侧tftp服务器 -``` -sudo service tftpd-hpa restart -``` - -# 开发板侧设置 - -## 使用go命令跳转 -- 关闭D-cache和I-cache -``` -icache off -dcache off -``` - -- 下载新版本到FT2000-4 -``` -setenv ipaddr 192.168.4.20 -setenv serverip 192.168.4.50 -setenv gatewayip 192.168.4.1 -tftpboot 0x80100000 freertos.bin -dcache flush -go 0x80100000 -``` - - -## 使用bootelf命令跳转 -- 下载新版本到FT2000-4 -``` -setenv ipaddr 192.168.4.20 -setenv serverip 192.168.4.50 -setenv gatewayip 192.168.4.1 -tftpboot 0x90100000 freertos.elf -bootelf -p 0x90100000 -``` - + + + +# host侧设置 +- 重启host侧tftp服务器 +``` +sudo service tftpd-hpa restart +``` + +# 开发板侧设置 + +## 使用go命令跳转 +- 关闭D-cache和I-cache +``` +icache off +dcache off +``` + +- 下载新版本到FT2000-4 +``` +setenv ipaddr 192.168.4.20 +setenv serverip 192.168.4.50 +setenv gatewayip 192.168.4.1 +tftpboot 0x80100000 freertos.bin +dcache flush +go 0x80100000 +``` + + +## 使用bootelf命令跳转 +- 下载新版本到FT2000-4 +``` +setenv ipaddr 192.168.4.20 +setenv serverip 192.168.4.50 +setenv gatewayip 192.168.4.1 +tftpboot 0x90100000 freertos.elf +bootelf -p 0x90100000 +``` + diff --git a/example/start_up/asm_debug.c b/example/start_up/asm_debug.c index 31bbb826581d10d9dd5c8640e1b8deb1aa0c08d8..3825af7649e97d24d5367cc3b9f7bf585d416e86 100644 --- a/example/start_up/asm_debug.c +++ b/example/start_up/asm_debug.c @@ -1,13 +1,22 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 09:30:54 - * @LastEditTime: 2021-07-05 09:45:26 - * @Description:  This files is for + * FilePath: asm_debug.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:02:09 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ diff --git a/example/start_up/configs/d2000_aarch32_eg_configs b/example/start_up/configs/d2000_aarch32_eg_configs index 8e72dd207f963c37522994149280cca2f40bfc73..d018cf740e2aa9d391aeba4f328c57ffa5ff597b 100644 --- a/example/start_up/configs/d2000_aarch32_eg_configs +++ b/example/start_up/configs/d2000_aarch32_eg_configs @@ -36,8 +36,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -77,24 +79,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -122,6 +116,12 @@ CONFIG_ABORT_STACK_SIZE=0x1000 CONFIG_FIQ_STACK_SIZE=0x1000 CONFIG_UNDEF_STACK_SIZE=0x1000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -139,4 +139,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/start_up/configs/d2000_aarch64_eg_configs b/example/start_up/configs/d2000_aarch64_eg_configs index 1ac5110c8f667dd1782a526663e2188cb0a41f01..a82ed3a5ef662b3f55924a746caddf3dcb44e15c 100644 --- a/example/start_up/configs/d2000_aarch64_eg_configs +++ b/example/start_up/configs/d2000_aarch64_eg_configs @@ -29,14 +29,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y # CONFIG_USE_SYS_TICK is not set +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -76,24 +79,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -114,8 +109,14 @@ CONFIG_LINK_SCRIPT_RAM=y CONFIG_RAM_START_UP_ADDR=0x81000000 CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 -CONFIG_STACK_SIZE=0x100000 +CONFIG_STACK_SIZE=0x400 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -133,4 +134,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/start_up/configs/ft2004_aarch32_eg_configs b/example/start_up/configs/ft2004_aarch32_eg_configs index 861b811d2a6576d7f2c6d16be609b40f3b9bc036..233fac34baafc8efedba0fc04fd8729abec34d05 100644 --- a/example/start_up/configs/ft2004_aarch32_eg_configs +++ b/example/start_up/configs/ft2004_aarch32_eg_configs @@ -36,8 +36,10 @@ CONFIG_USE_AARCH64_L1_TO_AARCH32=y # Board Configuration # CONFIG_TARGET_F2000_4=y -# CONFIG_TARGET_E2000 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -77,24 +79,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -122,6 +116,12 @@ CONFIG_ABORT_STACK_SIZE=0x1000 CONFIG_FIQ_STACK_SIZE=0x1000 CONFIG_UNDEF_STACK_SIZE=0x1000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -139,4 +139,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/start_up/configs/ft2004_aarch64_eg_configs b/example/start_up/configs/ft2004_aarch64_eg_configs index f22d58d79f32fe745f9a4b141d2f9605315df458..5908438a099e8ed652b90afb84ad5ee121ab10ad 100644 --- a/example/start_up/configs/ft2004_aarch64_eg_configs +++ b/example/start_up/configs/ft2004_aarch64_eg_configs @@ -29,14 +29,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y CONFIG_USE_SYS_TICK=y +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # CONFIG_TARGET_F2000_4=y -# CONFIG_TARGET_E2000 is not set # CONFIG_TARGET_D2000 is not set +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -76,24 +79,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -116,6 +111,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x100000 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -133,4 +134,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/start_up/get_cpu_stats.c b/example/start_up/get_cpu_stats.c index fe6a4131590189cf3734b165274c249aa861bbe9..898e8ddab81a64025cdbe06b9defdf56b71381cf 100644 --- a/example/start_up/get_cpu_stats.c +++ b/example/start_up/get_cpu_stats.c @@ -1,17 +1,27 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 10:28:22 - * @LastEditTime: 2021-07-05 11:36:56 - * @Description:  This files is for + * FilePath: get_cpu_stats.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:02:12 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include #include "FreeRTOS.h" diff --git a/example/start_up/main.c b/example/start_up/main.c index 21eb9cf554ef9f96a83aba7e60692d9bd915c4b8..2530a826abd1e87e7914293f8c27c0da5652a2c6 100644 --- a/example/start_up/main.c +++ b/example/start_up/main.c @@ -1,13 +1,22 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-06-29 17:57:10 - * @LastEditTime: 2021-07-05 14:26:47 - * @Description:  This files is for + * FilePath: main.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:02:16 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ diff --git a/example/start_up/makefile b/example/start_up/makefile index 17dc4729dac953dbab35c736e5e6eb4a232b1295..509822c4cbbeebc6b9e3aeeefcec8a418cbac402 100644 --- a/example/start_up/makefile +++ b/example/start_up/makefile @@ -1,28 +1,31 @@ -# 指定工程项目根目录为当前(只能指定一个目录) -export PROJECT_DIR ?= . -# 用户添加的源文件夹和头文件夹(可以指定多个) -export USR_SRC_DIR ?= . \ - ./src -export USR_INC_DIR ?= . \ - ./inc - -# 用户定义的编译目标文件上传路径 -ifeq ($(OS),Windows_NT) -USR_BOOT_DIR ?= /d/tftboot -else -USR_BOOT_DIR ?= /mnt/d/tftboot -endif - - -# 设置启动镜像名 -BOOT_IMG_NAME ?= freertos - -# 指定编译freertos项目使用的makefile -include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk - -# 完成编译 -boot: - make -# @echo tar $(CONFIG_TARGET_NAME) -# @echo img $(BOOT_IMG_NAME) - cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf +# 指定工程项目根目录为当前(只能指定一个目录) +export PROJECT_DIR ?= $(shell pwd) +export KCONFIG_DIR ?= $(PROJECT_DIR) +# 用户添加的源文件夹和头文件夹(可以指定多个) +export USR_SRC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/src +export USR_INC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/inc + + +# 用户定义的编译目标文件上传路径 +ifeq ($(OS),Windows_NT) +USR_BOOT_DIR ?= /d/tftboot +else +USR_BOOT_DIR ?= /mnt/d/tftboot +endif + + +# 设置启动镜像名 +BOOT_IMG_NAME ?= freertos + +# 指定编译freertos项目使用的makefile +include $(FREERTOS_SDK_ROOT)/make/build_freertos.mk + +# 完成编译 +boot: + make + cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf + + + diff --git a/example/start_up/sdkconfig b/example/start_up/sdkconfig index b249eaa1a68368c54ca1d35d77cf04ccca501d8f..a82ed3a5ef662b3f55924a746caddf3dcb44e15c 100644 --- a/example/start_up/sdkconfig +++ b/example/start_up/sdkconfig @@ -29,14 +29,17 @@ CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y # CONFIG_USE_SYS_TICK is not set +# CONFIG_MMU_DEBUG_PRINTS is not set # end of Arch Configuration # # Board Configuration # # CONFIG_TARGET_F2000_4 is not set -# CONFIG_TARGET_E2000 is not set CONFIG_TARGET_D2000=y +# CONFIG_TARGET_E2000Q is not set +# CONFIG_TARGET_E2000D is not set +# CONFIG_TARGET_E2000S is not set # end of Board Configuration # @@ -76,24 +79,16 @@ CONFIG_FGMAC_PHY_COMMON=y # CONFIG_USE_DMA is not set # CONFIG_USE_NAND is not set # CONFIG_USE_RTC is not set +# CONFIG_USE_SATA is not set +# CONFIG_USE_USB is not set # end of Components Configuration -CONFIG_USE_G_LIBC=y -# CONFIG_USE_NEW_LIBC is not set +CONFIG_USE_NEW_LIBC=y # end of Standalone Setting # # Building Option # - -# -# Cross-Compiler Setting -# -CONFIG_COMPILER_NO_STD_STARUP=y -CONFIG_GCC_OPTIMIZE_LEVEL=0 -# CONFIG_USE_EXT_COMPILER is not set -# end of Cross-Compiler Setting - # CONFIG_LOG_VERBOS is not set # CONFIG_LOG_DEBUG is not set CONFIG_LOG_INFO=y @@ -116,6 +111,12 @@ CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 CONFIG_STACK_SIZE=0x400 # end of Linker Options + +# +# Compiler Options +# +CONFIG_DON_T_BINARY_OUTPUT=y +# end of Compiler Options # end of Building Option # @@ -133,4 +134,7 @@ CONFIG_FREERTOS_USE_UART=y # FreeRTOS Setting # # CONFIG_USE_LWIP is not set +CONFIG_USE_BACKTRACE=y +# CONFIG_USE_AMP is not set +# CONFIG_USE_LETTER_SHELL is not set # end of FreeRTOS Setting diff --git a/example/start_up/sdkconfig.h b/example/start_up/sdkconfig.h index ea5cb17aa772651670c701cf4e484c981846d79f..f9fffb475a02d1a98fa450b48302c6d941081197 100644 --- a/example/start_up/sdkconfig.h +++ b/example/start_up/sdkconfig.h @@ -26,13 +26,16 @@ #define CONFIG_USE_L3CACHE #define CONFIG_USE_MMU /* CONFIG_USE_SYS_TICK is not set */ +/* CONFIG_MMU_DEBUG_PRINTS is not set */ /* end of Arch Configuration */ /* Board Configuration */ /* CONFIG_TARGET_F2000_4 is not set */ -/* CONFIG_TARGET_E2000 is not set */ #define CONFIG_TARGET_D2000 +/* CONFIG_TARGET_E2000Q is not set */ +/* CONFIG_TARGET_E2000D is not set */ +/* CONFIG_TARGET_E2000S is not set */ /* end of Board Configuration */ /* Components Configuration */ @@ -67,19 +70,14 @@ /* CONFIG_USE_DMA is not set */ /* CONFIG_USE_NAND is not set */ /* CONFIG_USE_RTC is not set */ +/* CONFIG_USE_SATA is not set */ +/* CONFIG_USE_USB is not set */ /* end of Components Configuration */ -#define CONFIG_USE_G_LIBC -/* CONFIG_USE_NEW_LIBC is not set */ +#define CONFIG_USE_NEW_LIBC /* end of Standalone Setting */ /* Building Option */ -/* Cross-Compiler Setting */ - -#define CONFIG_COMPILER_NO_STD_STARUP -#define CONFIG_GCC_OPTIMIZE_LEVEL 0 -/* CONFIG_USE_EXT_COMPILER is not set */ -/* end of Cross-Compiler Setting */ /* CONFIG_LOG_VERBOS is not set */ /* CONFIG_LOG_DEBUG is not set */ #define CONFIG_LOG_INFO @@ -101,6 +99,11 @@ #define CONFIG_HEAP_SIZE 1 #define CONFIG_STACK_SIZE 0x400 /* end of Linker Options */ + +/* Compiler Options */ + +#define CONFIG_DON_T_BINARY_OUTPUT +/* end of Compiler Options */ /* end of Building Option */ /* Component Configuration */ @@ -114,6 +117,9 @@ /* FreeRTOS Setting */ /* CONFIG_USE_LWIP is not set */ +#define CONFIG_USE_BACKTRACE +/* CONFIG_USE_AMP is not set */ +/* CONFIG_USE_LETTER_SHELL is not set */ /* end of FreeRTOS Setting */ #endif diff --git a/example/start_up/test_msg_queue.c b/example/start_up/test_msg_queue.c index 87ea71fbdbc38c1bb5110bb6603ea6a6394cfcfa..2832830f178861c5256355a93ccb0a3d7364dc01 100644 --- a/example/start_up/test_msg_queue.c +++ b/example/start_up/test_msg_queue.c @@ -1,16 +1,26 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 13:24:16 - * @LastEditTime: 2021-07-05 13:55:20 - * @Description:  This files is for + * FilePath: test_msg_queue.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:02:23 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include #include "FreeRTOS.h" @@ -40,7 +50,7 @@ static void AppTaskCreate(void) Test_Queue = xQueueCreate((UBaseType_t ) QUEUE_LEN, /* 消息队列的长度 */ (UBaseType_t ) QUEUE_SIZE);/* 消息的大小 */ - FT_ASSERTVOID(NULL != Test_Queue); + FASSERT(NULL != Test_Queue); /* 创建任务 */ xReturn = xTaskCreate((TaskFunction_t )Receive_Task, /* 任务入口函数 */ @@ -50,7 +60,7 @@ static void AppTaskCreate(void) (UBaseType_t )2, /* 任务的优先级 */ (TaskHandle_t* )&Receive_Task_Handle);/* 任务控制块指针 */ - FT_ASSERTVOID(pdPASS == xReturn); + FASSERT(pdPASS == xReturn); xReturn = xTaskCreate((TaskFunction_t )Send_Task, /* 任务入口函数 */ (const char* )"Send_Task",/* 任务名字 */ @@ -59,7 +69,7 @@ static void AppTaskCreate(void) (UBaseType_t )2, /* 任务的优先级 */ (TaskHandle_t* )&Send_Task_Handle);/* 任务控制块指针 */ - FT_ASSERTVOID(pdPASS == xReturn); + FASSERT(pdPASS == xReturn); vTaskDelete(AppTaskCreate_Handle); //删除 AppTaskCreate 任务 diff --git a/example/start_up/test_semaphore.c b/example/start_up/test_semaphore.c index 4bb97ef3aa176486a2b4c72ae1abcd797878e283..4332f98a21caa14764aa84589adedec5e84da0f1 100644 --- a/example/start_up/test_semaphore.c +++ b/example/start_up/test_semaphore.c @@ -1,16 +1,26 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 14:00:50 - * @LastEditTime: 2021-07-05 14:15:44 - * @Description:  This files is for + * FilePath: test_semaphore.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:02:26 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include #include "ft_types.h" @@ -70,7 +80,7 @@ static void AppTaskCreate(void) BinarySem_Handle = xSemaphoreCreateBinary(); - FT_ASSERTVOID(NULL != BinarySem_Handle); + FASSERT(NULL != BinarySem_Handle); /* 创建任务 */ xReturn = xTaskCreate((TaskFunction_t )Receive_Task, /* 任务入口函数 */ @@ -80,7 +90,7 @@ static void AppTaskCreate(void) (UBaseType_t )2, /* 任务的优先级 */ (TaskHandle_t* )&Receive_Task_Handle);/* 任务控制块指针 */ - FT_ASSERTVOID(pdPASS == xReturn); + FASSERT(pdPASS == xReturn); xReturn = xTaskCreate((TaskFunction_t )Send_Task, /* 任务入口函数 */ (const char* )"Send_Task",/* 任务名字 */ @@ -89,7 +99,7 @@ static void AppTaskCreate(void) (UBaseType_t )2, /* 任务的优先级 */ (TaskHandle_t* )&Send_Task_Handle);/* 任务控制块指针 */ - FT_ASSERTVOID(pdPASS == xReturn); + FASSERT(pdPASS == xReturn); vTaskDelete(AppTaskCreate_Handle); //删除 AppTaskCreate 任务 diff --git a/example/start_up/test_task_priority.c b/example/start_up/test_task_priority.c index a03dfe8cb06f953f6c6a7b4c4f45135806fcbc07..cdc3fb6a01394b2609734aa16660a8f3b089ab0f 100644 --- a/example/start_up/test_task_priority.c +++ b/example/start_up/test_task_priority.c @@ -1,17 +1,27 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 09:06:14 - * @LastEditTime: 2021-07-05 13:24:26 - * @Description:  This files is for + * FilePath: test_task_priority.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:02:33 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include "FreeRTOS.h" #include "task.h" diff --git a/example/start_up/test_uart.c b/example/start_up/test_uart.c index 735a6af6c0136ad52a14db259335259892c5161e..eac942ce6247d7dc9cb8be225e27b540a9906650 100644 --- a/example/start_up/test_uart.c +++ b/example/start_up/test_uart.c @@ -1,16 +1,26 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 13:48:25 - * @LastEditTime: 2021-07-21 09:32:09 - * @Description:  This files is for + * FilePath: test_uart.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:02:36 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include "ft_types.h" #include "fpl011.h" diff --git a/example/template/Readme.md b/example/template/Readme.md index 2a1e169192e77731cc91eecf8863c75959612f6e..53532cba3dd73aef1c0988f2277dbec0dd044888 100644 --- a/example/template/Readme.md +++ b/example/template/Readme.md @@ -1,17 +1,27 @@ + # host侧设置 - 重启host侧tftp服务器 ``` diff --git a/example/template/main.c b/example/template/main.c index 754033d93494713f7d96813f2a695883b3ceb0ff..2dd73873421f97fccd117e96310368f277c9efd2 100644 --- a/example/template/main.c +++ b/example/template/main.c @@ -1,17 +1,27 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-09 08:08:39 - * @LastEditTime: 2021-07-09 13:55:27 - * @Description:  This files is for + * FilePath: main.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:02:53 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include #include #include "FreeRTOS.h" diff --git a/example/template/makefile b/example/template/makefile index d8b858a95db430b15d9dec91957b2d01981d1198..60c127aff74b9cb828fd3509493bb2a14bf19dce 100644 --- a/example/template/makefile +++ b/example/template/makefile @@ -1,10 +1,11 @@ # 指定工程项目根目录为当前(只能指定一个目录) -export PROJECT_DIR ?= . +export PROJECT_DIR ?= $(shell pwd) +export KCONFIG_DIR ?= $(PROJECT_DIR) # 用户添加的源文件夹和头文件夹(可以指定多个) -export USR_SRC_DIR ?= . \ - ./src -export USR_INC_DIR ?= . \ - ./inc +export USR_SRC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/src +export USR_INC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/inc # 用户定义的编译目标文件上传路径 ifeq ($(OS),Windows_NT) @@ -26,3 +27,6 @@ boot: # @echo tar $(CONFIG_TARGET_NAME) # @echo img $(BOOT_IMG_NAME) cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf + + + diff --git a/example/template/sdkconfig b/example/template/sdkconfig index fde19b6238c503dba780c741ce12ed13eab5332c..4f19551765d863d224485712442b57b550ebf333 100644 --- a/example/template/sdkconfig +++ b/example/template/sdkconfig @@ -6,7 +6,7 @@ # # Template Configuration # -CONFIG_TARGET_NAME="d2000_freertos" +CONFIG_TARGET_NAME="ft2004_freertos" # end of Template Configuration # end of Project Configuration @@ -18,21 +18,22 @@ CONFIG_USE_FREERTOS=y # # Arch Configuration # -# CONFIG_TARGET_ARMV8_AARCH32 is not set -CONFIG_TARGET_ARMV8_AARCH64=y +CONFIG_TARGET_ARMV8_AARCH32=y +# CONFIG_TARGET_ARMV8_AARCH64 is not set # CONFIG_TARGET_ARMV7 is not set CONFIG_USE_CACHE=y CONFIG_USE_L3CACHE=y CONFIG_USE_MMU=y -# CONFIG_USE_SYS_TICK is not set +CONFIG_USE_SYS_TICK=y +CONFIG_USE_AARCH64_L1_TO_AARCH32=y # end of Arch Configuration # # Board Configuration # -# CONFIG_TARGET_F2000_4 is not set +CONFIG_TARGET_F2000_4=y # CONFIG_TARGET_E2000 is not set -CONFIG_TARGET_D2000=y +# CONFIG_TARGET_D2000 is not set # end of Board Configuration # @@ -42,7 +43,14 @@ CONFIG_TARGET_D2000=y # CONFIG_USE_QSPI is not set CONFIG_USE_GIC=y CONFIG_ENABLE_GICV3=y -# CONFIG_USE_SERIAL is not set +CONFIG_USE_SERIAL=y + +# +# Usart Configuration +# +CONFIG_ENABLE_Pl011_UART=y +# end of Usart Configuration + # CONFIG_USE_GPIO is not set # CONFIG_USE_IOMUX is not set CONFIG_USE_ETH=y @@ -93,8 +101,8 @@ CONFIG_LOG_INFO=y # # Linker Options # -# CONFIG_AARCH32_RAM_LD is not set -CONFIG_AARCH64_RAM_LD=y +CONFIG_AARCH32_RAM_LD=y +# CONFIG_AARCH64_RAM_LD is not set # CONFIG_USER_DEFINED_LD is not set CONFIG_LINK_SCRIPT_ROM=y CONFIG_ROM_START_UP_ADDR=0x80100000 @@ -103,7 +111,12 @@ CONFIG_LINK_SCRIPT_RAM=y CONFIG_RAM_START_UP_ADDR=0x81000000 CONFIG_RAM_SIZE_MB=64 CONFIG_HEAP_SIZE=1 -CONFIG_STACK_SIZE=0x100000 +CONFIG_SVC_STACK_SIZE=0x1000 +CONFIG_SYS_STACK_SIZE=0x1000 +CONFIG_IRQ_STACK_SIZE=0x1000 +CONFIG_ABORT_STACK_SIZE=0x1000 +CONFIG_FIQ_STACK_SIZE=0x1000 +CONFIG_UNDEF_STACK_SIZE=0x1000 # end of Linker Options # end of Building Option diff --git a/example/template/sdkconfig.h b/example/template/sdkconfig.h index fdb8d1c4ed5479e744536e0423a6bdb7c3bf2af4..ac92b7219c92f12e0bca38fa5d47ea641f93df11 100644 --- a/example/template/sdkconfig.h +++ b/example/template/sdkconfig.h @@ -5,7 +5,7 @@ /* Template Configuration */ -#define CONFIG_TARGET_NAME "d2000_freertos" +#define CONFIG_TARGET_NAME "ft2004_freertos" /* end of Template Configuration */ /* end of Project Configuration */ @@ -15,20 +15,21 @@ /* Arch Configuration */ -/* CONFIG_TARGET_ARMV8_AARCH32 is not set */ -#define CONFIG_TARGET_ARMV8_AARCH64 +#define CONFIG_TARGET_ARMV8_AARCH32 +/* CONFIG_TARGET_ARMV8_AARCH64 is not set */ /* CONFIG_TARGET_ARMV7 is not set */ #define CONFIG_USE_CACHE #define CONFIG_USE_L3CACHE #define CONFIG_USE_MMU -/* CONFIG_USE_SYS_TICK is not set */ +#define CONFIG_USE_SYS_TICK +#define CONFIG_USE_AARCH64_L1_TO_AARCH32 /* end of Arch Configuration */ /* Board Configuration */ -/* CONFIG_TARGET_F2000_4 is not set */ +#define CONFIG_TARGET_F2000_4 /* CONFIG_TARGET_E2000 is not set */ -#define CONFIG_TARGET_D2000 +/* CONFIG_TARGET_D2000 is not set */ /* end of Board Configuration */ /* Components Configuration */ @@ -37,7 +38,12 @@ /* CONFIG_USE_QSPI is not set */ #define CONFIG_USE_GIC #define CONFIG_ENABLE_GICV3 -/* CONFIG_USE_SERIAL is not set */ +#define CONFIG_USE_SERIAL + +/* Usart Configuration */ + +#define CONFIG_ENABLE_Pl011_UART +/* end of Usart Configuration */ /* CONFIG_USE_GPIO is not set */ /* CONFIG_USE_IOMUX is not set */ #define CONFIG_USE_ETH @@ -80,8 +86,8 @@ /* Linker Options */ -/* CONFIG_AARCH32_RAM_LD is not set */ -#define CONFIG_AARCH64_RAM_LD +#define CONFIG_AARCH32_RAM_LD +/* CONFIG_AARCH64_RAM_LD is not set */ /* CONFIG_USER_DEFINED_LD is not set */ #define CONFIG_LINK_SCRIPT_ROM #define CONFIG_ROM_START_UP_ADDR 0x80100000 @@ -90,7 +96,12 @@ #define CONFIG_RAM_START_UP_ADDR 0x81000000 #define CONFIG_RAM_SIZE_MB 64 #define CONFIG_HEAP_SIZE 1 -#define CONFIG_STACK_SIZE 0x400 +#define CONFIG_SVC_STACK_SIZE 0x1000 +#define CONFIG_SYS_STACK_SIZE 0x1000 +#define CONFIG_IRQ_STACK_SIZE 0x1000 +#define CONFIG_ABORT_STACK_SIZE 0x1000 +#define CONFIG_FIQ_STACK_SIZE 0x1000 +#define CONFIG_UNDEF_STACK_SIZE 0x1000 /* end of Linker Options */ /* end of Building Option */ diff --git a/freertos.mk b/freertos.mk new file mode 100644 index 0000000000000000000000000000000000000000..852a4df927a7681b344adb979c9e06163a0d203a --- /dev/null +++ b/freertos.mk @@ -0,0 +1,3 @@ +include $(FREERTOS_SDK_ROOT)/drivers/drivers.mk#freertos 相关依赖 +include $(FREERTOS_SDK_ROOT)/make/ld.mk#freertos 链接脚本依赖 +include $(FREERTOS_SDK_ROOT)/third-party/third-party.mk#第三方库依赖 diff --git a/install.py b/install.py index e03dcebec0c2b81e83a709c1097f2e62071e9e71..fb6299d6cccf0d723780c8c91244383b776460b9 100644 --- a/install.py +++ b/install.py @@ -86,14 +86,14 @@ os.system("chmod +x ./make/*.mk --silent ") os.system("chmod +x ./lib/Kconfiglib/*.py --silent ") # Add standalone sdk -standalone_sdk_v="v0.1.15" +standalone_sdk_v="v0.1.17" standalone_path=freertos_sdk_path + '/standalone' standalone_branche="master" standalone_remote="https://gitee.com/phytium_embedded/phytium-standalone-sdk.git" if not os.path.exists(standalone_path): current_path = os.getcwd() - + os.system("git clone {} {}".format(standalone_remote,standalone_path)) os.chdir(standalone_path) # 切换工作路径至standalone 路径 os.system("git config core.sparsecheckout true") @@ -104,6 +104,7 @@ if not os.path.exists(standalone_path): os.system("echo \"drivers/*\" >> {}".format(r'.git/info/sparse-checkout')) os.system("echo \"standalone.mk\" >> {}".format(r'.git/info/sparse-checkout')) os.system("echo \"lib/*\" >> {}".format(r'.git/info/sparse-checkout')) + os.system("echo \"doc/*\" >> {}".format(r'.git/info/sparse-checkout')) os.system("git checkout {}".format(standalone_sdk_v)) print('[1]: Standalone sdk download is succeed') diff --git a/make/Kconfig b/make/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..66276df111449883b4ab45e0fd310b450918de92 --- /dev/null +++ b/make/Kconfig @@ -0,0 +1,11 @@ + +menu "Compiler Options" + +config DON_T_BINARY_OUTPUT + bool "Don't output *.bin file" + default y + help + Don't create output bin by binary + +endmenu + diff --git a/make/build_freertos.mk b/make/build_freertos.mk index aafbaedd666875447e0eb719c7bd9793698089ee..41a2d8f881cc1cbb7e84dddb7b532ca2eb334731 100755 --- a/make/build_freertos.mk +++ b/make/build_freertos.mk @@ -1,12 +1,25 @@ -INC_DIR ?= # include 目录 -SRC_DIR ?= # 源文件目录 -EXCL_SRC ?= # 在源文件目录中不编译 +# 指定工程项目根目录为当前(只能指定一个目录) +export PROJECT_DIR ?= $(shell pwd) +# 用户添加的源文件夹和头文件夹(可以指定多个) +export USR_SRC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/src +export USR_INC_DIR ?= $(PROJECT_DIR) \ + $(PROJECT_DIR)/inc -export STANDALONE_DIR=$(FREERTOS_STANDALONE) +export EXCL_SRC ?= # 在源文件目录中不编译 +export OUTPUT_DIR ?= $(PROJECT_DIR)/build#编译信息存放目录 +export KCONFIG_DIR ?= $(PROJECT_DIR)# sdkconfig 目录 +export EG_CONFIGS_DIR ?= $(PROJECT_DIR)/configs#不同平台备份配置信息 +export STANDALONE_DIR?=$(FREERTOS_STANDALONE) include $(FREERTOS_SDK_ROOT)/make/preconfig.mk -include $(FREERTOS_SDK_ROOT)/make/complier.mk -include $(FREERTOS_SDK_ROOT)/make/buildinfo.mk -include $(FREERTOS_SDK_ROOT)/make/packsource.mk -include $(FREERTOS_SDK_ROOT)/make/menuconfig.mk -include $(FREERTOS_SDK_ROOT)/make/build_all.mk \ No newline at end of file +ifdef USER_DEFINE_MK#用户自定义makefile 脚本 +include $(USER_DEFINE_MK) +endif +include $(FREERTOS_SDK_ROOT)/make/standalone_dependence.mk# standalone sdk 依赖 +include $(FREERTOS_SDK_ROOT)/freertos.mk#freertos 相关依赖 +include $(FREERTOS_SDK_ROOT)/make/complier.mk#编译功能 +include $(FREERTOS_SDK_ROOT)/make/buildinfo.mk#目录调试相关打印 +include $(FREERTOS_SDK_ROOT)/make/packsource.mk# +include $(FREERTOS_SDK_ROOT)/make/menuconfig.mk#kconfig 相关功能 +include $(FREERTOS_SDK_ROOT)/make/default_load.mk#kconfig 相关的默认加载功能 diff --git a/make/buildinfo.mk b/make/buildinfo.mk index fa3cea7ee369a651144ecbafbe70937c4a513287..b19a17ceb84c149b8f9b79c8e850bce0a69d25cf 100755 --- a/make/buildinfo.mk +++ b/make/buildinfo.mk @@ -1,16 +1,4 @@ -# -# @ : Copyright (c) 2021 Phytium Information Technology, Inc. -# -# SPDX-License-Identifier: Apache-2.0. -# -# @Date: 2021-06-02 14:17:37 -# @LastEditTime: 2021-06-02 14:24:21 -# @Description:  This files is to print build info for debugging -# -# @Modify History: -# Ver   Who        Date         Changes -# ----- ------     --------    -------------------------------------- -# + .PHONY: info info-objs info-incs info-srcs info-libs info-variables info: info-objs info-incs info-srcs @@ -44,7 +32,7 @@ info-srcs: @echo info-variables: - @echo "sdkconfig: "$(PROJECT_DIR)/$(KCONFIG_CONFIG) + @echo "sdkconfig: "$(KCONFIG_DIR)/$(KCONFIG_CONFIG) info-flags: @echo "target arch: "$(TARGET_ARCH) diff --git a/make/complier.mk b/make/complier.mk index fd65240f35b5b1ad5cab450b9f179679d62dfa1e..3f76460b9ec71538a934caa931c681ed441f2a55 100755 --- a/make/complier.mk +++ b/make/complier.mk @@ -11,15 +11,16 @@ # OPT_LEVEL 0, 1, 2 or 3 # DEFINES -D MYDEFINE -#include $(FREERTOS_SDK_ROOT)/make/preconfig.mk -export USR_SRC_DIR ?= $(PROJECT_DIR) -export USR_INC_DIR ?= $(PROJECT_DIR) - APP ?= $(CONFIG_TARGET_NAME) QUIET ?=@ OPT_LEVEL ?= 0 +INC_DIR ?= # include 目录 +SRC_DIR ?= # 源文件目录 +EXCL_SRC ?= # 在源文件目录中不编译 +OUTPUT_DIR ?= #输出目标文件 + # Other switches the user should not normally need to change: ifdef CONFIG_TARGET_ARMV8_AARCH32 ARCH = armv8-a @@ -41,7 +42,7 @@ $(error error, please set FREERTOS_SDK_ROOT first!!) endif ifeq ($(QUIET),@) -PROGRESS = @echo Compiling $<... +PROGRESS = @echo $<... endif ifdef CONFIG_TARGET_ARMV8_AARCH64 @@ -67,23 +68,8 @@ OC = $(CROSS_COMPILE)objcopy OD = $(CROSS_COMPILE)objdump LD = $(CROSS_COMPILE)ld -# Commit hash from git -COMMIT=$(shell git rev-parse --short HEAD) -PACK_DATA=$(shell date +'%m%d_%H%M') -INC_DIR ?= # include 目录 -SRC_DIR ?= # 源文件目录 -EXCL_SRC ?= # 在源文件目录中不编译 -#OUTPUT_DIR ?= build # 输出目录 $(shell if [ ! -e $(OUTPUT_DIR) ];then mkdir -p $(OUTPUT_DIR); fi) - -include $(STANDALONE_DIR)/standalone.mk -include $(STANDALONE_DIR)/lib/lib.mk -include $(FREERTOS_SDK_ROOT)/make/ld.mk -include $(FREERTOS_SDK_ROOT)/third-party/third-party.mk -include $(FREERTOS_SDK_ROOT)/standalone_adaptive.mk - - INC_DIR := $(INC_DIR) $(USR_INC_DIR) INCLUDES := $(patsubst %, -I %, $(INC_DIR)) # 使用ld.o作为后缀,区分临时用的linkscript @@ -103,7 +89,6 @@ CPPFLAGS = $(DEFINES) $(INCLUDES) $(DEPEND_FLAGS) $(CPPFLAGS_EXTRA) CFLAGS = $(DEBUG_FLAGS) -DGUEST -ffreestanding -Wextra -g -O$(OPT_LEVEL) ASFLAGS = $(CFLAGS) - #mkdir 创建输出文件目录 SRC_DIR := $(SRC_DIR) $(USR_SRC_DIR) X_OUTPUT_DIRS := $(patsubst %, $(OUTPUT_DIR)/%, $(SRC_DIR)) @@ -116,7 +101,6 @@ OBJ_FILES := $(patsubst %, $(OUTPUT_DIR)/%, $(APP_S_SRC:.S=.o)) \ EXCL_OBJS ?= $(patsubst %, $(OUTPUT_DIR)/%, $(EXCL_SRC:.c=.o) $(EXCL_SRC:.S=.o)) OBJ_FILES := $(filter-out $(EXCL_OBJS), $(OBJ_FILES)) -OBJ_FILES += $(LIBC) DEP_FILES := $(OBJ_FILES:%=%.d) @@ -130,18 +114,6 @@ ifdef CONFIG_TARGET_ARMV8_AARCH32 endif -# 使用编译链自带的Glibc -ifdef CONFIG_USE_G_LIBC - ifdef CONFIG_TARGET_ARMV8_AARCH32 - LIBPATH += $(CROSS_PATH)/arm-none-eabi/lib/thumb/v7/nofp - LDFLAGS += -lgcc -L $(LIBPATH) - INC_DIR := $(INC_DIR) $(CROSS_PATH)/arm-none-eabi/include - OBJ_FILES += $(CROSS_PATH)/arm-none-eabi/lib/thumb/v7/nofp/libc.a \ - $(CROSS_PATH)/arm-none-eabi/lib/thumb/v7/nofp/libm.a \ - $(CROSS_PATH)/lib/gcc/arm-none-eabi/$(CC_VERSION)/libgcc.a - endif -endif - TEST_DATA ?= # 使用外链的NewLibc ifdef CONFIG_USE_NEW_LIBC @@ -171,12 +143,6 @@ ifdef CONFIG_USE_NOSTD_LIBC endif -ifdef CONFIG_DUMMY_COMPILE - DO_ECHO = @echo -else - DO_ECHO = -endif - .phony: all linkscript clean rebuild all: $(APP) @@ -184,7 +150,7 @@ linkscript: # 如果用户指定了linkscript,跳过使用用户指定的linkscript ifndef CONFIG_USER_DEFINED_LD @cp -f $(LDSNAME) $(TEMP_LD) - $(DO_ECHO) $(QUIET) $(CC) -P -E $(TEMP_LD) -o $(PROJ_LD) -I $(PROJECT_DIR) + $(QUIET) $(CC) -P -E $(TEMP_LD) -o $(PROJ_LD) -I $(KCONFIG_DIR) $(INCLUDES) @rm -f $(TEMP_LD) else PROJ_LD := $(EXT_LDSNAME) @@ -193,10 +159,12 @@ endif $(APP): $(OBJ_FILES) linkscript @echo Linking $@.elf @echo Dumping $@.map - $(DO_ECHO) $(QUIET) $(CC) $(TARGET_ARCH) $(LDFLAGS) -T $(PROJ_LD) --output $@.elf -Wl,-Map=$@.map $(OBJ_FILES) -lm + $(QUIET) $(CC) $(TARGET_ARCH) $(LDFLAGS) -T $(PROJ_LD) --output $@.elf -Wl,-Map=$@.map $(OBJ_FILES) -lm +ifndef CONFIG_DON_T_BINARY_OUTPUT @echo Objcopying $@.bin - $(DO_ECHO) $(QUIET) $(OC) -v -O binary $@.elf $@.bin - $(DO_ECHO) $(QUIET) $(OD) -D $@.elf > $@.dis + $(QUIET) $(OC) -v -O binary $@.elf $@.bin +endif + $(QUIET) $(OD) -D $@.elf > $@.dis @echo Done. diff --git a/make/build_all.mk b/make/default_load.mk similarity index 65% rename from make/build_all.mk rename to make/default_load.mk index 66b4c72dd90b46fc72585a6e6a90f779aa85c853..d6597fbbd4228d79bbc9d67a7601b7e25d132f07 100644 --- a/make/build_all.mk +++ b/make/default_load.mk @@ -1,22 +1,6 @@ -# /* -# * @ : Copyright (c) 2021 Phytium Information Technology, Inc. -# * -# * SPDX-License-Identifier: Apache-2.0. -# * -# * @Date: 2021-10-28 14:51:27 -# * @LastEditTime: 2021-10-28 15:04:55 -# * @Description:  This files is for build images for all platform -# * -# * @Modify History: -# * Ver   Who        Date         Changes -# * ----- ------     --------    -------------------------------------- -# */ - -EG_CONFIGS_DIR := ./configs - # 根据例程默认,编译各平台的镜像 -.PHONY: load_e2000_aarch32 load_e2000_aarch64 backup_kconfig +.PHONY: load_e2000_aarch32 load_e2000_aarch64 backup_kconfig build_ft2004_aarch32 build_ft2004_aarch64 build_d2000_aarch32 build_d2000_aarch64 config_ft2004_aarch32 config_ft2004_aarch64 config_d2000_aarch32 config_d2000_aarch64 load_ft2004_aarch32: @echo "========Load for FT2000/4 AARCH32 Start=============" @@ -48,27 +32,34 @@ load_e2000_aarch64: make ldconfig LDCONFIG_ARG=$(EG_CONFIGS_DIR)/e2000_aarch64_eg_configs @echo "==============E2000 AARCH64=========================" + backup_kconfig: ifdef CONFIG_TARGET_ARMV8_AARCH32 ifdef CONFIG_TARGET_D2000 - cp sdkconfig ./configs/d2000_aarch32_eg_configs + cp sdkconfig $(EG_CONFIGS_DIR)/d2000_aarch32_eg_configs endif ifdef CONFIG_TARGET_F2000_4 - cp sdkconfig ./configs/ft2004_aarch32_eg_configs + cp sdkconfig $(EG_CONFIGS_DIR)/ft2004_aarch32_eg_configs endif ifdef CONFIG_TARGET_E2000 - cp sdkconfig ./configs/e2000_aarch32_eg_configs + cp sdkconfig $(EG_CONFIGS_DIR)/e2000_aarch32_eg_configs endif endif ifdef CONFIG_TARGET_ARMV8_AARCH64 ifdef CONFIG_TARGET_D2000 - cp sdkconfig ./configs/d2000_aarch64_eg_configs + cp sdkconfig $(EG_CONFIGS_DIR)/d2000_aarch64_eg_configs endif ifdef CONFIG_TARGET_F2000_4 - cp sdkconfig ./configs/ft2004_aarch64_eg_configs + cp sdkconfig $(EG_CONFIGS_DIR)/ft2004_aarch64_eg_configs endif ifdef CONFIG_TARGET_E2000 - cp sdkconfig ./configs/e2000_aarch64_eg_configs + cp sdkconfig $(EG_CONFIGS_DIR)/e2000_aarch64_eg_configs endif -endif \ No newline at end of file +endif + + +config_ft2004_aarch32: lddefconfig genconfig clean +config_ft2004_aarch64: lddefconfig genconfig clean +config_d2000_aarch32: lddefconfig genconfig clean +config_d2000_aarch64: lddefconfig genconfig clean \ No newline at end of file diff --git a/make/ld/aarch32_ram.ld b/make/ld/aarch32_ram.ld index 590de49cad7ec2de7ba38c17e6741437a9107781..6d69402d8ce2ba02e3ddb6f18170691c184e6f0b 100644 --- a/make/ld/aarch32_ram.ld +++ b/make/ld/aarch32_ram.ld @@ -185,4 +185,7 @@ SECTIONS } > RAM +#ifdef CONFIG_USE_OPENAMP +#include "ft_openamp.ld" +#endif } diff --git a/make/ld/aarch64_ram.ld b/make/ld/aarch64_ram.ld index 662a53653377121696333510d83b35c795dd0914..4c28d58a57e8c40e8714e8fa4fed2a685f217bac 100644 --- a/make/ld/aarch64_ram.ld +++ b/make/ld/aarch64_ram.ld @@ -165,5 +165,7 @@ SECTIONS __el1_stack = .; } > RAM - +#ifdef CONFIG_USE_OPENAMP +#include "ft_openamp.ld" +#endif } diff --git a/make/menuconfig.mk b/make/menuconfig.mk index 61433c51fe39ae28aa28b5e6bc95984406cf9887..534401b8f6aa836542bd86f1f186808e0ec23c34 100755 --- a/make/menuconfig.mk +++ b/make/menuconfig.mk @@ -1,17 +1,3 @@ -# -# @ : Copyright (c) 2021 Phytium Information Technology, Inc. -# -# SPDX-License-Identifier: Apache-2.0. -# -# @Date: 2021-05-31 16:54:49 -# @LastEditTime: 2021-05-31 16:55:15 -# @Description:  This files is for baremetal build config -# -# @Modify History: -# Ver   Who        Date         Changes -# ----- ------     --------    -------------------------------------- -# - .PHONY: menuconfig oldconfig alldefconfig savedefconfig lddefconfig genconfig menuconfig: $(STANDALONE_DIR)/lib/Kconfiglib/menuconfig.py @@ -35,22 +21,11 @@ savedefconfig: $(STANDALONE_DIR)/lib/Kconfiglib/savedefconfig.py lddefconfig: - @cp $(FREERTOS_SDK_ROOT)/configs/$(DEF_KCONFIG) ./$(KCONFIG_CONFIG) -f + @cp $(FREERTOS_SDK_ROOT)/configs/$(DEF_KCONFIG) $(KCONFIG_DIR)/$(KCONFIG_CONFIG) -f @echo "get default configs at " $(FREERTOS_SDK_ROOT)/configs/$(DEF_KCONFIG) ldconfig: - cp $(LDCONFIG_ARG) ./$(KCONFIG_CONFIG) -f + cp $(LDCONFIG_ARG) $(KCONFIG_DIR)/$(KCONFIG_CONFIG) -f @echo "get configs at " $(LDCONFIG_ARG) $(STANDALONE_DIR)/lib/Kconfiglib/genconfig.py -# load default configs,then generate sdkconfig.h, and clean build targets -# support platform -# FT2000/4 AARCH32/AARCH64 -# D2000 AARCH32/AARCH64 -.PHONY: config_ft2004_aarch32 config_ft2004_aarch64 config_d2000_aarch32 config_d2000_aarch64 - -config_ft2004_aarch32: lddefconfig genconfig clean -config_ft2004_aarch64: lddefconfig genconfig clean -config_d2000_aarch32: lddefconfig genconfig clean -config_d2000_aarch64: lddefconfig genconfig clean - diff --git a/make/packsource.mk b/make/packsource.mk index 57cac488957030596ce909c36d784c6c1aac7f8a..7eec54cce04615c07f5cc461f244b2f709fb93fa 100755 --- a/make/packsource.mk +++ b/make/packsource.mk @@ -1,18 +1,3 @@ -# -# @ : Copyright (c) 2021 Phytium Information Technology, Inc. -# -# SPDX-License-Identifier: Apache-2.0. -# -# @Date: 2021-06-02 11:03:35 -# @LastEditTime: 2021-06-02 11:39:19 -# @Description:  This files is for pack mini source code for building -# -# make pack OUTPATH=/mnt/d/6-2021 -# -# @Modify History: -# Ver   Who        Date         Changes -# ----- ------     --------    -------------------------------------- -# ifeq ($(MAKECMDGOALS),pack) ifndef OUTPATH diff --git a/make/preconfig.mk b/make/preconfig.mk index 958d1ce4b40104d9cf30ea383013557549b37264..e47a901e284212117f854edc280d2299bcbee411 100755 --- a/make/preconfig.mk +++ b/make/preconfig.mk @@ -1,13 +1,10 @@ -export USR_SRC_DIR ?= $(PROJECT_DIR) -export USR_INC_DIR ?= $(PROJECT_DIR) - # Read in dependencies to all Kconfig* files, make sure to run # oldconfig if changes are detected. # DO NOT USE CONFIG ITEM BEFORE INCLUDE KCONFIG # specify menuconfig setting export MENUCONFIG_STYLE=aquatic export KCONFIG_CONFIG=sdkconfig -export OUTPUT_DIR ?= $(PROJECT_DIR)/build + # 定义不同平台的默认配置文件 ifeq ($(MAKECMDGOALS),config_ft2004_aarch32) @@ -35,15 +32,15 @@ export DEF_KCONFIG=d2000_aarch64_defconfig endif #if sdkconfig not exits, prompt user to load default sdkconfig first -FILE_EXISTS = $(shell if [ -f ./$(KCONFIG_CONFIG) ]; then echo "exist"; else echo "notexist"; fi;) +FILE_EXISTS = $(shell if [ -f $(KCONFIG_DIR)/$(KCONFIG_CONFIG) ]; then echo "exist"; else echo "notexist"; fi;) ifneq ($(MAKECMDGOALS),lddefconfig) ifeq (FILE_EXISTS, "notexist") $(error error, please type in 'make lddefconfig DEF_KCONFIG=' first!!) endif -$(shell if [ ! -d $(KCONFIG_CONFIG) ]; then touch ./$(KCONFIG_CONFIG); fi) -include $(PROJECT_DIR)/$(KCONFIG_CONFIG) +$(shell if [ ! -d $(KCONFIG_DIR)/$(KCONFIG_CONFIG) ]; then touch $(KCONFIG_DIR)/$(KCONFIG_CONFIG); fi) +include $(KCONFIG_DIR)/$(KCONFIG_CONFIG) else ifndef DEF_KCONFIG diff --git a/make/standalone_dependence.mk b/make/standalone_dependence.mk new file mode 100644 index 0000000000000000000000000000000000000000..3ff4c72c1984e8456c715750bd4e602b7ef89fac --- /dev/null +++ b/make/standalone_dependence.mk @@ -0,0 +1,14 @@ +export STANDALONE_DIR?=$(FREERTOS_STANDALONE) + +include $(STANDALONE_DIR)/standalone.mk#裸跑相关依赖 +include $(STANDALONE_DIR)/lib/lib.mk#libc 相关依赖 + +EXCL_SRC += $(STANDALONE_DIR)/common/fmemory_pool.c + +ifdef CONFIG_TARGET_ARMV8_AARCH64 +EXCL_SRC += $(STANDALONE_DIR)/arch/armv8/aarch64/gcc/boot.S +EXCL_SRC += $(STANDALONE_DIR)/arch/armv8/aarch64/gcc/vectors.S +EXCL_SRC += $(STANDALONE_DIR)/arch/armv8/aarch64/gcc/vectors_g.c +else +EXCL_SRC += $(STANDALONE_DIR)/arch/armv8/aarch32/gcc/vector.S +endif diff --git a/scripts/git_operations.sh b/scripts/git_operations.sh index 7cb917698033c41b9471c6b4f12ece0fb04014a2..fd12e8a36f80048c76c85659f49b73e02f72f329 100755 --- a/scripts/git_operations.sh +++ b/scripts/git_operations.sh @@ -1,16 +1,3 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-07-06 08:46:10 - # @LastEditTime: 2021-07-22 11:00:29 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### #!/bin/sh git update-index --chmod=+x ./install.sh diff --git a/scripts/release_tag.sh b/scripts/release_tag.sh index 966cf173c4f0844a19539d0bafa57ce23a4e1888..49a5b5b83bc6c16fda814360387a8bfcc2fa36ad 100644 --- a/scripts/release_tag.sh +++ b/scripts/release_tag.sh @@ -1,16 +1,3 @@ -### - # @ : Copyright (c) 2021 Phytium Information Technology, Inc. - # - # SPDX-License-Identifier: Apache-2.0. - # - # @Date: 2021-07-02 10:54:34 - # @LastEditTime: 2021-07-22 15:56:44 - # @Description:  This files is for - # - # @Modify History: - # Ver   Who        Date         Changes - # ----- ------     --------    -------------------------------------- -### #!/bin/sh version=v0.0.3 diff --git a/standalone_adaptive.mk b/standalone_adaptive.mk deleted file mode 100644 index 1225afa2b93b83b0da7a4bacccf67e10db9b569a..0000000000000000000000000000000000000000 --- a/standalone_adaptive.mk +++ /dev/null @@ -1,11 +0,0 @@ - -EXCL_SRC += $(FREERTOS_SDK_ROOT)/standalone/common/fmemory_pool.c - - -ifdef CONFIG_TARGET_ARMV8_AARCH64 -EXCL_SRC += $(FREERTOS_SDK_ROOT)/standalone/arch/armv8/aarch64/gcc/boot.S -EXCL_SRC += $(FREERTOS_SDK_ROOT)/standalone/arch/armv8/aarch64/gcc/vectors.S -EXCL_SRC += $(FREERTOS_SDK_ROOT)/standalone/arch/armv8/aarch64/gcc/vectors_g.c -else -EXCL_SRC += $(FREERTOS_SDK_ROOT)/standalone/arch/armv8/aarch32/gcc/vector.S -endif diff --git a/third-party/Kconfig b/third-party/Kconfig index 3071d5eb7abdb4f6a39489eb020948a5827adf11..7d65499aacbad269698b84ba3d6a5bb06d5c14c7 100644 --- a/third-party/Kconfig +++ b/third-party/Kconfig @@ -10,3 +10,40 @@ config USE_LWIP source "$(FREERTOS_SDK_ROOT)/third-party/lwip-2.1.2/Kconfig" endif + +config USE_BACKTRACE + bool + prompt "Display a backtrace." + default y + + + +config USE_AMP + bool + prompt "Use Asymmetric Multi-processing" + default n + help + Include OpenAMP framework + + if USE_AMP + config USE_LIBMETAL + bool + prompt "Use Libmetal" + help + Include Libmetal + + source "$(FREERTOS_SDK_ROOT)/third-party/openamp/ports/Kconfig" + + endif + + +config USE_LETTER_SHELL + bool + prompt "Use Letter Shell" + default n + help + Include Litter Shell for User Interactive + + if USE_LETTER_SHELL + source "$(FREERTOS_SDK_ROOT)/third-party/letter-shell-3.1/Kconfig" + endif \ No newline at end of file diff --git a/third-party/backtrace/backtrace.c b/third-party/backtrace/backtrace.c new file mode 100644 index 0000000000000000000000000000000000000000..41d7565f721225b2f3a014e67c7e040bb27b3893 --- /dev/null +++ b/third-party/backtrace/backtrace.c @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include + +/* Maximum number of entries in the backtrace to display */ +#define UNWIND_LIMIT 20U + +/* + * If -fno-omit-frame-pointer is used: + * + * - AArch64: The AAPCS defines the format of the frame records and mandates the + * usage of r29 as frame pointer. + * + * - AArch32: The format of the frame records is not defined in the AAPCS. + * However, at least GCC and Clang use the same format. When they are forced + * to only generate A32 code (with -marm), they use r11 as frame pointer and a + * similar format as in AArch64. If interworking with T32 is enabled, the + * frame pointer is r7 and the format is different. This is not supported by + * this implementation of backtrace, so it is needed to use -marm. + */ + +/* Frame records form a linked list in the stack */ +struct frame_record +{ + /* Previous frame record in the list */ + struct frame_record *parent; + /* Return address of the function at this level */ + uintptr_t return_addr; +}; + +/* + * Returns true if all the bytes in a given object are in mapped memory and an + * LDR using this pointer would succeed, false otherwise. + */ +static bool is_valid_object(uintptr_t addr, size_t size) +{ + assert(size > 0U); + + if (addr == 0U) + return false; + + /* Detect overflows */ + if ((addr + size) < addr) + return false; + + /* A pointer not aligned properly could trigger an alignment fault. */ + if ((addr & (sizeof(uintptr_t) - 1U)) != 0U) + return false; + + return true; +} + +/* + * Returns true if the specified address is correctly aligned and points to a + * valid memory region. + */ +static bool is_valid_jump_address(uintptr_t addr) +{ + if (addr == 0U) + return false; + + /* Check alignment. Both A64 and A32 use 32-bit opcodes */ + if ((addr & (sizeof(uint32_t) - 1U)) != 0U) + return false; + + return true; +} + +/* + * Returns true if the pointer points at a valid frame record, false otherwise. + */ +static bool is_valid_frame_record(struct frame_record *fr) +{ + return is_valid_object((uintptr_t)fr, sizeof(struct frame_record)); +} + +/* + * Adjust the frame-pointer-register value by 4 bytes on AArch32 to have the + * same layout as AArch64. + */ +static struct frame_record *adjust_frame_record(struct frame_record *fr) +{ + return fr; +} + +static void unwind_stack(struct frame_record *fr, uintptr_t current_pc, + uintptr_t link_register) +{ + uintptr_t call_site; + static const char *backtrace_str = "%u: 0x%lx\n"; + + if (!is_valid_frame_record(fr)) + { + printf("ERROR: Corrupted frame pointer (frame record address = %p)\n", + fr); + return; + } + + if (fr->return_addr != link_register) + { + printf("ERROR: Corrupted stack (frame record address = %p)\n", + fr); + return; + } + + /* The level 0 of the backtrace is the current backtrace function */ + printf(backtrace_str, 0U, current_pc); + + /* + * The last frame record pointer in the linked list at the beginning of + * the stack should be NULL unless stack is corrupted. + */ + for (unsigned int i = 1U; i < UNWIND_LIMIT; i++) + { + /* If an invalid frame record is found, exit. */ + if (!is_valid_frame_record(fr)) + return; + /* + * A32 and A64 are fixed length so the address from where the + * call was made is the instruction before the return address, + * which is always 4 bytes before it. + */ + call_site = fr->return_addr - 4U; + + /* + * If the address is invalid it means that the frame record is + * probably corrupted. + */ + if (!is_valid_jump_address(call_site)) + return; + + printf(backtrace_str, i, call_site); + + fr = adjust_frame_record(fr->parent); + } + + printf("ERROR: Max backtrace depth reached\n"); +} + +/* + * Display a backtrace. The cookie string parameter is displayed along the + * trace to help filter the log messages. + * + * Many things can prevent displaying the expected backtrace. For example, + * compiler optimizations can use a branch instead of branch with link when it + * detects a tail call. The backtrace level for this caller will not be + * displayed, as it does not appear in the call stack anymore. Also, assembly + * functions will not be displayed unless they setup AAPCS compliant frame + * records on AArch64 and compliant with GCC-specific frame record format on + * AArch32. + * + * Usage of the trace: addr2line can be used to map the addresses to function + * and source code location when given the ELF file compiled with debug + * information. The "-i" flag is highly recommended to improve display of + * inlined function. The *.dump files generated when buildidng each image can + * also be used. + * + * WARNING: In case of corrupted stack, this function could display security + * sensitive information past the beginning of the stack so it must not be used + * in production build. This function is only compiled in when ENABLE_BACKTRACE + * is set to 1. + */ +void backtrace(const char *cookie) +{ + uintptr_t return_address = (uintptr_t)__builtin_return_address(0U); + struct frame_record *fr = __builtin_frame_address(0U); + + fr = adjust_frame_record(fr); + + printf("BACKTRACE: START: %s\n", cookie); + + unwind_stack(fr, (uintptr_t)&backtrace, return_address); + + printf("BACKTRACE: END: %s\n", cookie); +} diff --git a/third-party/backtrace/backtrace.h b/third-party/backtrace/backtrace.h new file mode 100644 index 0000000000000000000000000000000000000000..e8fcc59017a58feeb50e51573fb2a1e2598ace1d --- /dev/null +++ b/third-party/backtrace/backtrace.h @@ -0,0 +1,6 @@ +#ifndef _BACKTRACE_H +#define _BACKTRACE_H + +void backtrace(const char *cookie); + +#endif /* _BACKTRACE_H */ \ No newline at end of file diff --git a/third-party/freertos/portable/GCC/ft_platform/aarch32/FreeRTOSConfig.h b/third-party/freertos/portable/GCC/ft_platform/aarch32/FreeRTOSConfig.h index 71a59afd671f6c4fecbf58f29efb18633cbee4f4..0e189b2c915421df1d8b16263b9601c323b1dcd0 100644 --- a/third-party/freertos/portable/GCC/ft_platform/aarch32/FreeRTOSConfig.h +++ b/third-party/freertos/portable/GCC/ft_platform/aarch32/FreeRTOSConfig.h @@ -76,7 +76,7 @@ #define configUSE_TICK_HOOK 1 #define configMAX_PRIORITIES (7) #define configMINIMAL_STACK_SIZE ((unsigned short)1024) //min task stack size 100*4 bytes -#define configTOTAL_HEAP_SIZE (4096 * 1024) //total heap size +#define configTOTAL_HEAP_SIZE (10*1024 * 1024) //total heap size #define configMAX_TASK_NAME_LEN (20) #define configUSE_TRACE_FACILITY 1 //启用可视化跟踪调试 /* 与宏 configUSE_TRACE_FACILITY 同时为 1 时会编译下面 3 个函数 diff --git a/third-party/freertos/portable/GCC/ft_platform/aarch64/portAsm_debug.c b/third-party/freertos/portable/GCC/ft_platform/aarch64/portAsm_debug.c index 5384a88997cf5f8ecd80b2bc9cc6125849ea9447..732ab98531fd843834baf8f45a69b25fb3c4e58f 100644 --- a/third-party/freertos/portable/GCC/ft_platform/aarch64/portAsm_debug.c +++ b/third-party/freertos/portable/GCC/ft_platform/aarch64/portAsm_debug.c @@ -1,18 +1,28 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-12-15 17:24:04 - * @LastEditTime: 2021-12-15 17:28:22 - * @Description:  This files is for + * FilePath: portAsm_debug.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:03:36 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include "stdio.h" void test_value(void * x0 ,void * x1,void * x2 ,void * x3) diff --git a/third-party/freertos/portable/GCC/ft_platform/aarch64/vectors_g.c b/third-party/freertos/portable/GCC/ft_platform/aarch64/vectors_g.c index 276897ebfd065cead936b5123ad247ee7b66c96b..61546459a4b1ae1ecd749bdcf2e26c99abc9271f 100644 --- a/third-party/freertos/portable/GCC/ft_platform/aarch64/vectors_g.c +++ b/third-party/freertos/portable/GCC/ft_platform/aarch64/vectors_g.c @@ -1,13 +1,22 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-12-15 11:26:01 - * @LastEditTime: 2021-12-15 11:52:25 - * @Description:  This files is for + * FilePath: vectors_g.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:03:39 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ @@ -17,6 +26,7 @@ + #include "ft_types.h" diff --git a/third-party/freertos/portable/freertos_configs.c b/third-party/freertos/portable/freertos_configs.c index 97cef5a66eaf2d8755f474526e7914d20e53ef60..c2f9d4e1d8b9b4bc7d17e6a398c53096488ad050 100644 --- a/third-party/freertos/portable/freertos_configs.c +++ b/third-party/freertos/portable/freertos_configs.c @@ -1,16 +1,26 @@ /* - * @ : Copyright (c) 2021 Phytium Information Technology, Inc. + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. * - * SPDX-License-Identifier: Apache-2.0. * - * @Date: 2021-07-05 08:35:41 - * @LastEditTime: 2021-12-15 16:59:45 - * @Description:  This files is for + * FilePath: freertos_configs.c + * Date: 2022-02-24 13:42:19 + * LastEditTime: 2022-03-21 17:03:31 + * Description:  This file is for * - * @Modify History: + * Modify History: * Ver   Who        Date         Changes * ----- ------     --------    -------------------------------------- */ + #include "FreeRTOS.h" #include "task.h" #include "ft_types.h" @@ -19,6 +29,7 @@ #include "generic_timer.h" #include "interrupt.h" #include +#include "cpu_info.h" #include "ft_assert.h" void vMainAssertCalled(const char *pcFileName, uint32_t ulLineNumber) @@ -30,7 +41,9 @@ void vMainAssertCalled(const char *pcFileName, uint32_t ulLineNumber) void vApplicationMallocFailedHook(void) { - printf("Malloc Failed\r\n"); + u32 cpu_id; + GetCpuId(&cpu_id); + printf("cpu %d Malloc Failed\r\n",cpu_id); while (1) ; } @@ -162,7 +175,7 @@ void vApplicationStackOverflowHook(xTaskHandle pxTask, signed char *pcTaskName) (void) pcTaskName; taskDISABLE_INTERRUPTS(); - FT_ASSERTNONERETURN(FALSE); + FASSERT(FALSE); } diff --git a/third-party/letter-shell-3.1/Kconfig b/third-party/letter-shell-3.1/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..cce820581ec432d625516ad045358daabc3e5962 --- /dev/null +++ b/third-party/letter-shell-3.1/Kconfig @@ -0,0 +1,14 @@ +menu "Letter Shell Configuration" + choice LETTER_SHELL_USART_TYPE + prompt "Usart Drivers" + default LS_PL011_UART + help + Select Usart Driver for Letter Shell + + config LS_PL011_UART + select USE_SERIAL + select ENABLE_Pl011_UART + bool "PL011" + + endchoice # LETTER_SHELL_USART_TYPE +endmenu \ No newline at end of file diff --git a/third-party/letter-shell-3.1/LICENSE b/third-party/letter-shell-3.1/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..229cea04fd9882e58b35231d4e717cda32b54252 --- /dev/null +++ b/third-party/letter-shell-3.1/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Letter + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/third-party/letter-shell-3.1/README.md b/third-party/letter-shell-3.1/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8cfca7799dac66f9358ac7f98a16058c5b158f7e --- /dev/null +++ b/third-party/letter-shell-3.1/README.md @@ -0,0 +1,484 @@ +# letter shell 3.0 + +![version](https://img.shields.io/badge/version-3.0.5-brightgreen.svg) +![standard](https://img.shields.io/badge/standard-c99-brightgreen.svg) +![build](https://img.shields.io/badge/build-2020.08.23-brightgreen.svg) +![license](https://img.shields.io/badge/license-MIT-brightgreen.svg) + +一个功能强大的嵌入式 shell + +![shell_info.png](doc/img/shell_info.png) + +- [letter shell 3.0](#letter-shell-30) + - [简介](#简介) + - [功能](#功能) + - [移植说明](#移植说明) + - [使用方式](#使用方式) + - [函数定义](#函数定义) + - [main 函数形式](#main函数形式) + - [普通 C 函数形式](#普通c函数形式) + - [变量使用](#变量使用) + - [在函数中获取当前 shell 对象](#在函数中获取当前shell对象) + - [执行未导出函数](#执行未导出函数) + - [命令定义](#命令定义) + - [定义方式](#定义方式) + - [定义宏说明](#定义宏说明) + - [命令属性字段说明](#命令属性字段说明) + - [代理函数和代理参数解析](#代理函数和代理参数解析) + - [权限系统说明](#权限系统说明) + - [伴生对象](#伴生对象) + - [尾行模式](#尾行模式) + - [建议终端软件](#建议终端软件) + - [命令遍历工具](#命令遍历工具) + +## 简介 + +[letter shell 3.0](https://github.com/NevermindZZT/letter-shell/tree/shell3.0)是一个 C 语言编写的,可以嵌入在程序中的嵌入式 shell,主要面向嵌入式设备,以 C 语言函数为运行单位,可以通过命令行调用,运行程序中的函数 + +相对 2.x 版本,letter shell 3.0 增加了用户管理,权限管理,后续会增加对文件系统的支持 + +此外 3.0 版本修改了命令格式和定义,2.x 版本的工程需要经过简单的修改才能完成迁移 + +若只需要使用基础功能,可以使用[letter shell 2.x](https://github.com/NevermindZZT/letter-shell/tree/shell2.x)版本 + +使用说明可参考[Letter shell 3.0 全新出发](https://nevermindzzt.github.io/2020/01/19/Letter%20shell%203.0%E5%85%A8%E6%96%B0%E5%87%BA%E5%8F%91/) + +## 功能 + +- 命令自动补全 +- 快捷键功能定义 +- 命令权限管理 +- 用户管理 +- 变量支持 +- 代理函数和参数代理解析 + +## 移植说明 + +1. 定义 shell 对象 + + ```C + Shell shell; + ``` + +2. 定义 shell 读,写函数,函数原型如下 + + ```C + /** + * @brief shell读取数据函数原型 + * + * @param char shell读取的字符 + * + * @return char 0 读取数据成功 + * @return char -1 读取数据失败 + */ + typedef signed char (*shellRead)(char *); + + /** + * @brief shell写数据函数原型 + * + * @param const char 需写的字符 + */ + typedef void (*shellWrite)(const char); + ``` + +3. 申请一片缓冲区 + + ```C + char shellBuffer[512]; + ``` + +4. 调用 shellInit 进行初始化 + + ```C + shell.read = shellRead; + shell.write = shellWrite; + shellInit(&shell, shellBuffer, 512); + ``` + +5. 调用(建立)shell 任务 + + 对于运行在操作系统的情况,建立`shellTask`任务(确保 sell_cfg.h 中的配置无误),任务参数为 shell 对象 + + ```C + OsTaskCreate(shellTask, &shell, ...); + ``` + + 对于裸机环境,在主循环中调用`shellTask`,或者在接收到数据时,调用`shellHandler` + +6. 说明 + + - 对于中断方式使用 shell,不用定义`shell->read`,但需要在中断中调用`shellHandler` + - 对于使用操作系统的情况,使能`SHEHLL_TASK_WHILE`宏,然后创建 shellTask 任务 + +7. 其他配置 + + - 定义宏`SHELL_GET_TICK()`为获取系统 tick 函数,使能 tab 双击操作,用户长帮助补全 + +8. 配置宏 + + shell_cfg.h 文件中包含了所有用于配置 shell 的宏,在使用前,需要根据需要进行配置 + + | 宏 | 意义 | + | --------------------------- | ---------------------------------- | + | SHELL_TASK_WHILE | 是否使用默认 shell 任务 while 循环 | + | SHELL_USING_CMD_EXPORT | 是否使用命令导出方式 | + | SHELL_USING_COMPANION | 是否使用 shell 伴生对象功能 | + | SHELL_SUPPORT_END_LINE | 是否支持 shell 尾行模式 | + | SHELL_HELP_LIST_USER | 是否在输入命令列表中列出用户 | + | SHELL_HELP_LIST_VAR | 是否在输入命令列表中列出变量 | + | SHELL_HELP_LIST_KEY | 是否在输入命令列表中列出按键 | + | SHELL_ENTER_LF | 使用 LF 作为命令行回车触发 | + | SHELL_ENTER_CR | 使用 CR 作为命令行回车触发 | + | SHELL_ENTER_CRLF | 使用 CRLF 作为命令行回车触发 | + | SHELL_EXEC_UNDEF_FUNC | 使用执行未导出函数的功能 | + | SHELL_COMMAND_MAX_LENGTH | shell 命令最大长度 | + | SHELL_PARAMETER_MAX_NUMBER | shell 命令参数最大数量 | + | SHELL_HISTORY_MAX_NUMBER | 历史命令记录数量 | + | SHELL_DOUBLE_CLICK_TIME | 双击间隔(ms) | + | SHELL_MAX_NUMBER | 管理的最大 shell 数量 | + | SHELL_GET_TICK() | 获取系统时间(ms) | + | SHELL_MALLOC(size) | 内存分配函数(shell 本身不需要) | + | SHELL_FREE(obj) | 内存释放函数(shell 本身不需要) | + | SHELL_SHOW_INFO | 是否显示 shell 信息 | + | SHELL_CLS_WHEN_LOGIN | 是否在登录后清除命令行 | + | SHELL_DEFAULT_USER | shell 默认用户 | + | SHELL_DEFAULT_USER_PASSWORD | 默认用户密码 | + | SHELL_LOCK_TIMEOUT | shell 自动锁定超时 | + +## 使用方式 + +### 函数定义 + +letter shell 3.0 同时支持两种形式的函数定义方式,形如 main 函数定义的`func(int argc, char *agrv[])`以及形如普通 C 函数的定义`func(int i, char *str, ...)`,两种函数定义方式适用于不同的场景 + +#### main 函数形式 + +使用此方式,一个函数定义的例子如下: + +```C +int func(int argc, char *agrv[]) +{ + printf("%dparameter(s)\r\n", argc); + for (char i = 1; i < argc; i++) + { + printf("%s\r\n", argv[i]); + } +} +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), func, func, test); +``` + +终端调用 + +```sh +letter:/$ func "hello world" +2 parameter(s) +hello world +``` + +#### 普通 C 函数形式 + +使用此方式,shell 会自动对参数进行转化处理,目前支持二进制,八进制,十进制,十六进制整形,字符,字符串的自动处理,如果需要其他类型的参数,请使用代理参数解析的方式(参考[代理函数和代理参数解析](#代理函数和代理参数解析)),或者使用字符串的方式作为参数,自行进行处理,例子如下: + +```C +int func(int i, char ch, char *str) +{ + printf("input int: %d, char: %c, string: %s\r\n", i, ch, str); +} +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), func, func, test); +``` + +终端调用 + +```sh +letter:/$ func 666 'A' "hello world" +input int: 666, char: A, string: hello world +``` + +### 变量使用 + +letter shell 3.0 支持导出变量,通过命令行查看,设置以及使用变量的值 + +- 导出变量 + + 变量导出使用`SHELL_EXPORT_VAR`宏,支持整形(char, short, int),字符串,指针以及节点变量,变量导出需要使用引用的方式,如果不允许对变量进行修改,在属性中添加`SHELL_CMD_READ_ONLY` + + ```C + int varInt = 0; + SHELL_EXPORT_VAR(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_VAR_INT), varInt, &varInt, test); + + char str[] = "test string"; + SHELL_EXPORT_VAR(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_VAR_STRING), varStr, str, test); + + Log log; + SHELL_EXPORT_VAR(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_VAR_POINT), log, &log, test); + ``` + +- 查看变量 + + 在命令行直接输入导出的变量名即可查看变量当前的值 + + ```sh + letter:/$ varInt + varInt = 0, 0x00000000 + + letter:/$ varStr + varStr = "test string" + ``` + +- 修改变量 + + 使用`setVar`命令修改变量的值,对于字符串型变量,请确认字符串有分配足够的空间,指针类型的变量不可修改 + + ```sh + letter:/$ setVar varInt 45678 + varInt = 45678, 0x0000b26e + + letter:/$ setVar varStr "hello" + varStr = "hello" + ``` + +- 使用变量 + + letter shell 3.0 的变量可以在命令中作为参数传递,对于需要传递结构体引用到命令中的场景特别适用,使用`$`+变量名的方式传递 + + ```sh + letter:/$ shellPrint $shell "hello world\r\n" + hello world + ``` + +### 在函数中获取当前 shell 对象 + +letter shell 采取一个静态数组对定义的多个 shell 进行管理,shell 数量可以修改宏`SHELL_MAX_NUMBER`定义(为了不使用动态内存分配,此处通过数据进行管理),从而,在 shell 执行的函数中,可以调用`shellGetCurrent()`获得当前活动的 shell 对象,从而可以实现某一个函数在不同的 shell 对象中发生不同的行为,也可以通过这种方式获得 shell 对象后,调用`shellWriteString(shell, string)`进行 shell 的输出 + +### 执行未导出函数 + +letter shell 支持通过函数地址直接执行函数,可以方便执行那些没有导出,但是有临时需要使用的函数,使用命令`exec [addr] [args]`执行,使用此功能需要开启`SHELL_EXEC_UNDEF_FUNC`宏,注意,由于直接操作函数地址执行,如果给进的地址有误,可能引起程序崩溃 + +函数的地址可以通过编译生成的文件查找,比如说对于 keil,可以在`.map`文件中查找到每个函数的地址,对于 keil,`.map`文件中的地址需要偏移一个字节,才可以成功执行,比如说`shellClear`函数地址为`0x08028620`,则通过`exec`执行应为`exec 0x08028621` + +其他编译器查找函数地址的方式和地址偏移的处理,请参考各编译器手册 + +## 命令定义 + +letter shell 3.0 将可执行的函数命令定义,用户定义,按键定义以及变量定义统一归为命令定义,使用相同的结构储存,查找和执行 + +### 定义方式 + +letter shell 支持使用命令导出方式和命令表方式进行命令的添加,定义,通过宏`SHELL_USING_CMD_EXPORT`控制 + +命令导出方式支持 keil,IAR(未测试)以及 GCC + +1. 命令导出方式 + + letter shell 支持在函数体外部,采用定义常量的方式定义命令,例如`SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE (SHELL_TYPE_CMD_MAIN)|SHELL_CMD_DISABLE_RETURN,help, shellHelp, show command info\r\nhelp [cmd]);` + + 对于使用 keil 进行编译,需要在 keil 的 target option 中增加--keep shellCommand\*,防止定义的命令被优化掉 + + 使用 GCC 编译时,需要在 ld 文件中的只读数据区(建议)添加: + + ```ld + _shell_command_start = .; + KEEP (*(shellCommand)) + _shell_command_end = .; + ``` + +2. 命令表方式 + + - 当使用其他暂时不支持使用命令导出方式的编译器时,需要在`shell_cmd_list.c`文件的命令表中添加 + + ```C + const SHELL_CommandTypeDef shellDefaultCommandList[] = + { + SHELL_CMD_ITEM( + SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_DISABLE_RETURN, + help, shellHelp, show command info\r\nhelp [cmd]), + }; + ``` + +### 定义宏说明 + +letter shell 3.0 对可执行命令,按键,用户以及变量分别提供了一个宏,用于进行命令定义 + +1. 可执行命令定义 + + 使用宏`SHELL_EXPORT_CMD`定义可执行命令,定义如下 + + ```C + /** + * @brief shell 命令定义 + * + * @param _attr 命令属性 + * @param _name 命令名 + * @param _func 命令函数 + * @param _desc 命令描述 + */ + #define SHELL_EXPORT_CMD(_attr, _name, _func, _desc) \ + const char shellCmd##_name[] = #_name; \ + const char shellDesc##_name[] = #_desc; \ + const ShellCommand \ + shellCommand##_name SECTION("shellCommand") = \ + { \ + .attr.value = _attr, \ + .data.cmd.name = shellCmd##_name, \ + .data.cmd.function = (int (*)())_func, \ + .data.cmd.desc = shellDesc##_name \ + } + ``` + +2. 变量定义 + + 使用宏`SHELL_EXPORT_VAR`定义变量,定义如下 + + ```C + /** + * @brief shell 变量定义 + * + * @param _attr 变量属性 + * @param _name 变量名 + * @param _value 变量值 + * @param _desc 变量描述 + */ + #define SHELL_EXPORT_VAR(_attr, _name, _value, _desc) \ + const char shellCmd##_name[] = #_name; \ + const char shellDesc##_name[] = #_desc; \ + const ShellCommand \ + shellVar##_name SECTION("shellCommand") = \ + { \ + .attr.value = _attr, \ + .data.var.name = shellCmd##_name, \ + .data.var.value = (void *)_value, \ + .data.var.desc = shellDesc##_name \ + } + ``` + + 变量定义时,`_value`应该是变量的引用,如果变量不允许修改,则需要在增加`SHELL_CMD_READ_ONLY`属性 + +3. 用户定义 + + 使用宏`SHELL_EXPORT_USER`定义用户,定义如下 + + ```C + /** + * @brief shell 用户定义 + * + * @param _attr 用户属性 + * @param _name 用户名 + * @param _password 用户密码 + * @param _desc 用户描述 + */ + #define SHELL_EXPORT_USER(_attr, _name, _password, _desc) \ + const char shellCmd##_name[] = #_name; \ + const char shellPassword##_name[] = #_password; \ + const char shellDesc##_name[] = #_desc; \ + const ShellCommand \ + shellUser##_name SECTION("shellCommand") = \ + { \ + .attr.value = _attr|SHELL_CMD_TYPE(SHELL_TYPE_USER), \ + .data.user.name = shellCmd##_name, \ + .data.user.password = shellPassword##_name, \ + .data.user.desc = shellDesc##_name \ + } + ``` + +4. 按键定义 + + 使用宏`SHELL_EXPORT_KEY`定义按键,定义如下 + + ```C + /** + * @brief shell 按键定义 + * + * @param _attr 按键属性 + * @param _value 按键键值 + * @param _func 按键函数 + * @param _desc 按键描述 + */ + #define SHELL_EXPORT_KEY(_attr, _value, _func, _desc) \ + const char shellDesc##_value[] = #_desc; \ + const ShellCommand \ + shellKey##_value SECTION("shellCommand") = \ + { \ + .attr.value = _attr|SHELL_CMD_TYPE(SHELL_TYPE_KEY), \ + .data.key.value = _value, \ + .data.key.function = (void (*)(Shell *))_func, \ + .data.key.desc = shellDesc##_value \ + } + ``` + + 按键键值为在终端输入按键会发送的字符串序列,以大端模式表示,比如在 SecureCRT 中断,按下 Tab 键,会发送 0x0B,则这个按键的键值为 0x0B000000,如果按下方向上,会依次发送 0x1B, 0x5B, 0x41, 则这个键的键值为 0x1B5B4100 + +### 命令属性字段说明 + +在命令定义中,有一个`attr`字段,表示该命令的属性,具体定义为 + +```C +union +{ + struct + { + unsigned char permission : 8; /**< command权限 */ + ShellCommandType type : 4; /**< command类型 */ + unsigned char enableUnchecked : 1; /**< 在未校验密码的情况下可用 */ + unsigned char readOnly : 1; /**< 只读 */ + unsigned char reserve : 1; /**< 保留 */ + unsigned char paramNum : 4; /**< 参数数量 */ + } attrs; + int value; +} attr; +``` + +在定义命令时,需要给定这些值,可以通过宏`SHELL_CMD_PERMISSION(permission)`, `SHELL_CMD_TYPE(type)`, `SHELL_CMD_ENABLE_UNCHECKED`, `SHELL_CMD_DISABLE_RETURN`, `SHELL_CMD_READ_ONLY`, `SHELL_CMD_PARAM_NUM(num)`快速声明 + +## 代理函数和代理参数解析 + +letter shell 3.0 原生支持将整数,字符,字符串参数,以及在某些情况下的浮点参数直接传递给执行命令的函数,一般情况下,这几种参数类型完全可以满足调试需要,然而在某些情况下,用户确实需要传递其他类型的参数,此时,可以选择将命令定义成 main 函数形式,使用字符串传递参数,然后自行对参数进行解析,除此之外,letter shell 还提供了代理函数的机制,可以对任意类型的参数进行自定义解析 + +关于代理函数的实现原理和具体使用示例,可以参考[letter-shell 代理函数解析](https://nevermindzzt.github.io/2020/04/17/letter-shell%E4%BB%A3%E7%90%86%E5%87%BD%E6%95%B0%E8%A7%A3%E6%9E%90/) + +使用代理函数,用户需要自定义代理参数解析器,即一个将基本参数(整数,字符,字符串参数)转换成目标类型参数的函数或者宏,letter shell 默认实现了浮点类型的参数解析器`SHELL_PARAM_FLOAT(x)` + +然后,使用代理函数命令导出宏定义命令,比如需要需要传递多个浮点参数的函数,如下 + +```C +void test(int a, float b, int c, float d) +{ + printf("%d, %f, %d, %f \r\n", a, b, c, d); +} +SHELL_EXPORT_CMD_AGENCY(SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), +test, test, test, +p1, SHELL_PARAM_FLOAT(p2), p3, SHELL_PARAM_FLOAT(p4)); +``` + +相比常规的命令导出,代理函数命令导出前 4 个参数和常规形式的命令导出一致,之后的参数即传递至目标函数的参数,letter shell 默认实现的代理函数定义支持最多 7 个参数,p1~p7,对于不需要代理参数解析的参数,只需要对应写入`px(x为1~7)`即可,比如上方示例的`p1`和`p3`,而需要代理参数解析的参数,则需要使用对应的参数解析器,比如上方示例的`p2`和`p4` + +## 权限系统说明 + +letter shell 3.0 的权限管理同用户定义紧密相关,letter shell 3.0 使用 8 个 bit 位表示命令权限,当用户和命令的权限按位与为真,或者命令权限为 0 时,表示该用户拥有此命令的权限,可以调用改命令 + +## 伴生对象 + +letter shell 3.0.3 版本引入了伴生对象的概念,通过宏`SHELL_USING_COMPANION`开启或者关闭,若使用伴生对象的功能,需要同时将 shell_companion.c 文件加入到工程中,伴生对象可以用于需要将某个对象同 shell 关联的场景,比如说,通过快捷键控制 shell 终端对应的日志打印对象 + +一般情况下,使用`shellCompanionAdd`将伴生对象同 shell 对象进行关联,之后,可以在 shell 操作中,通过`shellCompanionGet`获取相应的伴生对象,以达到在不同的 shell 中,操作不同对象的目的 + +## 尾行模式 + +letter shell 3.0.4 版本新增了尾行模式,适用于需要在 shell 所使用的交互终端同时输入其他信息(比如说日志)时,防止其他信息的输出,导致 shell 交互体验极差的情况,使用时,使能宏`SHELL_SUPPORT_END_LINE`,然后对于其他需要使用终端输入信息的地方,调用`shellWriteEndLine`接口将信息输入,此时,调用`shellWriteEndLine`进行输入的内容将会插入到命令行上方,终端会一直保持 shell 命令行位于最后一行 + +使用 letter shell 尾行模式结合[log](./extensions/log/readme.md)日志输出的效果如下: + +![end lin mode](doc/img/shell_end_line_mode.gif) + +## 建议终端软件 + +- 对于基于串口移植,letter shell 建议使用 secureCRT 软件,letter shell 中的相关按键映射都是按照 secureCRT 进行设计的,使用其他串口软件时,可能需要修改键值 + +## 命令遍历工具 + +letter shell 3.0 提供了一个用于遍历工程中命令导出的工具,位于 tools/shellTools.py,需要 python3 环境运行,可以列出工程中,所有使用`SHELL_EXPORT_XXX`导出的命令名,以及位置,结合 VS Code 可以直接进行跳转 + +```sh +python shellTools.py project +``` + +注意:shellTools 会遍历指定目录中所有文件,所以当工程中文件较多时,速度会比较慢,建议只用于遍历用户模块的目录 diff --git a/third-party/letter-shell-3.1/extensions/fs_support/readme.md b/third-party/letter-shell-3.1/extensions/fs_support/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..9ceacc6011de4f226fe8043204318b8b8958e667 --- /dev/null +++ b/third-party/letter-shell-3.1/extensions/fs_support/readme.md @@ -0,0 +1,52 @@ +# letter shell file system support + +![version](https://img.shields.io/badge/version-1.0.0-brightgreen.svg) +![standard](https://img.shields.io/badge/standard-c99-brightgreen.svg) +![build](https://img.shields.io/badge/build-2020.08.16-brightgreen.svg) +![license](https://img.shields.io/badge/license-MIT-brightgreen.svg) + +letter shell文件系统支持 + +![preview](../../doc/img/fs_support_preview.gif) + +- [letter shell file system support](#letter-shell-file-system-support) + - [简介](#简介) + - [使用](#使用) + +## 简介 + +fs_support作为letter shell的插件,用于实现letter shell对常见文件系统操作的支持,比如说cd,ls等命令,fs_support依赖于letter shell的伴生对象功能,并且使用到了内存分配和内存释放,所以请确认已经配置好了letter shell + +fs_support并非一个完全实现的letter shell插件,由于文件系统的接口和操作系统以及具体使用的文件系统相关,所以fs_support仅仅通过接入几个基本的接口以实现`cd`,`ls`命令,具体使用时,可能需要根据使用的文件系统接口修改fs_support,letter shell的[demo/x86-gcc](demo/x86-gcc)下有针对linux平台的移植,可以及进行参考 + +## 使用 + +1. 声明`ShellFs`对象并申请当前路径数据缓冲区 + + ```c + ShellFs shellFs; + char shellPathBuffer[512] = "/"; + ``` + +2. 实现`getcwd`,`chdir`,`listdir`函数 + + 根据文件系统不同,这些函数会有不同的实现,请根据具体使用的环境进行修改 + +3. 初始化`ShellFs`对象 + + ```c + shellFs.getcwd = getcwd; + shellFs.chdir = chdir; + shellFs.listdir = userShellListDir; + shellFsInit(&shellFs, shellPathBuffer, 512); + ``` + +4. 初始化`Shell`对象 + + 设置shell当前路径缓冲,初始化shell,并添加伴生对象 + + ```C + shellSetPath(&shell, shellPathBuffer); + shellInit(&shell, shellBuffer, 512); + shellCompanionAdd(&shell, SHELL_COMPANION_ID_FS, &shellFs); + ``` diff --git a/third-party/letter-shell-3.1/extensions/fs_support/shell_fs.c b/third-party/letter-shell-3.1/extensions/fs_support/shell_fs.c new file mode 100644 index 0000000000000000000000000000000000000000..432cc95f8ad4bfa3f03ff93a5755fb02ef2a9a5e --- /dev/null +++ b/third-party/letter-shell-3.1/extensions/fs_support/shell_fs.c @@ -0,0 +1,74 @@ +/** + * @file shell_fs.c + * @author Letter (nevermindzzt@gmail.com) + * @brief shell file system support + * @version 0.1 + * @date 2020-07-22 + * + * @copyright (c) 2020 Letter + * + */ +#include "shell_fs.h" +#include "shell.h" +#include "stdio.h" + +/** + * @brief 改变当前路径(shell调用) + * + * @param dir 路径 + */ +void shellCD(char *dir) +{ + Shell *shell = shellGetCurrent(); + ShellFs *shellFs = shellCompanionGet(shell, SHELL_COMPANION_ID_FS); + SHELL_ASSERT(shellFs, return); + if (shellFs->chdir(dir) != 0) + { + shellWriteString(shell, "error: "); + shellWriteString(shell, dir); + shellWriteString(shell, " is not a directory\r\n"); + } + shellFs->getcwd(shellFs->info.path, shellFs->info.pathLen); +} +SHELL_EXPORT_CMD( +SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_DISABLE_RETURN, +cd, shellCD, change dir); + +/** + * @brief 列出文件(shell调用) + * + */ +void shellLS(void) +{ + size_t count; + char *buffer; + + Shell *shell = shellGetCurrent(); + ShellFs *shellFs = shellCompanionGet(shell, SHELL_COMPANION_ID_FS); + SHELL_ASSERT(shellFs, return); + + buffer = SHELL_MALLOC(SHELL_FS_LIST_FILE_BUFFER_MAX); + SHELL_ASSERT(buffer, return); + count = shellFs->listdir(shellGetPath(shell), buffer, SHELL_FS_LIST_FILE_BUFFER_MAX); + + shellWriteString(shell, buffer); + + SHELL_FREE(buffer); +} +SHELL_EXPORT_CMD( +SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_DISABLE_RETURN, +ls, shellLS, list all files); + +/** + * @brief 初始化shell文件系统支持 + * + * @param shellFs shell文件系统对象 + * @param pathBuffer shell路径缓冲 + * @param pathLen 路径缓冲区大小 + */ +void shellFsInit(ShellFs *shellFs, char *pathBuffer, size_t pathLen) +{ + shellFs->info.path = pathBuffer; + shellFs->info.pathLen = pathLen; + shellFs->getcwd(shellFs->info.path, pathLen); +} diff --git a/third-party/letter-shell-3.1/extensions/fs_support/shell_fs.h b/third-party/letter-shell-3.1/extensions/fs_support/shell_fs.h new file mode 100644 index 0000000000000000000000000000000000000000..522f50ecae4c3ec7be7fc047c6229212ec2c3554 --- /dev/null +++ b/third-party/letter-shell-3.1/extensions/fs_support/shell_fs.h @@ -0,0 +1,41 @@ +/** + * @file shell_fs.h + * @author Letter (nevermindzzt@gmail.com) + * @brief shell file system support + * @version 0.1 + * @date 2020-07-22 + * + * @copyright (c) 2020 Letter + * + */ +#ifndef __SHELL_FS_H__ +#define __SHELL_FS_H__ + +#include "stddef.h" +#include "shell.h" + +#define SHELL_FS_VERSION "1.0.0" + +#define SHELL_COMPANION_ID_FS -1 + +#define SHELL_FS_LIST_FILE_BUFFER_MAX 4096 + +/** + * @brief shell文件系统支持结构体 + * + */ +typedef struct shell_fs +{ + size_t (*getcwd)(char *, size_t); + size_t (*chdir)(char *); + size_t (*listdir)(char *dir, char *buffer, size_t maxLen); + + struct { + char *path; + size_t pathLen; + } info; +} ShellFs; + +void shellFsInit(ShellFs *shellFs, char *pathBuffer, size_t pathLen); + +#endif diff --git a/third-party/letter-shell-3.1/extensions/log/log.c b/third-party/letter-shell-3.1/extensions/log/log.c new file mode 100644 index 0000000000000000000000000000000000000000..1b738ad47f82fc9d7e6f30b1f1de0fbda02a9a19 --- /dev/null +++ b/third-party/letter-shell-3.1/extensions/log/log.c @@ -0,0 +1,215 @@ +/** + * @file log.c + * @author Letter (nevermindzzt@gmail.com) + * @brief log + * @version 1.0.0 + * @date 2020-07-30 + * + * @copyright (c) 2020 Letter + * + */ +#include "log.h" +#include "stdio.h" +#include "stdarg.h" +#include "shell.h" + +#if LOG_USING_COLOR == 1 +#define memPrintHead \ + CSI(31) \ + " Offset: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F" CSI(39) +#define memPrintAddr CSI(31) \ +"0x%08x: " CSI(39) +#else +#define memPrintHead " Offset: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F" +#define memPrintAddr "0x%08x: " +#endif + +Log *logList[LOG_MAX_NUMBER] = {0}; +static char logBuffer[LOG_BUFFER_SIZE]; + +/** + * @brief 注册log对象 + * + * @param log log对象 + */ +void logRegister(Log *log, Shell *shell) +{ +#if SHELL_USING_COMPANION == 1 + if (shell) + { + log->shell = shell; + shellCompanionAdd(shell, SHELL_COMPANION_ID_LOG, log); + } +#endif + for (short i = 0; i < LOG_MAX_NUMBER; i++) + { + if (logList[i] == 0) + { + logList[i] = log; + return; + } + } +} + +/** + * @brief 注销log对象 + * + * @param log log对象 + */ +void logUnRegister(Log *log) +{ + for (short i = 0; i < LOG_MAX_NUMBER; i++) + { + if (logList[i] == log) + { + logList[i] = 0; + return; + } + } +} + +/** + * @brief 设置log日志级别 + * + * @param log log对象 + * @param level 日志级别 + */ +void logSetLevel(Log *log, LogLevel level) +{ + logAssert(log, return ); + log->level = level; +} +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), + logSetLevel, logSetLevel, set log level); + +/** + * @brief log写buffer + * + * @param log log对象 + * @param level 日志级别 + * @param buffer buffer + * @param len buffer长度 + */ +void logWriteBuffer(Log *log, LogLevel level, char *buffer, short len) +{ + if (log == LOG_ALL_OBJ) + { + for (short i = 0; i < LOG_MAX_NUMBER; i++) + { + if (logList[i] && logList[i]->active && logList[i]->level >= level) + { + logList[i]->write(logBuffer, len); + } + } + } + else if (log && log->active && log->level >= level) + { + log->write(logBuffer, len); + } +} + +/** + * @brief log格式化写入数据 + * + * @param log log对象 + * @param level log级别 + * @param fmt 格式 + * @param ... 参数 + */ +void logWrite(Log *log, LogLevel level, char *fmt, ...) +{ + va_list vargs; + short len; + + va_start(vargs, fmt); + len = vsnprintf(logBuffer, LOG_BUFFER_SIZE - 1, fmt, vargs); + va_end(vargs); + + logWriteBuffer(log, level, logBuffer, len); +} + +/** + * @brief 16进制输出 + * + * @param log log对象 + * @param base 内存基址 + * @param length 长度 + */ +void logHexDump(Log *log, void *base, unsigned int length) +{ + unsigned char *address; + unsigned int len = length; + unsigned int printLen = 0; + + if (length == 0) + { + return; + } + + logWrite(log, LOG_NONE, "memory of 0x%08x, size: %d:\r\n", (unsigned int)base, length); + + address = (unsigned char *)((unsigned int)base & (~0x0000000F)); + length += (unsigned int)base - (unsigned int)address; + length = (length + 15) & (~0x0000000F); + + logWrite(log, LOG_NONE, memPrintHead "\r\n"); + + while (length) + { + printLen += sprintf(logBuffer + printLen, memPrintAddr, (unsigned int)address); + for (int i = 0; i < 16; i++) + { + if ((unsigned int)(address + i) < (unsigned int)base || (unsigned int)(address + i) >= (unsigned int)base + len) + { + logBuffer[printLen++] = ' '; + logBuffer[printLen++] = ' '; + logBuffer[printLen++] = ' '; + } + else + { + printLen += sprintf(logBuffer + printLen, "%02x ", *(address + i)); + } + } + logBuffer[printLen++] = '|'; + logBuffer[printLen++] = ' '; + for (int i = 0; i < 16; i++) + { + if ((unsigned int)(address + i) < (unsigned int)base || (unsigned int)(address + i) >= (unsigned int)base + len) + { + logBuffer[printLen++] = ' '; + } + else + { + if (*(address + i) >= 32 && *(address + i) <= 126) + { + printLen += sprintf(logBuffer + printLen, "%c", *(address + i)); + } + else + { + logBuffer[printLen++] = '.'; + } + } + } + logBuffer[printLen++] = '|'; + logBuffer[printLen++] = '\r'; + logBuffer[printLen++] = '\n'; + logWriteBuffer(log, LOG_NONE, logBuffer, printLen); + address += 16; + length -= 16; + printLen = 0; + } +} +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), + hexdump, logHexDump, hex dump\r\n hexdump[log][base][len]); + +#if SHELL_USING_COMPANION == 1 +void logSwitchLevel(Shell *shell) +{ + Log *log = shellCompanionGet(shell, SHELL_COMPANION_ID_LOG); + SHELL_ASSERT(log, return ); + log->level = (LogLevel)(log->level >= LOG_ALL ? LOG_NONE : (log->level + 1)); + logPrintln("set log level: %d", log->level); +} +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0), 0x04000000, logSwitchLevel, switch log level); + +#endif /** SHELL_USING_COMPANION == 1 */ diff --git a/third-party/letter-shell-3.1/extensions/log/log.h b/third-party/letter-shell-3.1/extensions/log/log.h new file mode 100644 index 0000000000000000000000000000000000000000..817fd6d93b60f0e631f4e7f5a757ac2ffb014f0d --- /dev/null +++ b/third-party/letter-shell-3.1/extensions/log/log.h @@ -0,0 +1,191 @@ +/** + * @file log.h + * @author Letter (nevermindzzt@gmail.com) + * @brief log + * @version 1.0.0 + * @date 2020-07-30 + * + * @copyright (c) 2020 Letter + * + */ +#ifndef __LOG_H__ +#define __LOG_H__ + +#include "shell.h" + +#define LOG_VERSION "1.0.0" + +#define SHELL_COMPANION_ID_LOG -2 + +#define LOG_BUFFER_SIZE 256 /**< log输出缓冲大小 */ +#define LOG_USING_COLOR 1 /**< 是否使用颜色 */ +#define LOG_MAX_NUMBER 5 /**< 允许注册的最大log对象数量 */ +#define LOG_AUTO_TAG 1 /**< 是否自动添加TAG */ +#define LOG_END "\r\n" /**< log信息结尾 */ +#define LOG_TAG __FUNCTION__ /**< 自定添加的TAG */ +#define LOG_TIME_STAMP 0 /**< 设置获取系统时间戳 */ + +#ifndef LOG_ENABLE + #define LOG_ENABLE 1 /**< 使能log */ +#endif + +#define LOG_ALL_OBJ ((Log *)-1) /**< 所有已注册的log对象 */ + +/** + * 终端字体颜色代码 + */ +#define CSI_BLACK 30 /**< 黑色 */ +#define CSI_RED 31 /**< 红色 */ +#define CSI_GREEN 32 /**< 绿色 */ +#define CSI_YELLOW 33 /**< 黄色 */ +#define CSI_BLUE 34 /**< 蓝色 */ +#define CSI_FUCHSIN 35 /**< 品红 */ +#define CSI_CYAN 36 /**< 青色 */ +#define CSI_WHITE 37 /**< 白色 */ +#define CSI_BLACK_L 90 /**< 亮黑 */ +#define CSI_RED_L 91 /**< 亮红 */ +#define CSI_GREEN_L 92 /**< 亮绿 */ +#define CSI_YELLOW_L 93 /**< 亮黄 */ +#define CSI_BLUE_L 94 /**< 亮蓝 */ +#define CSI_FUCHSIN_L 95 /**< 亮品红 */ +#define CSI_CYAN_L 96 /**< 亮青 */ +#define CSI_WHITE_L 97 /**< 亮白 */ +#define CSI_DEFAULT 39 /**< 默认 */ + +#define CSI(code) "\033["#code"m" /**< ANSI CSI指令 */ + +/** + * log级别字符(包含颜色) + */ +#if LOG_USING_COLOR == 1 +#define ERROR_TEXT CSI(31)"E(%d) %s:"CSI(39) /**< 错误标签 */ +#define WARNING_TEXT CSI(33)"W(%d) %s:"CSI(39) /**< 警告标签 */ +#define INFO_TEXT CSI(32)"I(%d) %s:"CSI(39) /**< 信息标签 */ +#define DEBUG_TEXT CSI(34)"D(%d) %s:"CSI(39) /**< 调试标签 */ +#define VERBOSE_TEXT CSI(36)"V(%d) %s:"CSI(39) /**< 冗余信息标签 */ +#else +#define ERROR_TEXT "E(%d) %s:" +#define WARNING_TEXT "W(%d) %s:" +#define INFO_TEXT "I(%d) %s:" +#define DEBUG_TEXT "D(%d) %s:" +#define VERBOSE_TEXT "V(%d) %s:" +#endif + + +/** + * @brief 日志级别定义 + * + */ +typedef enum +{ + LOG_NONE = 0, /**< 无级别 */ + LOG_ERROR = 1, /**< 错误 */ + LOG_WRANING = 2, /**< 警告 */ + LOG_INFO = 3, /**< 消息 */ + LOG_DEBUG = 4, /**< 调试 */ + LOG_VERBOSE = 5, /**< 冗余 */ + LOG_ALL = 6, /**< 所有日志 */ +} LogLevel; + + +/** + * @brief log对象定义 + * + */ +typedef struct +{ + void (*write)(char *, short); /**< 写buffer */ + char active; /**< 是否激活 */ + LogLevel level; /**< 日志级别 */ + Shell *shell; /**< 关联shell对象 */ +} Log; + + + +/** + * @brief log打印(自动换行) + * + * @param fmt 格式 + * @param ... 参数 + */ +#define logPrintln(format, ...) \ + logWrite(LOG_ALL_OBJ, LOG_NONE, format"\r\n", ##__VA_ARGS__) + + +/** + * @brief 日志格式化输出 + * + * @param text 消息文本 + * @param level 日志级别 + * @param fmt 格式 + * @param ... 参数 + */ +#define logFormat(text, level, fmt, ...) \ + if (LOG_ENABLE) {\ + logWrite(LOG_ALL_OBJ, level, text" "fmt""LOG_END, \ + LOG_TIME_STAMP, LOG_TAG, ##__VA_ARGS__); } + +/** + * @brief 错误log输出 + * + * @param fmt 格式 + * @param ... 参数 + */ +#define logError(fmt, ...) \ + logFormat(ERROR_TEXT, LOG_ERROR, fmt, ##__VA_ARGS__) + +/** + * @brief 警告log输出 + * + * @param fmt 格式 + * @param ... 参数 + */ +#define logWarning(fmt, ...) \ + logFormat(WARNING_TEXT, LOG_WRANING, fmt, ##__VA_ARGS__) + +/** + * @brief 信息log输出 + * + * @param fmt 格式 + * @param ... 参数 + */ +#define logInfo(fmt, ...) \ + logFormat(INFO_TEXT, LOG_INFO, fmt, ##__VA_ARGS__) + +/** + * @brief 调试log输出 + * + * @param fmt 格式 + * @param ... 参数 + */ +#define logDebug(fmt, ...) \ + logFormat(DEBUG_TEXT, LOG_DEBUG, fmt, ##__VA_ARGS__) + +/** + * @brief 冗余log输出 + * + * @param fmt 格式 + * @param ... 参数 + */ +#define logVerbose(fmt, ...) \ + logFormat(VERBOSE_TEXT, LOG_VERBOSE, fmt, ##__VA_ARGS__) + +/** + * @brief 断言 + * + * @param expr 表达式 + * @param action 断言失败操作 + */ +#define logAssert(expr, action) \ + if (!(expr)) { \ + logError("\"" #expr "\" assert failed at file: %s, line: %d", __FILE__, __LINE__); \ + action; \ + } + +void logRegister(Log *log, Shell *shell); +void logUnRegister(Log *log); +void logSetLevel(Log *log, LogLevel level); +void logWrite(Log *log, LogLevel level, char *fmt, ...); +void logHexDump(Log *log, void *base, unsigned int length); + +#endif diff --git a/third-party/letter-shell-3.1/extensions/log/readme.md b/third-party/letter-shell-3.1/extensions/log/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..a3715aab7044310b4bbdcfe17f2a9302c5ed43ac --- /dev/null +++ b/third-party/letter-shell-3.1/extensions/log/readme.md @@ -0,0 +1,214 @@ +# log + +![version](https://img.shields.io/badge/version-1.0.0-brightgreen.svg) +![standard](https://img.shields.io/badge/standard-c99-brightgreen.svg) +![build](https://img.shields.io/badge/build-2020.08.02-brightgreen.svg) +![license](https://img.shields.io/badge/license-MIT-brightgreen.svg) + +嵌入式日志打印工具 + +![preview](../../doc/img/log_preview.png) + +- [log](#log) + - [简介](#简介) + - [使用](#使用) + - [配置](#配置) + - [API](#api) + - [logPrintln](#logprintln) + - [logError](#logerror) + - [logWarning](#logwarning) + - [logInfo](#loginfo) + - [logDebug](#logdebug) + - [logVerbose](#logverbose) + - [logAssert](#logassert) + - [logRegister](#logregister) + - [logSetLevel](#logsetlevel) + - [logHexDump](#loghexdump) + - [结合 letter shell 尾行模式](#结合letter-shell尾行模式) + - [其他用法](#其他用法) + - [单独控制某个文件日志](#单独控制某个文件日志) + +## 简介 + +log 是一个用于嵌入式系统的日志打印工具,可以为日志定义不同的级别,然后设置日志工具的打印级别,可以进行日志打印的控制 + +此外,log 通过 letter shell 的伴生对象功能,可以和 letter shell 结合,实现 log 和 shell 的绑定等功能 + +## 使用 + +1. 实现 log 写 buffer 函数 + + ```C + void uartLogWrite(char *buffer, short len) + { + serialTransmit(&debugSerial, (uint8_t *)buffer, len, 0x100); + } + ``` + +2. 定义 log 对象 + + ```C + Log uartLog = { + .write = uartLogWrite, + .active = true, + .level = LOG_DEBUG + }; + ``` + +3. 注册 log 对象 + + ```C + logRegister(&uartLog, NULL); + ``` + +## 配置 + +通过修改 log.h 文件中的宏,可以对 log 工具进行配置 + +| 宏 | 意义 | +| --------------- | --------------------------- | +| LOG_BUFFER_SIZE | log 输出缓冲大小 | +| LOG_USING_COLOR | 是否使用颜色 | +| LOG_MAX_NUMBER | 允许注册的最大 log 对象数量 | +| LOG_AUTO_TAG | 是否自动添加 TAG | +| LOG_END | log 信息结尾 | +| LOG_TAG | 自定添加的 TAG | +| LOG_TIME_STAMP | 设置获取系统时间戳 | + +## API + +以下是 log 工具部分 API 的说明 + +### logPrintln + +宏声明,用于一般的打印输出 + +```C +#define logPrintln(format, ...) +``` + +- 参数 + - `format` 输出格式 + - `...` 可变参数 + +### logError + +宏声明,错误日志级别输出 + +```C +#define logError(fmt, ...) +``` + +- 参数 + - `fmt` 输出格式 + - `...` 可变参数 + +### logWarning + +宏声明,警告日志级别输出,函数原型及参数说明参考`logError` + +### logInfo + +宏声明,信息日志级别输出,函数原型及参数说明参考`logError` + +### logDebug + +宏声明,调试日志级别输出,函数原型及参数说明参考`logError` + +### logVerbose + +宏声明,冗余日志级别输出,函数原型及参数说明参考`logError` + +### logAssert + +宏声明,断言 + +```C +#define logAssert(expr, action) +``` + +- 参数 + - `expr` 表达式 + - `action` 断言失败执行操作 + +### logRegister + +注册 log 对象 + +```C +void logRegister(Log *log, Shell *shell) +``` + +- 参数 + - `log` log 对象 + - `shell` 关联的 shell 对象 + +### logSetLevel + +设置日志级别 + +```C +void logSetLevel(Log *log, LogLevel level) +``` + +- 参数 + - `log` log 对象 + - `level` 日志级别 + +### logHexDump + +数据 16 进制打印 + +```C +void logHexDump(Log *log, void *base, unsigned int length) +``` + +- 参数 + - `log` log 对象 + - `base` 数据基址 + - `length` 数据长度 + +## 结合 letter shell 尾行模式 + +log 工具可以结合 letter shell 的尾行模式,实现 log 和 shell 共用一个终端,但不影响 shell 交互体验 + +1. 使用`shellWriteEndLine`事项 log 写 buffer 函数 + + ```C + void uartLogWrite(char *buffer, short len) + { + if (uartLog.shell) + { + shellWriteEndLine(uartLog.shell, buffer, len); + } + } + ``` + +2. 定义 log 对象 + + ```C + Log uartLog = { + .write = uartLogWrite, + .active = true, + .level = LOG_DEBUG + }; + ``` + +3. 注册 log 对象 + + ```C + logRegister(&uartLog, &shell); + ``` + +## 其他用法 + +### 单独控制某个文件日志 + +log 工具可以单独对某个文件的日志进行打印控制,使用时,在对应的.c 文件中加入 + +```C +#undef LOG_ENABLE +#define LOG_ENABLE 1 +``` + +即可单独控制某个文件的日志开关 diff --git a/third-party/letter-shell-3.1/port/cmd/cmd_bootelf.c b/third-party/letter-shell-3.1/port/cmd/cmd_bootelf.c new file mode 100644 index 0000000000000000000000000000000000000000..90ddf2c15ec244232f2b71bb275c2bd57e714d0d --- /dev/null +++ b/third-party/letter-shell-3.1/port/cmd/cmd_bootelf.c @@ -0,0 +1,109 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: cmd_bootelf.c + * Date: 2022-02-24 18:24:53 + * LastEditTime: 2022-03-21 17:03:44 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include +#include "../src/shell.h" +#include "strto.h" +#include "ft_elf.h" + +static unsigned long image_load_addr = 0x80100000; + +static void BootelfCmdUsage() +{ + printf("usage:\r\n"); + printf(" bootelf [-p|-s] [address] \r\n"); + printf(" load ELF image at [address] via program headers (-p)\r\n"); + printf(" or via section headers (-s)\r\n"); +} + +static int BootelfCmdEntry(int argc, char *argv[]) +{ + unsigned long addr; /* Address of the ELF image */ + unsigned long rc = 0; /* Return value from user code */ + unsigned long load_flg = 0; + char *sload = NULL; + + if(argc < 2) + { + BootelfCmdUsage(); + return -1; + } + + /* Consume 'bootelf' */ + argc--; argv++; + + /* Check for flag. */ + if (argc >= 1 && (argv[0][0] == '-' && (argv[0][1] == 'p' || argv[0][1] == 's'))) + { + sload = argv[0]; + /* Consume flag. */ + argc--; argv++; + } + + + if (argc >= 1 && (argv[0][0] == '-' && (argv[0][1] == 'l'))) + { + /* Consume flag. */ + argc--; argv++; + load_flg = 1; + } + + /* Check for address. */ + if (argc >= 1 && strict_strtoul(argv[0], 16, &addr) == 0) + { + /* Consume address */ + argc--; argv++; + } + else + { + addr = image_load_addr; + } + + if (!ElfIsImageValid(addr)) + return 1; + + + if (sload && sload[1] == 'p') + addr = ElfLoadElfImagePhdr(addr); + else + addr = ElfLoadElfImageShdr(addr); + + /* + * pass address parameter as argv[0] (aka command name), + * and all remaining args + */ + if (load_flg == 1 ) + { + printf("## Load application at 0x%08lx ...\n", addr); + }else{ + printf("## Starting application at 0x%08lx ...\n", addr); + rc = ElfExecBootElf((void *)addr, argc, argv); + } + + + printf("## Application terminated, rc = 0x%lx\n", rc); + return (int)rc; +} + +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), + bootelf, BootelfCmdEntry, Boot from an ELF image in memory); diff --git a/third-party/letter-shell-3.1/port/cmd/cmd_codeloader.c b/third-party/letter-shell-3.1/port/cmd/cmd_codeloader.c new file mode 100644 index 0000000000000000000000000000000000000000..fba1446b9ad178518e5abfd8d17529600d403db8 --- /dev/null +++ b/third-party/letter-shell-3.1/port/cmd/cmd_codeloader.c @@ -0,0 +1,80 @@ +/* + * @Author: your name + * @Date: 2021-09-06 17:11:48 + * @LastEditTime: 2022-02-10 15:01:05 + * @LastEditors: Please set LastEditors + * @Description: In User Settings Edit + * @FilePath: \phytium-standalone-sdk\third-party\letter-shell-3.1\port\cmd\cmd_codelode.c + */ + +#include +#include "../src/shell.h" +#include "strto.h" +#include "ft_elf.h" + +static unsigned long image_load_addr = 0x80100000; + +static void LoadElfCmdUsage() +{ + printf("usage:\r\n"); + printf(" loadelf [-p|-s] [address] \r\n"); + printf(" load ELF image at [address] via program headers (-p)\r\n"); + printf(" or via section headers (-s)\r\n"); +} + +static int LoadElfCmdEntry(int argc, char *argv[]) +{ + unsigned long addr; /* Address of the ELF image */ + unsigned long rc; /* Return value from user code */ + unsigned long load_flg = 0; + char *sload = NULL; + + if (argc < 2) + { + LoadElfCmdUsage(); + return -1; + } + /* Consume 'LoadElf' */ + argc--; + argv++; + + /* Check for flag. */ + if (argc >= 1 && (argv[0][0] == '-' && (argv[0][1] == 'p' || argv[0][1] == 's'))) + { + sload = argv[0]; + /* Consume flag. */ + argc--; + argv++; + } + + /* Check for address. */ + if (argc >= 1 && strict_strtoul(argv[0], 16, &addr) == 0) + { + /* Consume address */ + argc--; + argv++; + } + else + { + addr = image_load_addr; + } + + if (!ElfIsImageValid(addr)) + return 1; + + if (sload && sload[1] == 'p') + addr = ElfLoadElfImagePhdr(addr); + else + addr = ElfLoadElfImageShdr(addr); + + /* + * pass address parameter as argv[0] (aka command name), + * and all remaining args + */ + printf("## Load application at 0x%08lx ...\n", addr); + + return 0; +} + +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), + loadelf, LoadElfCmdEntry, Load from an ELF image in memory); \ No newline at end of file diff --git a/third-party/letter-shell-3.1/port/cmd/cmd_echo.c b/third-party/letter-shell-3.1/port/cmd/cmd_echo.c new file mode 100644 index 0000000000000000000000000000000000000000..ae83b1c7846f1ac8cd3d8592a18d001ede525894 --- /dev/null +++ b/third-party/letter-shell-3.1/port/cmd/cmd_echo.c @@ -0,0 +1,56 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: cmd_echo.c + * Date: 2022-02-24 18:24:53 + * LastEditTime: 2022-03-21 17:03:49 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include +#include +#include +#include "../src/shell.h" +#include "ft_io.h" +#include "ft_types.h" + +static void EchoCmdUsage() +{ + printf("usage:\r\n"); + printf(" echo [str] [str] \r\n"); + printf(" printf to shell\r\n"); +} + +static int EchoCmdEntry(int argc, char *argv[]) +{ + int loop; + + if(argc < 2) + { + EchoCmdUsage(); + return -1; + } + + for (loop = 1; loop < argc; loop++) + { + printf("%s", argv[loop]); + } + + printf("\r\n"); + return 0; +} +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), echo, EchoCmdEntry, printf string to shell prompt); \ No newline at end of file diff --git a/third-party/letter-shell-3.1/port/cmd/cmd_md.c b/third-party/letter-shell-3.1/port/cmd/cmd_md.c new file mode 100644 index 0000000000000000000000000000000000000000..c3868c162e2a5098c59363307f74c148be592f25 --- /dev/null +++ b/third-party/letter-shell-3.1/port/cmd/cmd_md.c @@ -0,0 +1,150 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: cmd_md.c + * Date: 2022-02-24 18:24:53 + * LastEditTime: 2022-03-21 17:03:53 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include +#include +#include +#include "../src/shell.h" +#include "ft_io.h" +#include "ft_types.h" + +static void MdCmdUsage() +{ + printf("usage:\r\n"); + printf(" md [-b|-w|-l|-q] address [-c count]\r\n"); +} + +static int MdCmdEntry(int argc, char *argv[]) +{ + uintptr addr = 0; + char buf[16]; + int n = 64, size = 1; + int i, len; + u8 b; + u16 w; + u32 l; + u64 q; + + if (argc < 2) + { + MdCmdUsage(); + return -1; + } + + for (i = 1; i < argc; i++) + { + if (!strcmp(argv[i], "-b")) + size = 1; + else if (!strcmp(argv[i], "-w")) + size = 2; + else if (!strcmp(argv[i], "-l")) + size = 4; + else if (!strcmp(argv[i], "-q")) + size = 8; + else if (!strcmp(argv[i], "-c") && (argc > i + 1)) + { + n = strtoul(argv[i + 1], NULL, 0); + i++; + } + else if (*argv[i] == '-') + { + MdCmdUsage(); + return (-1); + } + else if (*argv[i] != '-' && strcmp(argv[i], "-") != 0) + { + addr = strtoul(argv[i], NULL, 0); + } + } + + if (size == 1) + { + addr &= ~((uintptr)0x0); + } + else if (size == 2) + { + addr &= ~((uintptr)0x1); + } + else if (size == 4) + { + addr &= ~((uintptr)0x3); + } + else if (size == 8) + { + addr &= ~((uintptr)0x7); + } + n = n * size; + + while (n > 0) + { + len = (n > 16) ? 16 : n; + printf("%08lx: ", addr); + if (size == 1) + { + for (i = 0; i < len; i += size) + { + FtOut8((uintptr)(&buf[i]), (b = FtIn8(addr + i))); + printf(" %02lx", b); + } + } + else if (size == 2) + { + for (i = 0; i < len; i += size) + { + FtOut16((uintptr)(&buf[i]), (w = FtIn16(addr + i))); + printf(" %04lx", w); + } + } + else if (size == 4) + { + for (i = 0; i < len; i += size) + { + FtOut32((uintptr)(&buf[i]), (l = FtIn32(addr + i))); + printf(" %08lx", l); + } + } + else if (size == 8) + { + for (i = 0; i < len; i += size) + { + FtOut64((uintptr)(&buf[i]), (q = FtIn64(addr + i))); + printf(" %016llx", q); + } + } + printf("%*s", (16 - len) * 2 + (16 - len) / size + 4, ""); + for (i = 0; i < len; i++) + { + if ((buf[i] < 0x20) || (buf[i] > 0x7e)) + printf("."); + else + printf("%c", buf[i]); + } + addr += len; + n -= len; + printf("\r\n"); + } + + return 0; +} + +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), md, MdCmdEntry, dump a memory region); \ No newline at end of file diff --git a/third-party/letter-shell-3.1/port/cmd/cmd_mw.c b/third-party/letter-shell-3.1/port/cmd/cmd_mw.c new file mode 100644 index 0000000000000000000000000000000000000000..1b6d9504a12f9669defa0a951952d0667c2c0d98 --- /dev/null +++ b/third-party/letter-shell-3.1/port/cmd/cmd_mw.c @@ -0,0 +1,126 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: cmd_mw.c + * Date: 2022-02-24 18:24:53 + * LastEditTime: 2022-03-21 17:03:57 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include +#include +#include +#include "../src/shell.h" +#include "ft_io.h" +#include "ft_types.h" + +static void MwUsage() +{ + printf("usage:\r\n"); + printf(" mw [-b|-w|-l|-q] address value [-c count]\r\n"); +} + +static int MwCmdEntry(int argc, char **argv) +{ + uintptr addr = 0; + u64 value = 0; + int size = 1, n = 1; + int index = 0; + int i; + + if (argc < 3) + { + MwUsage(); + return -1; + } + + for (i = 1; i < argc; i++) + { + if (!strcmp(argv[i], "-b")) + size = 1; + else if (!strcmp(argv[i], "-w")) + size = 2; + else if (!strcmp(argv[i], "-l")) + size = 4; + else if (!strcmp(argv[i], "-q")) + size = 8; + else if (!strcmp(argv[i], "-c") && (argc > i + 1)) + { + n = strtoul(argv[i + 1], NULL, 0); + if (n == 0) + { + printf("mw: the writing count is zero by '-c %s'", argv[i + 1]); + return -1; + } + i++; + } + else if (*argv[i] == '-') + { + MwUsage(); + return -1; + } + else if (*argv[i] != '-' && strcmp(argv[i], "-") != 0) + { + if (index == 0) + addr = strtoul(argv[i], NULL, 0); + else if (index == 1) + value = strtoull(argv[i], NULL, 0); + else if (index >= 2) + { + printf("mw: invalid paramter '%s'\r\n", argv[i]); + printf("try 'help mw' for more information.\r\n"); + return (-1); + } + index++; + } + } + + if (size == 1) + { + addr &= ~((uintptr)0x0); + } + else if (size == 2) + { + addr &= ~((uintptr)0x1); + } + else if (size == 4) + { + addr &= ~((uintptr)0x3); + } + else if (size == 8) + { + addr &= ~((uintptr)0x7); + } + n = n * size; + + for (i = 0; i < n; i += size) + { + if (size == 1) + FtOut8((uintptr)(addr + i), (u8)value); + else if (size == 2) + FtOut16((uintptr)(addr + i), (u16)value); + else if (size == 4) + FtOut32((uintptr)(addr + i), (u32)value); + else if (size == 8) + FtOut64((uintptr)(addr + i), (u64)value); + } + printf("write done.\r\n"); + + return 0; +} + +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), mw, MwCmdEntry, write values to memory region); \ No newline at end of file diff --git a/third-party/letter-shell-3.1/port/cmd/cmd_os_stats.c b/third-party/letter-shell-3.1/port/cmd/cmd_os_stats.c new file mode 100644 index 0000000000000000000000000000000000000000..b5ee41e4d404088d080060200f362dd7b8790d96 --- /dev/null +++ b/third-party/letter-shell-3.1/port/cmd/cmd_os_stats.c @@ -0,0 +1,50 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: cmd_os_stats.c + * Date: 2022-02-25 08:34:53 + * LastEditTime: 2022-02-25 08:34:53 + * Description:  This file is for + * + * Modify History: +* Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ +#include "FreeRTOS.h" +#include "task.h" +#include "../src/shell.h" +#include "stdio.h" +#include "string.h" + +static int DisplayTaskStats(int argc, char *argv[]) +{ + uint8_t CPU_RunInfo[400] = {0}; //保存任务运行时间信息 + + vTaskList((char *)&CPU_RunInfo); //获取任务运行时间信息 + + printf("---------------------------------------------\r\n"); + printf("task_name\ttask_state\tpriority\tstack\ttask_num\r\n"); + printf("%s", CPU_RunInfo); + printf("---------------------------------------------\r\n"); + + memset(CPU_RunInfo, 0, 400); //信息缓冲区清零 + + vTaskGetRunTimeStats((char *)&CPU_RunInfo); + + printf("task_name\trun_time_count\tusage_rate\r\n"); + printf("%s", CPU_RunInfo); + printf("---------------------------------------------\r\n\n"); + + return 0; +} +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), ps, DisplayTaskStats, View the running status of the current task); \ No newline at end of file diff --git a/third-party/letter-shell-3.1/port/cmd/cmd_reboot.c b/third-party/letter-shell-3.1/port/cmd/cmd_reboot.c new file mode 100644 index 0000000000000000000000000000000000000000..ac0d83c10f51179a2afa19f35de798509da60f15 --- /dev/null +++ b/third-party/letter-shell-3.1/port/cmd/cmd_reboot.c @@ -0,0 +1,34 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: cmd_reboot.c + * Date: 2022-02-24 18:24:53 + * LastEditTime: 2022-03-21 17:04:01 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include "../src/shell.h" +#include "ft_types.h" +#include "psci.h" + +int RebootCmdEntry() +{ + PsciCpuReset(); + return 0; +} +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), reboot, + RebootCmdEntry, reboot board by psci); \ No newline at end of file diff --git a/third-party/letter-shell-3.1/port/cmd/cmd_rw.c b/third-party/letter-shell-3.1/port/cmd/cmd_rw.c new file mode 100644 index 0000000000000000000000000000000000000000..8cf1a3a9d4f63b56539a1228131c1054fede7ac0 --- /dev/null +++ b/third-party/letter-shell-3.1/port/cmd/cmd_rw.c @@ -0,0 +1,144 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: cmd_rw.c + * Date: 2022-02-24 18:24:53 + * LastEditTime: 2022-03-21 17:04:05 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include +#include +#include +#include "../src/shell.h" +#include "../shell_port.h" +#include "ft_io.h" +#include "ft_types.h" +#include "ft_debug.h" + +static int RwWriteRegister(u32 reg_addr, u32 reg_val, u32 bit_width) +{ + if (bit_width > 4) + return -1; + + if (4 == bit_width) + FtOut32((uintptr)reg_addr, reg_val); + else if (2 == bit_width) + FtOut16((uintptr)reg_addr, (u16)reg_val); + else if (1 == bit_width) + FtOut8((uintptr)reg_addr, (u8)reg_val); + + return 0; +} + +static int RwReadRegister(u32 reg_addr, u32 *reg_val_p, u32 bit_width, u32 len) +{ + if ((bit_width > 4) || (NULL == reg_val_p)) + return -1; + + if (4 == bit_width) + *reg_val_p = FtIn32(reg_addr); + else if (2 == bit_width) + *reg_val_p = FtIn16(reg_addr); + else if (1 == bit_width) + *reg_val_p = FtIn8(reg_addr); + + if (1 < len) + { + FtDumpHexByte((u8 *)(uintptr)reg_addr, len); + } + + return 0; +} + +static void RwCmdUsage() +{ + printf("usage:\r\n"); + printf(" rw [-w|-r] address register_val \r\n"); + printf(" rw -w [bit width] [address] [value]: write bits to address with value\r\n"); + printf(" rw -r [bit width] [address] [cnt=1]: read bits from address and print, by default read 1 bits\r\n"); +} + +static int RwCmdEntry(int argc, char *argv[]) +{ + int ret = 0; + u32 reg_addr = 0; + u32 reg_val = 0; + u32 bit_width = 0; + u32 read_cnt = 1; + + if (argc < 4) + { + RwCmdUsage(); + return -1; + } + + if (!strcmp(argv[1], "-w")) + { + if (argc < 5) + { + RwCmdUsage(); + return -2; + } + + bit_width = strtoul(argv[2], NULL, 0); + reg_addr = strtoul(argv[3], NULL, 0); + reg_val = strtoul(argv[4], NULL, 0); + ret = RwWriteRegister(reg_addr, reg_val, bit_width); + + if (0 != ret) + { + printf("write failed: %d\r\n", ret); + } + else + { + LSUserPrintf("set 0x%x = 0x%x\r\n", reg_addr, reg_val); + } + } + else if (!strcmp(argv[1], "-r")) + { + if (argc < 4) + { + RwCmdUsage(); + return -3; + } + + bit_width = strtoul(argv[2], NULL, 0); + reg_addr = strtoul(argv[3], NULL, 0); + reg_val = 0; + + if (argc = 4) + { + read_cnt = strtoul(argv[4], NULL, 0); + } + + ret = RwReadRegister(reg_addr, ®_val, bit_width, read_cnt); + + if (0 != ret) + { + printf("read failed: %d\r\n", ret); + } + else + { + LSUserPrintf("get 0x%x = 0x%x\r\n", reg_addr, reg_val); + LSUserSetResult(reg_val); + } + } + + return ret; +} +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), rw, RwCmdEntry, read or write register value); \ No newline at end of file diff --git a/third-party/letter-shell-3.1/port/cmd/cmd_sleep.c b/third-party/letter-shell-3.1/port/cmd/cmd_sleep.c new file mode 100644 index 0000000000000000000000000000000000000000..24143669fc75bbc57d4ecb95932906f3b024b808 --- /dev/null +++ b/third-party/letter-shell-3.1/port/cmd/cmd_sleep.c @@ -0,0 +1,71 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: cmd_sleep.c + * Date: 2022-02-24 18:24:53 + * LastEditTime: 2022-03-21 17:04:10 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include +#include +#include +#include "../src/shell.h" +#include "ft_io.h" +#include "ft_types.h" +#include "fsleep.h" + +static void SleepCmdUsage() +{ + printf("usage:\r\n"); + printf(" sleep [-s | -m | -u] [num] \r\n"); + printf(" sleep for num of seconds (-s), mill-seconds(-m), micro-seconds (-u)\r\n"); +} + +static int SleepCmdEntry(int argc, char *argv[]) +{ + u32 time = 0; + + if (argc < 3) + { + SleepCmdUsage(); + return -1; + } + + if(!strcmp(argv[1], "-s")) + { + time = strtoul(argv[2], NULL, 0); + fsleep_seconds(time); + } + else if(!strcmp(argv[1], "-m")) + { + time = strtoul(argv[2], NULL, 0); + fsleep_millisec(time); + } + else if(!strcmp(argv[1], "-u")) + { + time = strtoul(argv[2], NULL, 0); + fsleep_microsec(time); + } + else + { + return -2; + } + + return 0; +} +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), sleep, SleepCmdEntry, blocking sleep for a period of time); \ No newline at end of file diff --git a/third-party/letter-shell-3.1/port/cmd/cmd_version.c b/third-party/letter-shell-3.1/port/cmd/cmd_version.c new file mode 100644 index 0000000000000000000000000000000000000000..5a1c3eead50c8bf7d11e912f362067157175c088 --- /dev/null +++ b/third-party/letter-shell-3.1/port/cmd/cmd_version.c @@ -0,0 +1,37 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: cmd_version.c + * Date: 2022-02-24 18:24:53 + * LastEditTime: 2022-03-21 17:04:14 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include +#include +#include +#include "../src/shell.h" +#include "../shell_port.h" + + +static int VersionCmdEntry(int argc, char *argv[]) +{ + LSUShowVersion(); + return 0; +} +SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), version, + VersionCmdEntry, show version of cur shell); \ No newline at end of file diff --git a/third-party/letter-shell-3.1/port/pl011/fpl011_os_port.c b/third-party/letter-shell-3.1/port/pl011/fpl011_os_port.c new file mode 100644 index 0000000000000000000000000000000000000000..8dddc71f260cfeaafc55d93daacb508ff7edc021 --- /dev/null +++ b/third-party/letter-shell-3.1/port/pl011/fpl011_os_port.c @@ -0,0 +1,83 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: fpl011_os_port.c + * Date: 2022-02-24 21:42:27 + * LastEditTime: 2022-02-24 21:42:27 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + + +#include +#include "ft_assert.h" +#include "parameters.h" +#include "shell_port.h" +#include "interrupt.h" +#include "fpl011_os.h" + +FtFreertosUart os_uart1; +extern Shell shell_object; + +/** + * @brief 用户shell写 + * + * @param data 数据 + */ +void LSUserShellWrite(char data) +{ + // FtFreertosUartBlcokingSend(&os_uart1, &data, 1); + FPl011Send(&os_uart1.bsp_uart,&data, 1); +} + +/** + * @brief 用户shell读 + * + * @param data 数据 + * @return char 状态 + */ +signed char LSUserShellRead(char *data) +{ + u32 received_length; + FtFreertosUartReceiveBuffer(&os_uart1, data, 1, &received_length); + return 0; +} + +void LSSerialConfig(void) +{ + FtFreertosUartConfig config = { + .uart_instance = UART1_ID, /* select uart global object */ + .isr_priority = 0xd0, /* irq Priority */ + .isr_event_mask = (RTOS_UART_ISR_OEIM_MASK|RTOS_UART_ISR_BEIM_MASK|RTOS_UART_ISR_PEIM_MASK|RTOS_UART_ISR_FEIM_MASK|RTOS_UART_ISR_RTIM_MASK|RTOS_UART_ISR_RXIM_MASK) + }; + FtFreertosUartInit(&os_uart1,&config); +} + +void LSSerialWaitLoop(void) +{ + char data[64]; + u32 recive_length = 0; + u32 i = 0; + while (TRUE) + { + FtFreertosUartReceiveBuffer(&os_uart1,data,sizeof(data),&recive_length); + for (i = 0; i < recive_length; i++) + { + shellHandler(&shell_object, data[i]); + } + } + vTaskDelete(NULL); +} diff --git a/third-party/letter-shell-3.1/port/shell_port.c b/third-party/letter-shell-3.1/port/shell_port.c new file mode 100644 index 0000000000000000000000000000000000000000..cc7268aaa4e9ba2e994b571e5cbd30b6367ada71 --- /dev/null +++ b/third-party/letter-shell-3.1/port/shell_port.c @@ -0,0 +1,113 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: shell_port.c + * Date: 2022-02-24 22:03:27 + * LastEditTime: 2022-02-24 22:03:28 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + +#include "shell.h" +#include +#include +#include +#include "ft_assert.h" +#include "shell_port.h" +#include "FreeRTOS.h" +#include "task.h" + + +Shell shell_object; +u32 shell_last_result = 0; +char shell_buffer[4096]; +extern void LSUserShellWrite(char data); +extern signed char LSUserShellRead(char *data); +extern void LSSerialConfig(); +extern void LSSerialWaitLoop(); + +/** + * @brief 用户shell初始化 + * + * Note: Call this function will lead to infinite create freertos task + */ +BaseType_t LSUserShellTask(void) +{ + LSSerialConfig(); + + shell_object.write = LSUserShellWrite; + shell_object.read = LSUserShellRead; + shellInit(&shell_object, shell_buffer, 4096); + + + return xTaskCreate((TaskFunction_t )LSSerialWaitLoop, /* 任务入口函数 */ + (const char* )"LSSerialWaitLoop",/* 任务名字 */ + (uint16_t )1024, /* 任务栈大小 */ + (void* )NULL,/* 任务入口函数参数 */ + (UBaseType_t )2, /* 任务的优先级 */ + NULL); /* 任务控制块指针 */ +} + + + +/** + * @name: LSUserGetLastRet + * @msg: 获取上一条命令的执行返回值 + * @return {*} + */ +int LSUserGetLastRet(void) +{ + return shell_object.lastRet; +} + +/** + * @name: 通过letter shell执行一行命令 + * @msg: + * @return {*} + * @param {char} *cmd + */ +void LSUserExec(const char *cmd) +{ + LSUserPrintf("exec: '%s'==========\r\n", cmd); + shellRun(&shell_object, cmd); + LSUserPrintf("================\r\n"); + return; +} + +void LSUserSetResult(u32 result) +{ + shell_last_result = result; +} + +u32 LSUserGetResult() +{ + return shell_last_result; +} + +void LSUserSlient(boolean slient) +{ + shell_object.slient = slient ? 1 : 0; +} + +boolean LSUserIsSlient(void) +{ + return (1 == shell_object.slient); +} + +void LSUShowVersion(void) +{ + shellWriteVersion(&shell_object); +} \ No newline at end of file diff --git a/third-party/letter-shell-3.1/port/shell_port.h b/third-party/letter-shell-3.1/port/shell_port.h new file mode 100644 index 0000000000000000000000000000000000000000..964134f5889d9ec5bfcf93bd32dd391d14fc9752 --- /dev/null +++ b/third-party/letter-shell-3.1/port/shell_port.h @@ -0,0 +1,48 @@ +/* + * Copyright : (C) 2022 Phytium Information Technology, Inc. + * All Rights Reserved. + * + * This program is OPEN SOURCE software: you can redistribute it and/or modify it + * under the terms of the Phytium Public License as published by the Phytium Technology Co.,Ltd, + * either version 1.0 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Phytium Public License for more details. + * + * + * FilePath: shell_port.h + * Date: 2022-02-24 22:03:34 + * LastEditTime: 2022-02-24 22:03:34 + * Description:  This file is for + * + * Modify History: + * Ver   Who        Date         Changes + * ----- ------     --------    -------------------------------------- + */ + + +#ifndef THIRD_LETTER_SHELL_OS_PORT_H +#define THIRD_LETTER_SHELL_OS_PORT_H + +#include "shell.h" +#include "ft_types.h" +#include "FreeRTOS.h" +#include "task.h" + +extern Shell shell; +BaseType_t LSUserShellTask(void); +void LSUserExec(const char *cmd); +int LSUserGetLastRet(void); +void LSUserSetResult(u32 result); +u32 LSUserGetResult(void); +void LSUserSlient(boolean slient); +boolean LSUserIsSlient(void); +void LSUShowVersion(void); +#define LSUserPrintf(format, ...) \ + if (!LSUserIsSlient()) \ + { \ + printf(format, ##__VA_ARGS__); \ + } + +#endif diff --git a/third-party/letter-shell-3.1/src/shell.c b/third-party/letter-shell-3.1/src/shell.c new file mode 100644 index 0000000000000000000000000000000000000000..0be57292eedbdc2cc6380ad25fff46956ba08235 --- /dev/null +++ b/third-party/letter-shell-3.1/src/shell.c @@ -0,0 +1,1925 @@ +/** + * @file shell.c + * @author Letter (NevermindZZT@gmail.com) + * @version 3.0.0 + * @date 2019-12-30 + * + * @copyright (c) 2020 Letter + * + */ + +#include "sdkconfig.h" +#ifndef SDK_CONFIG_H__ + #warning "Please include sdkconfig.h" +#endif +#include "shell.h" +#include "string.h" +#include "stdio.h" +#include "stdarg.h" +#include "shell_ext.h" + + +#if SHELL_USING_CMD_EXPORT == 1 +/** + * @brief 默认用户 + */ +const char shellCmdDefaultUser[] = SHELL_DEFAULT_USER; +const char shellPasswordDefaultUser[] = SHELL_DEFAULT_USER_PASSWORD; +const char shellDesDefaultUser[] = "default user"; +const ShellCommand shellUserDefault SECTION("shellCommand") = +{ + .attr.value = SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_USER), + .data.user.name = shellCmdDefaultUser, + .data.user.password = shellPasswordDefaultUser, + .data.user.desc = shellDesDefaultUser +}; +#endif + +#if SHELL_USING_CMD_EXPORT == 1 + #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && __ARMCC_VERSION >= 6000000) + extern const unsigned int shellCommand$$Base; + extern const unsigned int shellCommand$$Limit; + #elif defined(__ICCARM__) || defined(__ICCRX__) + #pragma section="shellCommand" + #elif defined(__GNUC__) + extern const unsigned int _shell_command_start; + extern const unsigned int _shell_command_end; + #endif +#else + extern const ShellCommand shellCommandList[]; + extern const unsigned short shellCommandCount; +#endif + + +/** + * @brief shell 常量文本索引 + */ +enum +{ +#if SHELL_SHOW_INFO == 1 + SHELL_TEXT_INFO, /**< shell信息 */ +#endif + SHELL_TEXT_CMD_TOO_LONG, /**< 命令过长 */ + SHELL_TEXT_CMD_LIST, /**< 可执行命令列表标题 */ + SHELL_TEXT_VAR_LIST, /**< 变量列表标题 */ + SHELL_TEXT_USER_LIST, /**< 用户列表标题 */ + SHELL_TEXT_KEY_LIST, /**< 按键列表标题 */ + SHELL_TEXT_CMD_NOT_FOUND, /**< 命令未找到 */ + SHELL_TEXT_POINT_CANNOT_MODIFY, /**< 指针变量不允许修改 */ + SHELL_TEXT_VAR_READ_ONLY_CANNOT_MODIFY, /**< 只读变量不允许修改 */ + SHELL_TEXT_NOT_VAR, /**< 命令不是变量 */ + SHELL_TEXT_VAR_NOT_FOUND, /**< 变量未找到 */ + SHELL_TEXT_HELP_HEADER, /**< help头 */ + SHELL_TEXT_PASSWORD_HINT, /**< 密码输入提示 */ + SHELL_TEXT_PASSWORD_ERROR, /**< 密码错误 */ + SHELL_TEXT_CLEAR_CONSOLE, /**< 清空控制台 */ + SHELL_TEXT_CLEAR_LINE, /**< 清空当前行 */ + SHELL_TEXT_TYPE_CMD, /**< 命令类型 */ + SHELL_TEXT_TYPE_VAR, /**< 变量类型 */ + SHELL_TEXT_TYPE_USER, /**< 用户类型 */ + SHELL_TEXT_TYPE_KEY, /**< 按键类型 */ + SHELL_TEXT_TYPE_NONE, /**< 非法类型 */ +#if SHELL_EXEC_UNDEF_FUNC == 1 + SHELL_TEXT_PARAM_ERROR, /**< 参数错误 */ +#endif +}; + +#if defined(CONFIG_TARGET_F2000_4) +#define SHELL_PLATFORM "FT2000/4 " +#elif defined(CONFIG_TARGET_D2000) +#define SHELL_PLATFORM "D2000 " +#elif defined(CONFIG_TARGET_E2000) +#define SHELL_PLATFORM "E2000 " +#else +#define SHELL_PLATFORM "Unkonwn " +#endif + +#if defined(CONFIG_TARGET_ARMV8_AARCH32) +#define SHELL_ARCH "Armv8-aarch32 " +#elif defined(CONFIG_TARGET_ARMV8_AARCH64) +#define SHELL_ARCH "Armv8-aarch64 " +#else +#define SHELL_ARCH "Unkonwn " +#endif + +#if defined(CONFIG_USE_BAREMETAL_AMP) + +#if defined(CONFIG_TARGET_AMP_MASTER) +#define SHELL_AMP_ROLE "Amp-Master" +#elif defined(CONFIG_TARGET_AMP_SLAVE) +#define SHELL_AMP_ROLE "Amp-Slave" +#else +#define SHELL_AMP_ROLE "Amp-Role-Unkonwn" +#endif + +#endif + +static const char *shellText[] = +{ +#if SHELL_SHOW_INFO == 1 + [SHELL_TEXT_INFO] = + "\r\n" + " _____ _ _ _ \r\n" + "| __ \\ | | | | (_) \r\n" + "| |__) | | |__ _ _ | |_ _ _ _ _ __ ___ \r\n" + "| ___/ | '_ \\ | | | | | __| | | | | | | | '_ ` _ \\ \r\n" + "| | | | | | | |_| | | |_ | | | |_| | | | | | | |\r\n" + "|_| |_| |_| \\ __, | \\__| |_| \\__,_| |_| |_| |_|\r\n" + " __/ | \r\n" + " |___/ \r\n" + "================ Freertos Letter Shell================\r\n" + "Build: "__DATE__" "__TIME__"\r\n" + "Version: "SHELL_VERSION"\r\n" + "Platform: "SHELL_PLATFORM""SHELL_ARCH"\r\n" +#if defined(CONFIG_USE_BAREMETAL_AMP) + "Role: "SHELL_AMP_ROLE"\r\n" +#endif + "=======================================================\r\n", +#endif + [SHELL_TEXT_CMD_TOO_LONG] = + "\r\nWarning: Command is too long\r\n", + [SHELL_TEXT_CMD_LIST] = + "\r\nCommand List:\r\n", + [SHELL_TEXT_VAR_LIST] = + "\r\nVar List:\r\n", + [SHELL_TEXT_USER_LIST] = + "\r\nUser List:\r\n", + [SHELL_TEXT_KEY_LIST] = + "\r\nKey List:\r\n", + [SHELL_TEXT_CMD_NOT_FOUND] = + "Command not Found\r\n", + [SHELL_TEXT_POINT_CANNOT_MODIFY] = + "can't set pointer\r\n", + [SHELL_TEXT_VAR_READ_ONLY_CANNOT_MODIFY] = + "can't set read only var\r\n", + [SHELL_TEXT_NOT_VAR] = + " is not a var\r\n", + [SHELL_TEXT_VAR_NOT_FOUND] = + "Var not Fount\r\n", + [SHELL_TEXT_HELP_HEADER] = + "command help of ", + [SHELL_TEXT_PASSWORD_HINT] = + "\r\nPlease input password:", + [SHELL_TEXT_PASSWORD_ERROR] = + "\r\npassword error\r\n", + [SHELL_TEXT_CLEAR_CONSOLE] = + "\033[2J\033[1H", + [SHELL_TEXT_CLEAR_LINE] = + "\033[2K\r", + [SHELL_TEXT_TYPE_CMD] = + "CMD ", + [SHELL_TEXT_TYPE_VAR] = + "VAR ", + [SHELL_TEXT_TYPE_USER] = + "USER", + [SHELL_TEXT_TYPE_KEY] = + "KEY ", + [SHELL_TEXT_TYPE_NONE] = + "NONE", +#if SHELL_EXEC_UNDEF_FUNC == 1 + [SHELL_TEXT_PARAM_ERROR] = + "Parameter error\r\n", +#endif +}; + + +/** + * @brief shell对象表 + */ +static Shell *shellList[SHELL_MAX_NUMBER] = {NULL}; + + +static void shellAdd(Shell *shell); +static void shellWriteCommandLine(Shell *shell, unsigned char newline); +static void shellWriteReturnValue(Shell *shell, int value); +static int shellShowVar(Shell *shell, ShellCommand *command); +static void shellSetUser(Shell *shell, const ShellCommand *user); +ShellCommand* shellSeekCommand(Shell *shell, + const char *cmd, + ShellCommand *base, + unsigned short compareLength); + +/** + * @brief shell 初始化 + * + * @param shell shell对象 + */ +void shellInit(Shell *shell, char *buffer, unsigned short size) +{ + shell->parser.length = 0; + shell->parser.cursor = 0; + shell->history.offset = 0; + shell->history.number = 0; + shell->history.record = 0; + shell->info.user = NULL; + shell->status.isChecked = 1; + shell->lastRet = 0; + //shell->lastResult = 0; + shell->slient = 0; + + shell->parser.buffer = buffer; + shell->parser.bufferSize = size / (SHELL_HISTORY_MAX_NUMBER + 1); + for (short i = 0; i < SHELL_HISTORY_MAX_NUMBER; i++) + { + shell->history.item[i] = buffer + shell->parser.bufferSize * (i + 1); + } + +#if SHELL_USING_CMD_EXPORT == 1 + #if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && __ARMCC_VERSION >= 6000000) + shell->commandList.base = (ShellCommand *)(&shellCommand$$Base); + shell->commandList.count = ((unsigned int)(&shellCommand$$Limit) + - (unsigned int)(&shellCommand$$Base)) + / sizeof(ShellCommand); + + #elif defined(__ICCARM__) || defined(__ICCRX__) + shell->commandList.base = (ShellCommand *)(__section_begin("shellCommand")); + shell->commandList.count = ((unsigned int)(__section_end("shellCommand")) + - (unsigned int)(__section_begin("shellCommand"))) + / sizeof(ShellCommand); + #elif defined(__GNUC__) + shell->commandList.base = (ShellCommand *)(&_shell_command_start); + shell->commandList.count = ((unsigned long)(&_shell_command_end) + - (unsigned long)(&_shell_command_start)) + / (unsigned long)sizeof(ShellCommand); + #else + #error not supported compiler, please use command table mode + #endif +#else + shell->commandList.base = (ShellCommand *)shellCommandList; + shell->commandList.count = shellCommandCount; +#endif + + shellAdd(shell); + + shellSetUser(shell, shellSeekCommand(shell, + SHELL_DEFAULT_USER, + shell->commandList.base, + 0)); + shellWriteCommandLine(shell, 1); +} + + +/** + * @brief 添加shell + * + * @param shell shell对象 + */ +static void shellAdd(Shell *shell) +{ + for (short i = 0; i < SHELL_MAX_NUMBER; i++) + { + if (shellList[i] == NULL) + { + shellList[i] = shell; + return; + } + } +} + + +/** + * @brief 获取当前活动shell + * + * @return Shell* 当前活动shell对象 + */ +Shell* shellGetCurrent(void) +{ + for (short i = 0; i < SHELL_MAX_NUMBER; i++) + { + if (shellList[i] && shellList[i]->status.isActive) + { + return shellList[i]; + } + } + return NULL; +} + + +/** + * @brief shell写字符 + * + * @param shell shell对象 + * @param data 字符数据 + */ +static void shellWriteByte(Shell *shell, const char data) +{ + shell->write(data); +} + + +/** + * @brief shell 写字符串 + * + * @param shell shell对象 + * @param string 字符串数据 + * + * @return unsigned short 写入字符的数量 + */ +unsigned short shellWriteString(Shell *shell, const char *string) +{ + unsigned short count = 0; + SHELL_ASSERT(shell->write, return 0); + while(*string) + { + shell->write(*string ++); + count ++; + } + return count; +} + + +/** + * @brief shell 写命令描述字符串 + * + * @param shell shell对象 + * @param string 字符串数据 + * + * @return unsigned short 写入字符的数量 + */ +static unsigned short shellWriteCommandDesc(Shell *shell, const char *string) +{ + unsigned short count = 0; + SHELL_ASSERT(shell->write, return 0); + while(*string + && *string != '\r' + && *string != '\n' + && count < 36) + { + shell->write(*string ++); + count ++; + if (count >= 36 && *(string + 1)) + { + shell->write('.'); + shell->write('.'); + shell->write('.'); + } + } + return count; +} + + +/** + * @brief shell写命令提示符 + * + * @param shell shell对象 + * @param newline 新行 + * + */ +static void shellWriteCommandLine(Shell *shell, unsigned char newline) +{ + if (shell->status.isChecked) + { + if (newline) + { + shellWriteString(shell, "\r\n"); + } + shellWriteString(shell, shell->info.user->data.user.name); + shellWriteString(shell, ":"); + shellWriteString(shell, shell->info.path ? shell->info.path : "/"); + shellWriteString(shell, "$ "); + } + else + { + shellWriteString(shell, shellText[SHELL_TEXT_PASSWORD_HINT]); + } +} + +void shellWriteVersion(Shell *shell) +{ + shellWriteString(shell, shellText[SHELL_TEXT_INFO]); +} + +#if SHELL_PRINT_BUFFER > 0 +/** + * @brief shell格式化输出 + * + * @param shell shell对象 + * @param fmt 格式化字符串 + * @param ... 参数 + */ +void shellPrint(Shell *shell, char *fmt, ...) +{ + char buffer[SHELL_PRINT_BUFFER]; + va_list vargs; + + SHELL_ASSERT(shell, return); + + va_start(vargs, fmt); + vsnprintf(buffer, SHELL_PRINT_BUFFER - 1, fmt, vargs); + va_end(vargs); + + shellWriteString(shell, buffer); +} +#endif + + +/** + * @brief shell 检查命令权限 + * + * @param shell shell对象 + * @param command ShellCommand + * + * @return signed char 0 当前用户具有该命令权限 + * @return signec char -1 当前用户不具有该命令权限 + */ +signed char shellCheckPermission(Shell *shell, ShellCommand *command) +{ + return ((!command->attr.attrs.permission + || command->attr.attrs.type == SHELL_TYPE_USER + || (command->attr.attrs.permission + & shell->info.user->attr.attrs.permission)) + && (shell->status.isChecked + || command->attr.attrs.enableUnchecked)) + ? 0 : -1; +} + + +/** + * @brief int转16进制字符串 + * + * @param value 数值 + * @param buffer 缓冲 + * + * @return signed char 转换后有效数据长度 + */ +signed char shellToHex(unsigned int value, char *buffer) +{ + char byte; + unsigned char i = 8; + buffer[8] = 0; + while (value) + { + byte = value & 0x0000000F; + buffer[--i] = (byte > 9) ? (byte + 87) : (byte + 48); + value >>= 4; + } + return 8 - i; +} + + +/** +* @brief int转10进制字符串 + * + * @param value 数值 + * @param buffer 缓冲 + * + * @return signed char 转换后有效数据长度 + */ +signed char shellToDec(int value, char *buffer) +{ + unsigned char i = 11; + int v = value; + if (value < 0) + { + v = -value; + } + buffer[11] = 0; + while (v) + { + buffer[--i] = v % 10 + 48; + v /= 10; + } + if (value < 0) + { + buffer[--i] = '-'; + } + if (value == 0) { + buffer[--i] = '0'; + } + return 11 - i; +} + + +/** + * @brief shell字符串复制 + * + * @param dest 目标字符串 + * @param src 源字符串 + * @return unsigned short 字符串长度 + */ +static unsigned short shellStringCopy(char *dest, char* src) +{ + unsigned short count = 0; + while (*(src + count)) + { + *(dest + count) = *(src + count); + count++; + } + *(dest + count) = 0; + return count; +} + + +/** + * @brief shell字符串比较 + * + * @param dest 目标字符串 + * @param src 源字符串 + * @return unsigned short 匹配长度 + */ +static unsigned short shellStringCompare(char* dest, char *src) +{ + unsigned short match = 0; + unsigned short i = 0; + + while (*(dest +i) && *(src + i)) + { + if (*(dest + i) != *(src +i)) + { + break; + } + match ++; + i++; + } + return match; +} + + +/** + * @brief shell获取命令名 + * + * @param command 命令 + * @return const char* 命令名 + */ +static const char* shellGetCommandName(ShellCommand *command) +{ + static char buffer[9]; + for (unsigned char i = 0; i < 9; i++) + { + buffer[i] = '0'; + } + if (command->attr.attrs.type <= SHELL_TYPE_CMD_FUNC) + { + return command->data.cmd.name; + } + else if (command->attr.attrs.type <= SHELL_TYPE_VAR_NODE) + { + return command->data.var.name; + } + else if (command->attr.attrs.type <= SHELL_TYPE_USER) + { + return command->data.user.name; + } + else + { + shellToHex(command->data.key.value, buffer); + return buffer; + } +} + + +/** + * @brief shell获取命令描述 + * + * @param command 命令 + * @return const char* 命令描述 + */ +static const char* shellGetCommandDesc(ShellCommand *command) +{ + if (command->attr.attrs.type <= SHELL_TYPE_CMD_FUNC) + { + return command->data.cmd.desc; + } + else if (command->attr.attrs.type <= SHELL_TYPE_VAR_NODE) + { + return command->data.var.desc; + } + else if (command->attr.attrs.type <= SHELL_TYPE_USER) + { + return command->data.user.desc; + } + else + { + return command->data.key.desc; + } +} + +/** + * @brief shell 列出命令条目 + * + * @param shell shell对象 + * @param item 命令条目 + */ +void shellListItem(Shell *shell, ShellCommand *item) +{ + short spaceLength; + + spaceLength = 22 - shellWriteString(shell, shellGetCommandName(item)); + spaceLength = (spaceLength > 0) ? spaceLength : 4; + do { + shellWriteByte(shell, ' '); + } while (--spaceLength); + if (item->attr.attrs.type <= SHELL_TYPE_CMD_FUNC) + { + shellWriteString(shell, shellText[SHELL_TEXT_TYPE_CMD]); + } + else if (item->attr.attrs.type <= SHELL_TYPE_VAR_NODE) + { + shellWriteString(shell, shellText[SHELL_TEXT_TYPE_VAR]); + } + else if (item->attr.attrs.type <= SHELL_TYPE_USER) + { + shellWriteString(shell, shellText[SHELL_TEXT_TYPE_USER]); + } + else if (item->attr.attrs.type <= SHELL_TYPE_KEY) + { + shellWriteString(shell, shellText[SHELL_TEXT_TYPE_KEY]); + } + else + { + shellWriteString(shell, shellText[SHELL_TEXT_TYPE_NONE]); + } +#if SHELL_HELP_SHOW_PERMISSION == 1 + shellWriteString(shell, " "); + for (signed char i = 7; i >= 0; i--) + { + shellWriteByte(shell, item->attr.attrs.permission & (1 << i) ? 'x' : '-'); + } +#endif + shellWriteString(shell, " "); + shellWriteCommandDesc(shell, shellGetCommandDesc(item)); + shellWriteString(shell, "\r\n"); +} + + +/** + * @brief shell列出可执行命令 + * + * @param shell shell对象 + */ +void shellListCommand(Shell *shell) +{ + ShellCommand *base = (ShellCommand *)shell->commandList.base; + shellWriteString(shell, shellText[SHELL_TEXT_CMD_LIST]); + for (unsigned short i = 0; i < shell->commandList.count; i++) + { + if (base[i].attr.attrs.type <= SHELL_TYPE_CMD_FUNC + && shellCheckPermission(shell, &base[i]) == 0) + { + shellListItem(shell, &base[i]); + } + } +} + + +/** + * @brief shell列出变量 + * + * @param shell shell对象 + */ +void shellListVar(Shell *shell) +{ + ShellCommand *base = (ShellCommand *)shell->commandList.base; + shellWriteString(shell, shellText[SHELL_TEXT_VAR_LIST]); + for (unsigned long i = 0; i < shell->commandList.count; i++) + { + if (base[i].attr.attrs.type > SHELL_TYPE_CMD_FUNC + && base[i].attr.attrs.type <= SHELL_TYPE_VAR_NODE + && shellCheckPermission(shell, &base[i]) == 0) + { + shellListItem(shell, &base[i]); + } + } +} + + +/** + * @brief shell列出用户 + * + * @param shell shell对象 + */ +void shellListUser(Shell *shell) +{ + ShellCommand *base = (ShellCommand *)shell->commandList.base; + shellWriteString(shell, shellText[SHELL_TEXT_USER_LIST]); + for (unsigned long i = 0; i < shell->commandList.count; i++) + { + if (base[i].attr.attrs.type > SHELL_TYPE_VAR_NODE + && base[i].attr.attrs.type <= SHELL_TYPE_USER + && shellCheckPermission(shell, &base[i]) == 0) + { + shellListItem(shell, &base[i]); + } + } +} + + +/** + * @brief shell列出按键 + * + * @param shell shell对象 + */ +void shellListKey(Shell *shell) +{ + ShellCommand *base = (ShellCommand *)shell->commandList.base; + shellWriteString(shell, shellText[SHELL_TEXT_KEY_LIST]); + for (unsigned long i = 0; i < shell->commandList.count; i++) + { + if (base[i].attr.attrs.type > SHELL_TYPE_USER + && base[i].attr.attrs.type <= SHELL_TYPE_KEY + && shellCheckPermission(shell, &base[i]) == 0) + { + shellListItem(shell, &base[i]); + } + } +} + + +/** + * @brief shell列出所有命令 + * + * @param shell shell对象 + */ +void shellListAll(Shell *shell) +{ +#if SHELL_HELP_LIST_USER == 1 + shellListUser(shell); +#endif + shellListCommand(shell); +#if SHELL_HELP_LIST_VAR == 1 + shellListVar(shell); +#endif +#if SHELL_HELP_LIST_KEY == 1 + shellListKey(shell); +#endif +} + + +/** + * @brief shell删除命令行数据 + * + * @param shell shell对象 + * @param length 删除长度 + */ +void shellDeleteCommandLine(Shell *shell, unsigned char length) +{ + while (length--) + { + shellWriteString(shell, "\b \b"); + } +} + + +/** + * @brief shell 清空命令行输入 + * + * @param shell shell对象 + */ +void shellClearCommandLine(Shell *shell) +{ + for (short i = shell->parser.length - shell->parser.cursor; i > 0; i--) + { + shellWriteByte(shell, ' '); + } + shellDeleteCommandLine(shell, shell->parser.length); +} + + +/** + * @brief shell插入一个字符到光标位置 + * + * @param shell shell对象 + * @param data 字符数据 + */ +void shellInsertByte(Shell *shell, char data) +{ + /* 判断输入数据是否过长 */ + if (shell->parser.length >= shell->parser.bufferSize - 1) + { + shellWriteString(shell, shellText[SHELL_TEXT_CMD_TOO_LONG]); + shellWriteCommandLine(shell, 1); + shellWriteString(shell, shell->parser.buffer); + return; + } + + /* 插入数据 */ + if (shell->parser.cursor == shell->parser.length) + { + shell->parser.buffer[shell->parser.length++] = data; + shell->parser.buffer[shell->parser.length] = 0; + shell->parser.cursor++; + shellWriteByte(shell, data); + } + else if (shell->parser.cursor < shell->parser.length) + { + for (short i = shell->parser.length - shell->parser.cursor; i > 0; i--) + { + shell->parser.buffer[shell->parser.cursor + i] = + shell->parser.buffer[shell->parser.cursor + i - 1]; + } + shell->parser.buffer[shell->parser.cursor++] = data; + shell->parser.buffer[++shell->parser.length] = 0; + for (short i = shell->parser.cursor - 1; i < shell->parser.length; i++) + { + shellWriteByte(shell, shell->parser.buffer[i]); + } + for (short i = shell->parser.length - shell->parser.cursor; i > 0; i--) + { + shellWriteByte(shell, '\b'); + } + } +} + + +/** + * @brief shell 删除字节 + * + * @param shell shell对象 + * @param direction 删除方向 {@code 1}删除光标前字符 {@code -1}删除光标处字符 + */ +void shellDeleteByte(Shell *shell, signed char direction) +{ + char offset = (direction == -1) ? 1 : 0; + + if ((shell->parser.cursor == 0 && direction == 1) + || (shell->parser.cursor == shell->parser.length && direction == -1)) + { + return; + } + if (shell->parser.cursor == shell->parser.length && direction == 1) + { + shell->parser.cursor--; + shell->parser.length--; + shell->parser.buffer[shell->parser.length] = 0; + shellDeleteCommandLine(shell, 1); + } + else + { + for (short i = offset; i < shell->parser.length - shell->parser.cursor; i++) + { + shell->parser.buffer[shell->parser.cursor + i - 1] = + shell->parser.buffer[shell->parser.cursor + i]; + } + shell->parser.length--; + if (!offset) + { + shell->parser.cursor--; + shellWriteByte(shell, '\b'); + } + shell->parser.buffer[shell->parser.length] = 0; + for (short i = shell->parser.cursor; i < shell->parser.length; i++) + { + shellWriteByte(shell, shell->parser.buffer[i]); + } + shellWriteByte(shell, ' '); + for (short i = shell->parser.length - shell->parser.cursor + 1; i > 0; i--) + { + shellWriteByte(shell, '\b'); + } + } +} + + +/** + * @brief shell 解析参数 + * + * @param shell shell对象 + */ +static void shellParserParam(Shell *shell) +{ + unsigned char quotes = 0; + unsigned char record = 1; + + for (short i = 0; i < SHELL_PARAMETER_MAX_NUMBER; i++) + { + shell->parser.param[i] = NULL; + } + + shell->parser.paramCount = 0; + for (unsigned short i = 0; i < shell->parser.length; i++) + { + if (quotes != 0 + || (shell->parser.buffer[i] != ' ' + && shell->parser.buffer[i] != 0)) + { + if (shell->parser.buffer[i] == '\"') + { + quotes = quotes ? 0 : 1; + } + if (record == 1) + { + if (shell->parser.paramCount < SHELL_PARAMETER_MAX_NUMBER) + { + shell->parser.param[shell->parser.paramCount++] = + &(shell->parser.buffer[i]); + } + record = 0; + } + if (shell->parser.buffer[i] == '\\' + && shell->parser.buffer[i + 1] != 0) + { + i++; + } + } + else + { + shell->parser.buffer[i] = 0; + record = 1; + } + } +} + + +/** + * @brief shell去除字符串参数头尾的双引号 + * + * @param shell shell对象 + */ +static void shellRemoveParamQuotes(Shell *shell) +{ + unsigned short paramLength; + for (unsigned short i = 0; i < shell->parser.paramCount; i++) + { + if (shell->parser.param[i][0] == '\"') + { + shell->parser.param[i][0] = 0; + shell->parser.param[i] = &shell->parser.param[i][1]; + } + paramLength = strlen(shell->parser.param[i]); + if (shell->parser.param[i][paramLength - 1] == '\"') + { + shell->parser.param[i][paramLength - 1] = 0; + } + } +} + + +/** + * @brief shell匹配命令 + * + * @param shell shell对象 + * @param cmd 命令 + * @param base 匹配命令表基址 + * @param compareLength 匹配字符串长度 + * @return ShellCommand* 匹配到的命令 + */ +ShellCommand* shellSeekCommand(Shell *shell, + const char *cmd, + ShellCommand *base, + unsigned short compareLength) +{ + const char *name; + unsigned short count = shell->commandList.count - + ((long)base - (long)shell->commandList.base) / sizeof(ShellCommand); + for (unsigned short i = 0; i < count; i++) + { + if (base[i].attr.attrs.type == SHELL_TYPE_KEY + || shellCheckPermission(shell, &base[i]) != 0) + { + continue; + } + name = shellGetCommandName(&base[i]); + if (!compareLength) + { + if (strcmp(cmd, name) == 0) + { + return &base[i]; + } + } + else + { + if (strncmp(cmd, name, compareLength) == 0) + { + return &base[i]; + } + } + } + return NULL; +} + + +/** + * @brief shell 获取变量值 + * + * @param shell shell对象 + * @param command 命令 + * @return int 变量值 + */ +int shellGetVarValue(Shell *shell, ShellCommand *command) +{ + int value = 0; + switch (command->attr.attrs.type) + { + case SHELL_TYPE_VAR_INT: + value = *((int *)(command->data.var.value)); + break; + case SHELL_TYPE_VAR_SHORT: + value = *((short *)(command->data.var.value)); + break; + case SHELL_TYPE_VAR_CHAR: + value = *((char *)(command->data.var.value)); + break; + case SHELL_TYPE_VAR_STRING: + case SHELL_TYPE_VAR_POINT: + value = (long)(command->data.var.value); + break; + case SHELL_TYPE_VAR_NODE: + value = ((ShellNodeVarAttr *)command->data.var.value)->get ? + ((ShellNodeVarAttr *)command->data.var.value) + ->get(((ShellNodeVarAttr *)command->data.var.value)->var) : 0; + break; + default: + break; + } + return value; +} + + +/** + * @brief shell设置变量值 + * + * @param shell shell对象 + * @param command 命令 + * @param value 值 + * @return int 返回变量值 + */ +int shellSetVarValue(Shell *shell, ShellCommand *command, int value) +{ + if (command->attr.attrs.readOnly) + { + shellWriteString(shell, shellText[SHELL_TEXT_VAR_READ_ONLY_CANNOT_MODIFY]); + } + else + { + switch (command->attr.attrs.type) + { + case SHELL_TYPE_VAR_INT: + *((int *)(command->data.var.value)) = value; + break; + case SHELL_TYPE_VAR_SHORT: + *((short *)(command->data.var.value)) = value; + break; + case SHELL_TYPE_VAR_CHAR: + *((char *)(command->data.var.value)) = value; + break; + case SHELL_TYPE_VAR_STRING: + shellStringCopy(((char *)(command->data.var.value)), (char *)(unsigned long)value); + break; + case SHELL_TYPE_VAR_POINT: + shellWriteString(shell, shellText[SHELL_TEXT_POINT_CANNOT_MODIFY]); + break; + case SHELL_TYPE_VAR_NODE: + if (((ShellNodeVarAttr *)command->data.var.value)->set) + { + if (((ShellNodeVarAttr *)command->data.var.value)->var) + { + ((ShellNodeVarAttr *)command->data.var.value) + ->set(((ShellNodeVarAttr *)command->data.var.value)->var, value); + } + else + { + ((ShellNodeVarAttr *)command->data.var.value)->set(value); + } + } + break; + default: + break; + } + } + return shellShowVar(shell, command); +} + + +/** + * @brief shell变量输出 + * + * @param shell shell对象 + * @param command 命令 + * @return int 返回变量值 + */ +static int shellShowVar(Shell *shell, ShellCommand *command) +{ + char buffer[12] = "00000000000"; + int value = shellGetVarValue(shell, command); + + shellWriteString(shell, command->data.var.name); + shellWriteString(shell, " = "); + + switch (command->attr.attrs.type) + { + case SHELL_TYPE_VAR_STRING: + shellWriteString(shell, "\""); + shellWriteString(shell, (char *)(unsigned long)value); + shellWriteString(shell, "\""); + break; + // case SHELL_TYPE_VAR_INT: + // case SHELL_TYPE_VAR_SHORT: + // case SHELL_TYPE_VAR_CHAR: + // case SHELL_TYPE_VAR_POINT: + default: + shellWriteString(shell, &buffer[11 - shellToDec(value, buffer)]); + shellWriteString(shell, ", 0x"); + for (short i = 0; i < 11; i++) + { + buffer[i] = '0'; + } + shellToHex(value, buffer); + shellWriteString(shell, buffer); + break; + } + + shellWriteString(shell, "\r\n"); + return value; +} + + +/** + * @brief shell设置变量 + * + * @param name 变量名 + * @param value 变量值 + * @return int 返回变量值 + */ +int shellSetVar(char *name, int value) +{ + Shell *shell = shellGetCurrent(); + if (shell == NULL) + { + return 0; + } + ShellCommand *command = shellSeekCommand(shell, + name, + shell->commandList.base, + 0); + if (!command) + { + shellWriteString(shell, shellText[SHELL_TEXT_VAR_NOT_FOUND]); + return 0; + } + if (command->attr.attrs.type < SHELL_TYPE_VAR_INT + || command->attr.attrs.type > SHELL_TYPE_VAR_NODE) + { + shellWriteString(shell, name); + shellWriteString(shell, shellText[SHELL_TEXT_NOT_VAR]); + return 0; + } + return shellSetVarValue(shell, command, value); +} +SHELL_EXPORT_CMD( +SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_DISABLE_RETURN, +setVar, shellSetVar, set var); + + +/** + * @brief shell运行命令 + * + * @param shell shell对象 + * @param command 命令 + */ +static void shellRunCommand(Shell *shell, ShellCommand *command) +{ + int returnValue; + shell->status.isActive = 1; + if (command->attr.attrs.type == SHELL_TYPE_CMD_MAIN) + { + shellRemoveParamQuotes(shell); + returnValue = command->data.cmd.function(shell->parser.paramCount, + shell->parser.param); + if (!command->attr.attrs.disableReturn) + { + shellWriteReturnValue(shell, returnValue); + } + } + else if (command->attr.attrs.type == SHELL_TYPE_CMD_FUNC) + { + returnValue = shellExtRun(shell, + command, + shell->parser.paramCount, + shell->parser.param); + shell->lastRet = returnValue; /* 记录上一条命令执行的返回值 */ + if (!command->attr.attrs.disableReturn) + { + shellWriteReturnValue(shell, returnValue); + } + } + else if (command->attr.attrs.type >= SHELL_TYPE_VAR_INT + && command->attr.attrs.type <= SHELL_TYPE_VAR_NODE) + { + shellShowVar(shell, command); + } + else if (command->attr.attrs.type == SHELL_TYPE_USER) + { + shellSetUser(shell, command); + } + shell->status.isActive = 0; +} + + +/** + * @brief shell校验密码 + * + * @param shell shell对象 + */ +static void shellCheckPassword(Shell *shell) +{ + if (strcmp(shell->parser.buffer, shell->info.user->data.user.password) == 0) + { + shell->status.isChecked = 1; + #if SHELL_SHOW_INFO == 1 + shellWriteString(shell, shellText[SHELL_TEXT_INFO]); + #endif + } + else + { + shellWriteString(shell, shellText[SHELL_TEXT_PASSWORD_ERROR]); + } + shell->parser.length = 0; + shell->parser.cursor = 0; +} + + +/** + * @brief shell设置用户 + * + * @param shell shell对象 + * @param user 用户 + */ +static void shellSetUser(Shell *shell, const ShellCommand *user) +{ + shell->info.user = user; + shell->status.isChecked = + ((user->data.user.password && strlen(user->data.user.password) != 0) + && (shell->parser.paramCount < 2 + || strcmp(user->data.user.password, shell->parser.param[1]) != 0)) + ? 0 : 1; + +#if SHELL_CLS_WHEN_LOGIN == 1 + shellWriteString(shell, shellText[SHELL_TEXT_CLEAR_CONSOLE]); +#endif +#if SHELL_SHOW_INFO == 1 + if (shell->status.isChecked) + { + shellWriteString(shell, shellText[SHELL_TEXT_INFO]); + } +#endif +} + + +/** + * @brief shell写返回值 + * + * @param shell shell对象 + * @param value 返回值 + */ +static void shellWriteReturnValue(Shell *shell, int value) +{ + if (shell->slient && (0 == value)) //skip returen value print if 'silent' and no error + return; + + char buffer[12] = "00000000000"; + shellWriteString(shell, "Return: "); + shellWriteString(shell, &buffer[11 - shellToDec(value, buffer)]); + shellWriteString(shell, ", 0x"); + for (short i = 0; i < 11; i++) + { + buffer[i] = '0'; + } + shellToHex(value, buffer); + shellWriteString(shell, buffer); + shellWriteString(shell, "\r\n"); +} + + +/** + * @brief shell历史记录添加 + * + * @param shell shell对象 + */ +static void shellHistoryAdd(Shell *shell) +{ + shell->history.offset = 0; + if (shell->history.number > 0 + && strcmp(shell->history.item[(shell->history.record == 0 ? + SHELL_HISTORY_MAX_NUMBER : shell->history.record) - 1], + shell->parser.buffer) == 0) + { + return; + } + if (shellStringCopy(shell->history.item[shell->history.record], + shell->parser.buffer) != 0) + { + shell->history.record++; + } + if (++shell->history.number > SHELL_HISTORY_MAX_NUMBER) + { + shell->history.number = SHELL_HISTORY_MAX_NUMBER; + } + if (shell->history.record >= SHELL_HISTORY_MAX_NUMBER) + { + shell->history.record = 0; + } +} + + +/** + * @brief shell历史记录查找 + * + * @param shell shell对象 + * @param dir 方向 {@code <0}往上查找 {@code >0}往下查找 + */ +static void shellHistory(Shell *shell, signed char dir) +{ + if (dir > 0) + { + if (shell->history.offset-- <= + -((shell->history.number > shell->history.record) ? + shell->history.number : shell->history.record)) + { + shell->history.offset = -((shell->history.number > shell->history.record) + ? shell->history.number : shell->history.record); + } + } + else if (dir < 0) + { + if (++shell->history.offset > 0) + { + shell->history.offset = 0; + return; + } + } + else + { + return; + } + shellClearCommandLine(shell); + if (shell->history.offset == 0) + { + shell->parser.cursor = shell->parser.length = 0; + } + else + { + if ((shell->parser.length = shellStringCopy(shell->parser.buffer, + shell->history.item[(shell->history.record + SHELL_HISTORY_MAX_NUMBER + + shell->history.offset) % SHELL_HISTORY_MAX_NUMBER])) == 0) + { + return; + } + shell->parser.cursor = shell->parser.length; + shellWriteString(shell, shell->parser.buffer); + } + +} + + +/** + * @brief shell 常规输入 + * + * @param shell shell 对象 + * @param data 输入字符 + */ +void shellNormalInput(Shell *shell, char data) +{ + shell->status.tabFlag = 0; + shellInsertByte(shell, data); +} + + +/** + * @brief shell运行命令 + * + * @param shell shell对象 + */ +void shellExec(Shell *shell) +{ + + if (shell->parser.length == 0) + { + return; + } + + shell->parser.buffer[shell->parser.length] = 0; + + if (shell->status.isChecked) + { + shellHistoryAdd(shell); + shellParserParam(shell); + shell->parser.length = shell->parser.cursor = 0; + if (shell->parser.paramCount == 0) + { + return; + } + shellWriteString(shell, "\r\n"); + + ShellCommand *command = shellSeekCommand(shell, + shell->parser.param[0], + shell->commandList.base, + 0); + if (command != NULL) + { + shellRunCommand(shell, command); + } + else + { + shellWriteString(shell, shellText[SHELL_TEXT_CMD_NOT_FOUND]); + } + } + else + { + shellCheckPassword(shell); + } +} + + +/** + * @brief shell上方向键输入 + * + * @param shell shell对象 + */ +void shellUp(Shell *shell) +{ + shellHistory(shell, 1); +} +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0), 0x1B5B4100, shellUp, up); + + +/** + * @brief shell下方向键输入 + * + * @param shell shell对象 + */ +void shellDown(Shell *shell) +{ + shellHistory(shell, -1); +} +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0), 0x1B5B4200, shellDown, down); + + +/** + * @brief shell右方向键输入 + * + * @param shell shell对象 + */ +void shellRight(Shell *shell) +{ + if (shell->parser.cursor < shell->parser.length) + { + shellWriteByte(shell, shell->parser.buffer[shell->parser.cursor++]); + } +} +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0)|SHELL_CMD_ENABLE_UNCHECKED, +0x1B5B4300, shellRight, right); + + +/** + * @brief shell左方向键输入 + * + * @param shell shell对象 + */ +void shellLeft(Shell *shell) +{ + if (shell->parser.cursor > 0) + { + shellWriteByte(shell, '\b'); + shell->parser.cursor--; + } +} +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0)|SHELL_CMD_ENABLE_UNCHECKED, +0x1B5B4400, shellLeft, left); + + +/** + * @brief shell Tab按键处理 + * + * @param shell shell对象 + */ +void shellTab(Shell *shell) +{ + unsigned short maxMatch = shell->parser.bufferSize; + unsigned short lastMatchIndex = 0; + unsigned short matchNum = 0; + unsigned short length; + + if (shell->parser.length == 0) + { + shellListAll(shell); + shellWriteCommandLine(shell, 1); + } + else if (shell->parser.length > 0) + { + shell->parser.buffer[shell->parser.length] = 0; + ShellCommand *base = (ShellCommand *)shell->commandList.base; + for (unsigned long i = 0; i < shell->commandList.count; i++) + { + if (shellCheckPermission(shell, &base[i]) == 0 + && shellStringCompare(shell->parser.buffer, + (char *)shellGetCommandName(&base[i])) + == shell->parser.length) + { + if (matchNum != 0) + { + if (matchNum == 1) + { + shellWriteString(shell, "\r\n"); + } + shellListItem(shell, &base[lastMatchIndex]); + length = + shellStringCompare((char *)shellGetCommandName(&base[lastMatchIndex]), + (char *)shellGetCommandName(&base[i])); + maxMatch = (maxMatch > length) ? length : maxMatch; + } + lastMatchIndex = i; + matchNum++; + } + } + if (matchNum == 0) + { + return; + } + if (matchNum == 1) + { + shellClearCommandLine(shell); + } + if (matchNum != 0) + { + shell->parser.length = + shellStringCopy(shell->parser.buffer, + (char *)shellGetCommandName(&base[lastMatchIndex])); + } + if (matchNum > 1) + { + shellListItem(shell, &base[lastMatchIndex]); + shellWriteCommandLine(shell, 1); + shell->parser.length = maxMatch; + } + shell->parser.buffer[shell->parser.length] = 0; + shell->parser.cursor = shell->parser.length; + shellWriteString(shell, shell->parser.buffer); + } + + if (SHELL_GET_TICK()) + { + if (matchNum == 1 + && shell->status.tabFlag + && SHELL_GET_TICK() - shell->info.activeTime < SHELL_DOUBLE_CLICK_TIME) + { + shellClearCommandLine(shell); + for (short i = shell->parser.length; i >= 0; i--) + { + shell->parser.buffer[i + 5] = shell->parser.buffer[i]; + } + shellStringCopy(shell->parser.buffer, "help"); + shell->parser.buffer[4] = ' '; + shell->parser.length += 5; + shell->parser.cursor = shell->parser.length; + shellWriteString(shell, shell->parser.buffer); + } + else + { + shell->status.tabFlag = 1; + } + } +} +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0), 0x09000000, shellTab, tab); + + +/** + * @brief shell 退格 + * + * @param shell shell对象 + */ +void shellBackspace(Shell *shell) +{ + shellDeleteByte(shell, 1); +} +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0)|SHELL_CMD_ENABLE_UNCHECKED, +0x08000000, shellBackspace, backspace); +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0)|SHELL_CMD_ENABLE_UNCHECKED, +0x7F000000, shellBackspace, backspace); + + +/** + * @brief shell 删除 + * + * @param shell shell对象 + */ +void shellDelete(Shell *shell) +{ + shellDeleteByte(shell, -1); +} +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0)|SHELL_CMD_ENABLE_UNCHECKED, +0x1B5B337E, shellDelete, delete); + + +/** + * @brief shell 回车处理 + * + * @param shell shell对象 + */ +void shellEnter(Shell *shell) +{ + shellExec(shell); + shellWriteCommandLine(shell, 1); +} +#if SHELL_ENTER_LF == 1 +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0)|SHELL_CMD_ENABLE_UNCHECKED, +0x0A000000, shellEnter, enter); +#endif +#if SHELL_ENTER_CR == 1 +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0)|SHELL_CMD_ENABLE_UNCHECKED, +0x0D000000, shellEnter, enter); +#endif +#if SHELL_ENTER_CRLF == 1 +SHELL_EXPORT_KEY(SHELL_CMD_PERMISSION(0)|SHELL_CMD_ENABLE_UNCHECKED, +0x0D0A0000, shellEnter, enter); +#endif + +/** + * @brief shell help + * + * @param argc 参数个数 + * @param argv 参数 + */ +int shellHelp(int argc, char *argv[]) +{ + Shell *shell = shellGetCurrent(); + SHELL_ASSERT(shell, return 0); + if (argc == 1) + { + shellListAll(shell); + } + else if (argc > 1) + { + ShellCommand *command = shellSeekCommand(shell, + argv[1], + shell->commandList.base, + 0); + shellWriteString(shell, shellText[SHELL_TEXT_HELP_HEADER]); + shellWriteString(shell, shellGetCommandName(command)); + shellWriteString(shell, "\r\n"); + shellWriteString(shell, shellGetCommandDesc(command)); + shellWriteString(shell, "\r\n"); + } + + return 0; +} +SHELL_EXPORT_CMD( +SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_DISABLE_RETURN, +help, shellHelp, show command info\r\nhelp [cmd]); + +/** + * @brief shell 输入处理 + * + * @param shell shell对象 + * @param data 输入数据 + */ +void shellHandler(Shell *shell, char data) +{ + SHELL_ASSERT(data, return); + +#if SHELL_LOCK_TIMEOUT > 0 + if (shell->info.user->data.user.password + && strlen(shell->info.user->data.user.password) != 0 + && SHELL_GET_TICK()) + { + if (SHELL_GET_TICK() - shell->info.activeTime > SHELL_LOCK_TIMEOUT) + { + shell->status.isChecked = 0; + } + } +#endif + + /* 根据记录的按键键值计算当前字节在按键键值中的偏移 */ + char keyByteOffset = 24; + int keyFilter = 0x00000000; + if ((shell->parser.keyValue & 0x0000FF00) != 0x00000000) + { + keyByteOffset = 0; + keyFilter = 0xFFFFFF00; + } + else if ((shell->parser.keyValue & 0x00FF0000) != 0x00000000) + { + keyByteOffset = 8; + keyFilter = 0xFFFF0000; + } + else if ((shell->parser.keyValue & 0xFF000000) != 0x00000000) + { + keyByteOffset = 16; + keyFilter = 0xFF000000; + } + + /* 遍历ShellCommand列表,尝试进行按键键值匹配 */ + ShellCommand *base = (ShellCommand *)shell->commandList.base; + for (unsigned short i = 0; i < shell->commandList.count; i++) + { + /* 判断是否是按键定义并验证权限 */ + if (base[i].attr.attrs.type == SHELL_TYPE_KEY + && shellCheckPermission(shell, &(base[i])) == 0) + { + /* 对输入的字节同按键键值进行匹配 */ + if ((base[i].data.key.value & keyFilter) == shell->parser.keyValue + && (base[i].data.key.value & (0xFF << keyByteOffset)) + == (data << keyByteOffset)) + { + shell->parser.keyValue |= data << keyByteOffset; + data = 0x00; + if (keyByteOffset == 0 + || (base[i].data.key.value & (0xFF << (keyByteOffset - 8))) + == 0x00000000) + { + if (base[i].data.key.function) + { + base[i].data.key.function(shell); + } + shell->parser.keyValue = 0x00000000; + break; + } + } + } + } + + if (data != 0x00) + { + shell->parser.keyValue = 0x00000000; + shellNormalInput(shell, data); + } + + if (SHELL_GET_TICK()) + { + shell->info.activeTime = SHELL_GET_TICK(); + } +} + + +#if SHELL_SUPPORT_END_LINE == 1 +void shellWriteEndLine(Shell *shell, char *buffer, int len) +{ + shellWriteString(shell, shellText[SHELL_TEXT_CLEAR_LINE]); + while (len --) + { + shell->write(*buffer++); + } + shellWriteCommandLine(shell, 0); + if (shell->parser.length > 0) + { + shellWriteString(shell, shell->parser.buffer); + for (short i = 0; i < shell->parser.length - shell->parser.cursor; i++) + { + shell->write('\b'); + } + } +} +#endif /** SHELL_SUPPORT_END_LINE == 1 */ + + +/** + * @brief shell 任务 + * + * @param param 参数(shell对象) + * + */ +void shellTask(void *param) +{ + Shell *shell = (Shell *)param; + char data; +#if SHELL_TASK_WHILE == 1 + while(1) + { +#endif + if (shell->read && shell->read(&data) == 0) + { + shellHandler(shell, data); + } +#if SHELL_TASK_WHILE == 1 + } +#endif +} + + +/** + * @brief shell 输出用户列表(shell调用) + */ +void shellUsers(void) +{ + Shell *shell = shellGetCurrent(); + if (shell) + { + shellListUser(shell); + } +} +SHELL_EXPORT_CMD( +SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_DISABLE_RETURN, +users, shellUsers, list all user); + + +/** + * @brief shell 输出命令列表(shell调用) + */ +void shellCmds(void) +{ + Shell *shell = shellGetCurrent(); + if (shell) + { + shellListCommand(shell); + } +} +SHELL_EXPORT_CMD( +SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_DISABLE_RETURN, +cmds, shellCmds, list all cmd); + + +/** + * @brief shell 输出变量列表(shell调用) + */ +void shellVars(void) +{ + Shell *shell = shellGetCurrent(); + if (shell) + { + shellListVar(shell); + } +} +SHELL_EXPORT_CMD( +SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_DISABLE_RETURN, +vars, shellVars, list all var); + + +/** + * @brief shell 输出按键列表(shell调用) + */ +void shellKeys(void) +{ + Shell *shell = shellGetCurrent(); + if (shell) + { + shellListKey(shell); + } +} +SHELL_EXPORT_CMD( +SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_DISABLE_RETURN, +keys, shellKeys, list all key); + + +/** + * @brief shell 清空控制台(shell调用) + */ +void shellClear(void) +{ + Shell *shell = shellGetCurrent(); + if (shell) + { + shellWriteString(shell, shellText[SHELL_TEXT_CLEAR_CONSOLE]); + } +} +SHELL_EXPORT_CMD( +SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_DISABLE_RETURN, +clear, shellClear, clear console); + + +/** + * @brief shell执行命令 + * + * @param shell shell对象 + * @param cmd 命令字符串 + * @return int 返回值 + */ +int shellRun(Shell *shell, const char *cmd) +{ + SHELL_ASSERT(shell && cmd, return -1); + char active = shell->status.isActive; + if (strlen(cmd) > (size_t)shell->parser.bufferSize - 1) + { + shellWriteString(shell, shellText[SHELL_TEXT_CMD_TOO_LONG]); + return -1; + } + else + { + shell->parser.length = shellStringCopy(shell->parser.buffer, (char *)cmd); + shellExec(shell); + shell->status.isActive = active; + return 0; + } +} + + +#if SHELL_EXEC_UNDEF_FUNC == 1 +/** + * @brief shell执行未定义函数 + * + * @param argc 参数个数 + * @param argv 参数 + * @return int 返回值 + */ +int shellExecute(int argc, char *argv[]) +{ + Shell *shell = shellGetCurrent(); + if (shell && argc >= 2) + { + int (*func)() = (int (*)())shellExtParsePara(shell, argv[1]); + shellPrint(shell, "%08x\r\n", func); + ShellCommand command = { + .attr.value = SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) + |SHELL_CMD_DISABLE_RETURN, + .data.cmd.function = func, + }; + return shellExtRun(shell, &command, argc - 1, &argv[1]); + } + else + { + shellWriteString(shell, shellText[SHELL_TEXT_PARAM_ERROR]); + return -1; + } +} +SHELL_EXPORT_CMD( +SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN)|SHELL_CMD_DISABLE_RETURN, +exec, shellExecute, execute function undefined); +#endif diff --git a/third-party/letter-shell-3.1/src/shell.h b/third-party/letter-shell-3.1/src/shell.h new file mode 100644 index 0000000000000000000000000000000000000000..9983f1e3670244faf4d6532d3826f7d14a0fd3c8 --- /dev/null +++ b/third-party/letter-shell-3.1/src/shell.h @@ -0,0 +1,434 @@ +/** + * @file shell.h + * @author Letter (NevermindZZT@gmail.com) + * @brief letter shell + * @version 3.0.0 + * @date 2019-12-30 + * + * @copyright (c) 2020 Letter + * + */ + +#ifndef __SHELL_H__ +#define __SHELL_H__ + +#include "shell_cfg.h" + +#define SHELL_VERSION "3.0.5" /**< 版本号 */ + +/** + * @brief shell 断言 + * + * @param expr 表达式 + * @param action 断言失败操作 + */ +#define SHELL_ASSERT(expr, action) \ + if (!(expr)) \ + { \ + action; \ + } + +/** + * @brief shell 命令权限 + * + * @param permission 权限级别 + */ +#define SHELL_CMD_PERMISSION(permission) \ + (permission & 0x000000FF) + +/** + * @brief shell 命令类型 + * + * @param type 类型 + */ +#define SHELL_CMD_TYPE(type) \ + ((type & 0x0000000F) << 8) + +/** + * @brief 使能命令在未校验密码的情况下使用 + */ +#define SHELL_CMD_ENABLE_UNCHECKED \ + (1 << 12) + +/** + * @brief 禁用返回值打印 + */ +#define SHELL_CMD_DISABLE_RETURN \ + (1 << 13) + +/** + * @brief 只读属性(仅对变量生效) + */ +#define SHELL_CMD_READ_ONLY \ + (1 << 14) + +/** + * @brief 命令参数数量 + */ +#define SHELL_CMD_PARAM_NUM(num) \ + ((num & 0x0000000F)) << 16 + +#ifndef SECTION +#if defined(__CC_ARM) || (defined(__ARMCC_VERSION) && __ARMCC_VERSION >= 6000000) +#define SECTION(x) __attribute__((used, section(x))) +#elif defined(__ICCARM__) || defined(__ICCRX__) +#define SECTION(x) @x +#elif defined(__GNUC__) +#define SECTION(x) __attribute__((section(x))) +#else +#define SECTION(x) +#endif +#endif + +/** + * @brief shell float型参数转换 + */ +#define SHELL_PARAM_FLOAT(x) (*(float *)(&x)) + +/** + * @brief shell 代理函数名 + */ +#define SHELL_AGENCY_FUNC_NAME(_func) agency##_func + +/** + * @brief shell代理函数定义 + * + * @param _func 被代理的函数 + * @param ... 代理参数 + */ +#define SHELL_AGENCY_FUNC(_func, ...) \ + void SHELL_AGENCY_FUNC_NAME(_func)(int p1, int p2, int p3, int p4, int p5, int p6, int p7) \ + { \ + _func(__VA_ARGS__); \ + } + +#if SHELL_USING_CMD_EXPORT == 1 + +/** + * @brief shell 命令定义 + * + * @param _attr 命令属性 + * @param _name 命令名 + * @param _func 命令函数 + * @param _desc 命令描述 + */ +#define SHELL_EXPORT_CMD(_attr, _name, _func, _desc) \ + const char shellCmd##_name[] = #_name; \ + const char shellDesc##_name[] = #_desc; \ + const ShellCommand \ + shellCommand##_name SECTION("shellCommand") = \ + { \ + .attr.value = _attr, \ + .data.cmd.name = shellCmd##_name, \ + .data.cmd.function = (int (*)())_func, \ + .data.cmd.desc = shellDesc##_name} + +/** + * @brief shell 代理命令定义 + * + * @param _attr 命令属性 + * @param _name 命令名 + * @param _func 命令函数 + * @param _desc 命令描述 + * @param ... 代理参数 + */ +#define SHELL_EXPORT_CMD_AGENCY(_attr, _name, _func, _desc, ...) \ + SHELL_AGENCY_FUNC(_func, ##__VA_ARGS__) \ + SHELL_EXPORT_CMD(_attr, _name, SHELL_AGENCY_FUNC_NAME(_func), _desc) + +/** + * @brief shell 变量定义 + * + * @param _attr 变量属性 + * @param _name 变量名 + * @param _value 变量值 + * @param _desc 变量描述 + */ +#define SHELL_EXPORT_VAR(_attr, _name, _value, _desc) \ + const char shellCmd##_name[] = #_name; \ + const char shellDesc##_name[] = #_desc; \ + const ShellCommand \ + shellVar##_name SECTION("shellCommand") = \ + { \ + .attr.value = _attr, \ + .data.var.name = shellCmd##_name, \ + .data.var.value = (void *)_value, \ + .data.var.desc = shellDesc##_name} + +/** + * @brief shell 用户定义 + * + * @param _attr 用户属性 + * @param _name 用户名 + * @param _password 用户密码 + * @param _desc 用户描述 + */ +#define SHELL_EXPORT_USER(_attr, _name, _password, _desc) \ + const char shellCmd##_name[] = #_name; \ + const char shellPassword##_name[] = #_password; \ + const char shellDesc##_name[] = #_desc; \ + const ShellCommand \ + shellUser##_name SECTION("shellCommand") = \ + { \ + .attr.value = _attr | SHELL_CMD_TYPE(SHELL_TYPE_USER), \ + .data.user.name = shellCmd##_name, \ + .data.user.password = shellPassword##_name, \ + .data.user.desc = shellDesc##_name} + +/** + * @brief shell 按键定义 + * + * @param _attr 按键属性 + * @param _value 按键键值 + * @param _func 按键函数 + * @param _desc 按键描述 + */ +#define SHELL_EXPORT_KEY(_attr, _value, _func, _desc) \ + const char shellDesc##_value[] = #_desc; \ + const ShellCommand \ + shellKey##_value SECTION("shellCommand") = \ + { \ + .attr.value = _attr | SHELL_CMD_TYPE(SHELL_TYPE_KEY), \ + .data.key.value = _value, \ + .data.key.function = (void (*)(Shell *))_func, \ + .data.key.desc = shellDesc##_value} + +/** + * @brief shell 代理按键定义 + * + * @param _attr 按键属性 + * @param _value 按键键值 + * @param _func 按键函数 + * @param _desc 按键描述 + * @param ... 代理参数 + */ +#define SHELL_EXPORT_KEY_AGENCY(_attr, _value, _func, _desc, ...) \ + SHELL_AGENCY_FUNC(_func, ##__VA_ARGS__) \ + SHELL_EXPORT_KEY(_attr, _value, SHELL_AGENCY_FUNC_NAME(_func), _desc) +#else +/** + * @brief shell 命令item定义 + * + * @param _attr 命令属性 + * @param _name 命令名 + * @param _func 命令函数 + * @param _desc 命令描述 + */ +#define SHELL_CMD_ITEM(_attr, _name, _func, _desc) \ + { \ + .attr.value = _attr, \ + .data.cmd.name = #_name, \ + .data.cmd.function = (int (*)())_func, \ + .data.cmd.desc = #_desc \ + } + +/** + * @brief shell 变量item定义 + * + * @param _attr 变量属性 + * @param _name 变量名 + * @param _value 变量值 + * @param _desc 变量描述 + */ +#define SHELL_VAR_ITEM(_attr, _name, _value, _desc) \ + { \ + .attr.value = _attr, \ + .data.var.name = #_name, \ + .data.var.value = (void *)_value, \ + .data.var.desc = #_desc \ + } + +/** + * @brief shell 用户item定义 + * + * @param _attr 用户属性 + * @param _name 用户名 + * @param _password 用户密码 + * @param _desc 用户描述 + */ +#define SHELL_USER_ITEM(_attr, _name, _password, _desc) \ + { \ + .attr.value = _attr | SHELL_CMD_TYPE(SHELL_TYPE_USER), \ + .data.user.name = #_name, \ + .data.user.password = #_password, \ + .data.user.desc = #_desc \ + } + +/** + * @brief shell 按键item定义 + * + * @param _attr 按键属性 + * @param _value 按键键值 + * @param _func 按键函数 + * @param _desc 按键描述 + */ +#define SHELL_KEY_ITEM(_attr, _value, _func, _desc) \ + { \ + .attr.value = _attr | SHELL_CMD_TYPE(SHELL_TYPE_KEY), \ + .data.key.value = _value, \ + .data.key.function = (void (*)(Shell *))_func, \ + .data.key.desc = #_desc \ + } + +#define SHELL_EXPORT_CMD(_attr, _name, _func, _desc) +#define SHELL_EXPORT_CMD_AGENCY(_attr, _name, _func, _desc, ...) +#define SHELL_EXPORT_VAR(_attr, _name, _value, _desc) +#define SHELL_EXPORT_USER(_attr, _name, _password, _desc) +#define SHELL_EXPORT_KEY(_attr, _value, _func, _desc) +#define SHELL_EXPORT_KEY_AGENCY(_attr, _name, _func, _desc, ...) +#endif /** SHELL_USING_CMD_EXPORT == 1 */ + +/** + * @brief shell command类型 + */ +typedef enum +{ + SHELL_TYPE_CMD_MAIN = 0, /**< main形式命令 */ + SHELL_TYPE_CMD_FUNC, /**< C函数形式命令 */ + SHELL_TYPE_VAR_INT, /**< int型变量 */ + SHELL_TYPE_VAR_SHORT, /**< short型变量 */ + SHELL_TYPE_VAR_CHAR, /**< char型变量 */ + SHELL_TYPE_VAR_STRING, /**< string型变量 */ + SHELL_TYPE_VAR_POINT, /**< 指针型变量 */ + SHELL_TYPE_VAR_NODE, /**< 节点变量 */ + SHELL_TYPE_USER, /**< 用户 */ + SHELL_TYPE_KEY, /**< 按键 */ +} ShellCommandType; + +/** + * @brief Shell定义 + */ +typedef struct shell_def +{ + struct + { + const struct shell_command *user; /**< 当前用户 */ + int activeTime; /**< shell激活时间 */ + char *path; /**< 当前shell路径 */ +#if SHELL_USING_COMPANION == 1 + struct shell_companion_object *companions; /**< 伴生对象 */ +#endif + } info; + struct + { + unsigned short length; /**< 输入数据长度 */ + unsigned short cursor; /**< 当前光标位置 */ + char *buffer; /**< 输入缓冲 */ + char *param[SHELL_PARAMETER_MAX_NUMBER]; /**< 参数 */ + unsigned short bufferSize; /**< 输入缓冲大小 */ + unsigned short paramCount; /**< 参数数量 */ + int keyValue; /**< 输入按键键值 */ + } parser; + struct + { + char *item[SHELL_HISTORY_MAX_NUMBER]; /**< 历史记录 */ + unsigned short number; /**< 历史记录数 */ + unsigned short record; /**< 当前记录位置 */ + signed short offset; /**< 当前历史记录偏移 */ + } history; + struct + { + void *base; /**< 命令表基址 */ + unsigned /*short*/ long count; /**< 命令数量 */ + } commandList; + struct + { + unsigned char isChecked : 1; /**< 密码校验通过 */ + unsigned char isActive : 1; /**< 当前活动Shell */ + unsigned char tabFlag : 1; /**< tab标志 */ + } status; + signed char (*read)(char *); /**< shell读函数 */ + void (*write)(const char); /**< shell写函数 */ + int lastRet; /**< 上一条cmd的返回值 */ + //int lastResult; /**< 上一条cmd的传回的值 */ + unsigned char slient; /**< 执行cmd时尽可能减少打印 */ +} Shell; + +/** + * @brief shell command定义 + */ +typedef struct shell_command +{ + union + { + struct + { + unsigned char permission : 8; /**< command权限 */ + ShellCommandType type : 4; /**< command类型 */ + unsigned char enableUnchecked : 1; /**< 在未校验密码的情况下可用 */ + unsigned char disableReturn : 1; /**< 禁用返回值输出 */ + unsigned char readOnly : 1; /**< 只读 */ + unsigned char reserve : 1; /**< 保留 */ + unsigned char paramNum : 4; /**< 参数数量 */ + } attrs; + int value; + } attr; /**< 属性 */ + union + { + struct + { + const char *name; /**< 命令名 */ + int (*function)(); /**< 命令执行函数 */ + const char *desc; /**< 命令描述 */ + } cmd; /**< 命令定义 */ + struct + { + const char *name; /**< 变量名 */ + void *value; /**< 变量值 */ + const char *desc; /**< 变量描述 */ + } var; /**< 变量定义 */ + struct + { + const char *name; /**< 用户名 */ + const char *password; /**< 用户密码 */ + const char *desc; /**< 用户描述 */ + } user; /**< 用户定义 */ + struct + { + int value; /**< 按键键值 */ + void (*function)(Shell *); /**< 按键执行函数 */ + const char *desc; /**< 按键描述 */ + } key; /**< 按键定义 */ + } data; +} ShellCommand; + +/** + * @brief shell节点变量属性 + */ +typedef struct +{ + void *var; /**< 变量引用 */ + int (*get)(); /**< 变量get方法 */ + int (*set)(); /**< 变量set方法 */ +} ShellNodeVarAttr; + +#define shellSetPath(_shell, _path) (_shell)->info.path = _path +#define shellGetPath(_shell) ((_shell)->info.path) + +void shellInit(Shell *shell, char *buffer, unsigned short size); +unsigned short shellWriteString(Shell *shell, const char *string); +void shellPrint(Shell *shell, char *fmt, ...); +Shell *shellGetCurrent(void); +void shellHandler(Shell *shell, char data); +void shellWriteEndLine(Shell *shell, char *buffer, int len); +void shellTask(void *param); +int shellRun(Shell *shell, const char *cmd); +void shellWriteVersion(Shell *shell); + +#if SHELL_USING_COMPANION == 1 +/** + * @brief shell伴生对象定义 + */ +typedef struct shell_companion_object +{ + int id; /**< 伴生对象ID */ + void *obj; /**< 伴生对象 */ + struct shell_companion_object *next; /**< 下一个伴生对象 */ +} ShellCompanionObj; + +signed char shellCompanionAdd(Shell *shell, int id, void *object); +signed char shellCompanionDel(Shell *shell, int id); +void *shellCompanionGet(Shell *shell, int id); +#endif + +#endif diff --git a/third-party/letter-shell-3.1/src/shell_cfg.h b/third-party/letter-shell-3.1/src/shell_cfg.h new file mode 100644 index 0000000000000000000000000000000000000000..bc9835259f88a2eb6d98a34c14d2a74a21ed6955 --- /dev/null +++ b/third-party/letter-shell-3.1/src/shell_cfg.h @@ -0,0 +1,161 @@ +/** + * @file shell_cfg.h + * @author Letter (nevermindzzt@gmail.com) + * @brief shell config + * @version 3.0.0 + * @date 2019-12-31 + * + * @copyright (c) 2019 Letter + * + */ + +#ifndef __SHELL_CFG_H__ +#define __SHELL_CFG_H__ + +/** + * @brief 是否使用默认shell任务while循环,使能宏`SHELL_USING_TASK`后此宏有意义 + * 使能此宏,则`shellTask()`函数会一直循环读取输入,一般使用操作系统建立shell + * 任务时使能此宏,关闭此宏的情况下,一般适用于无操作系统,在主循环中调用`shellTask()` + */ +#define SHELL_TASK_WHILE 0 + +/** + * @brief 是否使用命令导出方式 + * 使能此宏后,可以使用`SHELL_EXPORT_CMD()`等导出命令 + * 定义shell命令,关闭此宏的情况下,需要使用命令表的方式 + */ +#define SHELL_USING_CMD_EXPORT 1 + +/** + * @brief 是否使用shell伴生对象 + * 一些扩展的组件(文件系统支持,日志工具等)需要使用伴生对象 + */ +#define SHELL_USING_COMPANION 0 + +/** + * @brief 支持shell尾行模式 + */ +#define SHELL_SUPPORT_END_LINE 1 + +/** + * @brief 是否在输出命令列表中列出用户 + */ +#define SHELL_HELP_LIST_USER 0 + +/** + * @brief 是否在输出命令列表中列出变量 + */ +#define SHELL_HELP_LIST_VAR 0 + +/** + * @brief 是否在输出命令列表中列出按键 + */ +#define SHELL_HELP_LIST_KEY 0 + +/** + * @brief 是否在输出命令列表中展示命令权限 + */ +#define SHELL_HELP_SHOW_PERMISSION 1 + +/** + * @brief 使用LF作为命令行回车触发 + * 可以和SHELL_ENTER_CR同时开启 + */ +#define SHELL_ENTER_LF 0 + +/** + * @brief 使用CR作为命令行回车触发 + * 可以和SHELL_ENTER_LF同时开启 + */ +#define SHELL_ENTER_CR 1 + +/** + * @brief 使用CRLF作为命令行回车触发 + * 不可以和SHELL_ENTER_LF或SHELL_ENTER_CR同时开启 + */ +#define SHELL_ENTER_CRLF 0 + +/** + * @brief 使用执行未导出函数的功能 + * 启用后,可以通过`exec [addr] [args]`直接执行对应地址的函数 + * @attention 如果地址错误,可能会直接引起程序崩溃 + */ +#define SHELL_EXEC_UNDEF_FUNC 0 + +/** + * @brief shell命令参数最大数量 + * 包含命令名在内,超过8个参数并且使用了参数自动转换的情况下,需要修改源码 + */ +#define SHELL_PARAMETER_MAX_NUMBER 8 + +/** + * @brief 历史命令记录数量 + */ +#define SHELL_HISTORY_MAX_NUMBER 10 + +/** + * @brief 双击间隔(ms) + * 使能宏`SHELL_LONG_HELP`后此宏生效,定义双击tab补全help的时间间隔 + */ +#define SHELL_DOUBLE_CLICK_TIME 200 + +/** + * @brief 管理的最大shell数量 + */ +#define SHELL_MAX_NUMBER 5 + +/** + * @brief shell格式化输出的缓冲大小 + * 为0时不使用shell格式化输出 + */ +#define SHELL_PRINT_BUFFER 128 + +/** + * @brief 获取系统时间(ms) + * 定义此宏为获取系统Tick,如`HAL_GetTick()` + * @note 此宏不定义时无法使用双击tab补全命令help,无法使用shell超时锁定 + */ +#define SHELL_GET_TICK() 0 + +/** + * @brief shell内存分配 + * shell本身不需要此接口,若使用shell伴生对象,需要进行定义 + */ +#define SHELL_MALLOC(size) 0 + +/** + * @brief shell内存释放 + * shell本身不需要此接口,若使用shell伴生对象,需要进行定义 + */ +#define SHELL_FREE(obj) 0 + +/** + * @brief 是否显示shell信息 + */ +#define SHELL_SHOW_INFO 1 + +/** + * @brief 是否在登录后清除命令行 + */ +#define SHELL_CLS_WHEN_LOGIN 1 + +/** + * @brief shell默认用户 + */ +#define SHELL_DEFAULT_USER "phytium" + +/** + * @brief shell默认用户密码 + * 若默认用户不需要密码,设为"" + */ +#define SHELL_DEFAULT_USER_PASSWORD "" + +/** + * @brief shell自动锁定超时 + * shell当前用户密码有效的时候生效,超时后会自动重新锁定shell + * 设置为0时关闭自动锁定功能,时间单位为`SHELL_GET_TICK()`单位 + * @note 使用超时锁定必须保证`SHELL_GET_TICK()`有效 + */ +#define SHELL_LOCK_TIMEOUT 0 * 60 * 1000 + +#endif diff --git a/third-party/letter-shell-3.1/src/shell_cmd_list.c b/third-party/letter-shell-3.1/src/shell_cmd_list.c new file mode 100644 index 0000000000000000000000000000000000000000..74a7f56710ffcdf209643e2c98b3e7ff03f4b193 --- /dev/null +++ b/third-party/letter-shell-3.1/src/shell_cmd_list.c @@ -0,0 +1,100 @@ +/** + * @file shell_cmd_list.c + * @author Letter (NevermindZZT@gmail.com) + * @brief shell cmd list + * @version 3.0.0 + * @date 2020-01-17 + * + * @copyright (c) 2020 Letter + * + */ + +#include "shell.h" + +#if SHELL_USING_CMD_EXPORT != 1 + +extern int shellSetVar(char *name, int value); +extern void shellUp(Shell *shell); +extern void shellDown(Shell *shell); +extern void shellRight(Shell *shell); +extern void shellLeft(Shell *shell); +extern void shellTab(Shell *shell); +extern void shellBackspace(Shell *shell); +extern void shellDelete(Shell *shell); +extern void shellEnter(Shell *shell); +extern int shellHelp(int argc, char *argv[]); +extern void shellUsers(void); +extern void shellCmds(void); +extern void shellVars(void); +extern void shellKeys(void); +extern void shellClear(void); +#if SHELL_EXEC_UNDEF_FUNC == 1 +extern int shellExecute(int argc, char *argv[]); +#endif + +SHELL_AGENCY_FUNC(shellRun, shellGetCurrent(), (const char *)p1); + +/** + * @brief shell命令表 + * + */ +const ShellCommand shellCommandList[] = + { + {.attr.value = SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_USER), + .data.user.name = SHELL_DEFAULT_USER, + .data.user.password = SHELL_DEFAULT_USER_PASSWORD, + .data.user.desc = "default user"}, + SHELL_CMD_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), + setVar, shellSetVar, set var), + SHELL_KEY_ITEM(SHELL_CMD_PERMISSION(0), 0x1B5B4100, shellUp, up), + SHELL_KEY_ITEM(SHELL_CMD_PERMISSION(0), 0x1B5B4200, shellDown, down), + SHELL_KEY_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_ENABLE_UNCHECKED, + 0x1B5B4300, shellRight, right), + SHELL_KEY_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_ENABLE_UNCHECKED, + 0x1B5B4400, shellLeft, left), + SHELL_KEY_ITEM(SHELL_CMD_PERMISSION(0), 0x09000000, shellTab, tab), + SHELL_KEY_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_ENABLE_UNCHECKED, + 0x08000000, shellBackspace, backspace), + SHELL_KEY_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_ENABLE_UNCHECKED, + 0x7F000000, shellDelete, delete), + SHELL_KEY_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_ENABLE_UNCHECKED, + 0x1B5B337E, shellDelete, delete), +#if SHELL_ENTER_LF == 1 + SHELL_KEY_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_ENABLE_UNCHECKED, + 0x0A000000, shellEnter, enter), +#endif +#if SHELL_ENTER_CR == 1 + SHELL_KEY_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_ENABLE_UNCHECKED, + 0x0D000000, shellEnter, enter), +#endif +#if SHELL_ENTER_CRLF == 1 + SHELL_KEY_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_ENABLE_UNCHECKED, + 0x0D0A0000, shellEnter, enter), +#endif + SHELL_CMD_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_DISABLE_RETURN, + help, shellHelp, show command info\r\nhelp[cmd]), + SHELL_CMD_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_DISABLE_RETURN, + users, shellUsers, list all user), + SHELL_CMD_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_DISABLE_RETURN, + cmds, shellCmds, list all cmd), + SHELL_CMD_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_DISABLE_RETURN, + vars, shellVars, list all var), + SHELL_CMD_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_DISABLE_RETURN, + keys, shellKeys, list all key), + SHELL_CMD_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_DISABLE_RETURN, + clear, shellClear, clear console), + SHELL_CMD_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC) | SHELL_CMD_DISABLE_RETURN, + sh, SHELL_AGENCY_FUNC_NAME(shellRun), run command directly), +#if SHELL_EXEC_UNDEF_FUNC == 1 + SHELL_CMD_ITEM(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_DISABLE_RETURN, + exec, shellExecute, execute function undefined), +#endif +}; + +/** + * @brief shell命令表大小 + * + */ +const unsigned short shellCommandCount = sizeof(shellCommandList) / sizeof(ShellCommand); + +#endif diff --git a/third-party/letter-shell-3.1/src/shell_companion.c b/third-party/letter-shell-3.1/src/shell_companion.c new file mode 100644 index 0000000000000000000000000000000000000000..eb494c7c5dbf3605f5bf0a008aa3b97be015900f --- /dev/null +++ b/third-party/letter-shell-3.1/src/shell_companion.c @@ -0,0 +1,87 @@ +/** + * @file shell_companion.c + * @author Letter (nevermindzzt@gmail.com) + * @brief shell companion object support + * @version 3.0.3 + * @date 2020-07-22 + * + * @copyright (c) 2020 Letter + * + */ + #include "shell.h" + +#if SHELL_USING_COMPANION == 1 +/** + * @brief shell添加伴生对象 + * + * @param shell shell对象 + * @param id 伴生对象ID + * @param object 伴生对象 + * @return signed char 0 添加成功 -1 添加失败 + */ +signed char shellCompanionAdd(Shell *shell, int id, void *object) +{ + ShellCompanionObj *companions = shell->info.companions; + ShellCompanionObj *node = SHELL_MALLOC(sizeof(ShellCompanionObj)); + SHELL_ASSERT(node, return -1); + node->id = id; + node->obj = object; + node->next = companions; + shell->info.companions = node; + return 0; +} + +/** + * @brief shell删除伴生对象 + * + * @param shell shell对象 + * @param id 伴生对象ID + * @return signed char 0 删除成功 -1 无匹配对象 + */ +signed char shellCompanionDel(Shell *shell, int id) +{ + ShellCompanionObj *companions = shell->info.companions; + ShellCompanionObj *front = companions; + while (companions) + { + if (companions->id == id) + { + if (companions == shell->info.companions && !(companions->next)) + { + shell->info.companions = (void *)0; + } + else + { + front->next = companions->next; + } + SHELL_FREE(companions); + return 0; + } + front = companions; + companions = companions->next; + } + return -1; +} + +/** + * @brief shell获取伴生对象 + * + * @param shell shell对象 + * @param id 伴生对象ID + * @return void* 伴生对象,无匹配对象时返回NULL + */ +void *shellCompanionGet(Shell *shell, int id) +{ + SHELL_ASSERT(shell, return (void *)0); + ShellCompanionObj *companions = shell->info.companions; + while (companions) + { + if (companions->id == id) + { + return companions->obj; + } + companions = companions->next; + } + return (void *)0; +} +#endif /** SHELL_USING_COMPANION == 1 */ diff --git a/third-party/letter-shell-3.1/src/shell_ext.c b/third-party/letter-shell-3.1/src/shell_ext.c new file mode 100644 index 0000000000000000000000000000000000000000..1d04192618610b29d3323c082db43023a83e05ed --- /dev/null +++ b/third-party/letter-shell-3.1/src/shell_ext.c @@ -0,0 +1,351 @@ +/** + * @file shell_ext.c + * @author Letter (NevermindZZT@gmail.com) + * @brief shell extensions + * @version 3.0.0 + * @date 2019-12-31 + * + * @copyright (c) 2019 Letter + * + */ + +#include "shell_cfg.h" +#include "shell.h" +#include "shell_ext.h" + + +extern ShellCommand* shellSeekCommand(Shell *shell, + const char *cmd, + ShellCommand *base, + unsigned short compareLength); +extern int shellGetVarValue(Shell *shell, ShellCommand *command); + +/** + * @brief 判断数字进制 + * + * @param string 参数字符串 + * @return NUM_Type 进制 + */ +static NUM_Type shellExtNumType(char *string) +{ + char *p = string; + NUM_Type type = NUM_TYPE_INT; + + if ((*p == '0') && ((*(p + 1) == 'x') || (*(p + 1) == 'X'))) + { + type = NUM_TYPE_HEX; + } + else if ((*p == '0') && ((*(p + 1) == 'b') || (*(p + 1) == 'B'))) + { + type = NUM_TYPE_BIN; + } + else if (*p == '0') + { + type = NUM_TYPE_OCT; + } + + while (*p++) + { + if (*p == '.' && *(p + 1) != 0) + { + type = NUM_TYPE_FLOAT; + break; + } + } + + return type; +} + + +/** + * @brief 字符转数字 + * + * @param code 字符 + * @return char 数字 + */ +static char shellExtToNum(char code) +{ + if ((code >= '0') && (code <= '9')) + { + return code -'0'; + } + else if ((code >= 'a') && (code <= 'f')) + { + return code - 'a' + 10; + } + else if ((code >= 'A') && (code <= 'F')) + { + return code - 'A' + 10; + } + else + { + return 0; + } +} + + +/** + * @brief 解析字符参数 + * + * @param string 字符串参数 + * @return char 解析出的字符 + */ +static char shellExtParseChar(char *string) +{ + char *p = string + 1; + char value = 0; + + if (*p == '\\') + { + switch (*(p + 1)) + { + case 'b': + value = '\b'; + break; + case 'r': + value = '\r'; + break; + case 'n': + value = '\n'; + break; + case 't': + value = '\t'; + break; + case '0': + value = 0; + break; + default: + value = *(p + 1); + break; + } + } + else + { + value = *p; + } + return value; +} + + +/** + * @brief 解析字符串参数 + * + * @param string 字符串参数 + * @return char* 解析出的字符串 + */ +static char* shellExtParseString(char *string) +{ + char *p = string; + unsigned short index = 0; + + if (*string == '\"') + { + p = ++string; + } + + while (*p) + { + if (*p == '\\') + { + *(string + index) = shellExtParseChar(p - 1); + p++; + } + else if (*p == '\"') + { + *(string + index) = 0; + } + else + { + *(string + index) = *p; + } + p++; + index ++; + } + *(string + index) = 0; + return string; +} + + +/** + * @brief 解析数字参数 + * + * @param string 字符串参数 + * @return unsigned int 解析出的数字 + */ +static unsigned int shellExtParseNumber(char *string) +{ + NUM_Type type = NUM_TYPE_INT; + char radix = 10; + char *p = string; + char offset = 0; + signed char sign = 1; + unsigned int valueInt = 0; + float valueFloat = 0.0; + unsigned int devide = 0; + + if (*string == '-') + { + sign = -1; + } + + type = shellExtNumType(string + ((sign == -1) ? 1 : 0)); + + switch ((char)type) + { + case NUM_TYPE_HEX: + radix = 16; + offset = 2; + break; + + case NUM_TYPE_OCT: + radix = 8; + offset = 1; + break; + + case NUM_TYPE_BIN: + radix = 2; + offset = 2; + break; + + default: + break; + } + + p = string + offset + ((sign == -1) ? 1 : 0); + + while (*p) + { + if (*p == '.') + { + devide = 1; + p++; + continue; + } + valueInt = valueInt * radix + shellExtToNum(*p); + devide *= 10; + p++; + } + if (type == NUM_TYPE_FLOAT && devide != 0) + { + valueFloat = (float)valueInt / devide * sign; + return *(unsigned int *)(&valueFloat); + } + else + { + return valueInt * sign; + } +} + + +/** + * @brief 解析变量参数 + * + * @param shell shell对象 + * @param var 变量 + * @return unsigned int 变量值 + */ +static unsigned int shellExtParseVar(Shell *shell, char *var) +{ + ShellCommand *command = shellSeekCommand(shell, + var + 1, + shell->commandList.base, + 0); + if (command) + { + return shellGetVarValue(shell, command); + } + else + { + return 0; + } +} + + +/** + * @brief 解析参数 + * + * @param shell shell对象 + * @param string 参数 + * @return unsigned int 解析结果 + */ +unsigned int shellExtParsePara(Shell *shell, char *string) +{ + if (*string == '\'' && *(string + 1)) + { + return (unsigned int)shellExtParseChar(string); + } + else if (*string == '-' || (*string >= '0' && *string <= '9')) + { + return (unsigned int)shellExtParseNumber(string); + } + else if (*string == '$' && *(string + 1)) + { + return shellExtParseVar(shell, string); + } + else if (*string) + { + return (unsigned int)(unsigned long)shellExtParseString(string); + } + return 0; +} + + +/** + * @brief 执行命令 + * + * @param shell shell对象 + * @param command 命令 + * @param argc 参数个数 + * @param argv 参数 + * @return int 返回值 + */ +int shellExtRun(Shell *shell, ShellCommand *command, int argc, char *argv[]) +{ + unsigned int params[8] = {0}; + int paramNum = command->attr.attrs.paramNum > (argc - 1) ? + command->attr.attrs.paramNum : (argc - 1); + for (int i = 0; i < argc - 1; i++) + { + params[i] = shellExtParsePara(shell, argv[i + 1]); + } + switch (paramNum) + { + case 0: + return command->data.cmd.function(); + // break; + case 1: + return command->data.cmd.function(params[0]); + // break; + case 2: + return command->data.cmd.function(params[0], params[1]); + // break; + case 3: + return command->data.cmd.function(params[0], params[1], + params[2]); + // break; + case 4: + return command->data.cmd.function(params[0], params[1], + params[2], params[3]); + // break; + case 5: + return command->data.cmd.function(params[0], params[1], + params[2], params[3], + params[4]); + // break; + case 6: + return command->data.cmd.function(params[0], params[1], + params[2], params[3], + params[4], params[5]); + // break; + case 7: + return command->data.cmd.function(params[0], params[1], + params[2], params[3], + params[4], params[5], + params[6]); + // break; + default: + return -1; + // break; + } +} + diff --git a/third-party/letter-shell-3.1/src/shell_ext.h b/third-party/letter-shell-3.1/src/shell_ext.h new file mode 100644 index 0000000000000000000000000000000000000000..f4d6a829d9ec092df0962a1d5290a9e4078f27ac --- /dev/null +++ b/third-party/letter-shell-3.1/src/shell_ext.h @@ -0,0 +1,33 @@ +/** + * @file shell_ext.h + * @author Letter (NevermindZZT@gmail.com) + * @brief shell extensions + * @version 3.0.0 + * @date 2019-12-31 + * + * @copyright (c) 2019 Letter + * + */ + +#ifndef __SHELL_EXT_H__ +#define __SHELL_EXT_H__ + +#include "shell.h" + +/** + * @brief 数字类型 + * + */ +typedef enum +{ + NUM_TYPE_INT, /**< 十进制整型 */ + NUM_TYPE_BIN, /**< 二进制整型 */ + NUM_TYPE_OCT, /**< 八进制整型 */ + NUM_TYPE_HEX, /**< 十六进制整型 */ + NUM_TYPE_FLOAT /**< 浮点型 */ +} NUM_Type; + +unsigned int shellExtParsePara(Shell *shell, char *string); +int shellExtRun(Shell *shell, ShellCommand *command, int argc, char *argv[]); + +#endif diff --git a/third-party/letter-shell-3.1/tools/shellTools.py b/third-party/letter-shell-3.1/tools/shellTools.py new file mode 100644 index 0000000000000000000000000000000000000000..e7c43a5b5506af17ee6d462e71755b4e7e048f94 --- /dev/null +++ b/third-party/letter-shell-3.1/tools/shellTools.py @@ -0,0 +1,84 @@ +#!/usr/bin/python +# -*- coding:UTF-8 -*- + +""" +shellTools + +Author + Letter(nevermindzzt@gmail.com) + +Date + 2020-04-14 + +Copyright + (c) Letter 2020 +""" + +import os +import sys +import re + +FILE_PATTERN = r"^.*?\.(c|h)$" +SHELL_EXPORT_PATTERN = r"^\s*SHELL_EXPORT_(CMD|CMD_AGENCY|VAR|USER|KEY)\s*\(\s*\S+\s*,\s*(\S+)\s*,.*$" + +def isCodeFile(name): + return re.match(FILE_PATTERN, name) != None + +def getCodeFiles(path): + names = os.listdir(path) + files = [] + for name in names: + fullName = path + '\\' + name + if os.path.isdir(fullName): + files = files + getCodeFiles(fullName) + else: + if re.match(FILE_PATTERN, name) != None: + files.append(fullName) + return files + +def getFileEcoding(name): + encoding = "" + try: + with open(name, encoding="utf-8") as f: + f.read() + encoding = "utf-8" + except: + try: + with open(name, encoding="gbk") as f: + f.read() + encoding = "gbk" + except: + encoding = "ascii" + return encoding + + +if __name__ == "__main__": + path = sys.argv[1] + itemList = [] + codeLine = "" + for codeFile in getCodeFiles(path): + try: + with open(codeFile, encoding=getFileEcoding(codeFile)) as f: + lineNum = 0 + while True: + line = f.readline() + if line: + line = line.replace("\r", " ").replace("\n", " ") + codeLine = codeLine + line + lineNum = lineNum + 1 + if ";" in codeLine or "}" in codeLine: + matcher = re.match(SHELL_EXPORT_PATTERN, codeLine) + if matcher != None: + item = (matcher.group(1), matcher.group(2), codeFile, lineNum) + itemList.append(item) + codeLine = "" + else: + codeLine = "" + break + except Exception as e: + print(e) + pass + + for item in sorted(itemList, key=lambda x:(x[1])): + print("shell export %s, %s in file %s(%d)" + %(item[0], item[1], item[2], item[3])) diff --git a/third-party/libmetal/.checkpatch.conf b/third-party/libmetal/.checkpatch.conf new file mode 100644 index 0000000000000000000000000000000000000000..f147ba30d28f811ac3e2eadad8a43714d9aa04db --- /dev/null +++ b/third-party/libmetal/.checkpatch.conf @@ -0,0 +1,23 @@ +--emacs +--no-tree +--summary-file +--show-types +--max-line-length=80 +--min-conf-desc-length=1 + +--ignore BRACES +--ignore PRINTK_WITHOUT_KERN_LEVEL +--ignore SPLIT_STRING +--ignore VOLATILE +--ignore CONFIG_EXPERIMENTAL +--ignore AVOID_EXTERNS +--ignore NETWORKING_BLOCK_COMMENT_STYLE +--ignore DATE_TIME +--ignore MINMAX +--ignore CONST_STRUCT +--ignore FILE_PATH_CHANGES +--ignore BIT_MACRO +--ignore PREFER_KERNEL_TYPES +--ignore NEW_TYPEDEFS +--ignore ARRAY_SIZE +--ignore MACRO_ARG_REUSE \ No newline at end of file diff --git a/third-party/libmetal/.gitlint b/third-party/libmetal/.gitlint new file mode 100644 index 0000000000000000000000000000000000000000..92d9e1b8db145a9bfe8c73c5de0066734faadbb0 --- /dev/null +++ b/third-party/libmetal/.gitlint @@ -0,0 +1,99 @@ +# All these sections are optional, edit this file as you like. +[general] +# Ignore certain rules, you can reference them by their id or by their full name +ignore=title-trailing-punctuation, T3, title-max-length, T1, body-hard-tab, B1, B3 + +# verbosity should be a value between 1 and 3, the commandline -v flags take precedence over this +verbosity = 3 + +# By default gitlint will ignore merge commits. Set to 'false' to disable. +ignore-merge-commits=true + +# By default gitlint will ignore fixup commits. Set to 'false' to disable. +# ignore-fixup-commits=false + +# By default gitlint will ignore squash commits. Set to 'false' to disable. +# ignore-squash-commits=true + +# Ignore any data send to gitlint via stdin +# ignore-stdin=true + +# Enable debug mode (prints more output). Disabled by default. +debug=true + +# Enable community contributed rules +# See http://jorisroovers.github.io/gitlint/contrib_rules for details +# contrib=contrib-title-conventional-commits,CC1 + +# Set the extra-path where gitlint will search for user defined rules +# See http://jorisroovers.github.io/gitlint/user_defined_rules for details +extra-path=scripts/gitlint + +[title-max-length] +line-length=75 + +[body-min-line-count] +min-line-count=1 + +[body-max-line-count] +max-line-count=200 + +[title-must-not-contain-word] +# Comma-separated list of words that should not occur in the title. Matching is case +# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING" +# will not cause a violation, but "WIP: my title" will. +words=wip + +# [title-match-regex] +# python like regex (https://docs.python.org/2/library/re.html) that the +# commit-msg title must be matched to. +# Note that the regex can contradict with other rules if not used correctly +# (e.g. title-must-not-contain-word). +# regex=^US[0-9]* + +[body-max-line-length] +# B1 = body-max-line-length +line-length=80 + +[body-min-length] +min-length=3 + +[body-is-missing] +# Whether to ignore this rule on merge commits (which typically only have a title) +# default = True +ignore-merge-commits=false + +# [body-changed-file-mention] +# List of files that need to be explicitly mentioned in the body when they are changed +# This is useful for when developers often erroneously edit certain files or git submodules. +# By specifying this rule, developers can only change the file when they explicitly reference +# it in the commit message. +# files=gitlint/rules.py,README.md + +# [author-valid-email] +# python like regex (https://docs.python.org/2/library/re.html) that the +# commit author email address should be matched to +# For example, use the following regex if you only want to allow email addresses from foo.com +# regex=[^@]+@foo.com + +# [ignore-by-title] +# Ignore certain rules for commits of which the title matches a regex +# E.g. Match commit titles that start with "Release" +# regex=^Release(.*) +# +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +# ignore=T1,body-min-length + +# [ignore-by-body] +# Ignore certain rules for commits of which the body has a line that matches a regex +# E.g. Match bodies that have a line that that contain "release" +# regex=(.*)release(.*) +# +# Ignore certain rules, you can reference them by their id or by their full name +# Use 'all' to ignore all rules +# ignore=T1,body-min-length + +# [contrib-title-conventional-commits] +# Specify allowed commit types. For details see: https://www.conventionalcommits.org/ +# types = bugfix,user-story,epic \ No newline at end of file diff --git a/third-party/libmetal/CMakeLists.txt b/third-party/libmetal/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..7ea8f7bc9945a2f7ea5fff17d2dc6e6402a9fd8e --- /dev/null +++ b/third-party/libmetal/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required (VERSION 3.0.2) +if (POLICY CMP0048) + cmake_policy(SET CMP0048 NEW) +endif() + +if (POLICY CMP0077) + cmake_policy(SET CMP0077 NEW) +endif() + +set (LIBMETAL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + +list (APPEND CMAKE_MODULE_PATH + "${CMAKE_CURRENT_SOURCE_DIR}/cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/platforms") + +include (syscheck) +project (metal C) + +include (CheckIncludeFiles) +include (CheckCSourceCompiles) +include (collect) +include (options) +include (depends) + +foreach(_inc_path ${CMAKE_INCLUDE_PATH}) + collect (PROJECT_INC_DIRS "${_inc_path}") +endforeach() + +enable_testing () + +add_subdirectory (lib) + +if (WITH_TESTS) + add_subdirectory (test) +endif (WITH_TESTS) + +if (WITH_DOC) + add_subdirectory (doc) +endif (WITH_DOC) + +if (WITH_EXAMPLES) + add_subdirectory (examples) +endif (WITH_EXAMPLES) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/LICENSE.md b/third-party/libmetal/LICENSE.md new file mode 100644 index 0000000000000000000000000000000000000000..ec819a9622d3051a5abfd0578894c936f5152821 --- /dev/null +++ b/third-party/libmetal/LICENSE.md @@ -0,0 +1,41 @@ +Software License Agreement (BSD License) +======================================== + +Copyright (c) 2015, Xilinx Inc. and Contributors. 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 Xilinx 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. + + +Notes +========================================= +Use the following tag instead of the full license text in the individual files: + + SPDX-License-Identifier: BSD-3-Clause + +This enables machine processing of license information based on the SPDX +License Identifiers that are here available: http://spdx.org/licenses/ + diff --git a/third-party/libmetal/MAINTAINERS.md b/third-party/libmetal/MAINTAINERS.md new file mode 100644 index 0000000000000000000000000000000000000000..5f388dea0e3c787cb115bec71fa0bbaf5c852c5a --- /dev/null +++ b/third-party/libmetal/MAINTAINERS.md @@ -0,0 +1,22 @@ +# libmetal Maintainers + +libmetal project is maintained by the OpenAMP open source community. +Everyone is encouraged to submit issues and changes to improve libmetal. + +The intention of this file is to provide a set of names that developers can +consult when they have a question about OpenAMP and to provide a a set of +names to be CC'd when submitting a patch. + +## Project Administration +Ed Mooring +Arnaud Pouliquen + +### All patches CC here +openamp-rp@lists.openampproject.org + +## Machines +### Xilinx Platform - Zynq-7000 +Ed Mooring + +### Xilinx Platform - Zynq UltraScale+ MPSoC +Ed Mooring diff --git a/third-party/libmetal/README.md b/third-party/libmetal/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d6be115f9b78818049205844e7be629b4139b3ac --- /dev/null +++ b/third-party/libmetal/README.md @@ -0,0 +1,301 @@ +# libmetal + +## Overview + +Libmetal provides common user APIs to access devices, handle device interrupts +and request memory across the following operating environments: + * Linux user space (based on UIO and VFIO support in the kernel) + * RTOS (with and without virtual memory) + * Bare-metal environments + +## Project configuration +The configuration phase begins when the user invokes CMake. CMake begins by processing the CMakeLists.txt file and the cmake directory. +Some cmake options are available to help user to customize the libmetal to their +own project. + +* **WITH_DOC** (default ON): Build with documentation. Add -DWITH_DOC=OFF in +cmake command line to disable. +* **WITH_EXAMPLES** (default ON): Build with application exemples. Add +-DWITH_DOC=OFF in cmake command line to disable the option. +* **WITH_TESTS** (default ON): Build with application tests. Add -DWITH_DOC=OFF +in cmake command line to disable the option. +* **WITH_DEFAULT_LOGGER** (default ON): Build with default trace logger. Add +-DWITH_DEFAULT_LOGGER=OFF in cmake command line to disable the option. +* **WITH_SHARED_LIB** (default ON): Generate a shared library. Add +-DWITH_SHARED_LIB=OFF in cmake command line to disable the option. +* **WITH_STATIC_LIB** (default ON): Generate a static library. Add +-DWITH_STATIC_LIB=OFF in cmake command line to disable the option. +* **WITH_ZEPHYR** (default OFF): Build for Zephyr environment. Add +-DWITH_ZEPHYR=ON in cmake command line to enable the the option. + +## Build Steps + +### Building for Linux Host +``` + $ git clone https://github.com/OpenAMP/libmetal.git + $ mkdir -p libmetal/ + $ cd libmetal/ + $ cmake .. + $ make VERBOSE=1 DESTDIR= install +``` + +### Cross Compiling for Linux Target +Use [meta-openamp](https://github.com/openamp/meta-openamp) to build +libmetal library. +Use package `libmetal` in your yocto config file. + +### Building for Baremetal + +To build on baremetal, you will need to provide a toolchain file. Here is an +example toolchain file: +``` + set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "") + set (MACHINE "zynqmp_r5" CACHE STRING "") + + set (CROSS_PREFIX "armr5-none-eabi-" CACHE STRING "") + set (CMAKE_C_FLAGS "-mfloat-abi=soft -mcpu=cortex-r5 -Wall -Werror -Wextra \ + -flto -Os -I/ws/xsdk/r5_0_bsp/psu_cortexr5_0/include" CACHE STRING "") + + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto") + SET(CMAKE_AR "gcc-ar" CACHE STRING "") + SET(CMAKE_C_ARCHIVE_CREATE " qcs ") + SET(CMAKE_C_ARCHIVE_FINISH true) + + include (cross-generic-gcc) +``` +* Note: other toolchain files can be found in the `cmake/platforms/` directory. +* Compile with your toolchain file. +``` + $ mkdir -p build-libmetal + $ cd build-libmetal + $ cmake -DCMAKE_TOOLCHAIN_FILE= + $ make VERBOSE=1 DESTDIR= install +``` +* Note: When building baremetal for Xilinx 2018.3 or earlier environments, +add -DXILINX_PRE_V2019 to your CMake invocation. This will include the +xilmem and xilstandalone libraries in your build. These libraries were +removed in 2019.1. + +### Building for Zephyr +The [zephyr-libmetal](https://github.com/zephyrproject-rtos/libmetal) +implements the libmetal for the Zephyr project. It is mainly a fork of this repository, with some add-ons for integration in the Zephyr project. + +Following instruction is only to be able to run test application on a QEMU running +a Zephyr environment. + +As Zephyr uses CMake, we build libmetal library and test application as +targets of Zephyr CMake project. Here is how to build libmetal for Zephyr: +``` + $ export ZEPHYR_GCC_VARIANT=zephyr + $ export ZEPHYR_SDK_INSTALL_DIR= + $ source /zephyr-env.sh + + $ cmake -DWITH_ZEPHYR=on -DBOARD=qemu_cortex_m3 \ + [-DWITH_TESTS=on] + $ make VERBOSE=1 all + # If we have turned on tests with "-DWITH_TESTS=on" when we run cmake, + # we launch libmetal test on Zephyr QEMU platform as follows: + $ make VERBOSE=1 run +``` + +## Interfaces + +The following subsections give an overview of interfaces provided by libmetal. + +### Platform and OS Independent Utilities + +These interfaces do not need to be ported across to new operating systems. + +#### I/O + +The libmetal I/O region abstraction provides access to memory mapped I/O and +shared memory regions. This includes: + * primitives to read and write memory with ordering constraints, and + * ability to translate between physical and virtual addressing on systems + that support virtual memory. + +#### Log + +The libmetal logging interface is used to plug log messages generated by +libmetal into application specific logging mechanisms (e.g. syslog). This +also provides basic message prioritization and filtering mechanisms. + +#### List + +This is a simple doubly linked list implementation used internally within +libmetal, and also available for application use. + +#### Other Utilities + +The following utilities are provided in lib/utilities.h: + * Min/max, round up/down, etc. + * Bitmap operations + * Helper to compute container structure pointers + * ... and more ... + +#### Version + +The libmetal version interface allows user to get the version of the library. The version increment +follows the set of rule proposed in [Semantic Versioning specification](https://semver.org/). + +### Top Level Interfaces + +The users will need to call two top level interfaces to use libmetal APIs: + * metal_init - initialize the libmetal resource + * metal_finish - release libmetal resource + +Each system needs to have their own implementation inside libmetal for these +two APIs to call: + * metal_sys_init + * metal_sys_finish + +For the current release, libmetal provides Linux userspace and bare-metal +implementation for metal_sys_init and metal_sys_finish. + +For Linux userspace, metal_sys_init sets up a table for available shared pages, +checks whether UIO/VFIO drivers are avail, and starts interrupt handling +thread. +Please note that on Linux, to access device's memory that is not page +aligned, an offset has to be added to the pointer returned by +mmap(). This `offset`, although it can be read from the device tree +property exposed by the uio driver, is not handled yet by the +library. + +For bare-metal, metal_sys_init and metal_sys_finish just returns. + +### Atomics + +The libmetal atomic operations API is consistent with the C11/C++11 stdatomics +interface. The stdatomics interface is commonly provided by recent toolchains +including GCC and LLVM/Clang. When porting to a different toolchain, it may be +necessary to provide an stdatomic compatible implementation if the toolchain +does not already provide one. + +### Alloc + +libmetal provides memory allocation and release APIs. + +### Locking + +libmetal provides the following locking APIs. + +#### Mutex + +libmetal has a generic mutex implementation which is a busy wait. It is +recommended to have OS specific implementation for mutex. + +The Linux userspace mutex implementation uses futex to wait for the lock +and wakeup a waiter. + +#### Condition Variable +libmetal condition variable APIs provide "wait" for user applications to wait +on some condition to be met, and "signal" to indicate a particular even occurs. + +#### Spinlock +libmetal spinlock APIs provides busy waiting mechanism to acquire a lock. + +### Shmem + +libmetal has a generic static shared memory implementation. If your OS has a +global shared memory allocation, you will need to port it for the OS. + +The Linux userspace shmem implementation uses libhugetlbfs to support huge page +sizes. + +### Bus and Device Abstraction + +libmetal has a static generic implementation. If your OS has a driver model +implementation, you will need to port it for the OS. + +The Linux userspace abstraction binds the devices to UIO or VFIO driver. +The user applications specify which device to use, e.g. bus "platform" bus, +device "f8000000.slcr", and then the abstraction will check if platform UIO +driver or platform VFIO driver is there. If platform VFIO driver exists, +it will bind the device to the platform VFIO driver, otherwise, if UIO driver +exists, it will bind the device to the platform UIO driver. + +The VFIO support is not yet implemented. + +### Interrupt + +libmetal provides APIs to register an interrupt, disable interrupts and restore +interrupts. + +The Linux userspace implementation will use a thread to call select() function +to listen to the file descriptors of the devices to see if there is an interrupt +triggered. If there is an interrupt triggered, it will call the interrupt +handler registered by the user application. + +### Cache + +libmetal provides APIs to flush and invalidate caches. + +The cache APIs for Linux userspace are empty functions for now as cache +operations system calls are not avaiable for all architectures. + +### DMA + +libmetal DMA APIs provide DMA map and unmap implementation. + +After calling DMA map, the DMA device will own the memory. +After calling DMA unmap, the cpu will own the memory. + +For Linux userspace, it only supports to use UIO device memory as DMA +memory for this release. + +### Time +libmetal time APIs provide getting timestamp implementation. + +### Sleep +libmetal sleep APIs provide getting delay execution implementation. + +### Compiler + +This API is for compiler dependent functions. For this release, there is only +a GCC implementation, and compiler specific code is limited to atomic +operations. + +## How to contribute: +As an open-source project, we welcome and encourage the community to submit patches directly to the project. As a contributor you should be familiar with common developer tools such as Git and CMake, and platforms such as GitHub. +Then following points should be rescpected to facilitate the review process. + +### Licencing +Code is contributed to OpenAMP under a number of licenses, but all code must be compatible with version the [BSD License](https://github.com/OpenAMP/libmetal/blob/master/LICENSE.md), which is the license covering the OpenAMP distribution as a whole. In practice, use the following tag instead of the full license text in the individual files: + + ``` + SPDX-License-Identifier: BSD-3-Clause + ``` +### Signed-off-by +Commit message must contain Signed-off-by: line and your email must match the change authorship information. Make sure your .gitconfig is set up correctly: + + ``` + git config --global user.name "first-name Last-Namer" + git config --global user.email "yourmail@company.com" + ``` +### gitlint +Before you submit a pull request to the project, verify your commit messages meet the requirements. The check can be performed locally using the the gitlint command. + +Run gitlint locally in your tree and branch where your patches have been committed: + + ```gitlint``` +Note, gitlint only checks HEAD (the most recent commit), so you should run it after each commit, or use the --commits option to specify a commit range covering all the development patches to be submitted. + +### Code style +In general, follow the Linux kernel coding style, with the following exceptions: + +* Use /** */ for doxygen comments that need to appear in the documentation. + +The Linux kernel GPL-licensed tool checkpatch is used to check coding style conformity.Checkpatch is available in the scripts directory. + +To check your \ commits in your git branch: + ``` + ./scripts/checkpatch.pl --strict -g HEAD- + + ``` +### Send a pull request +We use standard github mechanism for pull request. Please refer to github documentation for help. + +## Communication and Collaboration +[Subscribe](https://lists.openampproject.org/mailman/listinfo/openamp-rp) to the OpenAMP mailing list(openamp-rp@lists.openampproject.org). + +For more details on the framework please refer to the the [OpenAMP wiki](https://github.com/OpenAMP/open-amp/wiki). diff --git a/third-party/libmetal/VERSION b/third-party/libmetal/VERSION new file mode 100644 index 0000000000000000000000000000000000000000..28f0f0226d631c38af4d2c87b7129b592bd20f18 --- /dev/null +++ b/third-party/libmetal/VERSION @@ -0,0 +1,3 @@ +VERSION_MAJOR = 1 +VERSION_MINOR = 0 +VERSION_PATCH = 0 diff --git a/third-party/libmetal/cmake/collect.cmake b/third-party/libmetal/cmake/collect.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3a1c580342e2b9ec18e324bff8b5edeb71396e98 --- /dev/null +++ b/third-party/libmetal/cmake/collect.cmake @@ -0,0 +1,36 @@ +function (collector_create name base) + set_property (GLOBAL PROPERTY "COLLECT_${name}_LIST") + set_property (GLOBAL PROPERTY "COLLECT_${name}_BASE" "${base}") +endfunction (collector_create) + +function (collector_list var name) + get_property (_list GLOBAL PROPERTY "COLLECT_${name}_LIST") + set (${var} "${_list}" PARENT_SCOPE) +endfunction (collector_list) + +function (collector_base var name) + get_property (_base GLOBAL PROPERTY "COLLECT_${name}_BASE") + set (${var} "${_base}" PARENT_SCOPE) +endfunction (collector_base) + +function (collect name) + collector_base (_base ${name}) + string(COMPARE NOTEQUAL "${_base}" "" _is_rel) + set (_list) + foreach (s IN LISTS ARGN) + if (_is_rel) + get_filename_component (s "${s}" ABSOLUTE) + file (RELATIVE_PATH s "${_base}" "${s}") + endif (_is_rel) + list (APPEND _list "${s}") + endforeach () + set_property (GLOBAL APPEND PROPERTY "COLLECT_${name}_LIST" "${_list}") +endfunction (collect) + +# Create global collectors +collector_create (PROJECT_INC_DIRS "") +collector_create (PROJECT_LIB_DIRS "") +collector_create (PROJECT_LIB_DEPS "") +collector_create (PROJECT_HDR_TESTS "") + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/depends.cmake b/third-party/libmetal/cmake/depends.cmake new file mode 100644 index 0000000000000000000000000000000000000000..1a9ed4629455d875e2ebdecc19081ce8cd479165 --- /dev/null +++ b/third-party/libmetal/cmake/depends.cmake @@ -0,0 +1,38 @@ +if (WITH_DOC) + find_package (Doxygen) +endif (WITH_DOC) + +if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + + check_include_files (stdatomic.h HAVE_STDATOMIC_H) + check_include_files (linux/futex.h HAVE_FUTEX_H) + + find_package (HugeTLBFS) + if (HUGETLBFS_FOUND) + collect (PROJECT_INC_DIRS "${HUGETLBFS_INCLUDE_DIR}") + collect (PROJECT_LIB_DEPS "${HUGETLBFS_LIBRARIES}") + add_definitions(-DHAVE_HUGETLBFS_H) + endif(HUGETLBFS_FOUND) + + find_package (LibSysFS REQUIRED) + collect (PROJECT_INC_DIRS "${LIBSYSFS_INCLUDE_DIR}") + collect (PROJECT_LIB_DEPS "${LIBSYSFS_LIBRARIES}") + + find_package(Threads REQUIRED) + collect (PROJECT_LIB_DEPS "${CMAKE_THREAD_LIBS_INIT}") + + find_package(LibRt REQUIRED) + collect (PROJECT_LIB_DEPS "${LIBRT_LIBRARIES}") + +else ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + + # TODO: fix for find_path() to detect stdatomic.h + # find_path (HAVE_STDATOMIC_H stdatomic.h) + set (_saved_cmake_required_flags ${CMAKE_REQUIRED_FLAGS}) + set (CMAKE_REQUIRED_FLAGS "-c" CACHE STRING "") + check_include_files (stdatomic.h HAVE_STDATOMIC_H) + set (CMAKE_REQUIRED_FLAGS ${_saved_cmake_required_flags}) + +endif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/modules/FindHugeTLBFS.cmake b/third-party/libmetal/cmake/modules/FindHugeTLBFS.cmake new file mode 100644 index 0000000000000000000000000000000000000000..b3a6c1e0acd31a4136f2c92847a9e92c758d5066 --- /dev/null +++ b/third-party/libmetal/cmake/modules/FindHugeTLBFS.cmake @@ -0,0 +1,34 @@ +# FindHugeTLBFS +# -------- +# +# Find HugeTLBFS +# +# Find the native HugeTLBFS includes and library This module defines +# +# :: +# +# HUGETLBFS_INCLUDE_DIR, where to find hugetlbfs.h, etc. +# HUGETLBFS_LIBRARIES, the libraries needed to use HugeTLBFS. +# HUGETLBFS_FOUND, If false, do not try to use HugeTLBFS. +# +# also defined, but not for general use are +# +# :: +# +# HUGETLBFS_LIBRARY, where to find the HugeTLBFS library. + +find_path (HUGETLBFS_INCLUDE_DIR hugetlbfs.h) + +set (HUGETLBFS_NAMES ${HUGETLBFS_NAMES} hugetlbfs) +find_library (HUGETLBFS_LIBRARY NAMES ${HUGETLBFS_NAMES}) + +# handle the QUIETLY and REQUIRED arguments and set HUGETLBFS_FOUND to TRUE if +# all listed variables are TRUE +include (FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS (HugeTLBFS DEFAULT_MSG HUGETLBFS_LIBRARY HUGETLBFS_INCLUDE_DIR) + +if (HUGETLBFS_FOUND) + set (HUGETLBFS_LIBRARIES ${HUGETLBFS_LIBRARY}) +endif (HUGETLBFS_FOUND) + +mark_as_advanced (HUGETLBFS_LIBRARY HUGETLBFS_INCLUDE_DIR) diff --git a/third-party/libmetal/cmake/modules/FindLibRt.cmake b/third-party/libmetal/cmake/modules/FindLibRt.cmake new file mode 100644 index 0000000000000000000000000000000000000000..c496edf862a3a8c6357718e63336e492d7a45af9 --- /dev/null +++ b/third-party/libmetal/cmake/modules/FindLibRt.cmake @@ -0,0 +1,46 @@ +#.rst: +# FindLibRt +# -------- +# +# Find the native realtime includes and library. +# +# IMPORTED Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines :prop_tgt:`IMPORTED` target ``LIBRT::LIBRT``, if +# LIBRT has been found. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following variables: +# +# :: +# +# LIBRT_INCLUDE_DIRS - where to find time.h, etc. +# LIBRT_LIBRARIES - List of libraries when using librt. +# LIBRT_FOUND - True if realtime library found. +# +# Hints +# ^^^^^ +# +# A user may set ``LIBRT_ROOT`` to a realtime installation root to tell this +# module where to look. + +find_path(LIBRT_INCLUDE_DIRS + NAMES time.h + PATHS ${LIBRT_ROOT}/include/ +) +find_library(LIBRT_LIBRARIES rt) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibRt DEFAULT_MSG LIBRT_LIBRARIES LIBRT_INCLUDE_DIRS) +mark_as_advanced(LIBRT_INCLUDE_DIRS LIBRT_LIBRARIES) + +if(LIBRT_FOUND) + if(NOT TARGET LIBRT::LIBRT) + add_library(LIBRT::LIBRT UNKNOWN IMPORTED) + set_target_properties(LIBRT::LIBRT PROPERTIES + IMPORTED_LOCATION "${LIBRT_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${LIBRT_INCLUDE_DIRS}") + endif() +endif() diff --git a/third-party/libmetal/cmake/modules/FindLibSysFS.cmake b/third-party/libmetal/cmake/modules/FindLibSysFS.cmake new file mode 100644 index 0000000000000000000000000000000000000000..898a72d2f98769af79b20fd1da8db98ddd00fc99 --- /dev/null +++ b/third-party/libmetal/cmake/modules/FindLibSysFS.cmake @@ -0,0 +1,34 @@ +# FindLibSysFS +# -------- +# +# Find LibSysFS +# +# Find the native LibSysFS includes and library This module defines +# +# :: +# +# LIBSYSFS_INCLUDE_DIR, where to find libsysfs.h, etc. +# LIBSYSFS_LIBRARIES, the libraries needed to use LibSysFS. +# LIBSYSFS_FOUND, If false, do not try to use LibSysFS. +# +# also defined, but not for general use are +# +# :: +# +# LIBSYSFS_LIBRARY, where to find the LibSysFS library. + +find_path (LIBSYSFS_INCLUDE_DIR sysfs/libsysfs.h) + +set (LIBSYSFS_NAMES ${LIBSYSFS_NAMES} sysfs) +find_library (LIBSYSFS_LIBRARY NAMES ${LIBSYSFS_NAMES}) + +# handle the QUIETLY and REQUIRED arguments and set LIBSYSFS_FOUND to TRUE if +# all listed variables are TRUE +include (FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS (LibSysFS DEFAULT_MSG LIBSYSFS_LIBRARY LIBSYSFS_INCLUDE_DIR) + +if (LIBSYSFS_FOUND) + set (LIBSYSFS_LIBRARIES ${LIBSYSFS_LIBRARY}) +endif (LIBSYSFS_FOUND) + +mark_as_advanced (LIBSYSFS_LIBRARY LIBSYSFS_INCLUDE_DIR) diff --git a/third-party/libmetal/cmake/options.cmake b/third-party/libmetal/cmake/options.cmake new file mode 100644 index 0000000000000000000000000000000000000000..cbf1c2b0e000e462a2f0bd81e155abe225eb1498 --- /dev/null +++ b/third-party/libmetal/cmake/options.cmake @@ -0,0 +1,73 @@ +file(READ ${LIBMETAL_ROOT_DIR}/VERSION ver) + +string(REGEX MATCH "VERSION_MAJOR = ([0-9]*)" _ ${ver}) +set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1}) + +string(REGEX MATCH "VERSION_MINOR = ([0-9]*)" _ ${ver}) +set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_1}) + +string(REGEX MATCH "VERSION_PATCH = ([0-9]*)" _ ${ver}) +set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_1}) + +set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) + +message(STATUS "libmetal version: ${PROJECT_VERSION} (${CMAKE_SOURCE_DIR})") + +if (NOT DEFINED CMAKE_BUILD_TYPE) + set (CMAKE_BUILD_TYPE Debug) +endif (NOT DEFINED CMAKE_BUILD_TYPE) +message ("-- Build type: ${CMAKE_BUILD_TYPE}") + +if (NOT CMAKE_INSTALL_LIBDIR) + set (CMAKE_INSTALL_LIBDIR "lib") +endif (NOT CMAKE_INSTALL_LIBDIR) + +if (NOT CMAKE_INSTALL_BINDIR) + set (CMAKE_INSTALL_BINDIR "bin") +endif (NOT CMAKE_INSTALL_BINDIR) + +set (_host "${CMAKE_HOST_SYSTEM_NAME}/${CMAKE_HOST_SYSTEM_PROCESSOR}") +message ("-- Host: ${_host}") + +set (_target "${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR}") +message ("-- Target: ${_target}") + +if (NOT DEFINED MACHINE) + set (MACHINE "Generic") +endif (NOT DEFINED MACHINE) +message ("-- Machine: ${MACHINE}") + +# handle if '-' in machine name +string (REPLACE "-" "_" MACHINE ${MACHINE}) + +if (NOT DEFINED PROJECT_SYSTEM) + string (TOLOWER ${CMAKE_SYSTEM_NAME} PROJECT_SYSTEM) + string (TOUPPER ${CMAKE_SYSTEM_NAME} PROJECT_SYSTEM_UPPER) +endif (NOT DEFINED PROJECT_SYSTEM) + +string (TOLOWER ${CMAKE_SYSTEM_PROCESSOR} PROJECT_PROCESSOR) +string (TOUPPER ${CMAKE_SYSTEM_PROCESSOR} PROJECT_PROCESSOR_UPPER) +string (TOLOWER ${MACHINE} PROJECT_MACHINE) +string (TOUPPER ${MACHINE} PROJECT_MACHINE_UPPER) + +option (WITH_STATIC_LIB "Build with a static library" ON) + +if ("${PROJECT_SYSTEM}" STREQUAL "linux") + option (WITH_SHARED_LIB "Build with a shared library" ON) + option (WITH_TESTS "Install test applications" ON) +endif ("${PROJECT_SYSTEM}" STREQUAL "linux") + +if (WITH_TESTS AND (${_host} STREQUAL ${_target})) + option (WITH_TESTS_EXEC "Run test applications during build" ON) +endif (WITH_TESTS AND (${_host} STREQUAL ${_target})) + +if (WITH_ZEPHYR) + option (WITH_ZEPHYR_LIB "Build libmetal as a zephyr library" OFF) +endif (WITH_ZEPHYR) + +option (WITH_DEFAULT_LOGGER "Build with default logger" ON) + +option (WITH_DOC "Build with documentation" ON) + +set (PROJECT_EC_FLAGS "-Wall -Werror -Wextra" CACHE STRING "") +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/cross-freertos-gcc.cmake b/third-party/libmetal/cmake/platforms/cross-freertos-gcc.cmake new file mode 100644 index 0000000000000000000000000000000000000000..f12fdc78d66a1634cb50a8ecb0b8d42120b16cfb --- /dev/null +++ b/third-party/libmetal/cmake/platforms/cross-freertos-gcc.cmake @@ -0,0 +1,6 @@ +# cmake 3.3.2 does not know CMAKE_SYSTEM_NAME=FreeRTOS, we set it to Generic +include (cross-generic-gcc) +string (TOLOWER "FreeRTOS" PROJECT_SYSTEM) +string (TOUPPER "FreeRTOS" PROJECT_SYSTEM_UPPER) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/cross-generic-gcc.cmake b/third-party/libmetal/cmake/platforms/cross-generic-gcc.cmake new file mode 100644 index 0000000000000000000000000000000000000000..958ade5e1ac33693ae9899c2bf42cc65aed3312c --- /dev/null +++ b/third-party/libmetal/cmake/platforms/cross-generic-gcc.cmake @@ -0,0 +1,10 @@ +set (CMAKE_SYSTEM_NAME "Generic" CACHE STRING "") +set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE STRING "") +set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER CACHE STRING "") +set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER CACHE STRING "") + +include (CMakeForceCompiler) +CMAKE_FORCE_C_COMPILER ("${CROSS_PREFIX}gcc" GNU) +CMAKE_FORCE_CXX_COMPILER ("${CROSS_PREFIX}g++" GNU) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/cross-generic-iar.cmake b/third-party/libmetal/cmake/platforms/cross-generic-iar.cmake new file mode 100644 index 0000000000000000000000000000000000000000..f31a14be0300ec131ac5dffc820d56b277a52f12 --- /dev/null +++ b/third-party/libmetal/cmake/platforms/cross-generic-iar.cmake @@ -0,0 +1,10 @@ +set (CMAKE_SYSTEM_NAME "Generic" CACHE STRING "") +set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE STRING "") +set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER CACHE STRING "") +set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER CACHE STRING "") + +include (CMakeForceCompiler) +CMAKE_FORCE_C_COMPILER ("icc${CROSS_SUFFIX}" IAR) +CMAKE_FORCE_CXX_COMPILER ("icc${CROSS_SUFFIX} --eec++" IAR) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/cross-linux-gcc.cmake b/third-party/libmetal/cmake/platforms/cross-linux-gcc.cmake new file mode 100644 index 0000000000000000000000000000000000000000..28c228b15bdc4326b51efd5a42d8b6c07a4f0503 --- /dev/null +++ b/third-party/libmetal/cmake/platforms/cross-linux-gcc.cmake @@ -0,0 +1,8 @@ +set (CMAKE_SYSTEM_NAME "Linux" CACHE STRING "") +set (CMAKE_C_COMPILER "${CROSS_PREFIX}gcc" CACHE STRING "") +set (CMAKE_CXX_COMPILER "${CROSS_PREFIX}g++" CACHE STRING "") +set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE STRING "") +set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER CACHE STRING "") +set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER CACHE STRING "") + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/microblaze-generic.cmake b/third-party/libmetal/cmake/platforms/microblaze-generic.cmake new file mode 100644 index 0000000000000000000000000000000000000000..91cb64e0c03d3589d566bbef4422630e0b0793d9 --- /dev/null +++ b/third-party/libmetal/cmake/platforms/microblaze-generic.cmake @@ -0,0 +1,7 @@ + set (CMAKE_SYSTEM_PROCESSOR "microblaze" CACHE STRING "") + set (MACHINE "microblaze_generic" CACHE STRING "") + set (CROSS_PREFIX "mb-" CACHE STRING "") + # These flags are for a demo. If microblaze is changed, the flags need to be changed too. + set (CMAKE_C_FLAGS "-mlittle-endian -mxl-barrel-shift -mxl-pattern-compare \ + -mcpu=v10.0 -mno-xl-soft-mul" CACHE STRING "") + include (cross-generic-gcc) diff --git a/third-party/libmetal/cmake/platforms/template-freertos.cmake b/third-party/libmetal/cmake/platforms/template-freertos.cmake new file mode 100644 index 0000000000000000000000000000000000000000..385655ee2016cc6eee5b67a238d52e570658b04c --- /dev/null +++ b/third-party/libmetal/cmake/platforms/template-freertos.cmake @@ -0,0 +1,12 @@ +# Modify to match your needs. These setttings can also be overridden at the +# command line. (eg. cmake -DCMAKE_C_FLAGS="-O3") + +set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "") +set (MACHINE "template" CACHE STRING "") +set (CROSS_PREFIX "arm-none-eabi-" CACHE STRING "") + +set (CMAKE_C_FLAGS "" CACHE STRING "") + +include (cross-freertos-gcc) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/template-generic.cmake b/third-party/libmetal/cmake/platforms/template-generic.cmake new file mode 100644 index 0000000000000000000000000000000000000000..3905cf107910506f91a12dc60c3a91cfaa34f987 --- /dev/null +++ b/third-party/libmetal/cmake/platforms/template-generic.cmake @@ -0,0 +1,12 @@ +# Modify to match your needs. These setttings can also be overridden at the +# command line. (eg. cmake -DCMAKE_C_FLAGS="-O3") + +set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "") +set (MACHINE "template" CACHE STRING "") +set (CROSS_PREFIX "arm-none-eabi-" CACHE STRING "") + +set (CMAKE_C_FLAGS "" CACHE STRING "") + +include (cross-generic-gcc) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/zynq7-freertos.cmake b/third-party/libmetal/cmake/platforms/zynq7-freertos.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6ba5f8673c038d3b9959feb1c66e36b6f62463f9 --- /dev/null +++ b/third-party/libmetal/cmake/platforms/zynq7-freertos.cmake @@ -0,0 +1,9 @@ +set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "") +set (MACHINE "zynq7" CACHE STRING "") +set (CROSS_PREFIX "arm-none-eabi-" CACHE STRING "") + +set (CMAKE_C_FLAGS "-mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard" CACHE STRING "") + +include (cross-freertos-gcc) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/zynq7-generic-iar.cmake b/third-party/libmetal/cmake/platforms/zynq7-generic-iar.cmake new file mode 100644 index 0000000000000000000000000000000000000000..942abc7ca38860320df7187fba5bd4b9e690b077 --- /dev/null +++ b/third-party/libmetal/cmake/platforms/zynq7-generic-iar.cmake @@ -0,0 +1,5 @@ +set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "") +set (CROSS_SUFFIX "arm" CACHE STRING "") +include (cross-generic-iar) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/zynq7-generic.cmake b/third-party/libmetal/cmake/platforms/zynq7-generic.cmake new file mode 100644 index 0000000000000000000000000000000000000000..7881f67ed35965c2127eb43ea1022682c7ebc7ad --- /dev/null +++ b/third-party/libmetal/cmake/platforms/zynq7-generic.cmake @@ -0,0 +1,9 @@ +set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "") +set (MACHINE "zynq7" CACHE STRING "") +set (CROSS_PREFIX "arm-none-eabi-" CACHE STRING "") + +set (CMAKE_C_FLAGS "-mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard" CACHE STRING "") + +include (cross-generic-gcc) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/zynq7-linux.cmake b/third-party/libmetal/cmake/platforms/zynq7-linux.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6143d90cf30c4c651fd8d07de94affb5352041ff --- /dev/null +++ b/third-party/libmetal/cmake/platforms/zynq7-linux.cmake @@ -0,0 +1,5 @@ +set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "") +set (CROSS_PREFIX "arm-xilinx-linux-gnueabi-" CACHE STRING "") +include (cross-linux-gcc) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/zynqmp-a53-freertos.cmake b/third-party/libmetal/cmake/platforms/zynqmp-a53-freertos.cmake new file mode 100644 index 0000000000000000000000000000000000000000..baa3bfafe554d48f5fa9731ee486e48ab1648d5c --- /dev/null +++ b/third-party/libmetal/cmake/platforms/zynqmp-a53-freertos.cmake @@ -0,0 +1,8 @@ +set (CMAKE_SYSTEM_PROCESSOR "aarch64" CACHE STRING "") +set (MACHINE "zynqmp_a53" CACHE STRING "") +set (CROSS_PREFIX "aarch64-none-elf-" CACHE STRING "") +set (CMAKE_C_FLAGS "" CACHE STRING "") + +include (cross-freertos-gcc) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/zynqmp-a53-generic.cmake b/third-party/libmetal/cmake/platforms/zynqmp-a53-generic.cmake new file mode 100644 index 0000000000000000000000000000000000000000..be4204f4aea2074e10766a5c89c2bee2b1be70f7 --- /dev/null +++ b/third-party/libmetal/cmake/platforms/zynqmp-a53-generic.cmake @@ -0,0 +1,8 @@ +set (CMAKE_SYSTEM_PROCESSOR "aarch64" CACHE STRING "") +set (MACHINE "zynqmp_a53" CACHE STRING "") +set (CROSS_PREFIX "aarch64-none-elf-" CACHE STRING "") +set (CMAKE_C_FLAGS "" CACHE STRING "") + +include (cross-generic-gcc) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/zynqmp-linux.cmake b/third-party/libmetal/cmake/platforms/zynqmp-linux.cmake new file mode 100644 index 0000000000000000000000000000000000000000..241407fa811b53ea104b9985e4e6c52012aa7aae --- /dev/null +++ b/third-party/libmetal/cmake/platforms/zynqmp-linux.cmake @@ -0,0 +1,5 @@ +set (CMAKE_SYSTEM_PROCESSOR "aarch64" CACHE STRING "") +set (CROSS_PREFIX "aarch64-linux-gnu-" CACHE STRING "") +include (cross-linux-gcc) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/zynqmp-r5-freertos.cmake b/third-party/libmetal/cmake/platforms/zynqmp-r5-freertos.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a756248fdf1df248981553176c2470826956b6b6 --- /dev/null +++ b/third-party/libmetal/cmake/platforms/zynqmp-r5-freertos.cmake @@ -0,0 +1,8 @@ +set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "") +set (MACHINE "zynqmp_r5" CACHE STRING "") +set (CROSS_PREFIX "armr5-none-eabi-" CACHE STRING "") +set (CMAKE_C_FLAGS "-mfloat-abi=soft -mcpu=cortex-r5" CACHE STRING "") + +include (cross-freertos-gcc) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/platforms/zynqmp-r5-generic.cmake b/third-party/libmetal/cmake/platforms/zynqmp-r5-generic.cmake new file mode 100644 index 0000000000000000000000000000000000000000..291d28b11053a21d10ba253bb4646cdd581f7a4c --- /dev/null +++ b/third-party/libmetal/cmake/platforms/zynqmp-r5-generic.cmake @@ -0,0 +1,10 @@ +set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "") +set (MACHINE "zynqmp_r5" CACHE STRING "") +set (CROSS_PREFIX "armr5-none-eabi-" CACHE STRING "") + +# Xilinx SDK version earlier than 2017.2 use mfloat-abi=soft by default to generat libxil +set (CMAKE_C_FLAGS "-mfloat-abi=hard -mfpu=vfpv3-d16 -mcpu=cortex-r5" CACHE STRING "") + +include (cross-generic-gcc) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/cmake/syscheck.cmake b/third-party/libmetal/cmake/syscheck.cmake new file mode 100644 index 0000000000000000000000000000000000000000..70225adb68cb80631f789aaa193de0ab5759332b --- /dev/null +++ b/third-party/libmetal/cmake/syscheck.cmake @@ -0,0 +1,14 @@ +# use "Generic" as CMAKE_SYSTEM_NAME + +if (WITH_ZEPHYR) + set (CMAKE_SYSTEM_NAME "Generic" CACHE STRING "") + string (TOLOWER "Zephyr" PROJECT_SYSTEM) + string (TOUPPER "Zephyr" PROJECT_SYSTEM_UPPER) + if (NOT WITH_ZEPHYR_LIB) + include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) + endif() + if (CONFIG_ARM) + set (MACHINE "arm" CACHE STRING "") + endif(CONFIG_ARM) + +endif (WITH_ZEPHYR) diff --git a/third-party/libmetal/doc/CMakeLists.txt b/third-party/libmetal/doc/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..89566381648d57d3d12f9b472f38d79f7469786e --- /dev/null +++ b/third-party/libmetal/doc/CMakeLists.txt @@ -0,0 +1,19 @@ +if (DOXYGEN_FOUND) + + configure_file (Doxyfile.in Doxyfile @ONLY) + + add_custom_target (doc ALL + ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + +install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html + DESTINATION share/doc/${PROJECT_NAME}) +install (FILES ${PROJECT_SOURCE_DIR}/README.md + DESTINATION share/doc/${PROJECT_NAME}) +install (FILES ${PROJECT_SOURCE_DIR}/LICENSE.md + DESTINATION share/doc/${PROJECT_NAME}) + +endif (DOXYGEN_FOUND) + +# vim: expandtab:ts=2:sw=2:smartindent diff --git a/third-party/libmetal/doc/Doxyfile.in b/third-party/libmetal/doc/Doxyfile.in new file mode 100644 index 0000000000000000000000000000000000000000..0d0b4d41473234171a0347fd90f76ac099a9909e --- /dev/null +++ b/third-party/libmetal/doc/Doxyfile.in @@ -0,0 +1,2385 @@ +# Doxyfile 1.8.9.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = libmetal + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@/ + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO, these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. +# Note: If this tag is empty the current directory is searched. + +INPUT = @PROJECT_SOURCE_DIR@/README.md +INPUT += @PROJECT_SOURCE_DIR@/LICENSE.md +INPUT += @PROJECT_SOURCE_DIR@/lib + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank the +# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, +# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, +# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, +# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, +# *.qsf, *.as and *.js. + +FILE_PATTERNS = *.c *.h + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = README.md + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the +# cost of reduced performance. This can be particularly helpful with template +# rich C++ code for which doxygen's built-in parser lacks the necessary type +# information. +# Note: The availability of this option depends on whether or not doxygen was +# compiled with the --with-libclang option. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = NO + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to NO can help when comparing the output of multiple runs. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /