ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2009年7月7日 星期二

initrd ? initramfs - todo

有關 INITRAMFS:
  • 要看一下 Documentation/early-userspace/README
  • Documentation/filesystems/ramfs-rootfs-initramfs.txt:
  • usr/Makefile: 中有 ramfs-input
grep 一下 CONFIG_INITRAMFS_SOURCE

2009年7月3日 星期五

gnu make 的 call function

這只是節錄 nmake 的 documentation:
The syntax of the call function is:    
$(call variable,param,param,...)
make 執行這道命時,會賦予param...一個暫時的變數名稱 $(1), $(2), etc. 變數 $(0) 則是 variable.

Then variable is expanded as a make variable in the context of these temporary assignments. Thus, any reference to $(1) in the value of variable will resolve to the first param in the invocation of call.

If variable is the name of a builtin function, the builtin function is always invoked (even if a make variable by that name also exists).

examples

This macro simply reverses its arguments:

reverse = $(2) $(1)
foo = $(call reverse,a,b)

foo 會是 `b a'.

This one is slightly more interesting: it defines a macro to search for the first instance of a program in PATH:

pathsearch = $(firstword $(wildcard $(addsufix /$(1),$(subst :, ,$(PATH)))))
LS := $(call pathsearch,ls)

Now the variable LS contains /bin/ls or similar.

The call function can be nested. Each recursive invocation gets its own local values for $(1), etc. that mask the values of higher-level call. For example, here is an implementation of a map function:

map = $(foreach a,$(2),$(call $(1),$(a)))

Now you can map a function that normally takes only one argument, such as origin, to multiple values in one step:

o = $(call map,origin,o map MAKE)

and end up with o containing something like `file file default'.

A final caution: be careful when adding whitespace to the arguments to call. As with other functions, any whitespace contained in the second and subsequent arguments is kept; this can cause strange effects. It's generally safest to remove all extraneous whitespace when providing parameters to call.

uimage 的 quiet_cmd_uimage ...

在找 uImage 的 Makefile 時,最後指向:
 arch/arm/boot/Makefile
其中:
quiet_cmd_uimage = UIMAGE  $@
     cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A arm -O linux -T kernel \
                  -C none -a $(LOADADDR) -e $(LOADADDR) \
                  -n 'Linux-$(KERNELRELEASE)' -d $< $@  
但是我到處都找不到 ref quiet_cmd_uimage 和 cmd_uimage 的地方。 後來找到原來是 .. Kbuild
Kbuild 的 instruction:
  quiet_cmd_CMD = 要顯示的
       cmd_CMD = 要執行的
有關Kbuild 在 kernel/Documentation/kbuild/makefile.txt 有說明:
--- 6.7 Custom kbuild commands

        When kbuild is executing with KBUILD_VERBOSE=0, then only a shorthand
        of a command is normally displayed.
        To enable this behaviour for custom commands kbuild requires
        two variables to be set:
        quiet_cmd_<command>     - what shall be echoed
              cmd_<command>     - the command to execute

        Example:
                #
                quiet_cmd_image = BUILD   $@
                      cmd_image = $(obj)/tools/build $(BUILDFLAGS) \
                                                     $(obj)/vmlinux.bin > $@

                targets += bzImage
                $(obj)/bzImage: $(obj)/vmlinux.bin $(obj)/tools/build FORCE
                        $(call if_changed,image)
                        @echo 'Kernel: $@ is ready'

        When updating the $(obj)/bzImage target, the line

        BUILD    arch/i386/boot/bzImage

        will be displayed with "make KBUILD_VERBOSE=0".

uImage 和 mkimage

uImage 是能讓 u-boot 開機的 kernel image。 在u-boot 的 README 中的 "Building a Linux Image:" 有提到.. 不能用以前的zImage,bzImage。新的 kernel source已經新增一個 target 叫 "uImage"。 所以..
make xx_config
make coldconfig
make dep
make uImage
就可以build 出 uImage。 uImage 和以往zImage, bzImage 不同的是..她需要用 tools/mkimage 這個 tool 來包裝過:
  • build vmlinux (ELF binary format)
  • {CROSS_COMPILE)-objcopy -O binary -R .note -R .comment -S vmlinux linu.bin
  • gzip -9 linux.bin
  • 包裝:
    mkimage -A arm -O linux -T kernel -C gzip -a 0 -e 0 -n "Linux Kernel Image" -d linux.bin.gz uImage
有關mkimage 的help:
Usage: ../kernel/scripts/mkimage -l image
          -l == list image header information
       ../kernel/scripts/mkimage [-x] -A arch -O os -T type -C comp -a addr 
                                      -e ep -n name -d data_file[:data_file...] image
          -A == set architecture to 'arch'
          -O == set operating system to 'os'
          -T == set image type to 'type'
          -C == set compression type 'comp'
          -a == set load address to 'addr' (hex)
          -e == set entry point to 'ep' (hex)
          -n == set image name to 'name'
          -d == use image data from 'datafile'
          -x == set XIP (execute in place)

2009年7月1日 星期三

worklog : build android from source

取得 source 後,可以到 build 下看看..
build/core/build-system.html
然後,run
build/envsetup.sh
就可以多出幾個command,可以用 "help" 指令 (run 完後直接key "help")看一下..
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- croot:   Changes directory to the top of the tree.
- m:       Makes from the top of the tree.
- mm:      Builds all of the modules in the current directory.
- mmm:     Builds all of the modules in the supplied directories.
- cgrep:   Greps on all local C/C++ files.
- jgrep:   Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- godir:   Go to the directory containing a file.

Look at the source to view more functions. The complete list is:
add_lunch_combo cgrep check_product check_variant choosecombo chooseproduct
choosetype choosevariant croot findmakefile gdbclient get_abs_build_var
getbugreports get_build_var getprebuilt gettop godir help isviewserverstarted
jgrep lunch m mm mmm pid printconfig print_lunch_menu resgrep runhat runtest
runtest_py setpaths set_sequence_number set_stuff_for_environment settitle
smoketest startviewserver stopviewserver tapas tracedmdump
其中有關"mm" 這個command 的使用方法,在 SipX Android Build Environment 有提到。
這個 build-system.html 也包含很多其他的說明,像是 # 如何增加一個 project 到 android build system # 各種 build target 的差異 # 各種 clean 的差異

標籤

網誌存檔