README.rst
1.. zephyr:code-sample:: mimxrt595_evk_system_off
2 :name: RT595 System Off
3 :relevant-api: sys_poweroff
4
5 Use soft-off on MIMXRT595-EVK.
6
7Overview
8********
9
10This sample can be used for basic power measurement and as an example of
11soft off on NXP i.MX RT platforms. The functional behavior is:
12
13* Busy-wait for 2 seconds
14* Turn the system off after enabling wakeup through RTC and set alarm
15 10 seconds in the future to wake up the processor
16
17Requirements
18************
19
20This application uses MIMXRT595-EVK for the demo.
21
22Building, Flashing and Running
23******************************
24
25.. zephyr-app-commands::
26 :zephyr-app: samples/boards/nxp/mimxrt595_evk/system_off
27 :board: mimxrt595_evk/mimxrt595s/cm33
28 :goals: build flash
29 :compact:
30
31Running:
32
331. Open UART terminal.
342. Power Cycle Device.
353. Device will turn on and idle for 2 seconds
364. Device will turn itself off using deep power down mode. RTC alarm
37 will wake device and restart the application from a warm reset.
38
39Sample Output
40=================
41MIMXRT595-EVK core output
42--------------------------
43
44.. code-block:: console
45
46 *** Booting Zephyr OS build zephyr-v3.2.0-1045-g07228f716c78 ***
47
48 Wake-up alarm set for 10 seconds
49 Powering off
50
51OTP Fuse setting to wake from Deep Power Down and reset flash
52#############################################################
53
54Background
55**********
56
57This sample will not resume the application after waking from Deep Power
58Down (DPD) mode on an EVK with default settings. The reason is that the
59flash is not normally reset when waking from DPD. This sample
60eXecutes-In-Place (XIP) from the external flash. When the MCU wakes from
61DPD, it wakes through the reset flow. But if the external flash is not
62reset, the MCU and flash are no longer in sync, and the MCU cannot XIP.
63In this default state, one can confirm the RTC is waking the MCU from
64DPD because the MCU will set the PMIC_MODE pins to 0b00 requesting the
65PMIC to enter the default boot mode, and the PMIC will enable the
66regulator driving the VDDCORE rail at 1.0V. However, the MCU will not be
67able to XIP from the flash to resume. One can press the Reset button in
68this state to restart the app.
69
70To wake from DPD and resume XIP from the flash, the MCU needs to be
71configured to reset the external flash. This can be done by programming
72the One-Time-Programmable (OTP) fuses in the MCU. The steps below detail
73how program the OTP BOOT_CFG1 fuses to use GPIO pin PIO4_5 as the flash
74reset. This fuse setting instructs the ROM bootloader to toggle PIO4_5
75when resetting the flash. Note that the MIMXRT595-EVK board is designed
76to have PIO4_5 drive the octal flash reset pin on FlexSPI0. Other boards
77using this MCU may use a different GPIO pin, and the setting in the OTP
78fuses must match the GPIO pin connected to reset. Before programming
79fuses, it is best to write the OTP shadow registers first and confirm
80the operation. Then program the OTP fuses after confirming the correct
81settings. For more details on OTP fuses and shadow registers, refer to
82the Reference Manual for this MCU, and the OTP Fuse Map spreadsheet
83included as an attachment in the Reference Manual PDF.
84
85Tools needed
86************
87These steps use the blhost tool that runs on a host computer running
88Linux, Windows, or MacOS. Download blhost, find the appropriate blhost
89executable for your host OS, and use the command-line steps below to
90program the OTP fuses. To download, go to https://www.nxp.com/mcuboot,
91and find the Blhost package under Downloads.
92
93Steps to program OTP fuses on MIMXRT595-EVK
94*******************************************
95These steps detail using USB as the interface between blhost and the
96ROM bootloader. UART is another option, for more details see the
97blhost documentation and the Boot ROM chapter in the MCU Reference
98Manual.
99
100 1. Power the EVK and connect USB J38 to host computer. J38 is for the
101 USB peripheral of the MCU, and will also power the EVK.
102
103 2. Set the DIP switches of SW7 to On-Off-On (123) to boot in ISP USB
104 HID mode.
105
106 3. Press the Reset button SW3 to boot in ISP mode. The EVK should
107 enumerate as a USB HID device in the host computer.
108
109 4. This command confirms the current settings of BOOT_CFG1 fuses:
110 blhost -u 0x1fc9,0x0023 -- efuse-read-once 0x61
111
112 5. This command programs BOOT_CFG1 to enable the flash reset pin using
113 PIO4_5:
114 blhost -u 0x1fc9,0x0023 -- efuse-program-once 0x61 0x164000
115
116 6. This command confirms the programmed fuses in BOOT_CFG1:
117 blhost -u 0x1fc9,0x0023 -- efuse-read-once 0x61
118
119 7. Set the DIP switches of SW7 to Off-Off-On (123) to boot from the
120 external flash on FlexSPI0.
121
122 8. Press the Reset button SW3 to boot from flash and run the app.
123
124Expected results from blhost
125****************************
126
127>blhost -u 0x1fc9,0x0023 -- efuse-read-once 0x61
128Inject command 'efuse-read-once'
129Response status = 0 (0x0) Success.
130Response word 1 = 4 (0x4)
131Response word 2 = 0 (0x0)
132
133>blhost -u 0x1fc9,0x0023 -- efuse-program-once 0x61 0x164000
134Inject command 'efuse-program-once'
135Successful generic response to command 'efuse-program-once'
136Response status = 0 (0x0) Success.
137
138>blhost -u 0x1fc9,0x0023 -- efuse-read-once 0x61
139Inject command 'efuse-read-once'
140Response status = 0 (0x0) Success.
141Response word 1 = 4 (0x4)
142Response word 2 = 1458176 (0x164000)
143