M-Drive and MDM in non M cars

carabuser

Lieutenant
Oct 2, 2019
888
1
789
0
UK
Ride
Z4 35i & 335i
If the code change works it would be easy to map the sport switch to the Mdrive button instead. That way you don't need any additional hardware.

I think a setup where you have everything tied to the sport button is ideal for the 335i. Currently I have my DCT flash set to go into drivelogic level 6 when the sport button is pressed but it would be nice to get relaxed DSC too.
 

amg6975

Sergeant
Oct 27, 2019
278
187
0
Ride
2012 135, 2005 ZHP, 2009 fJCW
If the code change works it would be easy to map the sport switch to the Mdrive button instead. That way you don't need any additional hardware.

I think a setup where you have everything tied to the sport button is ideal for the 335i. Currently I have my DCT flash set to go into drivelogic level 6 when the sport button is pressed but it would be nice to get relaxed DSC too.

Definitely agree with this. Olza can already make an M3 DCT flash to use the stock 135/335 GWS so you'd really only need to load the M DSC software with MDM enabled, then the custom DCT flash, and custom DME flash with this switch on and it should all be happy. I think the JBBF just needs to be coded to allow the Servotronic to go into Sport mode as well.
 

aus335iguy

Colonel
Nov 18, 2017
2,251
805
0
Down under
Ride
335i DCT 2009
Superwoofy had also done some work around the shift lights

There is one last cool thing to do on the PT-can. Shift lights. All someone with an M3 DCT has to sniff is:

"0x206", "Control Display Shiftlights [1]", "18", "0x12", "DME1" . ARB-ID 0x206.”
 

amg6975

Sergeant
Oct 27, 2019
278
187
0
Ride
2012 135, 2005 ZHP, 2009 fJCW
Superwoofy had also done some work around the shift lights

There is one last cool thing to do on the PT-can. Shift lights. All someone with an M3 DCT has to sniff is:

"0x206", "Control Display Shiftlights [1]", "18", "0x12", "DME1" . ARB-ID 0x206.”
Yeah, I don't suspect it's rocket surgery. I tried but they don't work if you aren't moving so I couldn't get any data. I should be able to log this when the M1.5 is put together though.

Also, 0x206 comes from the DME, not the DKG.
 
Last edited:

aus335iguy

Colonel
Nov 18, 2017
2,251
805
0
Down under
Ride
335i DCT 2009
That would have everything except EDC covered in M Drive . Im going to buy the Arduino CAN setup he had just for shits and giggles
 

AzNdevil

Lieutenant
Staff member
Nov 4, 2016
567
270
0
Hong Kong
@AzNdevil Feel free to comment if I've made a mistake with it, I don't think it'll mess up the addressing further down but it's quite hard to read.

just to double confirm, this edit is for IK or IN? i checked in IN, from my side the address to St_mdrv_anz should be [a0] (d0008000) + 0x5775
i got these addresses from the calc_sportschalter function
1611003432541.png




Let 'er rip if it's easy. If that's INA0S, use the original stock one from before (unpatched). Least invasive may be manual 0x399 test first, but if DME option is easy, I'll test it too/instead of.

this would be easy from DME side, we can just noop the sending jump but someone will need to build something to send the 0x399 canbus packet

Right. I don't suspect the MSD81 would accept values from 0x3CA anyway. The ideal scenario is to hard code in standard values that would be activated with the M button in non-M cars. Probably Power = Sport, Servotronic = SPort, DSC = MDM, DKG = S5.

i doubt the power part will work since there are only seperate throttle request maps (for the throttle pedal) on a msd81 but that only works in 1M mode or z4 sports mode

You're correct, Byte 1 bit 0-1 needs to be value of 2 for on and 1 for off (actually "Revert") but CTR_DISP_MDRV that's in Byte 4 is a value of 1 for on and 0 for off. So, you need to add one to it to get the correct value for Byte 1.

I don't really know arduino but in standard C the checksum calc would be:

Code:
uint8_t can_packet_399[6];
uint16_t checksum;

can_packet_399[0] &= 0xF0; //remove anything that may be in checksum

checksum = 0x399;   //initialize checksum to 0x399

//add up all the bytes of 0x399
for (uint8_t i=0, i<6, i++){
  checksum += can_packet_399[i]
  }

checksum = (checksum & 0x00FF) + (checksum >> 8); //add upper and lower Bytes

checksum &= 0x00FF; //throw away anything in upper Byte

checksum = (checksum & 0b000F) + (checksum >> 4); //add first and second nibble

checksum &= 0x000F; //throw away anything in upper nibble

can_packet_399[0] += checksum;  //add checksum back into Byte0.

this is nice, can probably be used in an arduino sketch with minor modifications!

Superwoofy had also done some work around the shift lights

There is one last cool thing to do on the PT-can. Shift lights. All someone with an M3 DCT has to sniff is:

"0x206", "Control Display Shiftlights [1]", "18", "0x12", "DME1" . ARB-ID 0x206.”

the activation for this is in byte 5 of 0x399 according to @amg6975 's canbus dump, i'd say there is a higher chance of editing the bin to get this working instead

That would have everything except EDC covered in M Drive . Im going to buy the Arduino CAN setup he had just for shits and giggles

it can be had for smaller and cheaper with a clone blue pill and canbus transceiver these days
too bad you are no where close to me or i can build it for you ;)
 
  • Like
Reactions: RSL

aus335iguy

Colonel
Nov 18, 2017
2,251
805
0
Down under
Ride
335i DCT 2009
it can be had for smaller and cheaper with a clone blue pill and canbus transceiver these days
too bad you are no where close to me or i can build it for you ;)
Really? Cheaper than this ?
 

RSL

Lieutenant
Aug 11, 2017
937
501
0
Thanks @AzNdevil. @carabuser if there is a consensus on the correct location, make any change when you can.

@amg6975 thanks man. I had to do a little work for the bit addition, but works pretty much copy/paste otherwise once the high byte counter is supplied.

I think at this point, just need to kill SZL enable in DME, dump into woofy's code for button press and send 3x at 160ms intervals in press and possibly every 10 secs outside of button press.

Right now, I just have an "on" state to send in the sketch, but if it works at all, will probably move quickly to DME logic once the addresses are confirmed and coded.

Counter 0-E +checksum calc in B0 with defined message:
Code:
16:23:14.567 -> 2
16:23:14.567 -> 36
16:23:14.567 -> 23
16:23:14.601 -> FF
16:23:14.601 -> DF
16:23:14.601 -> FF
16:23:14.601 ->  
16:23:14.601 -> 13
16:23:14.601 -> 36
16:23:14.601 -> 23
16:23:14.601 -> FF
16:23:14.601 -> DF
16:23:14.635 -> FF
16:23:14.635 ->  
16:23:14.635 -> 24
16:23:14.635 -> 36
16:23:14.635 -> 23
16:23:14.635 -> FF
16:23:14.635 -> DF
16:23:14.635 -> FF
16:23:14.669 ->  
16:23:14.669 -> 35
16:23:14.669 -> 36
16:23:14.669 -> 23
16:23:14.669 -> FF
16:23:14.669 -> DF
16:23:14.669 -> FF
16:23:14.669 ->  
16:23:14.669 -> 47
16:23:14.703 -> 36
16:23:14.703 -> 23
16:23:14.703 -> FF
16:23:14.703 -> DF
16:23:14.703 -> FF
16:23:14.703 ->  
16:23:14.703 -> 58
16:23:14.703 -> 36
16:23:14.737 -> 23
16:23:14.737 -> FF
16:23:14.737 -> DF
16:23:14.737 -> FF
16:23:14.737 ->  
16:23:14.737 -> 69
16:23:14.737 -> 36
16:23:14.737 -> 23
16:23:14.771 -> FF
16:23:14.771 -> DF
16:23:14.771 -> FF
16:23:14.771 ->  
16:23:14.771 -> 7A
16:23:14.771 -> 36
16:23:14.771 -> 23
16:23:14.771 -> FF
16:23:14.771 -> DF
16:23:14.805 -> FF
16:23:14.805 ->  
16:23:14.805 -> 8B
16:23:14.805 -> 36
16:23:14.805 -> 23
16:23:14.805 -> FF
16:23:14.805 -> DF
16:23:14.805 -> FF
16:23:14.805 ->  
16:23:14.839 -> 9C
16:23:14.839 -> 36
16:23:14.839 -> 23
16:23:14.839 -> FF
16:23:14.839 -> DF
16:23:14.839 -> FF
16:23:14.839 ->  
16:23:14.839 -> AD
16:23:14.873 -> 36
16:23:14.873 -> 23
16:23:14.873 -> FF
16:23:14.873 -> DF
16:23:14.873 -> FF
16:23:14.873 ->  
16:23:14.873 -> BE
16:23:14.873 -> 36
16:23:14.907 -> 23
16:23:14.907 -> FF
16:23:14.907 -> DF
16:23:14.907 -> FF
16:23:14.907 ->  
16:23:14.907 -> CF
16:23:14.907 -> 36
16:23:14.907 -> 23
16:23:14.907 -> FF
16:23:14.941 -> DF
16:23:14.941 -> FF
16:23:14.941 ->  
16:23:14.941 -> D0
16:23:14.941 -> 36
16:23:14.941 -> 23
16:23:14.941 -> FF
16:23:14.941 -> DF
16:23:14.975 -> FF
16:23:14.975 ->  
16:23:14.975 -> E1
16:23:14.975 -> 36
16:23:14.975 -> 23
16:23:14.975 -> FF
16:23:14.975 -> DF
16:23:14.975 -> FF
 
  • Like
Reactions: AzNdevil

carabuser

Lieutenant
Oct 2, 2019
888
1
789
0
UK
Ride
Z4 35i & 335i
just to double confirm, this edit is for IK or IN? i checked in IN, from my side the address to St_mdrv_anz should be [a0] (d0008000) + 0x5775
i got these addresses from the calc_sportschalter function
IKM0S
 

superwofy

Corporal
Jan 18, 2021
109
153
0
Hello all. Hope I can give something back. I did at some point promise to document things but you know.. life and all that.

My car: 6MT, E92 03/08 N54.


What you guys are trying to accomplish is a bit above what my requirements were at the time I wrote that sketch.
Flashing the MDSC ZB or indeed a hardware change would have enabled the throttle map switching. However, I also have ACC which I wasn't willing to part with.
You're all probably aware but the MDSCs don't have the ECBA (interface for the ACC to request deceleration from DSC).

I went through all M ZBs (E82, E9X and E6X) with the same results. I even tried rebuilding the CAN structure for ECBA but that was silly since all it would have done is trick ACC into working but without actual braking...

So, I set about replacing the missing message 0x1D9 while keeping the stock DSC. MDM notwithstanding, the MK60E5 with stock software is superior in terms of the functionalities it affords. Brake fade, pre-tensioning, disc drying etc. are useful in a street car.
I wanted it to behave like stock so it took a bit of tweaking with filters, reducing the size of libraries etc. to make it nice. It's not 100% (i.e sometimes it doesn't pick up the key press unless you hold it for a bit) but that is rare. The board has been installed in my LDM for about a year now.

IMG_20200419_230653-pinout - Copy.jpg
IMG_20200420_011323 - Copy.jpg


The module is Longan's "Serial CAN Bus Module" v1.2. I think a capacitor may be a good idea on the 5V line to prevent spikes from crashing the LM2594 in the LDM. I never had any issues tho.


Small bit about the code. Not sure if it's been answered yet, but the checksum is simply a counter between F0 and FF sent every 100ms. I can see that I made a mistake in my sketch and did the checksum between 00 and FF. The DME never complained oddly enough. I will correct now.



As mentioned above, I do want to get the shift lights working and it just so happens a friend picked up an LCI DKG M3 but we're in lock-down here so :confused:



P.S, sport mode in MSD81 can also be triggered with the FDS switch from the Z4. I did succeed in doing this, just grounding the line from JBBF with FDS set to aktiv. No indicators when it's on. Can't get anything on my CIC either (FDS popup). I did check RealOEM and E89 Z4 has its own CIC part no. Presumably because of FDS. Adding the FDS popup when pressing the M key on my sketch would be cool too. Don't have the ICOM yet and I've already killed a CIC (word of advice for anyone typing in a flashctl command, double check you didn't forget '0x' when writing in an address :tonguewink:)

P.S.S Has anybody disassembled the firmware from JBBF3 to see why COMFORT/SPORT never toggle? I think I can dump it with XPROG.

P.S.S.S? I'm also fitting EDC. Harness is 70% complete, module is fitted and working. Awaiting some hardware. Doing it with M4 hubs, 370mm brakes and E92 M shocks. Rear subframe swap is still pending.
 
Last edited:

aus335iguy

Colonel
Nov 18, 2017
2,251
805
0
Down under
Ride
335i DCT 2009
Hey mate! Great to see you in here.
I’ll be buying one of the boards you suggested and used but does that have the arduino on board or ... doesn’t seem to?
 

RSL

Lieutenant
Aug 11, 2017
937
501
0
Sketch is messy, but got it to a point it should've worked on button and wanted to test before it got too late. I disabled the SZL in DME and confirmed no response with SZL = 0. Plugged in shield, pressed button and got M light in Kombi.

The mode only stays active a few seconds, but I do not have a continual broadcast after enable yet. I'll need to double check my bits/hex, DSC should be off, but power finally shows sport! Didn't test to see what is actually active, I'll need to doctor the sketch to keep it on and set some flags on/off everything on alternating button presses.

Not sure yet if any of the settings are actually active or if it's just changing visual info, but it's doing some of what we expected at least.

 

superwofy

Corporal
Jan 18, 2021
109
153
0
Hey mate! Great to see you in here.
I’ll be buying one of the boards you suggested and used but does that have the arduino on board or ... doesn’t seem to?

Yep, it's a 32U4 https://docs.longan-labs.cc/1030001/
[Correction: AT128p not 32u4]

This was my "production" choice since it's tiny and includes everything on board. For "development" I used the typical knock-off 328 with a 16mhz MCP2551.
 
Last edited:
  • Like
Reactions: aus335iguy

aus335iguy

Colonel
Nov 18, 2017
2,251
805
0
Down under
Ride
335i DCT 2009
Sketch is messy, but got it to a point it should've worked on button and wanted to test before it got too late. I disabled the SZL in DME and confirmed no response with SZL = 0. Plugged in shield, pressed button and got M light in Kombi.

The mode only stays active a few seconds, but I do not have a continual broadcast after enable yet. I'll need to double check my bits/hex, DSC should be off, but power finally shows sport! Didn't test to see what is actually active, I'll need to doctor the sketch to keep it on and set some flags on/off everything on alternating button presses.

Not sure yet if any of the settings are actually active or if it's just changing visual info, but it's doing some of what we expected at least.

@RSL
This is awesome! I cant wait to do this to mine now!

Ive ordered the board and ill be adding it to my LDM the way @superwofy did it to keep it neat.
P.S, sport mode in MSD81 can also be triggered with the FDS switch from the Z4. I did succeed in doing this, just grounding the line from JBBF with FDS set to aktiv. No indicators when it's on. Can't get anything on my CIC either (FDS popup). I did check RealOEM and E89 Z4 has its own CIC part no. Presumably because of FDS.
The CICs have different Product line settings. Did you try changing those ?
 

RSL

Lieutenant
Aug 11, 2017
937
501
0
I realized I still had woofy's M wheel message sent on the first try, commented that out. I changed the bits for sport plus, MDM DSC, drive logic 5, shift lights on. It all shows in CIC, but that's all it's doing. In fact, without the M wheel button signal, not a thing related to Mdrive shows active in DME addresses.

To boot, drive level logic in Kombi stays at default of 2, so this is still not making it into the GWS/EGS either.

20210118_202111.jpg
 
  • Like
Reactions: aus335iguy

RSL

Lieutenant
Aug 11, 2017
937
501
0
Hello all. Hope I can give something back. I did at some point promise to document things but you know.. life and all that.

My car: 6MT, E92 03/08 N54.


What you guys are trying to accomplish is a bit above what my requirements were at the time I wrote that sketch.
Flashing the MDSC ZB or indeed a hardware change would have enabled the throttle map switching. However, I also have ACC which I wasn't willing to part with.
You're all probably aware but the MDSCs don't have the ECBA (interface for the ACC to request deceleration from DSC).

I went through all M ZBs (E82, E9X and E6X) with the same results. I even tried rebuilding the CAN structure for ECBA but that was silly since all it would have done is trick ACC into working but without actual braking...

So, I set about replacing the missing message 0x1D9 while keeping the stock DSC. MDM notwithstanding, the MK60E5 with stock software is superior in terms of the functionalities it affords. Brake fade, pre-tensioning, disc drying etc. are useful in a street car.
I wanted it to behave like stock so it took a bit of tweaking with filters, reducing the size of libraries etc. to make it nice. It's not 100% (i.e sometimes it doesn't pick up the key press unless you hold it for a bit) but that is rare. The board has been installed in my LDM for about a year now.

View attachment 48262View attachment 48263

The module is Longan's "Serial CAN Bus Module" v1.2. I think a capacitor may be a good idea on the 5V line to prevent spikes from crashing the LM2594 in the LDM. I never had any issues tho.


Small bit about the code. Not sure if it's been answered yet, but the checksum is simply a counter between F0 and FF sent every 100ms. I can see that I made a mistake in my sketch and did the checksum between 00 and FF. The DME never complained oddly enough. I will correct now.



As mentioned above, I do want to get the shift lights working and it just so happens a friend picked up an LCI DKG M3 but we're in lock-down here so :confused:



P.S, sport mode in MSD81 can also be triggered with the FDS switch from the Z4. I did succeed in doing this, just grounding the line from JBBF with FDS set to aktiv. No indicators when it's on. Can't get anything on my CIC either (FDS popup). I did check RealOEM and E89 Z4 has its own CIC part no. Presumably because of FDS. Adding the FDS popup when pressing the M key on my sketch would be cool too. Don't have the ICOM yet and I've already killed a CIC (word of advice for anyone typing in a flashctl command, double check you didn't forget '0x' when writing in an address :tonguewink:)

P.S.S Has anybody disassembled the firmware from JBBF3 to see why COMFORT/SPORT never toggle? I think I can dump it with XPROG.

P.S.S.S? I'm also fitting EDC. Harness is 70% complete, module is fitted and working. Awaiting some hardware. Doing it with M4 hubs, 370mm brakes and E92 M shocks. Rear subframe swap is still pending.
I assumed the Z4 option would be completely doable and I have the button block to mess with that setup later. Can you shed any more light on which pin from JBBF you grounded and what your hardware/DCT flash setup was (stock GWS, Z4 bin, sport button disconnected, etc)? If I play with that route later, I'd like to get both sport modes working.
 
  • Like
Reactions: aus335iguy

superwofy

Corporal
Jan 18, 2021
109
153
0
I assumed the Z4 option would be completely doable and I have the button block to mess with that setup later. Can you shed any more light on which pin from JBBF you grounded and what your hardware/DCT flash setup was (stock GWS, Z4 bin, sport button disconnected, etc)? If I play with that route later, I'd like to get both sport modes working.


No DCT/AT I'm 6MT.
IKM0S on MSD81.
Stock DSC or MDSC.
JBE coded for FDS

Ground Pin 18 on X14271 for Sport and 36 for Normal.
Check status in Tool32 -> MSD80 -> status_spt. STAT_STAT_SPT will change to 1.

It does the same thing 1D9 does but doesn't broadcast 399 so you never get an M light on Kombi.
It does change vehicle mode 0x315. See https://github.com/superwofy/N54-Mdrive-MCP/blob/master/traces/trace 315 (E89 FDS).txt

On the Z4 Kombi you'll see Normal, Sport, Sport+. You should also get a popup on Z4 CIC if FDS is coded.



I doubt this will be useful to most people. It would be really cool for my sketch to display the popup on CIC but that's about it. I can already trigger the sport mode with M drive.
 
Last edited:
  • Like
Reactions: RSL and aus335iguy

amg6975

Sergeant
Oct 27, 2019
278
187
0
Ride
2012 135, 2005 ZHP, 2009 fJCW
I assumed the Z4 option would be completely doable and I have the button block to mess with that setup later. Can you shed any more light on which pin from JBBF you grounded and what your hardware/DCT flash setup was (stock GWS, Z4 bin, sport button disconnected, etc)? If I play with that route later, I'd like to get both sport modes working.
1611027776689.png
 
  • Like
Reactions: RSL and aus335iguy