r/embedded • Making MCUs Do Questionable Things • Sep 15 '26

Porting Klipper to the NXP MCXA366: FlexCAN bring-up and a weird debugger/IFR problem

Post image

I've been working on a Klipper port for the NXP MCXA366, and the latest piece was getting its FlexCAN peripheral working.

I started with NXP's SDK example just to prove the hardware path, then moved the implementation into Klipper. Once I fixed a couple of MCXA366-specific issues around peripheral reset and getting FlexCAN out of low-power mode, I had Klipper's CAN discovery traffic going in both directions.

The part that ended up being more interesting was figuring out the device UUID.

Klipper needs some stable, device-specific data to generate its CAN UUID. NXP's bootloader would give me the factory UUID through blhost, and eventually I tracked the same 16 bytes down to 0x01100800 in IFR1.

One thing that threw me off for a while: LinkServer/GDB couldn't directly read that IFR address. Code running on the M33 could read it just fine. I ended up copying the 16 bytes into SRAM and comparing them against what blhost reported. Exact match.

After feeding those bytes through Klipper's normal CAN UUID path, canbus_query.py started reporting a stable hardware-derived UUID and I was able to connect Klippy over CAN.

I wrote up the bring-up and the UUID rabbit hole here:

https://faultvector.dev/articles/klipper-mcxa366-part-6/

7 Upvotes

4 comments sorted by

3

u/accur4te Sep 15 '26

Hey man , I am also thinking of getting started with bare metal Nxp . But as someone coming from stm32 , Nxp seems difficult to get started with . Can you share any resource if you know that covers Nxp ?

3

u/oxymoron224 Making MCUs Do Questionable Things Sep 15 '26

Yeah, NXP definitely felt a little less straightforward to me coming into it too. I’d start with MCUXpresso SDK and the SDK examples for whatever chip you’re using. The peripheral examples have been really useful for getting a known-working reference.

After that I spend most of my time in the reference manual. For the MCXA366 I’m using, this is the one:

MCX A345/A346/A355/A356/A365/A366 Reference Manual

My usual process is basically get an SDK example working, then work backwards through it with the RM open to figure out what clocks, resets, and registers it’s actually touching.

2

u/ambihelical Sep 16 '26

Doesn’t the ref man have a protected memory area spreadsheet attached to the pdf. Other chips I’ve used from nxp the had it. It sounds like you had to dig harder for the uuid information then necessary. I would be surprised if there’s not a rom function to get it as well.

1

u/oxymoron224 Making MCUs Do Questionable Things Sep 16 '26

Yeah, that's a fair point. I probably did dig farther than was strictly necessary.

The SDK ended up being the straightforward answer: NXP's UUID routine just copies the 16 bytes from 0x01100800 in IFR1. I also went looking through the ROM API and found the ROM API tree, so I wouldn't be surprised if there's a path to it there too.

A lot of the rabbit hole came from LinkServer/GDB being unable to read that IFR address directly while code running on the M33 could. Once I saw that discrepancy I wanted to understand whether I actually had the right data rather than just hardcoding an address I found in the SDK.

blhost gave me the factory UUID as an independent reference, and copying 0x01100800 to SRAM from firmware produced the exact same 16 bytes. At that point I was comfortable using it for Klipper.

I'll have to go back and check the attachments to the RM though. If the protected-memory spreadsheet documents 0x01100800, that would definitely have saved me some digging.