Showing posts with label Google. Show all posts
Showing posts with label Google. Show all posts

Tuesday, June 24, 2014

[HOWTO] Build RTEMS tool-chain for OpenRISC targets

This post provides two methods of building RTEMS tool-chain for OpenRISC 1000 architecture: 1) building from RSB (RTEMS Source Builder) and 2) building each tool/program separately by downloading official tools' releases and apply our RTEMS specific patches to them. Merely, RSB is responsible for all the stuff including: setting up the environment, downloading releases, applying patches, configuring, building, and installing all the tools. The resulted tools should be program prefixed with or1k-rtems4.11-*. You may want to have a look at OpenRISC ELF GNU tool-chain; but note that RTEMS applications can't be built via these tools. The tool-chain has been tested and used on Fedora 20 and Ububtu 12.04 LTS. 

The tools/programs releases in the time being this post was written are:

  • binutils-2.24
  • gcc-4.8.2
  • newlib-2.1.0
  • gdb-7.7
  • or1ksim-github-head

Building RTEMS from RSB


Please have a look at RSB documentation here. It provides details in a thorough manner about RSB: how to download RSB, check environment, build RTEMS tool-chain for a specific target. Also, it gives a clear picture how RSB works internally.

1- Setup development and work space

$mkdir ~/rtems-dev
$cd ~/rtems-dev

2- Clone RSB 

$ git clone git://git.rtems.org/rtems-source-builder.git
$ cd rtems-source-builder

3- Check host environment


Check if host environment is setup correctly.
$ source-builder/sb-check
This command will tell you if any packages are required to be installed, if you miss any, please install them and try again, once every thing is Ok, you should have the following message:
$ source-builder/sb-check
RTEMS Source Builder environment is ok

 4- Building

$ cd rtems
$ ../source-builder/sb-set-builder --log=l-or1k.txt --prefix=$HOME/rtems-dev/rtems/4.11 \ 4.11/rtems-or1k

5- Check if all tools are installed successfully. You should get the following results


$ ls $HOME/rtems-dev/rtems/4.11
bin include lib libexec share or1k-rtems4.11
$ ls $HOME/development/rtems/4.11/bin
 

6- Add the newly installed tool-chain to the executable PATH

$ export PATH=$PATH:/$HOME/development/rtems/4.11/bin

Building RTEMS manually 

Currently, all or1k and RTEMS related patches are not upstreamed. So, we have to download official releases and apply patches to support or1k and RTEMS to them. I have worked on combining both or1k and RTEMS patches for all the tools against official tool releases. The following method of building the tools should be temporal. Eventually all patches including or1k and RTEMS should be upstreamed and tools should be built without patches provided here. 

1- Setup development and work space

$mkdir ~/rtems-dev
$cd ~/rtems-dev

2- Get the sources

3- Get the patches

Download all patches for the previous binutils, gcc, newlib, gdb releases from my repopreferably, the latest patches (with respect to commit time). Put them in the same directory. 

4- Unpack archives 

$ tar xf binutils*.tar.* 
$ tar xf gcc*.tar.* 
$ tar xf newlib*.tar.* 
$ tar xf gdb*.tar.
*

5- Apply patches

$ cd binutils-2.24
$ cat ../binutils*.diff | patch -p1
$ cd ../gcc-4.8.2
$ cat ../gcc*.diff | patch -p1
$ cd ../newlib-2.1.0$ cat ../newlib*.diff | patch -p1
$ cd ../gdb-7.7
cat ../gdb*.diff | patch -p1
 $ cd ../ 

6- Configure and build tools


  • Create build directories for all the tools
$ mkdir b-binutils b-gcc b-gdb

  • Configure and build binutils
$ cd b-binutils
$ ../binutils-2.24/configure --target=or1k-rtems4.11 --prefix=$HOME/rtems-dev/rtems/4.11
$ make
$ make install

  • Setup the PATH to include binutils binaries 
$ export PATH=$PATH:/$HOME/rtems-dev/rtems/4.11/bin

  • Link newlib into gcc directory
$ cd ../gcc-4.8.2/
$ ln -s ../newlib-2.1.0/newlib .

  • Configure and build gcc and newlib
$ cd ..
$ cd b-gcc
$ ../gcc-4.8.2/configure --target=or1k-rtems4.11 --prefix=$HOME/rtems-dev/rtems/4.11 --with-gnu-as --with-gnu-ld --enable-languages="c,c++" --enable-threads --disable-libssp --with-newlib --with-system-zlib --disable-libstdcxx-pch --disable-nls --without-included-gettext --disable-win32-registry --disable-lto --enable-newlib-io-c99-formats
$ make 
$ make install
  • Configure and build gdb
$ cd ../
$ cd b-gdb$ ../gdb-7.7/configure --target=or1k-rtems4.11 \
--prefix=$HOME/rtems-dev/rtems/4.11 \
--verbose --disable-nls \
--without-included-gettext \
--disable-win32-registry \
--disable-werror \
--disable-sim} \
--without-zlib \
--with-expat \
--with-python} \
--prefix=$HOME/rtems-dev/rtems/4.11

Building or1ksim

You can follow instructions here to build and configure OpenRISC simulator- or1ksim. Patch for building or1ksim from RSB is on its way to be commited soon.

Monday, April 14, 2014

My experience with GSoC



Back to 2012, I was already familiar with some interesting program called GSoC that Google organizes for students to do open source software projects. Like most of CS and Computer Engineering students, GSoC was a great opportunity: only if I could have the chance to participate in. The expectation of being accepted was almost null for me. But why not giving a try? What will I lose? So, I decided to take a step.

Embedded Systems, Operating Systems, RTOS, C: all the keywords I needed to find an accepted organization which matches my interests, and that's exactly what RTEMS tags include in the melange website: the official host for GSoC program. Immediately, I clicked on the link to the RTEMS website, read what RTEMS is about, and searched for open projects. Not surprisingly, there was an open project that appealed to me. To be able to write down a good proposal, I started to read more documentations. After having some headlines in the proposal, it was gradually increasing in size, details and consistency in parallel with reading more about the project details and grasping more concepts. "Nice, now I think I can submit my proposal," I said to myself. Fortunately, submitting my proposal was early and, later, I knew this was one lucky move; I got a lot of valuable and detailed comments from the folks of RTEMS community. That's how things became serious.

The comments made me feel that what I proposed was something important, and needed by users; a feeling that I never had before. I began to try to understand comments, ask about more details, read more and more; consequently, these comments dramatically re-factored my proposal structure and details. After a few weeks of discussions and modifications, the proposal was ready. Once the deadline of application period hit, I was comfortable with what I did. I thought I could not have done better. Few weeks later, the accepted projects were announced, and guess what? I had been accepted! Absolutely, that was a turning point in my life.

I got to do new things and learn interesting stuff about software engineering, how design phase is very important, the benefits of feedback and discussions, why it’s useful to frequently interact with the community via mailing list and IRC. Moreover, I learned a lot about technical issues and coding. Exclusively to my project with RTEMS, my technical hands-on experience has been enriched in a variety of areas like: C programming, RTOS, gdb, gcc, simulators, hardware, embedded systems, git, source control, documentation, other open source tools, and a lot more. Making connections with some great mentors there was one great aspect of participating in GSoC.

I enjoyed having commitments, deadlines, challenges and troubles. That's what GSoC is partially about (other than encouraging students to work with open source software): a real world work experience. People in RTEMS, and any other organization, want you to complete your project successfully. They are thrilled to help you with every challenge you face. Thanks to my mentor, I was able to pass midterm and final evaluations, and I could brag that I am a former GSoC participant.


Statement of accomplishment - GSoC'2012

Next year (2013), I applied to GSoC with RTEMS (again!) and I have been accepted. Right after GSoC, I participated in GCI--Google Code In--as a mentor, not surprisingly, with the same organization. This year (2014), I have applied to GSoC with RTEMS and I am currently awaiting the announcement of accepted students (wish me luck).


GCI'2013

For me, GSoC made what it aims/claims to achieve:

(a) I learned much about open source software.
(b) Now I am stuck to open source and RTEMS.
(c) Got hands-on experience with real world software process.
(d) Made connections with great developers.
(e) Achieved a glory (and got a nice paycheck).

If you are a student and you're considering applying to GSoC, here is my two cents:

(a) Do not worry about your modest experience, you're ought to learn in the first place. Basics are enough.
(b) Make a proposal and get in touch with the organization community. Do both early!
(c) Your proposal should be well structured and detailed. It should explain how will you work on the project and give a clear and reasonable timeline as well as deliverables. Most organizations provide a template for writing proposals.
(d) Choose a project that 1) appeals to the organization and its users, 2) match your interests. Most likely it will be one of the projects ideas.