diff --git a/docs/helios64/auto_poweron.md b/docs/helios64/auto_poweron.md new file mode 100644 index 0000000..a92dfaf --- /dev/null +++ b/docs/helios64/auto_poweron.md @@ -0,0 +1,79 @@ +Helios64 automatic power on circuitry when main power applied to the system so user does not need to press power button. +This is useful in case of loss of main power longer than UPS back up time. The system will automatically power on when main power return. + +![!Auto power on State](/helios64/img/auto-poweron/flowchart.png) + +U-Boot will enable Auto Power On and a [systemd-shutdown](https://www.freedesktop.org/software/systemd/man/systemd-shutdown.html) hook script to disable the Auto Power On during graceful shutdown. + + +By default the system need the user to press power button to power up. This behaviour can be changed by manipulating a set of GPIOs. +The circuitry uses [D Flip Flop](https://en.wikipedia.org/wiki/Flip-flop_(electronics)#D_flip-flop) and rely on RTC battery or UPS battery to keep the state. + +![!Auto Power On Schematic](/helios64/img/auto-poweron/schematic_flip_flop.png) + +| State | D | Clock | +|---------|-------|-------------| +| Enable | 1 | Rising edge | +| Disable | 0 | Rising edge | + + +## Auto Power On Control under Linux + +*AUTO_ON_EN_D* pin and *AUTO_ON_EN_CLK* pin is assigned to gpio **153** and gpio **154** respectively. +After exporting and configure the GPIOs as output (refer to [GPIO Control](/helios64/gpio/#gpio-control)), we will do bit-banging to configure the D Flip Flop. + +To enable the Auto Power On + +``` +echo 1 > /sys/class/gpio/gpio153/value +echo 0 > /sys/class/gpio/gpio154/value +sleep 0.1 +echo 1 > /sys/class/gpio/gpio154/value +sleep 0.1 +echo 0 > /sys/class/gpio/gpio154/value +``` + +To disable the Auto Power On + +``` +echo 0 > /sys/class/gpio/gpio153/value +echo 0 > /sys/class/gpio/gpio154/value +sleep 0.1 +echo 1 > /sys/class/gpio/gpio154/value +sleep 0.1 +echo 0 > /sys/class/gpio/gpio154/value +``` + +## Systemd-shutdown Script + +We put a script to disable Auto Power On during shutdown, located on + +`/lib/systemd/system-shutdown/disable_auto_poweron`. + +The script content: + +```bash +#!/bin/bash + +# Export GPIO +# AUTO_ON_D +echo 153 > /sys/class/gpio/export +# AUTO_EN_CLK +echo 154 > /sys/class/gpio/export + +echo out > /sys/class/gpio/gpio153/direction +echo out > /sys/class/gpio/gpio154/direction + +# Toggling the D Flip-Flop +echo 0 > /sys/class/gpio/gpio153/value +echo 0 > /sys/class/gpio/gpio154/value +sleep 0.1 +echo 1 > /sys/class/gpio/gpio154/value +sleep 0.1 +echo 0 > /sys/class/gpio/gpio154/value +``` + +!!! Info + Current implementation does not check whether there is loss of power event. + + diff --git a/docs/helios64/gpio.md b/docs/helios64/gpio.md index 37516d9..3e6632f 100644 --- a/docs/helios64/gpio.md +++ b/docs/helios64/gpio.md @@ -28,3 +28,83 @@ Helios64 provides 16 GPIOs via a 20-Pin header (P5). Those GPIOs are provided vi | 18 | EXP_P1_6 | | | 19 | EXP_P1_7 | | | 20 | - | GND | + +## Accessing GPIOs under Linux + +If the kernel supports debugfs (*CONFIG_DEBUG_FS=y*), list of GPIOs can be retrieved with the following command + +```bash +sudo cat /sys/kernel/debug/gpio +``` + +Look for the **gpiochip5: GPIOs XXX-YYY** section, whereas **XXX** is first GPIO number and **YYY** is last GPIO number of IO expander. + +``` +gpiochip5: GPIOs 496-511, parent: i2c/2-0020, 2-0020, can sleep: +``` + +Another way to get first GPIO number of the IO expander + +``` +cat /sys/bus/i2c/devices/2-0020/gpio/gpiochip*/base +``` + +Therefore the mapping between header P5 Pins and Sysfs GPIO numbers will be as described in the following table + +### GPIO Table + +| PIN | Sysfs GPIO number | Remarks | +|-----|------|-------------| +| 1 | - | 3.3V Supply | +| 2 | - | 5V Supply | +| 3 | - | GND | +| 4 | 496 | | +| 5 | 497 | | +| 6 | 498 | | +| 7 | 499 | | +| 8 | 500 | | +| 9 | 501 | | +| 10 | 502 | | +| 11 | 503 | | +| 12 | 504 | | +| 13 | 505 | | +| 14 | 506 | | +| 15 | 507 | | +| 16 | 508 | | +| 17 | 509 | | +| 18 | 510 | | +| 19 | 511 | | +| 20 | - | GND | + +### GPIO Control + +**1.** Export the GPIO number you want to use + +``` +echo N | sudo tee -a /sys/class/gpio/export +``` + +**2.** Set the direction, "out" for Output or "in" for Input + +``` +echo DIRECTION | sudo tee -a /sys/class/gpio/gpioN/direction +``` + +**3.** Now you can read or change the GPIO value + +To read GPIO value + +``` +cat /sys/class/gpio/gpioN/value +``` + +To change GPIO value (only if GPIO set as Output) + +``` +echo VALUE | sudo tee -a /sys/class/gpio/gpioN/value +``` + +!!! notes + Pay attention to the path, /sys/class/gpio/gpio**N**/ where **N** is the GPIO number. + + diff --git a/docs/helios64/img/auto-poweron/flowchart.png b/docs/helios64/img/auto-poweron/flowchart.png new file mode 100644 index 0000000..ce84be3 Binary files /dev/null and b/docs/helios64/img/auto-poweron/flowchart.png differ diff --git a/docs/helios64/img/auto-poweron/schematic_flip_flop.png b/docs/helios64/img/auto-poweron/schematic_flip_flop.png new file mode 100644 index 0000000..d8b94c3 Binary files /dev/null and b/docs/helios64/img/auto-poweron/schematic_flip_flop.png differ diff --git a/docs/helios64/img/pwm/fan_control_schematic.png b/docs/helios64/img/pwm/fan_control_schematic.png index b7b42ca..ffd6c4c 100644 Binary files a/docs/helios64/img/pwm/fan_control_schematic.png and b/docs/helios64/img/pwm/fan_control_schematic.png differ diff --git a/docs/helios64/img/pwm/fan_duty_cycle_formula.png b/docs/helios64/img/pwm/fan_duty_cycle_formula.png new file mode 100755 index 0000000..694f747 Binary files /dev/null and b/docs/helios64/img/pwm/fan_duty_cycle_formula.png differ diff --git a/docs/helios64/img/pwm/fan_speed_graph_stock_fan.png b/docs/helios64/img/pwm/fan_speed_graph_stock_fan.png new file mode 100755 index 0000000..73d0a57 Binary files /dev/null and b/docs/helios64/img/pwm/fan_speed_graph_stock_fan.png differ diff --git a/docs/helios64/img/pwm/fan_speed_graph_stock_fan_linux.png b/docs/helios64/img/pwm/fan_speed_graph_stock_fan_linux.png new file mode 100755 index 0000000..96b7f05 Binary files /dev/null and b/docs/helios64/img/pwm/fan_speed_graph_stock_fan_linux.png differ diff --git a/docs/helios64/img/pwm/fan_stock_photo.jpg b/docs/helios64/img/pwm/fan_stock_photo.jpg new file mode 100644 index 0000000..1e9694c Binary files /dev/null and b/docs/helios64/img/pwm/fan_stock_photo.jpg differ diff --git a/docs/helios64/img/ups/battery_level_schematic.png b/docs/helios64/img/ups/battery_level_schematic.png new file mode 100644 index 0000000..48b77b3 Binary files /dev/null and b/docs/helios64/img/ups/battery_level_schematic.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_lsusb_tree.png b/docs/helios64/img/usb/linux_gadget_das_lsusb_tree.png new file mode 100644 index 0000000..b657bd9 Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_lsusb_tree.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_lsusb_tree_raid.png b/docs/helios64/img/usb/linux_gadget_das_lsusb_tree_raid.png new file mode 100644 index 0000000..4465243 Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_lsusb_tree_raid.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_thunar_5_drive.png b/docs/helios64/img/usb/linux_gadget_das_thunar_5_drive.png new file mode 100644 index 0000000..e2083c6 Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_thunar_5_drive.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_thunar_raid.png b/docs/helios64/img/usb/linux_gadget_das_thunar_raid.png new file mode 100644 index 0000000..9072895 Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_thunar_raid.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_usbview.png b/docs/helios64/img/usb/linux_gadget_das_usbview.png new file mode 100644 index 0000000..5c10128 Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_usbview.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_usbview_raid.png b/docs/helios64/img/usb/linux_gadget_das_usbview_raid.png new file mode 100644 index 0000000..79f3217 Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_usbview_raid.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_windows_device_manager.png b/docs/helios64/img/usb/linux_gadget_das_windows_device_manager.png new file mode 100644 index 0000000..ce5f9d3 Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_windows_device_manager.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_windows_device_manager_raid.png b/docs/helios64/img/usb/linux_gadget_das_windows_device_manager_raid.png new file mode 100755 index 0000000..60f1006 Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_windows_device_manager_raid.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_windows_diskmgmt.png b/docs/helios64/img/usb/linux_gadget_das_windows_diskmgmt.png new file mode 100755 index 0000000..8a7b1b5 Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_windows_diskmgmt.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_windows_diskmgmt_raid.png b/docs/helios64/img/usb/linux_gadget_das_windows_diskmgmt_raid.png new file mode 100755 index 0000000..8a75880 Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_windows_diskmgmt_raid.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_windows_usbtreeview.png b/docs/helios64/img/usb/linux_gadget_das_windows_usbtreeview.png new file mode 100755 index 0000000..5549fb5 Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_windows_usbtreeview.png differ diff --git a/docs/helios64/img/usb/linux_gadget_das_windows_usbtreeview_raid.png b/docs/helios64/img/usb/linux_gadget_das_windows_usbtreeview_raid.png new file mode 100755 index 0000000..2fc206e Binary files /dev/null and b/docs/helios64/img/usb/linux_gadget_das_windows_usbtreeview_raid.png differ diff --git a/docs/helios64/pwm.md b/docs/helios64/pwm.md index 7e101b3..3a76831 100644 --- a/docs/helios64/pwm.md +++ b/docs/helios64/pwm.md @@ -35,7 +35,7 @@ The term *duty cycle* describes the proportion of 'on' time to the regular inter ## PWM Fan Connector -![Fan Connector](/helios4/img/pwm/fan_connector.png) +![Fan Connector](/helios64/img/pwm/fan_connector.png) Connector Pinout @@ -45,3 +45,162 @@ Connector Pinout | 2 | 12V | Red | | 3 | Sense | Yellow | | 4 | Control | Blue | + + +## Stock Fan + +![!Type-C Fan](/helios64/img/pwm/fan_stock_photo.jpg) + +Fan Specification + +| Parameter | Value | Unit | Remarks | +|---------------|----------|------|---------| +| Maximum Speed | 3600 | RPM | @ duty cycle 98% | +| Minimum Speed | 350 | RPM | @ duty cycle 10% | +| Shut off | Yes | | duty cycle < 6.5% and restart @ duty cycle > 9.5% | +| Implementation Type | C | | | + +![!Type-C Speed Graph](/helios64/img/pwm/fan_speed_graph_stock_fan.png) + +!!! info + Duty cycle data is converted from Linux PWM + +## Helios64 Temperature Sensors + +### SoC Temperature Sensor + +RK3399 has internal temperature sensor (TS-ADC) for monitoring die temperature. The system has two Temperature Sensors, channel 0 is for CPU, channel 1 is for GPU. + +The sensor has -40~125°C temperature range and 5°C temperature resolution. + +### Board Temp Sensor + +Helios64 has a **Digital Temperature Sensor with 2‐wire Interface** ([NCT75 Datasheet](https://www.onsemi.com/pub/Collateral/NCT75-D.PDF)), located on top side of the board near RTC battery. It is used to read ambient temperature. + +## PWM Fan Control under Linux + +Linux use 8-bit integer to represent duty cycle. PWM value 0 represent 0% duty cycle and PWM value 255 represent 100% duty cycle. + +![Duty Cycle Formula](/helios64/img/pwm/fan_duty_cycle_formula.png) + +Below graphs are stock fan speed vs pwm value instead of duty cycle. + +![!Stock Fan Speed Graph](/helios64/img/pwm/fan_speed_graph_stock_fan_linux.png) + +### Using SYSFS interface + +Linux export the fan control mechanism to SYSFS under hwmon class. +List of devices can be checked under /sys/class/hwmon + +``` +ls -l /sys/class/hwmon/ +total 0 +lrwxrwxrwx 1 root root 0 Oct 16 08:38 hwmon0 -> ../../devices/virtual/thermal/thermal_zone0/hwmon0 +lrwxrwxrwx 1 root root 0 Oct 16 08:38 hwmon1 -> ../../devices/virtual/thermal/thermal_zone1/hwmon1 +lrwxrwxrwx 1 root root 0 Oct 16 08:38 hwmon2 -> ../../devices/platform/ff120000.i2c/i2c-2/2-004c/hwmon/hwmon2 +lrwxrwxrwx 1 root root 0 Oct 16 09:29 hwmon3 -> ../../devices/platform/gpio-charger/power_supply/gpio-charger/hwmon3 +lrwxrwxrwx 1 root root 0 Oct 16 09:29 hwmon4 -> ../../devices/platform/p7-fan/hwmon/hwmon4 +lrwxrwxrwx 1 root root 0 Oct 16 09:29 hwmon5 -> ../../devices/platform/p6-fan/hwmon/hwmon5 +lrwxrwxrwx 1 root root 0 Oct 16 09:29 hwmon6 -> ../../devices/platform/ff3d0000.i2c/i2c-4/4-0022/power_supply/tcpm-source-psy-4-0022/hwmon6 +``` + +!!! info + The numbering may different from above example output. It depends on whether the driver built as kernel module or built-in, device initialization order. Take this as consideration when using [fancontrol](#fancontrol-automated-software-based-fan-speed-control) + +To identify which hwmon belong to fan, look for *p6-fan* and *p7-fan*. On above example + +``` +hwmon4 -> ../../devices/platform/p7-fan/hwmon/hwmon4 +hwmon5 -> ../../devices/platform/p6-fan/hwmon/hwmon5 +``` + +To read current PWM +``` +cat /sys/class/hwmon4/pwm1 +cat /sys/class/hwmon5/pwm1 +``` + +To set PWM +``` +echo NEW_PWM_VALUE > /sys/class/hwmon4/pwm1 +echo NEW_PWM_VALUE > /sys/class/hwmon5/pwm1 +``` + +### Fancontrol - automated software based fan speed control + +fancontrol is a shell script for use with lm_sensors. It reads its configuration from a file, then calculates fan speeds from temperatures and sets the corresponding PWM outputs to the computed values. + +``` +sudo apt-get install fancontrol +``` + +fancontrol includes *pwmconfig* script to create automatically a configuration file but it can not be used for Helios64. + +#### UDEV rules + +Since hwmon order can be changed between kernel version or even between reboot, on Armbian we use udev rules as workaround. The rules can be found from [here](https://raw.githubusercontent.com/armbian/build/master/packages/bsp/helios64/90-helios64-hwmon.rules) (mainline) or [here](https://raw.githubusercontent.com/armbian/build/master/packages/bsp/helios64/90-helios64-hwmon-legacy.rules) (legacy kernel 4.4) and to be copied to **/etc/udev/rules.d/** + +*/dev/fan-p6, /dev/fan-p7, /dev/thermal-cpu* and */dev/thermal-board* are symlinks generated by the udev rules. + +#### Configuration File + +fancontrol uses **/etc/fancontrol** as configuration file. Below is an example configuration to control fan speed on Helios64. + +``` +# Helios64 PWM Fan Control Configuration +# Temp source : /dev/thermal-cpu +INTERVAL=10 +FCTEMPS=/dev/fan-p6/pwm1=/dev/thermal-cpu/temp1_input /dev/fan-p7/pwm1=/dev/thermal-cpu/temp1_input +MINTEMP=/dev/fan-p6/pwm1=40 /dev/fan-p7/pwm1=40 +MAXTEMP=/dev/fan-p6/pwm1=80 /dev/fan-p7/pwm1=80 +MINSTART=/dev/fan-p6/pwm1=20 /dev/fan-p7/pwm1=20 +MINSTOP=/dev/fan-p6/pwm1=29 /dev/fan-p7/pwm1=29 +MINPWM=20 +``` + +INTERVAL + +This variable defines at which interval in seconds the main loop of fancontrol will be executed. + +FCTEMPS + +Maps PWM outputs to temperature sensors so fancontrol knows which temperature sensors should be used for calculation of new values for the corresponding PWM outputs. + +Fans (**fan-p6** & **fan-p7**) are controlled based on CPU thermal sensor (**thermal-cpu**) reading. + +MINSTART + +Sets the minimum speed at which the fan begins spinning. You should use a safe value to be sure it works, even when the fan gets old. + +Stock fan restart at 15, added 5 for safety (in case of aging fan) give us **20**. + +MINSTOP + +The minimum speed at which the fan still spins. Use a safe value here, too. + +Stock fan stopped at 24, added 5 for safety (in case of aging fan) give us **29**. + +----- + +*Following settings can be adjusted by user to tweak further.* + +MINTEMP + +The temperature below which the fan gets switched to minimum speed. + +Fans (fan-p6 & fan-p7) runs in minimum speed if the CPU temperature below **40** degree C. + +MAXTEMP + +The temperature over which the fan gets switched to maximum speed. + +Fans (fan-p6 & fan-p7) runs in maximum speed if the CPU temperature above **80** degree C. + +MINPWM + +The PWM value to use when the temperature is below MINTEMP. Typically, this will be either 0 if it is OK for the fan to plain stop, or the same value as MINSTOP if you don't want the fan to ever stop. If this value isn't defined, it defaults to 0 (stopped fan). + +!!! note + The Helios64 fancontrol configuration file can be found [here](https://github.com/armbian/build/blob/master/packages/bsp/helios64/fancontrol.conf). + + diff --git a/docs/helios64/rtc.md b/docs/helios64/rtc.md index 3c98724..3b64755 100644 --- a/docs/helios64/rtc.md +++ b/docs/helios64/rtc.md @@ -14,3 +14,72 @@ To save time information and allow the RTC to keep running while system is power !!! Note The polarity of the battery holder is indicated on the PCB with **'+'** signs. + + +## Scheduled Power On using RTC + +User can set up a scheduled power on using RTC alarm. + +### Use SYSFS + +Run following command to check whether there is any alarm set, + +```bash +cat /sys/class/rtc/rtc0/wakealarm +``` +If nothing return, it means no alarm set. +To reset/disable the alarm, run + +```bash +echo 0 | sudo tee /sys/class/rtc/rtc0/wakealarm +``` + +The alarm only accept Unix epoch time. We can use *[date](https://linux.die.net/man/1/date)* utility as helper to get epoch time of our calendar. + +To set alarm from absolute calendar time, run + +```bash +echo `date '+%s' -d '20 December 2020 02:14:10 PM'` | sudo tee /sys/class/rtc/rtc0/wakealarm +``` +You can also set alarm from relative time using this command, + +```bash +echo `date '+%s' -d '+ 1 hour 2 minutes 10 seconds'` | sudo tee /sys/class/rtc/rtc0/wakealarm +``` + +After alarm set, you can power off the system and keep the power plugged in. Helios64 should automatically power on at the scheduled time. + +### Use rtcwake + +Run following command to check whether there is any alarm set, + +```bash +sudo rtcwake -m show +``` + +To reset/disable the alarm, run + +```bash +sudo rtcwake -m disable +``` + +To set alarm from absolute calendar time, run + +```bash +sudo rtcwake -m off --date '2020-12-20 14:14:10' +``` + +You can also set alarm from relative time using this command, + +```bash +sudo rtcwake -m off --date '+ 1 hour 2 minutes 10 seconds' +``` + +After the command successfully executed, system will shutdown. Keep the power plugged in and Helios64 should autommatically power on at the scheduled time. + +## References + +[date- Linux manual page](https://linux.die.net/man/1/date) + +[rtcwake - Linux manual page](https://linux.die.net/man/8/rtcwake) + diff --git a/docs/helios64/sata.md b/docs/helios64/sata.md index 3782f1f..6c6a865 100644 --- a/docs/helios64/sata.md +++ b/docs/helios64/sata.md @@ -37,6 +37,8 @@ The power delivery of the HDDs is devided into two group: Helios64 implements a power staggering approach where *HDD Rail A* will be powered up first, then few seconds later *HDD Rail B* will be powered up. This power control scenario is performed to reduce the inrush current during disk spin-up. +The power staggering mechanism is not user configurable. It is done by bootloader. + ### J8 Pinout ![J8 Location](/helios64/img/sata/j8_pinout.jpg) diff --git a/docs/helios64/ups.md b/docs/helios64/ups.md index c1ff3f4..930d380 100644 --- a/docs/helios64/ups.md +++ b/docs/helios64/ups.md @@ -36,7 +36,7 @@ The battery pack is rated 7.2V 3180mAh (22.9Wh) with max continuous discharge of ## Charge Management -Battery charge is fully managed by hardware, no software required. Charging function still operates when system is powered off. Helios64 board provides a visual charging indicator on LED9. +Battery charge is fully managed by hardware ([Texas Instrument BQ24133](https://www.ti.com/product/BQ24133)), no software required. Charging function still operates when system is powered off. Helios64 board provides a visual charging indicator on LED9. |LED State | Description | |-----------|-------------| @@ -45,3 +45,66 @@ Battery charge is fully managed by hardware, no software required. Charging func | Blinking | Fault / Battery Absent | **Note:** The estimated time to fully charge the empty battery is around 4 hours. + +## UPS Status Under Linux + +In Linux, the UPS declared as gpio-charger located at +`/sys/class/power_supply/gpio-charger` + + +### Main Power Status + +Main Power status can be read using + +```bash +cat /sys/class/power_supply/gpio-charger/online +``` + +**1** means power adapter supplying the power. + +**0** means loss of power, power adapter no longer supplying power. + +### Charging Status + +!!! Note + This status is unavailable on Linux Kernel 4.4 + +Battery charging status can be read using + +```bash +cat /sys/class/power_supply/gpio-charger/status +``` + +It will return **Charging** or **Not Charging** + +!!! Info + The status is only **valid** when main power is available. + + *Fault / Battery Absent* status is unavailable but it can be concluded if the status keep changing. + +### Battery Level + +Battery voltage can be measured on internal ADC channel 2. The internal ADC is located at +`/sys/bus/iio/devices/iio:device0` + +![!Battery level](/helios64/img/ups/battery_level_schematic.png) + + +Following table show scalling between ADC reading and actual battery voltage + +| Battery Voltage (V) | ADC reading (mV) | Remarks | +|---------------------|------------------|---------| +| 0 | 114 | No batteries | +| 7.0 | 916 | Recommended threshold to force shutdown system | +| 8.4 | 1099 | Fully Charge | + +[IIO subsystem](https://www.kernel.org/doc/html/latest/driver-api/iio/index.html) provide hardware raw value. To convert the raw value to standard units, use following formula + +`adc = in_voltage2_raw * in_voltage_scale` + +To get the actual ADC reading in shell run following command + +```bash +echo "`cat /sys/bus/iio/devices/iio:device0/in_voltage2_raw` * `cat /sys/bus/iio/devices/iio:device0/in_voltage_scale`" | bc +``` + diff --git a/docs/helios64/usb.md b/docs/helios64/usb.md index 366e0d9..94f698d 100644 --- a/docs/helios64/usb.md +++ b/docs/helios64/usb.md @@ -109,3 +109,337 @@ Using Type-C to Type A male cable such as, ![Type-C to Type-A male](/helios64/img/usb/typec_typea_male.jpg) Helios64 can be used as Direct Attached Storage (DAS) with the required software configuration. It can also be used as "USB eMMC reader/writer" during system recovery mode. + + +## USB under U-Boot + +### USB Host Port + +USB Host support in U-Boot is quite minimal, it only support USB storage. + +### USB OTG Port (USB Type-C) + +USB Type C port is configured as USB device mode as USB Mass Storage connected to eMMC. +This function can be activated by pressing [Recovery Button](/helios64/button/#recovery-button). +This is to serve as a way to (re)install OS to eMMC. + +## USB under Linux + +!!! Info + Currently only applicable under Linux Kernel 4.4. + Mainline kernel support is still under development. + +### Helios64 as Direct Attached Storage (DAS) device + +Helios64 can be used as Direct Attached Storage (DAS) device with help of Linux USB Gadget kernel module. + +The kernel moodule only export the underlying block device NOT the filesystem layer. Therefore if the block device is formatted with filesystem unique to Linux, +the exported disk may not readable by computer that has Helios64 connected to. + +For example, the block device is formatted with EXT4 filesystem and Helios64 connected to Windows PC as DAS, +the Windows PC will not be able to read the disk content unless 3rd party software/driver installed. + + +!!! warning + Do NOT access Helios64 simultanouesly as DAS and NAS, as the filesystem is not managed by system and can lead to data corruption. + +#### Individual Disk Exported as Separate Disk + +To export all SATA disks that has been identified as /dev/sda ... /dev/sde, run the following command on Helios64. + +``` +sudo modprobe g_mass_storage file=/dev/sda,/dev/sdb,/dev/sdc,/dev/sdd,/dev/sde iSerialNumber=1234567890 iManufacturer="Kobol Innovations" iProduct=Helios64 +``` + +The following screenshot, Helios64 connected with 5x 120GB SATA drive. + +***Helios64 connected to PC running Windows*** + +USB device visualization using USB Device Tree Viewer +![!usbtreeview Screenshot](/helios64/img/usb/linux_gadget_das_windows_usbtreeview.png) + +Helios64 in Device Manager +![!device manager Screenshot](/helios64/img/usb/linux_gadget_das_windows_device_manager.png) + +Disks detected under Disk Management +![!disk mgmt Screenshot](/helios64/img/usb/linux_gadget_das_windows_diskmgmt.png) + +***Helios64 connected to PC running Linux*** + +USB device visualization using USBview +![!usbview Screenshot](/helios64/img/usb/linux_gadget_das_usbview.png) + +USB tree using lsusb +![!lsusb tree Screenshot](/helios64/img/usb/linux_gadget_das_lsusb_tree.png) + +``` +$ sudo lsusb -s 2:6 -v + +Bus 002 Device 006: ID 0525:a4a5 Netchip Technology, Inc. Pocketbook Pro 903 +Device Descriptor: + bLength 18 + bDescriptorType 1 + bcdUSB 3.00 + bDeviceClass 0 (Defined at Interface level) + bDeviceSubClass 0 + bDeviceProtocol 0 + bMaxPacketSize0 9 + idVendor 0x0525 Netchip Technology, Inc. + idProduct 0xa4a5 Pocketbook Pro 903 + bcdDevice 4.04 + iManufacturer 3 Kobol Innovations + iProduct 4 Helios64 + iSerial 5 1234567890 + bNumConfigurations 1 +OTG Descriptor: + bLength 3 + bDescriptorType 9 + bmAttributes 0x03 + SRP (Session Request Protocol) + HNP (Host Negotiation Protocol) + Configuration Descriptor: + bLength 9 + bDescriptorType 2 + wTotalLength 47 + bNumInterfaces 1 + bConfigurationValue 1 + iConfiguration 0 + bmAttributes 0xe0 + Self Powered + Remote Wakeup + MaxPower 126mA + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 0 + bAlternateSetting 0 + bNumEndpoints 2 + bInterfaceClass 8 Mass Storage + bInterfaceSubClass 6 SCSI + bInterfaceProtocol 80 Bulk-Only + iInterface 1 Mass Storage + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x81 EP 1 IN + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0400 1x 1024 bytes + bInterval 0 + bMaxBurst 15 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x01 EP 1 OUT + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0400 1x 1024 bytes + bInterval 0 + bMaxBurst 15 +Binary Object Store Descriptor: + bLength 5 + bDescriptorType 15 + wTotalLength 22 + bNumDeviceCaps 2 + USB 2.0 Extension Device Capability: + bLength 7 + bDescriptorType 16 + bDevCapabilityType 2 + bmAttributes 0x00000006 + Link Power Management (LPM) Supported + SuperSpeed USB Device Capability: + bLength 10 + bDescriptorType 16 + bDevCapabilityType 3 + bmAttributes 0x00 + wSpeedsSupported 0x000f + Device can operate at Low Speed (1Mbps) + Device can operate at Full Speed (12Mbps) + Device can operate at High Speed (480Mbps) + Device can operate at SuperSpeed (5Gbps) + bFunctionalitySupport 1 + Lowest fully-functional device speed is Full Speed (12Mbps) + bU1DevExitLat 1 micro seconds + bU2DevExitLat 500 micro seconds +Device Status: 0x0000 + (Bus Powered) + +``` + +xfce file manager (thunar) +![!Thunar Screenshot](/helios64/img/usb/linux_gadget_das_thunar_5_drive.png) + +lsblk output: +``` +$ lsblk +NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT +sdc 8:32 0 111,8G 0 disk +└─sdc1 8:33 0 111,8G 0 part +sdd 8:48 0 111,8G 0 disk +└─sdd1 8:49 0 111,8G 0 part +sde 8:64 0 111,8G 0 disk +└─sde1 8:65 0 111,8G 0 part +sdf 8:80 0 111,8G 0 disk +└─sdf1 8:81 0 111,8G 0 part +sdg 8:96 0 111,8G 0 disk +└─sdg1 8:97 0 111,8G 0 part + +$ lsblk -S +NAME HCTL TYPE VENDOR MODEL REV TRAN +sda 0:0:0:0 disk ATA WDC WDS240G2G0B 0000 sata +sdb 1:0:0:0 disk ATA TOSHIBA MQ04 0J sata +sdc 2:0:0:0 disk Linux File-Stor Gadget 0404 usb +sdd 2:0:0:1 disk Linux File-Stor Gadget 0404 usb +sde 2:0:0:2 disk Linux File-Stor Gadget 0404 usb +sdf 2:0:0:3 disk Linux File-Stor Gadget 0404 usb +sdg 2:0:0:4 disk Linux File-Stor Gadget 0404 usb +``` + +#### RAID device exported as One Disk + +Assuming the RAID already created and identified as /dev/md/md-raid6, run the following command on Helios64 to export the RAID block device as USB Mass Storage + +``` +sudo modprobe g_mass_storage file=/dev/md/md-raid6 iManufacturer="Kobol Innovations" iProduct="Helios64" iSerialNumber="1234567890" +``` + +The following screenshot, Helios64 connected with 5x 120GB SATA drive and configured as RAID 6 so total space of the block device is ~360GB (3x 120GB). The block device then formatted with NTFS. + +***Helios64 connected to PC running Windows*** + +USB device visualization using USB Device Tree Viewer +![!usbtreeview Screenshot](/helios64/img/usb/linux_gadget_das_windows_usbtreeview_raid.png) + +Helios64 in Device Manager +![!device manager Screenshot](/helios64/img/usb/linux_gadget_das_windows_device_manager_raid.png) + +Disks detected under Disk Management +![!disk mgmt Screenshot](/helios64/img/usb/linux_gadget_das_windows_diskmgmt_raid.png) + +!!! note + Since the block device is formatted with NTFS, Windows can recognize it and assign drive letter E: + +***Helios64 connected to PC running Linux*** + +USB device visualization using USBview +![!usbview Screenshot](/helios64/img/usb/linux_gadget_das_usbview_raid.png) + +USB tree using lsusb +![!lsusb tree Screenshot](/helios64/img/usb/linux_gadget_das_lsusb_tree_raid.png) + +``` +Bus 002 Device 006: ID 0525:a4a5 Netchip Technology, Inc. Pocketbook Pro 903 +Device Descriptor: + bLength 18 + bDescriptorType 1 + bcdUSB 3.00 + bDeviceClass 0 (Defined at Interface level) + bDeviceSubClass 0 + bDeviceProtocol 0 + bMaxPacketSize0 9 + idVendor 0x0525 Netchip Technology, Inc. + idProduct 0xa4a5 Pocketbook Pro 903 + bcdDevice 4.04 + iManufacturer 3 Kobol Innovations + iProduct 4 Helios64 + iSerial 5 1234567890 + bNumConfigurations 1 +OTG Descriptor: + bLength 3 + bDescriptorType 9 + bmAttributes 0x03 + SRP (Session Request Protocol) + HNP (Host Negotiation Protocol) + Configuration Descriptor: + bLength 9 + bDescriptorType 2 + wTotalLength 47 + bNumInterfaces 1 + bConfigurationValue 1 + iConfiguration 0 + bmAttributes 0xe0 + Self Powered + Remote Wakeup + MaxPower 126mA + Interface Descriptor: + bLength 9 + bDescriptorType 4 + bInterfaceNumber 0 + bAlternateSetting 0 + bNumEndpoints 2 + bInterfaceClass 8 Mass Storage + bInterfaceSubClass 6 SCSI + bInterfaceProtocol 80 Bulk-Only + iInterface 1 Mass Storage + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x81 EP 1 IN + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0400 1x 1024 bytes + bInterval 0 + bMaxBurst 15 + Endpoint Descriptor: + bLength 7 + bDescriptorType 5 + bEndpointAddress 0x01 EP 1 OUT + bmAttributes 2 + Transfer Type Bulk + Synch Type None + Usage Type Data + wMaxPacketSize 0x0400 1x 1024 bytes + bInterval 0 + bMaxBurst 15 +Binary Object Store Descriptor: + bLength 5 + bDescriptorType 15 + wTotalLength 22 + bNumDeviceCaps 2 + USB 2.0 Extension Device Capability: + bLength 7 + bDescriptorType 16 + bDevCapabilityType 2 + bmAttributes 0x00000006 + Link Power Management (LPM) Supported + SuperSpeed USB Device Capability: + bLength 10 + bDescriptorType 16 + bDevCapabilityType 3 + bmAttributes 0x00 + wSpeedsSupported 0x000f + Device can operate at Low Speed (1Mbps) + Device can operate at Full Speed (12Mbps) + Device can operate at High Speed (480Mbps) + Device can operate at SuperSpeed (5Gbps) + bFunctionalitySupport 1 + Lowest fully-functional device speed is Full Speed (12Mbps) + bU1DevExitLat 1 micro seconds + bU2DevExitLat 500 micro seconds +Device Status: 0x0000 + (Bus Powered) +``` + +xfce file manager (thunar) +![!Thunar Screenshot](/helios64/img/usb/linux_gadget_das_thunar_raid.png) + +lsblk output +``` +$ lsblk +NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT +sdc 8:32 0 335,2G 0 disk +└─sdc1 8:33 0 335,2G 0 part + +$ lsblk -S +NAME HCTL TYPE VENDOR MODEL REV TRAN +sda 0:0:0:0 disk ATA WDC WDS240G2G0B 0000 sata +sdb 1:0:0:0 disk ATA TOSHIBA MQ04 0J sata +sdc 2:0:0:0 disk Linux File-Stor Gadget 0404 usb +``` + diff --git a/mkdocs.yml b/mkdocs.yml index caf4d1f..de4d7b6 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -93,13 +93,15 @@ nav: - Jumper: 'helios64/jumper.md' - LED: 'helios64/led.md' - M.2: 'helios64/m2.md' - - PMIC: 'helios64/pmic.md' + - Power: + - Auto Power On: 'helios64/auto_poweron.md' + - PMIC: 'helios64/pmic.md' + - UPS Battery: 'helios64/ups.md' - PWM Fan: 'helios64/pwm.md' - RTC: 'helios64/rtc.md' - SATA: 'helios64/sata.md' - SPI: 'helios64/spi.md' - UEXT: 'helios64/uext.md' - - UPS Battery: 'helios64/ups.md' - USB: 'helios64/usb.md' - Documents: 'helios64/docs.md' - Helios4: