Skip to content

Commit

Permalink
Add Linxdot RK3566 hardware defs (#290)
Browse files Browse the repository at this point in the history
* Add Linxdot RK3566 hardware defs

* Update pyproject.toml

* Update test_hardware_definitions.py

* Update test_hardware_definitions.py

---------

Co-authored-by: Aaron Shaw <shawaj@gmail.com>
  • Loading branch information
ccrisan and shawaj authored Oct 27, 2024
1 parent 209c1d8 commit 4d10c10
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 13 deletions.
19 changes: 14 additions & 5 deletions hm_pyhelper/hardware_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def is_bobcat_rk3566() -> bool:
return sbc.is_sbc_type(sbc.DeviceVendorID.BOBCAT_RK3566)


def is_linxdot_rk3566() -> bool:
return sbc.is_sbc_type(sbc.DeviceVendorID.LINXDOT_RK3566)


def is_rockpi() -> bool:
return sbc.is_sbc_type(sbc.DeviceVendorID.ROCK_PI)

Expand Down Expand Up @@ -511,19 +515,24 @@ def is_raspberry_pi() -> bool:
'CONTAINS_IC_IDS': []
},

# Linxdot RKCM3
# Linxdot RK3566
'linxdot-rk3566-fl1': {
'FRIENDLY': 'Linxdot RK3566 Hotspot',
'SUPPORTED_MODELS': ['Linxdot RK3566 Hotspot'],
'CPU_ARCH': 'arm64',
'BALENA_DEVICE_TYPE': ['nanopc-t4'],
'SPIBUS': 'spidev0.0',
'SWARM_KEY_URI': ['ecc://i2c-1:96?slot=0'],
'ONBOARDING_KEY_URI': ['ecc://i2c-1:96?slot=0'],
'SWARM_KEY_URI': ['ecc://i2c-5:96?slot=1'],
'ONBOARDING_KEY_URI': ['ecc://i2c-5:96?slot=1'],
'RESET': 17,
'MAC': 'wlan0',
'STATUS': 22,
'BUTTON': 27,
'STATUS': None,
'BUTTON': None,
'BUTTON_ADC': {
'PATH': '/sys/bus/iio/devices/iio:device0/in_voltage0_raw',
'ACTIVE_BELOW': 500,
},
'STATUS_LINUX_LED': '/sys/devices/platform/leds/leds/work-led1/brightness',
'ECCOB': True,
'TYPE': 'Full',
'CELLULAR': False,
Expand Down
10 changes: 9 additions & 1 deletion hm_pyhelper/sbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DeviceVendorID(Enum):
RASPBERRY_PI = auto()
BOBCAT_PX30 = auto()
BOBCAT_RK3566 = auto()
LINXDOT_RK3566 = auto()


# Pulled from
Expand All @@ -42,9 +43,12 @@ class DeviceVendorID(Enum):

BALENA_ENV_BOBCATRK3566_MODELS = ['rockpro64']

BALENA_ENV_LINXDOTRK3566_MODELS = ['nanopc-t4']

BALENA_MODELS = {
DeviceVendorID.BOBCAT_PX30: BALENA_ENV_BOBCATPX30_MODELS,
DeviceVendorID.BOBCAT_RK3566: BALENA_ENV_BOBCATRK3566_MODELS,
DeviceVendorID.LINXDOT_RK3566: BALENA_ENV_LINXDOTRK3566_MODELS,
DeviceVendorID.ROCK_PI: BALENA_ENV_ROCKPI_MODELS,
DeviceVendorID.RASPBERRY_PI: BALENA_ENV_RASPBERRY_PI_MODELS
}
Expand Down Expand Up @@ -179,10 +183,14 @@ def sbc_info() -> SBCInfo:
sbc_info = SBCInfo(vendor_id=DeviceVendorID.RASPBERRY_PI,
vendor_name='Raspberry Pi',
model_name=dev_model)
elif dev_model.lower().find('rk3566') >= 0:
elif dev_model.lower().find('rk3566 evb2') >= 0:
sbc_info = SBCInfo(vendor_id=DeviceVendorID.BOBCAT_RK3566,
vendor_name='Bobcat',
model_name=dev_model)
elif dev_model.lower().find('rk3566 r01') >= 0:
sbc_info = SBCInfo(vendor_id=DeviceVendorID.LINXDOT_RK3566,
vendor_name='Linxdot',
model_name=dev_model)
elif dev_model.lower().find('rock') >= 0:
sbc_info = SBCInfo(vendor_id=DeviceVendorID.ROCK_PI,
vendor_name='Radxa Rock Pi',
Expand Down
37 changes: 31 additions & 6 deletions hm_pyhelper/tests/test_hardware_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
UnknownVariantAttributeException

from hm_pyhelper.hardware_definitions import is_rockpi, variant_definitions, \
get_variant_attribute, is_raspberry_pi, is_bobcat_px30, is_bobcat_rk3566
get_variant_attribute, is_raspberry_pi, is_bobcat_px30, is_bobcat_rk3566, is_linxdot_rk3566
from hm_pyhelper.sbc import BALENA_ENV_RASPBERRY_PI_MODELS, \
BALENA_ENV_ROCKPI_MODELS, BALENA_ENV_BOBCATPX30_MODELS, BALENA_ENV_BOBCATRK3566_MODELS
BALENA_ENV_ROCKPI_MODELS, BALENA_ENV_BOBCATPX30_MODELS, BALENA_ENV_BOBCATRK3566_MODELS, \
BALENA_ENV_LINXDOTRK3566_MODELS

BUILTINS_OPEN_LITERAL = "builtins.open"

Expand Down Expand Up @@ -119,7 +120,8 @@ def test_is_raspberry_pi(self):
self.assertTrue(is_raspberry_pi())
# in absence of the env, it should look for /proc/device-tree/model
# which will not exist on test environment.
with self.assertRaises(FileNotFoundError):
with patch.dict(os.environ, {'BALENA_DEVICE_TYPE': "something"}):
self.assertRaises(FileNotFoundError)
self.assertFalse(is_raspberry_pi())

mock_known_rock_dts_models = ["ROCK PI 4B"]
Expand All @@ -138,7 +140,8 @@ def test_is_rock_pi(self):
self.assertTrue(is_rockpi())
# in absence of the env, it should look for /proc/device-tree/model
# which will not exist on test environment.
with self.assertRaises(FileNotFoundError):
with patch.dict(os.environ, {'BALENA_DEVICE_TYPE': "something"}):
self.assertRaises(FileNotFoundError)
self.assertFalse(is_rockpi())

mock_known_bobcat_px30_dts_models = ["Bobcat PX30"]
Expand All @@ -157,7 +160,8 @@ def test_is_bobcat_px30(self):
self.assertTrue(is_bobcat_px30())
# in absence of the env, it should look for /proc/device-tree/model
# which will not exist on test environment.
with self.assertRaises(FileNotFoundError):
with patch.dict(os.environ, {'BALENA_DEVICE_TYPE': "something"}):
self.assertRaises(FileNotFoundError)
self.assertFalse(is_bobcat_px30())

mock_known_bobcat_rk3566_dts_models = ["Rockchip RK3566 EVB2 LP4X V10 Board"]
Expand All @@ -176,5 +180,26 @@ def test_is_bobcat_rk3566(self):
self.assertTrue(is_bobcat_rk3566())
# in absence of the env, it should look for /proc/device-tree/model
# which will not exist on test environment.
with self.assertRaises(FileNotFoundError):
with patch.dict(os.environ, {'BALENA_DEVICE_TYPE': "something"}):
self.assertRaises(FileNotFoundError)
self.assertFalse(is_bobcat_rk3566())

mock_known_linxdot_rk3566_dts_models = ["Linxdot RK3566 R01"]

def test_is_linxdot_rk3566(self):
for model in self.mock_known_linxdot_rk3566_dts_models:
with patch(BUILTINS_OPEN_LITERAL, new_callable=mock_open, read_data=model):
self.assertTrue(is_linxdot_rk3566())
with patch(BUILTINS_OPEN_LITERAL, new_callable=mock_open,
read_data="raspberry something"):
self.assertFalse(is_linxdot_rk3566())

# test balena env based detection
for model in BALENA_ENV_LINXDOTRK3566_MODELS:
with patch.dict(os.environ, {'BALENA_DEVICE_TYPE': model}):
self.assertTrue(is_linxdot_rk3566())
# in absence of the env, it should look for /proc/device-tree/model
# which will not exist on test environment.
with patch.dict(os.environ, {'BALENA_DEVICE_TYPE': "something"}):
self.assertRaises(FileNotFoundError)
self.assertFalse(is_linxdot_rk3566())
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "hm_pyhelper"
version = "0.14.35"
version = "0.14.36"
description = "Helium Python Helper"
authors = ["Nebra Ltd <support@nebra.com>"]
readme = "README.md"
Expand Down

0 comments on commit 4d10c10

Please sign in to comment.