Skip to content

Jumping to the other EC image halts the new image while a PWM runs: please backport Zephyr 55cdcdce86 (npcx PWM access check) #104

Open

Description

@mitar

On a Laptop 13 Pro with the AMD Ryzen AI 300 Series mainboard, EC lilac-4.0.2-fdbf549 (RO and RW), a jump to the other image (framework_tool --reboot-ec jump-rw or jump-ro) often does not arrive: the EC ends up in RO with the reset flags Soft and a saved panic. James3 reported the same on the Laptop 16 with 4.0.4: "Sysjump rw works...after a few tries", with the same kind of panic record (forum post, and).

Cause: pwm_npcx_init() in Zephyr's drivers/pwm/pwm_npcx.c starts with NPCX_REG_WORD_ACCESS_CHECK(inst->PRSC, 0xA55A), which writes a pattern to PRSC and asserts that it reads it back. PRSC cannot be written while PWMCTL.PWR is set (pwm_npcx_set_cycles() clears PWR before it writes PRSC for the same reason). After a reset every PWM is off, but after a jump the PWMs keep running as the previous image left them. So whenever the fan spins or the side battery LED is lit in any color at the jump, the check fails for that PWM in the new image's PRE_KERNEL initialization, the assertion calls k_panic(), and the EC restarts in RO.

Nuvoton fixed this upstream in zephyrproject-rtos/zephyr#96203, commit 55cdcdce868f7c2d383d0f0264866be29b7b0496 "drivers: pwm: npcx: fix word register access check placement", which moves the check after the driver clears PWR. FrameworkComputer/zephyr has it in cros-main, but not in fwk-main, fwk-lilac-27116, fwk-sakura-20260429 or fwk-sunflower-dahlia-2026-09-30 (checked on 2026-11-22). The lilac 4.0.2 release builds from 8bdbcbbbe6, and the commit applies to it without changes.

Evidence: every saved panic record from these jumps names a PWM device in the callee-saved registers, which match pwm_npcx_init() (r5 the device, r6 its config, r8 its data, mapped with the image's own zephyr.ro.elf or zephyr.rw.elf):

Jump Running at the jump PWM in the record
into RW (my build of 4.0.2 with other fixes), charging, 3 times side LED lit PWM3 (red LED)
into Framework's RO (jump-ro), on AC side LED lit PWM2 (blue LED)
into Framework's RO (jump-ro), charging, 2 times side LED lit PWM3
into RW (my build), on battery fan running PWM0 (fan)
into Framework's RO (jump-ro), on battery fan running PWM0 (fan)

The last record, from Framework's own RO (fdbf549, where r1/r12 are z_arm_fault+0x104):

r0 :00000000 r1 :1009b5e5 r2 :000ac264 r3 :00000000
r4 :100a690c r5 :100a690c r6 :100a9bdc r7 :200cb5d0
r8 :200c549c r9 :00000000 r10:200c18fc r11:00000000
r12:1009b5e5 sp :200c7ad0 lr :000ac264 pc :00000000

r5 is __device_dts_ord_258 (the fan's pwm0), r6 is pwm_npcx_cfg_0 and r8 is pwm_npcx_data_0. The exception frame itself is not meaningful (pc 0): an instrumented build which also saves the fault registers recorded HFSR = FORCED with CFSR = 0 and the current thread _thread_dummy, as expected for k_panic() from PRE_KERNEL initialization, where the SVC escalates to a HardFault.

The same jumps succeed when nothing runs: with the battery LED switched off through EC_CMD_LED_CONTROL (manual, all colors 0), a jump while charging arrived in RW; with the fan at duty 0 (framework_tool --fansetduty 0), the keyboard backlight off and the side LED dark, a jump on battery arrived as well.

With the fix: my build applies 55cdcdce86 to Framework's Zephyr (commit). Eight jumps into its RW with AC attached at the jump, one of them while charging, arrived without a panic, as did several on battery.

Workaround until then: before a jump, framework_tool --fansetduty 0, framework_tool --kblight 0, and the battery LED off (on battery, or framework_tool --host-command 0x29 1 0 0 0 0 0 0 0 0).

A jump after such a crash restart can also leave the USB-C ports unable to detect chargers, see #105.

Activity

  1. JohnAZoidberg commented on Nov 24, 2026

    @JohnAZoidberg
    Member

    Wow you're right, this works!

    I was looking into the same issue recently and worked around it a different way, by turning PWM off before jump and back on after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions