MS-II Downloader v2.00

The MS-II™ downloader by Eric Fahlgren now includes a "package browser", which lets the user pick a package site and grab the latest updated code/ini files directly via the GUI downloader, and the downloader will automatically update both MegaSquirt® and MegaTune with the right files.

You can get the V2.00 Downloader here: ms2dl200_setup.exe

Install the program like any other Windows application.

To do a code and INI update:

  1. Power off your MegaSquirt® controller, put the bootloader jumper in place, and power it back up - it will now be in 'bootloader mode' waiting for code.
  2. Open the downloader application (MS Download 2.00),
  3. Click on the menu item 'File/Updates'.
  4. Select the appropriate ftp site ('megamanual.com/updates/MS-II/' for MS-II, for example), click on the code package (*.msu, ms2_2.884.msu for example) you want to install, and select the target project from the drop-down boxes,
  5. Then click 'install',
  6. The installation will proceed automatically. Note that the S19 file is not extracted from the MSU file, instead it is transferred directly from the MSU file to MegaSquirt®.
(Note that you can also transfer an update file without installing it by using the FTP -> button.)

The downloader drops the .msu file into either the "car" directory or "car/packages" directory and then the downloader automatically stores them in car/mtCfg (unless it's not found in which case it drops them in "." - the directory in which the .msu file is found).

   MegaSquirt/
      Car1/
         mtCfg/
            extracted.ini
         packages/
            *.msu
 

User Notes:

The quick synopsis is:

  1. "#!MSU-OUT" section copies text from the MSU file to the output window, so you can embed notes to the user.

  2. Search path is as discussed previously is only with the GUI version. The command line version (see below) forces you specify the installation directory like this:

    ms2dl -i c:/wherever/mtCfg myCode.msu

  3. There is a new command-line utility included, msu.exe, that creates msu files. You can package your own MS-II™ code and ini combinations with it. The command line looks like this:

    msu my.msu c:\iniFiles\file.ini c:\s19Files\file.s19

    where you can grab files from anywhere and they end up in one MSP.

If you set the 'Settings/Verbosity' to 3 or higher, the main log window will display the ftp conversation (useful to debug things).

File Format

The following comments contain the official documentation of the MSU (MegaSquirt Update) file format.

Once you've got the program installed, you can look at the file:

C:\Program Files\MegaSquirt\MS Download 2.00\msu.cpp

for the documentation on the MSU file format as well as the source code.

The MSU file is pure text, with "fences" defining the sections. The sections may appear in any order, which can be useful in that they are processed in the order given in the file, so user-defined output messages can delimit the system status messages in a meaningful way.

There are four MSU keywords that have meaning, all are prefixed with these six characters: #!MSU-

The prefix must reside starting in the first column of the MSU file. The four keywords are: END, INI, OUT, S19 (described below).

Some keywords have argument lists enclosed in parentheses. Any text after the keyword or its arguments are ignored, so you can put commentary on the fence lines if you like (see the first and last lines of the example file below).

Keyword Descriptions

  1. END delimits any of the other sections and may appear any number of times. Text between an "END" section and the start of any other section is ignored.

  2. INI delimits a text section that will be copied into a specific location, using the required file name argument. In use it looks like this,

    #!MSU-INI(file.ini)

    where the "file.ini" part is extracted from the input and used as the name of the destination file.

    NOTE: The GUI-based MS Downloader will determine the destination file location via a MegaTune-like search algorithm. (The command-line downloader forces you to supply the destination directory explicitly with the "-i" switch, otherwise it uses ".".)

    a) If the .msu file is found in a directory named "updates", then the search begins in "..", otherwise it starts in ".".

    b) If a directory named "mtCfg" is found, then it is used as the destination, otherwise the files are extracted into ".".

    Based on this, it is strongly suggested that you install your update files into the following directory structure:

          MegaSquirt\
             Car1\
                updates\
                   Put Car1 MSU files here.
                mtCfg\
                   Car1 INI files will be extracted into this directory.
             Porsche\
                updates\
                   Put Porsche MSU files here.
                mtCfg\
                   Porsche INI files will be extracted into this directory.
    

  3. OUT delimits a section of the file that is commentary, but is also copied to the user output log area. Run the example to see how it is processed.

  4. S19 delimits the block of Motorola S-records that normally reside in an S19 file. The S19 may or may not have a file name, this is strictly optional, but msu.exe inserts it as documentation. The S19 file is not extracted from the MSU file, it is transferred directly from the MSU file to the MegaSquirt®.

    Both of these uses are valid.

          #!MSU-S19
          #!MSU-S19(file.s19)
    

Example

Here's an example, which may be cut and pasted into a file for test purposes. The S19 section is gibberish, so while it will read in just fine, you should not use it while connected to an active MegaSquirt®.

#!MSU-OUT <-- This is the first line of the MSU file.
-----------------------------------------------------------
WARNING!  Read this first.
This text block is copied to the output log window.

#!MSU-S19
S02E0000433A5C4D5349495F454D4245444445445C4D5349495F56315F43575C62696E5C4D6F6E69746F722E61627393
S1138000CF3FFF16B744CED454CD3800CC00002760
S113FB0002C0038402D003D14FC7FFFF6E011E6EF3
S113FB10011F4502409445FB00AD22A600B705A68F
S113FB2070B73EA604B73C0F3CFDB63DA1052529A0
S113FB30C6FAFEA1FF272220C487898A8819361BAA
S104FF7EF688
S12340800848084008390831082A0822081B0813080C0807080207FD07F807F007E907E171
S123410006B806B306AE06A906A406A1069F069C069A06950690068B06860681067C0677B5
S9030000FC
#!MSU-INI(megasquirt-II.ini)
;-------------------------------------------------------------------------------
;#alert "This 2.6 version of megasquirt-II.ini is not complete,\nget a newer one when it is available."
[MegaTune]
   writeXML       = true
   MTversion      = 2.50 ; MegaTune itself; needs to match exec version.

   versionInfo    = "S"  ; Put this in the title bar.
   queryCommand   = "Q"  ; Verify against signature.
   signature      = "MSII Rev 2.60000   " ; MS-II sends a null at 20th byte.
                   ; 123456789.123456789.
#if LAMBDA
      afrTable1       = array ,  U08,     48,    [12x12], "AFR",      0.10000,   0.00000,  9.00,   20.00,      1
      afrTable2       = array ,  U08,    192,    [12x12], "AFR",      0.10000,   0.00000,  9.00,   20.00,      1
#else
      afrTable1       = array ,  U08,     48,    [12x12], "AFR",      0.10000,   0.00000,  9.00,   20.00,      1
      afrTable2       = array ,  U08,    192,    [12x12], "AFR",      0.10000,   0.00000,  9.00,   20.00,      1
#endif
#!MSU-INI(myCustom.ini)
[MegaTune]
   MTversion = 2.50
[Units]
   TPS       = "raw"
#!MSU-OUT

Read this last.
-----------------------------------------------------------
#!MSU-END <-- This is the last line of the MSU file.

Downloader Errors

The downloader will produce a diagnostic error code (more correctly, it is the serial monitor on the MS-II™ that produce the error code that the downloader reports). These error codes have the following meaning:

  1. 0xE0: no errors
  2. 0xE1: command not recognized
  3. 0xE2: command not allowed in run mode
  4. 0xE3: SP was out of range
  5. 0xE4: attempted to write bad SP value
  6. 0xE5: write_byte attempt NVM
  7. 0xE6: FACCERR or FPVIOL error
  8. 0xE7: Error code not implemented
  9. 0xE8: Error code not implemented
  10. 0xE9: EACCERR or EPVIOL error

Quoting these errors codes can be helpful when mentioning code loading issues on the forums.

Command Line Downloader

The downloader also has a command line version (ms2dl.exe) included in the package. You can run the command line version in a script, so if you have makefiles or something of the sort, you don't need to interact with GUI version at all.

Look in the downloader installation directory (typically 'C:\Program Files\MegaSquirt\MS Download 2.00') and you'll see ms2dl.exe, which can be invoked from the command line (or .bat file) like this:

ms2dl -c3 -r115200 something.s19

Where:

("ms2dl -h" gives you a usage message.)

You can even hook this up to one of the buttons/keys in the CodeWarrior IDE, if you are doing code development. Add it under 'Edit/Commands and Key Bindings', by creating a 'Downloader/DL to MegaSquirt' menu item. It should look like this:

You might need quotes around the 'Execute' field value if there are any blanks in the directory path. The 'Directory' field should be the path to the BIN directory containing the .S19 files (and will depend on your compiler set-up).



MegaSquirt® and MicroSquirt® controllers are experimental devices intended for educational purposes.
MegaSquirt® and MicroSquirt® controllers are not for sale or use on pollution controlled vehicles. Check the laws that apply in your locality to determine if using a MegaSquirt® or MicroSquirt® controller is legal for your application.
©2004, 2008 Bruce Bowling and Al Grippo. All rights reserved. MegaSquirt® and MicroSquirt® are registered trademarks.