Page 5 of 8

Re: MS2 development/coding for dummies

Posted: Mon Jul 21, 2014 8:10 pm
by firyembers
Hi.
Thanks for the support and pointers but after a stint of 90 odd hours,miniscle time i know ,realised not going to get what i want in a timely manner..Not that i am giving up,defeat is never an option..but really a programmer i am not with bits and bites(deliberate mistake) and so on

So am going another way around and likely use a pic or micro controller with temp or rev or speed inputs from ms2 to control the bipolar servo (STV)to do on my tb from a gsxr 750.as i would like.

meaning also there are so many servo control projects out there that i can find one to turn to what i want,of course with respect to the original author.s*** i not want to reinvent the wheel,but being an engineer of many disiplines means i look and research choose and change accordingly..
Maybe an add board eventually

This is not likely correct place,maybe i should start a new thread or join one when i am done searching..as likely many also are asking especially as suzuki tbi late one are going cheapish (i Paid £50 for my really clean set 17000 miles done)well i think it's cheap))

Ideas,critisms and thoughts always appreciated

Later Guys

Re: MS2 development/coding for dummies

Posted: Sat Aug 23, 2014 3:22 pm
by AbatelliCristian
Hi,
I have installed all tool, but have a problem

During "make" command I have error:
ls: impossibile accedere a c:/usr/bin/m68hc11-elf-gcc: No such file or directory

I search the file m68hc11-elf-gcc.exe, but there isn't.
I search in zip tools file and I see m68hc11-elf-gcc.exe = 0kb :?

I have tried 2010 and 2012 version

Re: MS2 development/coding for dummies

Posted: Fri Oct 03, 2014 2:35 pm
by luftvagon
acab wrote:I make little cheat for new dummies :)

1. Download and install VirtualBox.
2. Download and install PuTTY SSH client for work in console of VM.
3. Download and install WinSCP SFTP client for coping files.
4. Download and unpack my pre-builded Debian VM with all tools for compilating.
5. Run and enjoy VM via VirtualBox.
6. Log in to VM via user ms and password 123456. Root password is msextra.
7. Build your code for new versions of Megasquirt!
I am still getting a different md5sum even with your vbox...

# make clean
# make microsquirt

# md5sum microsquirt.s19
fc5ac7959ffca259421d3c4868a4597f microsquirt.s19

# md5sum ../microsquirt.s19
5003c29992899fca4f80d8cd88f2f5d4 ../microsquirt.s19

Re: MS2 development/coding for dummies

Posted: Mon Oct 27, 2014 9:54 am
by mrx79
Hallo,

sorry for threadjacking this thread, but i have a small problem compiling the current code.
I installed Cygwin (32bit) with the total develop package and the 2012 edition of the compiler tools.
Running WindowsXP 32bit SP3.
Cygwin is installed to C:\cygwin
the development tools are extracted to c:\usr

i can also compile the ms2extra pre3.3 beta13 without any problems. Getting a few adress warning while compiling but it compiles without problems and the resulting s19 is identical to the one which is delivered to the beta13 code package.

But when i want to compile for example the pre3.3 beta19 i get a different s19.
Again, compiler throws a few warnings but compiles without problems. But the resulting S19 is differen.

I noticed quite large change in the makefile between beta13 and beta19 - may that be the reason?

also i get some strange error messages when compiling the beta19:
for example when doing make clean or make

Re: MS2 development/coding for dummies

Posted: Sun Feb 15, 2015 3:51 am
by MS2tester
have a fresh install on ubuntu 14.04
installed wine wich was the last problem not having the proper libraries
somthing did not go well installing as it seemed to hang
waited for 30 min then closed it
try to do make file
but obviously it did not work

Re: MS2 development/coding for dummies

Posted: Sun Feb 15, 2015 7:09 am
by jsmcortina
You didn't follow the instructions.

James

Re: MS2 development/coding for dummies

Posted: Sun Feb 15, 2015 10:55 am
by MS2tester
cd /
seems to be the important factor here :o :oops: :cry:

Re: MS2 development/coding for dummies

Posted: Tue Apr 07, 2015 1:36 pm
by Manu
Hi,

I'm currently try to ad some CAN messages to MS2extra 3.4b10 and when I launch "make ms2" I get a compilation error. Can somebody point me where is my mistake ?

Here the code :

Code: Select all

if (flash4.can_bcast2 & 0x04) {
	id = 0xFA; //0xFA - engine control unit RPM is 8:1 ratio = outpc.rpm*8
        val = outpc.rpm * 8;
        data[0] = (unsigned char)(val & 0xff); //byte 0 = RPM, L
        data[1] = (unsigned char)(val >> 8);   //byte 1 = RPM, H
        data[2] = 0x00;
        data[3] = 0x00;
        data[4] = 0x00;
        data[5] = 0x00;
        data[6] = 0x00;
        data[7] = 0x00;
        send_can11bit(id, data, 8);
}

if (flash4.can_bcast2 & 0x08) {
        id = 0x77A; //0x77A - engine control unit CLT is CLT(DegC) - 40
        val = (((outpc.clt - 320) * 5) / 9)/10;
        val = val - 40;
        data[0] = (unsigned char)val; 
        data[1] = 0x00;
        data[2] = 0x00;
        data[3] = 0x00;
        data[4] = 0x00;
        data[5] = 0x00;
        data[6] = 0x00;
        data[7] = 0x00;
        send_can11bit(id, data, 8);
}
And the error is :
/cygdrive/c/usr/bin/../lib/gcc-lib/m68hc11-elf/3.3.6-9s12x-20120502/m68hc12/mshort/crt1.o:(.install4+0x1): AVERTISSEMENT: Reference to the far symbol `main' using a wrong relocation may result in incorrect execution
/cygdrive/c/usr/bin/../lib/gcc-lib/m68hc11-elf/3.3.6-9s12x-20120502/m68hc12/mshort/crt1.o: dans la fonction « fatal »:
crt0.s:(.install4+0xc026): AVERTISSEMENT: reference to a banked address [3d:8000] in the normal address space at c026
collect2: ld a retourné 1 code d'état d'exécution
Makefile:176 : la recette pour la cible « megasquirt2.elf » a échouée
make[1]: *** [megasquirt2.elf] Erreur 1
make[1] : on quitte le répertoire « /ms2extra-pre3.4beta10/ms2extra »
Makefile:56 : la recette pour la cible « megasquirt » a échouée
make: *** [megasquirt] Erreur 2
Bests,
Manu

Re: MS2 development/coding for dummies

Posted: Wed Apr 08, 2015 2:50 am
by jsmcortina
Can you post all of the error/warning messages? Often the actual error is followed by a page of spurious errors that results from it.

Or

Code: Select all

make ms2 2> err.txt
less err.txt
James

Re: MS2 development/coding for dummies

Posted: Wed Apr 08, 2015 6:21 am
by Manu
Thank for your reply James.

Attached is :

err.txt => the file you requested
good.txt => one normal compilation (straight from scratch code, but canbtr0 & canbtr1 modified)
ms2_extra_can.c => the only modified file that block compilation. The mod is in the previous post

I already do this mod in 3.3.x series and it work well BUT i didn't attempt to add CAN function. In my old mod I replace 0x280 code. If I do the same with 3.4b10 it work well.

I use cygwin and I can compile .s19. I don't think that it is an environment problem.

Thx,
Manu

Re: MS2 development/coding for dummies

Posted: Wed Apr 08, 2015 6:41 am
by jsmcortina
This is the problem:

Code: Select all

/cygdrive/c/usr/bin/../lib/gcc-lib/m68hc11-elf/3.3.6-9s12x-20120502/../../../../m68hc11-elf/bin/ld: megasquirt2.elf la section «.rodata» ne va pas s'adapter à la région «text»
/cygdrive/c/usr/bin/../lib/gcc-lib/m68hc11-elf/3.3.6-9s12x-20120502/../../../../m68hc11-elf/bin/ld: la région «text» est débordée de 70 octets
Your code doesn't fit in the existing defined regions. (The chip uses various memory regions.)

It appears that your added code has caused .text to overflow.

With code that compiles, take a look at the start of megasquirt2.dmp and you can see the usage of each region. Check memory.x to see the sizes available.

James

Re: MS2 development/coding for dummies

Posted: Wed Apr 08, 2015 6:43 am
by Manu
Thank James,

I was thinking about something like that but was unsure about it.

Bests,
Manu

Re: MS2 development/coding for dummies

Posted: Wed Apr 08, 2015 6:56 am
by Manu
I will use my old method and remplace 0x280 RPM CAN Code with mine as this code is only for on vehicle. I'm not strong enough to go ahead this problem.

FIY this code is used with renault dashboard (clio 2.0 16V - 182cv). Original cars have drive-by-wire throttle body and this car is well used here in rally. For this purpose Renault Sport sell a kit that contain a normal throttle body (cable) and an ECU for those cars, but the ecu is not easy to program. So many drivers switch for a Megasquirt ECU and need those 2 CAN infos. CAN bus is 250kbit/s.

This is part of my PNP line and I like to move to 3.4 code. I currently work at the same project but for Peugeot 206RC.

Cheers,
Manu

Re: MS2 development/coding for dummies

Posted: Thu Apr 16, 2015 1:03 pm
by Manu
Hi,

This is the code I use to match Renault Clio RS phase 2 dashboard :

Code: Select all

if (flash4.can_bcast1 & 0x02) {
		id = 0xFA; //0xFA - CLIO RS2 - engine control unit RPM is 8:1 ratio = outpc.rpm*8
		if (outpc.rpm > 8190) {
			val = 65520;
		} else {
			val = outpc.rpm * 8;
		}
				
        data[0] = (unsigned char)(val >> 8);   //byte 1 = RPM, H
		data[1] = (unsigned char)(val & 0xff); //byte 0 = RPM, L
        data[2] = 0x00;
        data[3] = 0x00;
        data[4] = 0x00;
        data[5] = 0x00;
        data[6] = 0x00;
        data[7] = 0x00;
        send_can11bit(id, data, 8);
    }

    if (flash4.can_bcast1 & 0x04) {
        id = 0x77A; //0x77A - CLIO RS2 - engine control unit CLT is CLT(DegC) - 40
		val = ((((outpc.clt - 320) * 5) / 9)/10)+40;
        data[0] = (unsigned char)val; 
        data[1] = 0x00;
        data[2] = 0x00;
        data[3] = 0x00;
        data[4] = 0x00;
        data[5] = 0x00;
        data[6] = 0x00;
        data[7] = 0x00;
        send_can11bit(id, data, 8);
    }
The can bus speed is 250kbit/s so you have to change those parameters too :

Code: Select all

    CANBTR0 = 0xC5;
    CANBTR1 = 0x1C; 
Cheers,
Manu

Re: MS2 development/coding for dummies

Posted: Mon May 04, 2015 1:05 pm
by Fabius72
Hello,
reading and following the provided instructions I am able to compile the source code.
Please, is there someone that can answer to a newby question?

I would like to tune my trimTables on my four cylinders engine, by four EGTs and an micro-controlled device.
Since I have mounted an wideband lambda sensor on the second cylinder exhaust pipe and the sequence of my odd fire engine is 1-3-2-4, the VE table is referred to TrimTable3 (that obviously will be an whole 100% table). So my code will tune TrimTable 1-2-4.
The problem is that veTrim1 is placed on page4 and veTrim2-3-4 on page6.
Tuning 1-2-4 tables at the same time actually isn't possible without burning tables before changing page, but I would like to make an live tuning while driving my bike.

By an simple address changing I could solve my problem:
On the ini file if I swap veTrim1 and veTrim3, the new compiled s19 will work or the ini file is a file only used by TS and other software to know where data is?
I have already made this change and well compiled, but that's all? Or I'm wrong?

Thanks for reading and hope to have an clarification.
Best Regards,

Fabio

Re: MS2 development/coding for dummies

Posted: Mon May 04, 2015 1:11 pm
by racingmini_mtl
The ini file has no impact on the s19 file and the code inside the MS. You need to change the code. Changing the ini will only result in a mismatch between the code and what you edit in TS.

Jean

Re: MS2 development/coding for dummies

Posted: Mon May 04, 2015 1:21 pm
by Fabius72
Thank you Jean for the very fast answer!
Unfortunately that complicate my situation. I feared this kind of answer.
Now I'm lost here, since I really don't know where the code fill the memory's pages.
Any starting point? :roll:

Cheers,
Fabio

Re: MS2 development/coding for dummies

Posted: Tue May 05, 2015 12:54 am
by Fabius72
Hello,
I have made a lot of search through the code, but the code is so complex (lot of respect for you all developers!).
I'm not an experienced coder (I am learning), so it's high complexity makes things very hard for me.

I have found some lines that I think they have to do with trimTables: the key words are page8-11, flash 8-11, pg8-11, EEPROM_ATTR, .eeprom, but I have found nothing about specific memory address, or maybe I don't know how to handle those.

Code: Select all

ms2_extra_vars.h: 

extern const page8_data flash8 EEPROM_ATTR;
extern const page11_data flash11 EEPROM_ATTR;
extern page8_data *pg8_ptr;
extern page11_data *pg11_ptr;   

Code: Select all

ms2_extra_init.c:

pg8_ptr = (page8_data *)&flash8;
pg11_ptr = (page11_data *)&flash11;

Code: Select all

ms2_extra.h:

#define EEPROM_ATTR __attribute__ ((section (".eeprom")))

typedef struct {
    union {
        char ve_trim1L[NO_EXFMAPS][NO_EXFRPMS];
        char ve_trim1S[NO_FMAPS][NO_FRPMS];
    } ve_tables;
    union {
        unsigned int frpm_trimvL[NO_EXFRPMS];
        unsigned int frpm_trimvS[NO_FRPMS];
    } frpm_tables;
    union {
        int fmap_trimvL[NO_EXFMAPS];            // kpa x 10,
        int fmap_trimvS[NO_FMAPS];
    } fmap_tables;
    unsigned int can_outpc_msg;
    unsigned char can_outpc_gp[32]; /* omit unused groups */
    unsigned char spare989[34];
} page8_data;

typedef struct {
    union {
        char ve_trimL[3][NO_EXFMAPS][NO_EXFRPMS];
        char ve_trimS[3][NO_FMAPS][NO_FRPMS];
    } ve_tables;
    union {
        unsigned int frpm_trimvL[3][NO_EXFRPMS];
        unsigned int frpm_trimvS[3][NO_FRPMS];
    } frpm_tables;
    union {
        int fmap_trimvL[3][NO_EXFMAPS];            // kpa x 10,
        int fmap_trimvS[3][NO_FMAPS];
    } fmap_tables;
    int ITB_load_loadvals[10];
    int ITB_load_switchpoints[10];
    unsigned int ITB_load_rpms[10];
    char junk[4];
} page11_data;  

Code: Select all

ms2_extra_main_defaults.h:

const page8_data flash8 EEPROM_ATTR = {
    // 1024 bytes = 1 block flash
......
    // ** VE TRIM 1 ** //
    {{{0,            // ve_trim1[MAP/tps no =0][RPM no = 0]
          0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
......
......

const page11_data flash11 EEPROM_ATTR = {
    // ** VE TRIM 2 ** //
    {{{{0,            // ve_trim[inj2][MAP/tps no =0][RPM no = 0]
           0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
......
......
    // ** VE TRIM 3 ** //
    {{0,            // ve_trim[inj3][MAP/tps no =0][RPM no = 0]
           0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
......
......
    // ** VE TRIM 4 ** //
    {{0,            // ve_trim[inj4][MAP/tps no =0][RPM no = 0]
         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
......
......

Code: Select all

memory.x:

  MEMORY
  {
    ......
    eeprom  (rx)  : ORIGIN = 0x4000, LENGTH = 0x1e00
    ...... 
  }
  PROVIDE (_stack = 0x3fff);
Without a bit of light, all is quite dark now.
I though should be an easy thing to do, but probably an easy thing doesn't mean an easy solution.
For you expert: have my question an very easy solution like I was thinking, or is better to follow a different route?
Thank you for your patience and hope this topic is the right place to speak about that.

Cheers,
Fabio

Re: MS2 development/coding for dummies

Posted: Tue May 05, 2015 6:35 am
by Fabius72
Hi all,
maybe my intuition fetch me on the right way :?:

Jean, I have found your "add_vetrim()" function on the ms2_extra_inj.c:

Code: Select all

void add_vetrim(void)
{
        if (outpc.vetrim[0]) {
                //Use trim table
                tmp_pw1 += (((long)tmp_pw1 * outpc.vetrim[0]) / 10) >> 10;
        }
        if (outpc.vetrim[1]) {
                //Use trim table
                tmp_pw2 += (((long)tmp_pw2 * outpc.vetrim[1]) / 10) >> 10;
        }
        if (outpc.vetrim[2]) {
                //Use trim table
                tmp_pw3 += (((long)tmp_pw3 * outpc.vetrim[2]) / 10) >> 10;
        }
        if (outpc.vetrim[3]) {
                //Use trim table
                tmp_pw4 += (((long)tmp_pw4 * outpc.vetrim[3]) / 10) >> 10;
        }
}


So, on the ms2_extra_main.c file I have discovered one "magic" function that combine tables taken from the memory and the vetrim array:

Code: Select all

                if ((flash8.seq_inj & 0x03) && (pg8_ptr->seq_inj & 0x10)) {
                    int ix;
                    outpc.vetrim[0] = intrp_2dctable_signed(outpc.rpm, outpc.fuelload, NO_EXFRPMS, NO_EXFMAPS,
                            &pg8_ptr->frpm_tables.frpm_trimvL[0], &pg8_ptr->fmap_tables.fmap_trimvL[0], 
                            (unsigned char *)&pg8_ptr->ve_tables.ve_trim1L[0][0]); // in .1 %
                    for (ix = 0; ix < no_inj -1; ix++) {
                        outpc.vetrim[ix+1] = intrp_2dctable_signed(outpc.rpm, outpc.fuelload, NO_EXFRPMS, NO_EXFMAPS,
                                &pg11_ptr->frpm_tables.frpm_trimvL[ix][0], &pg11_ptr->fmap_tables.fmap_trimvL[ix][0], 
                                (unsigned char *)&pg11_ptr->ve_tables.ve_trimL[ix][0][0]); // in .1 %
                    }
ix = 0-1-2
vetrim[0]=trimTable1 cyl1 <-- swap
vetrim[1]=trimTable2 cyl3
vetrim[2]=trimTable3 cyl2 <-- swap
vetrim[3]=trimTable4 cyl4

If I modify the code in this way, I miss something somewhere else or could it works without issue?
Thank you.

Code: Select all

                if ((flash8.seq_inj & 0x03) && (pg8_ptr->seq_inj & 0x10)) {

                    outpc.vetrim[2] = intrp_2dctable_signed(outpc.rpm, outpc.fuelload, NO_EXFRPMS, NO_EXFMAPS,
                                                            &pg8_ptr->frpm_tables.frpm_trimvL[0], 
                                                            &pg8_ptr->fmap_tables.fmap_trimvL[0],             
                                           (unsigned char *)&pg8_ptr->ve_tables.ve_trim1L[0][0]); // in .1 %
           
                    outpc.vetrim[1] = intrp_2dctable_signed(outpc.rpm, outpc.fuelload, NO_EXFRPMS, NO_EXFMAPS,
                                                            &pg11_ptr->frpm_tables.frpm_trimvL[0][0], 
                                                            &pg11_ptr->fmap_tables.fmap_trimvL[0][0], 
                                           (unsigned char *)&pg11_ptr->ve_tables.ve_trimL[0][0][0]); // in .1 %

                    outpc.vetrim[0] = intrp_2dctable_signed(outpc.rpm, outpc.fuelload, NO_EXFRPMS, NO_EXFMAPS,
                                                            &pg11_ptr->frpm_tables.frpm_trimvL[1][0], 
                                                            &pg11_ptr->fmap_tables.fmap_trimvL[1][0], 
                                           (unsigned char *)&pg11_ptr->ve_tables.ve_trimL[1][0][0]); // in .1 %

                    outpc.vetrim[3] = intrp_2dctable_signed(outpc.rpm, outpc.fuelload, NO_EXFRPMS, NO_EXFMAPS,
                                                            &pg11_ptr->frpm_tables.frpm_trimvL[2][0], 
                                                            &pg11_ptr->fmap_tables.fmap_trimvL[2][0], 
                                           (unsigned char *)&pg11_ptr->ve_tables.ve_trimL[2][0][0]); // in .1 %

                    }
Cheers,
Fabio



(EDIT: previously the arrays were wrongly related to 12x12 tables (like tables.ve_trim1S[0][0]), but for the 16x16 need to substitute S with L (like tables.ve_trim1L[0][0]), my fault)

then on the ms2extra.ini swap Trim1 and Trim3 so TS will look and write accordingly on the right place:

Code: Select all

page = 4
      veTrim3         = array ,  S08,    636,      [16x16], "%",   0.0976562500, 1024.0000,   87.60,  112.40,      1 ; * (256 bytes)
      frpm_trim3      = array ,  U16,    892,      [   16], "RPM",      1.00000,   0.00000,    0.00,{rpmhigh},      0 ; * ( 32 bytes)
      fmap_trim3      = array ,  S16,    924,      [   16], { bitStringValue( algorithmUnits ,  algorithm  ) },        0.10000,   0.00000,    0.00,  {loadhigh},      1 ; * ( 32 bytes)


page = 6
      veTrim2         = array ,  S08,      0,      [16x16], "%",   0.0976562500, 1024.0000,   87.60,  112.40,    1 ; * (256 bytes)
      veTrim1         = array ,  S08,      256,    [16x16], "%",   0.0976562500, 1024.0000,   87.60,  112.40,    1 ;
      veTrim4         = array ,  S08,      512,    [16x16], "%",   0.0976562500, 1024.0000,   87.60,  112.40,    1 ;
      frpm_trim2      = array ,  U16,    768,    [   16], "RPM",      1.00000,   0.00000,  0.00,{rpmhigh},      0 ; * ( 32 bytes)
      frpm_trim1      = array ,  U16,    800,    [   16], "RPM",      1.00000,   0.00000,  0.00,{rpmhigh},      0 ; * ( 32 bytes)
      frpm_trim4      = array ,  U16,    832,    [   16], "RPM",      1.00000,   0.00000,  0.00,{rpmhigh},      0 ; * ( 32 bytes)
      fmap_trim2      = array ,  S16,    864,    [   16], { bitStringValue( algorithmUnits ,  algorithm  ) },      0.10000,   0.00000,  0.00,  {loadhigh},      1 ; * ( 32 bytes)
      fmap_trim1      = array ,  S16,    896,    [   16], { bitStringValue( algorithmUnits ,  algorithm  ) },      0.10000,   0.00000,  0.00,  {loadhigh},      1 ; * ( 32 bytes)
      fmap_trim4      = array ,  S16,    928,    [   16], { bitStringValue( algorithmUnits ,  algorithm  ) },      0.10000,   0.00000,  0.00,  {loadhigh},      1 ; * ( 32 bytes)

In this way I got it working!
Cheers,
Fabio

Re: MS2 development/coding for dummies

Posted: Tue May 05, 2015 11:32 pm
by Fabius72
Hello,
compiled correctly, but without the closing brace, since the function doesn't finish there.
Unfortunately I'll try that only at the end of this month, since I'm not at my town until then.
I though about status1=1 (need burn) flag that maybe couldn't work properly, but isn't a too bad thing, I hope.
Hoping also that this is not a too bad practice (please, excuse me in this case), but after trimTables tuned (if everything will work, obviously), I'll reload the official code.
I would have a billion of questions about the code, but I don't know how to have answers. Would be a very good thing an flow chart or some documentations about what variables used are... but I know that all take time and you developers have a trillion of things to do.
In any case, this was a good and helpful experience for me.

Best Regards,
Fabio