SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (ModusToolbox)
Loading...
Searching...
No Matches

Functions

void optiga_manager_touch_hold (void)
 การจับไว้ (hold) แบบนับจำนวน ครอบการติดต่อกับชิปทั้งชุด; การจับไว้ครั้งแรกจะหลับ 50 ms
void optiga_manager_touch_hold_reason (const char *reason)
 การจับไว้แบบนับจำนวนแบบเดียวกัน พร้อมข้อความ busy modal ที่ CM55 แสดงระหว่างที่การสัมผัสถูกปิด
void optiga_manager_touch_release (void)
 ลดค่าตัวนับการจับไว้ — จับคู่ 1:1 อย่างเคร่งครัดกับการจับไว้ทุกครั้ง ในทุกการคืนค่าก่อนกำหนด

Detailed Description

3 ฟังก์ชัน — กัน CM55 ให้อยู่ห่างจากบัสที่ใช้ร่วมกัน secure element กับตัวควบคุมการสัมผัส (touch) ของ CM55 ใช้บัส I2C เส้นเดียวกัน (SCB5 บน AI Kit) การจับไว้คือการขอให้ CM55 หยุดวนถาม (polling) การสัมผัสตลอดช่วงการติดต่อกับชิปหนึ่งชุด และการปล่อยคือการให้กลับมาทำต่อ การจับไว้เป็นตัวนับ (s_touch_holds, tesaiot_optiga_manager.c:290): การซ้อนกันปลอดภัยและจำเป็น และการจับไว้ทุกครั้งต้องมีการปล่อยหนึ่งครั้งพอดีในทุกเส้นทางออก — "an unbalanced release leaves the panel dead" (ipc_hsm_handler.c:1873-1877)

ข้อห้าม: ห้ามส่ง IPC_CMD_TOUCH_RESUME ดิบ ๆ ด้วยตัวเอง CM55 จะถือว่าเป็น touch_disabled = false แบบไม่มีเงื่อนไข ซึ่งไปยกเลิกการจับไว้ของ task อื่น และการถ่ายโอนกับชิปครั้งถัดไปจะชนกับการอ่านค่าการสัมผัส — OPTIGA_COMMS_ERROR (0x0102) (ipc_hsm_handler.c:1393-1405) มีเพียง optiga_manager_touch_release() เท่านั้นที่ลดค่าตัวนับ

variant ที่ใช้ได้
mtb-mpy และ mtb-only

Function Documentation

◆ optiga_manager_touch_hold()

void optiga_manager_touch_hold ( void )

การจับไว้ (hold) แบบนับจำนวน ครอบการติดต่อกับชิปทั้งชุด; การจับไว้ครั้งแรกจะหลับ 50 ms

Hold the chip powered between operations, and let it go again. _reason is the same hold with a string for the log.

ข้อกำหนดการเรียกใช้
การจับไว้ (hold) แบบนับจำนวน โดยการจับไว้ครั้งแรกจะหลับ 50 ms เพื่อให้การถ่ายโอนข้อมูลการสัมผัส (touch) ที่ค้างอยู่ทำงานจนจบ ให้จับไว้ตลอดการติดต่อกับชิปทั้งชุด ไม่ใช่ทีละปฏิบัติการ — การปล่อยระหว่างขั้นตอนคือการเปิดช่องเดิมขึ้นมาอีก ให้จัดโครงสร้างฟังก์ชันให้ทุกเส้นทางออกไหลมารวมผ่านlabel สำหรับการปล่อยเพียงจุดเดียว (goto pu_done ในโค้ด ingest) ฟังก์ชันนี้เป็น wrapper บาง ๆ ของ optiga_manager_touch_hold_reason("Signing with secure element") จุดที่เรียกแบบเปล่า ๆ 2 แห่งใน optiga_trust_helpers.c คือเส้นทางการเซ็นของ TLS (:1673 ภายใน trustm_ecdsa_sign) และการตรวจสอบโมเดลแบบเป็นขั้น (staged) (:4629) ทั้ง 2 แห่งซ้อนอยู่ภายใน lock หรือ gate (ด่านกั้น) ชั้นนอก
variant ที่ใช้ได้
mtb-mpy และ mtb-only
/* ...context: inside the Protected Update bundle ingest ... */
/* Keep CM55 touch off the bus for the whole ingest.
*
* The secure element and the touch controller share SCB5 on this board.
* The carried-over reference has no touchscreen and so no notion of this;
* dropped in here unchanged, its longest writes lose the bus mid-transfer.
* Observed 2026-08-06 on correlation bento-pu-1: the 8-byte trust anchor
* metadata write succeeded, and the 580-byte certificate write that follows
* failed with 0x0102 — OPTIGA_COMMS_ERROR, the transport layer, not the
* chip refusing anything — after 57 seconds of comms retries.
*
* Held across the entire function rather than per operation: the ingest is
* one long conversation with the chip, and releasing between steps would
* reopen the same window. Counted, so the signature path inside
* trustm_ecdsa_sign() nests without resuming polling early. Every exit runs
* through pu_done, which releases it. */
/* ...context: inside optiga_verify_staged_model() ... */
return STAGE_SIG_CHIP_ERROR;
}
/* Same bus discipline every other transaction here uses: the secure
* element and the touch controller share SCB5. */

◆ optiga_manager_touch_hold_reason()

void optiga_manager_touch_hold_reason ( const char * reason)

การจับไว้แบบนับจำนวนแบบเดียวกัน พร้อมข้อความ busy modal ที่ CM55 แสดงระหว่างที่การสัมผัสถูกปิด

ข้อกำหนดการเรียกใช้
การจับไว้แบบนับจำนวนแบบเดียวกัน พร้อมข้อความที่ CM55 นำขึ้นแสดงบนหน้าจอการจัดเตรียม (provisioning) ระหว่างที่การสัมผัสถูกปิด (busy modal) กฎการจับคู่เหมือนกัน จุดที่ยกมาแสดงรายละเอียดข้อเดียวที่คนมองข้าม คือการจับไว้ถูกปล่อยที่ branch ของ optiga_chip_enter() ที่ล้มเหลวด้วย (ipc_hsm_handler.c:2419-2420) — เพราะจับไว้ก่อนเข้า gate ดังนั้น gate ที่ปฏิเสธก็ยังค้างการปล่อยอยู่
variant ที่ใช้ได้
mtb-mpy และ mtb-only
/* ...context: inside the synchronous credential read ... */
/* Pause CM55 touch to get exclusive SCB0 I2C access */
optiga_manager_touch_hold_reason("Reading stored credentials");
/* These take s_optiga_mutex but never entered the gate, so they were the
* third mechanism that did not know about the other two. */
xSemaphoreGive(s_optiga_mutex);
return false;
}
bool ok = false;
if (optiga_open()) {
uint16_t len = read_oid(oid, buf, buf_len);
printf("[HSM] cred_read_sync: slot %u OID 0x%04X → %u bytes\r\n",
slot, oid, len);
if (len > 0) {
if (out_len) *out_len = len;
ok = true;
}
optiga_close();
} else {
printf("[HSM] cred_read_sync: optiga_open FAILED (slot %u)\r\n", slot);
}
/* Resume CM55 touch polling */

◆ optiga_manager_touch_release()

void optiga_manager_touch_release ( void )

ลดค่าตัวนับการจับไว้ — จับคู่ 1:1 อย่างเคร่งครัดกับการจับไว้ทุกครั้ง ในทุกการคืนค่าก่อนกำหนด

ข้อกำหนดการเรียกใช้
ลดค่าตัวนับ CM55 จะกลับมาวนถาม (polling) การสัมผัสอีกครั้งเมื่อตัวนับถึงศูนย์ จับคู่ 1:1 อย่างเคร่งครัดกับการจับไว้ทุกครั้ง ในทุกการคืนค่าก่อนกำหนด wrapper *_held() ทั้ง 5 ตัวใน ipc_hsm_handler.c คือตัวอย่างที่ชัดเจนที่สุด แต่ละตัวจับไว้หนึ่งครั้ง ทำงานหนึ่งอย่าง ปล่อยหนึ่งครั้ง แล้วคืนค่า "Nothing holds across the 60 second wait for the platform" — การจับไว้มีไว้สำหรับการติดต่อกับชิปหนึ่งชุด ห้ามใช้กับการรอเครือข่าย mqtt_mtls_setup.c คือตัวอย่างอ้างอิงของการคืนค่าก่อนกำหนดทุกเส้นทาง: ปล่อย 7 ครั้งต่อการจับไว้หนึ่งครั้ง หนึ่งครั้งต่อหนึ่งเส้นทางออก
variant ที่ใช้ได้
mtb-mpy และ mtb-only
static bool prov_open_held(void)
{
bool ok;
optiga_manager_touch_hold_reason("Opening the secure element");
return ok;
}
static void prov_close_held(void)
{
optiga_manager_touch_hold_reason("Closing the secure element");
}
static bool prov_make_csr_held(uint16_t key_oid)
{
bool ok;
optiga_manager_touch_hold_reason("Generating a key and signing the request");
ok = prov_make_csr(key_oid);
return ok;
}
static uint16_t prov_manifest_anchor_held(uint16_t oid)
{
uint16_t anchor;
optiga_manager_touch_hold_reason("Reading the secure element");
return anchor;
}
static int prov_publish_pu_held(const char *target, const char *anchor)
{
int rc;
optiga_manager_touch_hold_reason("Generating a key and signing the request");
rc = tesaiot_publish_protected_update(target, anchor, 1U, true);
return rc;
}