Flashing LPC802 with pyOcd

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flashing LPC802 with pyOcd

400 Views
JeanMichel
Contributor I

Hello,

I'm working with an LPC802, using MCUXpresso IDE and some external scripts relying on PyOcd v0.34.3. I'm connecting to the LPC802 with an MCU-link probe connected through the SWD pins.

The program I've developped works fine when I'm flashing it from MCUXpresso, but doesn't work when flashed with pyOcd. I tried writting the most basic program with pyOcd, but it still fails to work properly. My program : 

 
options={"frequency": 1000000, "target_override": "LPC802", "hide_programming_progress": False}

with ConnectHelper.session_with_chosen_probe(options=options) as session:
target = session.board.target
target.reset_and_halt()

loader = FlashLoader(session, chip_erase="chip")
loader.add_data(0x400, [0xAA,0xBB,0xCC,0xDD])
loader.commit()

I should just be able to write a single word  into flash.

After mass erase (pyocd erase --mass -t LPC802), running my script and using pyocd commander (pyocd commander -t LPC802 --connect=pre-reset) to check the value, i can see it's not written properly :

Connected to LPC802 [Halted]:
pyocd> read32 0x400
00000400: 50040a0a

After running my program a second time, the value is finally wirtten properly :

Connected to LPC802 [Halted]:
pyocd> read32 0x400
00000400: ddccbbaa

The intermediate value is not always the same. I'm facing the same issue with other LPC802. 

I tried different things, but now I'm clueless on how to keep investigating on this subject. I would really appreciate if you had any idea of what is going on here.

Thank you for your response.

0 Kudos
Reply
2 Replies

377 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @JeanMichel,

pyOCD is not a tool recommended or fully supported by NXP to be used on our MCUs. I highly recommend using MCUXpresso IDE instead.

That said, here's a thread that might be useful for your inquiry: How to flash a LPC1114 with pyocd or openocd using mcu-link probe? - NXP Community.

0 Kudos
Reply

355 Views
JeanMichel
Contributor I

Thank you for your response. I've already done all the setup part of making pyOcd and NXP probe/microcontrollers work together, as the scripts I'm using were working fine on other NXP microcontrollers (LPC55S06 and LPC824). I understand that NXP doesn't support pyOcd though, so I'll try to get support on the pyOcd community. 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2184986%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EFlashing%20LPC802%20with%20pyOcd%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2184986%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI'm%20working%20with%20an%20LPC802%2C%20using%20MCUXpresso%20IDE%20and%20some%20external%20scripts%20relying%20on%20PyOcd%20v0.34.3.%20I'm%20connecting%20to%20the%20LPC802%20with%20an%20MCU-link%20probe%20connected%20through%20the%20SWD%20pins.%3C%2FP%3E%3CP%3EThe%20program%20I've%20developped%20works%20fine%20when%20I'm%20flashing%20it%20from%20MCUXpresso%2C%20but%20doesn't%20work%20when%20flashed%20with%20pyOcd.%20I%20tried%20writting%20the%20most%20basic%20program%20with%20pyOcd%2C%20but%20it%20still%20fails%20to%20work%20properly.%20My%20program%20%3A%26nbsp%3B%3C%2FP%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CPRE%20class%3D%22lia-code-sample%20language-python%22%3E%3CCODE%3Eoptions%3D%7B%22frequency%22%3A%201000000%2C%20%22target_override%22%3A%20%22LPC802%22%2C%20%22hide_programming_progress%22%3A%20False%7D%0A%0Awith%20ConnectHelper.session_with_chosen_probe(options%3Doptions)%20as%20session%3A%0Atarget%20%3D%20session.board.target%0Atarget.reset_and_halt()%0A%0Aloader%20%3D%20FlashLoader(session%2C%20chip_erase%3D%22chip%22)%0Aloader.add_data(0x400%2C%20%5B0xAA%2C0xBB%2C0xCC%2C0xDD%5D)%0Aloader.commit()%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EI%20should%20just%20be%20able%20to%20write%20a%20single%20word%26nbsp%3B%20into%20flash.%3C%2FP%3E%3CP%3EAfter%20mass%20erase%20(pyocd%20erase%20--mass%20-t%20LPC802)%2C%20running%20my%20script%20and%20using%20pyocd%20commander%20(pyocd%20commander%20-t%20LPC802%20--connect%3Dpre-reset)%20to%20check%20the%20value%2C%20i%20can%20see%20it's%20not%20written%20properly%20%3A%3C%2FP%3E%3CP%3EConnected%20to%20LPC802%20%5BHalted%5D%3A%3CBR%20%2F%3Epyocd%26gt%3B%20read32%200x400%3CBR%20%2F%3E00000400%3A%2050040a0a%3C%2FP%3E%3CP%3EAfter%20running%20my%20program%20a%20second%20time%2C%20the%20value%20is%20finally%20wirtten%20properly%20%3A%3C%2FP%3E%3CP%3EConnected%20to%20LPC802%20%5BHalted%5D%3A%3CBR%20%2F%3Epyocd%26gt%3B%20read32%200x400%3CBR%20%2F%3E00000400%3A%20ddccbbaa%3C%2FP%3E%3CP%3EThe%20intermediate%20value%20is%20not%20always%20the%20same.%20I'm%20facing%20the%20same%20issue%20with%20other%20LPC802.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20different%20things%2C%20but%20now%20I'm%20clueless%20on%20how%20to%20keep%20investigating%20on%20this%20subject.%20I%20would%20really%20appreciate%20if%20you%20had%20any%20idea%20of%20what%20is%20going%20on%20here.%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20response.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2185491%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Flashing%20LPC802%20with%20pyOcd%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2185491%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20for%20your%20response.%20I've%20already%20done%20all%20the%20setup%20part%20of%20making%20pyOcd%20and%20NXP%20probe%2Fmicrocontrollers%20work%20together%2C%20as%20the%20scripts%20I'm%20using%20were%20working%20fine%20on%20other%20NXP%20microcontrollers%20(LPC55S06%20and%20LPC824).%26nbsp%3BI%20understand%20that%20NXP%20doesn't%20support%20pyOcd%20though%2C%20so%20I'll%20try%20to%20get%20support%20on%20the%20pyOcd%20community.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2185091%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Flashing%20LPC802%20with%20pyOcd%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2185091%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F255763%22%20target%3D%22_blank%22%3E%40JeanMichel%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EpyOCD%20is%20not%20a%20tool%20recommended%20or%20fully%20supported%20by%20NXP%20to%20be%20used%20on%20our%20MCUs.%20I%20highly%20recommend%20using%20MCUXpresso%20IDE%20instead.%3C%2FP%3E%0A%3CP%3EThat%20said%2C%20here's%20a%20thread%20that%20might%20be%20useful%20for%20your%20inquiry%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FLPC-Microcontrollers%2FHow-to-flash-a-LPC1114-with-pyocd-or-openocd-using-mcu-link%2Fm-p%2F1654022%22%20target%3D%22_blank%22%3EHow%20to%20flash%20a%20LPC1114%20with%20pyocd%20or%20openocd%20using%20mcu-link%20probe%3F%20-%20NXP%20Community%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E