Open source reflashing for >2002 ECUs

A place to discuss the systems and methods of tuning Nissan engines.
User avatar
fenugrec
Posts: 4
Joined: Wed Aug 10, 2016 5:15 pm
Car: Sentra B15

Open source reflashing for >2002 ECUs

Postby fenugrec » Wed Aug 10, 2016 5:45 pm

Hi people,
I'm a total stranger here but I've been hacking on Nissan ECUs for over two years now. I've been figuring out the reflashing process for ~2002 onwards ECUs, specifically those with the K-line OBD2 interface since that's what I have on my 04 Sentra.

It's been done before by a few people and companies, but I figured it would be nice to have it documented and open-source. Here's some of what I've been up to : (arg, I can't post URLs due to me being in the "new poster baby sandbox") !!!
nissanecu.miraheze.org NissanECU wiki: lots of reverse-engineering info
"Nissan QR25DE ECU dumping tool " : (***) drawn out thread on RomRaider forums where I posted updates as I made slow progress during 2 years.

So now it's pretty much solved :
- use any software (RomRaider/winOLS/ even a hex editor really) to modify your ROM;
- use (***) freediag / nisprog (software I've been working on in parallel, some custom commands in there, and that's almost it.

The last missing piece was a "reflashing kernel" - the way this works is that the stock firmware doesn't hold the low-level routines for reflashing, so it needs to load a kernel to RAM, and execute it from there. The issue was then finding / writing a kernel...

Hopefully this doesn't count as advertising -- I'm not selling anything, but I'd like to promote a crowdfunding campaign I've set up to fund the final development of the reflashing kernel and associated tools. The result is a fully open-source kernel, which as far as I know is something very unusual on the tuning scene.

The campaign is set to begin very soon. Stay tuned on the crowdsupply website (***) ,project name is "nisprog reflashing kernel" !


ArmedAviator
Posts: 507
Joined: Tue Mar 22, 2016 5:28 pm
Car: 2012 M37x
Location: SW Ohio

Re: Open source reflashing for >2002 ECUs

Postby ArmedAviator » Wed Aug 10, 2016 8:58 pm

Did you write the kernel from scratch?
What license is it under?
Has this been tested on a running engine yet or still being hashed out?

User avatar
fenugrec
Posts: 4
Joined: Wed Aug 10, 2016 5:15 pm
Car: Sentra B15

Re: Open source reflashing for >2002 ECUs

Postby fenugrec » Thu Aug 11, 2016 5:09 pm

Hi,
ArmedAviator wrote:Did you write the kernel from scratch?
What license is it under?
Yes, I wrote all of it - mostly C code, and some SuperH assembly for the tricky startup code. Other than that, I've been the maintainer of freediag since ~2009 (didn't write all of that code though); and the "nisprog" additions are all mine too.

License will be GPLv3, so real open source, unlike certain products that have "open" in their name : )
Has this been tested on a running engine yet or still being hashed out?
So far, only tested on a bench ECU (05 Sentra QG18DE) as proof of concept. When I get back to my gear in a few days I'll be testing on a QR25DE ECU that still has a car attached P-) I'll try to take some videos or something.

The campaign is now up (sorry for the mangled link, I'm still not allowed to post URLs)
www crowdsupply_dot_com/nisprog/reflashing-kernel

ArmedAviator
Posts: 507
Joined: Tue Mar 22, 2016 5:28 pm
Car: 2012 M37x
Location: SW Ohio

Re: Open source reflashing for >2002 ECUs

Postby ArmedAviator » Thu Aug 11, 2016 7:41 pm

This is really cool if successful, and there's no reason it can't be.

I like digging into how things work and how they can be changed or improved. I only took a few C++ classes as college electives years ago, so I'd not be of any help in terms of coding in C, but I do other coding so understand programming logic.

I think the ultimate goal would be to remove factory firmware, upload your opensource firmware/kernel with near-normal functionality (as best as can be programmed) with stock AFR and spark tables, shift points and pressures, and stuff like that and then have a very easy way to modify those basic things for super cheap custom-tuning.

One big consideration comes to mind, though. There's a chance that any 3rd party firmware, or even factory firmware, can cause some sort of issue at the least opportune time (corner cases) that can cause serious issues. In this case, a serious ECU issue at 75MPH can be deadly. Your programming must be rock solid, and anyone that uses, redistributes, and contributes to these related projects must really be careful and test well, as should always be the case.

User avatar
fenugrec
Posts: 4
Joined: Wed Aug 10, 2016 5:15 pm
Car: Sentra B15

Re: Open source reflashing for >2002 ECUs

Postby fenugrec » Sat Aug 20, 2016 8:07 pm

Well, writing ECU code from scratch would be quite an undertaking. There's a few open source projects that do this already. For these ECUS however, some of the hardware is undocumented (custom ICs). Plus, there are many different hardware revisions; probably hundreds of hours of work just to reverse engineer the hardware enough to write code.

I think that effort is better spent analyzing the existing firmware, which already has a proven track record of reliability and is backed by thousands/millions of hours of testing in actual use. This also has the benefit of starting from a known good starting point, making it easier to make incremental changes instead of having to come up with maps and compensation data for absolutely everything.

Note that this kernel is a small piece of code that runs in RAM (erased on the next reboot / power cycle), and only provides a way to reflash the ROM -- it's just a tool. You're absolutely right, the user needs to be extra careful when modifying stock programming.

User avatar
fenugrec
Posts: 4
Joined: Wed Aug 10, 2016 5:15 pm
Car: Sentra B15

Re: Open source reflashing for >2002 ECUs

Postby fenugrec » Fri Aug 26, 2016 8:21 am

Here's a minor video update on the project -
https://www.crowdsupply.com/nipsrog/ref ... /poc-video

The campaign is 50% funded, only 3 weeks to go !

HollywoodJackson
Posts: 163
Joined: Thu Oct 23, 2014 1:35 pm
Car: 2002 Q45 Premium (daily)
1990 240SX (drift)
1999 Q45 (RIP)
Location: Hollywood, CA
Contact:

Re: Open source reflashing for >2002 ECUs

Postby HollywoodJackson » Tue Nov 07, 2017 1:35 am

Very interesting!


Return to “Engine Tuning”