MS2 development/coding for dummies

This is a forum for discussing the development and testing of alpha MS2/Extra code. Documentation
(Runs on MS2 and Microsquirt)

Moderators: muythaibxr, jsmcortina

Re: MS2 development/coding for dummies

Postby elsp1991 » Thu May 17, 2012 11:53 am

Hey guys I'm working for my Fsae team and i want to implement a traction control so i want to be able to change the advance on the run and cut some spark events if spark retard is not enough. And i was thinking if it is possible to do something wrong that could make ms2 unprogramable?
elsp1991
MS/Extra Newbie
 
Posts: 2
Joined: Sat Mar 19, 2011 10:14 am

Re: MS2 development/coding for dummies

Postby gslender » Fri May 18, 2012 1:41 pm

elsp1991 wrote:Hey guys I'm working for my Fsae team and i want to implement a traction control so i want to be able to change the advance on the run and cut some spark events if spark retard is not enough.


What you want to do is possible, but on an ms2 the big issue will be available inputs to detect when you've lost traction.

And i was thinking if it is possible to do something wrong that could make ms2 unprogramable?


It is, but you can just trip the boot jumper and reset the ms2 back to a state that will allow serial programming again.

I've had to rely on that a few times when I crash the CPU or do some code loops that stop serial interrupts from being active.

G
Mazda MX5 91 NA6 LE | M45 Mini SC | 4-2-1 Extractors & HI-Flow Exhaust | HSD HR Coilovers | MS2 DIYPNP Full Seq running ms2extra pre3.3alpha5 gslender v2.8 | Toyota COP | RX8 425cc Inj | W2A Intercooled
User avatar
gslender
Super MS/Extra'er
 
Posts: 1028
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia

Re: MS2 development/coding for dummies

Postby elsp1991 » Mon May 21, 2012 3:10 am

Ok this is the thing i want to do with MS2. An avr will produce a analog output. And i have some question

1. The thing is that i dont know the internal variable of adc7, do you know where i can find this info.
2. should i put this tile in several places or just before the end of the main loop? cause i notice that ms2 do launch in several lines??!!

3. user_value_1 = my spark retard
user_value_2 = adc prescaler in order to convert 0-1024 range to 0-50
(????adc7???) = adc7 input signal


Code: Select all
                                                //my code
user_value_1 = user_value_2*(????adc7???);

   if (user_value_1 >= 20) //spark retard is not enough cut some events
      {
      user_value_1 = 20;

      spk_cutx = 4;
      spk_cuty = 7;

      outpc.status2 |= status2_spkcut; //do spark cut with above x,y
      }

   else if (user_value_1 <= 20) //spark retard is enough dont need to cut events
      {
      outpc.status2 &= ~status2_spkcut; //disable spark cut
      }
              else if (user_value_1 <=0)
              {
              user_value_1 = 0;
              outpc.status2 &= ~status2_spkcut; //disable spark cut
              }

lsum += user_value_1;     
                                                  //end of my code




 outpc.adv_deg = (int)lsum;  // Report advance before we fudge it
elsp1991
MS/Extra Newbie
 
Posts: 2
Joined: Sat Mar 19, 2011 10:14 am

Re: MS2 development/coding for dummies

Postby m3ltd0wn » Tue Jun 12, 2012 12:44 am

take a look in megasquirt 1 and see how traction control/anti-rev is done, it is a crude implementation but it does it's job, too bad it didn't make it in ms2-extra code, it would be very usefull even if it was just rpm based.
m3ltd0wn
Helpful MS/Extra'er
 
Posts: 135
Joined: Sun Oct 03, 2010 2:32 am

Re: MS2 development/coding for dummies

Postby jsmcortina » Tue Jun 12, 2012 1:24 am

elsp1991 wrote:1. The thing is that i dont know the internal variable of adc7, do you know where i can find this info.

Example on how to search for stuff:
Code: Select all
[jsm@jsm2 ms2extra]$ grep -i adc7 *.c
ms2_extra_main.c:  retard based on ADC7 sensor.
ms2_extra_misc.c:            outpc.adc7 = ATD0DR7;
ms2_extra_misc.c:            tmpadc = outpc.adc7;
ms2_extra_misc.c:            tmpadc = outpc.adc7;
ms2_extra_misc.c:        txbuf.adc7 = outpc.adc7;

James
I can supply, repair or upgrade Megasquirts in UK.

My Success story: viewtopic.php?f=104&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
jsmcortina
Site Admin
 
Posts: 26003
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK

Re: MS2 development/coding for dummies

Postby Wergilius » Thu Jun 14, 2012 5:46 am

i use this editor for my small changes in the code, "find in files" and nice color coding makes life a little more easy.
http://www.editplus.com/
User avatar
Wergilius
Helpful MS/Extra'er
 
Posts: 140
Joined: Fri Sep 16, 2005 12:50 pm
Location: Stockholm, Sweden

Re: MS2 development/coding for dummies

Postby Peter Florance » Mon Dec 24, 2012 3:13 am

jsmcortina wrote:
Martin Young wrote:Anyway, I try to follow the instruction but having entered the tar command with the path to get to the tools.tar.gz file, nothing appears to happen. I don't know if anything ought to happen, but nothing does.

If it didn't give an error message then it worked.
If you prefer to see tons of output, use:

cd /
tar xvfz <path>/tools.tar.gz

To see if it extracted:
ls -l /usr/bin/m9s*

James

Is that what one would do in Linux? I'd like to compile some code to test CANBus in BMW setup (apparently different ID's and multipliers).
When I tried above I got a bunch of errors, the last few being:

tar: usr/m68hc11-elf/lib/m9s12x/libm.a: Cannot open: No such file or directory
usr/m68hc11-elf/lib/m9s12x/libbcc.a
tar: usr/m68hc11-elf/lib/m9s12x/libbcc.a: Cannot open: No such file or directory
usr/m68hc11-elf/lib/libbcc.a
tar: usr/m68hc11-elf/lib/libbcc.a: Cannot open: No such file or directory
tar: Exiting with failure status due to previous errors


I'm really pretty much an idiot in Linux. :RTFM:
Peter Florance
PF Tuning
81 BMW Euro 528i ESP Car
60-2 Wheel LS2 Coils, Low Z Inj
Check your grounds: http://www.msextra.com/doc/general/grounding.html
User avatar
Peter Florance
Super MS/Extra'er
 
Posts: 3330
Joined: Fri Apr 02, 2004 8:40 pm
Location: Virginia Beach, VA

Re: MS2 development/coding for dummies

Postby robs » Tue Dec 25, 2012 3:07 pm

Not exactly sure what's wrong. A couple of things:

  1. you must be root to write to these directories. (either use sudo before the tar command or do "sudo su -" to log in as root full time).
  2. if you have put the tools.tar.gz file in /tmp, the commands you want to type are:
Code: Select all
cd /
tar xvfz /tmp/tools.tar.gz

You should then see a list of the various files and directories as they are created.

All that said, the error messages don't really look like you've got a problem with either of these things. Just can't think of anything else to suggest.

Have fun,

Rob.
robs
Experienced MS/Extra'er
 
Posts: 349
Joined: Sun Jan 17, 2010 4:26 pm
Location: Sydney, Australia

Re: MS2 development/coding for dummies

Postby Peter Florance » Tue Dec 25, 2012 5:52 pm

I'll try that.
Thanks!
Peter Florance
PF Tuning
81 BMW Euro 528i ESP Car
60-2 Wheel LS2 Coils, Low Z Inj
Check your grounds: http://www.msextra.com/doc/general/grounding.html
User avatar
Peter Florance
Super MS/Extra'er
 
Posts: 3330
Joined: Fri Apr 02, 2004 8:40 pm
Location: Virginia Beach, VA

Re: MS2 development/coding for dummies

Postby jsmcortina » Thu Dec 27, 2012 5:00 pm

I'd also suggest that you use the current build tools release and see the instructions it includes.

http://www.msextra.com/tools

James
I can supply, repair or upgrade Megasquirts in UK.

My Success story: viewtopic.php?f=104&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
jsmcortina
Site Admin
 
Posts: 26003
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK

Re: MS2 development/coding for dummies

Postby srmeister » Wed Jun 19, 2013 4:38 am

James,
i downloaded the 2012 version of the linux toolchain, extracted and installed it according to README.

Now my problem is, the makefiles point to m9s12x-elf-gcc but there is no such files included in the tar archive. Only versions for m9s11.
What to do in this case? use 2010 version or rename the gcc files?

thanks, Stefan
srmeister
MS/Extra Newbie
 
Posts: 28
Joined: Thu Dec 24, 2009 8:49 am

Re: MS2 development/coding for dummies

Postby jsmcortina » Wed Jun 19, 2013 8:57 am

What code are you trying to compile?

The most likely fix is to edit the appropriate Makefile to replace
Code: Select all
PROGPREF=$(BINDIR)m9s12x-elf-
with
Code: Select all
PROGPREF=$(BINDIR)m68hc11-elf-

James
I can supply, repair or upgrade Megasquirts in UK.

My Success story: viewtopic.php?f=104&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
jsmcortina
Site Admin
 
Posts: 26003
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK

Re: MS2 development/coding for dummies

Postby srmeister » Wed Jun 19, 2013 11:44 am

i was trying the 3.2.5 release.
i do see now that its fixed in latest beta.

thx
srmeister
MS/Extra Newbie
 
Posts: 28
Joined: Thu Dec 24, 2009 8:49 am

Re: MS2 development/coding for dummies

Postby aut0m4tic1 » Sun Jun 23, 2013 9:38 am

Hi all:
I've been trying to get a build to succeed, but always get errors. Does any of this mean anything to you. The folders are there and I have edited the make files. Thanks in advance for taking a look.

cory@satellite /cygdrive/c/cygwin/ms2extra_3.2.5_release/ms2extra
$ make release
rm -f -rf release megasquirt-ii.ini.ms2extra megasquirt-ii.ini.us2extra *~
make --makefile Makefile.ms2 clean
which: no m68hc11-elf-gcc in (/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/windows/system32:/cygdrive/c/windows:/cygdrive/c/windows/System32/Wbem:/cygdrive/c/windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon:/usr/lib/lapack)
ls: cannot access /usr/bin/m68hc11-elf-gcc: No such file or directory
ls: cannot access c:cygwin/usr/bin/m68hc11-elf-gcc: No such file or directory
make[1]: Entering directory `/cygdrive/c/cygwin/ms2extra_3.2.5_release/ms2extra'
rm -f -f ms2_extra.elf
rm -f -f ms2_extra.s19
rm -f -f ms2_extra.dmp
rm -f -f ms2_extra.map
rm -f -f ms2_extra_main.o ms2_extra_can.o ms2_extra_can_isr.o ms2_extra_ego.o ms2_extra_ign.o ms2_extra_ign_wheel.o ms2_extra_misc.o premain.o ms2_extra_init.o sigs.o ms2_extra_ign_in.o ms2_extra_inj.o ms2_extra_idle.o ms2_extra_user.o msii_flash_gcc.o ms2_sermon.o ms2_conferr.o ms2_extra_burner.o ms2_extra_burnfactor.o isr_inj.o isr_sci.o isr_rtc.o ms2_extra_asm.o isr_timerovf.o isr_ign.o crc32.o interp.o
rm -f -f us_opt_c.h
rm -f -f us_opt_asm.inc
make[1]: Leaving directory `/cygdrive/c/cygwin/ms2extra_3.2.5_release/ms2extra'
make --makefile Makefile.us clean
which: no m68hc11-elf-gcc in (/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/windows/system32:/cygdrive/c/windows:/cygdrive/c/windows/System32/Wbem:/cygdrive/c/windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon:/usr/lib/lapack)
ls: cannot access /usr/bin/m68hc11-elf-gcc: No such file or directory
cygwin warning:
MS-DOS style path detected: c:/usr/bin/m68hc11-elf-gcc
Preferred POSIX equivalent is: /cygdrive/c/usr/bin/m68hc11-elf-gcc
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.h ... -pathnames
ls: cannot access c:/usr/bin/m68hc11-elf-gcc: No such file or directory
make[1]: Entering directory `/cygdrive/c/cygwin/ms2extra_3.2.5_release/ms2extra'
rm -f -f ms2_extra_us.elf
rm -f -f ms2_extra_us.s19
rm -f -f ms2_extra_us.dmp
rm -f -f ms2_extra_us.map
rm -f -f ms2_extra_main.o ms2_extra_can.o ms2_extra_can_isr.o ms2_extra_ego.o ms2_extra_ign.o ms2_extra_ign_wheel.o ms2_extra_misc.o premain.o ms2_extra_init.o sigs.o ms2_extra_ign_in.o ms2_extra_inj.o ms2_extra_idle.o ms2_extra_user.o msii_flash_gcc.o ms2_sermon.o ms2_conferr.o ms2_extra_burner.o ms2_extra_burnfactor.o isr_inj.o isr_sci.o isr_rtc.o ms2_extra_asm.o isr_timerovf.o isr_ign.o crc32.o interp.o
rm -f -f us_opt_c.h
rm -f -f us_opt_asm.inc
make[1]: Leaving directory `/cygdrive/c/cygwin/ms2extra_3.2.5_release/ms2extra'
make -C bootstrap_src clean
make[1]: Entering directory `/cygdrive/c/cygwin/ms2extra_3.2.5_release/ms2extra/bootstrap_src'
rm -f -f bootstrap.elf
rm -f -f bootstrap.s19
rm -f -f bootstrap.dmp
rm -f -f bootstrap.map
rm -f -f ms2_extra_main.o premain.o sigs.o msii_flash_gcc.o ms2_sermon.o isr_sci.o ms2_extra_asm.o
make[1]: Leaving directory `/cygdrive/c/cygwin/ms2extra_3.2.5_release/ms2extra/bootstrap_src'
rm -f -f ms2_extra_ign.o ms2_extra_ign_in.o ms2_extra_init.o ms2_extra_misc.o isr_ign.o isr_inj.o isr_rtc.o ms2_extra_main.o ms2_extra_idle.o ms2_extra_inj.o sigs.o
make --makefile Makefile.ms2
which: no m68hc11-elf-gcc in (/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/windows/system32:/cygdrive/c/windows:/cygdrive/c/windows/System32/Wbem:/cygdrive/c/windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon:/usr/lib/lapack)
ls: cannot access /usr/bin/m68hc11-elf-gcc: No such file or directory
ls: cannot access c:cygwin/usr/bin/m68hc11-elf-gcc: No such file or directory
make[1]: Entering directory `/cygdrive/c/cygwin/ms2extra_3.2.5_release/ms2extra'
echo '// setup for Megasquirt' > us_opt_c.h
echo '; setup for Megasquirt' > us_opt_asm.inc
m68hc11-elf-gcc -g -Wall -Werror -O -fomit-frame-pointer -m68hcs12 -mshort -msoft-reg-count=5 -mauto-incdec -fsigned-char -DGCC_BUILD -c ms2_extra_main.c
make[1]: m68hc11-elf-gcc: Command not found
Makefile.ms2:47: recipe for target `ms2_extra_main.o' failed
make[1]: *** [ms2_extra_main.o] Error 127
make[1]: Leaving directory `/cygdrive/c/cygwin/ms2extra_3.2.5_release/ms2extra'
Makefile:16: recipe for target `megasquirt' failed
make: *** [megasquirt] Error 2

cory@satellite /cygdrive/c/cygwin/ms2extra_3.2.5_release/ms2extra
$
aut0m4tic1
Experienced MS/Extra'er
 
Posts: 197
Joined: Mon Feb 06, 2012 12:32 pm
Location: Layton, Utah

Re: MS2 development/coding for dummies

Postby jsmcortina » Sun Jun 23, 2013 9:44 am

Before trying to make a release, I'd suggest building a single target.

Did you check through the error messages?
Looks like you do not have the build tools installed or they aren't installed in the correct place.

James
I can supply, repair or upgrade Megasquirts in UK.

My Success story: viewtopic.php?f=104&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
jsmcortina
Site Admin
 
Posts: 26003
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK

Re: MS2 development/coding for dummies

Postby aut0m4tic1 » Sun Jun 23, 2013 11:44 am

James:
Thanks! I'll give that a try. I'm new to tar and gz so i'm not sure I did it right either. I'll double check and post results.
Thanks!
Cory
aut0m4tic1
Experienced MS/Extra'er
 
Posts: 197
Joined: Mon Feb 06, 2012 12:32 pm
Location: Layton, Utah

Re: MS2 development/coding for dummies

Postby aut0m4tic1 » Mon Jun 24, 2013 11:14 am

James:
Still no success. I have a C:/cgywin folder and inside are several folders including the ms firmware and the usr files. When I unzip/untar the tools into the cygwin root folder I get a folder named tools.tar. The tools.tar folder also has a usr file inside. Can you help me understand how,the file structure has to look to make this work?

In the usr/bin folder there are two m68hc11-elf-gcc exe files. One has a version number behind it and is abt 180kb while the plain one is 0kb not sure this is significant.
I appreciate your help.
Cory
aut0m4tic1
Experienced MS/Extra'er
 
Posts: 197
Joined: Mon Feb 06, 2012 12:32 pm
Location: Layton, Utah

Re: MS2 development/coding for dummies

Postby jsmcortina » Mon Jun 24, 2013 4:33 pm

Did you follow the instructions in the README file?

You will expect to see the files that the Makefile is looking for
e.g. as viewed by Cygwin, /usr/bin/m68hc11-elf-gcc

James
I can supply, repair or upgrade Megasquirts in UK.

My Success story: viewtopic.php?f=104&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
jsmcortina
Site Admin
 
Posts: 26003
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK

Re: MS2 development/coding for dummies

Postby aut0m4tic1 » Mon Jun 24, 2013 7:26 pm

James:
I Googled how the cygwin tar function works and was able to untar the tools.tar.gz into the cygwin folder. I now have the m68hc11-elf-gcc file with a 276kb size. I still get the file or folder do not exist errors even though I have re-booted and also ran cygwin as administrator. I am running Win7 if that matters. I have edited line 13 of the make.us file from: PROGPREF=$ (BINDIR)/m9s12x-elf- to: PROGPREF=$ (BINDIR)/m68hc11-elf-
I notice that on line 11 there are 4 references to "usr/bin/m9s12x-elf-gcc do these need to be edited also?
Sorry to be a pain, I did read the README, I have never used linux in my life. I've only ever programmed PIC, Arduino and Picaxe controllers, so this is a significant jump in technology for me.
Thanks
Cory
aut0m4tic1
Experienced MS/Extra'er
 
Posts: 197
Joined: Mon Feb 06, 2012 12:32 pm
Location: Layton, Utah

Re: MS2 development/coding for dummies

Postby aut0m4tic1 » Thu Jun 27, 2013 4:03 pm

Ok, so after hopefully learning how to install the build tools I still get errors. Being unfamiliar with Unix/Linux, I'm not sure what all the errors mean or how to go about fixing them so here is a screen dump of the errors i am getting. If you have any ideas on how to get this going I would be very grateful.


cory@satellite /cygdrive/c/cygwin/ms2extra_3.2.1_release/ms2extra_3.2.1_release/ms2extra
$ make us
make --makefile Makefile.us
which: no m9s12x-elf-gcc in (/usr/local/bin:/usr/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/windows/system32:/cygdrive/c/windows:/cygdrive/c/windows/System32/Wbem:/cygdrive/c/windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon:/usr/lib/lapack)
ls: cannot access /usr/bin/m9s12x-elf-gcc: No such file or directory
cygwin warning:
MS-DOS style path detected: c:/usr/bin/m9s12x-elf-gcc
Preferred POSIX equivalent is: /cygdrive/c/usr/bin/m9s12x-elf-gcc
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.h ... -pathnames
ls: cannot access c:/usr/bin/m9s12x-elf-gcc: No such file or directory
make[1]: Entering directory `/cygdrive/c/cygwin/ms2extra_3.2.1_release/ms2extra_3.2.1_release/ms2extra'
echo '#define MICROSQUIRT' > us_opt_c.h
echo '.set MICROSQUIRT, 1' > us_opt_asm.inc
/m68hc11-elf-gcc -g -Wall -Werror -O -fomit-frame-pointer -m68hcs12 -mshort -msoft-reg-count=5 -mauto-incdec -fsigned-char -DGCC_BUILD -c ms2_extra_main.c
make[1]: /m68hc11-elf-gcc: Command not found
Makefile.us:48: recipe for target `ms2_extra_main.o' failed
make[1]: *** [ms2_extra_main.o] Error 127
make[1]: Leaving directory `/cygdrive/c/cygwin/ms2extra_3.2.1_release/ms2extra_3.2.1_release/ms2extra'
Makefile:18: recipe for target `microsquirt' failed
make: *** [microsquirt] Error 2

I have also attached my make file to make sure I have edited it correctly and in the right places.

#*******************************************************************
#* Makefile for MSII
#*
#* COPYRIGHT: Philip L Johnson 2004
#* This header must appear on all derivatives of this file.
#*
#*******************************************************************
# Extended for MS2/Extra by Ken Culver and James Murray 2006
# $Id: Makefile.us,v 1.11 2011-11-12 17:26:06 jsmcortina Exp $

BINDIR:=$(shell ls /usr/bin/m9s12x-elf-gcc c:/usr/bin/m9s12x-elf-gcc `which m9s12x-elf-gcc` | head -1 | sed -e's,m9s12x-elf-gcc,,g' 2> /dev/null)

PROGPREF=$(BINDIR)/m68hc11-elf-

CC = $(PROGPREF)gcc
OBJCOPY = $(PROGPREF)objcopy
OBJDUMP = $(PROGPREF)objdump
NM = $(PROGPREF)nm

CFLAGS = -g -Wall -Werror -O -fomit-frame-pointer -m68hcs12 -mshort -msoft-reg-count=5 -mauto-incdec -fsigned-char -DGCC_BUILD

LDFLAGS = -Wl,-defsym,vectors_addr=0xff80,-m,m68hc12elfb,-T,m68hc12elfb.x

CSRCS=ms2_extra_main.c ms2_extra_can.c ms2_extra_can_isr.c ms2_extra_ego.c ms2_extra_ign.c ms2_extra_ign_wheel.c\
ms2_extra_misc.c \
premain.c ms2_extra_init.c sigs.c ms2_extra_ign_in.c ms2_extra_inj.c \
ms2_extra_idle.c ms2_extra_user.c

ASRCS=msii_flash_gcc.s ms2_sermon.s ms2_conferr.s ms2_extra_burner.s \
ms2_extra_burnfactor.s isr_inj.s isr_sci.s isr_rtc.s ms2_extra_asm.s \
isr_timerovf.s isr_ign.s crc32.s interp.s

OBJS=$(CSRCS:.c=.o)
AOBJS= $(ASRCS:.s=.o)

all: setmicrosquirt ms2_extra_us.dmp ms2_extra_us.elf ms2_extra_us.s19

#in order to safely build both targets, must remove existing object code
setmicrosquirt:
# touch ms2_extra.h
echo '#define MICROSQUIRT' > us_opt_c.h
echo '.set MICROSQUIRT, 1' > us_opt_asm.inc

$(AOBJS): %.o: %.s
$(CC) $(CFLAGS) -c $<

$(OBJS): %.o: %.c cltfactor.inc egofactor.inc matfactor.inc hcs12def.h flash.h ms2_extra.h
$(CC) $(CFLAGS) -c $<

ms2_extra_us.elf: $(OBJS) $(AOBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o ms2_extra_us.elf $(OBJS) $(AOBJS)

ms2_extra_us.s19: ms2_extra_us.elf
$(OBJCOPY) --output-target=srec \
--only-section=.text3 \
--only-section=.rodata \
--only-section=.vectors \
--only-section=.eeprom \
--only-section=.lookup --change-section-lma .lookup=0x3Ca400 \
--only-section=.text3c --change-section-lma .text3c=0x3C8000 \
--only-section=.text3d --change-section-lma .text3d=0x3D8000 \
--only-section=.text3b --change-section-lma .text3b=0x3B8000 \
--only-section=.text3a --change-section-lma .text3a=0x3A8000 \
--only-section=.text39 --change-section-lma .text39=0x398000 \
--only-section=.text38 --change-section-lma .text38=0x388000 \
--only-section=.lookup \
--only-section=.text \
ms2_extra_us.elf ms2_extra_us.s19
$(NM) ms2_extra_us.elf | sort > ms2_extra_us.map

ms2_extra_us.dmp: ms2_extra_us.elf
$(OBJDUMP) -Ssdp ms2_extra_us.elf > ms2_extra_us.dmp

PHONY: clean
clean:
$(RM) -f ms2_extra_us.elf
$(RM) -f ms2_extra_us.s19
$(RM) -f ms2_extra_us.dmp
$(RM) -f ms2_extra_us.map
$(RM) -f $(OBJS) $(AOBJS)
$(RM) -f us_opt_c.h
$(RM) -f us_opt_asm.inc
Sorry for the SUPER long post, but the board wont accept a .us or .docx format and everything else I tried to save it as destroyed the formatting so it wouldn't work otherwise.

Thanks again
Cory
aut0m4tic1
Experienced MS/Extra'er
 
Posts: 197
Joined: Mon Feb 06, 2012 12:32 pm
Location: Layton, Utah

PreviousNext

Return to MS2/Extra Development

Who is online

Users browsing this forum: No registered users and 3 guests