Page 1 of 8

MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 3:45 pm
by Martin Young
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.

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 3:49 pm
by jsmcortina
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

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 3:55 pm
by gslender
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.

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 3:58 pm
by Martin Young
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.

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 4:00 pm
by gslender
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

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 4:01 pm
by racingmini_mtl
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

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 4:02 pm
by gslender
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:

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 4:28 pm
by jsmcortina
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

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 4:32 pm
by Martin Young
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.

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 4:45 pm
by robs
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.

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 4:59 pm
by jsmcortina
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

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 5:12 pm
by Martin Young
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

Re: MS2 development/coding for dummies

Posted: Tue Jan 10, 2012 5:20 pm
by jsmcortina
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

Re: MS2 development/coding for dummies

Posted: Wed Jan 11, 2012 12:54 pm
by muythaibxr
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

Re: MS2 development/coding for dummies

Posted: Wed Jan 11, 2012 1:25 pm
by TBI_Master
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...

Re: MS2 development/coding for dummies

Posted: Thu Jan 12, 2012 2:55 pm
by TBI_Master
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?

Re: MS2 development/coding for dummies

Posted: Thu Jan 12, 2012 3:03 pm
by gslender
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

Re: MS2 development/coding for dummies

Posted: Sun Jan 29, 2012 4:58 am
by Jobro
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?

Re: MS2 development/coding for dummies

Posted: Mon Jan 30, 2012 1:30 am
by Jobro
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?

Re: MS2 development/coding for dummies

Posted: Mon Jan 30, 2012 1:42 am
by gslender
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