1.. _longan_nano:
2
3Sipeed Longan Nano
4##################
5
6.. image:: img/longan_nano.jpg
7     :align: center
8     :alt: longan_nano
9
10Overview
11********
12
13The Sipeed Longan Nano and Longan Nano Lite is an simple and tiny development board with
14an GigaDevice GD32VF103 SoC that based on N200 RISC-V IP core by Nuclei system technology.
15More information can be found on:
16
17- `Sipeed Longan website <https://longan.sipeed.com/en/>`_
18- `GD32VF103 datasheet <https://www.gigadevice.com/datasheet/gd32vf103xxxx-datasheet/>`_
19- `GD32VF103 user manual <https://www.gd32mcu.com/data/documents/userManual/GD32VF103_User_Manual_Rev1.4.pdf>`_
20- `Nuclei website <https://www.nucleisys.com/download.php>`_
21- `Nuclei Bumblebee core documents <https://github.com/nucleisys/Bumblebee_Core_Doc>`_
22- `Nuclei ISA Spec <https://doc.nucleisys.com/nuclei_spec/>`_
23
24Hardware
25********
26
27- 4 x universal 16-bit timer
28- 2 x basic 16-bit timer
29- 1 x advanced 16-bit timer
30- Watchdog timer
31- RTC
32- Systick
33- 3 x USART
34- 2 x I2C
35- 3 x SPI
36- 2 x I2S
37- 2 x CAN
38- 1 x USBFS(OTG)
39- 2 x ADC(10 channel)
40- 2 x DAC
41
42Supported Features
43==================
44
45The board configuration supports the following hardware features:
46
47.. list-table::
48   :header-rows: 1
49
50   * - Peripheral
51     - Kconfig option
52     - Devicetree compatible
53   * - GPIO
54     - :kconfig:option:`CONFIG_GPIO`
55     - :dtcompatible:`gd,gd32-gpio`
56   * - Machine timer
57     - :kconfig:option:`CONFIG_RISCV_MACHINE_TIMER`
58     - :dtcompatible:`riscv,machine-timer`
59   * - Nuclei ECLIC Interrupt Controller
60     - :kconfig:option:`CONFIG_NUCLEI_ECLIC`
61     - :dtcompatible:`nuclei,eclic`
62   * - PWM
63     - :kconfig:option:`CONFIG_PWM`
64     - :dtcompatible:`gd,gd32-pwm`
65   * - USART
66     - :kconfig:option:`CONFIG_SERIAL`
67     - :dtcompatible:`gd,gd32-usart`
68   * - I2C
69     - :kconfig:option:`CONFIG_I2C`
70     - :dtcompatible:`gd,gd32-i2c`
71   * - DAC
72     - :kconfig:option:`CONFIG_DAC`
73     - :dtcompatible:`gd,gd32-dac`
74
75Serial Port
76===========
77
78USART0 is on the opposite end of the USB.
79Connect to TX0 (PA9) and RX0 (PA10).
80
81Programming and debugging
82*************************
83
84Building & Flashing
85===================
86
87Here is an example for building the :zephyr:code-sample:`blinky` application.
88
89.. zephyr-app-commands::
90   :zephyr-app: samples/basic/blinky
91   :board: longan_nano
92   :goals: build flash
93
94When using a custom toolchain it should be enough to have the downloaded
95version of the binary in your ``PATH``.
96
97The default runner tries to flash the board via an external programmer using openocd.
98To flash via the USB port, select the DFU runner when flashing:
99
100.. code-block:: console
101
102   west flash --runner dfu-util
103
104Debugging
105=========
106
107You can debug an application in the usual way.  Here is an example for the
108:zephyr:code-sample:`blinky` application.
109
110.. zephyr-app-commands::
111   :zephyr-app: samples/basic/blinky
112   :board: longan_nano
113   :maybe-skip-config:
114   :goals: debug
115