Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(BLE): MAX32690 DATC Hardfaulting with ICC enabled #988

Merged
merged 13 commits into from
Apr 15, 2024
82 changes: 41 additions & 41 deletions .github/workflows/scripts/test_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -295,42 +295,42 @@ function change_advertising_names() {
if [ $(hostname) == "wall-e" ]; then
# change advertising name for projects under test to avoid
# connections with office devices
printf "> changing advertising names : $MSDK_DIR/Examples/$DUT_NAME_UPPER\r\n\r\n"
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_dats
printf "> changing advertising names : $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth\r\n\r\n"
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_dats
perl -i -pe "s/\'D\'/\'X\'/g" dats_main.c
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_datc
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_datc
perl -i -pe "s/\'D\'/\'X\'/g" datc_main.c
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_otac
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_otac
perl -i -pe "s/\'S\'/\'X\'/g" datc_main.c
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_otas
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_otas
perl -i -pe "s/\'S\'/\'X\'/g" dats_main.c
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_FreeRTOS
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_FreeRTOS
perl -i -pe "s/\'S\'/\'X\'/g" dats_main.c
# change advertising name to scan for on the main device client apps
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_datc
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_datc
perl -i -pe "s/\'D\'/\'X\'/g" datc_main.c
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_otac
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_otac
perl -i -pe "s/\'S\'/\'X\'/g" datc_main.c
# build BLE examples
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER
else
# change advertising name for projects under test to avoid
# connections with office devices
printf "> changing advertising names : $MSDK_DIR/Examples/$DUT_NAME_UPPER\r\n\r\n"
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_dats
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_dats
perl -i -pe "s/\'D\'/\'Z\'/g" dats_main.c
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_datc
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_datc
perl -i -pe "s/\'D\'/\'Z\'/g" datc_main.c
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_otac
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_otac
perl -i -pe "s/\'S\'/\'Z\'/g" datc_main.c
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_otas
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_otas
perl -i -pe "s/\'S\'/\'Z\'/g" dats_main.c
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_FreeRTOS
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_FreeRTOS
perl -i -pe "s/\'S\'/\'Z\'/g" dats_main.c
# change advertising name to scan for on the main device client apps
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_datc
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_datc
perl -i -pe "s/\'D\'/\'Z\'/g" datc_main.c
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_otac
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_otac
perl -i -pe "s/\'S\'/\'Z\'/g" datc_main.c
fi
}
Expand Down Expand Up @@ -419,23 +419,23 @@ function run_datcs_conencted_tests() {
erase_all_devices

# Flash MAIN_DEVICE with BLE_datc
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_datc
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_datc
make clean
make libclean
make -j

# flash client first because it takes longer
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_datc/build
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_datc/build
printf "\r\n> Flashing BLE_datc on main device: $MAIN_DEVICE_NAME_UPPER\r\n"
#flash_with_openocd_fast $MAIN_DEVICE_NAME_LOWER $MAIN_DEVICE_ID 1
flash_with_openocd $MAIN_DEVICE_NAME_LOWER $MAIN_DEVICE_ID 1

# flash DUT with BLE_dats
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_dats
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_dats
make clean
make libclean
make -j
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_dats/build
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/Bluetooth/BLE_dats/build
printf "\r\n> Flashing BLE_dats on DUT $DUT_NAME_UPPER\r\n"
#flash_with_openocd_fast $DUT_NAME_LOWER $DUT_ID 2
flash_with_openocd $DUT_NAME_LOWER $DUT_ID 2
Expand All @@ -462,7 +462,7 @@ function run_datcs_conencted_tests() {
let "numOfFailedTests+=$testResult"
failedTestList+="| BLE_dat_cs ($DUT_NAME_UPPER) "
# test failed, save elfs datc/s
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_datc/build
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_datc/build
cp $MAIN_DEVICE_NAME_LOWER.elf $EXAMPLE_TEST_PATH/results/failed_elfs/$MAIN_DEVICE_NAME_LOWER"_BLE_datcs_client.elf"
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_dats/build
cp $DUT_NAME_LOWER.elf $EXAMPLE_TEST_PATH/results/failed_elfs/$DUT_NAME_LOWER"_BLE_datcs_server.elf"
Expand Down Expand Up @@ -497,7 +497,7 @@ function run_ota_test() {
change_advertising_names

# change the target the OTAC embedded firmware in the client is built for
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_otac
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_otac
#appends TARGET , TARGET_UC and TARGET_LC to the make commands and sets them to $DUT_NAME_UPPER and $DUT_NAME_LOWER
sed -i 's/BUILD_DIR=\$(FW_BUILD_DIR) BUILD_BOOTLOADER=0 PROJECT=fw_update/BUILD_DIR=\$(FW_BUILD_DIR) BUILD_BOOTLOADER=0 PROJECT=fw_update TARGET='"$DUT_NAME_UPPER"' TARGET_UC='"$DUT_NAME_UPPER"' TARGET_LC='"$DUT_NAME_LOWER"'/g' project.mk
sed -i 's/BUILD_DIR=\$(FW_BUILD_DIR) \$(FW_UPDATE_BIN)/BUILD_DIR=\$(FW_BUILD_DIR) \$(FW_UPDATE_BIN) TARGET='"$DUT_NAME_UPPER"' TARGET_UC='"$DUT_NAME_UPPER"' TARGET_LC='"$DUT_NAME_LOWER"'/g' project.mk
Expand Down Expand Up @@ -526,18 +526,18 @@ function run_ota_test() {
make BOARD=$DUT_BOARD_TYPE USE_INTERNAL_FLASH=$INTERNAL_FLASH_TEST BUILD_BOOTLOADER=0 -j
echo "BOARD=$DUT_BOARD_TYPE USE_INTERNAL_FLASH=$INTERNAL_FLASH_TEST -j"
# make OTAC
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_otac
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_otac
# flash MAIN_DEVICE with BLE_OTAC, it will use the OTAS bin with new firmware
make clean
make BOARD=$DUT_BOARD_TYPE FW_UPDATE_DIR=../../$DUT_NAME_UPPER/BLE_otas USE_INTERNAL_FLASH=$INTERNAL_FLASH_TEST BUILD_BOOTLOADER=0 -j

cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_otac/build
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_otac/build
printf ">>>>>>> Flashing BLE_otac on main device: $MAIN_DEVICE_NAME_UPPER\r\n "
flash_with_openocd $MAIN_DEVICE_NAME_LOWER $MAIN_DEVICE_ID
printf ">>>>>>> Flashing done"

#revert files back
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_otac
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_otac
git restore .

cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_otas
Expand All @@ -559,14 +559,14 @@ function run_ota_test() {
if [[ "$INTERNAL_FLASH_TEST" -ne "0" ]]; then
failedTestList+="| BLE_ota_cs_int ($DUT_NAME_UPPER) "
# test failed, save elfs datc/s
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_otac/build
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_otac/build
cp $MAIN_DEVICE_NAME_LOWER.elf $EXAMPLE_TEST_PATH/results/failed_elfs/$MAIN_DEVICE_NAME_LOWER"_"$DUT_NAME_LOWER"_BLE_otacs_client_int.elf"
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_otas/build
cp $DUT_NAME_LOWER.elf $EXAMPLE_TEST_PATH/results/failed_elfs/$DUT_NAME_LOWER"_BLE_otacs_server_int.elf"
else
failedTestList+="| BLE_ota_cs_ext ($DUT_NAME_UPPER) "
# test failed, save elfs datc/s
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/BLE_otac/build
cd $MSDK_DIR/Examples/$MAIN_DEVICE_NAME_UPPER/Bluetooth/BLE_otac/build
cp $MAIN_DEVICE_NAME_LOWER.elf $EXAMPLE_TEST_PATH/results/failed_elfs/$MAIN_DEVICE_NAME_LOWER"_"$DUT_NAME_LOWER"_BLE_otacs_client_ext.elf"
cd $MSDK_DIR/Examples/$DUT_NAME_UPPER/BLE_otas/build
cp $DUT_NAME_LOWER.elf $EXAMPLE_TEST_PATH/results/failed_elfs/$DUT_NAME_LOWER"_BLE_otacs_server_ext.elf"
Expand Down Expand Up @@ -610,31 +610,31 @@ if [ $CURRENT_TEST == "all" ]; then
erase_all_devices
run_all_not_conencted_tests
CURRENT_TEST="all"
# temp diasble datc/s and otas tests until new RF PHY is debugged with ME17B
# run_datcs_conencted_tests
# CURRENT_TEST="all"
# run_ota_test 1 # arg 1= internal flash
# if [[ $DUT_NAME_UPPER != "MAX32690" ]]; then
# run_ota_test 0 # arg 0 = external flash
# fi
temp diasble datc/s and otas tests until new RF PHY is debugged with ME17B
run_datcs_conencted_tests
CURRENT_TEST="all"
run_ota_test 1 # arg 1= internal flash
if [[ $DUT_NAME_UPPER != "MAX32690" ]]; then
run_ota_test 0 # arg 0 = external flash
fi

echo
elif [ $CURRENT_TEST == "dats" ]; then
echo
echo "Running Datc/s connected test"
erase_all_devices
# temp diasble datc/s and otas tests until new RF PHY is debugged with ME17B
#run_datcs_conencted_tests
temp diasble datc/s and otas tests until new RF PHY is debugged with ME17B
run_datcs_conencted_tests
echo
elif [ $CURRENT_TEST == "ota" ]; then
echo
echo "Running OTA test"
# temp diasble datc/s and otas tests until new RF PHY is debugged with ME17B
# erase_all_devices
# run_ota_test 1 # arg 1 = internal flash
# if [[ $DUT_NAME_UPPER != "MAX32690" ]]; then
# run_ota_test 0 # arg 0= external flash
#fi
temp diasble datc/s and otas tests until new RF PHY is debugged with ME17B
erase_all_devices
run_ota_test 1 # arg 1 = internal flash
if [[ $DUT_NAME_UPPER != "MAX32690" ]]; then
run_ota_test 0 # arg 0= external flash
fi
echo
else
echo
Expand Down
24 changes: 23 additions & 1 deletion Examples/MAX32690/Bluetooth/BLE_datc/datc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,19 @@ void DatcHandlerInit(wsfHandlerId_t handlerId)
datcCb.scanTimer.handlerId = handlerId;
datcCb.scanTimer.msg.event = SCAN_START_EVT;
}

/*************************************************************************************************/
/*!
* \brief Check to see if btn timer is enabled.
*
* \param[in] tmr btn timer.
*
* \return TRUE if enabled, FALSE otherwise.
*/
/*************************************************************************************************/
static bool_t btnTmrIsEnabled(mxc_tmr_regs_t *tmr)
{
return (bool_t)(BTN_1_TMR->ctrl0 & (MXC_F_TMR_CTRL0_EN_A | MXC_F_TMR_CTRL0_EN_B));
}
/*************************************************************************************************/
/*!
* \brief Platform button press handler.
Expand All @@ -1265,6 +1277,11 @@ void DatcHandlerInit(wsfHandlerId_t handlerId)
static void btnPressHandler(uint8_t btnId, PalBtnPos_t state)
{
if (btnId == 1) {
if (!btnTmrIsEnabled(BTN_1_TMR)) {
APP_TRACE_INFO0("Software timer is not enabled!");
return;
}

/* Start/stop button timer */
if (state == PAL_BTN_POS_UP) {
/* Button Up, stop the timer, call the action function */
Expand All @@ -1283,6 +1300,11 @@ static void btnPressHandler(uint8_t btnId, PalBtnPos_t state)
MXC_TMR_SW_Start(BTN_1_TMR);
}
} else if (btnId == 2) {
if (!btnTmrIsEnabled(BTN_2_TMR)) {
APP_TRACE_INFO0("Software timer is not enabled!");
return;
}

/* Start/stop button timer */
if (state == PAL_BTN_POS_UP) {
/* Button Up, stop the timer, call the action function */
Expand Down
23 changes: 22 additions & 1 deletion Examples/MAX32690/Bluetooth/BLE_dats/dats_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,19 @@ static void datsWsfBufDiagnostics(WsfBufDiag_t *pInfo)
pInfo->param.alloc.taskId, pInfo->param.alloc.len);
}
}

/*************************************************************************************************/
/*!
* \brief Check to see if btn timer is enabled.
*
* \param[in] tmr btn timer.
*
* \return TRUE if enabled, FALSE otherwise.
*/
/*************************************************************************************************/
static bool_t btnTmrIsEnabled(mxc_tmr_regs_t *tmr)
{
return (bool_t)(BTN_1_TMR->ctrl0 & (MXC_F_TMR_CTRL0_EN_A | MXC_F_TMR_CTRL0_EN_B));
}
/*************************************************************************************************/
/*!
* \brief Platform button press handler.
Expand All @@ -909,6 +921,10 @@ static void datsWsfBufDiagnostics(WsfBufDiag_t *pInfo)
static void btnPressHandler(uint8_t btnId, PalBtnPos_t state)
{
if (btnId == 1) {
if (!btnTmrIsEnabled(BTN_1_TMR)) {
APP_TRACE_INFO0("Software timer is not enabled!");
return;
}
/* Start/stop button timer */
if (state == PAL_BTN_POS_UP) {
/* Button Up, stop the timer, call the action function */
Expand All @@ -927,6 +943,11 @@ static void btnPressHandler(uint8_t btnId, PalBtnPos_t state)
MXC_TMR_SW_Start(BTN_1_TMR);
}
} else if (btnId == 2) {
if (!btnTmrIsEnabled(BTN_2_TMR)) {
APP_TRACE_INFO0("Software timer is not enabled!");
return;
}

/* Start/stop button timer */
if (state == PAL_BTN_POS_UP) {
/* Button Up, stop the timer, call the action function */
Expand Down
4 changes: 4 additions & 0 deletions Libraries/Boards/MAX32690/EvKit_V1/Source/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "spixf.h"
#include "tft_st7735.h"
#include "uart.h"
#include "icc.h"

/***** Global Variables *****/
mxc_uart_regs_t *ConsoleUart = MXC_UART_GET_UART(CONSOLE_UART);
Expand Down Expand Up @@ -102,6 +103,9 @@ __weak void GPIO2_IRQHandler(void)
/******************************************************************************/
int Board_Init(void)
{
//Disable to prevent cache bug
MXC_ICC_Disable(MXC_ICC0);

int err;

// Enable GPIO
Expand Down
Loading