2968 views|6 replies

2549

Posts

0

Resources
The OP
 

【BearPi-HM Micro】Part 4: Familiar with the Openharmomy compilation framework and serial port interactive output [Copy link]

This post was last edited by Digital Leaf on 2022-4-13 21:21

After a few days of practice, I have a better understanding of Openharmomy, such as how to compile a simple program into the system.

First, you need a source code program to implement the function, such as helloworld.c. You also need a BUILD.gn file. The .gn file is a compilation build file, similar to Cmake. Compared with Cmake, when the project scale increases to an unimaginable level, the compilation speed and the division of project modules become particularly important, and gn solves these two problems very well. The Openharmomy document introduces the relevant .gn coding standards.

The basic structure of BUILD.gn is as follows

import("//build/lite/config/component/lite_component.gni")

executable("生成的库名称") {
    output_name = "可执行文件名称"
    sources = [ "源文件" ]
    include_dirs = []
    defines = []
    cflags_c = []
    ldflags = []
}

lite_component("lite组件名") {
    features = [
        ":库文件",
    ]
}

Import the gni component, compile the source code into a library file, and then package the library file into a lite component. At the same time, define the name of the output executable file.

Similar to Cmake, BUILD.gn is also case sensitive. I made a mistake at first and it kept failing to compile.

The next step is to configure the ~\bearpi\project\bearpi-hm_micro_small\build\lite\components\applications.json file and add the lite component just defined

Save after adding, and then modify the single board configuration file ~\bearpi\project\bearpi-hm_micro_small\vendor\bearpi\bearpi_hm_micro\config.json

When you unbox it, you will see the built-in lock screen. The components defined by its functions are also seen here. Going back to the applications.json file just now, you can also find the screensaver related content. Compared with the simple helloworld serial port output, the lock screen relies on more components.

At the same time, it can also explain that after burning the source code in the previous article, there are only two applications. Here you can see the definition

Go to this directory and look for the original pictures of the lock screen. Pictures of the four seasons: spring, summer, autumn and winter

For details on how to modify the above files and what the parameters in each file mean, you can find a detailed introduction in the Openharmomy documentation, including internal structure descriptions and configuration examples.

Compile the entire source code, and burn the compiled file into BearPi-HM Micro as in the previous article

After the burning is completed, open the serial port assistant. Through the serial port assistant, you can use most of the Linux operating commands

Run the program we compiled and view the serial port output

./bin/helloworld


Successfully printed the contents of the source file

Throughout the whole process, I found that I had to deal with components quite often. OpenHarmony follows a layered design, which is divided into the kernel layer, system service layer, framework layer, and application layer from bottom to top. System functions are expanded step by step according to "system > subsystem > component". In the multi-device deployment scenario, it supports cutting out some unnecessary components according to actual needs. A subsystem is a logical concept, which is specifically composed of corresponding components.

A component is a reusable software unit that is a further decomposition of a subsystem. It contains source code, configuration files, resource files, and compilation scripts. It is a binary unit that can be independently built, integrated in binary form, and has independent verification capabilities.

This post is from Linux and Android

Latest reply

It gives me a headache to see the engineering configuration of this kind of text.   Details Published on 2022-4-19 17:42

6593

Posts

0

Resources
2
 

It is true that the Openharmomy compilation framework and components have to deal with each other quite often.

This post is from Linux and Android

Comments

There are so many rules to be familiar with.  Details Published on 2022-4-19 20:26
 
 

6841

Posts

11

Resources
3
 
It seems that I need to learn how to compile seriously. I feel a little dizzy looking at it!
This post is from Linux and Android

Comments

Openharmomy is not compatible with CMake  Details Published on 2022-4-19 20:25
 
 
 

7456

Posts

2

Resources
4
 

It gives me a headache to see the engineering configuration of this kind of text.

This post is from Linux and Android

Comments

The advantage is that it is free and does not require an IDE  Details Published on 2022-4-19 20:24
 
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 

2549

Posts

0

Resources
5
 
freebsder posted on 2022-4-19 17:42 It gives me a headache to see this kind of text engineering configuration.

The advantage is that it is free and does not require an IDE

This post is from Linux and Android
 
 
 

2549

Posts

0

Resources
6
 
lugl4313820 posted on 2022-4-14 08:41 It seems that I have to learn how to compile seriously. I feel a little dizzy looking at it!

Openharmomy is not compatible with CMake

This post is from Linux and Android
 
 
 

2549

Posts

0

Resources
7
 
Jacktang posted on 2022-4-14 07:15 It is true that the number of times the Openharmomy compilation framework and components are dealt with is still quite large

There are so many rules to be familiar with.

This post is from Linux and Android
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
Analog Electronics

<<Analog Electronics>> is a very good book, I hope it will be helpful to your design journey!

Infineon Position2Go Development Kit Review - skypinglee

This content is provided by EEWORLD Forum 1. Unboxing I am honored to participate in the evaluation of the Infineon Po ...

CAN IAP Example

This content is originally created by EEWORLD forum user Xueshan Feihu11 . If you want to reprint or use it for comm ...

TI's Several Important Notes on Ethernet

TI Ethernet has grown by leaps and bounds since its introduction and is now widely used in the commercial and enterprise ...

Commonly used techniques in PCB design

Commonly used techniques in PCB design In the current mainstream market, the most commonly used circuit diagram drawing ...

[Flower carving DIY] Interesting and fun music visualization series of small projects (04) --- WS2812 strip light

This post was last edited by eagler8 on 2021-10-8 19:08 I suddenly had the urge to do a series of topics on sound visua ...

[Xianji HPM6750 Review] Testing the Ethernet Controller ENET

HPM6750 has 2 Gigabit Ethernet controllers. The MINI board leads to a RMII interface Ethernet controller HPM_ENET1 PIN ...

Use GD32F407RET6 USART5 DMA to send and receive data

As the title says, there is no problem with DMA sending data, but the microcontroller cannot receive data, and the recei ...

Image Dimension Measuring Instrument: Analyzing Applicable Components and Application Fields

Image dimension measuring instrument is also called one-button measuring instrument, fully automatic flash measuring ins ...

[Monthly awards are given out!] February monthly awards are distributed! There are awards for original creation, question discussion, and reply to questions!

Good afternoon, friends~ The list of winners for the monthly prizes in February is out~~~ There are prizes for original ...

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list