My first port on Ben NanoNote: gnuchess (Howto)
Set up of the framwork and toolchain compilation
on Ubuntu/Debian to obtain the packages needed to start working with OpenWRT execute the following in a console:
sudo apt-get install gcc g++ binutils patch bzip2 flex bison make gettext unzip libz-dev libc6 ncurses-dev subversion libxml-simple-perl gawk git-core
We will create a folder where we will save all related OpenWRT stuff, and we will download the framwork with git from qi-hardware repositories to be up to date and future updating.
git clone git://projects.qi-hardware.com/openwrt-xburst.git
git fetch origin
git checkout --track -b xburst origin/xburst
Here a popup will be shown with a graphical menu, this is the OpenWRT configuration menu, as you can see is based on the Linux kernel configuration menu, here we can select the packages we want to compile and a lot of parameters to generate a firmware to fit our needs, for now we will focus on select the Target Platform.
On Target we have to select "Ingenic Xburst" which is the Ben NanoNotes platform
Select Exit and select Yes when asked to save changes
We can return to that menu executin "make menuconfig"
To compile the toolchain, last kernel and some basic packages just type the folowing in the console:
Creating a Package with OpenWRT
In OpenWRT the packages are defined by a Makefile file, we will not enter in too much detail about aaaaaalll the parameters,variables and functions you can use in that file, instead we have take the example from here and we have modified it to fit our package
Now we will create a folder to create our own package and avoid messing with core ones of OpenWRT framwork, out of folder openwrt-xburst, to the folder we we create now you can name it as you like
Due I have the willing, if time and fortune allow me, to create various ports I have createda s subfolder for games inside this folder
and a folder to the package itself
and we will create a text file witho our favourite editor in my case joe
Lines marked as # are coments to explain briefly each part
# Copyright (C) 2008 OpenWrt.org
# This is free software, licensed under the GNU General Public License v2.
##name of the package
## version application we will i
## Version number of the package itself
##Name of the file with the source code, we use the variables we just have defined
##Url where the source file is aviable for downloading
## program to decompress de source file
#Definition of the package, title, classification and url of the project
#this info will be included in the ipkg and used to classify in the menuconfig
TITLE:=Chess GNU from FSF
#Folder where we will extract source and build the application
#BUILD_DIR is a framework variable of OpenWrt commonly used by all packages
#Long description of the application
GNU Chess lets most modern computers play a full game of chess. It has a plain terminal interface but supports visual interfaces such as xboard and eboard
#If you don't have to pass any especial parameter to ./configure you can forget about the following block.
#Defining from and where to copy binaries and libraries when installed
#gnuchess builds the binary inside his src folder
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/gnuchess $(1)/usr/sbin/
#Final instruction to build the package.
$(eval $(call BuildPackage,gnuchess))
Save and go back to the openwrt-xburst folder, where we will include our folder as feed.
Third party packages, the feeds
OpenWRT includes an easy way to agregate packages not included in his own repositories, we will include our folder as feed.
On openwrt-xburst folder
cp feeds.conf.default feeds.conf
with this we activate some feed included by default by OpenWRT growing the packages available.
Add following line to the end of the feed.conf file
src-link mutroxports /path/where/you/created/folder/openwrt/mutroxports
now we will include the packages to the framework.
./scripts/feeds install -p mutroxports
and the next step is to compile our packages, we can select it in the menuconfig, than thanks to the black magic of OpenWRT has been inclueded in a new section called Games, as we define in the CATEGORY variable of the Makefile
Due build a full firmware is out of the scope os this Howto , we will select <M>
We can also build that package only directly from console without needed to review/rebuild all stuff.
OOOH it diiidn't wooooork... it briings an eeeerrroorrr,(I'm evil , isn't? }:P)
To take a look what can be the cause of this error we can execute
make package/gnuchess/compile V=99
Patches , solving errors and adapting the code
In the folder where we have defined our Makefile, we can include another subfolder called patches, there we can include the modification needed to application original source code to make the program able to compile, to strip unneeded parts, adapting gui for lower resolutions... well anithing we have to modify in the source code to adapt it to the target platform.
In our example the error is a different variable definition between the header common.h and the file input.c, in the line 719 of the common.h file we have to change extern by static , to generate the patch file I have made the following, in a temp folder, if posible far away of the one we have being working on to not mess up things:
Download the original sources
make a clone of the just extracted folder
cp gnuchess-5.07 gnuchess-5.07.mod
make the modifications in the cloned folder
and generate the patch with following command
diff -crB gnuchess-5.07 gnuchess-5.07.mod > 001_static_definition.patch
And we have the patch created, the tree numbers in the beginning of the patch file name is to let OpenWrt control the order how the patch has to be applied if there is more than one pathch to be applied, but not applicable on this case.
If any body knows a more confortable way of generating patch, I'm all ears :P
Create a folder patches inside the gnuchess folder
cp 001_static_definition.patch /
and now yes!, we return to the openwrt-xburst folder and execute
And if every thing works as expected in the openwrt-xburst/bin/xburst/packages you will finde a brand new ipkg packages ready to install in Ben as you can find in http://tuxbrain.org/downloads/nanonote/packages :)
In http://tuxbrain.org/downloads/nanonote/mutroxports you can find the Makefile and the patches folder
This tutorial has been created quickly, at late hours of the night, and translated without too much deep review so any mistake you can find on it please report in the comments and I will try to fix it as soon as possible :)