quickstart-lite-steps-hi3516-program.md 22.0 KB
Newer Older
D
duangavin123 已提交
1
# Developing a Driver<a name="EN-US_TOPIC_0000001174350613"></a>
W
wenjun 已提交
2

[
[yang] 已提交
3
-   [Introduction to Driver](#s8efc1952ebfe4d1ea717182e108c29bb)
D
duangavin123 已提交
4
-   [Building Source Code and Burning Images](#section660016185110)
M
mamingshuai 已提交
5
-   [Running an Image](#section333215226219)
[
[yang] 已提交
6 7
-   [Follow-up Learning](#section9712145420182)

W
wenjun 已提交
8 9 10 11
This section describes how to develop a driver on the board, including introduction, compilation, burning, and running of the driver.

## Introduction to Driver<a name="s8efc1952ebfe4d1ea717182e108c29bb"></a>

E
ester.zhou 已提交
12
The following operations take a HDF-based UART driver as an example to show how to add configuration files, code the driver, and compile the code for interactions between the user-space applications and the driver. The driver source code is stored in the **drivers/framework/sample** directory.
W
wenjun 已提交
13 14 15

1.  Add Configurations.

N
NEEN 已提交
16
    Add driver configurations to the HDF driver configuration file \(for example,  **device/hisilicon/hi3516dv300/sdk\_liteos/config/uart/uart\_config.hcs**\).
W
wenjun 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

    ```
    root {
        platform {
            uart_sample {
                num = 5;            // UART device number
                base = 0x120a0000;  // Base address of the UART register
                irqNum = 38;
                baudrate = 115200;
                uartClk = 24000000;
                wlen = 0x60;
                parity = 0;
                stopBit = 0;
                match_attr = "sample_uart_5";
            }
        }
    }
    ```

N
NEEN 已提交
36
    Add the device node information to the HDF device configuration file \(for example,  **vendor/hisilicon/ipcamera\_hi3516dv300\_liteos/config/device\_info/device\_info.hcs**\)
W
wenjun 已提交
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

    ```
    root {
        device_info {
            platform :: host {
                hostName = "platform_host";
                priority = 50;
                device_uart :: device {
                    device5 :: deviceNode {
                        policy = 2;
                        priority = 10;
                        permission = 0660;
                        moduleName = "UART_SAMPLE";
                        serviceName = "HDF_PLATFORM_UART_5";
                        deviceMatchAttr = "sample_uart_5";
                    }
                }
            }
        }
    }
    ```

D
duangavin123 已提交
59
    >![](../public_sys-resources/icon-note.gif) **NOTE:** 
N
NEEN 已提交
60
    >The configuration files are in the same path as the source code of the UART driver. You need to manually add the files to the path of the Hi3516D V300 development board.
W
wenjun 已提交
61 62 63 64 65 66 67

2.  Register a UART driver entry.

    Register the  **HdfDriverEntry**  of the UART driver with the HDF.

    ```
    // Bind the UART driver interface to the HDF.
N
NEEN 已提交
68
    static int32_t SampleUartDriverBind(struct HdfDeviceObject *device)
W
wenjun 已提交
69
    {
N
NEEN 已提交
70 71
        struct UartHost *uartHost = NULL;
    
W
wenjun 已提交
72 73 74 75
        if (device == NULL) {
            return HDF_ERR_INVALID_OBJECT;
        }
        HDF_LOGI("Enter %s:", __func__);
N
NEEN 已提交
76 77 78 79 80 81 82 83
    
        uartHost = UartHostCreate(device);
        if (uartHost == NULL) {
            HDF_LOGE("%s: UartHostCreate failed", __func__);
            return HDF_FAILURE;
        }
        uartHost->service.Dispatch = SampleDispatch;
        return HDF_SUCCESS;
W
wenjun 已提交
84 85 86
    }
     
    // Obtain configuration information from the HCS of the UART driver.
N
NEEN 已提交
87
    static uint32_t GetUartDeviceResource(
W
wenjun 已提交
88 89 90 91 92 93 94 95 96
        struct UartDevice *device, const struct DeviceResourceNode *resourceNode)
    {
        struct UartResource *resource = &device->resource;
        struct DeviceResourceIface *dri = NULL;
        dri = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE);
        if (dri == NULL || dri->GetUint32 == NULL) {
            HDF_LOGE("DeviceResourceIface is invalid");
            return HDF_FAILURE;
        }
N
NEEN 已提交
97
    
W
wenjun 已提交
98 99 100 101 102 103 104 105
        if (dri->GetUint32(resourceNode, "num", &resource->num, 0) != HDF_SUCCESS) {
            HDF_LOGE("uart config read num fail");
            return HDF_FAILURE;
        }
        if (dri->GetUint32(resourceNode, "base", &resource->base, 0) != HDF_SUCCESS) {
            HDF_LOGE("uart config read base fail");
            return HDF_FAILURE;
        }
N
NEEN 已提交
106
        resource->physBase = (unsigned long)OsalIoRemap(resource->base, 0x48);
W
wenjun 已提交
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
        if (resource->physBase == 0) {
            HDF_LOGE("uart config fail to remap physBase");
            return HDF_FAILURE;
        }
        if (dri->GetUint32(resourceNode, "irqNum", &resource->irqNum, 0) != HDF_SUCCESS) {
            HDF_LOGE("uart config read irqNum fail");
            return HDF_FAILURE;
        }
        if (dri->GetUint32(resourceNode, "baudrate", &resource->baudrate, 0) != HDF_SUCCESS) {
            HDF_LOGE("uart config read baudrate fail");
            return HDF_FAILURE;
        }
        if (dri->GetUint32(resourceNode, "wlen", &resource->wlen, 0) != HDF_SUCCESS) {
            HDF_LOGE("uart config read wlen fail");
            return HDF_FAILURE;
        }
        if (dri->GetUint32(resourceNode, "parity", &resource->parity, 0) != HDF_SUCCESS) {
            HDF_LOGE("uart config read parity fail");
            return HDF_FAILURE;
        }
        if (dri->GetUint32(resourceNode, "stopBit", &resource->stopBit, 0) != HDF_SUCCESS) {
            HDF_LOGE("uart config read stopBit fail");
            return HDF_FAILURE;
        }
        if (dri->GetUint32(resourceNode, "uartClk", &resource->uartClk, 0) != HDF_SUCCESS) {
            HDF_LOGE("uart config read uartClk fail");
            return HDF_FAILURE;
        }
        return HDF_SUCCESS;
    }
     
    // Attach the configuration and interface of the UART driver to the HDF.
N
NEEN 已提交
139
    static int32_t AttachUartDevice(struct UartHost *host, struct HdfDeviceObject *device)
W
wenjun 已提交
140 141 142 143 144 145 146
    {
        int32_t ret;
        struct UartDevice *uartDevice = NULL;
        if (device->property == NULL) {
            HDF_LOGE("%s: property is NULL", __func__);
            return HDF_FAILURE;
        }
N
NEEN 已提交
147
        uartDevice = (struct UartDevice *)OsalMemCalloc(sizeof(struct UartDevice));
W
wenjun 已提交
148 149 150 151
        if (uartDevice == NULL) {
            HDF_LOGE("%s: OsalMemCalloc uartDevice error", __func__);
            return HDF_ERR_MALLOC_FAIL;
        }
N
NEEN 已提交
152
        ret = GetUartDeviceResource(uartDevice, device->property);
W
wenjun 已提交
153
        if (ret != HDF_SUCCESS) {
N
NEEN 已提交
154
            (void)OsalMemFree(uartDevice);
W
wenjun 已提交
155 156 157 158
            return HDF_FAILURE;
        }
        host->num = uartDevice->resource.num;
        host->priv = uartDevice;
N
NEEN 已提交
159 160
        AddUartDevice(host);
        return InitUartDevice(uartDevice);
W
wenjun 已提交
161 162 163
    }
     
    // Initialize the UART driver.
N
NEEN 已提交
164
    static int32_t SampleUartDriverInit(struct HdfDeviceObject *device)
W
wenjun 已提交
165 166 167
    {
        int32_t ret;
        struct UartHost *host = NULL;
N
NEEN 已提交
168
    
W
wenjun 已提交
169 170 171 172 173 174 175 176 177 178
        if (device == NULL) {
            HDF_LOGE("%s: device is NULL", __func__);
            return HDF_ERR_INVALID_OBJECT;
        }
        HDF_LOGI("Enter %s:", __func__);
        host = UartHostFromDevice(device);
        if (host == NULL) {
            HDF_LOGE("%s: host is NULL", __func__);
            return HDF_FAILURE;
        }
N
NEEN 已提交
179
        ret = AttachUartDevice(host, device);
W
wenjun 已提交
180 181 182 183
        if (ret != HDF_SUCCESS) {
            HDF_LOGE("%s: attach error", __func__);
            return HDF_FAILURE;
        }
N
NEEN 已提交
184
        host->method = &g_sampleUartHostMethod;
W
wenjun 已提交
185 186 187
        return ret;
    }
     
N
NEEN 已提交
188
    static void DeinitUartDevice(struct UartDevice *device)
W
wenjun 已提交
189
    {
N
NEEN 已提交
190
        struct UartRegisterMap *regMap = (struct UartRegisterMap *)device->resource.physBase;
W
wenjun 已提交
191 192 193 194
        /* Wait for the UART to enter the idle state. */
        while (UartPl011IsBusy(regMap));
        UartPl011ResetRegisters(regMap);
        uart_clk_cfg(0, false);
N
NEEN 已提交
195
        OsalIoUnmap((void *)device->resource.physBase);
W
wenjun 已提交
196 197 198 199
        device->state = UART_DEVICE_UNINITIALIZED;
    }
     
    // Detach and release the UART driver.
N
NEEN 已提交
200
    static void DetachUartDevice(struct UartHost *host)
W
wenjun 已提交
201 202
    {
        struct UartDevice *uartDevice = NULL;
N
NEEN 已提交
203
    
W
wenjun 已提交
204 205 206 207 208
        if (host->priv == NULL) {
            HDF_LOGE("%s: invalid parameter", __func__);
            return;
        }
        uartDevice = host->priv;
N
NEEN 已提交
209 210
        DeinitUartDevice(uartDevice);
        (void)OsalMemFree(uartDevice);
W
wenjun 已提交
211 212 213 214
        host->priv = NULL;
    }
     
    // Release the UART driver.
N
NEEN 已提交
215
    static void SampleUartDriverRelease(struct HdfDeviceObject *device)
W
wenjun 已提交
216 217 218
    {
        struct UartHost *host = NULL;
        HDF_LOGI("Enter %s:", __func__);
N
NEEN 已提交
219
    
W
wenjun 已提交
220
        if (device == NULL) {
N
NEEN 已提交
221
            HDF_LOGE("%s: device is NULL", __func__);
W
wenjun 已提交
222 223 224 225
            return;
        }
        host = UartHostFromDevice(device);
        if (host == NULL) {
N
NEEN 已提交
226
            HDF_LOGE("%s: host is NULL", __func__);
W
wenjun 已提交
227 228 229
            return;
        }
        if (host->priv != NULL) {
N
NEEN 已提交
230
            DetachUartDevice(host);
W
wenjun 已提交
231 232 233 234
        }
        UartHostDestroy(host);
    }
     
N
NEEN 已提交
235
    struct HdfDriverEntry g_sampleUartDriverEntry = {
W
wenjun 已提交
236 237
        .moduleVersion = 1,
        .moduleName = "UART_SAMPLE",
N
NEEN 已提交
238 239 240
        .Bind = SampleUartDriverBind,
        .Init = SampleUartDriverInit,
        .Release = SampleUartDriverRelease,
W
wenjun 已提交
241 242
    };
     
N
NEEN 已提交
243
    HDF_INIT(g_sampleUartDriverEntry);
W
wenjun 已提交
244 245 246 247 248 249 250
    ```

3.  Register a UART driver interface.

    Implement the UART driver interface using the template  **UartHostMethod**  provided by the HDF.

    ```
N
NEEN 已提交
251
    static int32_t SampleUartHostInit(struct UartHost *host)
W
wenjun 已提交
252 253 254 255 256 257 258 259 260
    {
        HDF_LOGI("%s: Enter", __func__);
        if (host == NULL) {
            HDF_LOGE("%s: invalid parameter", __func__);
            return HDF_ERR_INVALID_PARAM;
        }
        return HDF_SUCCESS;
    }
    
N
NEEN 已提交
261
    static int32_t SampleUartHostDeinit(struct UartHost *host)
W
wenjun 已提交
262 263 264 265 266 267 268 269 270 271
    {
        HDF_LOGI("%s: Enter", __func__);
        if (host == NULL) {
            HDF_LOGE("%s: invalid parameter", __func__);
            return HDF_ERR_INVALID_PARAM;
        }
        return HDF_SUCCESS;
    }
    
    // Write data into the UART device.
N
NEEN 已提交
272
    static int32_t SampleUartHostWrite(struct UartHost *host, uint8_t *data, uint32_t size)
W
wenjun 已提交
273 274 275 276 277
    {
        HDF_LOGI("%s: Enter", __func__);
        uint32_t idx;
        struct UartRegisterMap *regMap = NULL;
        struct UartDevice *device = NULL;
N
NEEN 已提交
278
    
W
wenjun 已提交
279 280 281 282
        if (host == NULL || data == NULL || size == 0) {
            HDF_LOGE("%s: invalid parameter", __func__);
            return HDF_ERR_INVALID_PARAM;
        }
N
NEEN 已提交
283
        device = (struct UartDevice *)host->priv;
W
wenjun 已提交
284 285 286 287
        if (device == NULL) {
            HDF_LOGE("%s: device is NULL", __func__);
            return HDF_ERR_INVALID_PARAM;
        }
N
NEEN 已提交
288
        regMap = (struct UartRegisterMap *)device->resource.physBase;
W
wenjun 已提交
289 290 291 292 293 294
        for (idx = 0; idx < size; idx++) {
            UartPl011Write(regMap, data[idx]);
        }
        return HDF_SUCCESS;
    }
     
[
[yang] 已提交
295
    // Set the baud rate for the UART device.
N
NEEN 已提交
296
    static int32_t SampleUartHostSetBaud(struct UartHost *host, uint32_t baudRate)
W
wenjun 已提交
297 298 299 300 301
    {
        HDF_LOGI("%s: Enter", __func__);
        struct UartDevice *device = NULL;
        struct UartRegisterMap *regMap = NULL;
        UartPl011Error err;
N
NEEN 已提交
302
    
W
wenjun 已提交
303 304 305 306
        if (host == NULL) {
            HDF_LOGE("%s: invalid parameter", __func__);
            return HDF_ERR_INVALID_PARAM;
        }
N
NEEN 已提交
307
        device = (struct UartDevice *)host->priv;
W
wenjun 已提交
308 309 310 311
        if (device == NULL) {
            HDF_LOGE("%s: device is NULL", __func__);
            return HDF_ERR_INVALID_PARAM;
        }
N
NEEN 已提交
312
        regMap = (struct UartRegisterMap *)device->resource.physBase;
W
wenjun 已提交
313 314 315 316 317 318 319 320 321 322 323 324 325 326
        if (device->state != UART_DEVICE_INITIALIZED) {
            return UART_PL011_ERR_NOT_INIT;
        }
        if (baudRate == 0) {
            return UART_PL011_ERR_INVALID_BAUD;
        }
        err = UartPl011SetBaudrate(regMap, device->uartClk, baudRate);
        if (err == UART_PL011_ERR_NONE) {
            device->baudrate = baudRate;
        }
        return err;
    }
     
    // Obtain the baud rate of the UART device.
N
NEEN 已提交
327
    static int32_t SampleUartHostGetBaud(struct UartHost *host, uint32_t *baudRate)
W
wenjun 已提交
328 329 330
    {
        HDF_LOGI("%s: Enter", __func__);
        struct UartDevice *device = NULL;
N
NEEN 已提交
331
    
W
wenjun 已提交
332 333 334 335
        if (host == NULL) {
            HDF_LOGE("%s: invalid parameter", __func__);
            return HDF_ERR_INVALID_PARAM;
        }
N
NEEN 已提交
336
        device = (struct UartDevice *)host->priv;
W
wenjun 已提交
337 338 339 340 341 342 343 344 345
        if (device == NULL) {
            HDF_LOGE("%s: device is NULL", __func__);
            return HDF_ERR_INVALID_PARAM;
        }
        *baudRate = device->baudrate;
        return HDF_SUCCESS;
    }
     
    // Bind the UART device using HdfUartSampleInit.
N
NEEN 已提交
346 347 348
    struct UartHostMethod g_sampleUartHostMethod = {
        .Init = SampleUartHostInit,
        .Deinit = SampleUartHostDeinit,
W
wenjun 已提交
349
        .Read = NULL,
N
NEEN 已提交
350 351 352
        .Write = SampleUartHostWrite,
        .SetBaud = SampleUartHostSetBaud,
        .GetBaud = SampleUartHostGetBaud,
W
wenjun 已提交
353 354 355 356 357 358
        .SetAttribute = NULL,
        .GetAttribute = NULL,
        .SetTransMode = NULL,
    };
    ```

N
NEEN 已提交
359
    Add the sample module of the UART driver to the compilation script  **device/hisilicon/drivers/lite.mk**.
W
wenjun 已提交
360 361 362

    ```
    LITEOS_BASELIB += -lhdf_uart_sample
E
ester.zhou 已提交
363
    LIB_SUBDIRS    += $(LITEOS_SOURCE_ROOT)/drivers/framework/sample/platform/uart
W
wenjun 已提交
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
    ```

4.  Implement the code for interaction between the user-space applications and driver.

    Create the  **/dev/uartdev-5**  node after the UART driver is initialized successfully. The following example shows how to interact with the UART driver through the node.

    ```
    #include <stdlib.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include "hdf_log.h"
    
    #define HDF_LOG_TAG "hello_uart"
    #define INFO_SIZE 16
    
    int main(void)
    {
        int ret;
        int fd;
        const char info[INFO_SIZE] = {" HELLO UART! "};
    
        fd = open("/dev/uartdev-5", O_RDWR);
        if (fd < 0) {
            HDF_LOGE("hello_uart uartdev-5 open failed %d", fd);
            return -1;
        }
        ret = write(fd, info, INFO_SIZE);
        if (ret != 0) {
            HDF_LOGE("hello_uart write uartdev-5 ret is %d", ret);
        }
        ret = close(fd);
        if (ret != 0) {
            HDF_LOGE("hello_uart uartdev-5 close failed %d", fd);
            return -1;
        }
        return ret;
    }
    ```

E
ester.zhou 已提交
403
    Add the  **hello\_uart\_sample**  component to  **targets**  of the  **hdf\_hi3516dv300\_liteos\_a**  component in the  **build/lite/components/hdf.json**  file.
W
wenjun 已提交
404 405 406

    ```
    {
N
NEEN 已提交
407
      "components": [
W
wenjun 已提交
408
        {
N
NEEN 已提交
409 410 411
          "component": "hdf_hi3516dv300_liteos_a",
          ...
          "targets": [
E
ester.zhou 已提交
412
            "//drivers/framework/sample/platform/uart:hello_uart_sample"
W
wenjun 已提交
413 414 415 416 417 418
          ]
        }
      ]
    }
    ```

D
duangavin123 已提交
419
    >![](../public_sys-resources/icon-note.gif) **NOTE:** 
E
ester.zhou 已提交
420
    >Preceding code snippets are for reference only. You can view the complete sample code in **drivers/framework/sample**.
W
wenjun 已提交
421 422 423
    >The sample code is not automatically compiled by default. You can add it to the compilation script.


D
duangavin123 已提交
424
## Building Source Code and Burning Images<a name="section660016185110"></a>
W
wenjun 已提交
425

D
duangavin123 已提交
426
Perform the  [building](quickstart-lite-steps-hi3516-running.md#section1077671315253)  and  [burning](quickstart-lite-steps-hi3516-running.md#section1347011412201)  as instructed in  **Running a Hello OHOS Program**.
W
wenjun 已提交
427

M
mamingshuai 已提交
428
## Running an Image<a name="section333215226219"></a>
W
wenjun 已提交
429 430 431

1.  Connect to a serial port.

D
duangavin123 已提交
432
    >![](../public_sys-resources/icon-notice.gif) **NOTICE:** 
D
duangavin123 已提交
433
    >If the connection fails, rectify the fault by referring to  [FAQs](quickstart-lite-steps-hi3516-faqs.md#section14871149155911).
N
NEEN 已提交
434

D
duangavin123 已提交
435
    **Figure  1**  Serial port connection<a name="fig124315964718"></a>  
D
duangavin123 已提交
436
    ![](figures/serial-port-connection.png "serial-port-connection")
W
wenjun 已提交
437

N
NEEN 已提交
438 439
    1.  Click  **Monitor**  to enable the serial port.
    2.  Press  **Enter**  repeatedly until  **hisilicon**  displays.
D
duangavin123 已提交
440
    3.  Go to step  [2](#li109940111259)  if the board is started for the first time or the startup parameters need to be modified; go to step  [3](#li448312542515)  otherwise.
W
wenjun 已提交
441

D
duangavin123 已提交
442
2.  <a name="li109940111259"></a>\(Mandatory when the board is started for the first time\) Modify the  **bootcmd**  and  **bootargs**  parameters of U-Boot. You need to perform this step only once if the parameters need not to be modified during the operation. The board automatically starts after it is reset.
W
wenjun 已提交
443

D
duangavin123 已提交
444
    >![](../public_sys-resources/icon-notice.gif) **NOTICE:** 
D
duangavin123 已提交
445
    >The default waiting time in the U-Boot is 2s. You can press  **Enter**  to interrupt the waiting and run the  **reset**  command to restart the system after "hisilicon" is displayed.
W
wenjun 已提交
446

D
duangavin123 已提交
447
    **Table  1**  Parameters of the U-Boot
W
wenjun 已提交
448

M
mamingshuai 已提交
449 450
    <a name="en-us_topic_0000001151888681_table1323441103813"></a>
    <table><thead align="left"><tr id="en-us_topic_0000001151888681_row1423410183818"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="en-us_topic_0000001151888681_p623461163818"><a name="en-us_topic_0000001151888681_p623461163818"></a><a name="en-us_topic_0000001151888681_p623461163818"></a>Command</p>
N
NEEN 已提交
451
    </th>
M
mamingshuai 已提交
452
    <th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="en-us_topic_0000001151888681_p42341014388"><a name="en-us_topic_0000001151888681_p42341014388"></a><a name="en-us_topic_0000001151888681_p42341014388"></a>Description</p>
W
wenjun 已提交
453
    </th>
N
NEEN 已提交
454 455
    </tr>
    </thead>
M
mamingshuai 已提交
456
    <tbody><tr id="en-us_topic_0000001151888681_row1623471113817"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001151888681_p102341719385"><a name="en-us_topic_0000001151888681_p102341719385"></a><a name="en-us_topic_0000001151888681_p102341719385"></a>setenv bootcmd "mmc read 0x0 0x80000000 0x800 0x4800; go 0x80000000";</p>
N
NEEN 已提交
457
    </td>
D
duangavin123 已提交
458
    <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001151888681_p92347120389"><a name="en-us_topic_0000001151888681_p92347120389"></a><a name="en-us_topic_0000001151888681_p92347120389"></a>Run this command to read content that has a size of 0x4800 (9 MB) and a start address of 0x800 (1 MB) to the memory address 0x80000000. The file size must be the same as that of the <strong id="b881982511127"><a name="b881982511127"></a><a name="b881982511127"></a>OHOS_Image.bin</strong> file in the IDE.</p>
W
wenjun 已提交
459 460
    </td>
    </tr>
M
mamingshuai 已提交
461
    <tr id="en-us_topic_0000001151888681_row12234912381"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001151888681_p172306219392"><a name="en-us_topic_0000001151888681_p172306219392"></a><a name="en-us_topic_0000001151888681_p172306219392"></a>setenv bootargs "console=ttyAMA0,115200n8 root=emmc fstype=vfat rootaddr=10M rootsize=20M rw";</p>
N
NEEN 已提交
462
    </td>
D
duangavin123 已提交
463 464
    <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001151888681_p13489329396"><a name="en-us_topic_0000001151888681_p13489329396"></a><a name="en-us_topic_0000001151888681_p13489329396"></a>Run this command to set the output mode to serial port output, baud rate to <strong id="b433815011512"><a name="b433815011512"></a><a name="b433815011512"></a>115200</strong>, data bit to <strong id="b1933919018155"><a name="b1933919018155"></a><a name="b1933919018155"></a>8</strong>, <strong id="b433912010151"><a name="b433912010151"></a><a name="b433912010151"></a>rootfs</strong> to be mounted to the <strong id="b83409014151"><a name="b83409014151"></a><a name="b83409014151"></a>emmc</strong> component, and file system type to <strong id="b133418081511"><a name="b133418081511"></a><a name="b133418081511"></a>vfat</strong>.</p>
    <p id="en-us_topic_0000001151888681_p12481832163913"><a name="en-us_topic_0000001151888681_p12481832163913"></a><a name="en-us_topic_0000001151888681_p12481832163913"></a><strong id="b1641214193158"><a name="b1641214193158"></a><a name="b1641214193158"></a>rootaddr=10M rootsize=20M rw</strong> indicates the start address and size of the <strong id="b1441320198151"><a name="b1441320198151"></a><a name="b1441320198151"></a>rootfs.img</strong> file to be burnt, respectively. The file size must be the same as that of the <strong id="b15414219161513"><a name="b15414219161513"></a><a name="b15414219161513"></a>rootfs.img</strong> file in the IDE.</p>
N
NEEN 已提交
465 466
    </td>
    </tr>
M
mamingshuai 已提交
467
    <tr id="en-us_topic_0000001151888681_row18234161153820"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001151888681_p823417118386"><a name="en-us_topic_0000001151888681_p823417118386"></a><a name="en-us_topic_0000001151888681_p823417118386"></a>saveenv</p>
N
NEEN 已提交
468
    </td>
D
duangavin123 已提交
469
    <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001151888681_p32341616389"><a name="en-us_topic_0000001151888681_p32341616389"></a><a name="en-us_topic_0000001151888681_p32341616389"></a><strong id="b8139162216169"><a name="b8139162216169"></a><a name="b8139162216169"></a>saveenv</strong> means to save the current configuration.</p>
N
NEEN 已提交
470 471
    </td>
    </tr>
M
mamingshuai 已提交
472
    <tr id="en-us_topic_0000001151888681_row192345113811"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="en-us_topic_0000001151888681_p7235111183819"><a name="en-us_topic_0000001151888681_p7235111183819"></a><a name="en-us_topic_0000001151888681_p7235111183819"></a>reset</p>
N
NEEN 已提交
473
    </td>
D
duangavin123 已提交
474
    <td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="en-us_topic_0000001151888681_p123781411114016"><a name="en-us_topic_0000001151888681_p123781411114016"></a><a name="en-us_topic_0000001151888681_p123781411114016"></a><strong id="b760219545018"><a name="b760219545018"></a><a name="b760219545018"></a>reset</strong> means to reset the board.</p>
W
wenjun 已提交
475 476 477 478 479
    </td>
    </tr>
    </tbody>
    </table>

D
duangavin123 已提交
480
    >![](../public_sys-resources/icon-notice.gif) **NOTICE:** 
D
duangavin123 已提交
481
    >**go 0x80000000**  is optional. It indicates that the command is fixed in the startup parameters by default and the board automatically starts after it is reset. If you want to manually start the board, press  **Enter**  in the countdown phase of the U-Boot startup to interrupt the automatic startup.
N
NEEN 已提交
482

D
duangavin123 已提交
483
3.  <a name="li448312542515"></a>Run the  **reset**  command and press  **Enter**  to restart the board. After the board is restarted,  **OHOS**  is displayed when you press  **Enter**.
W
wenjun 已提交
484

D
duangavin123 已提交
485
    **Figure  2**  System startup<a name="fig14618415485"></a>  
D
duangavin123 已提交
486
    ![](figures/system-startup.png "system-startup")
W
wenjun 已提交
487 488 489 490 491 492 493 494 495 496 497

4.  In the root directory, run the  **./bin/hello\_uart**  command line to execute the demo program. The compilation result is shown in the following example.

    ```
    OHOS # ./bin/hello_uart
    OHOS #  HELLO UART!
    ```


## Follow-up Learning<a name="section9712145420182"></a>

D
duangavin123 已提交
498
Congratulations! You have finished all steps! You are advised to go on learning how to develop  [Cameras with a Screen](../guide/device-iotcamera.md).
W
wenjun 已提交
499