Skip to content

Commit

Permalink
Add Linxdot RK3566 hardware defs
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrisan committed Oct 16, 2023
1 parent 75ac121 commit 91ed81b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 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 @@ -178,10 +182,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
24 changes: 22 additions & 2 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 @@ -178,3 +179,22 @@ def test_is_bobcat_rk3566(self):
# which will not exist on test environment.
with 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 self.assertRaises(FileNotFoundError):
self.assertFalse(is_linxdot_rk3566())

0 comments on commit 91ed81b

Please sign in to comment.