Thursday, August 23, 2018
There is still some minor traffic to this website and probably some visitors were disapointed that I redirect to not existing Github page in previous post, which is 5 years old. For last 4 years I was busy building my Embedded Systems Consulting buisness called 3mdeb. If you found things useful in my old blog you should be satisfied with content of followin website:
Tuesday, March 19, 2013
Blog moved to pietrushnic.github.com
Always ask yourself: What I can do better ?
In this case to improve blogger and readers experience I have to move to different framework. I choose Octopress and put my blog on github. All posts were transferred to new blog so its content wasn't lost. Please inform any interested parties.
You can find my blog on:
In this case to improve blogger and readers experience I have to move to different framework. I choose Octopress and put my blog on github. All posts were transferred to new blog so its content wasn't lost. Please inform any interested parties.
You can find my blog on:
Tuesday, January 15, 2013
Short hint for all those who use vim and pathogen
Today, after updating my wokspace to latest version I encounter below error during vim running:
Error detected while processing function pathogen#runtime_append_all_bundles:
line 1:
E121: Undefined variable: source_path
E116: Invalid arguments for function string(source_path).') to pathogen#incubate('.string(source_path.'/{}').')')
E116: Invalid arguments for function 4_warn
Press ENTER or type command to continue
Quick look on pathogen runtime_append_all_bundles function and I found:
call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#incubate('.string(a:1.'/{}').')')
So simply replacing:
call pathogen#runtime_append_all_bundles()with:
call pathogen#incubate()in $HOME/.vimrc fix the problem.
Labels:
linux,
productivity,
vim
Sunday, November 18, 2012
Sqlite3 gem not supported on Heroku
When I tried to deploy second part of RoR tutorial to Heroku I get this error:
An error occurred while installing sqlite3 (1.3.5), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.5'` succeeds before bundling.
!
! Failed to install gems via Bundler.
!
! Detected sqlite3 gem which is not supported on Heroku.
! http://devcenter.heroku.com/articles/how-do-i-use-sqlite3-for-development
!
! Heroku push rejected, failed to compile Ruby/rails app
To git@heroku.com:thawing-beyond-7283.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:thawing-beyond-7283.git'
I searched a little bit about this error and find this stackoverflow post. But when I look more carefully on the Gemfile syntax I found a mistake. I used simply:
gem 'sqlite3', '1.3.5'But I should have:
group :development do gem 'sqlite3', '1.3.5' end group :production do gem 'pg', '0.12.2' endAs RoR tutorial states.
Prepare for Ruby on Rails on Debian wheezy
I start to learn Ruby on Rails. As always when you learn new programming language toolchain is required. In this tutorial I will try to go through toolchain preparation for my Debian wheezy. Of course I based on Vim as my editor of choice. Second requirement will be using some parts of toolchain in latest greatest version.
As a beginner point for learning Ruby on Rails I choose this tutorial. I will try to use their methods of setting environment adding my comments where it is needed. Also will resolve Debian and Vim specific issues. So let's begin.
After quick look at RoR tutorial I have to switch to this site for installation for Ubuntu 12.04 LTS. But instructions don't work as expected for my Debian. So after quick:
As a beginner point for learning Ruby on Rails I choose this tutorial. I will try to use their methods of setting environment adding my comments where it is needed. Also will resolve Debian and Vim specific issues. So let's begin.
After quick look at RoR tutorial I have to switch to this site for installation for Ubuntu 12.04 LTS. But instructions don't work as expected for my Debian. So after quick:
sudo apt-get install git curlI realized that I need proxy for curl and not only temporary but permanent. I added below line to my $HOME/.curlrc:
proxy=proxy.server.com:8080After that I was able to download and install stable version of rvm:
curl -L get.rvm.io | bash -s stableNext I sourced configuration:
source ~/.rvm/scripts/rvmOutput which I get was:
pietrushnic@lothlann:~/src/node$ rvm requirements
Requirements for Linux "Debian GNU/Linux wheezy/sid"
NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
This is the *original* / standard Ruby Language Interpreter
'ree' represents Ruby Enterprise Edition
'rbx' represents Rubinius
bash >= 4.1 required
curl is required
git is required (>= 1.7 for ruby-head)
patch is required (for 1.8 rubies and some ruby-head's).
To install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head),
then you must install and use rvm 1.8.7 first.
Additional Dependencies:
# For Ruby / Ruby HEAD (MRI, Rubinius, & REE), install the following:
ruby: /usr/bin/apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-config
# For JRuby, install the following:
jruby: /usr/bin/apt-get install curl g++ openjdk-6-jre-headless
jruby-head: /usr/bin/apt-get install ant openjdk-6-jdk
# For IronRuby, install the following:
ironruby: /usr/bin/apt-get install curl mono-2.0-devel
I need Ruby so copy&paste line for it and:
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion pkg-configNext thing we need is Node.js because this code of JavaScript runtime is under active development (latest version is 0.8.14 and Debian provided for sid 0.6.19) we use its latest greatest version from git repository.
git clone https://github.com/joyent/node.gitFollowing by:
cd node;./configure;make;make testIn my configuration only one test failed test-tls-server-verify:
Running 'Allow both authed and unauthed connections with CA1'
assert.js:102
throw new assert.AssertionError({
^
AssertionError: agent1 rejected, but should NOT have been
at ChildProcess. (/home/pietrushnic/src/node/test/simple/test-tls-server-verify.js:217:14)
at ChildProcess.EventEmitter.emit (events.js:96:17)
at Process.ChildProcess._handle.onexit (child_process.js:698:12)
at process._makeCallback (node.js:248:20)
This is known issue probably we have to wait for update of OpenSSL library in wheezy.
Ignore this problem and install node.js:
sudo make installBecause of RoR tutorial requirements we install version 1.9.3:
rvm get head && rvm reload rvm install 1.9.3Next thing will be adding vim-ruby for our favorite editor Vim. I organize my dotfiles using git. I also use pathogen to control Vim plugins (as described here), so :
cd workspace git submodule add https://github.com/tpope/vim-rails.git dotfiles/vim/bundle/vim-rails git submodule init && git submodule update git commit -m "vim-rails submodule added"Finally we have ready to use Ruby on Rails development environment based on Vim. I suggest to take a look at this movie and after that dive into tutorial.
Tuesday, November 13, 2012
New background and not so big "coming back"
It's been a long time since I last wrote anything on the blog. Because I hear complains about the background causing my blog hard to read I decide to change it.
I have little break in my side project and noticed that most read posts are related to some technical workarounds and solutions for different problems I decide to write a series about gcc errors and some solutions for it. I know it may sound like some complete spam and trash for blog, but when I searched for some explanation and solution of this errors sometimes it was hard to find them, sometimes it was hard to match with my code and finally sometimes I was unable to understand what is going on. I want to share what I learned and even if it wouldn't help anyone I want to have this in one place.
Recently I returned to my long-neglected hobby - chess. I will also try to write something constructive in this topic. Last time I also think a lot about embedded stuff (trying to reverse my printer), android (writing little project helping my colleague) and many other things. So maybe I will write about this. To not be boring I will simply get my hands dirty.
I have little break in my side project and noticed that most read posts are related to some technical workarounds and solutions for different problems I decide to write a series about gcc errors and some solutions for it. I know it may sound like some complete spam and trash for blog, but when I searched for some explanation and solution of this errors sometimes it was hard to find them, sometimes it was hard to match with my code and finally sometimes I was unable to understand what is going on. I want to share what I learned and even if it wouldn't help anyone I want to have this in one place.
Recently I returned to my long-neglected hobby - chess. I will also try to write something constructive in this topic. Last time I also think a lot about embedded stuff (trying to reverse my printer), android (writing little project helping my colleague) and many other things. So maybe I will write about this. To not be boring I will simply get my hands dirty.
Labels:
about this blog
Sunday, May 13, 2012
Mutt tutorial part 4 - html mails, address book and other useful features
How mutt can handle mails in html format ? Takling about html mail handling is talking about handling any type of Multipurpose Internet Mail Extensions. Mutt supports handling for all MIME types in one place for all programs. This place is .mailcap file. Googling a little bit I found below mailcap file configuration (kudos to Bart Nagel).
There is few more options that I found useful. To find it please go to my workspace scripts at github. Also if you have any issues with the configuration or comments please let me know by commenting below the post.
text/html; pandoc -f html -t markdown; copiousoutput; description=HTML Text; test=type pandoc >/dev/null text/html; lynx -stdin -dump -force_html -width 70; copiousoutput; description=HTML Text; test=type lynx >/dev/null text/html; w3m -dump -T text/html -cols 70; copiousoutput; description=HTML Text; test=type w3m >/dev/null text/html; html2text -width 70; copiousoutput; description=HTML Text; test=type html2text >/dev/nullOf course we need to install all applications to make mailcap work correct:
sudo apt-get install pandoc lynx w3m html2textTo bring address book functionality to mutt we need abook application:
sudo apt-get install abookAlso few new line in $HOME/.muttrc will be needed:
# add alias file for addresses set alias_file=~/.mutt/alias source ~/.mutt/alias # configure addressbook set query_command= "abook --mutt-query '%s'" macro index,pager A "<pipe-message>abook --add-email-quiet<return>" "add the sender address to abook"Adding new address simply create entry in alias file. During adding new alias abook asks about alias name, e-mail address, personal name and confirmation for given data. Some this fields could be filled automatically by interaction between abook and mutt. Of course file $HOME/.mutt/alias have to exist before running mutt:
touch $HOME/.mutt/aliasTo access saved aliases simply click <Tab> button in cc, to or bcc filed.
There is few more options that I found useful. To find it please go to my workspace scripts at github. Also if you have any issues with the configuration or comments please let me know by commenting below the post.
Labels:
linux
Mutt tutorial part 3 - sidebar, URLs in e-mails
Information in this post came from lunar linux page. Kudos to its author. In this post I want to discuss two topics: sidebar and how to open urls form inside mutt.
Sidebar is mutt feature delivered in mutt-patched package in Debian. It cause to split standard mutt window in two parts. In first we can find list of folders defined in the $HOME/.muttrc file, second window is a known old window with the list of posts. Mutt window with sidebar looks like on the picture below:
To use side bar we need to install mutt-patched packed in Debian:
To use side bar we need to install mutt-patched packed in Debian:
sudo apt-get install mutt-patchedTo make side bar more accessible I use default settings from lunar linux page. Add below lines to $HOME/.muttrc:
set sidebar_width = 30 set sidebar_visible = yes color sidebar_new yellow default bind index CP sidebar-prev bind index CN sidebar-next bind index CO sidebar-open bind pager CP sidebar-prev bind pager CN sidebar-next bind pager CO sidebar-openFirst line sets width of side bar it depends on how long are your folder names. Second line makes sidebar by default visible. Third makes folders with new messages yellow. Other lines create shortcuts for navigating sidebar. Note that C is not Ctrl but uppercase 'c' key. Second topic I want to discuss is how to open urls from inside e-mails. To do this we can use tip from mutt site. As it said we need urlview application:
sudo apt-get install urlviewTo correctly configure this tool you need to create $HOME/.urlview file. So:
vim $HOME/.urlviewIn this file we define two things. First will be regular expression which match urls and second will be command line to run when regexp was matched. File looks like below:
REGEXP (((https?|ftp|gopher)://|(mailto|file|news):)[^’ <>"]+|(www|web|w3).[-a-z0-9.]+)[^’ .,;<>":] COMMAND chromium %sChromuim is my browser of choice but you can use firefox, lynx or anything you want.
Labels:
linux
Mutt tutorial part 2 - secure login
This is second post of mutt tutorial series. As in the previous post for below information I need to thank Kousik for posts about gpg and using it with mutt. But probably the most important to simplify this method was Fau comment here. So going to the point of secure login for mutt we need gpg. First of all we need to install it by simply:
sudo apt-get install gpgAfter that we generate our keys by:
gpg --gen-keyI choose all default answers. So first is key type: 'RSA and RSA'. Second - keysize: 2048. Third - time for key expiration: '0 = key does not expire'. After that you need to identify your key with some data. This data will be used to find your key so IMHO it should be short and simple but meaningful. At the end of this process you will be asked about pass phrase, which will be used to decrypt files encrypted with generated key. When you end with key generation you can encrypt file with passwords. Best way to do this is to write some script that will be sourced by mutt after decryption. For storing passwords I create directory in my $HOME:
mkdir $HOME/.passwdInside this directory I create text file with the script, which look like below:
vim $HOME/.passwd/mutt.txt
set my_isp1 = "password1" set my_isp2 = "password2" set my_isp3 = "password3"This script of course mean to set value of variable name my_isp{1,2,3} to some password string. Remember to use 'my_' prefix because this is the way that user variables should be defined in mutt scripts. After writing this file we need to encrypt it.
gpg -e -o mutt.gpg mutt.txtNow we should delete txt file. To use our newly created encrypted password script we need to add some lines to $HOME/.muttrc. So:
vim $HOME/.muttrcLine that we need before sourcing encrypted scripts is declaration of variables in the script:
set my_isp1 = "" set my_isp2 = "" set my_isp3 = ""After this line we can source and decrypt out file with the passwords:
source "gpg --textmode -d ~/.passwd/mutt.gpg |"At the end wee need to replace all out plain text passwords (smtp_pass and imap_pass variables) with variables defined in out encrypted file. This settings will cause that mutt during start will run gpg to ask about password to decrypt password script file. In the next post I will discuss mutt with sidebar and how to open html files from inside mutt.
Labels:
linux
Mutt tutorial part 1 - setup IMAP account
Mutt is one of those programs that make people call you a linux geek, nerd or a snob. This is because using TUI or command line tools in world of fancy GUI for most people is wierd. What's so great about mutt? I probably still have not found much of its advantages, but at first glance we can notice a few things. First, it keeps Unix convention of small programs for specific task "Make each program to one thing well" or KISS. This means that mutt is only MUA, which is used to retrieve e-mails and for other tasks you need to use another application. However, due to the philosophy most applications are well suited to each other and usually everything works good. So you can easily combine it with Vim as the mail editor, abook as a address book, urlview as a browser launcher for html and graphics elements and so on. Third, it has support for IMAP which gives very nice usage model for most of e-mail account providers. Fourth, is used by such notables as Greg Kroah-Hartman and as kernel documentation suggest by other kernel developers. So lets start to discover mutt. Below I will discuss some basic features that until now (few days of using mutt) I found useful.
- Big kudos to Shinobu for this post it helps me a lot. So first of all we need support for multiple accounts. In my case I have 4 accounts. Three of them got working IMAP access. 4th provider screw up something and access to IMAP server doesn't work so I need to workaround this with one of the Gmail features. At the beginning we create $HOME/.muttrc file:
vim $HOME/.muttrc
IMAP account configuration for looks like that:# unset important variables account-hook . "unset imap_user; unset imap_pass" account-hook "imaps://<account_name>@<imap_server_address>/" "\ set imap_user = <e-mail_address> \ imap_pass = <e-mail_password>" # Setup for <e-mail_address>: set folder = imaps://<account_name>@<imap_server_address>/ # setup needed folders mailboxes = +INBOX =<folder_name> set spoolfile = +INBOX folder-hook imaps://<account_name>@<imap_server_address>/ "\ set folder = imaps://<account_name>@<imap_server_address>/ \ spoolfile = +INBOX \ postponed = +[Gmail]/Drafts \ record = +[Gmail]/'Sent Mail' \ from = '<your_name> <e-mail_address> ' \ realname = '<real_name>' \ smtp_url = smtps://<account_name>@<smpt_server_address> \ smtp_pass = <e-mail_password>"<account_name> - for foo.bar@gmail.com it will be foo.bar <imap_server_address> - this information you can get from your e-mail provider help pages or from the settings of web e-mail client, for Gmail it is imap.gmail.com
<e-mail_address> - your e-mail address
<e-mail_password> - your e-mail password, later we will discuss how to store this more secure than plain text :) <folder_name> - any folder (for gmail account also filters) you have on you IMAP account, so for gmail account it could be Drafts, Starred, Important or others. <your_name> - your real name or nick anything you want to show in from field <real_name> - could be the same as <your_name> <smpt_server_address> - your SMTP server address, for gmail users it will be smtp.gmail.com - If your e-mail provider have only pop3 access and you have gmail account you can use one of gmail account features to make your pop3 account visible as a IMAP folder. To do this got to Settings -> Accounts and Import and in the section "Check mail from other accounts" add your POP3 account. After that make sure to label your mails from POP3 account. Try to not use '@' in the label name because this cause problems during mutt configuration. If you set label for your POP3 account check if your label in Label tab have "Show in IMAP" marked, if yes everything was set correctly. To use this label in mutt simply add another <folder_name> to mailboxes line.
Labels:
linux
Saturday, April 21, 2012
Vim as a Blogger editor
Blogger.vim is a vim plugin for interfacing with Google's Blogger. Below I will use my workspace git repository. To use this plugin we need pretty new ruby >= 1.9.2 and gems nokogiri and net-https-wrapper. Let's install latest possible ruby for Debian, before that make sure you have latest updates:
sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgradeAnd ruby:
sudo apt-get install ruby1.9.3Before we install gems , we need to resolve some dependencies:
sudo apt-get install libxml2-dev libxslt1-devLatest nokogiri 1.5.2 have some issues, so we need to use 1.5.0 which is stable:
sudo gem install nokogiri --version 1.5.0And the wrapper for https:
sudo gem install net-https-wrapperFinally also pandoc will be neded to display web pages in vim:
sudo apt-get install pandocRight now we are able to run vim with blogger support. First we need to configure vim, add below lines to your $HOME/.vimrc file:
let g:blogger_blogid = 'your_blogid_here' let g:blogger_email = 'your_email_here' let g:blogger_pass = 'your_blogger_password_here'Run vim and try to list your blogger posts by typing:
:e blogger:listIf list of you see all your posts than it seems that plugin works good. Finally check writing feature. Create file with some text and type:
:w blogger:createFew things doesn't work as it should. Meybe I will find enough time to fix it. This article was created by using blogger.vim script.
Labels:
productivity
Wednesday, April 18, 2012
Debugging coreboot in qemu environment - part 2
In previous post coreboot was configured and installed. Here we try to establish good debugging environment for it. To create a good emulated environment to debug, research and learn coreboot few tricks are required. First of all we need to know how to run our emulated enviroment (qemu). What I mean by that ?
- load coreboot image (-bios option),
- freeze CPU at startup (-S),
- get appropriate feedback about virtual machine state (-d in_asm,cpu),
- set up remote gdb server to run qemu step by step (-s).
qemu -bios src/coreboot/build/coreboot.rom -s -S -d in_asm,cpu -nographicWe don't need graphics so it also could be disable (-nographic). Run above command and prepare debugging environment as described below.
- Set up gdb:
- load bootblock file in gdb:
file path/to/coreboot/build/bootblock.elf
- use objdump to find out at what address .text, .bss and .data sections are:
objdump -h src/coreboot/build/coreboot_ram|grep -E "text|bss|\.data"
my output looks like that:0 .text 00010810 00100000 00100000 00001000 2**2 3 .data 000004d8 001174e8 001174e8 000184e8 2**2 4 .bss 0000080c 001179c0 001179c0 000189c0 2**3
- use above addresses to load symbols from coreboot_ram file in gdb:
add-symbol-file src/coreboot/build/coreboot_ram 0x00100000 -s .data \ 0x001174e8 -s .bss 0x001179c0
- load bootblock file in gdb:
- In another terminal or screen window
vim /tmp/qemu.log
(use :e to reload qemu.log file after every instruction), in this file we will get information about all registers of virtual machine - target remote :1234
- Run next instruction (ni command in gdb) and refresh qemu.log, if you get something like:
EAX=00000000 EBX=00000000 ECX=00000000 EDX=00000633 ESI=00000000 EDI=00000000 EBP=00000000 ESP=00000000 EIP=0000fff0 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0 ES =0000 00000000 0000ffff 00009300 CS =f000 ffff0000 0000ffff 00009b00 SS =0000 00000000 0000ffff 00009300 DS =0000 00000000 0000ffff 00009300 FS =0000 00000000 0000ffff 00009300 GS =0000 00000000 0000ffff 00009300 LDT=0000 00000000 0000ffff 00008200 TR =0000 00000000 0000ffff 00008b00 GDT= 00000000 0000ffff IDT= 00000000 0000ffff CR0=60000010 CR2=00000000 CR3=00000000 CR4=00000000 DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000 DR6=ffff0ff0 DR7=00000400
it means that your debugging enviroment was set correctly.
Labels:
coreboot
Thursday, April 12, 2012
Building ARM toolchain - part 2: gcc and eglibc
Unfortunately after few tries of cross compiling eglibc using different source for instructions I alway end with hard to solve issues. Luckily, in the sources of eglibc I noticed instructions for cross-compiling written long time ago by Jim Blandy(I know i should start here). Lot of thanks to him for it. Below I describe my expierence which I gained during eglibc cross cpomliation for arm-unknown-linux-gnueabi and procedure that I used. Commands below contain some constants that I used in previous works. See this post. Eglibc library and the compiler itself is built with many various parameters this post is not the place to explain their meaning, please RTFM.
- Checkout eglibc from svn (as alwyas I try to use a latest sources possible). Version used r17815:
svn co http://www.eglibc.org/svn/trunk eglibc
- Link working ports to GNU/Linux on some machine architectures. They are not maintained in the official glibc source tree so we need to add it in this way:
ln -s ../ports eglibc/libc/ports/
- Create eglibc-headers directory:
mkdir eglib-headers; cd eglib-headers
- Configure eglibc and preliminary objects:
BUILD_CC=gcc CC=arm-unknown-linux-gnueabi-gcc CXX=arm-unknown-linux-gnueabi-cpp \ AR=arm-unknown-linux-gnueabi-ar RANLIB=arm-unknown-linux-gnueabi-ranlib \ ../eglibc/libc/configure --prefix=/usr --with-headers=$TARGET/usr/include \ --build=x86_64-pc-linux-gnu --host=arm-unknown-linux-gnueabi --disable-profile \ --without-gd --without-cvs --enable-add-ons
- Install eglibc headers:
make install-headers install_root=$TARGET install-bootstrap-headers=yes
- We need few object file to link shared libraries, which will be built and
installed by hand:
mkdir -p $TARGET/usr/lib make csu/subdir_lib cp csu/crt1.o csu/crti.o csu/crtn.o $TARGET/usr/lib
- To produce libgcc_s.so we need libc.so, but only need its dummy version because we'll never use it. It doesn't matter what we will point as a libc.so
we use /dev/null as C file.
arm-unknown-linux-gnueabi-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o \ $TARGET/usr/lib/libc.so
- Get latest gcc sources using git repository mirror. Latest commit while writing this post was 5b9a8c3:
cd .. git clone git://repo.or.cz/official-gcc.git
- Now, we can build gcc which can compile eglibc.
mkdir eglibc-gcc; cd eglibc-gcc ../official-gcc/configure --target=arm-unknown-linux-gnueabi \ --prefix=$TARGET/arm-x-tools --with-sysroot=$TARGET --disable-libssp \ --disable-libgomp --disable-libmudflap --enable-languages=c \ --with-gmp=$TARGET/arm-x-tools --with-mpfr=$TARGET/arm-x-tools \ --with-mpc=$TARGET/arm-x-tools --disable-libquadmath --build=$MACHTYPE \ --host=$MACHTYPE --with-local-prefix=$TARGET/arm-x-tools --disable-multilib \ --with-float=soft --with-pkgversion="pietrushnic" --enable-threads=no \ --enable-target-optspace --disable-nls --enable-c99 --enable-long-long make -j4 make install
- Confugure and compile final version of eglibc.
mkdir eglibc-final cd eglibc-final/ BUILD_CC=gcc CC=arm-unknown-linux-gnueabi-gcc CXX=arm-unknown-linux-gnueabi-cpp \ AR=arm-unknown-linux-gnueabi-ar RANLIB=arm-unknown-linux-gnueabi-ranlib \ ../eglibc/libc/configure --prefix=/usr --with-headers=$TARGET/usr/include \ --build=x86_64-pc-linux-gnu --host=arm-unknown-linux-gnueabi --disable-profile \ --without-gd --without-cvs --enable-add-ons make make install install_root=$TARGET
- Install libelf library
wget http://www.mr511.de/software/libelf-0.8.13.tar.gz tar zxvf libelf-0.8.13.tar.gz cd libelf-0.8.13/ ./configure --prefix=$TARGET/arm-x-tools --disable-shared --enable-static make;make install
- Prepare final version of gcc.
cd .. mkdir final-gcc cd final-gcc ../official-gcc/configure --target=arm-unknown-linux-gnueabi \ --prefix=$TARGET/arm-x-tools --with-sysroot=$TARGET --disable-libssp \ --disable-libgomp --disable-libmudflap --enable-languages=c,c++ --with-gmp=$TARGET/arm-x-tools --with-mpfr=$TARGET/arm-x-tools --with-mpc=$TARGET/arm-x-tools --disable-libquadmath --build=$MACHTYPE \ --host=$MACHTYPE --with-local-prefix=$TARGET/arm-x-tools --disable-multilib \ --with-float=soft --with-pkgversion="pietrushnic" --enable-threads=posix \ --enable-target-optspace --disable-nls --enable-c99 --enable-long-long \ --enable-__cxa_atexit --enable-symvers=gnu --with-libelf=$TARGET/arm-x-tools \ --enable-lto make make install
- Few libraries should be copied manualy
cp -d $TARGET/arm-x-tools/arm-unknown-linux-gnueabi/lib/libgcc_s.so* $TARGET/lib cp -d $TARGET/arm-x-tools/arm-unknown-linux-gnueabi/lib/libstdc++.so* $TARGET/lib
- Compile and install chrpath - this is useful tool to remove the rpath or runpath setting from binary.
cd .. sudo apt-get install libc6-i386 gcc-multilib apt-get source chrpath cd chrpath-0.13/ CFLAGS=-m32 ./configure --prefix=$TARGET/arm-x-tools \ --program-prefix=arm-unknown-linux-gnueabi- make make install
- Strip debug symbols
strip --strip-debug $TARGET/arm-x-tools/lib/* \ $TARGET/arm-x-tools/arm-unknown-linux-gnueabi/lib/* $TARGET/arm-x-tools/libexec/*
strip --strip-unneeded $TARGET/arm-x-tools/bin/* \ $TARGET/arm-x-tools/arm-unknown-linux-gnueabi/bin/*
arm-unknown-linux-gnueabi-strip --strip-debug $TARGET/lib/* $TARGET/usr/lib/*
- At the end simple test to find out if basic functionality works:
$ cat > hello.c <<EOF > #include <stdio.h> > int > main (int argc, char **argv) > { > puts ("Hello, world!"); > return 0; > } > EOFTry to cross compile C file:$TARGET/arm-x-tools/bin/arm-unknown-linux-gnueabi-gcc -Wall hello.c -o hello
$ cat > c++-hello.cc <<EOF > #include <iostream> > int > main (int argc, char **argv) > { > std::cout << "Hello, C++ world!" << std::endl; > return 0; > } > EOFTry to cross compile C++ file:$TARGET/arm-x-tools/bin/arm-unknown-linux-gnueabi-g++ -Wall c++-hello.cc -o \ c++-hello
Displays the information contained in the ELF header and in the file's segment headers:$TARGET/arm-x-tools/bin/arm-unknown-linux-gnueabi-readelf -hl hello $TARGET/arm-x-tools/bin/arm-unknown-linux-gnueabi-readelf -hl c++-hello
Result should look like that:ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: ARM (...) Flags: 0x5000002, has entry point, Version5 EABI (...) Program Headers: (...) INTERP 0x000134 0x00008134 0x00008134 0x00013 0x00013 R 0x1 [Requesting program interpreter: /lib/ld-linux.so.3] LOAD 0x000000 0x00008000 0x00008000 0x004b8 0x004b8 R E 0x8000 (...)$TARGET/arm-x-tools/bin/arm-unknown-linux-gnueabi-readelf -d \ $TARGET/lib/libgcc_s.so.1
Result should look like that:(...) Tag Type Name/Value 0x00000001 (NEEDED) Shared library: [libc.so.6] 0x0000000e (SONAME) Library soname: [libgcc_s.so.1] 0x0000000c (INIT) 0xcc2c (...)
Labels:
embedded
Friday, April 6, 2012
How to download videos from videos.linux.com
Therefore, I'm leaving for the Easter holidays I wanted to download some lecture on embedded systems, which was presented at the 2012 Embedded Linux Conference. Although I regret I found that I could not find as good quality copy in the network as on the Linux Foundation page. It is unfortunate that linux.com site does not have the possibility of direct downloading video files. But there is a workaround. Follow below tutorial:
- Go to page with video. For example: http://video.linux.com/videos/to-provide-a-long-term-stable-linux-for-industry
- Click play on the video and if you using Chrome browser right click on player window and inspect this element. Result should look like that:
- Expand div tag marked in red on screenshot above. If video was start you should see video tag which contain two links to video files mp4 and webm. Screen shot below shows hot it should look like:
Labels:
linux
Tuesday, March 20, 2012
Building ARM toolchain - part 1: libs and binutils
Searching the internet for information on how to build arm toolchain from scratch I realize that it is very hard to find information about this matter (and recent one even harder). I will try to fill this lack of information and try to build toolchain. My main goal is to use a component based on the GNU public license, and using them in as the newest version as it is possible.
What is toolchain ? (according to wikipedia):
Requirements:
- Cross compiler, I create one using corsstool-ng and describe this process in previous post. I will use arm-unknown-linux-gnueabi as entry point compiler. - $TARGET is defined as my destination directory
Procedure:
What is toolchain ? (according to wikipedia):
In software, a toolchain is the set of programming tools that are used to create a product (typically another computer program or system of programs). The tools may be used in a chain, so that the output of each tool becomes the input for the next, but the term is used widely to refer to any set of linked development tools.
Requirements:
- Cross compiler, I create one using corsstool-ng and describe this process in previous post. I will use arm-unknown-linux-gnueabi as entry point compiler. - $TARGET is defined as my destination directory
export TARGET=/home/pietrushnic/sandbox/toolchain
Procedure:
- Kernel header files:
- clone linux git repository
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
- install headers $TARGET is home of our toolchain
make ARCH=arm INSTALL\_HDR\_PATH=\$TARGET/usr headers\_install
- Libraries (gmp, mpfr, mpc)
- GMP (GNU Multiple Precision Arithmetic Library) - changeset used: 14765:0acae62fa162
- As I said before I use "latest greatest" ;P version, and for gmp we can reach it using:
hg clone http://gmplib.org:8000/gmp
- create configuration files
./.bootstrap
- configure
./configure --prefix=$TARGET/arm-x-tools --enable-shared=n \ --enable-static
- compile
make make check make install
- As I said before I use "latest greatest" ;P version, and for gmp we can reach it using:
- MPFR (GNU Multiple Precision Floating-Point Reliably) - version: r8103
- get latest version
svn checkout svn://scm.gforge.inria.fr/svn/mpfr/trunk mpfr
- create configuration file
autoreconf -i
- configure
./configure --prefix=$TARGET/arm-x-tools --enable-thread-safe \ --with-gmp=$TARGET/arm-x-tools --disable-shared --enable-static
- compile
make make install
- get latest version
- MPC (Multiple Precision Complex)- version: r1146
- checkout svn
svn checkout svn://scm.gforge.inria.fr/svnroot/mpc/trunk mpc
- create configuration file
autoreconf -i
- configure
./configure --prefix=$TARGET/arm-x-tools \ --with-gmp=$TARGET/arm-x-tools --with-mpfr=$TARGET/arm-x-tools \ --disable-shared --enable-static
- compile
make make install
- checkout svn
- GMP (GNU Multiple Precision Arithmetic Library) - changeset used: 14765:0acae62fa162
- Binutils - collection of a GNU binary tools:
- checkout version from anonymous cvs
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login
create directory for checkoutmkdir binutils
checkout sourcescvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co binutils
- configure
LDFLAGS="-Wl,-rpath -Wl,$TARGET/arm-x-tools/lib" ./configure \ --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu \ --target=arm-unknown-linux-gnueabi --prefix=$TARGET/arm-x-tools \ --disable-nls --disable-multilib --disable-werror --with-float=soft \ --with-gmp=$TARGET/arm-x-tools --with-mpfr=$TARGET/arm-x-tools \ --with-mpc=$TARGET/arm-x-tools --with-sysroot=$TARGET
- compile
make configure-host make make install
- to check if everything was made correctly
ldd $TARGET/arm-x-tools/bin/arm-unknown-linux-gnueabi-ldd
it should show that it use library compiled previously by us:libz.so.1 => /home/pietrushnic/sandbox/toolchain/arm-x-tools/lib/libz.so.1 \ (0x00007f0086cc5000)
- checkout version from anonymous cvs
Labels:
embedded
Wednesday, March 14, 2012
Quick build of arm-unknown-linux-gnueabi with crosstool-ng
You might be surprised at how much you have to make to correctly build arm-unknown-linux-gnueabi config based toolchain with crosstool-ng. As you can see examples of many open source projects, the man's work is a rare resource. The result of this economic fact is that the attempt to build configuration arm-unknown-linux-gnueabi is not a simple task and during an operation you can come across many problems. Although I am not afraid of problems and effectively try to fight them and of course sharing the results of my work. My build system parameters:
Debian GNU/Linux wheezy/sid 3.2.0-2-amd64
Debian GNU/Linux wheezy/sid 3.2.0-2-amd64
- Clone crosstools-ng (you need mercurial)
hg clone http://crosstool-ng.org/hg/crosstool-ng
- Create temporary directory and run
ct-ng arm-unknown-linux-eabi
choose latest kernel (for me it was 3.2.9) - We probably want to change directory to which all stuff will be build (default is $HOME/x-tools):
ct-ng menuconfig
And go to:Paths and misc options ---> (${HOME}/x-tools/${CT_TARGET}) Prefix directoryChange it according to your needs. Exit end save configuration.- Build (number depend on how many command we want to run simultaneously):
ct-ng build.4
It can take a lot of time. On my machine with 5k BogoMips it takes over 1h.
- gcj - latest changeset 2916:6f758ed4c0b9 have trouble finding gcj binary,
which it show using following message:
[ERROR] Missing: 'x86_64-unknown-linux-gnu-gcj' or 'x86_64-unknown-linux-gnu-gcj' or 'gcj' : either needed!
To workaround this install gcj and link binary like this:sudo ln -s /usr/bin/gcj-4.6 /usr/bin/gcj
- duma - mentioned changeset also has problem with url to D.U.M.A library, apply below changes to workaround problems:
--- a/scripts/build/debug/200-duma.sh Mon Mar 12 21:19:26 2012 +0100 +++ b/scripts/build/debug/200-duma.sh Wed Mar 14 20:02:22 2012 +0100 @@ -4,7 +4,7 @@ # Downloading an non-existing file from sourceforge will give you an # HTML file containing an error message, instead of returning a 404. # Sigh... - CT_GetFile "duma_${CT_DUMA_VERSION}" .tar.gz http://kent.dl.sourceforge.net/sourceforge/duma/ + CT_GetFile "duma_${CT_DUMA_VERSION}" .tar.gz http://downloads.sourceforge.net/project/duma/duma/2.5.15 # Downloading from sourceforge may leave garbage, cleanup CT_DoExecLog ALL rm -f "${CT_TARBALLS_DIR}/showfiles.php"* } - mawk - if mawk return syntax error like this:
mawk: scripts/gen-sorted.awk: line 19: regular expression compile failed (bad class -- [], [^] or [)
It could be fixed in two ways. First is to change line 19 in /path/to/tmp/dir/.build/src/glibc-2.9/scripts/gen-sorted.awk Is:sub(/\/[^/]+$/, "", subdir);
Should be:sub(/\/[^\/]+$/, "", subdir);
Or simply by installing gawk, reconfigure and recompile crosstools-ng.
Labels:
embedded
Splitting my personal repository
After writing a few posts in which my workspace scripts could be useful, I realized that I should split blog works from the scripts that can be useful to others. From now materials related to the blog I will track in a separate repository and I'll add them as submodule into my environment. This implies that if we intend to deliver something to a broader audience this should include only those things which the recipient is expected and which we say that we provide. Any additional items should be removed. We get a lot of unwanted stuff today, at every opportunity. From an economic point of view, it is known that very often margin value law is used here i.e. by hypermarkets, I will touch on this subject on another occasion, related to economics.
Labels:
productivity
Monday, March 12, 2012
Debugging coreboot in qemu environment - part 1
First of all I use testing version of Debian - wheezy. Clone coreboot repository:
:e src/cpu/x86/16bit/reset16.inc
Put cursor over protected_start and press Ctrl-]. If everything goes ok you should jump to build/mainboard/emulation/qemu-x86/bootblock.s line 537.
In second article we dive into first phase of coreboot execution in emulated environment.
git clone http://review.coreboot.org/p/corebootConifigure:
cd coreboot; make menuconfigSet:
Payload ---> Add a payload ---> FILO Payload ---> FILO version ---> HEAD Debugging ---> Check PIRQ table consistency Debugging ---> Output verbose malloc debug messages Debugging ---> Output verbose ACPI debug messages Debugging ---> Enable debug messages for option ROM execution Debugging ---> Built-in low-level shell Debugging ---> Trace function callsTry to build:
makeIf everything builds correctly you can process. Sometimes there is need to use cross compiler. To build one:
cd util/crossgcc
./buildgccTo explore coreboot code effectively I suggest to create tags and cscope database for coreboot. In my personal workspace I've got process that I go through before I start work (if you use my workspace configuration which is available @github you can follow below steps directly, if not adjust to your enviroment):
- run vim ;)
- :cd /path/to/code
- s<Tab> (fuzzyfinder -> bookmark dir)
- si (fuzzyfinder -> change dir)
- sr (run ctags to generate tags and cscope to build symbol database - ctags -R;cscope -R -q -b -v)
:e src/cpu/x86/16bit/reset16.inc
Put cursor over protected_start and press Ctrl-]. If everything goes ok you should jump to build/mainboard/emulation/qemu-x86/bootblock.s line 537.
In second article we dive into first phase of coreboot execution in emulated environment.
Labels:
coreboot
Wednesday, March 7, 2012
"Human Action" Ludwig von Mises
"Human Action" Ludwig von Mises's work by some of called the pope of free market. IMHO is one of the best books on economics I read in my life. It is not easy, however, giving it time with certainly pays off. Allows to understand the basic laws which ruled the modern world of finance. Mises in a sensational way talk about the myths explaining what is inflation, why it has impact on our lives, what is and how works the supply of credit, and who depend most on the production of money without coverage (fiat money). I can say that until I read this book, I was lost in the dark. Thanks to it I received a weapon to overthrow ridiculous world order concepts, absurd messages communicated in the media. I recommend: mises.org store - Human Action
Labels:
books
Nice small additions for my blog
Blog has changed slightly. I've added two new sections: social media and afk. In "social media" I will add links to my profiles on various social networking sites. You'll find my most recent development achievements (@github) and twitts on topics of interest to me (@twitter). The second section, "afk" (away from keyboard) is intended for the information of life beyond the keyboard, which in my case is not too extensive. I will publish here information about the books we read, watched movies and many other interesting things, which can be passionate away from the keyboard.
Labels:
about this blog
Subscribe to:
Posts (Atom)


