Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:common:development:kbi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
products:sbc:common:development:kbi [2022/07/05 21:38]
nick created
products:sbc:common:development:kbi [2024/12/27 04:30] (current)
hyphop [Read for reference]
Line 1: Line 1:
-====== KBI ======+====== KBI - Khadas Bootloader Instructions ====== 
 + 
 +This page introduces about KBI. You will learn how to manage the status of Khadas SBC through KBI. 
 + 
 +<WRAP important > 
 +Khadas Bootloader Instructions(KBI) can be used to: 
 +  * Manage the programmable MCU 
 +  * Carry out low level hardware management 
 +  * Let developers utilise all the features of Khadas SBCs. 
 +</WRAP> 
 + 
 +<WRAP info > 
 +This page takes VIM2 as an example. 
 +</WRAP> 
 + 
 +===== Uboot usage ===== 
 + 
 +To get started, make sure 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 ''kbi'': 
 + 
 +```shell 
 +kvim2# kbi 
 +kbi - Khadas Bootloader Instructions sub-system 
 + 
 +Usage: 
 +kbi [function] [mode] [write|read] <value> 
 + 
 +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 <off|on|breathe|heartbeat> - set blue led mode 
 +kbi led [systemoff|systemon] r - read blue led mode 
 + 
 +kbi bootmode w <emmc|spi> - set bootmode to emmc or spi 
 +kbi bootmode r - read current bootmode 
 + 
 +kbi trigger [wol|rtc|ir|dcin|key|gpio] w <0|1> - disable/enable boot trigger 
 +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 distinguish between 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:aa:fc:60:44:c0 
 +``` 
 + 
 +==== LED Control ==== 
 + 
 +Setup the blue LED: 
 + 
 +The blue LED has 4 working modes: ''Always Off'', ''Always on'', ''Breathe'' and ''Heartbeat''. It indicates VIM working modes. 
 + 
 +The MCU,in charge of system power management, controls the blue LED. The CPU controls the white LED.  
 +In this case, the blue LED still work even VIM2 was powered off. 
 + 
 +The KBI can be used to program the blue LED for two working modes: 
 + 
 +  * system off / idle: power off status, the CPU is in power-down mode. 
 +  * system on / working: power on status, the CPU is in working mode. 
 + 
 +For example: 
 + 
 +To check the blue LED’s setting for ''system off'' / idle status: 
 + 
 +```shell 
 +kvim2# kbi led systemoff r 
 +led mode: breathe  [systemoff] 
 +``` 
 + 
 +To check the blue LED’s setting for ''system on'' / working status: 
 + 
 +```shell 
 +kvim2# kbi led systemon r 
 +led mode: off  [systemon] 
 +``` 
 +When VIM2 is powered on,the blue LED is ''Always off''.  
 + 
 +You can also reset it to ''breathe'' mode: 
 +```shell 
 +kvim2# kbi led systemon w breathe 
 +``` 
 + 
 +You can also change the setting for ''system on'' / working status: 
 + 
 +```shell 
 +kvim2# kbi led systemon w Heartbeat 
 +``` 
 + 
 +==== Boot Mode ==== 
 + 
 +You can flash the images to SPI or eMMC storage in VIM2, and setup one of them as the default boot media by KBI. 
 + 
 +Set the default boot media as the SPI: 
 + 
 +```shell 
 +kvim2# kbi bootmode w spi 
 +``` 
 + 
 +Set default boot media as eMMC storage: 
 + 
 +```shell 
 +kvim2# kbi bootmode w emmc 
 +``` 
 + 
 +You can take a review on the default boot media by running: 
 + 
 +```shell 
 +kvim2# kbi bootmode r 
 +bootmode: emmc 
 +``` 
 + 
 +==== Boot Trigger Events ==== 
 + 
 +VIM2 supports different events for triggering boot-up: 
 +  * WOL: Wake on Lan 
 +  * RTC: RTC timer 
 +  * IR: IR remote controller 
 +  * DCIN: Plug in the DC adapter 
 +  * Key: Power Key/Button 
 +  * GPIO: External GPIO events 
 +It means any of the above events can trigger VIM2 to power-on after that trigger event has been set to the ''enabled'' status. 
 + 
 +For example: 
 + 
 +  * Get the status of the WOL trigger event: \\ ```shell 
 +kvim2# kbi trigger wol r 
 +boot wol: disable 
 +``` 
 +  * WOL is disabled for the pre-installed ROM by default, you can enable it by writing a new value: \\ ```shell 
 +kvim2# kbi trigger wol w 1 
 +set_wol: 1 
 +``` 
 +  * In general, you will disable the WOL for security reasons. : \\ ```shell 
 +kvim2# kbi trigger wol w 0 
 +set_wol: 0 
 +``` 
 + 
 +====== Read for reference ====== 
 + 
 +  * [[dl>hardware/edge/mcu/edge-v_mcu_reg_en.pdf|Edge-V MCU Register Map]] 
 +  * [[dl>hardware/vim2/mcu/vim2_mcu_reg_en.pdf|VIM2 MCU Register Map]] 
 +  * [[dl>hardware/vim3/mcu/vim3_mcu_reg_en.pdf|VIM3 MCU Register Map]]
  
Last modified: 2022/07/05 21:38 by nick