Shop OBEX P1 Docs P2 Docs Learn Events
Catalina 3.10 - Black is Back! - Page 4 — Parallax Forums

Catalina 3.10 - Black is Back!

124

Comments

  • David BetzDavid Betz Posts: 14,516
    edited 2012-12-07 03:49
    RossH wrote: »
    Hi David,

    Haven't had time to look at this yet, and soon I'll be out of internet range for a few days. I'll try to get to this next week.

    Ross.
    No problem. This doesn't need to be resolved immediately. We'll welcome your input when you return.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-12-07 05:00
    Ok, looking at the .cfg files.

    I'll see if I can create a "bare propeller" one.
  • RossHRossH Posts: 5,462
    edited 2012-12-10 01:39
    Dr_Acula wrote: »
    Ok, looking at the .cfg files.

    I'll see if I can create a "bare propeller" one.

    Hi Dr_A,

    You don't need to - I guess I didn't explain it well enough. I'll try again ...

    As installed, the CUSTOM configuration is as "bare propeller" as you could possibly want. All it does is define a 5Mhz clock (and you can change even that if you need to). It defines no pins or peripherals except for a serial port on pins 30 & 31 - this serial port can be used with any terminal emulator. If you want to disable even the serial port (i.e. have no preripherals at all) then just define the NO_HMI symbol - either on the command line or in the Custom_CFG.inc file.

    If you do that, then when you compile a C program without specifying a platform (since CUSTOM is the default) Catalina will not include any plugins at all.

    I think you somehow believe all this must be much more complicated than it really is :smile:

    Ross.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-12-11 16:43
    Thanks Ross. Sorry about the delay - work work work :)
    so It defines no pins or peripherals except for a serial port on pins 30 & 31
    then just define the NO_HMI symbol - either on the command line or in the Custom_CFG.inc file.

    That will work fine on my catalina IDE as I can add the NO_HMI to the command line.

    So can I get this running on code::blocks?

    I did a search for Custom_CFG.inc and there are three copies of this file - in directories c:\program files\catalina\basic, in c:\program_files\catalina\minimal and c:\program files\catalina\target.

    Which of those would I need to change?

    And the file itself seems to be all comments
    '
    ' This file has been modified to suit the Parallax QuickStart board.
    '
    ' This board supports only serial comms HMI options, such as the PC
    ' and PROPTERMINAL options (the default is PC). 
    '
    ' It assumes a 5Mhz crystal is installed. 
    '
    ' Programs should be compiled to use the CUSTOM platform - e.g:
    '
    '    catalina hello_world.c -lc -C CUSTOM
    '
    '===============================================================================
    '
    ' This configuration file should only contain #defines for configuring various
    ' platform-specific hardware (for example, whether the pins used for XMM access
    ' are shared with other devices). Any other platform-specific definitions or
    ' constants should be included in the definitions file for the platform.
    '
    ' QuickStart specific #defines:
    '
    '===============================================================================
    '
    

    So it is a bit unclear what the syntax ought to be to define the no hmi symbol. Do I just add "NO_HMI" to the last line, or is the syntax #define NO_HMI or something else?
  • RossHRossH Posts: 5,462
    edited 2012-12-11 20:08
    Dr_Acula wrote: »
    Thanks Ross. Sorry about the delay - work work work :)
    So can I get this running on code::blocks?

    Of course - if you are using the Catalina Project Wizard then just choose CUSTOM as the Propeller Platfrom, and None as the HMI option - or manually select these in your project's "build options".
    Dr_Acula wrote: »
    I did a search for Custom_CFG.inc and there are three copies of this file - in directories c:\program files\catalina\basic, in c:\program_files\catalina\minimal and c:\program files\catalina\target.

    Which of those would I need to change?
    The default target directory is the one in C:\Program Files\Catalina\target. The other target directories are examples of targets customized for specific purposes - their use is described in the Catalina documentation.
    Dr_Acula wrote: »
    And the file itself seems to be all comments

    ... <snip> ...

    So it is a bit unclear what the syntax ought to be to define the no hmi symbol. Do I just add "NO_HMI" to the last line, or is the syntax #define NO_HMI or something else?

    The example file for the CUSTOM platform is just a placeholder. To do what you want, add the following lines:
    #ifndef NO_HMI
    #define NO_HMI
    #endif
    

    All this does is eliminate the need to add -C NO_HMI to each command line (or select this HMI option in Code::Blocks). Surrounding it with #ifndef ... #endif just makes sure the compiler won't spit the dummy if you accidentally do define it.

    Ross.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-12-11 20:57
    Thanks Ross,

    I think I am getting there. Ok, edited the custom_cfg.inc file in c:\program files\catalina\target to this
    '
    ' This file has been modified to suit the Parallax QuickStart board.
    '
    ' This board supports only serial comms HMI options, such as the PC
    ' and PROPTERMINAL options (the default is PC). 
    '
    ' It assumes a 5Mhz crystal is installed. 
    '
    ' Programs should be compiled to use the CUSTOM platform - e.g:
    '
    '    catalina hello_world.c -lc -C CUSTOM
    '
    '===============================================================================
    '
    ' This configuration file should only contain #defines for configuring various
    ' platform-specific hardware (for example, whether the pins used for XMM access
    ' are shared with other devices). Any other platform-specific definitions or
    ' constants should be included in the definitions file for the platform.
    '
    ' QuickStart specific #defines:
    '
    '===============================================================================
    '
    #ifndef NO_HMI
    #define NO_HMI
    #endif
    
    

    (there is an #endif on the last line, but it is not displaying in the forum listing)

    Saved the file.
    Start code::blocks
    New project
    Catalina project
    Selected custom platform
    Tiny model
    Bare program is this
    /*
     * main.c - main program
     */
    
    #include <stdio.h>
    
    int main(int argc, char *argv[])
    {
    
        // insert your code here
    
        while(1) ; // the propeller reboots on exit - this line prevents that
    
        return 0;
    }
    

    and compile log is this
    -------------- Build: Debug in test8 ---------------
    
    Compiling: main.c
    Catalina Compiler 3.10
    Linking console executable: bin\Debug\test8
    Homespun Spin Compiler 0.32
    parsing C:\Program Files\Catalina\target\lmm_blackcat.spin
    parsing C:\Program Files\Catalina\target\Catalina_Common.spin
    parsing .\Catalina.spin
    parsing C:\Program Files\Catalina\target\BlackCat_DebugCog.spin
    parsing C:\Program Files\Catalina\target\Command_Line.spin
    parsing C:\Program Files\Catalina\target\Catalina_CogStore.spin
    parsing C:\Program Files\Catalina\target\Floating_Point.spin
    parsing C:\Program Files\Catalina\target\SD_Card.spin
    parsing C:\Program Files\Catalina\target\Clock.spin
    parsing C:\Program Files\Catalina\target\HMI.spin
    parsing C:\Program Files\Catalina\target\Graphics.spin
    parsing C:\Program Files\Catalina\target\Proxy_IO.spin
    parsing C:\Program Files\Catalina\target\Extras.spin
    parsing C:\Program Files\Catalina\target\Catalina_LMM.spin
    writing 4976 bytes to bin\Debug\test8.binary
    Writing listing to bin\Debug\test8.lst
    Catalina Compiler 3.10
    code = 360 bytes
    cnst = 0 bytes
    init = 4 bytes
    data = 4 bytes
    file = 4976 bytes
    

    Were you getting it smaller than that?
  • RossHRossH Posts: 5,462
    edited 2012-12-11 21:21
    Dr_Acula wrote: »
    ...

    Were you getting it smaller than that?

    Yes - you are building a "Debug" version, which includes an extra few hundred bytes of code to load the debugger cog. In Code::Blocks, look for the "Build Target" dropdown and select Release instead of Debug. Or from the menus, select Build->Select target->Release.

    This will reduce the code size to 80 bytes. There are various other symbols you can define to reduce it further, but they require specific knowledge of the program being compiled. For instance, in this particular case, you could also add all of the following #defines - but because it is so program dependent, it is not recommended you set this up as the default for ALL programs:
    #define NO_ARGS
    #define NO_PLUGINS
    #define NO_EXIT
    

    This will reduce the code size to 16 bytes - i.e. 4 PASM instructions.
    Ross.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2012-12-12 21:55
    Thanks Ross, that is working. Compiling to 80 bytes.

    I'm documenting this more for myself so I don't forget all the steps along the way.
    1) Run Spin2C on a Spin program. Create a batch file with this in it if required. This creates C code rather than C++ code
    spin2cpp --ccode --main hello.spin
    pause
    
    2) Edit custom_cfg.inc in c:\program file\catalina\target so it has these lines at the end
    #ifndef NO_HMI
    #define NO_HMI
    #endif
    
    3) Open a new project in code::blocks -, click the propeller icon "catalina project", pick a name, select catalina c compiler, select custom for the platform, select standard c library (no maths or file system), select "none" for HMI drivers, select tiny memory model.
    4) In codeblocks, Build/Select Target/Release
    5) Do a test compile - should be 80 bytes.
    6) Do a save of the file - note the location of the directory (it might be c:\codeblocks\ or similar)
    7) Copy the .c and .h files spin2c created to this directory
    8) Copy and paste in the 'main' program that spin2c created. (comment out or delete the skeleton code code::blocks made)
    9) In code::blocks, Project/Add Files and add all the rest of the .c programs that spin2c created.
    10) Do a Build and it should compile with no errors.
    11) Tools/ and select download option - eg download to Hub and interact.

    Woot! Hello World in a terminal :)
  • RossHRossH Posts: 5,462
    edited 2012-12-13 01:27
    Dr_Acula wrote: »
    Thanks Ross, that is working. Compiling to 80 bytes.

    I'm documenting this more for myself so I don't forget all the steps along the way.

    ... <snip> ...

    Woot! Hello World in a terminal :)

    Glad you got it working, Dr_A.

    For others, it is worth pointing out that these instructions relate specifically to getting the Spin program Dr_A mentioned earlier in this thread to compile and run in Code::Blocks. They are not necessary for compiling or running a normal C program, which would generally only needs steps 3, 4 and 11.

    Ross.
  • RossHRossH Posts: 5,462
    edited 2012-12-17 01:35
    David Betz wrote: »

    HI David,

    I had a read of this thread - or at least the parts that I think are relevant. There's a lot of misecllaneous stuff in this thread, and this makes it hard to tell if I found all the posts you intended I should read. I am still reading, but I have not yet found the significance of your loading code at $e80 (or $1000) - perhaps you could enlighten me as to why this is required (or desirable)?

    Thanks,

    Ross.
  • RossHRossH Posts: 5,462
    edited 2012-12-17 02:37
    All,

    Jazzed made several complaints about Catalina earlier in this thread, and I think I have previously dealt with most of them ... except for the one where he says Catalina has no linker, and therefore cannot exclude unused functions.

    Well, it's perfectly true to say Catalina has no linker - but I'm not quite sure why this would be percieved as a significant deficiency. Catalina has a binder instead, which does the same job. Most people never use such things directly anyway - they are just internal components of the toolchain required to turn source code into binary - and not otherwise especially interesting.

    However, Jazzed was right to say there was no optimizing step that removed unused objects ... until now! I have added this feature to a new version of the Catalina Optimizer, which is where I think it really belongs (rather than in the linker or binder). Now there is an additional optimizer level (-O4) which will scan the final program for any unused functions and data blocks, and remove them. Note that for most user's programs this doesn't save much - few people deliberately write unused code, and the Catalina libraries were already quite optimal - i.e. each library file usually contained only a single function, and did not pull in unused library code.

    However, redundant functions and data can creep in when creating your own libraries or larger programs, or when compiling code that is automatically generated by other tools. Now such unused code and data will be eliminated if you specify optimization level 4. On small programs the savings are usually minimal - a few dozen or hundred bytes. On larger "real world" programs I have seen savings between 2% and 10%. I have created test examples where the new optimizer saves much more, but these are all pathological examples that would rarely be seen in real life.

    Now, here's the situation ...

    I have been wanting to release the LMM version of the Catalina Optimizer for a while as a free part of Catalina (the CMM version of the optimizer is already free). I have not done so mainly because I originally charged for the Optimizer, and many people were kind enough to purchase a copy. I would not like to break faith with those people by releasing without their approval something they paid good money for, so I have sent an email (asking if there are any objections) to all current Optimizer owners - if none of them object, then I will release a new version of the Optimizer for everyone to use that contains the new unused code removal function - along with all the existing Optimizer functionality.

    If you have previously purchased the Optimizer and NOT received an email asking you about this, feel free to post any objection you have here instead. If I receive no objections, I will post a free version of the Catalina LMM Optimizer soon.

    If do I receive objections, I may choose to post just the dead code remover instead.

    Ross.
  • TorTor Posts: 2,010
    edited 2012-12-17 02:58
    Hi Ross, got your email. No objections from me, I would purchase again even if you released the free version the day after! :)

    Tor
  • SapiehaSapieha Posts: 2,964
    edited 2012-12-17 03:03
    Hi RossH.

    "I have been wanting to release the LMM version of the Catalina Optimizer for a while as a free part of Catalina"


    I don't use C -- have only made some tests in Catalina --- Not purchased Optimizer.

    But still will say DON't release it free else source code to it. Lets things be that them are now. ---- Them that recognise Yours work and use Catalina intensively will still BUY it with any complains --- As part to have You possibility made Catalina even more effective.
  • Heater.Heater. Posts: 21,230
    edited 2012-12-17 03:16
    That's very neat.

    I always though this idea of having to put all library functions into separate files if you ant them pruned out at build time was brain dead.
    It seems natural to me that a bunch of related functions remain in a single file. Especially as many of them may be "private" to the library and the only way to do that in C is to make them "static" which means that the callers of those private functions must be in the same file.

    Also I like to keep a collection of related functions in the same file sometimes even if that file is included in the projects source tree. For example my collection of pseudo random number generators. Perhaps in any given program only one of them gets used.

    The compiler should be taking care of this book keeping chore, and now Catalina does.
  • potatoheadpotatohead Posts: 10,261
    edited 2012-12-17 08:32
    I'll chime in here Ross.

    As I understand it, the significance question $e80 vs $1000 came down to mailboxes and other core things having a standard place to live, and or not be disturbed once the initial loader has completed it's work.

    $1000 was suggested as the general purpose, "start of program" address due to it being a nice, round number, and that it leaves a reasonable amount of HUB memory dedicated to meta things related to programs.
  • jazzedjazzed Posts: 11,803
    edited 2012-12-17 08:46
    Congratulations on correcting one of your deficiencies.
  • RossHRossH Posts: 5,462
    edited 2012-12-17 13:29
    jazzed wrote: »
    Congratulations on correcting one of your deficiencies.

    And when are you going to begin correcting yours?
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-12-17 13:46
    Nice work Ross. You will have to double Catalina's price for this! Soon you will be making a handsome profit ;)

    2x $0.00 = $0.00
  • jazzedjazzed Posts: 11,803
    edited 2012-12-17 13:48
    RossH wrote: »
    And when are you going to begin correcting yours?
    You are welcome to mention them in the beta forum.
  • RossHRossH Posts: 5,462
    edited 2012-12-17 13:58
    jazzed wrote: »
    You are welcome to mention them in the beta forum.

    Oh, I think you probably already have enough to worry about.
  • jazzedjazzed Posts: 11,803
    edited 2012-12-17 14:25
    RossH wrote: »
    Oh, I think you probably already have enough to worry about.
    Not very helpful, but I accept it. I only need to meet Parallax's requirements.
  • RossHRossH Posts: 5,462
    edited 2012-12-17 14:34
    jazzed wrote: »
    Not very helpful, but I accept it. I only need to meet Parallax's requirements.

    That's a really sad attitude. One day, you should try meeting some actual user's requirements. You'll find it's more difficult - but also more rewarding.
  • jazzedjazzed Posts: 11,803
    edited 2012-12-17 15:13
    My perspective is practical. You can cast it however you see fit as you usually do.

    As I said though Congratulations on your recent effort.
  • RossHRossH Posts: 5,462
    edited 2012-12-17 16:14
    jazzed wrote: »
    As I said though Congratulations on your recent effort.

    Thanks.
  • RossHRossH Posts: 5,462
    edited 2012-12-19 14:16
    I just noticed that Catalina has now been downloaded from SourceForge over 10,000 times!

    http://sourceforge.net/projects/catalina-c/files/releases/stats/map?dates=2010-01-01+to+2012-12-19

    Of course, this number is only for releases since 3.0 - the total number downloads of all releases would be much higher, and the number of downloads of the current release is much lower - around 500 over the last month.

    I also realize these figures include many downloads from users who just grab each release to have a play with it and never end up using it for much - but even so I thought I couldn't let this milestone pass unnoticed :cool:

    Ross.
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-12-19 16:27
    Nice Ross. However, you can scratch 1 from that list because I downloaded it twice - I needed to recover a file that I corrupted :(
  • RossHRossH Posts: 5,462
    edited 2012-12-19 17:14
    Cluso99 wrote: »
    Nice Ross. However, you can scratch 1 from that list because I downloaded it twice - I needed to recover a file that I corrupted :(

    Blast! Back to 9,999 :frown:

    Actually, I'll have to scrub at least 10 downloads from the list, because I always download it immediately myself - just to check if it has uploaded correctly :lol:
  • potatoheadpotatohead Posts: 10,261
    edited 2012-12-19 17:25
    Got your back Ross, just fetched one for this box.

    :)
  • RossHRossH Posts: 5,462
    edited 2012-12-19 17:41
    potatohead wrote: »
    Got your back Ross, just fetched one for this box.

    Whew! Thanks, potatohead :smile:
  • RossHRossH Posts: 5,462
    edited 2013-05-12 00:42
    Hi everyone!

    I've been away from the forums for a while - health issues - so I just wanted to post a note saying I'm ok and I expect to be back again on a regular basis from now on. Thanks to those who inquired and/or sent good wishes.

    Also thanks for the patience of those who've been emailing me Catalina queries and issues - I've been working my way through the backlog, but if I haven't gotten to yours yet, then there's a chance I have missed it, so feel free to send it again, or post it here.

    One that came up just today is that the library function coginit_Spin has been compiled to use a wait function, but no such function is included in the library - all my programs that uses this function also define this for themselves (and I presume others have been doing the same) so I never noticed it. If you get an error that wait is undefined, just include the following code somewhere in your program:
    /*
     * wait : pause for a specified number of milliseconds
     */ 
    void wait(int milliseconds) {
       _waitcnt(_cnt() + milliseconds *(_clockfreq()/1000));
    }
    
    

    I'll fix this in the next release.

    Ross.
Sign In or Register to comment.