LS-GL:debian:カーネル


ソース CD に納められている カーネルソース linux-2.6.12_lsp.1.7.8.tgz を 見てみる。
使うのは debian 化した LS-GL

展開

hackkit:/mnt/kernel# tar zxvf linux-2.6.12_lsp.1.7.8.tgz
	:
linux-2.6.12_lsp.1.7.8/.tmp_versions/llc.mod
linux-2.6.12_lsp.1.7.8/.config.cmd
hackkit:/mnt/kernel#

散歩

hackkit:/mnt/kernel# cd linux-2.6.12_lsp.1.7.8
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# ls -al
total 19608
drwxrwxrwx  27 root root    4096 Jun 11 14:33 .
drwxr-xr-x   3 root root    4096 Oct 14 00:49 ..
-rw-r--r--   1 root root     531 Jun 11 14:33 ..tmp_kallsyms1.o.cmd
-rw-r--r--   1 root root     531 Jun 11 14:33 ..tmp_kallsyms2.o.cmd
-rw-r--r--   1 root root     646 Jun 11 14:33 ..tmp_vmlinux1.cmd
-rw-r--r--   1 root root     662 Jun 11 14:33 ..tmp_vmlinux2.cmd
-rw-r--r--   1 root root   22691 Jun 10 17:45 .config
-rw-r--r--   1 root root    5443 Jun 10 17:45 .config.cmd
-rw-r--r--   1 root root   22691 Jun 10 17:44 .config.old
-rw-r--r--   1 root root  540540 Jun 11 14:33 .tmp_System.map
-rw-r--r--   1 root root 1271534 Jun 11 14:33 .tmp_kallsyms1.S
-rw-r--r--   1 root root  218472 Jun 11 14:33 .tmp_kallsyms1.o
-rw-r--r--   1 root root 1271534 Jun 11 14:33 .tmp_kallsyms2.S
-rw-r--r--   1 root root  218472 Jun 11 14:33 .tmp_kallsyms2.o
drwxr-xr-x   2 root root    4096 Jun 11 14:33 .tmp_versions
-rwxr-xr-x   1 root root 4387490 Jun 11 14:33 .tmp_vmlinux1
-rwxr-xr-x   1 root root 4605215 Jun 11 14:33 .tmp_vmlinux2
-rw-r--r--   1 root root       3 Jun 11 14:33 .version
-rw-r--r--   1 root root     650 Jun 11 14:33 .vmlinux.cmd
	:
	:
.config があるので、何とかなりそう。

何を作ればいいの?

カーネルを作って、mkimage で /boot/uImage.buffalo を作ればいいのは わかっているが、では作るカーネルは?vmlinux? vmlinuz?

/boot/uImage.buffalo に納められている”カーネル”を取り出し、 そのサイズから推測する。

hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# dd if=/boot/uImage.buffalo of=/tmp/hoge bs=64 skip=1
27979+1 records in
27979+1 records out
1790696 bytes transferred in 1.143682 seconds (1565729 bytes/sec)
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# ls -l /tmp/hoge
-rw-r--r--  1 root root 1790696 Oct 14 01:13 /tmp/hoge
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8#
1790696 のファイルを作れば良い(汗)
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# ls -l
total 6364
-rwxrwxrwx   1 root root   18691 Mar  9  2006 COPYING
	:
drwxrwxrwx   3 root root    4096 Apr 24 20:51 tools
-rw-rw-rw-   1 root root 1795564 May  5 00:16 uImage
drwxrwxrwx   2 root root    4096 Jun 11 14:33 usr
-rwxr-xr-x   1 root root 3752732 Oct 14 01:09 vmlinux
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8#
uImage がそれに近い。サイズの差はバージョンの差であろう。
後から考えれば、uImage.buffalo というファイル名から自明か。

どうやって作ればいいの

えーい。いきなり make
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# make uImage
make: arm-none-linux-gnueabi-gcc: Command not found
  CHK     include/linux/version.h
  HOSTCC  scripts/basic/fixdep
CTRL-C
クロスコンパイルするようになっている。
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# mv Makefile Makefile.orig
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# cp Makefile.orig Makefile
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# vi Makefile
	:
	:
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# diff -c Makefile.orig Makefile
*** Makefile.orig       Mon Jun  5 14:45:51 2006
--- Makefile    Sat Oct 14 01:19:23 2006
***************
*** 192,198 ****

  ARCH          ?= arm
  #CROSS_COMPILE        ?= arm-linux-
! CROSS_COMPILE=arm-none-linux-gnueabi-

  # Architecture as present in compile.h
  UTS_MACHINE := $(ARCH)
--- 192,198 ----

  ARCH          ?= arm
  #CROSS_COMPILE        ?= arm-linux-
! #CROSS_COMPILE=arm-none-linux-gnueabi-

  # Architecture as present in compile.h
  UTS_MACHINE := $(ARCH)
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8#
こんなところかな。

もう一回 make

hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# make uImage
  CHK     include/linux/version.h
  HOSTCC  scripts/basic/docproc
  CC      scripts/mod/empty.o
cc1: error: invalid option `abi=aapcs'
make[2]: *** [scripts/mod/empty.o] Error 1
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8#
どこで abi=aapcs が定義されているの?
とりあえず clean
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# make clean
  CLEAN   arch/arm/boot/compressed
  CLEAN   arch/arm/boot
  CLEAN   arch/arm/kernel
  CLEAN   drivers/char
  CLEAN   drivers/pci
  CLEAN   init
  CLEAN   lib
  CLEAN   usr
  CLEAN   .tmp_versions
  CLEAN   include/asm-arm/constants.h include/asm-arm/mach-types.h include/asm-arm/arch include/asm-arm/.arch vmlinux Syste
m.map .tmp_kallsyms1.S .tmp_kallsyms1.o .tmp_kallsyms2.S .tmp_kallsyms2.o .tmp_vmlinux1 .tmp_vmlinux2 .tmp_System.map
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# make mrproper
  CLEAN   scripts/basic
  CLEAN   scripts/kconfig
  CLEAN   scripts/lxdialog
  CLEAN   scripts/mod
  CLEAN   scripts
  CLEAN   include/config
  CLEAN   .config .config.old include/asm .version include/linux/autoconf.h include/linux/version.h Module.symvers
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8#
ごそごそ・・・

一カ所見っけ

hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# cd tools/
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8/tools# mv Makefile Makefile.orig
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8/tools# cp Makefile.orig Makefile
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8/tools# ls -l Makefile*
-rw-r--r--  1 root root 852 Oct 14 01:26 Makefile
-rw-rw-rw-  1 root root 852 Apr 24 20:51 Makefile.orig
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8/tools# vi Makefile
	:
	:
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8/tools# diff -c Makefile.orig Makefile
*** Makefile.orig       Mon Apr 24 20:51:21 2006
--- Makefile    Sat Oct 14 01:27:47 2006
***************
*** 7,14 ****

  include $(KSRC)/.config

! CC := arm-none-linux-gnueabi-gcc
! LD := arm-none-linux-gnueabi-ld

  CFLAGS  := $(EXTRA_CFLAGS)
  CFLAGS  += -I$(KSRC)/arch/arm/mach-mv88fxx81/LSP/cesa/
--- 7,14 ----

  include $(KSRC)/.config

! #CC := arm-none-linux-gnueabi-gcc
! #LD := arm-none-linux-gnueabi-ld

  CFLAGS  := $(EXTRA_CFLAGS)
  CFLAGS  += -I$(KSRC)/arch/arm/mach-mv88fxx81/LSP/cesa/
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8/tools#
でもこれではなさそう。

ごそごそ・・・

こんどこそみっけ。

hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# cd arch/arm
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8/arch/arm# vi Makefile
	:
	:
# Need -Uarm for gcc < 3.x
ifeq ($(CONFIG_AEABI),y)
CFLAGS_ABI      :=-mabi=aapcs -mno-thumb-interwork
else
CFLAGS_ABI      :=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call cc-option,-mno-thumb-interwork,)
endif
	:
	:
ということは、Makefile を修正するのではなくて、 config で CONFIG_AEABI をアンセットしなければいいのか。
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# ls buffalo/
buffalo_lsgl_arm_100.config  drivers  marvell_config100.config
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# cp buffalo/buffalo_lsgl_arm_100.config .config
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# vi .config
	:
	:
.config は編集してはいけません(汗)
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# make oldconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/split-include
  HOSTCC  scripts/basic/docproc
  SHIPPED scripts/kconfig/zconf.tab.h
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/kxgettext.o
  HOSTCC  scripts/kconfig/mconf.o
  SHIPPED scripts/kconfig/zconf.tab.c
	:
	:
*
CRC-CCITT functions (CRC_CCITT) [N/m/y/?] n
CRC32 functions (CRC32) [Y/m/?] y
CRC32c (Castagnoli, et al) Cyclic Redundancy-Check (LIBCRC32C) [Y/?] y
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# diff -c buffalo/buffalo_lsgl_arm_100.config .config
*** buffalo/buffalo_lsgl_arm_100.config Sat Jun 10 18:50:47 2006
--- .config     Sat Oct 14 01:43:07 2006
***************
*** 1,7 ****
  #
  # Automatically generated make config: don't edit
  # Linux kernel version: 2.6.12.6-arm1
! # Sat Jun 10 17:45:03 2006
  #
  CONFIG_ARM=y
  CONFIG_MMU=y
--- 1,7 ----
  #
  # Automatically generated make config: don't edit
  # Linux kernel version: 2.6.12.6-arm1
! # Sat Oct 14 01:43:07 2006
  #
  CONFIG_ARM=y
  CONFIG_MMU=y
***************
*** 163,170 ****
  #
  # CONFIG_SMP is not set
  # CONFIG_PREEMPT is not set
! CONFIG_AEABI=y
! CONFIG_OABI_COMPAT=y
  # CONFIG_REORDER is not set
  # CONFIG_DISCONTIGMEM is not set
  CONFIG_LEDS=y
--- 163,169 ----
  #
  # CONFIG_SMP is not set
  # CONFIG_PREEMPT is not set
! # CONFIG_AEABI is not set
  # CONFIG_REORDER is not set
  # CONFIG_DISCONTIGMEM is not set
  CONFIG_LEDS=y
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8#
もう一回 make
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# make uImage
  CHK     include/linux/version.h
  SPLIT   include/linux/autoconf.h -> include/config/*
  CC      scripts/mod/empty.o
  HOSTCC  scripts/mod/mk_elfconfig
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/file2alias.o
	:
(寝よ。。。)	
	:
  AR      arch/arm/lib/lib.a
  GEN     .version
  CHK     include/linux/compile.h
  UPD     include/linux/compile.h
  CC      init/version.o
  LD      init/built-in.o
  LD      .tmp_vmlinux1
  KSYM    .tmp_kallsyms1.S
  AS      .tmp_kallsyms1.o
  LD      .tmp_vmlinux2
  KSYM    .tmp_kallsyms2.S
  AS      .tmp_kallsyms2.o
  LD      vmlinux
  SYSMAP  System.map
  SYSMAP  .tmp_System.map
  OBJCOPY arch/arm/boot/Image
  Kernel: arch/arm/boot/Image is ready
  AS      arch/arm/boot/compressed/head.o
  GZIP    arch/arm/boot/compressed/piggy.gz
  AS      arch/arm/boot/compressed/piggy.o
  CC      arch/arm/boot/compressed/misc.o
  LD      arch/arm/boot/compressed/vmlinux
  OBJCOPY arch/arm/boot/zImage
  Kernel: arch/arm/boot/zImage is ready
  UIMAGE  arch/arm/boot/uImage
Image Name:   Linux-2.6.12.6-arm1
Created:      Sat Oct 14 02:55:03 2006
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    1815952 Bytes = 1773.39 kB = 1.73 MB
Load Address: 0x00008000
Entry Point:  0x00008000
  Image arch/arm/boot/uImage is ready
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# 
ready だぁ!
1時間10分程。
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# ls -l arch/arm/boot/uImage
-rw-r--r--  1 root root 1816016 Oct 14 02:55 arch/arm/boot/uImage
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# mkimage -l !$
mkimage -l arch/arm/boot/uImage
Image Name:   Linux-2.6.12.6-arm1
Created:      Sat Oct 14 02:55:03 2006
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    1815952 Bytes = 1773.39 kB = 1.73 MB
Load Address: 0x00008000
Entry Point:  0x00008000
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8#
いけそう。

ブート

やってみる
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# mv /boot/uImage.buffalo{,.orig}
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# cp arch/arm/boot/uImage /boot/uImage.buffalo
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# ls -l /boot
total 7844
-rw-r--r--  1 root root 4376965 Sep 30 04:29 initrd.buffalo
drwx------  2 root root   12288 Sep 30 04:26 lost+found
-rw-r--r--  1 root root 1816016 Oct 14 08:03 uImage.buffalo
-rw-r--r--  1 root root 1790760 Sep 21 21:33 uImage.buffalo.orig
hackkit:/mnt/kernel/linux-2.6.12_lsp.1.7.8# shutdown -r now
	:
	:
ピロリロッ
	:
	:
Marvell Serial ATA Adapter
Intergrated Sata device found
  Device 1: OK
Model: IBM-DTTA-371010                          Firm: T77IA73A Ser#:          WL0WLA23870
            Type: Hard Disk
            Capacity: 9641.9 MB = 9.4 GB (19746720 x 512)

Using device ide1, partition 1

Loading from block device ide device 1, partition 1: Name: hdb1
  Type: U-Boot  File:/uImage.buffalo

1816016 bytes read
Using device ide1, partition 1

Loading from block device ide device 1, partition 1: Name: hdb1
  Type: U-Boot  File:/initrd.buffalo

4376965 bytes read
<>
## Booting image at 00100000 ...
   Image Name:   Linux-2.6.12.6-arm1
   Created:      2006-10-13  17:55:03 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1815952 Bytes =  1.7 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK
(UTC で 10/13 の Booting image をロードしている)
## Loading Ramdisk Image at 00800000 ...
   Image Name:   initrd
   Created:      2006-09-29  19:29:45 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    4376901 Bytes =  4.2 MB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK

Starting kernel ...

arg:console=ttyS0,115200 root=/dev/sda2 rw initrd=0x00800040,15M panic=5 BOOTVER=1.01
CONFIG_BUFFALO_PLATFORM CONFIG_BUFFALO_LINKSTATION_LSGL ---
Uncompressing Linux...................................................................................................................... done, booting the kernel.
Linux version 2.6.12.6-arm1 (root@hackkit) (gcc version 3.3.5 (Debian 1:3.3.5-13)) #1 Sat Oct 14 02:54:08 JST 2006
(hackkit でコンパイルされた 10/14 版 Linux が起動)
CPU: ARM926EJ-Sid(wb) [41069260] revision 0 (ARMv5TEJ)
CPU0: D VIVT write-back cache
CPU0: I cache: 32768 bytes, associativity 1, 32 byte lines, 1024 sets
CPU0: D cache: 32768 bytes, associativity 1, 32 byte lines, 1024 sets
	:
	:

Debian GNU/Linux 3.1 hackkit ttyS0

hackkit login: root
Password:
Last login: Sat Oct 14 01:53:31 2006 on ttyS0
Linux hackkit 2.6.12.6-arm1 #1 Sat Oct 14 02:54:08 JST 2006 armv5tejl GNU/Linux

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
hackkit:~# uname -a
Linux hackkit 2.6.12.6-arm1 #1 Sat Oct 14 02:54:08 JST 2006 armv5tejl GNU/Linux
hackkit:~# dmesg |head
Linux version 2.6.12.6-arm1 (root@hackkit) (gcc version 3.3.5 (Debian 1:3.3.5-13)) #1 Sat Oct 14 02:54:08 JST 2006
CPU: ARM926EJ-Sid(wb) [41069260] revision 0 (ARMv5TEJ)
CPU0: D VIVT write-back cache
CPU0: I cache: 32768 bytes, associativity 1, 32 byte lines, 1024 sets
CPU0: D cache: 32768 bytes, associativity 1, 32 byte lines, 1024 sets
Machine: MV-88fxx81
Using UBoot passing parameters structure
Sys Clk = 200000000, Tclk = 166664740


hackkit:~#
というわけで、カーネル交換成功。

白LinkStation シリーズや玄箱シリーズと比べると、 めっちゃ簡単、リスクもなし。
二度とやらなぁ〜い。




Bogo MIPS
ハックの記録
LinkStation/玄箱 をハックしよう

LS-GL:debian:ntp の設定

Copyright (C) 2006 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市