1204 views|4 replies

221

Posts

2

Resources
The OP
 

「Star Flash Experience Tutorial」1. How to add your own application project [Copy link]

Preface

This is also my first time to use HiSilicon's SDK. I am not familiar with the corresponding build system. I just follow the configuration of other examples and refer to the Bear Pie tutorial.


1. Project directory structure

I created an iot directory in the samples directory to store my own projects. To add the contents of this directory to the compilation target, we need to modify the CMakeLists.txt file in the samples directory (I added it after the add_subdirectory_if_exist(custom) line) and add the following content:



add_subdirectory_if_exist(custom)
add_subdirectory_if_exist(iot)

Then modify the Kconfig file in the samples directory and add the following content. This content is actually very simple. If the Iot_sample feature is turned on, expand the Kconfig content in the iot directory.

config ENABLE_IOT_SAMPLE
    bool
    prompt "Enable the Sample of IoT."
    default n
    depends on SAMPLE_ENABLE
    help
        This option means enable the sample of IoT.

if ENABLE_IOT_SAMPLE
osource "application/samples/iot/Kconfig"
endif

Next, write the Kconfig file of the iot project and add the following content. The content is not complicated. If the Support IOT_PLC Sample feature is turned on, the iot_plc directory will be added to the build system. If you do not need a configurable type, you do not need to add this file.

#===============================================================================
# [url=home.php?mod=space&uid=159083]@brief[/url] Kconfig file.
# Copyright (c) @CompanyNameMagicTag 2023-2023. All rights reserved.
#===============================================================================

config SAMPLE_SUPPORT_IOT_PLC
    bool "Support IOT_PLC Sample"
    prompt "Support IOT_PLC Sample."
    default n
    help
        This option means support IOT PLC Sample.

Next, write the CMakeLists.txt file of the iot project to add the iot_plc directory to the build system. If no configuration is required, delete the judgment statement if (DEFINED CONFIG_SAMPLE_SUPPORT_IOT_PLC)

#===============================================================================
# @brief    cmake file
# Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved.
#===============================================================================

if(DEFINED CONFIG_SAMPLE_SUPPORT_IOT_PLC)
    add_subdirectory_if_exist(iot_plc)
endif()

set(SOURCES "${SOURCES}" PARENT_SCOPE)

Finally, we create the iot_plc directory (functional module directory), and then add the CMakeLists.txt file in the iot_plc directory. This file is modified according to the template of the Bear Pi. This modification will make it more convenient to add source code files and header files in the future.

#===============================================================================
# @brief    cmake file
# Copyright (c) CompanyNameMagicTag 2023-2023. All rights reserved.
#===============================================================================

set(SOURCES_LIST
    ${CMAKE_CURRENT_SOURCE_DIR}/iot.c
)

set(PUBLIC_HEADER_LIST
    ${CMAKE_CURRENT_SOURCE_DIR}
)

set(SOURCES "${SOURCES_LIST}" PARENT_SCOPE)
set(PUBLIC_HEADER "${PUBLIC_HEADER_LIST}" PARENT_SCOPE)

The last step is to add the iot.c file. I directly copied the contents of blinky.c, so there is no need to upload it. Of course, I also modified some contents.

2. Corresponding analysis of configuration files

As shown in the figure below, the Kconfig files under the same directory level are generally used to configure the optional contents in the corresponding CMakeLists.txt file. I have used different colors of text in the picture to represent different levels.

For example, SAMPLE_SUPPORT_IOT_PLC in Kconfig under the iot directory will directly affect the configuration in the CMakeLists.txt file under the iot directory. This configuration will affect whether the iot_plc directory is added to the compilation file.

If we need to add some configurable options to the iot_plc function module, we need to add a Kconfig file in iot_plc (in fact, it is also possible to add it in other files, but it will be very annoying if you forget the corresponding relationship after a long time).

3. Compile and burn

After adding, you can compile and burn it to the board for testing.

This post is from RF/Wirelessly

Latest reply

Huawei is really amazing, with all kinds of magic changes   Details Published on 2024-8-13 16:49
 

6570

Posts

0

Resources
2
 

You need to add a Kconfig file in iot_plc. In fact, you can also add it in other files.

This post is from RF/Wirelessly
 
 

6027

Posts

6

Resources
3
 

VS Code development? I don't see any development environment

This post is from RF/Wirelessly

Comments

VSCode plus command line, HiSilicon's own IDE is also a magic modification of VSCode  Details Published on 2024-8-13 15:35
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 
 

221

Posts

2

Resources
4
 
Qintianqintian0303 posted on 2024-8-13 14:55 VS Code development? I don’t see any development environment

VSCode plus command line, HiSilicon's own IDE is also a magic modification of VSCode

This post is from RF/Wirelessly

Comments

Huawei is really amazing, with all kinds of magic changes  Details Published on 2024-8-13 16:49
 
 
 

6027

Posts

6

Resources
5
 
walker2048 posted on 2024-8-13 15:35 VSCode plus command line, HiSilicon's own IDE is also a magic modification of VSCode

Huawei is really amazing, with all kinds of magic changes

This post is from RF/Wirelessly
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

快速回复 返回顶部 Return list