Skip to content

Flashing LPC5536 #1776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
VasiliuVlad opened this issue May 8, 2025 · 1 comment
Open

Flashing LPC5536 #1776

VasiliuVlad opened this issue May 8, 2025 · 1 comment

Comments

@VasiliuVlad
Copy link

Controller: NXP LPC 5536
Debugger (NXP DAP debugger probe)

Problem Description :
There are actually 2 problems : )

Problem 1 : LPC5536 can be flash only using the target LPC55s36 (same family) using --target lpc5536 simply does not work.
(I can sent a trace, but I know that this target never worked properly to begin with. I have always used lpc55s36 which always worked fine.... until now :-) )

Problem 2 : If the controller is completely new (never flashed) , then the flashing fails(even with -- target lpc55s36) .

03355 D Analyze time: 0.000130 [builder]
0003355 D Using double buffer sector erase program [builder]
[                                                  ]   0%0003355 D halting core 0 [cortex_m]
0003364 D reset, core 0, type=SW_SYSTEM [cortex_m]
0005474 W Core #0 is not accessible after reset [cortex_m]
0005476 D uninit session <pyocd.core.session.Session object at 0x7fc951770b90> [session]
0005476 D uninit board <pyocd.board.board.Board object at 0x7fc9507e66f0> [board]
0005478 E Error during board uninit: [session]

I have noticed that SW_SYSRESET reset fails and I was able to track it until CortexM_LPC5500 > There is a "default reset type". I have set this to SW_CORE or SW EMULATED instead of SW_SYSRESETREQ and it will be able to flash 1 time correctly. Then I must switch back to SW_SYSRESETREQ and the flashing will work as intended.

0000952 D Analyze time: 0.000073 [builder]
0000952 D Using double buffer sector erase program [builder]
[                                                  ]   0%0000952 D halting core 0 [cortex_m]
0000961 D reset, core 0, type=SW_EMULATED [cortex_m]
0000961 D halting core 0 [cortex_m]
0000994 D resuming core 0 [cortex_m]
0000994 D added=[] removed=[] [manager]
0000994 D bps after flush={} [manager]
0000996 D reset: core was halted after non-halting reset; now resuming [cortex_m]
0000996 D resuming core 0 [cortex_m]
0000996 D added=[] removed=[] [manager]
0000996 D bps after flush={} [manager]
0001017 D resuming core 0 [cortex_m]
0001017 D added=[] removed=[] [manager]
0001017 D bps after flush={} [manager]
0001024 D resuming core 0 [cortex_m]
0001024 D added=[] removed=[] [manager]
0001024 D bps after flush={} [manager]
[                                                  ]   0%0001033 D resuming core 0 [cortex_m]
0001034 D added=[] removed=[] [manager]
0001034 D bps after flush={} [manager]
[                                                  ]   0%0001043 D resuming core 0 [cortex_m]
0001043 D added=[] removed=[] [manager]
0001043 D bps after flush={} [manager]
[                                                  ]   1%0001053 D resuming core 0 [cortex_m]

the second time flashing with the SW_CORE / SW_EMULATED

Using double buffer sector erase program [builder]
[                                                  ]   0%0000998 D halting core 0 [cortex_m]
0001007 D reset, core 0, type=SW_EMULATED [cortex_m]
0001007 D halting core 0 [cortex_m]
0001041 D resuming core 0 [cortex_m]
0001041 D added=[] removed=[] [manager]
0001041 D bps after flush={} [manager]
0001043 D reset: core was halted after non-halting reset; now resuming [cortex_m]
0001044 D resuming core 0 [cortex_m]
0001044 D added=[] removed=[] [manager]
0001044 D bps after flush={} [manager]
0001065 D resuming core 0 [cortex_m]
0001065 D added=[] removed=[] [manager]
0001065 D bps after flush={} [manager]
0006067 D halting core 0 [cortex_m]
0006070 D flash operation timed out; IPSR=3 [flash]
0006070 D uninit session <pyocd.core.session.Session object at 0x7027175ba3c0> [session]
0006070 D uninit board <pyocd.board.board.Board object at 0x7027168286b0> [board]
0006071 D resuming core 0 [cortex_m]
0006071 D added=[] removed=[] [manager]
0006071 D bps after flush={} [manager]
0006075 D closing interface [pyusb_backend]
0006076 C flash init timed out [__main__]

now the other reset type will work

0000801 D Analyze time: 0.000130 [builder]
0000801 D Using double buffer sector erase program [builder]
[                                                  ]   0%0000801 D halting core 0 [cortex_m]
0000902 D reset, core 0, type=SW_SYSTEM [cortex_m]
0001044 D reset: core was halted after non-halting reset; now resuming [cortex_m]
0001045 D resuming core 0 [cortex_m]
0001045 D added=[] removed=[] [manager]
0001045 D bps after flush={} [manager]
0001070 D resuming core 0 [cortex_m]
0001070 D added=[] removed=[] [manager]
0001070 D bps after flush={} [manager]
0001079 D resuming core 0 [cortex_m]
0001079 D added=[] removed=[] [manager]
0001079 D bps after flush={} [manager]
[                                                  ]   0%0001089 D resuming core 0 [cortex_m]
0001090 D added=[] removed=[] [manager]
0001090 D bps after flush={} [manager]
[                                                  ]   0%0001100 D resuming core 0 [cortex_m]
0001101 D added=[] removed=[] [manager]
0001101 D bps after flush={} [manager]
[                                                  ]   1%0001111 D resuming core 0 [cortex_m]
0001111 D added=[] removed=[] [manager]


I suppose that if SW_SYSRESETREQ fails, a retry is necessary with SW_CORE in order to work ... but I don't know how to modify the code in order to obtain this behavior.

@VasiliuVlad
Copy link
Author

After a little more digging, the only thing that seems to work is (target_lpc5500.py line 362 )

    def reset(self, reset_type):
        # unlock debug access after reset
        try : 
            super(CortexM_LPC5500, self).reset(reset_type)
        except:
            super(CortexM_LPC5500, self).reset(self.ResetType.HW) 

(Which, for me, looks like a "bring a bigger hammer" solution).
With this, I can flash also the completely new controllers and old ones.

I know that it is hard to get completely new controllers. I still like 80 left, which I will flash tomorrow. If somebody wants me to try something else, then I am happy to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant