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
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?
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".
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.
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.
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;
}
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:
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.
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.
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)?
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.
"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.
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.
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.
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.
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:
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
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));
}
Comments
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
Ross.
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
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?
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".
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.
The example file for the CUSTOM platform is just a placeholder. To do what you want, add the following lines:
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.
I think I am getting there. Ok, edited the custom_cfg.inc file in c:\program files\catalina\target to this
(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
and compile log is this
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:
This will reduce the code size to 16 bytes - i.e. 4 PASM instructions.
Ross.
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 2) Edit custom_cfg.inc in c:\program file\catalina\target so it has these lines at the end 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
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.
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.
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.
Tor
"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.
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.
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.
And when are you going to begin correcting yours?
2x $0.00 = $0.00
Oh, I think you probably already have enough to worry about.
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.
As I said though Congratulations on your recent effort.
Thanks.
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.
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
Whew! Thanks, potatohead
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:
I'll fix this in the next release.
Ross.