NanoPi NEOで最新版カーネルをビルドして試す

[前回](https://qiita.com/tetsu_koba/items/27d5c47592d1989431b0)はSoCベンダーの提供するカーネルソース(v4.11.2)をビルドしました。
今回は、メインラインのカーネル(v4.15.1) をビルドしてみます。

#カーネルのソースコードの取得

```
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
cd linux-stable/
git checkout -b v4.15 v4.15.1
```

stableカーネルのリポジトリをcloneして、v4.15.1 をチェックアウトします。

#ビルド

まずツールチェインを指定。

```
export ARCH=arm
export CROSS_COMPILE=/usr/local/4.9.3/bin/arm-cortexa9-linux-gnueabihf-
```
4.11のカーネルをビルドしたときの.config を持ってきます。

```
cp ../linux.4.11/.config .config
make menuconfig
```

ビルド

```
make -j10 zImage dtbs
```

openssl/bio.h が無いというエラーでビルドが止まったので、以下を追加インストール

```
sudo apt install libssl-dev
```

再度ビルドして今度は成功。

起動SDカードのbootパーティションの以下のファイルをさしかえます。
arch/arm/boot/zImage
arch/arm/boot/dts/sun8i-h3-nanopi-neo.dtb

カーネルモジュールは一切使わないようにコンフィグしたので、これだけでOK


#起動した結果

無事に起動しました。

```
# cat /proc/version 
Linux version 4.15.1 (koba@instance-3) (gcc version 4.9.3 (ctng-1.21.0-229g-FA)) #1 SMP Sun Feb 4 04:18:45 UTC 2018
```

```
# dmesg
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.15.1 (koba@instance-3) (gcc version 4.9.3 (ctng-1.21.0-229g-FA)) #1 SMP Sun Feb 4 04:18:45 UTC 2018
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: FriendlyARM NanoPi NEO
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] cma: Reserved 16 MiB at 0x5ec00000
[    0.000000] On node 0 totalpages: 131072
[    0.000000]   Normal zone: 1024 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 131072 pages, LIFO batch:31
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: Using PSCI v0.1 Function IDs from DT
[    0.000000] random: fast init done
[    0.000000] percpu: Embedded 16 pages/cpu @(ptrval) s33984 r8192 d23360 u65536
[    0.000000] pcpu-alloc: s33984 r8192 d23360 u65536 alloc=16*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 130048
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait fsck.repair=yes panic=10 fbcon=map:0
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 486952K/524288K available (7168K kernel code, 436K rwdata, 1700K rodata, 1024K init, 274K bss, 20952K reserved, 16384K cma-reserved, 0K highmem)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xe0800000 - 0xff800000   ( 496 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0x(ptrval) - 0x(ptrval)   (8160 kB)
[    0.000000]       .init : 0x(ptrval) - 0x(ptrval)   (1024 kB)
[    0.000000]       .data : 0x(ptrval) - 0x(ptrval)   ( 437 kB)
[    0.000000]        .bss : 0x(ptrval) - 0x(ptrval)   ( 275 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] Hierarchical RCU implementation.
[    0.000000] 	RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] GIC: Using split EOI/Deactivate mode
[    0.000000] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000007] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000018] Switching to timer-based delay loop, resolution 41ns
[    0.000184] Console: colour dummy device 80x30
[    0.000222] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.000236] pid_max: default: 32768 minimum: 301
[    0.000368] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000380] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000998] CPU: Testing write buffer coherency: ok
[    0.001345] /cpus/cpu@0 missing clock-frequency property
[    0.001367] /cpus/cpu@1 missing clock-frequency property
[    0.001382] /cpus/cpu@2 missing clock-frequency property
[    0.001398] /cpus/cpu@3 missing clock-frequency property
[    0.001411] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.001731] Setting up static identity map for 0x40100000 - 0x40100060
[    0.001837] Hierarchical SRCU implementation.
[    0.002342] smp: Bringing up secondary CPUs ...
[    0.013025] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.023769] CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
[    0.034476] CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
[    0.034546] smp: Brought up 1 node, 4 CPUs
[    0.034566] SMP: Total of 4 processors activated (192.00 BogoMIPS).
[    0.034572] CPU: All CPU(s) started in HYP mode.
[    0.034577] CPU: Virtualization extensions available.
[    0.035346] devtmpfs: initialized
[    0.038832] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.039032] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.039054] futex hash table entries: 1024 (order: 4, 65536 bytes)
[    0.039813] pinctrl core: initialized pinctrl subsystem
[    0.040684] NET: Registered protocol family 16
[    0.042101] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.043032] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.043043] hw-breakpoint: maximum watchpoint size is 8 bytes.
[    0.053928] SCSI subsystem initialized
[    0.054133] libata version 3.00 loaded.
[    0.054369] usbcore: registered new interface driver usbfs
[    0.054412] usbcore: registered new interface driver hub
[    0.054464] usbcore: registered new device driver usb
[    0.054607] pps_core: LinuxPPS API ver. 1 registered
[    0.054615] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.054634] PTP clock support registered
[    0.054802] Advanced Linux Sound Architecture Driver Initialized.
[    0.055766] clocksource: Switched to clocksource arch_sys_counter
[    0.055877] VFS: Disk quotas dquot_6.6.0
[    0.055941] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.062100] NET: Registered protocol family 2
[    0.062673] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.062728] TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
[    0.062790] TCP: Hash tables configured (established 4096 bind 4096)
[    0.062892] UDP hash table entries: 256 (order: 1, 8192 bytes)
[    0.062939] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
[    0.063159] NET: Registered protocol family 1
[    0.063502] RPC: Registered named UNIX socket transport module.
[    0.063511] RPC: Registered udp transport module.
[    0.063516] RPC: Registered tcp transport module.
[    0.063522] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.064110] Unpacking initramfs...
[    0.263497] Initramfs unpacking failed: junk in compressed archive
[    0.268503] Freeing initrd memory: 5120K
[    0.269877] Initialise system trusted keyrings
[    0.270173] workingset: timestamp_bits=30 max_order=17 bucket_order=0
[    0.275429] NFS: Registering the id_resolver key type
[    0.275465] Key type id_resolver registered
[    0.275472] Key type id_legacy registered
[    0.275488] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.275496] Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
[    0.276328] fuse init (API version 7.26)
[    0.279897] Key type asymmetric registered
[    0.279911] Asymmetric key parser 'x509' registered
[    0.279986] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 249)
[    0.279998] io scheduler noop registered
[    0.280004] io scheduler deadline registered
[    0.280148] io scheduler cfq registered (default)
[    0.280157] io scheduler mq-deadline registered
[    0.280163] io scheduler kyber registered
[    0.284116] sun8i-h3-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.285453] sun8i-h3-r-pinctrl 1f02c00.pinctrl: initialized sunXi PIO driver
[    0.327199] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.329365] console [ttyS0] disabled
[    0.349526] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 31, base_baud = 1500000) is a U6_16550A
[    1.027675] console [ttyS0] enabled
[    1.033237] libphy: Fixed MDIO Bus: probed
[    1.037382] CAN device driver interface
[    1.041598] dwmac-sun8i 1c30000.ethernet: PTP uses main clock
[    1.047398] dwmac-sun8i 1c30000.ethernet: No regulator found
[    1.053134] dwmac-sun8i 1c30000.ethernet: Current syscon value is not the default 148000 (expect 58000)
[    1.062541] dwmac-sun8i 1c30000.ethernet: Chain mode enabled
[    1.068206] dwmac-sun8i 1c30000.ethernet: No HW DMA feature register supported
[    1.075419] dwmac-sun8i 1c30000.ethernet: Normal descriptors
[    1.081082] dwmac-sun8i 1c30000.ethernet: RX Checksum Offload Engine supported
[    1.088315] dwmac-sun8i 1c30000.ethernet: COE Type 2
[    1.093273] dwmac-sun8i 1c30000.ethernet: TX Checksum insertion supported
[    1.100150] libphy: stmmac: probed
[    1.104034] dwmac-sun8i 1c30000.ethernet: Found internal PHY node
[    1.110225] libphy: mdio_mux: probed
[    1.113813] dwmac-sun8i 1c30000.ethernet: Switch mux to internal PHY
[    1.120189] dwmac-sun8i 1c30000.ethernet: Powering internal PHY
[    1.129548] libphy: mdio_mux: probed
[    1.133374] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.139915] ehci-platform: EHCI generic platform driver
[    1.145357] ehci-platform 1c1d000.usb: EHCI Host Controller
[    1.150964] ehci-platform 1c1d000.usb: new USB bus registered, assigned bus number 1
[    1.159160] ehci-platform 1c1d000.usb: irq 24, io mem 0x01c1d000
[    1.185778] ehci-platform 1c1d000.usb: USB 2.0 started, EHCI 1.00
[    1.192598] hub 1-0:1.0: USB hub found
[    1.196427] hub 1-0:1.0: 1 port detected
[    1.200738] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.206953] ohci-platform: OHCI generic platform driver
[    1.212362] ohci-platform 1c1d400.usb: Generic Platform OHCI controller
[    1.219007] ohci-platform 1c1d400.usb: new USB bus registered, assigned bus number 2
[    1.226936] ohci-platform 1c1d400.usb: irq 25, io mem 0x01c1d400
[    1.300331] hub 2-0:1.0: USB hub found
[    1.304107] hub 2-0:1.0: 1 port detected
[    1.308537] usbcore: registered new interface driver usb-storage
[    1.314831] mousedev: PS/2 mouse device common for all mice
[    1.321001] sun6i-rtc 1f00000.rtc: rtc core: registered rtc-sun6i as rtc0
[    1.327799] sun6i-rtc 1f00000.rtc: RTC enabled
[    1.332362] i2c /dev entries driver
[    1.336307] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    1.344425] cpu cpu0: failed to get clock: -2
[    1.348815] cpufreq-dt: probe of cpufreq-dt failed with error -2
[    1.355807] sunxi-mmc 1c0f000.mmc: Got CD GPIO
[    1.415976] sunxi-mmc 1c0f000.mmc: base:0xddff5061 irq:23
[    1.422398] usbcore: registered new interface driver usbhid
[    1.428007] usbhid: USB HID core driver
[    1.432335] usbcore: registered new interface driver snd-usb-audio
[    1.439527] Initializing XFRM netlink socket
[    1.443813] NET: Registered protocol family 17
[    1.448293] can: controller area network core (rev 20170425 abi 9)
[    1.454533] NET: Registered protocol family 29
[    1.458986] can: raw protocol (rev 20170425)
[    1.463252] can: broadcast manager protocol (rev 20170425 t)
[    1.468922] can: netlink gateway (rev 20170425) max_hops=1
[    1.474694] Key type dns_resolver registered
[    1.479167] Registering SWP/SWPB emulation handler
[    1.484463] Loading compiled-in X.509 certificates
[    1.484543] mmc0: host does not support reading read-only switch, assuming write-enable
[    1.488148] mmc0: new high speed SDHC card at address aaaa
[    1.488548] mmcblk0: mmc0:aaaa SL08G 7.40 GiB 
[    1.490376]  mmcblk0: p1 p2
[    1.514681] sun6i-rtc 1f00000.rtc: setting system clock to 1970-01-01 00:00:06 UTC (6)
[    1.522835] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    1.537720] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    1.544419] vcc3v0: disabling
[    1.547415] vcc5v0: disabling
[    1.550381] ALSA device list:
[    1.553343]   No soundcards found.
[    1.557205] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    1.565841] cfg80211: failed to load regulatory.db
[    1.567181] Freeing unused kernel memory: 1024K
[    1.575853] usb 1-1: new high-speed USB device number 2 using ehci-platform
[    1.712889] dwmac-sun8i 1c30000.ethernet eth0: device MAC address 12:ad:e6:c7:40:49
[    1.721200] Generic PHY 0.1:01: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0.1:01, irq=POLL)
[    1.732737] dwmac-sun8i 1c30000.ethernet eth0: No MAC Management Counters available
[    1.740426] dwmac-sun8i 1c30000.ethernet eth0: PTP not supported by HW
[    3.415198] usb 1-1: set resolution quirk: cval->res = 384
[  214.715840] random: crng init done
# 
```