Not able to program or erase MCXN236 custom board using MCU-Link

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

Not able to program or erase MCXN236 custom board using MCU-Link

957 Views
sstcor
Contributor II

I'm encountering an issue when trying to program or erase the MCXN236 using MCU-Link. Below is the log output:

Nc: Using SOFT reset to run the flash driver
Nc: Flash variant 'MCXNxxx (1024KB) (Secure)' detected (1MB = 128*8K at 0x10000000)
Nc: Closing flash driver MCXNxxx_S.cfx
Pc: ( 65) Chip Setup Complete
Pc: ( 70) License Check Complete
Nt: Loading 'GUI.bin' Binary 0x00000000 len 0x11068
Nc: Opening flash driver MCXNxxx.cfx
Nc: VECTRESET requested, but not supported on ARMv8-M CPUs. Using SOFTRESET instead.
Nc: Using SOFT reset to run the flash driver
Nc: Flash variant 'MCXNxxx (1024KB)' detected (1MB = 128*8K at 0x0)
Pb: 1 of 1 ( 0) Writing sectors 0-8 at 0x00000000 with 69736 bytes
Ps: ( 0) at 00000000: 0 bytes - 0/69736
Wc: failed read ChecksumSectors message readyness - rc Em(12). Target rejected debug access at location 0x040048D0

Wc: failed to send op EraseSector message - rc Em(12). Target rejected debug access at location 0x040048B8

Nc: Closing flash driver MCXNxxx.cfx
Nc: state - running or following reset request - re-read of state failed - rc Nn(05). Wire ACK Fault in DAP access
Wc: failed to send op Terminate message - rc Em(12). Target rejected debug access at location 0x040048B8

Pb: (100) Writing Flash ended with an error.
Ed:05: File 'GUI.bin' load failure: Em(12). Target rejected debug access at location 0x040048B8
Pc: (100) Target Operation Failed
Nc: error closing down debug session - Nn(05). Wire ACK Fault in DAP access


The ISP bootloader appears to be working. I can send commands to the memory using it but the code does not run after flashing.

Labels (1)
0 Kudos
Reply
9 Replies

937 Views
AshutoshNama
Contributor III

annotated_flash_debug_issue.png@sstcor  Check the image I hope this will help you still if you face any problem let me know. 



Best Regards,
Ashutosh Nama.

0 Kudos
Reply

947 Views
AshutoshNama
Contributor III

 

@sstcor  , Below is a sample flash script using blhost — NXP’s command-line tool for communicating with the bootloader — to fully erase and program the flash on an MCXN236 via ISP mode (UART or USB, depending on your setup).


1. Full Chip Erase via ISP (blhost script)

# Connect via UART or USB first # Replace COMx with your serial port (e.g., COM3 on Windows or /dev/ttyUSB0 on Linux) blhost -p COMx,115200 -- get-property 1 blhost -p COMx,115200 -- flash-erase-all

 

If this works, your flash is now clean.


2. Flashing New Firmware (GUI.bin)

blhost -p COMx,115200 -- write-memory 0x00000000 GUI.bin blhost -p COMx,115200 -- execute 0x00000000

 

This writes your firmware to the start of flash (address 0x00000000) and then tells the MCU to execute from there.
Note: If your GUI.bin is an image from MCUXpresso or GCC, ensure it is a proper binary file and not in ELF or HEX format. If needed, convert with:

arm-none-eabi-objcopy -O binary GUI.elf GUI.bin

3. Quick Image Validity Checklist

Before flashing, check that:

  • The first 8 bytes of GUI.bin contain a valid stack pointer and reset vector.

  • You're not configuring any memory regions (e.g., TrustZone, MPU) that might restrict access without properly initializing them.

  • If Secure Boot is enabled, the image is signed or provisioned correctly.

Would you like me to generate a minimal example main.c that’s safe to flash and test on the MCXN236?

Best Regards,
Ashutosh Nama

0 Kudos
Reply

937 Views
sstcor
Contributor II
Yes, can you please generate a minimal example? Also,it look like blhost execute is missing some args.

923 Views
AshutoshNama
Contributor III

 

Absolutely @sstcor  — here's a minimal working example of how to use blhost to:

  1. Connect to the target in ISP (UART) mode.

  2. Erase the flash memory.

  3. Write a binary image.

  4. Jump to the application.

Minimal blhost Flash Script Example

# Step 1: Check connection to bootloader ./blhost -p COM5,115200 -- get-property 1 # Step 2: Erase all flash ./blhost -p COM5,115200 -- flash-erase-all # Step 3: Write image to flash (replace `your_firmware.bin` with your image file) ./blhost -p COM5,115200 -- write-memory 0x0 your_firmware.bin # Step 4: Jump to application ./blhost -p COM5,115200 -- execute 0x00000000

Key Notes

  • -p COM5,115200 specifies UART port and baud rate (replace COM5 as needed).

  • 0x0 is the start address for most MCUs (check your specific part).

  • Make sure the target is in ISP mode (boot pins or jumper set).

Let me know if you'd like a .bat script version or a Linux shell script.

Best Regards,
Ashutosh Nama.

0 Kudos
Reply

919 Views
sstcor
Contributor II

I am getting this error when I enter the "execute" command.

satinder1_0-1746106656333.png

 

0 Kudos
Reply

908 Views
AshutoshNama
Contributor III

@sstcor  I'm running out of DMs can we connect over the call to solve this problem?

My mail address is: ashutoshnama26@gmail.com

Best Regards,
Ashutosh Nama

0 Kudos
Reply

901 Views
sstcor
Contributor II
Sure, I sent you an email on the given address.
0 Kudos
Reply

952 Views
AshutoshNama
Contributor III

Dear @sstcor 
This kind of issue is common when early development images misconfigure boot settings or lock debug access. Keeping ISP mode available and performing a full erase typically resolves it. Once erased, you should be able to regain normal debug access and proceed.

Let me know if you’d like a sample flash script or want help verifying your firmware image.

Best Regards,
Ashutosh Nama.

0 Kudos
Reply

948 Views
sstcor
Contributor II

Hi Ashutosh, I tried erasing the microcontroller in ISP mode but no success. I still can't access the microcontroller using debug port.

satinder1_0-1746104523978.png

 

0 Kudos
Reply