Skip to content

Commit 867d337

Browse files
[Tizen] Add arm64 target (#38093)
* Add ARM64 support * Restyled by gn * Allow arm64-only env * Fix missing env var * Add arm64 to CI * Bump CI docker versions from 119 to 125 * Update expected output * Fix cases * Fix tuple * Fix env var checking --------- Co-authored-by: Restyled.io <[email protected]>
1 parent 18d3991 commit 867d337

File tree

11 files changed

+57
-13
lines changed

11 files changed

+57
-13
lines changed

.github/workflows/chef.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
if: github.actor != 'restyled-io[bot]'
5959

6060
container:
61-
image: ghcr.io/project-chip/chip-build:119
61+
image: ghcr.io/project-chip/chip-build:125
6262
options: --user root
6363

6464
steps:

.github/workflows/examples-tizen.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
--enable-flashbundle \
6565
--target tizen-arm-all-clusters \
6666
--target tizen-arm-chip-tool-ubsan \
67-
--target tizen-arm-light-with-ui \
67+
--target tizen-arm64-light-with-ui \
6868
build \
6969
--copy-artifacts-to out/artifacts \
7070
"

build/config/arm.gni

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ if ((current_cpu == "arm" || current_cpu == "arm64") &&
4343
arm_float_abi = ""
4444
arm_abi = ""
4545
arm_use_thumb = current_os != "linux" &&
46-
(current_os != "android" || current_cpu != "arm64")
46+
(current_os != "android" || current_cpu != "arm64") &&
47+
(current_os != "tizen" || current_cpu != "arm64")
4748

4849
# Update defaults with platform values, if any.
4950
if (arm_platform_config != "") {

build/config/linux/pkg_config.gni

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ declare_args() {
6767
host_pkg_config = ""
6868

6969
system_libdir = "lib"
70+
71+
if (current_os == "tizen" && current_cpu == "arm64") {
72+
system_libdir = "lib64"
73+
}
7074
}
7175

7276
pkg_config_script = "${build_root}/config/linux/pkg-config.py"

build/toolchain/tizen/BUILD.gn

+7
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ tizen_toolchain("tizen_arm") {
2020
arm_arch = "armv7-a"
2121
}
2222
}
23+
24+
tizen_toolchain("tizen_arm64") {
25+
toolchain_args = {
26+
current_cpu = "arm64"
27+
arm_arch = "armv8-a"
28+
}
29+
}

build/toolchain/tizen/tizen_toolchain.gni

+7-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ template("tizen_toolchain") {
2727
forward_variables_from(_invoker_toolchain_args, "*")
2828
}
2929

30-
_tizen_toolchain_prefix =
31-
"${tizen_sdk_root}/tools/arm-linux-gnueabi-gcc-9.2/bin/arm-linux-gnueabi-"
30+
if (_invoker_toolchain_args.current_cpu == "arm") {
31+
_tizen_toolchain_prefix = "${tizen_sdk_root}/tools/arm-linux-gnueabi-gcc-9.2/bin/arm-linux-gnueabi-"
32+
} else if (_invoker_toolchain_args.current_cpu == "arm64") {
33+
_tizen_toolchain_prefix = "${tizen_sdk_root}/tools/aarch64-linux-gnu-gcc-9.2/bin/aarch64-linux-gnu-"
34+
} else {
35+
assert(false, "CPU architecture is not supported.")
36+
}
3237

3338
gcc_toolchain(target_name) {
3439
toolchain_args = _tizen_toolchain_args

scripts/build/build/targets.py

+1
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ def BuildTizenTarget():
667667
# board
668668
target.AppendFixedTargets([
669669
TargetPart('arm', board=TizenBoard.ARM),
670+
TargetPart('arm64', board=TizenBoard.ARM64),
670671
])
671672

672673
# apps

scripts/build/builders/tizen.py

+24-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
class TizenBoard(Enum):
3131

3232
ARM = Board('arm')
33+
ARM64 = Board('arm64')
3334

3435

3536
class TizenApp(Enum):
@@ -186,16 +187,37 @@ def PostBuildCommand(self):
186187

187188
def GnBuildArgs(self):
188189
# Make sure that required ENV variables are defined
189-
for env in ('TIZEN_SDK_ROOT', 'TIZEN_SDK_SYSROOT'):
190+
env = 'TIZEN_SDK_ROOT'
191+
if env not in os.environ:
192+
raise Exception(
193+
"Environment %s missing, cannot build Tizen target" % env)
194+
195+
sysroot = None
196+
197+
if self.board.value.target_cpu == "arm64":
198+
env = 'TIZEN_SDK_SYSROOT_ARM64'
190199
if env not in os.environ:
191200
raise Exception(
192201
"Environment %s missing, cannot build Tizen target" % env)
193202

203+
sysroot = os.environ[env]
204+
205+
elif self.board.value.target_cpu == "arm":
206+
env = 'TIZEN_SDK_SYSROOT'
207+
if env not in os.environ:
208+
raise Exception(
209+
"Environment %s missing, cannot build Tizen target" % env)
210+
211+
sysroot = os.environ[env]
212+
213+
else:
214+
raise Exception("CPU architecture is not supported")
215+
194216
return self.extra_gn_options + [
195217
'target_os="tizen"',
196218
'target_cpu="%s"' % self.board.value.target_cpu,
197219
'tizen_sdk_root="%s"' % os.environ['TIZEN_SDK_ROOT'],
198-
'tizen_sdk_sysroot="%s"' % os.environ['TIZEN_SDK_SYSROOT'],
220+
'tizen_sdk_sysroot="%s"' % sysroot,
199221
]
200222

201223
def _bundle(self):

scripts/build/testdata/all_targets_linux_x64.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ nuttx-x64-light
2222
qpg-qpg6105-{lock,light,shell,persistent-storage,light-switch,thermostat}[-updateimage]
2323
realtek-rtl8777g-{lighting,light-switch,lock,window}
2424
stm32-stm32wb5mm-dk-light
25-
tizen-arm-{all-clusters,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-coverage][-with-ui]
25+
tizen-{arm,arm64}-{all-clusters,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-coverage][-with-ui]
2626
telink-{tlsr9118bdk40d,tlsr9518adk80d,tlsr9528a,tlsr9528a_retention,tl3218x,tl3218x_retention,tl7218x,tl7218x_retention}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb][-mars][-usb][-compress-lzma][-thread-analyzer]
2727
openiotsdk-{shell,lock}[-mbedtls][-psa]

src/platform/Tizen/BLEManagerImpl.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include <lib/core/ErrorStr.h>
5353
#include <lib/support/BitFlags.h>
5454
#include <lib/support/CodeUtils.h>
55+
#include <lib/support/SafeInt.h>
5556
#include <lib/support/SetupDiscriminator.h>
5657
#include <lib/support/Span.h>
5758
#include <platform/CHIPDeviceEvent.h>
@@ -1249,11 +1250,12 @@ CHIP_ERROR BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const Ble
12491250
conId = static_cast<BLEConnection *>(g_hash_table_lookup(mConnectionMap, conId->peerAddr));
12501251
VerifyOrExit(conId != BLE_CONNECTION_UNINITIALIZED, ChipLogError(DeviceLayer, "Failed to find connection info"));
12511252

1252-
ret = bt_gatt_set_value(mGattCharC2Handle, Uint8::to_const_char(pBuf->Start()), pBuf->DataLength());
1253+
VerifyOrReturnError(CanCastTo<int>(pBuf->DataLength()), CHIP_ERROR_INTERNAL);
1254+
ret = bt_gatt_set_value(mGattCharC2Handle, Uint8::to_const_char(pBuf->Start()), static_cast<int>(pBuf->DataLength()));
12531255
VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_set_value() failed: %s", get_error_message(ret)));
12541256

12551257
ChipLogProgress(DeviceLayer, "Sending indication for CHIPoBLE RX characteristic (con %s, len %u)", conId->peerAddr,
1256-
pBuf->DataLength());
1258+
static_cast<int>(pBuf->DataLength()));
12571259

12581260
ret = bt_gatt_server_notify_characteristic_changed_value(
12591261
mGattCharC2Handle,
@@ -1283,11 +1285,12 @@ CHIP_ERROR BLEManagerImpl::SendWriteRequest(BLE_CONNECTION_OBJECT conId, const B
12831285
ChipLogError(DeviceLayer, "SendWriteRequest() called with invalid characteristic ID"));
12841286
VerifyOrExit(conId->gattCharC1Handle != nullptr, ChipLogError(DeviceLayer, "Char C1 is null"));
12851287

1286-
ret = bt_gatt_set_value(conId->gattCharC1Handle, Uint8::to_const_char(pBuf->Start()), pBuf->DataLength());
1288+
VerifyOrReturnError(CanCastTo<int>(pBuf->DataLength()), CHIP_ERROR_INTERNAL);
1289+
ret = bt_gatt_set_value(conId->gattCharC1Handle, Uint8::to_const_char(pBuf->Start()), static_cast<int>(pBuf->DataLength()));
12871290
VerifyOrExit(ret == BT_ERROR_NONE, ChipLogError(DeviceLayer, "bt_gatt_set_value() failed: %s", get_error_message(ret)));
12881291

12891292
ChipLogProgress(DeviceLayer, "Sending Write Request for CHIPoBLE TX characteristic (con %s, len %u)", conId->peerAddr,
1290-
pBuf->DataLength());
1293+
static_cast<int>(pBuf->DataLength()));
12911294

12921295
ret = bt_gatt_client_write_value(conId->gattCharC1Handle, WriteCompletedCb, conId);
12931296
VerifyOrExit(ret == BT_ERROR_NONE,

src/platform/Tizen/ThreadStackManagerImpl.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadProvision(ByteSpan netInfo)
273273

274274
int threadErr = THREAD_ERROR_NONE;
275275

276-
threadErr = thread_network_set_active_dataset_tlvs(mThreadInstance, netInfo.data(), netInfo.size());
276+
VerifyOrReturnError(CanCastTo<int>(netInfo.size()), CHIP_ERROR_INTERNAL);
277+
threadErr = thread_network_set_active_dataset_tlvs(mThreadInstance, netInfo.data(), static_cast<int>(netInfo.size()));
277278
VerifyOrExit(threadErr == THREAD_ERROR_NONE,
278279
ChipLogError(DeviceLayer, "FAIL: Thread set active dataset TLVs: %s", get_error_message(threadErr)));
279280

0 commit comments

Comments
 (0)