SlideShare ist ein Scribd-Unternehmen logo
1 von 20
OpenWRT
Basic tutorial guide, memo.
by Antony.Wu
1
OpenWRT builtroot
• It is a set of Makefiles and patches that allows users to generate
a cross-toolchain and a root filesystem for embeded system.
• It generates cross-compiler toolchain and use the toolchain to
build an image for your target board, such as AR-5387un router.
• It can also download packages (feeds), patches (using quilt) it
for you.
• # make toolchain/gdb/prepare QUILT=1
• <modify files in build_dir/>
• # make toolchain/gdb/updatevim
• It has modified make targets: component/name/action.
• # make toolchain/gdb/compile V=s
• V=s means “Verboase = stdout/stderror”
• # make toolchain/gdb/clean V=s
2
V=?
s standard output/error
w shows only warning
3
Get OpenWRT buildroot
Main repositories and feeds
− # git clone git://git.openwrt.org/openwrt.git
− # git clone git://git.openwrt.org/packages.git
Barrier Breaker
− # git clone git://git.openwrt.org/14.07/openwrt.git
− # git clone git://git.openwrt.org/14.07/packages.git
− # svn co -r 42990
svn://svn.openwrt.org/openwrt/branches/barrier_bre
aker
4
Setup OpenWRT environment
Using Fedora distribution, you need the following
package ready.
− # yum install -y subversion binutils bzip2 gcc gcc-c++ gawk
gettext flex ncurses-devel zlib-devel make patch unzip perl-
ExtUtils-MakeMaker glibc glibc-devel glibc-static quilt
ncurses-lib sed sdcc intltool sharutils bison wget
Check environment variables
− # echo $SED # must be empty, or issue '# unset SED'
− # echo $GREP_OPTIONS # don't contain '--initial-tab'
Set the PATH:
− PATH=$PATH:<buildroot dir>/staging_dir/host/bin
− PATH=$PATH:<buildroot dir>/staging_dir/toolchain-
<platform>-<gcc_ver>-<libc_ver>/bin
5
Understand OpenWRT Feeds
It is a set of packages, like a ‘yum repo’, or ‘apt-get repo’ on
desktop linux.
 The script downloads the packages info into ‘feeds/’ .
 The script installs packages into ‘package/feeds/’
 Packages in feeds selectable by CONFIG_PACKAGE_xxxx in .config
file.
The repo is configured in the feeds.conf or feeds.conf.default
(such as yum repo configured in /etc/yum.repos.d)
A script is used to control those packages
 # ./scripts/feeds update -a
 Package index (information) will be stored into feeds/
 # ./scripts/feeds install <package_name>
 Src will be checkouted into package/feeds/<package_name>
OpenWRT Make
• Clean
• # make clean # rm -rf bin build_dir
• # make dirclean # rm -rf bin build_dir staging_dir toolchain logs
• # make distclean # all above, rm all downloaded packages and .config
• Ignore errors
• #IGNORE_ERRORS=1 make <make options>
• component/name/action.
• Clean Linux objects
• # make target/linux/clean V=s
• Clean package luci.
• # make package/luci/clean
6
OpenWRT Make sequence
1. # make tools/install
2. # make toolchain/install
3. # make target/compile
4. # make package/cleanup
5. # make package/compile
6. # make package/install
7. # make package/preconfig
8. # make target/install
9. # make package/index
You can issue them, one by
one, in order, so that you
can check and debug
each step.
7
Create OpenWRT package
• Special Makefile template.
• Please refer to BuildPackage variables
PKG_NAME:=broadcom-wl
PKG_VERSION:=5.10.56.27.3
PKG_RELEASE:=5
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(ARCH).tar.bz2
PKG_SOURCE_URL:=http://downloads.openwrt.org/sources
…
…
$(eval $(call KernelPackage,brcm-wl))
$(eval $(call KernelPackage,brcm-wl-mini))
$(eval $(call BuildPackage,wlc))
$(eval $(call BuildPackage,wl))
$(eval $(call BuildPackage,nas))
• BuildPackage only takes one argument directly – the
name of the package to be built, in this case “wlc".
# ls -l package/broadcom-wl/
files # default config.
Makefile
patches # patches from diff
src # source code
8
Create OpenWRT package 2
• BuildPackage define ‘Package/’
• The following describe the ‘define’ you may need:
define Package/broadcom-wl/Default
<action>
endef
• Package/description : description
• Package/conffiles : config-files installed by this pkg.
• Build/Prepare (optional): How to unpack/patch src.
• Build/Configure (optional) : How to configure src.
• Build/Compile (optional) : How to compile src.
• Build/InstallDev (optoinal) : Lib. needed
• Please refer to BuildPackage defines
Note: ‘define’ in makefile is like
‘=‘ operator.
Define the action when calling
‘Package/broadcom/wl/Default ‘
9
Create OpenWRT package 3
• Override Build option
• Autoconf
• Eg. CONFIGURE_VARS += ac_cv_header_regex_h=no
• Eg. CONFIGURE_ARGS += --disable-native-affinity
• Compiler flags
• Eg. TARGET_CFLAGS+= -Wall
• Make
• Eg. MAKE_VARS = CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)
$(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)"  …
• Eg. MAKE_FLAGS = $(TARGET_CONFIGURE_OPTS)  CROSS="$
(TARGET_CROSS)" ARCH="$(ARCH)“
• CMake and Scons
• CMAKE_OPTIONS, CMAKE_HOST_OPTIONS
• SCONS_VARS
10
Create OpenWRT package 4
• Adding configuration options
• Add MENU:=1
• Add Config.in Package/<name>/config
Makefile:
define Package/mjpg-streamer/config source
"$(SOURCE)/Config.in“
endef
Config.in:
menu "Configuration" depends on PACKAGE_mjpg-streamer
config MJPEG_STREAMER_AUTOSTART
bool "Autostart enabled" default n
• How to check your configuration
Makefile:
ifeq ($(CONFIG_MJPEG_STREAMER_INPUT_UVC),y)
$(CP) $(PKG_BUILD_DIR)/input_uvc.so $(1)/usr/lib
endif
11
Create OpenWRT package 5
• Working on local application source
• Using feeds to tracking your state-of-the-art
work.
# ln -s /path/to/local/awesome_app_tree/.git feeds/my_cool_feed/awesome_app/git-src
# make package/awesome_app/{clean,compile} V=s
• Using USE_SOURCE_DIR
# make package/awesome_app/clean V=s
# make package/awesome_app/prepare USE_SOURCE_DIR=~/src/awesome_src V=s
# make package/awesome_app/clean V=s
• make prepare needs to be run every time
• make package/awesome_app/{clean,compile}
USE_SOURCE_DIR=~blah doesn't work
12
OpenWRT kernel package

Adding configuration options

Add .mk file
#vim package/kernel/modules/block.mk
define KernelPackage/loop
SUBMENU:=$(BLOCK_MENU)
TITLE:=Loopback device support
KCONFIG:= CONFIG_BLK_DEV_LOOP CONFIG_BLK_DEV_CRYPTOLOOP=n
FLES:=$(LINUX_DIR)/drivers/block/loop.ko
AUTOLOAD:=$(call AutoLoad,30,loop)
endef
$(eval $(call KernelPackage,loop))
 Announce to build system.
# touch package/kernel/linux/Makefile

Add a kernel module that is not part of kernel
distribution
 Please refer to ‘package/madwifi/Makefile’ 13
What’s in the following slides?
1. # make tools/install
2. # make toolchain/install
3. # make target/compile
4. # make package/cleanup
5. # make package/compile
6. # make package/install
7. # make package/preconfig
8. # make target/install
9. # make package/index
You can issue them, one by
one, in order, so that you
can check and debug
each step.
14
External Toolchain
 Compile everything with the target board,
you will have a dir named toolchain, called
build1

Copy the .config-file from the build1 and
make menuconfig.
[*] Advanced configuration options (for developers)
[*] Use external toolchain
Target name: arm-openwrt-linux-uclibcgnueabi (in my case, yours may vary)
Toolchain prefix: arm-openwrt-linux-uclibcgnueabi- (mind the dash at the end)
Toolchain root: /path/to/toolchain/staging_dir/toolchain-arm_v5te_gcc-
linaro_uClibc-0.9.32_eabi
15
Alter download procedure

$DL_DIR is the location for download

Through "include/download.mk“

Init in “rules.mk”

To share downloaded packages

Put them in a shared location /opt/…

Check them in download procedure “define
Download” in file “download.mk”

MEMO: we can use shell to do this.

Eg . test -e /opt/dl/$(FILE) && ln -s /opt/dl/$(FILE) $(DL_DIR)/$(FILE) || (
$(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$
(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$
(DownloadMethod/unknown)) )
16
What has been added?
dl/ # for downloaded src.
build_dir/ # source code location
├── host
├── target-mips_mips32_uClibc-0.9.33.2
└── toolchain-mips_mips32_gcc-4.8.3_uClibc-0.9.33.2
logs/ # for compile logs
├── target
├── toolchain
└── tools
staging_dir/ # built out binary files.
├── host
├── target-mips_mips32_uClibc-0.9.33.2
└── toolchain-mips_mips32_gcc-4.8.3_uClibc-0.9.33.2
tmp/
17
What’s in the following slides?
1. # make tools/install
2. # make toolchain/install
3. # make target/compile
4. # make package/cleanup
5. # make package/compile
6. # make package/install
7. # make package/preconfig
8. # make target/install
9. # make package/index
You can issue them, one by
one, in order, so that you
can check and debug
each step.
18
Add our own BSP in target

The makefile in target will go into each
subdir.

Create a dir <BSP> of yours in the target dir.

Create a Makefile contains the following target.
all, download, prepare,
compile, install, clean

This also apply to the general ruls
 Eg # make target/<BSP>/prepare
19
Reference
1. http://wiki.openwrt.org/doc/start
2. http://wiki.openwrt.org/about/toolchain
3. http://wiki.openwrt.org/doc/devel/packages
20

Weitere ähnliche Inhalte

Was ist angesagt?

Porting a new architecture (NDS32) to open wrt project
Porting a new architecture (NDS32) to open wrt projectPorting a new architecture (NDS32) to open wrt project
Porting a new architecture (NDS32) to open wrt project
Macpaul Lin
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
hugo lu
 

Was ist angesagt? (20)

BPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLabBPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLab
 
Linux Network Stack
Linux Network StackLinux Network Stack
Linux Network Stack
 
BusyBox for Embedded Linux
BusyBox for Embedded LinuxBusyBox for Embedded Linux
BusyBox for Embedded Linux
 
Embedded linux network device driver development
Embedded linux network device driver developmentEmbedded linux network device driver development
Embedded linux network device driver development
 
Openwrt startup
Openwrt startupOpenwrt startup
Openwrt startup
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
 
DPDK KNI interface
DPDK KNI interfaceDPDK KNI interface
DPDK KNI interface
 
Porting a new architecture (NDS32) to open wrt project
Porting a new architecture (NDS32) to open wrt projectPorting a new architecture (NDS32) to open wrt project
Porting a new architecture (NDS32) to open wrt project
 
Openwrt wireless
Openwrt wirelessOpenwrt wireless
Openwrt wireless
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
FreeBSD and Drivers
FreeBSD and DriversFreeBSD and Drivers
FreeBSD and Drivers
 
DPDK In Depth
DPDK In DepthDPDK In Depth
DPDK In Depth
 
Embedded linux system development (slides)
Embedded linux system development (slides)Embedded linux system development (slides)
Embedded linux system development (slides)
 
LinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking WalkthroughLinuxCon 2015 Linux Kernel Networking Walkthrough
LinuxCon 2015 Linux Kernel Networking Walkthrough
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
Course 102: Lecture 20: Networking In Linux (Basic Concepts)
Course 102: Lecture 20: Networking In Linux (Basic Concepts) Course 102: Lecture 20: Networking In Linux (Basic Concepts)
Course 102: Lecture 20: Networking In Linux (Basic Concepts)
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
 
Introduction to Modern U-Boot
Introduction to Modern U-BootIntroduction to Modern U-Boot
Introduction to Modern U-Boot
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 

Ähnlich wie OpenWRT guide and memo

Gnubs pres-foss-cdac-sem
Gnubs pres-foss-cdac-semGnubs pres-foss-cdac-sem
Gnubs pres-foss-cdac-sem
Sagun Baijal
 
ZopeSkel & Buildout packages
ZopeSkel & Buildout packagesZopeSkel & Buildout packages
ZopeSkel & Buildout packages
Quintagroup
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
Opersys inc.
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
Ben Lin
 
LOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdfLOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdf
Thninh2
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + Puppet
Omar Reygaert
 

Ähnlich wie OpenWRT guide and memo (20)

[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
Gnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-semGnubs-pres-foss-cdac-sem
Gnubs-pres-foss-cdac-sem
 
Gnubs pres-foss-cdac-sem
Gnubs pres-foss-cdac-semGnubs pres-foss-cdac-sem
Gnubs pres-foss-cdac-sem
 
How to make debian package from scratch (linux)
How to make debian package from scratch (linux)How to make debian package from scratch (linux)
How to make debian package from scratch (linux)
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Asian Spirit 3 Day Dba On Ubl
Asian Spirit 3 Day Dba On UblAsian Spirit 3 Day Dba On Ubl
Asian Spirit 3 Day Dba On Ubl
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
ZopeSkel & Buildout packages
ZopeSkel & Buildout packagesZopeSkel & Buildout packages
ZopeSkel & Buildout packages
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
 
CMake Tutorial
CMake TutorialCMake Tutorial
CMake Tutorial
 
C make cache
C make cacheC make cache
C make cache
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
 
PHP selber bauen
PHP selber bauenPHP selber bauen
PHP selber bauen
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
 
Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-Translator
 
Autotools
AutotoolsAutotools
Autotools
 
LOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdfLOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdf
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + Puppet
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 

Kürzlich hochgeladen

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
rknatarajan
 

Kürzlich hochgeladen (20)

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 

OpenWRT guide and memo

  • 1. OpenWRT Basic tutorial guide, memo. by Antony.Wu 1
  • 2. OpenWRT builtroot • It is a set of Makefiles and patches that allows users to generate a cross-toolchain and a root filesystem for embeded system. • It generates cross-compiler toolchain and use the toolchain to build an image for your target board, such as AR-5387un router. • It can also download packages (feeds), patches (using quilt) it for you. • # make toolchain/gdb/prepare QUILT=1 • <modify files in build_dir/> • # make toolchain/gdb/updatevim • It has modified make targets: component/name/action. • # make toolchain/gdb/compile V=s • V=s means “Verboase = stdout/stderror” • # make toolchain/gdb/clean V=s 2 V=? s standard output/error w shows only warning
  • 3. 3 Get OpenWRT buildroot Main repositories and feeds − # git clone git://git.openwrt.org/openwrt.git − # git clone git://git.openwrt.org/packages.git Barrier Breaker − # git clone git://git.openwrt.org/14.07/openwrt.git − # git clone git://git.openwrt.org/14.07/packages.git − # svn co -r 42990 svn://svn.openwrt.org/openwrt/branches/barrier_bre aker
  • 4. 4 Setup OpenWRT environment Using Fedora distribution, you need the following package ready. − # yum install -y subversion binutils bzip2 gcc gcc-c++ gawk gettext flex ncurses-devel zlib-devel make patch unzip perl- ExtUtils-MakeMaker glibc glibc-devel glibc-static quilt ncurses-lib sed sdcc intltool sharutils bison wget Check environment variables − # echo $SED # must be empty, or issue '# unset SED' − # echo $GREP_OPTIONS # don't contain '--initial-tab' Set the PATH: − PATH=$PATH:<buildroot dir>/staging_dir/host/bin − PATH=$PATH:<buildroot dir>/staging_dir/toolchain- <platform>-<gcc_ver>-<libc_ver>/bin
  • 5. 5 Understand OpenWRT Feeds It is a set of packages, like a ‘yum repo’, or ‘apt-get repo’ on desktop linux.  The script downloads the packages info into ‘feeds/’ .  The script installs packages into ‘package/feeds/’  Packages in feeds selectable by CONFIG_PACKAGE_xxxx in .config file. The repo is configured in the feeds.conf or feeds.conf.default (such as yum repo configured in /etc/yum.repos.d) A script is used to control those packages  # ./scripts/feeds update -a  Package index (information) will be stored into feeds/  # ./scripts/feeds install <package_name>  Src will be checkouted into package/feeds/<package_name>
  • 6. OpenWRT Make • Clean • # make clean # rm -rf bin build_dir • # make dirclean # rm -rf bin build_dir staging_dir toolchain logs • # make distclean # all above, rm all downloaded packages and .config • Ignore errors • #IGNORE_ERRORS=1 make <make options> • component/name/action. • Clean Linux objects • # make target/linux/clean V=s • Clean package luci. • # make package/luci/clean 6
  • 7. OpenWRT Make sequence 1. # make tools/install 2. # make toolchain/install 3. # make target/compile 4. # make package/cleanup 5. # make package/compile 6. # make package/install 7. # make package/preconfig 8. # make target/install 9. # make package/index You can issue them, one by one, in order, so that you can check and debug each step. 7
  • 8. Create OpenWRT package • Special Makefile template. • Please refer to BuildPackage variables PKG_NAME:=broadcom-wl PKG_VERSION:=5.10.56.27.3 PKG_RELEASE:=5 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(ARCH).tar.bz2 PKG_SOURCE_URL:=http://downloads.openwrt.org/sources … … $(eval $(call KernelPackage,brcm-wl)) $(eval $(call KernelPackage,brcm-wl-mini)) $(eval $(call BuildPackage,wlc)) $(eval $(call BuildPackage,wl)) $(eval $(call BuildPackage,nas)) • BuildPackage only takes one argument directly – the name of the package to be built, in this case “wlc". # ls -l package/broadcom-wl/ files # default config. Makefile patches # patches from diff src # source code 8
  • 9. Create OpenWRT package 2 • BuildPackage define ‘Package/’ • The following describe the ‘define’ you may need: define Package/broadcom-wl/Default <action> endef • Package/description : description • Package/conffiles : config-files installed by this pkg. • Build/Prepare (optional): How to unpack/patch src. • Build/Configure (optional) : How to configure src. • Build/Compile (optional) : How to compile src. • Build/InstallDev (optoinal) : Lib. needed • Please refer to BuildPackage defines Note: ‘define’ in makefile is like ‘=‘ operator. Define the action when calling ‘Package/broadcom/wl/Default ‘ 9
  • 10. Create OpenWRT package 3 • Override Build option • Autoconf • Eg. CONFIGURE_VARS += ac_cv_header_regex_h=no • Eg. CONFIGURE_ARGS += --disable-native-affinity • Compiler flags • Eg. TARGET_CFLAGS+= -Wall • Make • Eg. MAKE_VARS = CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" … • Eg. MAKE_FLAGS = $(TARGET_CONFIGURE_OPTS) CROSS="$ (TARGET_CROSS)" ARCH="$(ARCH)“ • CMake and Scons • CMAKE_OPTIONS, CMAKE_HOST_OPTIONS • SCONS_VARS 10
  • 11. Create OpenWRT package 4 • Adding configuration options • Add MENU:=1 • Add Config.in Package/<name>/config Makefile: define Package/mjpg-streamer/config source "$(SOURCE)/Config.in“ endef Config.in: menu "Configuration" depends on PACKAGE_mjpg-streamer config MJPEG_STREAMER_AUTOSTART bool "Autostart enabled" default n • How to check your configuration Makefile: ifeq ($(CONFIG_MJPEG_STREAMER_INPUT_UVC),y) $(CP) $(PKG_BUILD_DIR)/input_uvc.so $(1)/usr/lib endif 11
  • 12. Create OpenWRT package 5 • Working on local application source • Using feeds to tracking your state-of-the-art work. # ln -s /path/to/local/awesome_app_tree/.git feeds/my_cool_feed/awesome_app/git-src # make package/awesome_app/{clean,compile} V=s • Using USE_SOURCE_DIR # make package/awesome_app/clean V=s # make package/awesome_app/prepare USE_SOURCE_DIR=~/src/awesome_src V=s # make package/awesome_app/clean V=s • make prepare needs to be run every time • make package/awesome_app/{clean,compile} USE_SOURCE_DIR=~blah doesn't work 12
  • 13. OpenWRT kernel package  Adding configuration options  Add .mk file #vim package/kernel/modules/block.mk define KernelPackage/loop SUBMENU:=$(BLOCK_MENU) TITLE:=Loopback device support KCONFIG:= CONFIG_BLK_DEV_LOOP CONFIG_BLK_DEV_CRYPTOLOOP=n FLES:=$(LINUX_DIR)/drivers/block/loop.ko AUTOLOAD:=$(call AutoLoad,30,loop) endef $(eval $(call KernelPackage,loop))  Announce to build system. # touch package/kernel/linux/Makefile  Add a kernel module that is not part of kernel distribution  Please refer to ‘package/madwifi/Makefile’ 13
  • 14. What’s in the following slides? 1. # make tools/install 2. # make toolchain/install 3. # make target/compile 4. # make package/cleanup 5. # make package/compile 6. # make package/install 7. # make package/preconfig 8. # make target/install 9. # make package/index You can issue them, one by one, in order, so that you can check and debug each step. 14
  • 15. External Toolchain  Compile everything with the target board, you will have a dir named toolchain, called build1  Copy the .config-file from the build1 and make menuconfig. [*] Advanced configuration options (for developers) [*] Use external toolchain Target name: arm-openwrt-linux-uclibcgnueabi (in my case, yours may vary) Toolchain prefix: arm-openwrt-linux-uclibcgnueabi- (mind the dash at the end) Toolchain root: /path/to/toolchain/staging_dir/toolchain-arm_v5te_gcc- linaro_uClibc-0.9.32_eabi 15
  • 16. Alter download procedure  $DL_DIR is the location for download  Through "include/download.mk“  Init in “rules.mk”  To share downloaded packages  Put them in a shared location /opt/…  Check them in download procedure “define Download” in file “download.mk”  MEMO: we can use shell to do this.  Eg . test -e /opt/dl/$(FILE) && ln -s /opt/dl/$(FILE) $(DL_DIR)/$(FILE) || ( $(if $(DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$ (DownloadMethod/$(call dl_method,$(URL),$(PROTO))),$ (DownloadMethod/unknown)) ) 16
  • 17. What has been added? dl/ # for downloaded src. build_dir/ # source code location ├── host ├── target-mips_mips32_uClibc-0.9.33.2 └── toolchain-mips_mips32_gcc-4.8.3_uClibc-0.9.33.2 logs/ # for compile logs ├── target ├── toolchain └── tools staging_dir/ # built out binary files. ├── host ├── target-mips_mips32_uClibc-0.9.33.2 └── toolchain-mips_mips32_gcc-4.8.3_uClibc-0.9.33.2 tmp/ 17
  • 18. What’s in the following slides? 1. # make tools/install 2. # make toolchain/install 3. # make target/compile 4. # make package/cleanup 5. # make package/compile 6. # make package/install 7. # make package/preconfig 8. # make target/install 9. # make package/index You can issue them, one by one, in order, so that you can check and debug each step. 18
  • 19. Add our own BSP in target  The makefile in target will go into each subdir.  Create a dir <BSP> of yours in the target dir.  Create a Makefile contains the following target. all, download, prepare, compile, install, clean  This also apply to the general ruls  Eg # make target/<BSP>/prepare 19