망고 100 보드로놀아보자 -6 U-boot build 환경분석
U-boot build 환경분석 Board/$(Vendor)/$(BOARD)/Config.mk 파일분석 (U-boot 가실행하는주소정의 ) ifndeftext_base //TEXT_BASE = 0xc7e00000 :MMU 사용 TEXT_BASE = 0x2fe00000 # Physical Address endif
U-boot 1.3.4 Build 환경분석 #make mango100_config 실행시분석 1 $(Top dir)/makefile 에아래코드실행 2 3 4 5 6 7 1 Configuration 할보드이름정의 2 mkconfig 로 $1 인자의미 3 Architecture 인자 $2 인자 4 CPU :$3 인자 5 Board name :$4 6 VENDOR :$5 7 SOC :$6
U-boot build 분석 실행순서는 1 unconfig 실행 2 @$(MKCONFIG) $(@:_config=) arm s5pc1xx mango100 samsung s5pc100 include/config.h : include/configs/mango100.h 를 inlcude,mkconfig 에서 create ( 아래코드 ) Inlcude/config.mk: 내용 board/*/config.tmp, board/*/*/config.tmp : 존재하면삭제 Include/autoconfig.mk :makefile 에서생성 Include/autoconf.mk.dep : makefile 에서생성
U-boot build 환경분석 1 2 3 4 5 6 7 $(@:_config=) : @ 현재 target 값, 즉 mango100_config, _config= 는 null 변경하라는의미 매크로치환 (Macro substitution):http://cafe.naver.com/embeddedcrazyboys/7000 http://marvel.incheon.ac.kr/infomation/unix/makefile/gnu-make-4.html $1 값은 mango100 ${BOARD_NAME} : mango100 값을가진다. $# : 넘어오는인자수를의미 출력은 Configuring for mango100 board
U-boot build 환경분석 1 2 3 4 5 6 7 SRCTREE 와 OBJTREE 값은동일,else 문수행 $2 값은 arm Include/asm Symbol link Include/asm-arm [-z $6 : 파일이존재하지않으면참 -o : 논리적 OR 연산 Include/asm-arm/arch Symbol link Include/arch-s5pc1xxx
U-boot build 환경분석 1 2 3 4 5 6 7 Config.h 를만든다 Config.h 파일내용은 include <configs/mango100.h> 이다
U-boot Build 환경구조도
리눅스명령 find (TIP) #find. name *.[ch] exec grep 문자열 {} \; -print 예 ) find. name *.[ch] exec grep mango100 {} \; -print 스크립트추가방법 #!/bin/sh if [ "$1"!= "" ] && [ "$2"!= "" ]; then find. -name "$1" -exec grep "$2" {} \; -print else echo "Usage: $0 *.* abcd" exit 1 fi /usr/bin 디렉토리 vi fin 추가 #chmod 755 /usr/bin/fin
U-boot build 실행분석 #make 명령실행 $(TOPDIR)/config.mk $(TOPDIR)/arm_config.mk $(TOPDIR)/rules.mk
U-boot build 실행분석 include/config.h== include/configs/mango100.h 내용동일 Include/common.h 두개의파일의내용을가지고온다 $(CC): $(CROSS_COMPILE)gcc 값임 -M 옵션 : 의존성있는있는파일을구성해준다. -MQ (target) : target 이름을정의해준다. #> vi hello.c #include<stdio.h> int main(void) { printf( Hello Mango ); return 0; } #> arm-linux-gcc M hello.c 두개의예제를결과비교실습 #> vi hello.c #include<stdio.h> int main(void) { printf( Hello Mango ); return 0; } #> arm-linux-gcc M MQ foo.o hello.c
U-boot build 실행분석 1 2 3 4 5 6 7 cmp s file1 file2 : 비교하여같으면 0 && 연산자 :cmp 비교결과같으면실행 연산자 : cmp 비교결과다르면실행
U-boot build 실행분석 1 2 3 4 5 6 7 $$dir :tools, examples api_example 값을가진다. make C tools _depend make C examples _depend make C api_example _depend 형식 :make C 실행디렉토리타겟즉, -C 옵션에정의된디렉토리로가서 Makefile 을수행하며, target 은 _depend 임
U-boot build 실행분석 1 2 3 4 5 6 7 Make C $SUBDIRS all 수행되면서실제빌드됨 결과
U-boot build 실행분석 1 2 3 4 5 6 7 CPU 값은 s5pc1xx $(if $(REMOTE_BUILD),$@,$(notdir $@)) 의미는 REMOTE_BUILD 값이있으면, OBJS 값을그대로대입, 없으면, 디렉토리리를제외한파일이름만추출하라는의미 make C cpu/s5pc1xx start.o 이수행이됨
U-boot build 실행분석 (LIBBOARD) 1 2 3 4 5 6 7 LIBBOARD = board/$(boarddir)/lib$(board).a LIBBOARD := $(addprefix $(obj),$(libboard)) BOARDDIR = $(VENDOR)/$(BOARD) VENDOR=samsung, BOARD=mango100 값따라서 BORDDIR 은 samsung/mango100 LIBBOARD 는 $(obj)/board/samsung/mango100/libmango100.a
U-boot build 실행분석 (LIBBOARD) 1 2 3 4 5 6 7
U-boot build 실행분석 1 2 3 4 5 6 7 LDSCRIPT 값은 /board/samsung/mango100/u-boot.lds 따라서, $(MAKE) C /board/samsung/mango100 u-boot.lds 실행이됨
U-boot.lds 분석 : 섹션의시작번지를 0x00000000 로설정. 실제로컴파일된실행코드인 text 가로딩되고배치될번지는 config.mk 에지정된 TEXT_BASE + 0x00000000 이된다. 4byte align Text section 의맨앞에 cpu/$cpu/start.o 를배열 (Start-up code) u_boot_cmd_start 와 u_boot_cmd_end 사이의.u_boot_cmd 는 u_boot 에서사용되는 user interface command structure 를이사이에배열 u boot_cmd_start, _u_boot_cmd_end, bss_start, end 는나중에 C code, startup code 에서주소계산을위해사용함.
U-boot build 실행분석 1 2 3 4 5 6 7 UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) \ sed -n -e 's/.*\($(sym_prefix) u_boot_cmd_.*\)/-u\1/p' sort uniq` UNDEF_SYM=`/usr/local/arm/4.2.2-eabi/usr/bin/arm-linux-objdump -x board/samsung/mango100/libmango100.a lib_generic/libgeneric.a cpu/s5pc1xx/libs5pc1xx.a cpu/s5pc1xx/s5pc100/libs5pc100.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a net/libnet.a disk/libdisk.a drivers/bios_emulator/libatibiosemu.a drivers/block/libblock.a drivers/dma/libdma.a drivers/hwmon/libhwmon.a drivers/i2c/libi2c.a drivers/input/libinput.a drivers/misc/libmisc.a drivers/mmc/libmmc.a drivers/mtd/libmtd.a drivers/mtd/nand/libnand.a drivers/mtd/nand_legacy/libnand_legacy.a drivers/mtd/onenand/libonenand.a drivers/mtd/spi/libspi_flash.a drivers/net/libnet.a drivers/net/sk98lin/libsk98lin.a drivers/pci/libpci.a drivers/pcmcia/libpcmcia.a drivers/spi/libspi.a drivers/rtc/librtc.a drivers/serial/libserial.a drivers/usb/libusb.a drivers/video/libvideo.a common/libcommon.a libfdt/libfdt.a api/libapi.a post/libpost.a \ sed -n -e 's/.*\( u_boot_cmd_.*\)/-u\1/p' sort uniq` 실습 #echo abcd123 sed 's/\([a-z]*\).*/\1/'
U-boot build 실행분석 1 2 3 4 5 6 7 cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $( OBJS) \ --start-group $( LIBS) --end-group $(PLATFORM_LIBS) \ -Map u-boot.map -o u-boot cd /home/icanjji/work/u-boot-work/mango100-uboot-2010-06-29 && /usr/local/arm/4.2.2-eabi/usr/bin/arm-linux-ld -Bstatic -T /home/icanjji/work/u-boot-work/mango100-uboot-2010-06-29/board/samsung/mango100/u-boot.lds -Ttext 0x2fe00000 $UNDEF_SYM cpu/s5pc1xx/start.o \ --start-group lib_generic/libgeneric.a cpu/s5pc1xx/libs5pc1xx.a cpu/s5pc1xx/s5pc100/libs5pc100.a lib_arm/libarm.a fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a net/libnet.a disk/libdisk.a drivers/bios_emulator/libatibiosemu.a drivers/block/libblock.a drivers/dma/libdma.a drivers/hwmon/libhwmon.a drivers/i2c/libi2c.a drivers/input/libinput.a drivers/misc/libmisc.a drivers/mmc/libmmc.a drivers/mtd/libmtd.a drivers/mtd/nand/libnand.a drivers/mtd/nand_legacy/libnand_legacy.a drivers/mtd/onenand/libonenand.a drivers/mtd/spi/libspi_flash.a drivers/net/libnet.a drivers/net/sk98lin/libsk98lin.a drivers/pci/libpci.a drivers/pcmcia/libpcmcia.a drivers/spi/libspi.a drivers/rtc/librtc.a drivers/serial/libserial.a drivers/usb/libusb.a drivers/video/libvideo.a common/libcommon.a libfdt/libfdt.a api/libapi.a post/libpost.a board/samsung/mango100/libmango100.a --end-group -L /usr/local/arm/4.2.2-eabi/usr/bin-ccache/../lib/gcc/arm-unknown-linux-gnueabi/4.2.2 -lgcc \ -Map u-boot.map -o u-boot