use BBNSM RTC from U-Boot on i.MX 8ULP

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

use BBNSM RTC from U-Boot on i.MX 8ULP

Jump to solution
4,022 Views
DaisukeMizobuchi
Contributor III

Hello,

I want to use BBNSM(Battery-Backed Non-Secure Module) RTC from U-Boot on i.MX 8ULP.

The smart way would be to use RPMsg, but it's not implemented in U-Boot.

However, I can't access the BBNSM register from the Arm Cortex A35. Is there an exclusive lock with the Arm Cortex-M33? Since the power_mode_switch is working on the M33, the BBNSM RTC is used.


BBNSM is mapped to PBRIDGE0(Peripheral Bridge 0) on A35. I tried to see if I could use BBNSM with the A35.

I tried to read BBNSM_RTC_LS(BBNSM Real-Time Counter LS Register) but couldn't.

<pre>
=> md.l 0x28038040 1
"Synchronous Abort" handler, esr 0x96000210
elr: 000000008029b2a4 lr : 000000008029b1f4 (reloc)
elr: 00000000a5eef2a4 lr : 00000000a5eef1f4
x0 : 0000000000000009 x1 : 00000000fffffffe
x2 : 00000000a4e49458 x3 : 0000000000000020
x4 : 00000000ffffffff x5 : 00000000a4e491e8
x6 : 0000000000000030 x7 : 00000000a4e493a0
x8 : 0000000000000010 x9 : 0000000090a65063
x10: 00000000ffffffd8 x11: 0000000000000010
x12: 0000000000000006 x13: 000000000001869f
x14: 00000000a4e497c0 x15: 0000000000000021
x16: 00000000a5e6eb0c x17: 0000000000000000
x18: 00000000a4e51d40 x19: 0000000000000004
x20: 0000000000000004 x21: 0000000000000001
x22: 0000000028038040 x23: 00000000a4e49459
x24: 0000000000000000 x25: 00000000a4e49408
x26: 00000000a5f0ec2b x27: 0000000000000008
x28: 0000000000000004 x29: 00000000a4e493a0

Code: 2a0403f3 17ffffcb 7100129f 54000181 (b94002c3)
Resetting CPU ...

resetting ...
</pre>


PCC_BBNSM(PCC BBNSM Register) is 0xC0000000(PR=1, CGC=1), so it's
ready to use.

<pre>
=> md.l 0x280300e0 1 280300e0: c0000000 ....
</pre>


I've also tried using a Linux kernel, but I'm unable to access it
either. The driver used was rtc-nxp-bbnsm.c below.

https://lore.kernel.org/linux-arm-kernel/[email protected]/T/

Thanks,

mizo

0 Kudos
Reply
1 Solution
3,916 Views
jimmychan
NXP TechSupport
NXP TechSupport

Please add the following TRDC configuration to BOARD_SetTrdcGlobalConfig() in SDK : /boards/evkmimx8ulp/demo_apps/power_mode_switch/board.c. Then try to read 0x28038040 in uboot.

 

        mbcBlockConfig.memoryAccessControlSelect = TRDC_MBC_ACCESS_CONTROL_POLICY_ALL_INDEX;
        mbcBlockConfig.nseEnable                 = true; /* non secure state can access the block for cortex-A35 */
        mbcBlockConfig.mbcIdx                    = 2U;   /* MBC2 */
        mbcBlockConfig.domainIdx                 = 7U;   /* MBC2_DOM7 */
        mbcBlockConfig.slaveMemoryIdx            = 0U;   /* MBC2_DOM7_MEM0 */
        mbcBlockConfig.memoryBlockIdx            = 56U;  /* MBC2_DOM7_MEM0_BLK_CFG_W56 */
        TRDC_MbcSetMemoryBlockConfig(TRDC, &mbcBlockConfig);

 

 

For example, It can be added at line 401.

jimmychan_0-1721798486942.pngjimmychan_0-1721798486942.png

 

 

View solution in original post

0 Kudos
Reply
4 Replies
3,975 Views
jimmychan
NXP TechSupport
NXP TechSupport

Could you tell me which version of BSP are you using?

0 Kudos
Reply
3,943 Views
DaisukeMizobuchi
Contributor III

<p>Thank you for reply!</p>
<p>The BSP versions are as follows:</p>
<ul>
<li>imx-optee-os: lf-6.1.22-2.0.0</li>
<li>imx-atf: lf-6.1.22-2.0.0</li>
<li>uboot-imx: lf-6.1.22-2.0.0</li>
<li>linux-imx: lf-5.10.72-2.2.3</li>
</ul>
<p>Best regards,<br />mizo</p>

 

0 Kudos
Reply
3,917 Views
jimmychan
NXP TechSupport
NXP TechSupport

Please add the following TRDC configuration to BOARD_SetTrdcGlobalConfig() in SDK : /boards/evkmimx8ulp/demo_apps/power_mode_switch/board.c. Then try to read 0x28038040 in uboot.

 

        mbcBlockConfig.memoryAccessControlSelect = TRDC_MBC_ACCESS_CONTROL_POLICY_ALL_INDEX;
        mbcBlockConfig.nseEnable                 = true; /* non secure state can access the block for cortex-A35 */
        mbcBlockConfig.mbcIdx                    = 2U;   /* MBC2 */
        mbcBlockConfig.domainIdx                 = 7U;   /* MBC2_DOM7 */
        mbcBlockConfig.slaveMemoryIdx            = 0U;   /* MBC2_DOM7_MEM0 */
        mbcBlockConfig.memoryBlockIdx            = 56U;  /* MBC2_DOM7_MEM0_BLK_CFG_W56 */
        TRDC_MbcSetMemoryBlockConfig(TRDC, &mbcBlockConfig);

 

 

For example, It can be added at line 401.

jimmychan_0-1721798486942.pngjimmychan_0-1721798486942.png

 

 

0 Kudos
Reply
3,908 Views
DaisukeMizobuchi
Contributor III
Hello @jimmychan

Thanks for response,

I was able to use BBNSM RTC using the method I was taught!

Thanks,
mizo
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1910173%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Euse%20BBNSM%20RTC%20from%20U-Boot%20on%20i.MX%208ULP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1910173%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%20want%20to%20use%20BBNSM(Battery-Backed%20Non-Secure%20Module)%20RTC%20from%20U-Boot%20on%20i.MX%208ULP.%3C%2FP%3E%3CP%3EThe%20smart%20way%20would%20be%20to%20use%20RPMsg%2C%20but%20it's%20not%20implemented%20in%20U-Boot.%3C%2FP%3E%3CP%3EHowever%2C%20I%20can't%20access%20the%20BBNSM%20register%20from%20the%20Arm%20Cortex%20A35.%20Is%20there%20an%20exclusive%20lock%20with%20the%20Arm%20Cortex-M33%3F%20Since%20the%20power_mode_switch%20is%20working%20on%20the%20M33%2C%20the%20BBNSM%20RTC%20is%20used.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EBBNSM%20is%20mapped%20to%20PBRIDGE0(Peripheral%20Bridge%200)%20on%20A35.%20I%20tried%20to%20see%20if%20I%20could%20use%20BBNSM%20with%20the%20A35.%3C%2FP%3E%3CP%3EI%20tried%20to%20read%20BBNSM_RTC_LS(BBNSM%20Real-Time%20Counter%20LS%20Register)%20but%20couldn't.%3C%2FP%3E%3CP%3E%3CPRE%3E%3CBR%20%2F%3E%3D%26gt%3B%20md.l%200x28038040%201%3CBR%20%2F%3E%22Synchronous%20Abort%22%20handler%2C%20esr%200x96000210%3CBR%20%2F%3Eelr%3A%20000000008029b2a4%20lr%20%3A%20000000008029b1f4%20(reloc)%3CBR%20%2F%3Eelr%3A%2000000000a5eef2a4%20lr%20%3A%2000000000a5eef1f4%3CBR%20%2F%3Ex0%20%3A%200000000000000009%20x1%20%3A%2000000000fffffffe%3CBR%20%2F%3Ex2%20%3A%2000000000a4e49458%20x3%20%3A%200000000000000020%3CBR%20%2F%3Ex4%20%3A%2000000000ffffffff%20x5%20%3A%2000000000a4e491e8%3CBR%20%2F%3Ex6%20%3A%200000000000000030%20x7%20%3A%2000000000a4e493a0%3CBR%20%2F%3Ex8%20%3A%200000000000000010%20x9%20%3A%200000000090a65063%3CBR%20%2F%3Ex10%3A%2000000000ffffffd8%20x11%3A%200000000000000010%3CBR%20%2F%3Ex12%3A%200000000000000006%20x13%3A%20000000000001869f%3CBR%20%2F%3Ex14%3A%2000000000a4e497c0%20x15%3A%200000000000000021%3CBR%20%2F%3Ex16%3A%2000000000a5e6eb0c%20x17%3A%200000000000000000%3CBR%20%2F%3Ex18%3A%2000000000a4e51d40%20x19%3A%200000000000000004%3CBR%20%2F%3Ex20%3A%200000000000000004%20x21%3A%200000000000000001%3CBR%20%2F%3Ex22%3A%200000000028038040%20x23%3A%2000000000a4e49459%3CBR%20%2F%3Ex24%3A%200000000000000000%20x25%3A%2000000000a4e49408%3CBR%20%2F%3Ex26%3A%2000000000a5f0ec2b%20x27%3A%200000000000000008%3CBR%20%2F%3Ex28%3A%200000000000000004%20x29%3A%2000000000a4e493a0%3C%2FPRE%3E%3C%2FP%3E%3CP%3ECode%3A%202a0403f3%2017ffffcb%207100129f%2054000181%20(b94002c3)%3CBR%20%2F%3EResetting%20CPU%20...%3C%2FP%3E%3CP%3Eresetting%20...%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EPCC_BBNSM(PCC%20BBNSM%20Register)%20is%200xC0000000(PR%3D1%2C%20CGC%3D1)%2C%20so%20it's%3CBR%20%2F%3Eready%20to%20use.%3C%2FP%3E%3CP%3E%3CPRE%3E%3CBR%20%2F%3E%3D%26gt%3B%20md.l%200x280300e0%201%20280300e0%3A%20c0000000%20....%3CBR%20%2F%3E%3C%2FPRE%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI've%20also%20tried%20using%20a%20Linux%20kernel%2C%20but%20I'm%20unable%20to%20access%20it%3CBR%20%2F%3Eeither.%20The%20driver%20used%20was%20rtc-nxp-bbnsm.c%20below.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Flore.kernel.org%2Flinux-arm-kernel%2F20230215024117.3357341-1-ping.bai%40nxp.com%2FT%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Flore.kernel.org%2Flinux-arm-kernel%2F20230215024117.3357341-1-ping.bai%40nxp.com%2FT%2F%3C%2FA%3E%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3Emizo%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1910173%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3Ei.MX%208%20Family%20%7C%20i.MX%208QuadMax%20(8QM)%20%7C%208QuadPlus%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1915828%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20use%20BBNSM%20RTC%20from%20U-Boot%20on%20i.MX%208ULP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1915828%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHello%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1422%22%20target%3D%22_blank%22%3E%40jimmychan%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20for%20response%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI%20was%20able%20to%20use%20BBNSM%20RTC%20using%20the%20method%20I%20was%20taught!%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%2C%3CBR%20%2F%3Emizo%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1915806%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20use%20BBNSM%20RTC%20from%20U-Boot%20on%20i.MX%208ULP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1915806%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EPlease%20add%20the%20following%20TRDC%20configuration%20to%20BOARD_SetTrdcGlobalConfig()%20in%20SDK%20%3A%20%2Fboards%2Fevkmimx8ulp%2Fdemo_apps%2Fpower_mode_switch%2Fboard.c.%20Then%20try%20to%20read%200x28038040%20in%20uboot.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CPRE%20class%3D%22lia-code-sample%20%20language-markup%22%3E%3CCODE%3E%20%20%20%20%20%20%20%20mbcBlockConfig.memoryAccessControlSelect%20%3D%20TRDC_MBC_ACCESS_CONTROL_POLICY_ALL_INDEX%3B%0A%20%20%20%20%20%20%20%20mbcBlockConfig.nseEnable%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20true%3B%20%2F*%20non%20secure%20state%20can%20access%20the%20block%20for%20cortex-A35%20*%2F%0A%20%20%20%20%20%20%20%20mbcBlockConfig.mbcIdx%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%202U%3B%20%20%20%2F*%20MBC2%20*%2F%0A%20%20%20%20%20%20%20%20mbcBlockConfig.domainIdx%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%207U%3B%20%20%20%2F*%20MBC2_DOM7%20*%2F%0A%20%20%20%20%20%20%20%20mbcBlockConfig.slaveMemoryIdx%20%20%20%20%20%20%20%20%20%20%20%20%3D%200U%3B%20%20%20%2F*%20MBC2_DOM7_MEM0%20*%2F%0A%20%20%20%20%20%20%20%20mbcBlockConfig.memoryBlockIdx%20%20%20%20%20%20%20%20%20%20%20%20%3D%2056U%3B%20%20%2F*%20MBC2_DOM7_MEM0_BLK_CFG_W56%20*%2F%0A%20%20%20%20%20%20%20%20TRDC_MbcSetMemoryBlockConfig(TRDC%2C%20%26amp%3BmbcBlockConfig)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CBR%20%2F%3E%0A%3CP%3EFor%20example%2C%20It%20can%20be%20added%20at%20line%20401.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jimmychan_0-1721798486942.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jimmychan_0-1721798486942.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F290039i414A062E460E128C%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22jimmychan_0-1721798486942.png%22%20alt%3D%22jimmychan_0-1721798486942.png%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3Ejimmychan_0-1721798486942.png%3C%2Fspan%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1913485%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20use%20BBNSM%20RTC%20from%20U-Boot%20on%20i.MX%208ULP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1913485%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3C%2FP%3E%3CP%3EThank%20you%20for%20reply!%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EThe%20BSP%20versions%20are%20as%20follows%3A%3C%2FP%3E%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3Eimx-optee-os%3A%20lf-6.1.22-2.0.0%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3Eimx-atf%3A%20lf-6.1.22-2.0.0%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3Euboot-imx%3A%20lf-6.1.22-2.0.0%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3Elinux-imx%3A%20lf-5.10.72-2.2.3%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%3CP%3EBest%20regards%2C%3CBR%20%2F%3Emizo%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1912831%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20use%20BBNSM%20RTC%20from%20U-Boot%20on%20i.MX%208ULP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1912831%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ECould%20you%20tell%20me%20which%20version%20of%20BSP%20are%20you%20using%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E