This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
products:sbc:common:development:kbi [2022/07/05 21:39] nick |
products:sbc:common:development:kbi [2026/05/11 02:15] (current) nick |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== KBI (Khadas Bootloader Instructions) ====== | + | ====== KBI - Khadas Bootloader Instructions |
| + | |||
| + | This page introduces KBI. You will learn how to manage the status of a Khadas SBC through KBI. | ||
| + | |||
| + | <WRAP important > | ||
| + | Khadas Bootloader Instructions (KBI) can be used to: | ||
| + | * Manage the programmable MCU. | ||
| + | * Perform low-level hardware management. | ||
| + | * Enable developers to utilize all the features of Khadas SBCs. </ | ||
| + | </ | ||
| + | |||
| + | <WRAP info > | ||
| + | This page uses VIM2 as an example. | ||
| + | </ | ||
| + | |||
| + | ===== Uboot usage ===== | ||
| + | |||
| + | To get started, ensure you have booted into U-Boot: | ||
| + | |||
| + | ```shell | ||
| + | normal power off | ||
| + | boot wol: enable | ||
| + | Hit Enter or space or Ctrl+C key to stop autoboot -- : 0 | ||
| + | kvim2# _ | ||
| + | ``` | ||
| + | |||
| + | ==== Help information ===== | ||
| + | |||
| + | You can get help information by typing '' | ||
| + | |||
| + | ```shell | ||
| + | kvim2# kbi | ||
| + | kbi - Khadas Bootloader Instructions sub-system | ||
| + | |||
| + | Usage: | ||
| + | kbi [function] [mode] [write|read] < | ||
| + | |||
| + | kbi version - read version information | ||
| + | kbi usid - read usid information | ||
| + | kbi adc - read adc value | ||
| + | kbi powerstate - read power on state | ||
| + | kbi poweroff - power off device | ||
| + | kbi ethmac - read ethernet mac address | ||
| + | |||
| + | kbi led [systemoff|systemon] w < | ||
| + | kbi led [systemoff|systemon] r - read blue led mode | ||
| + | |||
| + | kbi bootmode w < | ||
| + | kbi bootmode r - read current bootmode | ||
| + | |||
| + | kbi trigger [wol|rtc|ir|dcin|key|gpio] w <0|1> - disable/ | ||
| + | kbi trigger [wol|rtc|ir|dcin|key|gpio] r - read mode of a boot trigger | ||
| + | ``` | ||
| + | |||
| + | ==== MCU verison ==== | ||
| + | |||
| + | Get the MCU firmware version: | ||
| + | |||
| + | ```shell | ||
| + | kvim2# kbi version | ||
| + | version: 03 | ||
| + | ``` | ||
| + | |||
| + | ==== Initialize ==== | ||
| + | |||
| + | Initialize the KBI: | ||
| + | |||
| + | ```shell | ||
| + | kvim2# kbi init | ||
| + | ``` | ||
| + | |||
| + | ==== Serial number ==== | ||
| + | |||
| + | Get the device serial number: | ||
| + | |||
| + | ```shell | ||
| + | kvim2# kbi usid | ||
| + | usid: 000000 | ||
| + | ``` | ||
| + | |||
| + | ==== ADC ==== | ||
| + | |||
| + | Get ADC value: | ||
| + | ```shell | ||
| + | kvim2# kbi adc | ||
| + | adc: 0x236 | ||
| + | ``` | ||
| + | |||
| + | The ADC value can be used to distinguish between different hardware modules. | ||
| + | |||
| + | ==== Power off ==== | ||
| + | |||
| + | Power off the device: | ||
| + | ```shell | ||
| + | kvim2# kbi poweroff | ||
| + | ``` | ||
| + | |||
| + | ==== MAC address ==== | ||
| + | |||
| + | Get the Ethernet MAC address: | ||
| + | ```shell | ||
| + | kvim2# kbi ethmac | ||
| + | mac address: 98: | ||
| + | ``` | ||
| + | |||
| + | ==== LED control ==== | ||
| + | |||
| + | The blue LED has four operating modes: '' | ||
| + | |||
| + | The MCU, which handles system power management, controls the blue LED. The CPU controls the white LED. | ||
| + | Therefore, the blue LED continues to function even when the VIM2 is powered off. | ||
| + | |||
| + | KBI can be used to program the blue LED for two operating modes: | ||
| + | |||
| + | * system off / idle: Power-off status, the CPU is in a power-down mode. | ||
| + | * system on / working: Power-on status, the CPU is in working mode. | ||
| + | |||
| + | Example: | ||
| + | |||
| + | To check the blue LED’s setting for '' | ||
| + | |||
| + | ```shell | ||
| + | kvim2# kbi led systemoff r | ||
| + | led mode: breathe | ||
| + | ``` | ||
| + | |||
| + | Check the blue LED setting for '' | ||
| + | |||
| + | ```shell | ||
| + | kvim2# kbi led systemon r | ||
| + | led mode: off [systemon] | ||
| + | ``` | ||
| + | When the VIM2 is powered on, the blue LED is set to '' | ||
| + | |||
| + | You can reset it to '' | ||
| + | ```shell | ||
| + | kvim2# kbi led systemon w breathe | ||
| + | ``` | ||
| + | |||
| + | You can also change the setting for '' | ||
| + | |||
| + | ```shell | ||
| + | kvim2# kbi led systemon w Heartbeat | ||
| + | ``` | ||
| + | |||
| + | ==== Boot mode ==== | ||
| + | |||
| + | You can flash images to either SPI flash or eMMC storage on the VIM2, and use KBI to set one of them as the default boot media. | ||
| + | |||
| + | Set the default boot media to SPI flash: | ||
| + | ```shell | ||
| + | kvim2# kbi bootmode w spi | ||
| + | ``` | ||
| + | |||
| + | Set default boot media to eMMC storage: | ||
| + | |||
| + | ```shell | ||
| + | kvim2# kbi bootmode w emmc | ||
| + | ``` | ||
| + | |||
| + | You can check the current default boot media setting: | ||
| + | |||
| + | ```shell | ||
| + | kvim2# kbi bootmode r | ||
| + | bootmode: emmc | ||
| + | ``` | ||
| + | |||
| + | ==== Boot trigger events ==== | ||
| + | |||
| + | The VIM2 supports several events to trigger boot-up: | ||
| + | * WOL: Wake-on-Lan | ||
| + | * RTC: RTC timer | ||
| + | * IR: IR remote controller | ||
| + | * DCIN: Plug in the DC adapter | ||
| + | * Key: Power Key/ | ||
| + | * GPIO: External GPIO events | ||
| + | This means any of the above events can trigger the VIM2 to power on, provided that the specific trigger event has been enabled. | ||
| + | |||
| + | For example: | ||
| + | |||
| + | * Get the status of the WOL trigger event: | ||
| + | ```shell | ||
| + | kvim2# kbi trigger wol r | ||
| + | boot wol: disable | ||
| + | ``` | ||
| + | * WOL is disabled by default in the pre-installed ROM. You can enable it: | ||
| + | ```shell | ||
| + | kvim2# kbi trigger wol w 1 | ||
| + | set_wol: 1 | ||
| + | ``` | ||
| + | * For security reasons, you may want to disable WOL: reasons. : | ||
| + | ```shell | ||
| + | kvim2# kbi trigger wol w 0 | ||
| + | set_wol: 0 | ||
| + | ``` | ||
| + | |||
| + | ====== Read for reference | ||
| + | |||
| + | * [[dl> | ||
| + | * [[dl> | ||
| + | * [[dl> | ||