Jump to content

System-Less Framework: Difference between revisions

From HW wiki
New page: This page describes an easy to use framework for developing software for small microcontrollers. First, you have to download a package for the architecture you want to use: * H8S/2638...
 
 
(30 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This page describes an easy to use framework for developing software for small microcontrollers.
This page describes an easy to use framework for developing software for small microcontrollers.


First, you have to download a package for the architecture you want to use:
== Support/Mailing list ==
 
There is a [http://rtime.felk.cvut.cz/mailman/listinfo/sysless mailing list] for discussion about this project. Allowed languages are Czech and English.
The address for sending to the list is [mailto:sysless@rtime.felk.cvut.cz sysless@rtime.felk.cvut.cz]. You can write there without subscribing but you will have to wait for moderator approval.
 
== Getting it ==
 
To get the sources from our [http://rtime.felk.cvut.cz/gitweb/sysless.git Git repository] use the following command:
 
  git clone git://rtime.felk.cvut.cz/sysless.git
 
You will also need a toolchain (compiler, linker, etc.) for your architecture. You can get some from the following pages:
* [[H8S/2638]]
* [[H8S/2638]]
* [[LPC21xx]]
* [[LPC21xx]]
Line 7: Line 18:
== Compiling ==
== Compiling ==


First, you have to configure the make-system for a board you plan to use. For ''h8canusb'' execute the following command from h8300-boot directory:
The downloaded packages must be configured for a particular board you plan to use. For ''h8canusb'' board execute the following commands from sysless directory:
  ln -s board/h8canusb/config.h8canusb config.omk
  ln -s board/h8300/h8canusb/config.h8canusb config.target
  make default-config
  make default-config
Then, you can change default configuration of what is compiled by copying <tt>config.omk-default</tt> to <tt>config.omk</tt>. In the copied file change default configuration as you want and delete other lines you want to have default value.
 
Then, you can override default configuration of what is compiled and how.  The list of variables available for modification is <tt>config.omk-default</tt>. Put your own settings to <tt>config.omk</tt> since the values here override those from <tt>config.omk-default</tt> and <tt>config.target</tt>.


After typing
After typing
  make
  make
everithing is goning to compile and if the compilation is completed without errors, you can use this ''build environment'' for building your own applications.
everything is going to compile and if the compilation is completed without errors, you can use this ''build environment'' for building your own applications.
 
If there are some build errors, you may try to compile it by
make -k
This command tries to build everyting even if there are some errors.


=== Compiling one application only ===
=== Compiling one application only ===
Line 20: Line 36:
To compile only a part of sources (e.g. your own application), change the directory to where your applications resides and run
To compile only a part of sources (e.g. your own application), change the directory to where your applications resides and run
  make
  make
This will (re)compile everithing in current directory and all subdirectories. The result of compilation can be found under the <tt>_compiled</tt> direcotry (located at root of h8300-boot directory structure). The structure of <tt>_compiled</tt> directory is as follows:
This will (re)compile everything in current directory and all subdirectories. The result of compilation can be found under the <tt>_compiled</tt> direcotry (located at the root of sysless directory structure). The structure of <tt>_compiled</tt> directory is as follows:


; bin : binary programs for target system
; bin : binary programs for target system
Line 27: Line 43:
; libs : compiled libraries for target
; libs : compiled libraries for target


There is another directory called <tt>_build</tt> where intermediate products of compilation such as object files, linker maps and dependency descriptions are stored. You can delete files in <tt>_build</tt> corresponding to your application by issuing
There is another directory called <tt>_build</tt> where are stored intermediate products of compilation such as object files, linker maps and dependency descriptions. You can delete files in <tt>_build</tt> corresponding to your current directory (and its subdirectories) by issuing
  make clean
  make clean
If you want to delete both <tt>_compiled</tt> and <tt>_build</tt> directories, run
If you want to delete both <tt>_compiled</tt> and <tt>_build</tt> directories, run
Line 34: Line 50:
==== Using non-default link variant ====
==== Using non-default link variant ====


If your board has it's default link variant set for example to ''ram'' and you want to link your application for flash memory, you can use the following command to compile another variant of your program:
If your board has it's default link variant set for example to ''ram'' and you want to link your application for loading into flash memory, you can use the following command to compile another variant of your program:


  make link_VARIANTS=flash
  make link_VARIANTS=flash
Line 48: Line 64:
  make load
  make load


This load the application from current directory to either RAM or FLASH memory. Which one is selected depends on a value of <tt>DEFAULT_LD_SCRIPT_VARIANT</tt> variable. This variable can be set globaly in <tt>config.target</tt> or locally in <tt>Makefile.omk</tt> and the first word of the value of this variable determines the default memory location for loading (and running).  
This loads the application from the current directory to either RAM or FLASH memory. Which one is selected depends on the value of <tt>DEFAULT_LD_SCRIPT_VARIANT</tt> variable. This variable can be set globally in <tt>config.target</tt> or locally in <tt>Makefile.omk</tt> and the first word of this variable value determines the default memory location for loading (and running).  


If you want to load an application to different memory location, use one of
If you want to load an application to a different memory region, use one of
  make load-flash
  make load-flash
  make load-ram
  make load-ram


If there are more programs to load in the current directory, and you want to load a non-default one, you have to run
If there are more programs to load in the current directory, and you want to load a non-default one, run
  make load-<progname>-ram
  make load-<progname>-ram
  make load-<progname>-flash
  make load-<progname>-flash
Line 63: Line 79:
  make run-flash
  make run-flash


You can also combine loading and running to one step and use
You can also combine loading and running into a signle step and use
  make load run
  make load run
=== Bootstrapping the processor ===
In order to be able to load applications to the target system, there have to be a boot loader program in processor's FLASH memory. It has to be loaded through serial channel 1 (pins TxD1, RxD1). The loader program is located at <tt>app/bloader</tt> directory and you can load it to the processor by
sh bootstrap
from <tt>bloader</tt> direcotry.


== Using KDevelop for development ==
== Using KDevelop for development ==


[http://www.kdevelop.org/ KDevelop] is very good IDE for developing various kind of applications. It can be easily used to develop software for H8300 processors and can be well integrated with OMK make-system.
[http://www.kdevelop.org/ KDevelop] is a very good IDE for developing various kind of applications. It can be easily used to develop software under the sysless framework and can be well integrated with [[OMK]] make-system.


If you want to use KDevelop for development, follow theese points:
If you want to use KDevelop for development, follow theese points:
Line 86: Line 96:
== Using TAGS for navigation in files ==
== Using TAGS for navigation in files ==


If you run
If you run {{shcmd|make TAGS}} in any direcotry, the file TAGS in the toplevel directory of the project will be created. This file can be used by various editors (such as [[wikipedia:Emacs|Emacs]]) for quick searching of symbols in source files.
make TAGS
in any direcotry, the file TAGS in the toplevel directory of the project will be created. This file can be used by various editors (such as [[wikipedia:Emacs|Emacs]]) for quick searching of symbols in source files.


== Writing your own application ==
== Writing your own application ==
Line 94: Line 102:
TODO:
TODO:


=== Interrupts ===
== Contributing to System-Less Framework ==
 
You are encouraged to send us fixes, enhancements and other contribution to the [mailto:sysless@rtime.felk.cvut.cz mailing list]. You can use {{shcmd|git format-patch}} and/or {{shcmd|git send-email}} to automate it a little bit.


Interrupts are disabled by default. If you wand to use interrupts in your application you have to enable them explicitly by
=== git send-email HOWTO ===
sti();


''Interrupts handling mechanisms'' are initialized by calling <tt>excptvec_initfill</tt> and particular interrupts are setup by calling <tt>excptvec_set</tt>. For example see the code bellow.
To send the last '''two''' commits together with an introductory letter use one of the following commands:


  void  no_isr(void) __attribute__ ((interrupt_handler));
  git send-email --compose HEAD~2  # you will be asked for destination address
void  no_isr(void) {};
  git send-email --compose --to=sysless@rtime.felk.cvut.cz HEAD~2
void my_isr(void)
  {
    /* some code */
}   
int main()
{
    // all the interrupts will run no_isr
    excptvec_initfill(no_isr, 0);
 
    // set the interrupt handler my_isr to the interrupt vector
    // number 42
    excptvec_set(42, my_isr);
    /* Enable interrupts which are disabled by default. */
    sti();
    ...
}


When linking your program you need to link it with library <tt>excptvec</tt>. So in your Makefile.omk you will need a line similar to
If the commit messages are descriptive enough so that it is not necessary to write the introductory e-mail, simply omit --compose option.
yourprogram_LIBS = excptvec


=== Serial Communication ===
If you do not have working sendmail on your system, you need to configure git to send via SMTP server. The following works with our faculty IMAP server:
git config --global sendemail.smtpserver imap.feld.cvut.cz
git config --global sendemail.smtpuser sojkam1
git config --global sendemail.smtpssl true


You have to include
You can also [https://git.wiki.kernel.org/index.php/GitTips#Using_gmail_to_send_your_patches use Gmail to send the patches].
    #include <periph/sci_rs232.h>
then initialize the needed serial ports:
    /* Initialize SCI channels 0 and 1 */
    sci_rs232_setmode(19200, 0, 0, 0);
    sci_rs232_setmode(19200, 0, 0, 1);
Then you can use:
        sci_rs232_sendch('H', 0);
to send characters.


You can also use <tt>printf()</tt> and similar functions. The output of theese will go to the serial port specified by <tt>sci_rs232_chan_default</tt> variable. Its default value is selected in <tt>system_def.h</tt> and can be different for every board.
== Additional documentation ==


For examples see [http://rtime.felk.cvut.cz/darcs/darcsweb.cgi?r=h8300-boot;a=tree;f=/app/rs_test app/rs_test/*.c]
* [http://rtime.felk.cvut.cz/omk OMK make system]
* [http://dce.felk.cvut.cz/dolezilkova/diplomky/2006/dp_2006_stanislav_marek/dp_2006_staniclav_marek.pdf Stanislav Marek's Diploma thesis] - Documentation to OMK build system in Czech (obsolete).


== Links to other similar projects and reusable components ==


== Additional documentation ==
* [http://elm-chan.org/fsw/ff/00index_e.html ChaN's FatFs Module]
* [http://gandalf.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html Interfacing ARM controllers with Memory-Cards by Martin THOMAS]


* [http://dce.felk.cvut.cz/dolezilkova/diplomky/2006/dp_2006_stanislav_marek/dp_2006_staniclav_marek.pdf Stanislav Marek's Diploma thesis] - Documentation to OMK build system in Czech.
[[Category:Software]]

Latest revision as of 13:00, 7 April 2011

This page describes an easy to use framework for developing software for small microcontrollers.

Support/Mailing list

There is a mailing list for discussion about this project. Allowed languages are Czech and English. The address for sending to the list is sysless@rtime.felk.cvut.cz. You can write there without subscribing but you will have to wait for moderator approval.

Getting it

To get the sources from our Git repository use the following command:

 git clone git://rtime.felk.cvut.cz/sysless.git

You will also need a toolchain (compiler, linker, etc.) for your architecture. You can get some from the following pages:

Compiling

The downloaded packages must be configured for a particular board you plan to use. For h8canusb board execute the following commands from sysless directory:

ln -s board/h8300/h8canusb/config.h8canusb config.target
make default-config

Then, you can override default configuration of what is compiled and how. The list of variables available for modification is config.omk-default. Put your own settings to config.omk since the values here override those from config.omk-default and config.target.

After typing

make

everything is going to compile and if the compilation is completed without errors, you can use this build environment for building your own applications.

If there are some build errors, you may try to compile it by

make -k

This command tries to build everyting even if there are some errors.

Compiling one application only

To compile only a part of sources (e.g. your own application), change the directory to where your applications resides and run

make

This will (re)compile everything in current directory and all subdirectories. The result of compilation can be found under the _compiled direcotry (located at the root of sysless directory structure). The structure of _compiled directory is as follows:

bin
binary programs for target system
bin-utils
binary programs for host system (PC) (note: This will probably change in future)
include
header files which are used when compiling for target
libs
compiled libraries for target

There is another directory called _build where are stored intermediate products of compilation such as object files, linker maps and dependency descriptions. You can delete files in _build corresponding to your current directory (and its subdirectories) by issuing

make clean

If you want to delete both _compiled and _build directories, run

make distclean

Using non-default link variant

If your board has it's default link variant set for example to ram and you want to link your application for loading into flash memory, you can use the following command to compile another variant of your program:

make link_VARIANTS=flash

You can use more variant at once by

make link_VARIANTS="flash ram"

Loading and running an application

To load an application to the target processor, run

make load

This loads the application from the current directory to either RAM or FLASH memory. Which one is selected depends on the value of DEFAULT_LD_SCRIPT_VARIANT variable. This variable can be set globally in config.target or locally in Makefile.omk and the first word of this variable value determines the default memory location for loading (and running).

If you want to load an application to a different memory region, use one of

make load-flash
make load-ram

If there are more programs to load in the current directory, and you want to load a non-default one, run

make load-<progname>-ram
make load-<progname>-flash

After loading your application, you can run it by running one of the following

make run
make run-ram
make run-flash

You can also combine loading and running into a signle step and use

make load run

Using KDevelop for development

KDevelop is a very good IDE for developing various kind of applications. It can be easily used to develop software under the sysless framework and can be well integrated with OMK make-system.

If you want to use KDevelop for development, follow theese points:

  1. Import project to KDevelop (from menu choose Project -> Import existing project). Select the type of project to Generic C Application (Custom Makefile)
  2. (Optional) Populate your project with source files by anwering yes to the dialog.
  3. Open Project Options dialog (menu Project -> Project Options) and choose Run Options. Select Run from the BUILD directory, to Main Program editbox write /usr/local/bin/make (you may have your make in a different directory) and as Program Arguments write load run.
  4. Now you can compile your application by pressing F8 and if there are some errors, you can quickly jump the place in source whre the error is by pressing F4.
  5. After successfull compilation you can run your application by clicking Execute program icon. I recomend you to create shortcut key F9 for this action. If you change your sources, you can booth recompile and execute your application by simply pressing F9.

Using TAGS for navigation in files

If you run make TAGS in any direcotry, the file TAGS in the toplevel directory of the project will be created. This file can be used by various editors (such as Emacs) for quick searching of symbols in source files.

Writing your own application

TODO:

Contributing to System-Less Framework

You are encouraged to send us fixes, enhancements and other contribution to the mailing list. You can use git format-patch and/or git send-email to automate it a little bit.

git send-email HOWTO

To send the last two commits together with an introductory letter use one of the following commands:

git send-email --compose HEAD~2   # you will be asked for destination address
git send-email --compose --to=sysless@rtime.felk.cvut.cz HEAD~2

If the commit messages are descriptive enough so that it is not necessary to write the introductory e-mail, simply omit --compose option.

If you do not have working sendmail on your system, you need to configure git to send via SMTP server. The following works with our faculty IMAP server:

git config --global sendemail.smtpserver imap.feld.cvut.cz
git config --global sendemail.smtpuser sojkam1
git config --global sendemail.smtpssl true

You can also use Gmail to send the patches.

Additional documentation

Links to other similar projects and reusable components