【html源码更改】【溯源码被查】【源码拉新】uclibc源码
1.arm-linux-gcc å arm-elf-gcc çåºå«
2.openWRT发展历程
3.å¦ä½å¨OpenWRTç¯å¢ä¸åå¼å
4.route OSä¸openWRTåºå«
arm-linux-gcc å arm-elf-gcc çåºå«
å¨åºäºARMçåµå ¥å¼ç³»ç»å¼åä¸ï¼å¸¸å¸¸ç¨å°äº¤åç¼è¯çGCCå·¥å ·é¾æ两ç§ï¼
arm-linux-*å arm-elf-*ï¼ä¸¤è åºå«ä¸»è¦å¨äºä½¿ç¨ä¸åçCåºæ件ãarm-linux-*使ç¨
GNUçGlibcï¼èarm-elf-*ä¸è¬ä½¿ç¨ uClibc/uC-libcæè 使ç¨REDHATä¸é¨ä¸ºåµå ¥å¼ç³»ç»
çå¼åçCåºnewlib.GlibcãuClibc/uC-libc以å newlibé½æ¯Cè¯è¨åºæ件ï¼åªæ¯æåº
ç¨çé¢åä¸åèå·²ï¼Glibcæ¯é对PCå¼åçï¼uClibc/uC-libcæ¯ä¸Glibc APIå ¼å®¹çå°å
åCè¯è¨åºï¼å®ç°äºGlibcé¨ååè½ã
ããå ³äºuClibc/uC-libcç说æï¼è¯¦è§å¦ä¸ï¼
ããThe源码html源码更改re are two libc libraries commonly used with uClinux. uC-libc and
uClibc. They are quite different despite their similar names. Here is a
quick overview of how they are different.
ããuC-libc is the original library for uClinux. It was based on sources
from the Linux- C library which was part of the ELKs project with m
support added by Jeff Dionne and Kenneth Albanowski. It is a fairly complete
libc implementation, however, some of the API's are a little non-standard
and quite a few common libc routines are not present. Currently it has
stable support for m, ColdFire and ARM (Non-MMU) architectures. It was
primary design goal is to be small and light weight. It does try to conform
to any standards, although its API tries to be compatible with most libcs,
it is not always exactly the same.
ããThe uClinux distribution provides an environment that can compile using
either uC-libc or uClibc depending on your needs. For m and Coldfire
platforms it is generally better to chose uC-libc as it supports shared
libraries and is the most commonly used libc for these CPUs. uClibc also
works quite well with almost all platforms supported by the distribution.
Which libc you choose to use will be decided by your requirements
uClinuxæ两个ç»å¸¸ä½¿ç¨çlibcåºï¼uC-libcåuClibcãè½ç¶ä¸¤è ååå¾ç¸ä¼¼ï¼å ¶å®æå·®
å«ï¼ä¸é¢å°±ç®åçä»ç»ä¸ä¸äºè çä¸åä¹å¤ãuC -libcæ¯ææ©ä¸ºuClinuxå¼åçåºï¼æ¯
Jeff DionneåKenneth Albanowski为å¨EKLs项ç®ä¸æ¯æmå¨Linux- Cåºæºç
ä¸ç§»æ¤çãuC-libcæ¯ä¸ä¸ªå®å ¨çlibcå®ç°ï¼ä½å ¶ä¸æä¸äºapiæ¯éæ åçï¼æäºlibcç
æ åä¹æ²¡æå®ç°ãuC-libc稳å®å°æ¯æ mï¼ColdFireå没æMMUçARMãå ¶ä¸»è¦è®¾è®¡
ç®æ æ¯âå°âã"è½»"ï¼å¹¶å°½éä¸æ åä¸è´ï¼è½ç¶å®çAPIåå¾å¤libcå ¼å®¹ï¼ä½æ¯ä¼¼ä¹å¹¶
ä¸åå®ææçé£æ ·åæææ åä¸è´ã
uClibcå°±æ¯ä¸ºäºè§£å³è¿ä¸ªé®é¢ä»uC-libcä¸åå±åºæ¥çãå®çææAPIé½æ¯æ åç(æ£ç¡®
çè¿åç±»åï¼åæ°çç)ï¼å®å¼¥è¡¥äºuC-libcä¸æ²¡æå®ç°çlibcæ åï¼ç°å¨å·²ç»è¢«ç§»æ¤å°
å¤ç§æ¶æä¸ãä¸è¬æ¥è®²ï¼å®å°½éå ¼å®¹glibc以便使åºç¨ç¨åºç¨uClibcæ¹ååç容æã
uClibcè½å¤å¨æ åç VM linuxåuClinuxä¸é¢ä½¿ç¨ã为äºåºç¨ç¨åºçç®æ´ï¼å®çè³å¯ä»¥
å¨è®¸å¤æ¯æMMUçå¹³å°ä¸è¢«ç¼è¯æå ±äº«åºãErik Andersonå¨uClibcèååäºå¾å¤çå·¥
ä½ãuClibcæ¯æ许å¤ç³»åçå¤çå¨ï¼mï¼Coldfireï¼ARMï¼MIPSï¼vï¼ xï¼
iï¼Sparcï¼SuperHï¼Alphaï¼PowerPCåHitachi 8ãä¸æå¢å çå¹³å°æ¯ææ¾ç¤ºuClibc
è½å¤å¾å®¹æçéåºæ°çæ¶æãuClinuxåè¡çæä¾äºç¯å¢è½å¤è®©ä½ éæ©ä½¿ç¨uC-libcææ¯
uClibcç¼è¯ã对äºmåColdfireå¹³å°æ¥è¯´ï¼éæ©uC-libcè¿æ¯ç¨å¾®å¥½ä¸ç¹ï¼å 为å®
æ¯æå ±äº«åºï¼èå ±äº«åºæ¯è¿äºcpuç»å¸¸ä½¿ç¨ç libc.uClibcä¹å ä¹åææçå¹³å°é½è½å¾
好çå·¥ä½ãéæ©åªç§libcåå³äºä½ çéæ±ã
newlib æ¯ä¸ä¸ªç¨äºåµå ¥å¼ç³»ç»çå¼æ¾æºä»£ç çCè¯è¨ç¨åºåºï¼ç±libcålibm两个åºç»
æï¼ç¹ç¹æ¯è½»é级ï¼é度快ï¼å¯ç§»æ¤å°å¾å¤CPUç»æä¸ãnewlibå®ç°äºè®¸å¤å¤æçå
è½ï¼å æ¬å符串æ¯æï¼æµ®ç¹è¿ç®ï¼å ååé (å¦malloc)åI/Oæµå½æ°(printfï¼fprinf()
çç)ãå ¶ä¸libcæä¾äºc è¯è¨åºçå®ç°ï¼èlibmæä¾äºæµ®ç¹è¿ç®æ¯æã
å¨ä¸ºARM交åç¼è¯gccç¼è¯å¨æ¶ï¼å¯¹gccæå®ä¸åçé ç½®é项æ¶ï¼ä½¿ç¨çCè¯è¨åºå°±ä¸åï¼
gccç¼è¯å¨é»è®¤ä½¿ç¨Glibcï¼ä¹å¯ä»¥ä½¿ç¨ uClibc/uC-libc(åºæ¬å ¼å®¹Glibc API)ï¼å½ä½¿ç¨
--with-newlibæ¶ï¼gccç¼è¯å¨ä¸ä½¿ç¨Glibcãå½æ²¡æ交åç¼è¯Glibcæ¶ï¼å¯ä»¥ä½¿ç¨
--with-newlibç¦æ¢è¿æ¥Glibcèç¼è¯bootstrap gccç¼è¯å¨ãä»gccæºç®å½ä¸ç
config/armä¸çt-linuxåt-arm-elfä¸å¯ä»¥çåºï¼ä¸åç--targetä¹å½±ågccè¿æ¥Cè¯è¨
åºï¼t-linux(--target=arm-linux)é»è®¤ä½¿ç¨Glibcï¼-arm-elf(--target=arm-elf)使ç¨
- Dinhibit_libcç¦æ¢è¿æ¥Glibcï¼è¿æ¶æ们就å¯ä»¥ä½¿ç¨newlibçå ¶ä»Cè¯è¨åºç¼è¯GCCå·¥
å ·é¾ã
è½ç¶GCCå·¥å ·é¾é ç½®äºä¸åççCè¯è¨åºï¼ä½ç±äºè¿äºCè¯è¨åºé½å¯ä»¥ç¨æ¥æ¯æGCCï¼å®ä»¬
å¯¹æ ¸å¿æ°æ®çå¤çä¸ä¸åå¨è¾å¤§åºå ¥ãå èarm-linux-* å arm-elf-*åºå«ä¸»è¦è¡¨ç°å¨
Cè¯è¨åºçå®ç°ä¸ï¼ä¾å¦ä¸åç³»ç»è°ç¨ï¼ä¸åçå½æ°éå®ç°ï¼ä¸åçABI\å¯å¨ä»£ç 以å
ä¸åç³»ç»ç¹æ§çå¾®å°çå·®å«ã
arm-linux-*å arm-elf-*ç使ç¨æ²¡æä¸ä¸ªç»å¯¹çæ åï¼æé¤ä¸ååºå®ç°çå·®å¼ï¼gccå¯
以ç¼è¯ä»»ä½ç³»ç»ãarm-linux-*å arm-elf-*é½å¯ä»¥ç¨æ¥ç¼è¯è£¸æºç¨åºåæä½ç³»ç»ï¼åª
æ¯å¨éµå¾ªä¸é¢çæè¿°æ¶ç³»ç»ç¨åºæ¾å¾æ´å åè°ï¼
arm-linux-*é对è¿è¡linuxçARMæºå¨ï¼å ¶ä¾èµäºæå®çCè¯è¨åºGlibcï¼å 为åæ ·ä½¿ç¨
Glibcçlinuxè使å¾arm-linux-*å¨è¿è¡linuxçARMæºå¨ä¸ç¼è¯æ¾å¾æ´å åè°ã
arm-elf-*åæ¯ä¸ä¸ªç¬ç«çç¼è¯ä½ç³»ï¼ä¸ä¾èµäºæå®çCè¯è¨åºGlibcï¼å¯ä»¥ä½¿ç¨newlib
çå ¶ä»Cè¯è¨åºï¼ä¸è¦æ±æä½ç³»ç»æ¯æï¼å½å ¶ä½¿ç¨ä¸ºåµå ¥å¼ç³»ç»è设计çä¸äºè½»å·§çCè¯
è¨åºæ¶ç¼è¯è£¸æºç¨åº(没ælinuxç大åæä½ç³»ç»çç¨åº)ï¼å¦çæ§ç¨åºï¼bootloaderç
è½ä½¿å¾ç³»ç»ç¨åºæ´å å°å·§å¿«æ·ã
Linaro prebuilt toolchain does support both hard and soft floating
point. You can get it from pile?\n\n");
return 0;
}
ããç¼åMakefileæ件
# build helloworld executable when user executes "make"
ããhelloworld: helloworld.o
$(CC) $(LDFLAGS) helloworld.o -o helloworld
ããhelloworld.o: helloworld.c
$(CC) $(CFLAGS) -c helloworld.c
ãã# remove object files and executable when user executes "make clean"
clean:
rm *.o helloworld
å¨è¿ä¸¤ä¸ªæ件çç®å½ä¸ï¼æ§è¡make åºè¯¥å¯ä»¥çæhelloworldçå¯æ§è¡æ件ãæ§è¡helloworldåï¼è½å¤æå°åºâHell! O' world, why won't my code compile?âã è¿ä¸æ¥ï¼ä¸»è¦ä¿è¯æ们çæºç¨åºæ¯å¯ä»¥æ£å¸¸ç¼è¯çãä¸é¢æ们å°å ¶ç§»æ¤å°OpenWRTä¸ã
ããï¼2ï¼å°OpenWrt-SDK-brcmxx-for-Linux-x_-gcc-4.3.3+cs_uClibc-0.9..1.tar.bz2解å
tar âxvf OpenWrt-SDK-brcmxx-for-Linux-x_-gcc-4.3.3+cs_uClibc-0.9..1.tar.bz2
ããï¼3ï¼è¿å ¥SDK
cd OpenWrt-SDK-brcmxx-for-Linux-x_-gcc-4.3.3+cs_uClibc-0.9..1
å¯ä»¥çå°éé¢çç®å½ç»æè·æ们ä¹åsourceçç®å½ç»æåºæ¬ç¸åï¼æéè¦ç¼è¯ç软件å ï¼éè¦æ¾ç½®å¨packageç®å½ä¸
ããï¼4ï¼å¨packageç®å½ä¸å建helloworldç®å½
cd package
mkdir helloworld
cd helloworld
ããï¼5ï¼å建srcç®å½ï¼æ·è´ helloworldæ件
mkdir src
cp /home/wrt/test/helloworld.c src
cp /home/wrt/test/Makefile src
ããï¼6ï¼å¨helloworldç®å½ä¸å建Makefileæ件
è¿ä¸ªMakefileæ件æ¯ç»OpenWRT读çï¼èä¹ååçé£ä¸ªMakefileæ件æ¯é对helloworldç»ç¼è¯å ¶è¯»çã两个Makefileä¸å¨åä¸å±ç®å½ä¸ã
ããtouch Makefile
vim Makefile
ããMakefileæ件模æ¿å 容å¦ä¸ï¼
##############################################
# OpenWrt Makefile for helloworld program
#
#
# Most of the variables used here are defined in
# the include directives below. We just need to
# specify a basic description of the package,
# where to build our program, where to find
# the source files, and where to install the
# compiled program on the router.
#
# Be very careful of spacing in this file.
# Indents should be tabs, not spaces, and
# there should be no trailing whitespace in
# lines that are not commented.
#
##############################################
ããinclude $(TOPDIR)/rules.mk
ãã# Name and release number of this package
PKG_NAME:=helloworld
PKG_RELEASE:=1
ãã# This specifies the directory where we're going to build the program.
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
ããinclude $(INCLUDE_DIR)/package.mk
ãã# Specify package information for this program.
# The variables defined here should be self explanatory.
# If you are running Kamikaze, delete the DESCRIPTION
# variable below and uncomment the Kamikaze define
# directive for the description below
define Package/helloworld
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Helloworld -- prints a snarky message
endef
ãã# Uncomment portion below for Kamikaze and delete DESCRIPTION variable above
define Package/helloworld/description
If you can't figure out what this program does, you're probably
brain-dead and need immediate medical attention.
endef
ãã# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default. The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
ãã# We do not need to define Build/Configure or Build/Compile directives
# The defaults are appropriate for compiling a simple program such as this one
ãã# Specify where and how to install the program. Since we only have one file,
# the helloworld executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
# directory if it does not already exist. Likewise $(INSTALL_BIN) contains the
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/helloworld/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef
ãã# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,helloworld))
ããï¼7ï¼è¿åå°SDKçæ ¹ç®å½
æ§è¡makeè¿è¡ç¼è¯
ç¼è¯è¿ç¨ä¼å¨build_dirç®å½ä¸å®æ
ç¼è¯ç»æä¼æ¾å¨ bin/[yourtarget]/packageç®å½ä¸helloworld_1_bcmxx.ipk
ããï¼8ï¼ä¸ä¼ helloworld_1_bcmxx.ipk
使ç¨sftp软件ä¸ä¼ helloworld_1_bcmxx.ipkè³è·¯ç±å¨
æ§è¡ opkg install helloworld_1_bcmxx.ipk
è¾å ¥helloç¶åæTabé®ï¼åç°openwrtä¸å·²ç»æhelloworldå¯æ§è¡å½ä»¤ã
æ§è¡ helloworld æ¥çç¨åºçææã
ããHell! O' world, why won't my code compile?
ãããEndã
ããå¸æ对大家è½æå¸®å© :)
route OSä¸openWRTåºå«
OpenWrt 项ç®ç± å¹´ 1 æå¼å§, 第ä¸ä¸ªçæ¬æ¯åºäº Linksys æä¾ç GPL æºç å uclibc ä¸ç buildroot 项ç®,è¿ä¸ªçæ¬ç§°ä¸º âstableâ ç, å¨ç½ä¸è³ä»ä»æå¾å¤é¡¹ç®ä½¿ç¨è¿ä¸ªçæ¬ï¼å°ç±³è·¯ç±å¨çâMiWiFiâç³»ç»æ£æ¯åºäºOpenWrtæé ,MiWiFiç³»ç»çé¢å¾å好