Jaeyong ChungSoC Laboratory
Incheon National University
Embedded System Design
Term Project – Porting(v1.04)
� The reason why you install an OS on your embedded system is not only to do multi-tasking� Operating Systems provide hardware abstraction, which let you
run many existing applications on your system
� These days, it is not common to build something from scratch� Most software is developed by integrating existing
programs/libraries� There are tons of open-source programs on the Internet
� Porting is the process of adapting software so that an executable program can be created for a computing environment that is different from the one for which it was originally designed.
Porting
Chung EPC6071 2
Open-source Community
� www.sourceforge.net� www.github.com� and many more
Chung EPC6071 3
Term Project
� The objective is to port an open-source program for 320 embedded system� Choose one out of 4 given programs (MP3 player, image
viewer, web server, pacman game)� Source codes will be provided� Cross-compile and run it on the target system
Chung EPC6071 4
Term Project
� You are supposed to change the USER INTERFACEof the programs
� You don’t have to modify and even understand the core of the programs
� Modify the user interface and use as many I/O devices in the 320 (e.g., FND, dot-matrix, character display, keypad, etc) as possible
� Install necessary device drivers to the target system � Driver sources and test programs will be given
Chung EPC6071 5
General guidelines
� Download the source files� Compile it for your intel PC� Run it and think about how to modify its user interface� Repeat when you don’t have the board:
� Try to find how the program take inputs from the user and produce outputs in the source files� Use printf here and there
� Compile it for your intel PC� Run it
Chung EPC6071 7
General guidelines
� Repeat until the project is done:� Modify the source files referring to fnd_test.c, key_test.c, etc� Cross-compile it for the 320 embedded system� Transfer executables and libraries to the board using minicom� Run it
Chung EPC6071 8
Topics
� (easiest) HTTP server� (tinyhttpd-0.1.0, http://sourceforge.net/projects/tinyhttpd/ )
� (easy) MP3 Player� (mpg123-1.19.0, http://www.mpg123.de )
� (moderate) Image Viewer� (sxiv-1.2, https://github.com/muennich/sxiv )
� (difficult) Pacman Game� (njam-1.25, http://njam.sourceforge.net/ )
� (difficult) Overlay System� Use Xilinx Zynq SoC, 4 teams only
Chung EPC6071 9
Webserver
� tinyhttpd (http://sourceforge.net/projects/tinyhttpd/)� Ideas to modify :
� Control FND and the character display from the web browser in your smartphone
� And many more
� Download tinyhttpd-0.1.0.tar.gz from the website� Extract it
Chung EPC6071 10
Webserver (Compile)
� In tinyhttpd-0.1.0 directory� $ nano Makefile
� $ make� $ ./httpd
� Open firefox and connect to http://localhost:[port]
Chung EPC6071 11
Webserver (Cross-compile)
� In tinyhttpd-0.1.0 directory� $ nano Makefile
� $ make
Chung EPC6071 12
For the rest of topics
� $ sudo ln -s /usr/local/hybus-arm-linux-R1.3/ /usr/local/arm-linux-4.1.1
Chung EPC6071 13
MP3 Player
� mpg123 (http://www.mpg123.de)� Ideas to modify:
� Display the name of the song being played in the character display
� Display remaining time in the FND� Play, Stop, etc buttons using keypad� and many mores
� Download mpg123-1.22.1.tar.bz2 from the website� Extract it (use $ tar -jxvf )
Chung EPC6071 14
MP3 Player (Compile)
� $ sudo apt-get install libasound2-dev� In mpg123-1.22.1 directory
� $ ./configure� $ make� $ cd src� $ ./mpg123 xxxxx.mp3
Chung EPC6071 15
MP3 Player (cross-compile)
� In mpg123-1.22.1 directory� $ ./configure CC=/usr/local/hybus-arm-linux-R1.3/bin/arm-
linux-gcc --with-cpu=arm_nofpu --with-default-audio=alsa --host=i686 --build=arm --enable-modules=no
� $ make clean� $ make� $ ls ./src/mpg123
� That is the executable for ARM CPU
Chung EPC6071 16
Image Viewer
� sxiv-1.2� Dependencies: Imlib2 and giflib� https://github.com/muennich/sxiv� Ideas to modify
� Display the file name in the character display� Display something in FND� Next and previous buttons using the keypad� And many more
� Download the source files� $ git clone https://github.com/muennich/sxiv
Chung EPC6071 17
Image Viewer (compile)
� $sudo apt-get install libimlib2-dev � In sxiv directory
� $ make� $ ./sxiv image.jpg image.png image.gif
Chung EPC6071 18
Image Viewer (cross-compile) - 1
� Download imlib2-1.4.4.tar.gz from� http://freecode.com/projects/imlib2
� In imlib2-1.4.4 directory� $ ./configure CC=/usr/local/hybus-arm-linux-R1.3/bin/arm-
linux-gcc FREETYPE_CONFIG=/usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-gnueabi/bin/freetype-config --host=arm-none-linux --build=i686 --without-gif --prefix=/usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-gnueabi
� $ nano src/lib/loaderpath.h
� $ make� $ sudo make install
Chung EPC6071 19
Image Viewer (cross-compile) - 2
� Download giflib-5.1.1.tar.bz2 from� http://sourceforge.net/projects/giflib/
� In giflib-5.1.1 directory� $ ./configure CC=/usr/local/hybus-arm-linux-R1.3/bin/arm-
linux-gcc --host=arm-none-linux --build=i686 --prefix=/usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-gnueabi
� $ make� $ sudo make install
Chung EPC6071 20
Image Viewer (cross-compile) - 3
� In sxiv directory� $ nano Makefile
� $ make� $ ls sxiv
� That’s the executable for ARM
Chung EPC6071 21
Image Viewer (Install to the target board)
� Transfer dynamic libraries� /usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-
gnueabi/lib/libImlib2.so.1.4.4� /usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-
gnueabi/lib/libgif.so.6.0.1
� Transfer dynamic libraries into /root/imlib2/loaders� /usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-
gnueabi/lib/imlib2/loaders/jpeg.so� /usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-
gnueabi/lib/imlib2/loaders/png.so� /usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-
gnueabi/lib/imlib2/loaders/bmp.so
� Transfer the executable
Chung EPC6071 22
Pacman game
� njam-1.25 (http://njam.sourceforge.net/)� Note that njam is written in C++� Dependencies: SDL_mixer, SDL_net� Ideas to modify :
� Buttons to move� Display something on FND, dot-matrix, and/or character display� Fix the sound problem� Fix the resolution problem� And many more
� Download njam-1.25-src.tar.gz from the website� Extract it
Chung EPC6071 23
Pacman game (compile)
� $ sudo apt-get install build-essentials� $ sudo apt-get install libsdl1.2-dev libsdl-image1.2-
dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
� In njam-1.25-src� $ ./configure –prefix=/usr/local� $ make� $ sudo make install� $ njam -w
Chung EPC6071 24
Pacman game (cross-compile) - 1
� Fix a bug in SDL� $ sudo nano /usr/local/arm-linux-4.1.1/arm-iwmmxt-linux-
gnueabi/include/SDL/SDL_stdinc.h
Chung EPC6071 25
Pacman game (cross-compile) - 2
� Download SDL_mixer-1.2.12.tar.gz from� http://www.libsdl.org/projects/SDL_mixer/release-1.2.html
� In SDL_mixer-1.2.12 directory� $ ./configure PKG_CONFIG=/usr/local/hybus-arm-linux-R1.3/arm-
iwmmxt-linux-gnueabi/bin/pkg-config CC=/usr/local/hybus-arm-linux-R1.3/bin/arm-linux-gcc --host=arm-none-linux --build=i686 SDL_CONFIG=/usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-gnueabi/bin/sdl-config --prefix=/usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-gnueabi –disable-music-mod
� $ make� $ sudo make install
Chung EPC6071 26
Pacman game (cross-compile) - 3
� Download SDL_net-1.2.8.tar.gz from http://www.libsdl.org/projects/SDL_net/release-1.2.html
� In SDL_net-1.2.8 directory� $ ./configure PKG_CONFIG=/usr/local/hybus-arm-linux-R1.3/arm-
iwmmxt-linux-gnueabi/bin/pkg-config CC=/usr/local/hybus-arm-linux-R1.3/bin/arm-linux-gcc --host=arm-none-linux --build=i686 SDL_CONFIG=/usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-gnueabi/bin/sdl-config --prefix=/usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-gnueabi
� $ make� $ sudo make install
Chung EPC6071 27
Pacman game (cross-compile) - 4
� In the njam-1.25-src directory� Fix a bug in ./configure
� $ nano ./configure� In 4089 line,
� SDL_LIBS="`$SDL_CONFIG --libs`"� SDL_CFLAGS="`$SDL_CONFIG --cflags`“
� $ ./configure PKG_CONFIG=/usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-gnueabi/bin/pkg-config CC=/usr/local/hybus-arm-linux-R1.3/bin/arm-linux-gcc CXX=/usr/local/hybus-arm-linux-R1.3/bin/arm-linux-g++ --host=arm-none-linux --build=i686 SDL_CONFIG=/usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-gnueabi/bin/sdl-config --prefix=/root
Chung EPC6071 28
Pacman game (cross-compile) - 4
� $ make clean� $ make� $ sudo make install� $ ls ./src/njam
� This is the executable for the ARM cpu
Chung EPC6071 29
Pacman game (cross-compile) - 5
� Transfer dynamic libraries� /usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-
gnueabi/lib/libSDL-1.2.so.0.11.1� /usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-
gnueabi/lib/libSDL_image-1.2.so.0.1.5� /usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-
gnueabi/lib/libSDL_mixer-1.2.so.0.12.0� /usr/local/hybus-arm-linux-R1.3/arm-iwmmxt-linux-
gnueabi/lib/libSDL_net-1.2.so.0.8.0
Chung EPC6071 30
Pacman game (cross-compile) - 6
� Transfer image files,etc� $ sudo -i� $ cd /root/share� $ tar czvf njam.tar.gz njam� Transfer njam.tar.gz and extract it at /usr/local/share
� Transfer the executable
Chung EPC6071 31
Overlay System
� Recommended for who took digital integrated circuits� Will use Xilinx Zynq SoC
� Cortex A9 + FPGA on a single chip
� Will exercise all of what you have learned in DIC and this course
� Need to develop hardware controllers and test programs
� Before you start:� Finish the following tutorial� https://www.digilentinc.com/Data/Products/ZYBO/ZYBO-
Embedded_Linux_Hands-on_Tutorial.pdf
Chung EPC6071 32
Overlay System
Chung EPC6071 33
ARM A9
Frame buffer
Overlay buffer
Zynq SOC
OV7670 Ctrl
VGA Ctrl