README_zh.md
1# device_soc_winnermicro
2
3#### 介绍
4
5本仓库托管联盛德芯片的样例代码,包含hal模块等。
6
7#### 目录
8
9```
10device/soc/
11├── wm800 # 芯片SOC名称
12├── ... # 芯片SOC名称
13|
14├── hals # hals适配目录
15│ └── console # 连接类接口适配目录
16├── Kconfig.liteos_m.defconfig # kconfig 默认宏配置
17├── Kconfig.liteos_m.series # W800系列soc配置宏
18└── Kconfig.liteos_m.soc # soc kconfig配置宏
19```
20
21#### 编译环境搭建
22
23系统要求: Ubuntu18.04 64位系统及以上版本。
24
25编译环境搭建包含如下几步:
26
271. 获取源码
282. 安装的库和工具
293. 安装Python3
304. 安装hb
315. 安装csky-abiv2-elf-gcc
32
33##### 获取源码
34
35```shell
36mkdir openharmony_winnermicro
37
38cd openharmony_winnermicro
39
40repo init -u git@gitee.com:openharmony/manifest.git -b master --no-repo-verify
41
42repo sync -c
43
44repo forall -c 'git lfs pull'
45```
46
47##### 安装的库和工具
48
49> - 通常系统默认安装samba、vim等常用软件。
50
51> - 使用如下apt-get命令安装下面的库和工具:
52
53```
54sudo apt-get install build-essential gcc g++ make zlib* libffi-dev e2fsprogs pkg-config flex bison perl bc openssl libssl-dev libelf-dev libc6-dev-amd64 binutils binutils-dev libdwarf-dev u-boot-tools mtd-utils gcc-arm-linux-gnueabi
55```
56
57##### 安装Python3
58
591. 打开Linux编译服务器终端。
602. 输入如下命令,查看python版本号:
61
62 ```
63 python3 --version
64 ```
65 1. 运行如下命令,查看Ubuntu版本:
66
67 ```
68 cat /etc/issue
69 ```
70
71 2. ubuntu 18安装python。
72 ```
73 sudo apt-get install python3.8
74 ```
75
763. 设置python和python3软链接为python3.8。
77
78 ```
79 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
80 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
81 ```
824. 安装并升级Python包管理工具(pip3),任选如下一种方式。
83
84 - **命令行方式:**
85
86 ```
87 sudo apt-get install python3-setuptools python3-pip -y
88 sudo pip3 install --upgrade pip
89 ```
90 - **安装包方式:**
91
92 ```
93 curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
94 python get-pip.py
95 ```
96
97##### 安装hb
98
991. 运行如下命令安装hb:
100
101 ```
102 pip3 uninstall ohos-build # 如果安装了hb,先卸载
103 pip3 install build/lite
104 ```
1052. 设置环境变量:
106
107 ```
108 vim ~/.bashrc
109 ```
110
111 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。
112
113 ```
114 export PATH=~/.local/bin:$PATH
115 ```
116
117 执行如下命令更新环境变量。
118
119 ```
120 source ~/.bashrc
121 ```
1223. 执行"hb -h",有打印以下信息即表示安装成功:
123
124 ```
125 usage: hb
126
127 OHOS build system
128
129 positional arguments:
130 {build,set,env,clean}
131 build Build source code
132 set OHOS build settings
133 env Show OHOS build env
134 clean Clean output
135
136 optional arguments:
137 -h, --help show this help message and exit
138 ```
139
140##### 安装csky-abiv2-elf-gcc
141
1421. 打开Linux编译服务器终端。
1432. 下载[csky-abiv2-elf-gcc 编译工具下载](https://occ.t-head.cn/community/download?id=3885366095506644992)
144 选择下载 csky-elfabiv2-tools-x86_64-minilibc-20210423.tar。
1453. 解压 csky-elfabiv2-tools-x86_64-minilibc-20210423.tar 安装包至\~/toolchain/路径下。
146
147 ```shell
148 cd toolchain
149 tar -zxvf csky-elfabiv2-tools-x86_64-minilibc-20210423.tar.gz
150 ```
1514. 设置环境变量。
152
153 ```
154 vim ~/.bashrc
155 ```
156
157 将以下命令拷贝到.bashrc文件的最后一行,保存并退出。
158
159 ```
160 export PATH=~/toolchain/bin:$PATH
161 ```
1625. 生效环境变量。
163
164 ```
165 source ~/.bashrc
166 ```
167
168#### 编译流程
169
170[编译构建使用指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-build-all.md)
171
172```shell
173hb set
174
175hihope
176 > neptune_iotlink_demo
177
178选择neptune_iotlink_demo
179
180hb build -f
181```
182
183#### 烧录打印
184
185windows下:
1861. 下载PC端固件烧录工具并安装(HW Upgrade Tools) [w800串口烧录工具下载参考](https://www.winnermicro.com/html/1/156/158/558.html)。
1872. 在代码根目录下执行编译命令hb build -f,编译成功会在out/neptune100/neptune_iotlink_demo/bin目录下生成 .fls文件。
1883. 通过USB转接线连接PC和w800开发板,在PC的设备管理器中确认与w800连接所用的COM口。
1894. 打开烧录工具(Upgrade_Tools),选定COM口并选择打开串口,选择固件为hihope_neptune100.fls文件,勾选擦除Flash(波特率:115200,型号:W80X)。
1905. 点击下载键等待烧录。
1916. 烧录成功图形界面会显示file success以及烧录成功之后的启动log,反之显示fail。
1927. 打开烧录工具(Upgrade_Tools),选择复位,可在图形界面看到板子启动log;或打开串口调试工具,RST按键启动板子,查看log。
193
194#### 相关仓
195
196* [device/board/hihope](https://gitee.com/openharmony-sig/device_board_hihope)
197* [vendor/hihope](https://gitee.com/openharmony-sig/vendor_hihope)