readme.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. Sipeed MAIX-Dock Board
  2. ======================
  3. The Sipeed MAXI-Dock board is a dual-core RISC-V 64-bits board based on the
  4. Canaan Kendryte K210 SoC.
  5. Prerequisite
  6. ------------
  7. In order to use the kflash utility to program this board, the user must have
  8. access to the board USB serial device file. The simplest way to do this is to
  9. add your user to the same group as this device file. Assume the device file is
  10. /dev/ttyUSB0, first identify the device group name. In most cases, it is
  11. either "dialout" or "uucp". Also verify that read-write access is enabled for
  12. the group:
  13. ```
  14. $ ls -l /dev/ttyUSB0
  15. crw-rw---- 1 root dialout 188, 0 May 26 13:48 /dev/ttyUSB0
  16. ```
  17. Then add yourself to that group (dialout in this example):
  18. ```
  19. $ sudo usermod -a -G dialout $(whoami)
  20. ```
  21. To enable the above, it is sometimes necessary to logout and login again.
  22. Buildroot Configuration
  23. -----------------------
  24. Two buildroot configuration files are provided:
  25. (1) Direct Linux Kernel Boot
  26. This is defined by the sipeed_maix_dock_defconfig configuration. This
  27. configuration allows building a bootable kernel image with a built-in initramfs
  28. root file system (the board SD card is not used). The built kernel image can be
  29. flashed directly to the board ROM for direct booting. No boot loader is
  30. required.
  31. (2) U-Boot SD-Card Boot
  32. The sipeed_maix_dock_sdcard_defconfig configuration allows building a kernel
  33. image with the root file system on the board SD card. U-Boot is used as the
  34. boot loader.
  35. Note: U-Boot does not natively support the Sipeed MAIX-Dock board. However, the
  36. board and device tree differences with the Sipeed MAIX-Bit board are small
  37. enough for U-Boot to work.
  38. Both configuration files will also compile the pyserial-miniterm host tool open
  39. a serial terminal console for the board.
  40. Direct Linux Kernel Boot
  41. -------------------------
  42. Using the sipeed_maix_dock_defconfig configuration, the bootable kernel binary
  43. image is built as follows.
  44. ```
  45. $ make sipeed_maix_dock_defconfig
  46. $ make
  47. ```
  48. Both configuration files will also compile and install the kflash and
  49. pyserial-miniterm host utilities to program bootable image files to the board
  50. and open a serial terminal console.
  51. ```
  52. $ output/host/bin/kflash -b 1500000 -p /dev/ttyUSB0 -t output/images/loader.bin
  53. ```
  54. Once the kernel image file is fully programmed, a terminal console is open and
  55. the board can be rebooted by pressing the reset button on the board (if it does
  56. not reboot automatically).
  57. The output will be similar to the following.
  58. ```
  59. [ 0.000000] Linux version 5.18.0 (foo@bar.com) (riscv64-buildroot-linux-uclibc-gcc.br_real (Buildroot 2022.02-560-g6a2b542a09-dirty) 10.3.0, GNU ld (GNU Binutils) 2.32) #2 SMP Thu Apr 21 15:47:42 JST 2022
  60. [ 0.000000] Machine model: SiPeed MAIX Dock
  61. [ 0.000000] earlycon: sifive0 at MMIO 0x0000000038000000 (options '115200n8')
  62. [ 0.000000] printk: bootconsole [sifive0] enabled
  63. [ 0.000000] Zone ranges:
  64. [ 0.000000] DMA32 [mem 0x0000000080000000-0x00000000807fffff]
  65. [ 0.000000] Normal empty
  66. [ 0.000000] Movable zone start for each node
  67. [ 0.000000] Early memory node ranges
  68. [ 0.000000] node 0: [mem 0x0000000080000000-0x00000000807fffff]
  69. [ 0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x00000000807fffff]
  70. [ 0.000000] riscv: ISA extensions acdfim
  71. [ 0.000000] riscv: ELF capabilities acdfim
  72. [ 0.000000] percpu: max_distance=0x16000 too large for vmalloc space 0x0
  73. [ 0.000000] percpu: Embedded 11 pages/cpu s15264 r0 d29792 u45056
  74. [ 0.000000] percpu: wasting 10 pages per chunk
  75. [ 0.000000] Built 1 zonelists, mobility grouping off. Total pages: 2020
  76. [ 0.000000] Kernel command line: earlycon console=ttySIF0
  77. [ 0.000000] Dentry cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
  78. [ 0.000000] Inode-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
  79. [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
  80. [ 0.000000] Memory: 5980K/8192K available (964K kernel code, 137K rwdata, 205K rodata, 546K init, 66K bss, 2212K reserved, 0K cma-reserved)
  81. [ 0.000000] rcu: Hierarchical RCU implementation.
  82. [ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
  83. [ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
  84. [ 0.000000] riscv-intc: 64 local interrupts mapped
  85. [ 0.000000] plic: interrupt-controller@c000000: mapped 65 interrupts with 2 handlers for 4 contexts.
  86. [ 0.000000] k210-clk: clock-controller: CPU running at 390 MHz
  87. [ 0.000000] clint: timer@2000000: timer running at 7800000 Hz
  88. [ 0.000000] clocksource: clint_clocksource: mask: 0xffffffffffffffff max_cycles: 0x3990be68b, max_idle_ns: 881590404272 ns
  89. [ 0.000001] sched_clock: 64 bits at 7MHz, resolution 128ns, wraps every 4398046511054ns
  90. [ 0.008187] Calibrating delay loop (skipped), value calculated using timer frequency.. 15.60 BogoMIPS (lpj=31200)
  91. [ 0.018250] pid_max: default: 4096 minimum: 301
  92. [ 0.022859] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
  93. [ 0.029971] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
  94. [ 0.040238] rcu: Hierarchical SRCU implementation.
  95. [ 0.045110] smp: Bringing up secondary CPUs ...
  96. [ 0.050215] smp: Brought up 1 node, 2 CPUs
  97. [ 0.054345] devtmpfs: initialized
  98. [ 0.071112] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
  99. [ 0.080182] pinctrl core: initialized pinctrl subsystem
  100. [ 0.120689] clocksource: Switched to clocksource clint_clocksource
  101. [ 0.133165] workingset: timestamp_bits=62 max_order=11 bucket_order=0
  102. [ 0.181750] k210-sysctl 50440000.syscon: K210 system controller
  103. [ 0.198612] k210-rst 50440000.syscon:reset-controller: K210 reset controller
  104. [ 0.206644] cacheinfo: Unable to detect cache hierarchy for CPU 0
  105. [ 0.216569] i2c_dev: i2c /dev entries driver
  106. [ 0.225905] k210-fpioa 502b0000.pinmux: K210 FPIOA pin controller
  107. [ 0.238866] 38000000.serial: ttySIF0 at MMIO 0x38000000 (irq = 1, base_baud = 115200) is a SiFive UART v0
  108. [ 0.247778] printk: console [ttySIF0] enabled
  109. [ 0.247778] printk: console [ttySIF0] enabled
  110. [ 0.256459] printk: bootconsole [sifive0] disabled
  111. [ 0.256459] printk: bootconsole [sifive0] disabled
  112. [ 0.268225] panel@0 enforce active low on chipselect handle
  113. [ 0.285238] Freeing unused kernel image (initmem) memory: 540K
  114. [ 0.290372] This architecture does not have kernel memory protection.
  115. [ 0.296807] Run /init as init process
  116. __ _
  117. / / (_) ____ _ _ __ __
  118. / / | || _ \ | | | |\ \/ /
  119. / /___| || | | || |_| | > <
  120. /_____/|_||_| |_| \____|/_/\_\
  121. 64-bits RISC-V Kendryte K210 NOMMU
  122. / #
  123. ```
  124. To open a terminal console without re-flashing the board, the pyserial-miniterm
  125. host tool can be used.
  126. ```
  127. $ output/host/bin/pyserial-miniterm --raw --eol=LF /dev/ttyUSB0 115200
  128. ```
  129. The options "--raw" and "--eol=LF" are added here to avoid a double carriage
  130. return each time a command is entered.
  131. U-Boot SD-Card Boot
  132. -------------------
  133. The build procedure is similar to the built-in initramfs case.
  134. ```
  135. $ make sipeed_maix_dock_sdcard_defconfig
  136. $ make
  137. ```
  138. The build process will generate two files under the output/images directory.
  139. * sdcard.img: The image file for the SD card filesystem. This image has 2
  140. partitions. The first partition is a vfat partition containing the kernel
  141. uImage and the board device tree binary. The second partition is the root
  142. filesystem with busybox installed. The second partition is formatted using
  143. ext2 (rev1).
  144. * uboot.bin: U-Boot bootable binary to load and boot the kernel from the SD
  145. card.
  146. The SD card can be prepared by writing the sdcard.img file, as follows.
  147. ```
  148. $ sudo dd if=output/images/sdcard.img of=/dev/sdX bs=1M
  149. $ sync
  150. $ eject /dev/sdX
  151. ```
  152. Where /dev/sdX is the device file name of the SD card. Once completed, the SD
  153. card can be inserted into the board and the U-Boot binary image written to the
  154. board boot flash using the kflash utility.
  155. ```
  156. $ output/host/bin/kflash -b 1500000 -p /dev/ttyUSB0 -t output/images/u-boot.bin
  157. ```
  158. The above command will program U-Boot image to the board boot ROM and open a
  159. terminal console once the u-boot.bin file is fully programmed. Reboot into the
  160. newly programmed environment by pressing the board reset button if it does not
  161. reboot automatically.
  162. The output will be similar to the following.
  163. ```
  164. U-Boot 2022.04 (Apr 21 2022 - 15:59:50 +0900)
  165. DRAM: 8 MiB
  166. Core: 34 devices, 17 uclasses, devicetree: separate
  167. WDT: Not starting watchdog@50400000
  168. MMC: spi@53000000:slot@0: 0
  169. Loading Environment from SPIFlash... SF: Detected w25q128fw with page size 256 Bytes, erase size 4 KiB, total 16 MiB
  170. *** Warning - bad CRC, using default environment
  171. In: serial@38000000
  172. Out: serial@38000000
  173. Err: serial@38000000
  174. Hit any key to stop autoboot: 0
  175. 1717730 bytes read in 957 ms (1.7 MiB/s)
  176. 10382 bytes read in 11 ms (920.9 KiB/s)
  177. ## Booting kernel from Legacy Image at 80060000 ...
  178. Image Name: Linux
  179. Image Type: RISC-V Linux Kernel Image (uncompressed)
  180. Data Size: 1717666 Bytes = 1.6 MiB
  181. Load Address: 80000000
  182. Entry Point: 80000000
  183. Verifying Checksum ... OK
  184. ## Flattened Device Tree blob at 80400000
  185. Booting using the fdt blob at 0x80400000
  186. Loading Kernel Image
  187. Loading Device Tree to 00000000803fa000, end 00000000803ff88d ... OK
  188. Starting kernel ...
  189. [ 0.000000] Linux version 5.18.0 (foo@bar.com) (riscv64-buildroot-linux-uclibc-gcc.br_real (Buildroot 2022.02-560-g6a2b542a09-dirty) 10.3.0, GNU ld (GNU Binutils) 2.32) #1 SMP Thu Apr 21 16:00:03 JST 2022
  190. [ 0.000000] Machine model: SiPeed MAIX Dock
  191. [ 0.000000] earlycon: sifive0 at MMIO 0x0000000038000000 (options '115200n8')
  192. [ 0.000000] printk: bootconsole [sifive0] enabled
  193. [ 0.000000] Zone ranges:
  194. [ 0.000000] DMA32 [mem 0x0000000080000000-0x00000000807fffff]
  195. [ 0.000000] Normal empty
  196. [ 0.000000] Movable zone start for each node
  197. [ 0.000000] Early memory node ranges
  198. [ 0.000000] node 0: [mem 0x0000000080000000-0x00000000807fffff]
  199. [ 0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x00000000807fffff]
  200. [ 0.000000] riscv: ISA extensions acdfim
  201. [ 0.000000] riscv: ELF capabilities acdfim
  202. [ 0.000000] percpu: max_distance=0x16000 too large for vmalloc space 0x0
  203. [ 0.000000] percpu: Embedded 11 pages/cpu s15392 r0 d29664 u45056
  204. [ 0.000000] percpu: wasting 10 pages per chunk
  205. [ 0.000000] Built 1 zonelists, mobility grouping off. Total pages: 2020
  206. [ 0.000000] Kernel command line: earlycon console=ttySIF0 root=/dev/mmcblk0p2 rootwait ro
  207. [ 0.000000] Dentry cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
  208. [ 0.000000] Inode-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
  209. [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
  210. [ 0.000000] Memory: 6156K/8192K available (1180K kernel code, 151K rwdata, 239K rodata, 102K init, 69K bss, 2036K reserved, 0K cma-reserved)
  211. [ 0.000000] rcu: Hierarchical RCU implementation.
  212. [ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
  213. [ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
  214. [ 0.000000] riscv-intc: 64 local interrupts mapped
  215. [ 0.000000] plic: interrupt-controller@c000000: mapped 65 interrupts with 2 handlers for 4 contexts.
  216. [ 0.000000] k210-clk: clock-controller: CPU running at 390 MHz
  217. [ 0.000000] clint: timer@2000000: timer running at 7800000 Hz
  218. [ 0.000000] clocksource: clint_clocksource: mask: 0xffffffffffffffff max_cycles: 0x3990be68b, max_idle_ns: 881590404272 ns
  219. [ 0.000001] sched_clock: 64 bits at 7MHz, resolution 128ns, wraps every 4398046511054ns
  220. [ 0.008196] Calibrating delay loop (skipped), value calculated using timer frequency.. 15.60 BogoMIPS (lpj=31200)
  221. [ 0.018256] pid_max: default: 4096 minimum: 301
  222. [ 0.022876] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
  223. [ 0.029980] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
  224. [ 0.040401] rcu: Hierarchical SRCU implementation.
  225. [ 0.045379] smp: Bringing up secondary CPUs ...
  226. [ 0.050494] smp: Brought up 1 node, 2 CPUs
  227. [ 0.054656] devtmpfs: initialized
  228. [ 0.072338] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
  229. [ 0.081415] pinctrl core: initialized pinctrl subsystem
  230. [ 0.123902] clocksource: Switched to clocksource clint_clocksource
  231. [ 0.136898] workingset: timestamp_bits=62 max_order=11 bucket_order=0
  232. [ 0.182570] k210-sysctl 50440000.syscon: K210 system controller
  233. [ 0.198158] k210-rst 50440000.syscon:reset-controller: K210 reset controller
  234. [ 0.207473] cacheinfo: Unable to detect cache hierarchy for CPU 0
  235. [ 0.219724] i2c_dev: i2c /dev entries driver
  236. [ 0.230080] k210-fpioa 502b0000.pinmux: K210 FPIOA pin controller
  237. [ 0.243091] 38000000.serial: ttySIF0 at MMIO 0x38000000 (irq = 1, base_baud = 115200) is a SiFive UART v0
  238. [ 0.252034] printk: console [ttySIF0] enabled
  239. [ 0.252034] printk: console [ttySIF0] enabled
  240. [ 0.260656] printk: bootconsole [sifive0] disabled
  241. [ 0.260656] printk: bootconsole [sifive0] disabled
  242. [ 0.272546] panel@0 enforce active low on chipselect handle
  243. [ 0.308098] mmc_spi spi3.0: SD/MMC host mmc0, no WP, no poweroff, cd polling
  244. [ 0.320197] Waiting for root device /dev/mmcblk0p2...
  245. [ 0.344667] mmc0: host does not support reading read-only switch, assuming write-enable
  246. [ 0.352020] mmc0: new SDHC card on SPI
  247. [ 0.358566] mmcblk0: mmc0:0000 SA16G 14.5 GiB
  248. [ 0.366866] random: fast init done
  249. [ 0.371439] mmcblk0: p1 p2
  250. [ 0.391314] random: get_random_bytes called from 0x000000008009b7d2 with crng_init=1
  251. [ 0.400977] VFS: Mounted root (ext2 filesystem) readonly on device 179:2.
  252. [ 0.410966] devtmpfs: mounted
  253. [ 0.413521] Freeing unused kernel image (initmem) memory: 96K
  254. [ 0.418944] This architecture does not have kernel memory protection.
  255. [ 0.425370] Run /sbin/init as init process
  256. [ 0.633502] random: crng init done
  257. __ _
  258. / / (_) ____ _ _ __ __
  259. / / | || _ \ | | | |\ \/ /
  260. / /___| || | | || |_| | > <
  261. /_____/|_||_| |_| \____|/_/\_\
  262. 64-bits RISC-V Kendryte K210 NOMMU
  263. / #
  264. ```
  265. Of note is that the kernel mounts the SD card as read-only by default to avoid
  266. corruptions of the ext2 root file system when the board is powered down. This
  267. is recommended as this board does not support clean shutdown or halt.
  268. Similarly to the initramfs build case, a console can be open without
  269. re-flashing the board using the host tool pyserial-miniterm.
  270. ```
  271. $ output/host/bin/pyserial-miniterm --raw --eol=LF /dev/ttyUSB0 115200
  272. ```