PWM with Zephyr on RT1020

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

PWM with Zephyr on RT1020

173 次查看
Deepa-khatri2588
Contributor I

I am working on a custom board based on the MIMXRT1021xxxxx (using the NXP MCUXpresso SDK under Zephyr RTOS). I am migrating a high-performance motor tension reel application from a standard FreeRTOS SDK implementation over to Zephyr, and I am hitting a critical blocker regarding the FlexPWM2 (Submodule 3, Channel A) peripheral clock behavior.

The Problem:

I am trying to command the torque dynamically

  • In FreeRTOS, the application works perfectly: the module maintains a constant frequency/tension holding loop without dropping out.

  • In Zephyr, the moment all operating system threads fall into an idle or sleep state (causing the ARM Cortex-M7 core to execute a Wait-for-Interrupt WFI instruction), the entire register space for FlexPWM2 Submodule 3 drops to 0 or freezes. The moment an event occurs or a thread wakes up, the registers temporarily recover, but the power/clock-saving "pauses" are completely breaking our motor control loop, resulting in a loss of torque and erratic brake behavior.

I have disabled the high-level OS Power Manager (CONFIG_PM=n), meaning the operating system isn't dynamically shutting down peripheral rails. It appears that the master clock source or the IPG peripheral clock tree feeding FlexPWM2 is automatically scaling down or clock-gating when the CPU idles.

  1. What is the definitive, ideal initialization sequence to ensure a FlexPWM sub-module's clock source remains strictly pinned ON across all Run, Wait, and Doze states?

  2. How can we cleanly change the duty cycle dynamically at runtime without causing glitch pulses or desynchronizing the shadow register buffer transfers (LDOK / MCTRL)?

  3. Is it possible to completely decouple the FlexPWM clock gating from the CPU core's sleep states on the RT1020, or do we have to resort to a hardware workaround like FlexIO?

Current Configuration Details:

1. prj.conf (Power Management disabled, Clocks forced open)

I
# Disable standard power management to keep peripheral clocks wide open
CONFIG_PM=n
CONFIG_PM_DEVICE=n
CONFIG_CLOCK_CONTROL=y

# Standard PWM Driver activation
CONFIG_PWM=y

2. app.overlay (Devicetree Mapping with low-power overrides)


 
&iomuxc {
    pinmux_motor_pwm: pinmux_motor_pwm {
        group0 {
            /* Routes Pad 6 (GPIO_AD_B0_06) to FlexPWM2 Module 3 Channel A */
            pinmux = <&iomuxc_gpio_ad_b0_06_flexpwm2_pwma3>;
            drive-strength = "r0-6";
            slew-rate = "fast";
            bias-pull-up;
            nxp,speed = "150-mhz";
        };
    };
};

&flexpwm2_pwm3 {
    status = "okay";
    pinctrl-0 = <&pinmux_motor_pwm>;
    pinctrl-names = "default";
    clocks = <&ccm IMX_CCM_PWM_CLK 0 0>;
    
    /* Intended to force the counter to stay alive when CPU idles */
    run-in-wait;
    nxp,prescaler = <1>; 
};

3. Current Runtime Configuration (Using standard Zephyr API)

C
 
/* Initializing to safe zero-torque baseline on boot */
pwm_set_cycles(pwm_dev, 1, 12499, 12499, PWM_POLARITY_INVERTED);

/* Dynamic Runtime Torque Shift via Web Callback */
void set_motor_torque(int8_t level) {
    uint32_t pulse = (level > 0) ? 5500 : 12499;
    
    // This call works when threads are hot, but fails during OS idle pauses
    pwm_set_cycles(pwm_dev, 1, 12499, pulse, PWM_POLARITY_INVERTED);
}

I have even attempted bare-metal register overrides targeting CCM_CCGR4 (setting bits 24-25 to 0x3 to force the clock gate open continuously) and manually strobing MCTRL |= (1 << 3) for an immediate shadow latch, but reading the registers via volatile pointers still returns 0 whenever the kernel goes quiet.

Any insights on how to force the FlexPWM clock tree to remain active independently of the core state would be greatly appreciated!

Thank you.

标记 (1)
0 项奖励
回复
1 回复

148 次查看
Gavin_Jia
NXP TechSupport
NXP TechSupport

Hi @Deepa-khatri2588 ,

Thanks for your interest in NXP MIMXRT series!

The first thing I would correct is the PWM channel index. Your pinmux routes GPIO_AD_B0_06 to FLEXPWM2_PWMA3, which is channel A of submodule 3. In Zephyr’s pwm_mcux.c, channel 0 maps to kPWM_PwmA and channel 1 maps to kPWM_PwmB. Therefore your calls should use channel 0, not channel 1.

Zephyr’s nxp,imx-pwm binding supports run-in-wait and run-in-debug, and the MCUX PWM driver maps these properties to pwm_config.enableWait and pwm_config.enableDebugMode. Please keep these properties in the flexpwm2_pwm3 node.
For runtime torque updates, keep the period and polarity unchanged and only update the pulse width. This allows the Zephyr MCUX driver to use PWM_UpdatePwmDutycycle() followed by PWM_SetPwmLdok(), instead of stopping and reconfiguring the submodule.

If the PWM still stops only when the kernel becomes idle, this indicates the issue is related to WFI/WAIT-mode clock handling. CONFIG_PM=n disables Zephyr PM policy/device PM, but does not necessarily prevent the CPU idle path from executing WFI. As a diagnostic test, keep the CPU out of idle with a temporary high-priority busy thread. If the PWM then becomes stable, we should focus on the SoC WAIT-mode clock/CCM/GPC configuration or apply the i.MX RT low-power workaround path.

Best regards,
Gavin

0 项奖励
回复
%3CLINGO-SUB%20id%3D%22lingo-sub-2372583%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E4%BD%BF%E7%94%A8%20Zephyr%20%E5%AF%B9%20RT1020%20%E8%BF%9B%E8%A1%8C%20PWM%20%E8%B0%83%E8%8A%82%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2372583%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E6%88%91%E6%AD%A3%E5%9C%A8%E5%BC%80%E5%8F%91%E4%B8%80%E6%AC%BE%E5%9F%BA%E4%BA%8E%20%3CSTRONG%3Emimxrt1021xxxxx%20%E7%9A%84%E5%AE%9A%E5%88%B6%E4%B8%BB%E6%9D%BF%EF%BC%88%E4%BD%BF%E7%94%A8%20Zephyr%20RTOS%20%E4%B8%8B%E7%9A%84%E6%81%A9%E6%99%BA%E6%B5%A6%20MCUX%3C%2FSTRONG%3E%20presso%20SDK%EF%BC%89%E3%80%82%E6%88%91%E6%AD%A3%E5%9C%A8%E5%B0%86%E4%B8%80%E4%B8%AA%E9%AB%98%E6%80%A7%E8%83%BD%E7%94%B5%E6%9C%BA%E5%BC%A0%E5%8A%9B%E5%8D%B7%E7%9B%98%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E4%BB%8E%E6%A0%87%E5%87%86%E7%9A%84%20FreeRTOS%20SDK%20%E5%AE%9E%E7%8E%B0%E7%A7%BB%E6%A4%8D%E5%88%B0%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%BA%8F%EF%BC%9F%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%E6%88%91%E4%BB%AC%E6%80%8E%E6%A0%B7%E6%89%8D%E8%83%BD%E5%9C%A8%E8%BF%90%E8%A1%8C%E6%97%B6%E5%B9%B2%E5%87%80%E5%88%A9%E8%90%BD%E5%9C%B0%E5%8A%A8%E6%80%81%E6%9B%B4%E6%94%B9%E5%8D%A0%E7%A9%BA%E6%AF%94%EF%BC%8C%E8%80%8C%E4%B8%8D%E4%BC%9A%E9%80%A0%E6%88%90%E5%B9%B2%E6%89%B0%E8%84%89%E5%86%B2%E6%88%96%E4%B8%8D%E5%90%8C%E6%AD%A5%E5%BD%B1%E5%AF%84%E5%AD%98%E5%99%A8%E7%BC%93%E5%86%B2%E5%8C%BA%E4%BC%A0%E8%BE%93%20(LDOK%2FMCTRL)%EF%BC%9F%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%E6%98%AF%E5%90%A6%E6%9C%89%E5%8F%AF%E8%83%BD%E5%9C%A8%20RT1020%20%E4%B8%8A%E5%B0%86%20FlexPWM%20%E6%97%B6%E9%92%9F%E9%97%A8%E6%8E%A7%E4%B8%8E%20CPU%20%E5%86%85%E6%A0%B8%E7%9A%84%E4%BC%91%E7%9C%A0%E7%8A%B6%E6%80%81%E5%AE%8C%E5%85%A8%E8%A7%A3%E8%80%A6%EF%BC%8C%E8%BF%98%E6%98%AF%E5%BF%85%E9%A1%BB%E9%87%87%E7%94%A8%20FlexIO%20%E7%AD%89%E7%A1%AC%E4%BB%B6%E5%8F%98%E9%80%9A%E6%96%B9%E6%B3%95%EF%BC%9F%3C%2FP%3E%3C%2FLI%3E%3C%2FOL%3E%3CH3%20id%3D%22toc-hId-225386358%22%20id%3D%22toc-hId-225419898%22%3E%E5%BD%93%E5%89%8D%E9%85%8D%E7%BD%AE%E8%AF%A6%E6%83%85%EF%BC%9A%3C%2FH3%3E%3CH4%20id%3D%22toc-hId-915947832%22%20id%3D%22toc-hId-915981372%22%3E1.%20prj.conf%EF%BC%88%E7%A6%81%E7%94%A8%E7%94%B5%E6%BA%90%E7%AE%A1%E7%90%86%E5%8D%95%E5%85%83%EF%BC%8C%E6%97%B6%E9%92%9F%E5%BC%BA%E5%88%B6%E6%89%93%E5%BC%80%EF%BC%89%3C%2FH4%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EI%3C%2FSPAN%3E%3C%2FDIV%3E%3CPRE%20translate%3D%22no%22%3E%3CSPAN%20class%3D%22%22%3E%23%20Disable%20standard%20power%20management%20to%20keep%20peripheral%20clocks%20wide%20open%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22%22%3ECONFIG_PM%3C%2FSPAN%3E%3Dn%0A%3CSPAN%20class%3D%22%22%3ECONFIG_PM_DEVICE%3C%2FSPAN%3E%3Dn%0A%3CSPAN%20class%3D%22%22%3ECONFIG_CLOCK_CONTROL%3C%2FSPAN%3E%3Dy%0A%0A%3CSPAN%20class%3D%22%22%3E%23%20Standard%20PWM%20Driver%20activation%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22%22%3ECONFIG_PWM%3C%2FSPAN%3E%3Dy%3C%2FPRE%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CH4%20id%3D%22toc-hId--891506631%22%20id%3D%22toc-hId--891473091%22%3E2.%20app.overlay%EF%BC%88%E5%85%B7%E6%9C%89%E4%BD%8E%E5%8A%9F%E8%80%97%E8%A6%86%E7%9B%96%E5%8A%9F%E8%83%BD%E7%9A%84%20Devicetree%20%E6%98%A0%E5%B0%84%EF%BC%89%3C%2FH4%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%3CBR%20%2F%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CPRE%20translate%3D%22no%22%3E%26amp%3Biomuxc%20%7B%0A%20%20%20%20pinmux_motor_pwm%3A%20pinmux_motor_pwm%20%7B%0A%20%20%20%20%20%20%20%20group0%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%2F*%20Routes%20Pad%206%20(GPIO_AD_B0_06)%20to%20FlexPWM2%20Module%203%20Channel%20A%20*%2F%0A%20%20%20%20%20%20%20%20%20%20%20%20pinmux%20%3D%20%26lt%3B%26amp%3Biomuxc_gpio_ad_b0_06_flexpwm2_pwma3%26gt%3B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20drive-strength%20%3D%20%22r0-6%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20slew-rate%20%3D%20%22fast%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20bias-pull-up%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20nxp%2Cspeed%20%3D%20%22150-mhz%22%3B%0A%20%20%20%20%20%20%20%20%7D%3B%0A%20%20%20%20%7D%3B%0A%7D%3B%0A%0A%26amp%3Bflexpwm2_pwm3%20%7B%0A%20%20%20%20status%20%3D%20%22okay%22%3B%0A%20%20%20%20pinctrl-0%20%3D%20%26lt%3B%26amp%3Bpinmux_motor_pwm%26gt%3B%3B%0A%20%20%20%20pinctrl-names%20%3D%20%22default%22%3B%0A%20%20%20%20clocks%20%3D%20%26lt%3B%26amp%3Bccm%20IMX_CCM_PWM_CLK%200%200%26gt%3B%3B%0A%20%20%20%20%0A%20%20%20%20%2F*%20Intended%20to%20force%20the%20counter%20to%20stay%20alive%20when%20CPU%20idles%20*%2F%0A%20%20%20%20run-in-wait%3B%0A%20%20%20%20nxp%2Cprescaler%20%3D%20%26lt%3B1%26gt%3B%3B%20%0A%7D%3B%3C%2FPRE%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CH4%20id%3D%22toc-hId-1596006202%22%20id%3D%22toc-hId-1596039742%22%3E3.%E5%BD%93%E5%89%8D%E8%BF%90%E8%A1%8C%E6%97%B6%E9%85%8D%E7%BD%AE%EF%BC%88%E4%BD%BF%E7%94%A8%E6%A0%87%E5%87%86%20Zephyr%20API%EF%BC%89%3C%2FH4%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%3CDIV%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EC%3C%2FSPAN%3E%3CDIV%20class%3D%22%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3CPRE%20translate%3D%22no%22%3E%3CSPAN%20class%3D%22%22%3E%2F*%20Initializing%20to%20safe%20zero-torque%20baseline%20on%20boot%20*%2F%3C%2FSPAN%3E%0Apwm_set_cycles(pwm_dev%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22%22%3E12499%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22%22%3E12499%3C%2FSPAN%3E%2C%20PWM_POLARITY_INVERTED)%3B%0A%0A%3CSPAN%20class%3D%22%22%3E%2F*%20Dynamic%20Runtime%20Torque%20Shift%20via%20Web%20Callback%20*%2F%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3Evoid%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22%22%3Eset_motor_torque%3C%2FSPAN%3E%3CSPAN%20class%3D%22%22%3E(%3CSPAN%20class%3D%22%22%3Eint8_t%3C%2FSPAN%3E%20level)%3C%2FSPAN%3E%20%3C%2FSPAN%3E%7B%0A%20%20%20%20%3CSPAN%20class%3D%22%22%3Euint32_t%3C%2FSPAN%3E%20pulse%20%3D%20(level%20%26gt%3B%20%3CSPAN%20class%3D%22%22%3E0%3C%2FSPAN%3E)%20%3F%20%3CSPAN%20class%3D%22%22%3E5500%3C%2FSPAN%3E%20%3A%20%3CSPAN%20class%3D%22%22%3E12499%3C%2FSPAN%3E%3B%0A%20%20%20%20%0A%20%20%20%20%3CSPAN%20class%3D%22%22%3E%2F%2F%20This%20call%20works%20when%20threads%20are%20hot%2C%20but%20fails%20during%20OS%20idle%20pauses%3C%2FSPAN%3E%0A%20%20%20%20pwm_set_cycles(pwm_dev%2C%20%3CSPAN%20class%3D%22%22%3E1%3C%2FSPAN%3E%2C%20%3CSPAN%20class%3D%22%22%3E12499%3C%2FSPAN%3E%2C%20pulse%2C%20PWM_POLARITY_INVERTED)%3B%0A%7D%3C%2FPRE%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3E%E6%88%91%E7%94%9A%E8%87%B3%E5%B0%9D%E8%AF%95%E8%BF%87%E9%92%88%E5%AF%B9%20CCM_CCGR4%20%E7%9A%84%E8%A3%B8%E6%9C%BA%E5%AF%84%E5%AD%98%E5%99%A8%E9%87%8D%E5%86%99%EF%BC%88%E5%B0%86%E7%AC%AC%2024-25%20%E4%BD%8D%E8%AE%BE%E7%BD%AE%E4%B8%BA%200x3%EF%BC%8C%E4%BB%A5%E5%BC%BA%E5%88%B6%E6%97%B6%E9%92%9F%E9%97%A8%E6%8C%81%E7%BB%AD%E6%89%93%E5%BC%80%EF%BC%89%EF%BC%8C%E4%BB%A5%E5%8F%8A%E6%89%8B%E5%8A%A8%E9%80%89%E9%80%9A%20MCTRL%20%7C%3D%20(1%26lt%3B%26lt%3B%203)%20%E4%BB%A5%E5%AE%9E%E7%8E%B0%E5%8D%B3%E6%97%B6%E9%98%B4%E5%BD%B1%E9%94%81%E5%AD%98%EF%BC%8C%E4%BD%86%E5%8F%AA%E8%A6%81%E5%86%85%E6%A0%B8%E4%B8%8D%E5%93%8D%EF%BC%8C%E9%80%9A%E8%BF%87%E6%98%93%E5%A4%B1%E6%80%A7%E6%8C%87%E9%92%88%E8%AF%BB%E5%8F%96%E5%AF%84%E5%AD%98%E5%99%A8%E7%9A%84%E7%BB%93%E6%9E%9C%E4%BB%8D%E7%84%B6%E6%98%AF%200%E3%80%82%3C%2FP%3E%3CP%3E%E5%A6%82%E6%9E%9C%E8%83%BD%E5%B0%B1%E5%A6%82%E4%BD%95%E5%BC%BA%E5%88%B6%20FlexPWM%20%E6%97%B6%E9%92%9F%E6%A0%91%E4%BF%9D%E6%8C%81%E6%B4%BB%E5%8A%A8%E7%8A%B6%E6%80%81%E8%80%8C%E4%B8%8D%E5%8F%97%E5%86%85%E6%A0%B8%E7%8A%B6%E6%80%81%E7%9A%84%E5%BD%B1%E5%93%8D%E6%8F%90%E5%87%BA%E4%BB%BB%E4%BD%95%E8%A7%81%E8%A7%A3%EF%BC%8C%E6%88%91%E4%BB%AC%E5%B0%86%E4%B8%8D%E8%83%9C%E6%84%9F%E6%BF%80%EF%BC%81%3C%2FP%3E%3CP%3E%E8%B0%A2%E8%B0%A2%EF%BC%81%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2372727%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PWM%20with%20Zephyr%20on%20RT1020%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2372727%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F261291%22%20target%3D%22_blank%22%3E%40Deepa-khatri2588%3C%2FA%3E%E3%80%81%3C%2FP%3E%0A%3CP%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E5%AF%B9%20NXP%20MIMXRT%20%E7%B3%BB%E5%88%97%E7%9A%84%E5%85%B3%E6%B3%A8%EF%BC%81%3C%2FP%3E%0A%3CP%3E%E6%88%91%E9%A6%96%E5%85%88%E8%A6%81%E7%BA%A0%E6%AD%A3%E7%9A%84%E6%98%AF%20PWM%20%E9%80%9A%E9%81%93%E7%B4%A2%E5%BC%95%E3%80%82%E5%BC%95%E8%84%9A%E5%A4%8D%E7%94%A8%E5%99%A8%E5%B0%86%20GPIO_AD_B0_06%20%E8%B7%AF%E7%94%B1%E5%88%B0%20FLEXPWM2_PWMA3%EF%BC%8C%E5%8D%B3%E5%AD%90%E6%A8%A1%E5%9D%97%203%20%E7%9A%84%E9%80%9A%E9%81%93%20A%E3%80%82%E5%9C%A8%20Zephyr%20%E7%9A%84%20pwm_mcux.c%20%E4%B8%AD%E9%80%9A%E9%81%93%200%20%E6%98%A0%E5%B0%84%E5%88%B0%20kPWM_PwmA%EF%BC%8C%E9%80%9A%E9%81%93%201%20%E6%98%A0%E5%B0%84%E5%88%B0%20kPWM_PwmB%E3%80%82%E5%9B%A0%E6%AD%A4%EF%BC%8C%E6%82%A8%E7%9A%84%E5%91%BC%E5%8F%AB%E5%BA%94%E4%BD%BF%E7%94%A8%E9%80%9A%E9%81%93%200%EF%BC%8C%E8%80%8C%E4%B8%8D%E6%98%AF%E9%80%9A%E9%81%93%201%E3%80%82%3C%2FP%3E%0A%3CP%3EZephyr%20%E7%9A%84%20nxp%2Cimx-pwm%20%E7%BB%91%E5%AE%9A%E6%94%AF%E6%8C%81%E8%BF%90%E8%A1%8C%E4%B8%AD%E7%AD%89%E5%BE%85%E5%92%8C%E8%BF%90%E8%A1%8C%E4%B8%AD%E8%B0%83%E8%AF%95%EF%BC%8CMCUX%20PWM%20%E9%A9%B1%E5%8A%A8%E7%A8%8B%E5%BA%8F%E5%B0%86%E8%BF%99%E4%BA%9B%E5%B1%9E%E6%80%A7%E6%98%A0%E5%B0%84%E5%88%B0%20pwm_config.enableWait%20%E5%92%8C%20pwm_config.enableDebugMode%E3%80%82%E8%AF%B7%E5%B0%86%E8%BF%99%E4%BA%9B%E5%B1%9E%E6%80%A7%E4%BF%9D%E7%95%99%E5%9C%A8%20flexpwm2_pwm3%20%E8%8A%82%E7%82%B9%E4%B8%AD%E3%80%82%3CBR%20%2F%3E%E5%AF%B9%E4%BA%8E%E8%BF%90%E8%A1%8C%E6%97%B6%E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