@@ -1727,7 +1727,7 @@ int xtensa_do_step(struct target *target, int current, target_addr_t address, in
17271727 xtensa_reg_val_t dbreakc [XT_WATCHPOINTS_NUM_MAX ];
17281728 xtensa_reg_val_t icountlvl , cause ;
17291729 xtensa_reg_val_t oldps , oldpc , cur_pc ;
1730- bool ps_lowered = false;
1730+ bool ps_modified = false;
17311731
17321732 LOG_TARGET_DEBUG (target , "current=%d, address=" TARGET_ADDR_FMT ", handle_breakpoints=%i" ,
17331733 current , address , handle_breakpoints );
@@ -1783,14 +1783,23 @@ int xtensa_do_step(struct target *target, int current, target_addr_t address, in
17831783 * RFI >= DBGLEVEL.
17841784 */
17851785 if (xtensa -> stepping_isr_mode == XT_STEPPING_ISR_OFF ) {
1786- if (!xtensa -> core_config -> high_irq .enabled ) {
1787- LOG_TARGET_WARNING (
1788- target ,
1789- "disabling IRQs while stepping is not implemented w/o high prio IRQs option!" );
1790- return ERROR_FAIL ;
1786+ if (xtensa -> core_config -> core_type == XT_LX ) {
1787+ if (!xtensa -> core_config -> high_irq .enabled ) {
1788+ LOG_TARGET_WARNING (target ,
1789+ "disabling IRQs while stepping is not implemented w/o high prio IRQs option!" );
1790+ return ERROR_FAIL ;
1791+ }
1792+ /* Update ICOUNTLEVEL accordingly */
1793+ icountlvl = MIN ((oldps & 0xF ) + 1 , xtensa -> core_config -> debug .irq_level );
1794+ } else {
1795+ /* Xtensa NX does not have the ICOUNTLEVEL feature present in Xtensa LX
1796+ * and instead disable interrupts while stepping. This could change
1797+ * the timing of the system while under debug */
1798+ xtensa_reg_val_t newps = oldps | XT_PS_DI_MSK ;
1799+ xtensa_reg_set (target , XT_REG_IDX_PS , newps );
1800+ icountlvl = xtensa -> core_config -> debug .irq_level ;
1801+ ps_modified = true;
17911802 }
1792- /* Update ICOUNTLEVEL accordingly */
1793- icountlvl = MIN ((oldps & 0xF ) + 1 , xtensa -> core_config -> debug .irq_level );
17941803 } else {
17951804 icountlvl = xtensa -> core_config -> debug .irq_level ;
17961805 }
@@ -1815,7 +1824,7 @@ int xtensa_do_step(struct target *target, int current, target_addr_t address, in
18151824 xtensa_cause_clear (target ); /* so we don't recurse into the same routine */
18161825 if (xtensa -> core_config -> core_type == XT_LX && ((oldps & 0xf ) >= icountlvl )) {
18171826 /* Lower interrupt level to allow stepping, but flag eps[dbglvl] to be restored */
1818- ps_lowered = true;
1827+ ps_modified = true;
18191828 uint32_t newps = (oldps & ~0xf ) | (icountlvl - 1 );
18201829 xtensa_reg_set (target , xtensa -> eps_dbglevel_idx , newps );
18211830 LOG_TARGET_DEBUG (target ,
@@ -1916,11 +1925,12 @@ int xtensa_do_step(struct target *target, int current, target_addr_t address, in
19161925 }
19171926
19181927 /* Restore int level */
1919- if (ps_lowered ) {
1928+ if (ps_modified ) {
19201929 LOG_DEBUG ("Restoring %s after stepping: 0x%08" PRIx32 ,
1921- xtensa -> core_cache -> reg_list [xtensa -> eps_dbglevel_idx ].name ,
1922- oldps );
1923- xtensa_reg_set (target , xtensa -> eps_dbglevel_idx , oldps );
1930+ xtensa -> core_cache -> reg_list [(xtensa -> core_config -> core_type == XT_LX ) ?
1931+ xtensa -> eps_dbglevel_idx : XT_REG_IDX_PS ].name , oldps );
1932+ xtensa_reg_set (target , (xtensa -> core_config -> core_type == XT_LX ) ?
1933+ xtensa -> eps_dbglevel_idx : XT_REG_IDX_PS , oldps );
19241934 }
19251935
19261936 /* write ICOUNTLEVEL back to zero */
@@ -4191,11 +4201,6 @@ COMMAND_HELPER(xtensa_cmd_mask_interrupts_do, struct xtensa *xtensa)
41914201 return ERROR_OK ;
41924202 }
41934203
4194- if (xtensa -> core_config -> core_type == XT_NX ) {
4195- command_print (CMD , "ERROR: ISR step mode only supported on Xtensa LX" );
4196- return ERROR_FAIL ;
4197- }
4198-
41994204 /* Masking is ON -> interrupts during stepping are OFF, and vice versa */
42004205 if (!strcasecmp (CMD_ARGV [0 ], "off" ))
42014206 state = XT_STEPPING_ISR_ON ;
0 commit comments