readme.txt 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. Canaan KD233 Board
  2. ==================
  3. The Canaan KD233 is a dual-core RISC-V 64-bits board based on the Canaan
  4. 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. Unlike other K210 based boards (Sipeed boards), U-Boot does not work on the
  25. KD233 board due to the different wiring for the SD-Card mmc controller. As such,
  26. the KD233 board can only be used by directly booting into Linux Kernel.
  27. buildroot can be configured to do so using the canaan_kd233_defconfig
  28. configuration file. This configuration allows building a bootable kernel image
  29. with a built-in initramfs root file system (the board SD card is not used). The
  30. built kernel image can be flashed directly to the board ROM for direct booting.
  31. No boot loader is required.
  32. Once booted, the on-board SD card can be used by Linux.
  33. The configuration file will also compile and install the kflash and
  34. pyserial-miniterm host utilities to program bootable image files to the board
  35. and open a serial terminal console.
  36. Direct Linux Kernel Boot
  37. -------------------------
  38. Using the canaan_kd233_defconfig configuration, the bootable kernel binary image
  39. is built as follows.
  40. ```
  41. $ make canaan_kd233_defconfig
  42. $ make
  43. ```
  44. The bootable binary image is the output/images/loader.bin file. This image file
  45. can be written to the board boot flash using the kflash utility.
  46. ```
  47. $ output/host/bin/kflash -b 1500000 -p /dev/ttyUSB0 -t output/images/loader.bin
  48. ```
  49. Once the kernel image file is fully programmed, a terminal console is open and
  50. the board can be rebooted by pressing the reset button on the board (if it does
  51. not reboot automatically).
  52. The output will be similar to the following.
  53. ```
  54. [ 0.000000] Linux version 5.17.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 16:40:44 JST 2022
  55. [ 0.000000] Machine model: Kendryte KD233
  56. [ 0.000000] earlycon: sifive0 at MMIO 0x0000000038000000 (options '115200n8')
  57. [ 0.000000] printk: bootconsole [sifive0] enabled
  58. [ 0.000000] Zone ranges:
  59. [ 0.000000] DMA32 [mem 0x0000000080000000-0x00000000807fffff]
  60. [ 0.000000] Normal empty
  61. [ 0.000000] Movable zone start for each node
  62. [ 0.000000] Early memory node ranges
  63. [ 0.000000] node 0: [mem 0x0000000080000000-0x00000000807fffff]
  64. [ 0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x00000000807fffff]
  65. [ 0.000000] riscv: ISA extensions acdfim
  66. [ 0.000000] riscv: ELF capabilities acdfim
  67. [ 0.000000] percpu: max_distance=0x16000 too large for vmalloc space 0x0
  68. [ 0.000000] percpu: Embedded 11 pages/cpu s15264 r0 d29792 u45056
  69. [ 0.000000] percpu: wasting 10 pages per chunk
  70. [ 0.000000] Built 1 zonelists, mobility grouping off. Total pages: 2020
  71. [ 0.000000] Kernel command line: earlycon console=ttySIF0
  72. [ 0.000000] Dentry cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
  73. [ 0.000000] Inode-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
  74. [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
  75. [ 0.000000] Memory: 5984K/8192K available (964K kernel code, 137K rwdata, 205K rodata, 546K init, 66K bss, 2208K reserved, 0K cma-reserved)
  76. [ 0.000000] rcu: Hierarchical RCU implementation.
  77. [ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
  78. [ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
  79. [ 0.000000] riscv-intc: 64 local interrupts mapped
  80. [ 0.000000] plic: interrupt-controller@c000000: mapped 65 interrupts with 2 handlers for 4 contexts.
  81. [ 0.000000] k210-clk: clock-controller: CPU running at 390 MHz
  82. [ 0.000000] clint: timer@2000000: timer running at 7800000 Hz
  83. [ 0.000000] clocksource: clint_clocksource: mask: 0xffffffffffffffff max_cycles: 0x3990be68b, max_idle_ns: 881590404272 ns
  84. [ 0.000001] sched_clock: 64 bits at 7MHz, resolution 128ns, wraps every 4398046511054ns
  85. [ 0.008178] Calibrating delay loop (skipped), value calculated using timer frequency.. 15.60 BogoMIPS (lpj=31200)
  86. [ 0.018251] pid_max: default: 4096 minimum: 301
  87. [ 0.022861] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
  88. [ 0.029971] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
  89. [ 0.040234] rcu: Hierarchical SRCU implementation.
  90. [ 0.045110] smp: Bringing up secondary CPUs ...
  91. [ 0.050211] smp: Brought up 1 node, 2 CPUs
  92. [ 0.054340] devtmpfs: initialized
  93. [ 0.070401] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
  94. [ 0.079473] pinctrl core: initialized pinctrl subsystem
  95. [ 0.117795] clocksource: Switched to clocksource clint_clocksource
  96. [ 0.130245] workingset: timestamp_bits=62 max_order=11 bucket_order=0
  97. [ 0.176925] k210-sysctl 50440000.syscon: K210 system controller
  98. [ 0.192947] k210-rst 50440000.syscon:reset-controller: K210 reset controller
  99. [ 0.200870] cacheinfo: Unable to detect cache hierarchy for CPU 0
  100. [ 0.210947] i2c_dev: i2c /dev entries driver
  101. [ 0.220535] k210-fpioa 502b0000.pinmux: K210 FPIOA pin controller
  102. [ 0.232253] 38000000.serial: ttySIF0 at MMIO 0x38000000 (irq = 1, base_baud = 115200) is a SiFive UART v0
  103. [ 0.241202] printk: console [ttySIF0] enabled
  104. [ 0.241202] printk: console [ttySIF0] enabled
  105. [ 0.249818] printk: bootconsole [sifive0] disabled
  106. [ 0.249818] printk: bootconsole [sifive0] disabled
  107. [ 0.261664] panel@0 enforce active low on chipselect handle
  108. [ 0.275950] Freeing unused kernel image (initmem) memory: 540K
  109. [ 0.281098] This architecture does not have kernel memory protection.
  110. [ 0.287520] Run /init as init process
  111. __ _
  112. / / (_) ____ _ _ __ __
  113. / / | || _ \ | | | |\ \/ /
  114. / /___| || | | || |_| | > <
  115. /_____/|_||_| |_| \____|/_/\_\
  116. 64-bits RISC-V Kendryte K210 NOMMU
  117. / #
  118. ```
  119. To open a terminal console without re-flashing the board, the pyserial-miniterm
  120. host tool can be used.
  121. ```
  122. $ output/host/bin/pyserial-miniterm --raw --eol=LF /dev/ttyUSB0 115200
  123. ```
  124. The options "--raw" and "--eol=LF" are added here to avoid a double carriage
  125. return each time a command is entered.