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: jsmcortina, muythaibxr

MS2 development/coding for dummies

Postby Martin Young » Tue Jan 10, 2012 3:45 pm

Can anyone help me understand how to begin the task of looking through the MS code (just out of curiosity, to see if I can understand any of it)?

I'm 20+ years out of date, and even then I was working in Fortran or 8-bit assembler, but I thought "how hard can this be?". So I tried following the clues on another couple of threads here.

Downloaded Cygwin, which gives me a nice window with a command line prompt. Stared helplessly at that for a while. Quit.

Next I downloaded the windows zip file of tools. And on second thoughts the Linux version too. Now I'm going round in circles trying to copy what others did in the couple of threads I found. Getting nowhere and not at all aware of what I'm doing...

Grateful for any nudges in the right direction. Please be gentle. Even if I understand in principle what you are saying, syntax will probably fly harmlessly over my head. I have zero knowledge of Unix.
Martin Young
Helpful MS/Extra'er
 
Posts: 77
Joined: Fri Feb 25, 2011 6:31 am

Re: MS2 development/coding for dummies

Postby jsmcortina » Tue Jan 10, 2012 3:49 pm

If you just want to look at the code (not change and recompile it) then you don't need Cygwin or the tools.

The whole source for MS2/Extra is included within the MS2/Extra firmware zips in the "ms2extra" subdirectory.
The C files are *.c
The C headers are *.h
The assembler files are *.s
The assembler includes are *.inc

Fire up your chosen text editor, open a file and start reading.

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: 27817
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK

Re: MS2 development/coding for dummies

Postby gslender » Tue Jan 10, 2012 3:55 pm

Ok, let me start ya off...

The main developers (Ken/James/Jean) I believe use Linux as the main platform for development, but you can successfully build and work in Windoze too !!

As you've done, download and install Cygwin and make sure you include the entire Development packages. It will ensure GCC, make and the needed libraries are installed.

Also, download Windows zip : s12buildtools-win32.zip from http://www.msextra.com/tools/

Exract that zip and follow README.txt and untar the gzip'd archive.

In the c:\cygwin folder, create and expand a MS2 (or MS3) release such that it looks like this ...

C:\cygwin\ms2extra_3.2.1_release\

Then run a Cygwin command shell and then "cd /ms2extra_3.2.1_release/ms2extra/"

You should then be able to run "make release" and if all goes well, it should compile and build a release for both megasquirt and microsquirt.

Done.
Mazda MX5 + MS3 Pro
User avatar
gslender
Super MS/Extra'er
 
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia

Re: MS2 development/coding for dummies

Postby Martin Young » Tue Jan 10, 2012 3:58 pm

Thanks. I'd tried opening a couple of files in Notepad but the formatting was messed up. Just tried Wordpad and suddenly it looks more like something humans might read.
Martin Young
Helpful MS/Extra'er
 
Posts: 77
Joined: Fri Feb 25, 2011 6:31 am

Re: MS2 development/coding for dummies

Postby gslender » Tue Jan 10, 2012 4:00 pm

Martin Young wrote:Thanks. I'd tried opening a couple of files in Notepad but the formatting was messed up. Just tried Wordpad and suddenly it looks more like something humans might read.


You'll need a text editor that is designed to be used for coding (unix and windows) - there are bazillions out there, but here one that should work for you http://notepad-plus-plus.org/

g
Mazda MX5 + MS3 Pro
User avatar
gslender
Super MS/Extra'er
 
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia

Re: MS2 development/coding for dummies

Postby racingmini_mtl » Tue Jan 10, 2012 4:01 pm

gslender wrote:The main developers (Ken/James/Jean) I believe use Linux as the main platform for development, but you can successfully build and work in Windoze too !!

Just FYI, I use Windows (with cygwin). So it does work fine. And I use Notepad++ as my editor.

Jean
jbperf.com Main site . . . . . . . . . . . . . . . . . . . . . . jbperf.com Forum
Image
racingmini_mtl
Super MS/Extra'er
 
Posts: 6436
Joined: Sun May 02, 2004 6:51 am
Location: Quebec, Canada

Re: MS2 development/coding for dummies

Postby gslender » Tue Jan 10, 2012 4:02 pm

racingmini_mtl wrote:
gslender wrote:The main developers (Ken/James/Jean) I believe use Linux as the main platform for development, but you can successfully build and work in Windoze too !!

Just FYI, I use Windows (with cygwin). So it does work fine. And I use Notepad++ as my editor.

Jean


Me too! I was too afraid to come out of the closet with that... fear of being bashed by Ken or James for being such a girl and not using *nix. :lol:
Mazda MX5 + MS3 Pro
User avatar
gslender
Super MS/Extra'er
 
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia

Re: MS2 development/coding for dummies

Postby jsmcortina » Tue Jan 10, 2012 4:28 pm

gslender wrote:Me too! I was too afraid to come out of the closet with that... fear of being bashed by Ken or James for being such a girl and not using *nix. :lol:

I use Linux because I prefer it, not as some kind of crusade! Each to his own.

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: 27817
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK

Re: MS2 development/coding for dummies

Postby Martin Young » Tue Jan 10, 2012 4:32 pm

gslender wrote:...
Exract that zip and follow README.txt and untar the gzip'd archive.
...

OK. Here I'm stuck. I read this:

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

... and I don't know what it means.

"cd" looks like "change directory" I vaguely recall from DOS, but the "/" is a mystery.

As for "tar", well having typed "info tar" into Cygwin it looks like i have a day's reading to do. :?

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.
Martin Young
Helpful MS/Extra'er
 
Posts: 77
Joined: Fri Feb 25, 2011 6:31 am

Re: MS2 development/coding for dummies

Postby robs » Tue Jan 10, 2012 4:45 pm

Fortran to C is a pretty big leap (Fortran IV and 77 had no pointers, no data structures and pretty feeble control structures and these are fundamental in C) and 20+ years of accumulated cobwebs won't have helped, so you should probably read up on C programming. Depending on which processor you were using, the assembly language might be surprisingly familiar. In the early '80s the Motorola 6809 was an elegant 8-bit processor that I enjoyed programming. It was quite a nostalgia kick 25 years on to see the Megasquirt processor's assembly language so similar. But if you were working with Z80/808x or 68k, your earlier assembly language experience won't be so applicable.

Plenty to delve into. At some stage, you may find my tutorial helps you get started understanding some of the oddities of this all-in-one processor. (see further down the subject headings)

Have fun,

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

Re: MS2 development/coding for dummies

Postby jsmcortina » Tue Jan 10, 2012 4:59 pm

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
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: 27817
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK

Re: MS2 development/coding for dummies

Postby Martin Young » Tue Jan 10, 2012 5:12 pm

robs wrote:... Depending on which processor you were using, the assembly language might be surprisingly familiar. In the early '80s the Motorola 6809 was an elegant 8-bit processor that I enjoyed programming. It was quite a nostalgia kick 25 years on to see the Megasquirt processor's assembly language so similar. But if you were working with Z80/808x or 68k, your earlier assembly language experience won't be so applicable...


Last time I looked at assembler was a couple of years ago when I spent ages on a more or less futile attempt to decode my '94 MX-5's ECU. I was seeing 6811 code in my sleep. Pity if it's irrelevant. :D
Martin Young
Helpful MS/Extra'er
 
Posts: 77
Joined: Fri Feb 25, 2011 6:31 am

Re: MS2 development/coding for dummies

Postby jsmcortina » Tue Jan 10, 2012 5:20 pm

Martin Young wrote:I was seeing 6811 code in my sleep. Pity if it's irrelevant. :D

If you know 6811, then the assembler sections should be familiar as the 9S12 CPUs are a superset of the 6811 family.

I have been thinking about drawing up a block diagram / flowchart of the code to help understanding. But these things all take time.

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: 27817
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK

Re: MS2 development/coding for dummies

Postby muythaibxr » Wed Jan 11, 2012 12:54 pm

gslender wrote:
racingmini_mtl wrote:
gslender wrote:The main developers (Ken/James/Jean) I believe use Linux as the main platform for development, but you can successfully build and work in Windoze too !!

Just FYI, I use Windows (with cygwin). So it does work fine. And I use Notepad++ as my editor.

Jean


Me too! I was too afraid to come out of the closet with that... fear of being bashed by Ken or James for being such a girl and not using *nix. :lol:



You're such a girl. You should use *nix.

:)

Just kidding.

I don't care. I prefer linux because the tools used in windows (cygwin) are ridiculously slow and klunky compared with just using the tools natively in linux (or FreeBSD, which I also use).

Ken
Megasquirt is not for use on pollution controlled vehicles. Any advice I give is for off road use only.

:msq:
muythaibxr
Site Admin
 
Posts: 7418
Joined: Thu Oct 14, 2004 12:48 pm

Re: MS2 development/coding for dummies

Postby TBI_Master » Wed Jan 11, 2012 1:25 pm

gslender wrote:Ok, let me start ya off...

The main developers (Ken/James/Jean) I believe use Linux as the main platform for development, but you can successfully build and work in Windoze too !!

As you've done, download and install Cygwin and make sure you include the entire Development packages. It will ensure GCC, make and the needed libraries are installed.

Also, download Windows zip : s12buildtools-win32.zip from http://www.msextra.com/tools/

Exract that zip and follow README.txt and untar the gzip'd archive.

In the c:\cygwin folder, create and expand a MS2 (or MS3) release such that it looks like this ...

C:\cygwin\ms2extra_3.2.1_release\

Then run a Cygwin command shell and then "cd /ms2extra_3.2.1_release/ms2extra/"

You should then be able to run "make release" and if all goes well, it should compile and build a release for both megasquirt and microsquirt.

Done.


Is that it? Oh boy...
TBI_Master
Experienced MS/Extra'er
 
Posts: 151
Joined: Wed Dec 21, 2011 11:54 am

Re: MS2 development/coding for dummies

Postby TBI_Master » Thu Jan 12, 2012 2:55 pm

So when 'make" returns a 'make: command not found'... Is because that package was not selected when installing cygwin?
I'm already in the ms2extra directory, Am I missing an argument or something?
TBI_Master
Experienced MS/Extra'er
 
Posts: 151
Joined: Wed Dec 21, 2011 11:54 am

Re: MS2 development/coding for dummies

Postby gslender » Thu Jan 12, 2012 3:03 pm

TBI_Master wrote:So when 'make" returns a 'make: command not found'... Is because that package was not selected when installing cygwin?
I'm already in the ms2extra directory, Am I missing an argument or something?


Yep. You need to install the Development packages with Cygwin.

G
Mazda MX5 + MS3 Pro
User avatar
gslender
Super MS/Extra'er
 
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia

Re: MS2 development/coding for dummies

Postby Jobro » Sun Jan 29, 2012 4:58 am

Hi,

I do embedded C,testing, calibrations etc for a paid living. Mostly Texas Instruments MSP430F and TMS320F MCU's. We have always just used a fully featured IDE that is basically download a 4gb package and install it, next next next, done click the right cpu and it 'just works'. I have used Hightide C for PIC18F, mplab for PIC16F asm. We also used minide with a HC12 at university. Any other time I have done work in this field I have always been spoon fed to get started. Install this install that, someone on hand to help out.

So right now I'm looking at my 2.1.0E zip with the source code in it. I have bloody no idea how to get it to work even with following the instructions.

#1 I have downloaded s12buildtools-win32.zip (filesize: (57,611,176 bytes))
#2 I have downloaded setup.exe from the www.cygwin.com

Which packages exactly do I need to get cygwin doing what it needs to? Are we just using cygwin because it includes the gcc compiler and someone has developed the s12 tools so that gcc works as required?
1982 RX-7 12A, MSII V3.0, running ms2extra 2.1.0E

Series 5 RX-7 throttle bodies, 2xID725, 2x1600
Complete fuel,ignition, and electric fan control. 11.828@124.30mph
Jobro
Helpful MS/Extra'er
 
Posts: 139
Joined: Wed Aug 16, 2006 12:24 am
Location: Brisbane, Australia

Re: MS2 development/coding for dummies

Postby Jobro » Mon Jan 30, 2012 1:30 am

OK following these instructions I got it closer to working than I have before but its still not working. Here is what I get.

I downloaded and installed the entire 'devel' options and all dependencies that it asked me to do. I extracted tools.tar.gzip into c:\cygwin\ and it added all the files to the /usr/ directory.

Does anyone know whats not working right?
1982 RX-7 12A, MSII V3.0, running ms2extra 2.1.0E

Series 5 RX-7 throttle bodies, 2xID725, 2x1600
Complete fuel,ignition, and electric fan control. 11.828@124.30mph
Jobro
Helpful MS/Extra'er
 
Posts: 139
Joined: Wed Aug 16, 2006 12:24 am
Location: Brisbane, Australia

Re: MS2 development/coding for dummies

Postby gslender » Mon Jan 30, 2012 1:42 am

Jobro wrote:OK following these instructions I got it closer to working than I have before but its still not working. Here is what I get.

I downloaded and installed the entire 'devel' options and all dependencies that it asked me to do. I extracted tools.tar.gzip into c:\cygwin\ and it added all the files to the /usr/ directory.

Does anyone know whats not working right?


You untar into the root / directory, not into /usr ..... ??

G
Mazda MX5 + MS3 Pro
User avatar
gslender
Super MS/Extra'er
 
Posts: 1072
Joined: Fri Sep 16, 2011 5:29 am
Location: Brisbane, Australia

Next

Return to MS2/Extra Development

Who is online

Users browsing this forum: No registered users and 0 guests