Integrating System Idle mode in SLN-LOCAL2-IOT

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Integrating System Idle mode in SLN-LOCAL2-IOT

3,418 Views
dashdwan
Contributor III

Hi,

I was validating the low power modes in SLN-LOCAL2-IOT using the evkmimxrt1060_power_mode_switch_bm  project for iMXRT1060 EVK. I just validated the System Idle mode and I need to integrate this mode to the sln_local2_iot_local_voice project. 

When I compared both the directories I find really confused regarding what all changes to be made.

Could anyone help me understand the required changes that should be made in order to perform this task?

If possible, a reference code for this could be more helpful!

Thanks in advance!!

Labels (1)
Tags (1)
0 Kudos
36 Replies

1,884 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan 

   As the directly low power demo works.

  About the low power integrated to the SLN_Local2_iot local_demo, you can post your issues to the solution team directly.

local-commands@nxp.com

When you send the email, please also contains these information:

Customer information

Project Annual Volume:

End Application Name:

Project requirement:

Then our solution team will help you about it!

Best Regards,

Kerry

0 Kudos

2,114 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan 

 Please check the attachment, the system idle mode already works, it can use the TP1 connect to GND J71-1 to wakeup the system.

 This project is based on the local_demo, and the flash adress is modified to the address 0x60000000, so even you don't download bootloader, bootstap, it also works.

 Just for your reference, more detail, please debug it by yourself, thanks.

 

Best Regards,

Kerry

0 Kudos

2,111 Views
dashdwan
Contributor III

Hi @kerryzhou 

I see that all the other threads are commented out in the main program. So the local-voice tasks are not performed at any point in this reference code (Before or after low power mode), right?

I actually need a provision to switch to system idle and wakeup via wake pin, and on run mode, it must be able to perform all the other tasks. I believe you have coded in a baremetal style, but actually i need the FreeRTOS implementation of the same (That's when the issues occured for me).

I hope it was clear. Please let me know otherwise.

0 Kudos

2,096 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan ,

   Yes, I understand you want to test the system idle on the local_demo.

  In fact, the code which I give you is on the local_demo, it is testing the system idle directly, as we talk it previously, it always meet the restart issues, right? Then I test the system idle directly with all the other task comment, just to find the root issues.

  At last, I find, you and me the restart issues is caused by this file:

  specific.c, please use my previous attached project one, very important, it even also can help you solve the low power issues, in the prevous time, we meet the low power run, low power idle can't work, now with this file, it also works.

  Then this code:

AT_QUICKACCESS_SECTION_CODE(void SwitchSystemClocks(lpm_power_mode_t power_mode));

The SwitchSystemClocks need to put into the internal RAM, if in the external flash, then it will meet issues.

So, you need to modify the fsl_common.h, 

#define AT_QUICKACCESS_SECTION_CODE(func) __attribute__((section("CodeQuickAccess"), __noinline__)) func
#define AT_QUICKACCESS_SECTION_DATA(func) func

This will helps to modfiy the API to the internal RAM.

In fact, I also modify the .ld file:

.data_RAM2 : ALIGN(4)
{
FILL(0xff)
PROVIDE(__start_data_RAM2 = .) ;
PROVIDE(__start_data_SRAM_ITC = .) ;
*(.ramfunc.$RAM2)
*(.ramfunc.$SRAM_ITC)
*(.vectorTableRam)
KEEP(*(CodeQuickAccess)) /*kerry add */
*flexspi_hyper_flash_ops.o(.text*)
*fsl_flexspi.o(.text*)
*sln_flash.o(.text*)
. = ALIGN(4) ;
PROVIDE(__end_data_RAM2 = .) ;
PROVIDE(__end_data_SRAM_ITC = .) ;
} > SRAM_ITC AT>BOARD_FLASH

Add the CodeQuickAccess to the internal ITCM.

So, I think you can test the system idle on the local_demo directly, after it works then you can add other voice related task again.

After it works, then you add the other code.

Before you enter the system idle mode, you must need to make sure all the interrupt is disabled, except the wakeup pin interrupt is enabled. Otherwise, you will meet the wakeup failed issues.

So, after you test the system idle works on the local_demo, you can try to add the original code back, and add the disable interrupt code before the system idle enter, then after the system idle is wakeup, enable the related interrupt again.

Please try to test it on your side.

You even can add my mentioned specific file to your old test code directly, you will find the low power can entered, but if you don't disable other interrupt, you may meet the wakeup filed issues. 

Again: disable all other interrupt expert wakeup interrupt before enter the low power mode.

Wish it helps you!

Best Regards,

Kerry

0 Kudos

2,089 Views
dashdwan
Contributor III

Hi @kerryzhou 

Thank you so much for your response. I tested with your code, it worked completely fine. But when I tried integrating with FreeRTOS, its getting stuck in this point:

Screenshot from 2021-12-06 13-08-00.png

Could you please check it?

 

0 Kudos

2,083 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan ,

    In fact, I think you can use the local_demo original code, then modify my mentioned points, add the system idle code in my package directly, then you should can find it can enter the low power mode directly, but wakeup may have issues, that is caused by: disable the other interrupt except the WAKEUP pin before enter the low power mode.

  About your assert issues, if you comment the low power code, wether you still have this issues or not?

Best Regards,

Kerry

0 Kudos

2,082 Views
dashdwan
Contributor III

Hi @kerryzhou 

In the above code, I have just created a sleepTask task and disabled all other tasks from the local_voice code. The code which was working alright in baremetal style does not work when given as a seperate task with all other tasks disabled. What does this indicate?

As you know, with respect to my use case, i cannot implement this in baremetal style and the FreeRTOS implimentation of the same is a must. 

When i tried again with the modifications you mentioned, I'm facing the same issue in when i give sleepTask as a seperate task. Could you please help me find a way out? 

0 Kudos

2,072 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan 

  Please note, not the task, it is the interrupt.

   You can check the NVIC register to the your enabled interrupt, before you enter the system idle more, just leave the wakeup pin interrupt, all other interrupt is disabled.

   Please try it again.

 

Best Regards,

Kerry

0 Kudos

2,061 Views
dashdwan
Contributor III

HI @kerryzhou 

The assert issue is still happening even after commenting out the sleepTask. The program gets stuck there and cannot come out of that state.

Regarding disabling all other interrupts from NVIC register, could you provide me an insight on how to do that? 

Thanks in advance!

0 Kudos

2,039 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan ,

  1. About the assert issue, it may be related to the original project, if still not OK.

    You can import a new local_demo, test it OK, then add the my related low power driver code again.

     You can compare and learn it.

 

  2. About the interrupts from NVIC register

   Please refer to this API: NVIC_DisableIRQ(IRQ).

NVIC_ClearPendingIRQ(TSC_DIG_IRQn)

__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
__DSB();
__ISB();
}
}

__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
}
}

You can see the related register ICPR, ICER, then you also can debug it check the NVIC register.

More detail about the NVIC, check ARM core document, IRQ, you can find it in MIMXRT106S.h

 

Wish it helps you!

Best Regards,

Kerry

 

0 Kudos

1,991 Views
dashdwan
Contributor III

Hi @kerryzhou 

Thanks for your response!

I tried disabling all interrupts and enabling just the GPIO1 interrupt using the DisableGlobalIRQ & EnableIRQ APIs. 

The assert problem was not solved, so, I commented out the threads which raised this error temporarily.

Now, I think the restart issue is solved as the LED blinking stops after a while. But it does not wake up from that state. 

  1. Can I confirm that the device is currently in the System Idle state?
  2. Can you please provide a working low power code which is already integrated with FreeRTOS for my reference?

 

0 Kudos

1,987 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan ,

  DisableGlobalIRQ & EnableIRQ is not OK,  as it will also disable the wakeup pin interrupt, that's why you enter the low power mode, and can't wake up.

   So, I suggest you disable the enabled IRQ in ICER, as i know, the bootloader, bootstrap enable some interrupt, and that also caused the pending IRQ, if you don't clear and disable the related interrupt, it may case the low power issues, which also include the wake up issues.

   So, you can debug your code, check NVIC_ICER register, check which IRQ is enabled, then disable it,  check the NVIC_ICPR register, clear it before the low power is entered, just leave the wakeup pin interrupt enabled.

NVIC_DisableIRQ(IRQ).

NVIC_ClearPendingIRQ(TSC_DIG_IRQn)

__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
__DSB();
__ISB();
}
}

__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
}
}

 

Best Regards,

Kerry

0 Kudos

1,972 Views
dashdwan
Contributor III

Hi @kerryzhou 

I checked the NVIC register, the only active interrupt other than Wakeup was USB_OTG1_IRQ. I disabled it and tried again; the device moves to system idle mode (LED blink stops) but it doesn't wake up. I clearly don't understand what's the issue here. Could you please check on your side with FreeRTOS?

I have attached my test code below.

0 Kudos

1,953 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan ,

  As I know, not only USB interrupt, also UART6, and others interrupt didn't disabled.

 Recently, really a little overload for a lot of cases in the queue, will find time to help you check it, but may be later.

  I think it is not the freertos issues, as you know, low power code also have the freertos project, I think, we can meger the freertos low power project to the local demo again when I have time.

Best Regards,

Kerry

0 Kudos

1,924 Views
dashdwan
Contributor III

Hi @kerryzhou 

Thanks for replying. 

I can wait for you to test from your side. Meanwhile I'll try from my side too.

 

0 Kudos

1,911 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan ,

   About your own checking, I suggest you test like this:

Use these code:

NVIC_GetEnableIRQ  -> NVIC_DisableIRQ

NVIC_GetPendingIRQ -> NVIC_GetPendingIRQ

The detail IRQ, you can check in MIMXRT106S.h, typedef enum IRQn .

You can write a code, get the enabled IRQ, if it is enabled, disable it, get pending IRQ, if it is enabled, disable it. Just leave the wakeup pin. You can check all the IRQ number from 0->157

You can test it, whether use this code before enter the low power mode in local_demo project it works or not?

Any updated information, please kindly let me know.

Best Regards,

Kerry

 

0 Kudos

2,139 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan ,

  Already help you create the private case, the case number is 00436202.

  And I also send you the email, you should already receive the reply in your email: xxx@vvdntech.in

 Then, you can reply me directly in your email, that is private through the email, not the public community.

  Wait for your reply!

Best Regards,

Kerry

0 Kudos

2,399 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan ,

    Thanks for your patient and new question post!

     You can merge the evkmimxrt1060_power_mode_switch project to the LOCAL2 board code sln_local2_iot_local_voice .

     If you just need to use System Idle mode, you even don't need to copy all the related API to the LOCAL2 project, you can just copy the related system idle code is OK.

    About the demo code already integrated directly, I still don't have it.

   But, the thought is very easy, as you already make the SDK code works on the local2 board,  you don't need to compare the two project, you can just copy the related low power used function to the local2 demo code, to set yourself API, then call it, the local2 project also use the SDK fsl driver.

  You can try it at first.

  If you still have issues, just kindly let me know.

Best Regards,

Kerry

 

      

    

0 Kudos

2,392 Views
dashdwan
Contributor III

Hi @kerryzhou 

Thanks for your response!

I tried copying the board files, driver files and related APIs to the local voice project in SLN-LOCAL2-IOT demo apps. But I am encountering many errors like redefining of several MACROS, pin muxing errors and some more, which i was not able to grasp completely. Is it this difficult to integrate system idle mode? Am I trying in the wrong path?

I have attached the demo code from SLN-LOCAL2-IOT. Could you please check that and help me in understanding in which all files i should add a change? It will be more helpful if you could provide an edited code of the same.

0 Kudos

2,380 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @dashdwan 

   You are welcome!

   In fact, integrating system idle mode is not difficult, that's why I let you try it.

   These days, really a lot of cases in the queue to test, that's why I guide you to test it at first.

   Today, I help you port one, you can check it at test, it build without errors, but I still don't have time to test it.

kerryzhou_0-1637050193720.png

In fact, it is the same code from the SDK which you have tested, please do more detail checking and testing on your side.

 

Wish it helps you!

Best Regards,

Kerry

   

0 Kudos