Skip to content

Commit

Permalink
Merge pull request home-assistant#7 from adeepn/jethome_5.7
Browse files Browse the repository at this point in the history
Jethome 5.7 j80 support
  • Loading branch information
adeepn authored Jan 30, 2021
2 parents a7d32ce + 38cf619 commit b5e8396
Show file tree
Hide file tree
Showing 42 changed files with 5,871 additions and 177 deletions.
2 changes: 2 additions & 0 deletions buildroot-external/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ source "$BR2_EXTERNAL_HASSOS_PATH/package/armbian-firmware-ap6255/Config.in"
source "$BR2_EXTERNAL_HASSOS_PATH/package/qemu-guest-agent/Config.in"
source "$BR2_EXTERNAL_HASSOS_PATH/package/intel-e1000e/Config.in"
source "$BR2_EXTERNAL_HASSOS_PATH/package/rpi-eeprom/Config.in"
source "$BR2_EXTERNAL_HASSOS_PATH/package/rtk-hciattach/Config.in"
source "$BR2_EXTERNAL_HASSOS_PATH/package/rtl8812au/Config.in"
source "$BR2_EXTERNAL_HASSOS_PATH/package/rtl8822cs/Config.in"
20 changes: 10 additions & 10 deletions buildroot-external/board/jethome/jethub-d1/hassos-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ function create_disk_image() {

function create_platform_conf () {
echo 'Platform:0x0811' > ${BINARIES_DIR}/platform.conf
echo 'DDRLoad:0xfffc0000' > ${BINARIES_DIR}/platform.conf
echo 'DDRRun:0xfffc0000' > ${BINARIES_DIR}/platform.conf
echo 'UbootLoad:0x200c000' > ${BINARIES_DIR}/platform.conf
echo 'UbootRun:0xfffc0000' > ${BINARIES_DIR}/platform.conf
echo 'Control0=0xfffc0000:0x000000b1' > ${BINARIES_DIR}/platform.conf
echo 'Control1=0xfffc0000:0x00005183' > ${BINARIES_DIR}/platform.conf
echo 'Encrypt_reg:0xff800228' > ${BINARIES_DIR}/platform.conf
echo 'bl2ParaAddr=0xfffcc000' > ${BINARIES_DIR}/platform.conf
echo 'DDRLoad:0xfffc0000' >> ${BINARIES_DIR}/platform.conf
echo 'DDRRun:0xfffc0000' >> ${BINARIES_DIR}/platform.conf
echo 'UbootLoad:0x200c000' >> ${BINARIES_DIR}/platform.conf
echo 'UbootRun:0xfffc0000' >> ${BINARIES_DIR}/platform.conf
echo 'Control0=0xfffc0000:0x000000b1' >> ${BINARIES_DIR}/platform.conf
echo 'Control1=0xfffc0000:0x00005183' >> ${BINARIES_DIR}/platform.conf
echo 'Encrypt_reg:0xff800228' >> ${BINARIES_DIR}/platform.conf
echo 'bl2ParaAddr=0xfffcc000' >> ${BINARIES_DIR}/platform.conf
}

function _create_disk_aml() {
Expand Down Expand Up @@ -93,8 +93,8 @@ function _create_disk_aml() {

create_platform_conf

cc -o $BINARIES_DIR/dtbTool $BOARD_DIR/bin/dtbTool.c
cc -o $BINARIES_DIR/dtbTool $BOARD_DIR/../src/dtbTool.c
$BINARIES_DIR/dtbTool -o $BINARIES_DIR/_aml_dtb.PARTITION ${BINARIES_DIR}/
$BOARD_DIR/bin/aml_image_v2_packer -r ${BINARIES_DIR}/image.cfg ${BINARIES_DIR}/ $hdd_img
$BOARD_DIR/../bin/aml_image_v2_packer -r ${BINARIES_DIR}/image.cfg ${BINARIES_DIR}/ $hdd_img
echo "Image created"
}
2 changes: 1 addition & 1 deletion buildroot-external/board/jethome/jethub-d1/meta
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ BOOTLOADER=uboot
KERNEL_FILE=Image
BOOT_SYS=mbr
BOOT_SPL=false
BOOT_ENV_SIZE=0x2000
BOOT_ENV_SIZE=0x10000
SUPERVISOR_MACHINE=odroid-c2
#SUPERVISOR_MACHINE=jethub-d1 TODO: add supervisor
SUPERVISOR_ARCH=aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ GPIO_ACTIVE_LOW=0
GPIO_ACTIVE_HIGH=1

configure_gpio() {
echo "Configure: gpio=${1}, direction=${2}, active_level=${3}"
echo "${0}: Configure: gpio=${1}, direction=${2}, active_level=${3}"

if [ ! -d /sys/class/gpio/gpio${1} ]; then
echo ${1} > /sys/class/gpio/export
if [ ! -d /sys/class/gpio/gpio${1} ]; then
echo "** Failed to configure GPIO ${1}"
echo "${0}: *** Error: Failed to configure GPIO ${1}"
exit 1
fi
fi
Expand All @@ -30,19 +30,19 @@ configure_gpio() {

echo "${0}: Configure GPIOs ..."

# Discrete inputs
# Discrete inputs: 1, 2, 3, 4
configure_gpio "472" "${GPIO_DIRECTION_INPUT}" "${GPIO_ACTIVE_HIGH}"
configure_gpio "471" "${GPIO_DIRECTION_INPUT}" "${GPIO_ACTIVE_HIGH}"
configure_gpio "470" "${GPIO_DIRECTION_INPUT}" "${GPIO_ACTIVE_HIGH}"
configure_gpio "469" "${GPIO_DIRECTION_INPUT}" "${GPIO_ACTIVE_HIGH}"
# Relays
# Relays: 1, 2, 3
configure_gpio "456" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_HIGH}"
configure_gpio "455" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_HIGH}"
configure_gpio "454" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_HIGH}"
# ZigBee module
# Zigbee module: RESET, BOOT
configure_gpio "467" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_HIGH}"
configure_gpio "462" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_HIGH}"
# LEDs
# LEDs: RED, GREEN
configure_gpio "452" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_LOW}"
configure_gpio "453" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_LOW}"
# Button
Expand All @@ -52,6 +52,12 @@ echo "${0}: Turn off LEDs ..."
echo 0 > /sys/class/gpio/gpio452/value
echo 0 > /sys/class/gpio/gpio453/value

echo "${0}: Reset Zigbee module ..."
echo 1 > /sys/class/gpio/gpio462/value
echo 1 > /sys/class/gpio/gpio467/value
sleep 1
echo 0 > /sys/class/gpio/gpio467/value

echo "${0}: Configure 1-Wire ..."
modprobe ds2482
if [ ${?} != 0 ]; then
Expand Down
100 changes: 100 additions & 0 deletions buildroot-external/board/jethome/jethub-h1/hassos-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash
# shellcheck disable=SC2155

# Change size partitions
BOOT_SIZE=(64M 64M)
BOOTSTATE_SIZE=8M
SYSTEM_SIZE=256M
KERNEL_SIZE=64M
OVERLAY_SIZE=128M
DATA_SIZE=1G

set -e # Exit immediately if a command exits with a non-zero status
set -u # Treat unset variables and parameters as an error

# some functions
print_var() {
if [ -n "$1" ] ; then
echo "-- ${1}==${!1}"
else
echo "${FUNCNAME[0]}(): Null parameter passed to this function"
fi
}

print_cmd_title() {
if [ -n "$1" ] ; then
echo "###### ${1} ######"
else
echo "${FUNCNAME[0]}(): Null parameter passed to this function"
fi
}

self_name() {
echo ${0##*/}
}


function hassos_pre_image() {
local BOOT_DATA="$(path_boot_dir)"

echo "console=tty0 console=ttyAML0,115200n8" > "${BOOT_DATA}/cmdline.txt"
cp "${BINARIES_DIR}/meson-gxl-s905w-jethome-jethub-j80.dtb" "${BOOT_DATA}/meson-gxl-s905w-jethome-jethub-j80.dtb"
}

function hassos_post_image() {
convert_disk_image_xz
}

function create_disk_image() {
_prepare_disk_image
_create_disk_aml
}

function create_platform_conf () {
echo 'Platform:0x0811' > ${BINARIES_DIR}/platform.conf
echo 'DDRLoad:0xd9000000' >> ${BINARIES_DIR}/platform.conf
echo 'DDRRun:0xd9000000' >> ${BINARIES_DIR}/platform.conf
echo 'UbootLoad:0x200c000' >> ${BINARIES_DIR}/platform.conf
echo 'UbootRun:0xd9000000' >> ${BINARIES_DIR}/platform.conf
echo 'Control0=0xd9000000:0x000000b1' >> ${BINARIES_DIR}/platform.conf
echo 'Control1=0xd9000000:0x00005183' >> ${BINARIES_DIR}/platform.conf
echo 'Encrypt_reg:0xc8100228' >> ${BINARIES_DIR}/platform.conf
echo 'bl2ParaAddr=0xd900c000' >> ${BINARIES_DIR}/platform.conf
}

function _create_disk_aml() {
local boot_img="$(path_boot_img)"
local rootfs_img="$(path_rootfs_img)"
local overlay_img="$(path_overlay_img)"
local data_img="$(path_data_img)"
local kernel_img="$(path_kernel_img)"
local hdd_img="$(hassos_image_name img)"
local hdd_count=${DISK_SIZE:-2}
local disk_layout="${BINARIES_DIR}/disk.layout"
local boot_start=$(size2sectors "8M")
local bootloader_img="u-boot.bin" # bootloader
local ubootbin_img="u-boot.bin.usb.tpl" # UBOOT
local ddrbin_img="u-boot.bin.usb.bl2" # DDR

echo '[LIST_NORMAL]' > ${BINARIES_DIR}/image.cfg
echo 'file="'${ddrbin_img}'" main_type="USB" sub_type="DDR"' >> ${BINARIES_DIR}/image.cfg
echo 'file="'${ubootbin_img}'" main_type="USB" sub_type="UBOOT"' >> ${BINARIES_DIR}/image.cfg
echo 'file="_aml_dtb.PARTITION" main_type="dtb" sub_type="meson1"' >> ${BINARIES_DIR}/image.cfg
echo 'file="platform.conf" main_type="conf" sub_type="platform"' >> ${BINARIES_DIR}/image.cfg
echo '' >> ${BINARIES_DIR}/image.cfg
echo '[LIST_VERIFY]' >> ${BINARIES_DIR}/image.cfg
echo 'file="_aml_dtb.PARTITION" main_type="PARTITION" sub_type="_aml_dtb"' >> ${BINARIES_DIR}/image.cfg
echo 'file="'${bootloader_img}'" main_type="PARTITION" sub_type="bootloader"' >> ${BINARIES_DIR}/image.cfg
echo 'file="'${boot_img##*/}'" main_type="PARTITION" sub_type="boot"' >> ${BINARIES_DIR}/image.cfg
echo 'file="'${kernel_img##*/}'" main_type="PARTITION" sub_type="kernela"' >> ${BINARIES_DIR}/image.cfg
echo 'file="'${rootfs_img##*/}'" main_type="PARTITION" sub_type="systema"' >> ${BINARIES_DIR}/image.cfg
echo 'file="'${overlay_img##*/}'" main_type="PARTITION" sub_type="overlay"' >> ${BINARIES_DIR}/image.cfg
echo 'file="'${data_img##*/}'" main_type="PARTITION" sub_type="data"' >> ${BINARIES_DIR}/image.cfg

create_platform_conf

cc -o $BINARIES_DIR/dtbTool $BOARD_DIR/../src/dtbTool.c
$BINARIES_DIR/dtbTool -o $BINARIES_DIR/_aml_dtb.PARTITION ${BINARIES_DIR}/
$BOARD_DIR/../bin/aml_image_v2_packer -r ${BINARIES_DIR}/image.cfg ${BINARIES_DIR}/ $hdd_img
echo "Image created"
}
11 changes: 11 additions & 0 deletions buildroot-external/board/jethome/jethub-h1/meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
BOARD_ID=jethub-h1
BOARD_NAME="JetHome JetHub H1"
CHASSIS=embedded
BOOTLOADER=uboot
KERNEL_FILE=Image
BOOT_SYS=mbr
BOOT_SPL=false
BOOT_ENV_SIZE=0x10000
SUPERVISOR_MACHINE=odroid-c2
#SUPERVISOR_MACHINE=jethub-h1 TODO: add supervisor
SUPERVISOR_ARCH=aarch64
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Files rtl8822cs_config, rtl8822cs_fw are not from Linux_BT_UART_v3.10_20200301_8822CS_BTCOEX_20200103-1717.
They are from stb project.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

GPIO_DIRECTION_OUTPUT=0
GPIO_DIRECTION_INPUT=1

GPIO_ACTIVE_LOW=0
GPIO_ACTIVE_HIGH=1

configure_gpio() {
echo "${0}: Configure: gpio=${1}, direction=${2}, active_level=${3}"

if [ ! -d /sys/class/gpio/gpio${1} ]; then
echo ${1} > /sys/class/gpio/export
if [ ! -d /sys/class/gpio/gpio${1} ]; then
echo "${0}: *** Error: Failed to configure GPIO ${1}"
exit 1
fi
fi

if [ "${2}" == "${GPIO_DIRECTION_OUTPUT}" ]; then
echo "out" > /sys/class/gpio/gpio${1}/direction
else
echo "in" > /sys/class/gpio/gpio${1}/direction
fi

if [ "${3}" == "${GPIO_ACTIVE_LOW}" ]; then
echo 1 > /sys/class/gpio/gpio${1}/active_low
fi
}

echo "${0}: Configure GPIOs ..."

# Zigbee module: RESET, BOOT
configure_gpio "507" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_HIGH}"
configure_gpio "510" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_HIGH}"
# Z-Wave module: RESET, SUSPEND
configure_gpio "490" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_HIGH}"
configure_gpio "491" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_HIGH}"
# LED
configure_gpio "474" "${GPIO_DIRECTION_OUTPUT}" "${GPIO_ACTIVE_HIGH}"


echo "${0}: Turn off LED ..."
echo 0 > /sys/class/gpio/gpio474/value

echo "${0}: Reset Zigbee module ..."
echo 1 > /sys/class/gpio/gpio510/value
echo 1 > /sys/class/gpio/gpio507/value
sleep 1
echo 0 > /sys/class/gpio/gpio507/value

echo "${0}: Reset Z-Wave module ..."
# Optional SUSPEND pin
#echo 1 > /sys/class/gpio/gpio491/value
echo 1 > /sys/class/gpio/gpio490/value
sleep 1
echo 0 > /sys/class/gpio/gpio490/value

exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

if grep -Eq "^GXL.+S905W" /sys/devices/soc0/soc_id; then
if [ ! -f /sys/class/gpio/gpio497/value ]; then
echo 497 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio497/direction
fi
echo 0 > /sys/class/gpio/gpio497/value && sleep 0.1
echo 1 > /sys/class/gpio/gpio497/value && sleep 0.1
rtk_hciattach /dev/ttyAML1 -s 115200 rtk_h5 115200
elif grep -Eq "^AXG" /sys/devices/soc0/soc_id; then
echo "Amlogic AXG detected. Skip rtk_hciattach execution."
else
echo "SoC detection failed. Unable to execute rtk_hciattach."
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

[Unit]
Description=rtk_hciattach
DefaultDependencies=no
After=local-fs.target
Conflicts=shutdown.target

[Service]
Type=oneshot
ExecStart=/usr/bin/bash /usr/lib/jethome/rtk_hciattach_starter
RemainAfterExit=yes
TimeoutStartSec=30sec

[Install]
WantedBy=sysinit.target
Loading

0 comments on commit b5e8396

Please sign in to comment.