Hi,
Previous E2E thread: https://e2e.ti.com/f/1/t/1134916
I am giving details on using the Simple Peripheral application example project from the SDK 5.10 where the SHA operation is stuck. Essentially, I have below threads as per priority highest to lowest in the firmware:
- ICall (BLE thread, already present)
- Simple Peripheral (changed priority from 1 to 2)
- Hash operation (priority 1) --> Added newly
- IDLE (priority 0)
The whole goal of this exercise is to reproduce the issue where the SHA operation is preempted by high priority thread (Simple Peripheral) and then the SHA operation is stuck forever. So, please take a note of this.
The example also uses the LED on the LP to let the user know when the firmware is stuck (when the Green LED is ON forever). Other than that, the firmware also uses the Display printf statements where the PUTTY shows freezed content when the issue happens. In normal case, the firmware calls the system reset after the GAP_DEVICE_INIT_DONE_EVENT is processed completely as we are seeing the issue only before that.
When I have the SHA operation performed under the critical section, the issue is never observed. However, if it is not under the critical section (see Hash_taskFxn()), the issue is observed.
//ICall_CSState key = ICall_enterCriticalSection();
// Verify correct input generates expected output
result = SHA2_addData(sha2Handle, &dataToHash[0], HASH_VERIFICATION_PARTIAL_BLOCK_SIZE); // --> ISSUE: Never returns
//ICall_leaveCriticalSection(key);
Task_sleep((xdc_UInt32)randomNumber+1);
Display_printf(dispHandle, SP_ROW_SHA+1, 0, "SHA Done: %d, RP Addr: %s", randomNumber, Util_convertBdAddr2Str(pRpaNew));
GPIO_write(CONFIG_LED_1_GPIO, CONFIG_GPIO_LED_OFF);
See the two files attached which has been modified. Also, we have this issue as the highest priority to analyze and fix so your help is very much appreciated.
simple_peripheral.syscfg:
/**
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
* @cliArgs --board "/ti/boards/CC26X2R1_LAUNCHXL" --product "simplelink_cc13x2_26x2_sdk@5.10.00.48"
* @versions {"data":"2021031521","timestamp":"2021031521","tool":"1.8.0+1863","templates":null}
*/
/**
* Import the modules used in this configuration.
*/
const ble = scripting.addModule("/ti/ble5stack/ble");
const CCFG = scripting.addModule("/ti/devices/CCFG");
const rfdesign = scripting.addModule("/ti/devices/radioconfig/rfdesign");
const Display = scripting.addModule("/ti/display/Display");
const Display1 = Display.addInstance();
const AESCCM = scripting.addModule("/ti/drivers/AESCCM");
const AESCCM1 = AESCCM.addInstance();
const AESCTRDRBG = scripting.addModule("/ti/drivers/AESCTRDRBG");
const AESCTRDRBG1 = AESCTRDRBG.addInstance();
const AESECB = scripting.addModule("/ti/drivers/AESECB");
const AESECB1 = AESECB.addInstance();
const ECDH = scripting.addModule("/ti/drivers/ECDH");
const ECDH1 = ECDH.addInstance();
const GPIO = scripting.addModule("/ti/drivers/GPIO");
const GPIO1 = GPIO.addInstance();
const GPIO2 = GPIO.addInstance();
const NVS = scripting.addModule("/ti/drivers/NVS");
const NVS1 = NVS.addInstance();
const Power = scripting.addModule("/ti/drivers/Power");
const RF = scripting.addModule("/ti/drivers/RF");
const RTOS = scripting.addModule("/ti/drivers/RTOS");
const SHA2 = scripting.addModule("/ti/drivers/SHA2", {}, false);
const SHA21 = SHA2.addInstance();
const TRNG = scripting.addModule("/ti/drivers/TRNG");
const TRNG1 = TRNG.addInstance();
const LED = scripting.addModule("/ti/drivers/apps/LED", {}, false);
const LED1 = LED.addInstance();
const LED2 = LED.addInstance();
/**
* Write custom configuration values to the imported modules.
*/
ble.lockProject = true;
ble.radioConfig.codeExportConfig.$name = "ti_devices_radioconfig_code_export_param0";
ble.connUpdateParamsPeripheral.$name = "ti_ble5stack_general_ble_conn_update_params0";
ble.advSet1.$name = "ti_ble5stack_broadcaster_advertisement_set0";
ble.advSet1.advParam1.$name = "ti_ble5stack_broadcaster_advertisement_params0";
ble.advSet1.advData1.$name = "ti_ble5stack_broadcaster_advertisement_data0";
ble.advSet1.advData1.GAP_ADTYPE_FLAGS = true;
ble.advSet1.advData1.advertisingFlags = ["GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED","GAP_ADTYPE_FLAGS_GENERAL"];
ble.advSet1.advData1.GAP_ADTYPE_LOCAL_NAME_SHORT = true;
ble.advSet1.advData1.shortenedLocalName = "SP";
ble.advSet1.advData1.GAP_ADTYPE_16BIT_MORE = true;
ble.advSet1.advData1.numOfUUIDs16More = 1;
ble.advSet1.advData1.UUID016More = 0xFFF0;
ble.advSet1.scanRes1.$name = "ti_ble5stack_broadcaster_advertisement_data1";
ble.advSet1.scanRes1.GAP_ADTYPE_LOCAL_NAME_COMPLETE = true;
ble.advSet1.scanRes1.completeLocalName = "Simple Peripheral";
ble.advSet1.scanRes1.GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE = true;
ble.advSet1.scanRes1.maxConnInterval = 130;
ble.advSet1.scanRes1.GAP_ADTYPE_POWER_LEVEL = true;
ble.advSet2.$name = "ti_ble5stack_broadcaster_advertisement_set1";
ble.advSet2.advParam2.$name = "ti_ble5stack_broadcaster_advertisement_params1";
ble.advSet2.advParam2.advType = "extended";
ble.advSet2.advData2.$name = "ti_ble5stack_broadcaster_advertisement_data2";
ble.advSet2.advData2.GAP_ADTYPE_FLAGS = true;
ble.advSet2.advData2.advertisingFlags = ["GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED","GAP_ADTYPE_FLAGS_GENERAL"];
ble.advSet2.advData2.GAP_ADTYPE_LOCAL_NAME_SHORT = true;
ble.advSet2.advData2.shortenedLocalName = "SP";
ble.advSet2.advData2.GAP_ADTYPE_16BIT_MORE = true;
ble.advSet2.advData2.numOfUUIDs16More = 1;
ble.advSet2.advData2.UUID016More = 0xFFF0;
ble.advSet2.scanRes2.$name = "ti_ble5stack_broadcaster_advertisement_data3";
ble.advSet2.scanRes2.GAP_ADTYPE_LOCAL_NAME_COMPLETE = true;
ble.advSet2.scanRes2.completeLocalName = "Simple Peripheral";
ble.advSet2.scanRes2.GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE = true;
ble.advSet2.scanRes2.maxConnInterval = 130;
ble.advSet2.scanRes2.GAP_ADTYPE_POWER_LEVEL = true;
CCFG.enableBootloader = true;
CCFG.enableBootloaderBackdoor = true;
CCFG.dioBootloaderBackdoor = 13;
CCFG.levelBootloaderBackdoor = "Active low";
CCFG.ccfgTemplate.$name = "ti_devices_CCFGTemplate0";
Display1.$name = "CONFIG_Display_0";
Display1.$hardware = system.deviceData.board.components.XDS110UART;
Display1.enableANSI = true;
Display1.uartBufferSize = 128;
Display1.uart.$name = "CONFIG_DISPLAY_UART";
Display1.uart.txPinInstance.outputState = "High";
Display1.uart.txPinInstance.$name = "CONFIG_PIN_UART_TX";
Display1.uart.rxPinInstance.$name = "CONFIG_PIN_UART_RX";
AESCCM1.$name = "CONFIG_AESCCM0";
AESCTRDRBG1.$name = "CONFIG_AESCTRDRBG_0";
AESCTRDRBG1.aesctrObject.$name = "CONFIG_AESCTR_0";
AESECB1.$name = "CONFIG_AESECB0";
ECDH1.$name = "CONFIG_ECDH0";
GPIO1.$hardware = system.deviceData.board.components["BTN-1"];
GPIO1.mode = "Dynamic";
GPIO1.$name = "CONFIG_GPIO_BTN1";
GPIO1.pinInstance.$name = "CONFIG_PIN_BTN1";
GPIO2.$hardware = system.deviceData.board.components["BTN-2"];
GPIO2.mode = "Dynamic";
GPIO2.$name = "CONFIG_GPIO_BTN2";
GPIO2.pinInstance.$name = "CONFIG_PIN_BTN2";
NVS1.$name = "CONFIG_NVSINTERNAL";
NVS1.internalFlash.$name = "ti_drivers_nvs_NVSCC26XX0";
NVS1.internalFlash.regionBase = 0x48000;
NVS1.internalFlash.regionSize = 0x4000;
SHA21.$name = "CONFIG_SHA2_0";
TRNG1.$name = "CONFIG_TRNG_0";
LED1.$name = "CONFIG_LED_0";
LED1.$hardware = system.deviceData.board.components.LED_RED;
LED1.gpioPin.pinInstance.$name = "CONFIG_PIN_0";
LED2.$name = "CONFIG_LED_1";
LED2.$hardware = system.deviceData.board.components.LED_GREEN;
LED2.gpioPin.pinInstance.$name = "CONFIG_PIN_1";
/**
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
* re-solve from scratch.
*/
Display1.uart.uart.$suggestSolution = "UART1";
Display1.uart.uart.txPin.$suggestSolution = "boosterpack.4";
Display1.uart.uart.rxPin.$suggestSolution = "boosterpack.3";
GPIO1.gpioPin.$suggestSolution = "boosterpack.13";
GPIO2.gpioPin.$suggestSolution = "boosterpack.12";
LED1.gpioPin.gpioPin.$suggestSolution = "boosterpack.39";
LED2.gpioPin.gpioPin.$suggestSolution = "boosterpack.40";