Q:

Linux kernel crash and unable to boot (console related)?

Having a hard time booting the tinycore linux kernel for an ARM A10 here, on boot the device crashes.
3.0.42 config found here: http://distro.ibiblio.org/tinycorelinux/5.x/armv7/Allwinner-A10/a10Core-kernel-3.0.42.config
U-Boot SPL 2013.01 (Feb 11 2013 - 15:19:28)
Board: mk802ii
DRAM: 1024MB
SUNXI SD/MMC: 0

U-Boot 2013.01 (Feb 11 2013 - 15:19:28) Allwinner Technology

CPU:   SUNXI Family
Board: mk802ii
I2C:   ready
DRAM:  1 GiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   wemac
Hit any key to stop autoboot:  0
reading uEnv.txt
117 bytes read in 2 ms (56.6 KiB/s)
Loaded environment from uEnv.txt
reading boot.scr
304 bytes read in 3 ms (98.6 KiB/s)
Jumping to boot.scr
## Executing script at 44000000
reading script.bin
42132 bytes read in 6 ms (6.7 MiB/s)
reading uImage
4109016 bytes read in 213 ms (18.4 MiB/s)
reading uCore
2951575 bytes read in 154 ms (18.3 MiB/s)
## Booting kernel from Legacy Image at 48000000 ...
   Image Name:   Linux-3.0.42
   Created:      2015-02-16  20:40:40 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4108952 Bytes = 3.9 MiB
   Load Address: 40008000
   Entry Point:  40008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 43100000 ...
   Image Name:   uCore for Allwinner A10
   Created:      2014-12-26  21:12:42 UTC
   Image Type:   ARM Linux RAMDisk Image (uncompressed)
   Data Size:    2951511 Bytes = 2.8 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...

<6>Initializing cgroup subsys cpuset
<5>Linux version 3.0.42 (root@localhost.localdomain) (gcc version 4.9.1 20140717                                                                                                                                                              (Red Hat Cross 4.9.1-1) (GCC) ) #3 PREEMPT Mon Feb 16 15:40:29 EST 2015
CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d
CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: sun4i
<6>Memory Reserved:
<6>     SYS  : 0x43000000 - 0x4300ffff  (  64 kB)
<6>     VE   : 0x44000000 - 0x48ffffff  (  80 MB)
<6>     G2D  : 0x58000000 - 0x58ffffff  (  16 MB)
<6>     LCD  : 0x5a000000 - 0x5bffffff  (  32 MB)
Memory policy: ECC disabled, Data cache writeback
<6>BROM Ver: 1100 1100 1623
<6>chip-id: A10 (AW1623 revision C)
<7>On node 0 totalpages: 262144
<7>free_area_init_node: node 0, pgdat c07e60e4, node_mem_map c08ab000
<7>  Normal zone: 1280 pages used for memmap
<7>  Normal zone: 0 pages reserved
<7>  Normal zone: 162560 pages, LIFO batch:31
<7>  HighMem zone: 768 pages used for memmap
<7>  HighMem zone: 97536 pages, LIFO batch:31
<7>pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
<7>pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260096
<5>Kernel command line: console=tty0 init=/init rootwait panic=10 loglevel=3 dis                                                                                                                                                             p.screen0_output_mode=EDID:1280x720p60 hdmi.audio=EDID:0 nozswap nortc
<6>PID hash table entries: 4096 (order: 2, 16384 bytes)
<6>Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
<6>Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
<6>Memory: 1024MB = 1024MB total
<5>Memory: 896644k/896644k available, 151932k reserved, 393216K highmem
<5>Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xe8800000 - 0xf0000000   ( 120 MB)
    lowmem  : 0xc0000000 - 0xe8000000   ( 640 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .init : 0xc0008000 - 0xc0035000   ( 180 kB)
      .text : 0xc0035000 - 0xc07a3000   (7608 kB)
      .data : 0xc07a4000 - 0xc07ef9f0   ( 303 kB)
       .bss : 0xc07ef9f0 - 0xc08aa768   ( 748 kB)
<6>SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
<6>NR_IRQS:96 nr_irqs:96 96
<6>timer0: Periodic Mode
<6>Console: colour dummy device 80x30
<6>console [tty0] enabled
<6>Calibrating delay loop... <c>1001.88 BogoMIPS (lpj=5009408)
<6>pid_max: default: 32768 minimum: 301
<6>Mount-cache hash table entries: 512
<6>Initializing cgroup subsys cpuacct
<6>Initializing cgroup subsys devices
<6>Initializing cgroup subsys freezer
<6>Initializing cgroup subsys blkio
<6>CPU: Testing write buffer coherency: ok
<6>hw perfevents: enabled with ARMv7 Cortex-A8 PMU driver, 5 counters available
<6>devtmpfs: initialized
<6>print_constraints: dummy:
<6>NET: Registered protocol family 16
<6>hw-breakpoint: debug architecture 0x4 unsupported.
[ccmu] try to set apb1 parent to sata_pll failed!
SOFTWINNER DMA Driver, (c) 2003-2004,2006 Simtec Electronics
<6>Initialize DMAC OK
<6>bio: create slab <bio-0> at 0
<5>SCSI subsystem initialized
<7>libata version 3.00 loaded.
<6>usbcore: registered new interface driver usbfs
<6>usbcore: registered new interface driver hub
<6>usbcore: registered new device driver usb
<6>Advanced Linux Sound Architecture Driver Version 1.0.24.
<6>Bluetooth: Core ver 2.16
<6>NET: Registered protocol family 31
<6>Bluetooth: HCI device and connection manager initialized
<6>Bluetooth: HCI socket layer initialized
<6>Bluetooth: L2CAP socket layer initialized
<6>Bluetooth: SCO socket layer initialized
Init eGon pin module V2.0
<6>Switching to clocksource aw 64bits couter
<6>cfg80211: Calling CRDA to update world regulatory domain
<5>FS-Cache: Loaded
<6>CacheFiles: Loaded
<6>Switched to NOHz mode on CPU #0
<1>Unable to handle kernel NULL pointer dereference at virtual address 00000001
<1>pgd = c0004000
<1>[00000001] *pgd=00000000
<0>Internal error: Oops: 5 [#1] PREEMPT
<d>Modules linked in:
CPU: 0    Not tainted  (3.0.42 #3)
PC is at kmem_cache_alloc+0x78/0xd0
LR is at con_insert_unipair+0xc0/0x10c
pc : [<c00f6e7c>]    lr : [<c031508c>]    psr: 60000093
sp : e783be88  ip : 0000025b  fp : e783bea4
r10: c07c37d0  r9 : 00000001  r8 : 00000003
r7 : 00000003  r6 : 000000d0  r5 : e7802200  r4 : 00000001
r3 : 20000013  r2 : 00000000  r1 : c10b0040  r0 : 00000001
Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 10c5387d  Table: 40004019  DAC: 00000015

PC: 0xc00f6dfc:
6dfc  eafffff2 c0596580 e1a0c00d e92dd878 e24cb004 e1a05000 e1a06001 e5953000
6e1c  e593c004 e5934000 e3540000 0a000018 e10f3000 f10c0080 e5951000 e5910000
6e3c  e1540000 0a000007 e3a00000 e121f003 e3500000 0afffff0 e3160902 1a000017
6e5c  e1a00004 e89da878 e5912004 e15c0002 1afffff4 e5952014 e28cc001 e3a00001
6e7c  e7942002 e5812000 e5952000 e582c004 eaffffed e1a01006 e1a0200e e1a00005
6e9c  e7e067d6 ebffff2a e3500000 03a06000 12066001 e1a04000 e3560000 0affffe7
6ebc  e5951010 e3510000 0affffe4 e1a00004 eb06e873 eaffffe1 e1a0c00d e92dd878
6edc  e24cb004 e3074dc0 e1a06000 e34c4088 e1a05001 e5943054 e3530003 0a00000f

LR: 0xc031500c:
500c  e0844a07 e3a00000 e1a03083 e18c70b3 e5963084 e0834004 e5864084 e89da8f0
502c  e3073dd8 e34c3088 e593001c e3500000 0a00001c e3a010d0 ebf7876e e3500000
504c  e7860105 0a00001e e2403004 e280e07c e3a0c000 e5a3c004 e153000e 1afffffc
506c  eaffffe0 e3073dd8 e34c3088 e593001c e3500000 0a00000f e3a010d0 ebf7875d
508c  e3500000 e1a0c000 e5850000 0a00000c e1a0000c e3a010ff e3a02080 ebfe6fcc
50ac  e1a0c000 eaffffd4 e3a01010 e7861105 e1a00001 eaffffe3 e3a0c010 e585c000
50cc  eafffff2 e3e0000b e89da8f0 e1a0c00d e92ddbf0 e24cb004 e2506000 089dabf0
50ec  e5964098 e3540000 0a000024 e1a00004 e3a01b01 ebfe6fe6 e2466004 e3a07000

SP: 0xe783be08:
be08  e783c980 ffd23940 ffffffff 0a21fe80 e783be5c 0000040f 00000005 000000d0
be28  00000003 00000003 e783bea4 e783be40 c003b750 c0035214 00000001 c10b0040
be48  00000000 20000013 00000001 e7802200 000000d0 00000003 00000003 00000001
be68  c07c37d0 e783bea4 0000025b e783be88 c031508c c00f6e7c 60000093 ffffffff
be88  c0887dd8 00002665 e78bc5e4 e786d780 e783bec4 e783bea8 c031508c c00f6e10
bea8  00000000 00000001 e786d780 00000003 e783bf04 e783bec8 c0315d70 c0314fd8
bec8  c08952b4 e7803200 c07c3a28 c07c37ce e783befc 00000001 00000014 c08954d8
bee8  00000002 00000004 00000000 00000000 e783bf24 e783bf08 c001e220 c0315c88

FP: 0xe783be24:
be24  000000d0 00000003 00000003 e783bea4 e783be40 c003b750 c0035214 00000001
be44  c10b0040 00000000 20000013 00000001 e7802200 000000d0 00000003 00000003
be64  00000001 c07c37d0 e783bea4 0000025b e783be88 c031508c c00f6e7c 60000093
be84  ffffffff c0887dd8 00002665 e78bc5e4 e786d780 e783bec4 e783bea8 c031508c
bea4  c00f6e10 00000000 00000001 e786d780 00000003 e783bf04 e783bec8 c0315d70
bec4  c0314fd8 c08952b4 e7803200 c07c3a28 c07c37ce e783befc 00000001 00000014
bee4  c08954d8 00000002 00000004 00000000 00000000 e783bf24 e783bf08 c001e220
bf04  c0315c88 00000000 00000000 c08953b4 00000001 e783bf54 e783bf28 c001e734

R1: 0xc10affc0:
ffc0  ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
ffe0  ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
0000  e78015e0 0000002e c0d9b020 00000000 e7802580 0000000b c0d9b040 00000000
0020  e786d840 00000299 c0d9bda0 00000000 e78bd880 000009d2 c0d9c7a0 00000000
0040  00000001 0000025a c0d9c780 00000000 e785c700 0000000d c0d9bb80 00000000
0060  e78bea00 000002d2 c0d9c7c0 00000000 e78a0400 0000000c c0d9c400 00000000
0080  e785a000 00000004 c0d9bb00 00000000 e7812000 0000025e c0d9b200 00000000
00a0  e780a000 00000001 c0d9b100 00000000 e7823130 00000291 c0d9b460 00000000

R5: 0xe7802180:
2180  c10b0030 00000000 00000006 00000040 00000040 00000000 00000040 00000040
21a0  00000040 00000000 00000004 00000000 00000040 00000040 00000000 e7800040
21c0  e7802140 e7802240 00000000 00000000 00000000 00000000 00000000 00000000
21e0  00000000 00000000 00000000 e7801060 ffffffff ffffffff ffffffff ffffffff
2200  c10b0040 00000000 00000007 00000080 00000080 00000000 00000020 00000020
2220  00000020 00000000 00000008 00000000 00000080 00000040 00000000 e7800080
2240  e78021c0 e78022c0 00000000 00000000 00000000 00000000 00000000 00000000
2260  00000000 00000000 00000000 e7801080 ffffffff ffffffff ffffffff ffffffff

R10: 0xc07c3750:
3750  f0c5f0c4 f0c7f0c6 f0c9f0c8 f0cbf0ca f0cdf0cc f0cff0ce f0d1f0d0 f0d3f0d2
3770  f0d5f0d4 f0d7f0d6 f0d9f0d8 f0dbf0da f0ddf0dc f0dff0de f0e1f0e0 f0e3f0e2
3790  f0e5f0e4 f0e7f0e6 f0e9f0e8 f0ebf0ea f0edf0ec f0eff0ee f0f1f0f0 f0f3f0f2
37b0  f0f5f0f4 f0f7f0f6 f0f9f0f8 f0fbf0fa f0fdf0fc f0fff0fe 263a0000 2665263b
37d0  25c62666 26602663 25d82022 25d925cb 26402642 266b266a 00a4263c 25ba25b6
37f0  25c425c0 203c2195 00a700b6 21a825ac 21932191 21902192 2194221f 25bc25b2
3810  00210020 00a80022 00240023 00260025 00b40027 00290028 002b002a 00b8002c
3830  00ad002d 002f002e 00310030 00330032 00350034 00370036 00390038 003b003a
<0>Process swapper (pid: 1, stack limit = 0xe783a2e8)
<0>Stack: (0xe783be88 to 0xe783c000)
<0>be80:                   c0887dd8 00002665 e78bc5e4 e786d780 e783bec4 e783bea8
<0>bea0: c031508c c00f6e10 00000000 00000001 e786d780 00000003 e783bf04 e783bec8
<0>bec0: c0315d70 c0314fd8 c08952b4 e7803200 c07c3a28 c07c37ce e783befc 00000001
<0>bee0: 00000014 c08954d8 00000002 00000004 00000000 00000000 e783bf24 e783bf08
<0>bf00: c001e220 c0315c88 00000000 00000000 c08953b4 00000001 e783bf54 e783bf28
<0>bf20: c001e734 c001e1e0 c0740fc8 e783bf38 c015d534 c0894ef8 00000000 c0627944
<0>bf40: 00000013 00000000 e783bf74 e783bf58 c001dcd8 c001e5ac c06f9560 e783bf7c
<0>bf60: 0000000c c0896500 e783bf9c e783bf78 c001f2f8 c001dbb0 c070e9d4 00000001
<0>bf80: 00000013 c07efa00 e783a020 00000001 e783bfe4 e783bfa0 c003549c c001f234
<0>bfa0: e783bfbc e783bfb0 00000000 c001f228 e783bfcc e783bfc0 c00ae8f4 c002d83c
<0>bfc0: c002de00 00000001 00000013 00000000 00000000 00000000 e783bff4 e783bfe8
<0>bfe0: c0008b44 c0035380 00000000 e783bff8 c006c9fc c0008a44 ffffffff ffffffff
Backtrace:
[<c00f6e04>] (kmem_cache_alloc+0x0/0xd0) from [<c031508c>] (con_insert_unipair+0                                                                                                                                                             xc0/0x10c)
 r6:e786d780 r5:e78bc5e4 r4:00002665 r3:c0887dd8
[<c0314fcc>] (con_insert_unipair+0x0/0x10c) from [<c0315d70>] (con_set_default_u                                                                                                                                                             nimap+0xf4/0x18c)
 r7:00000003 r6:e786d780 r5:00000001 r4:00000000
[<c0315c7c>] (con_set_default_unimap+0x0/0x18c) from [<c001e220>] (console_map_i                                                                                                                                                             nit+0x4c/0x58)
[<c001e1d4>] (console_map_init+0x0/0x58) from [<c001e734>] (vty_init+0x194/0x1a4                                                                                                                                                             )
 r6:00000001 r5:c08953b4 r4:00000000 r3:00000000
[<c001e5a0>] (vty_init+0x0/0x1a4) from [<c001dcd8>] (tty_init+0x134/0x14c)
 r8:00000000 r7:00000013 r6:c0627944 r5:00000000 r4:c0894ef8
[<c001dba4>] (tty_init+0x0/0x14c) from [<c001f2f8>] (chr_dev_init+0xd0/0xdc)
 r5:c0896500 r4:0000000c
[<c001f228>] (chr_dev_init+0x0/0xdc) from [<c003549c>] (do_one_initcall+0x128/0x                                                                                                                                                             180)
 r6:00000001 r5:e783a020 r4:c07efa00
[<c0035374>] (do_one_initcall+0x0/0x180) from [<c0008b44>] (kernel_init+0x10c/0x                                                                                                                                                             190)
[<c0008a38>] (kernel_init+0x0/0x190) from [<c006c9fc>] (do_exit+0x0/0x754)
<0>Code: 1afffff4 e5952014 e28cc001 e3a00001 (e7942002)
<4>---[ end trace 1871642cfdaefb45 ]---
<0>Kernel panic - not syncing: Attempted to kill init!
Backtrace:
[<c003f900>] (dump_backtrace+0x0/0x10c) from [<c058702c>] (dump_stack+0x18/0x1c)
 r6:e783c000 r5:c07afc64 r4:c07f2bb0 r3:00000000
[<c0587014>] (dump_stack+0x0/0x1c) from [<c0587124>] (panic+0x78/0x188)
[<c05870ac>] (panic+0x0/0x188) from [<c006d150>] (complete_and_exit+0x0/0x24)
 r3:00000000 r2:e783bbd0 r1:e783bbc8 r0:c0703720
 r7:00000001
[<c006c9fc>] (do_exit+0x0/0x754) from [<c003fd8c>] (die+0x298/0x300)
 r7:00000001
[<c003faf4>] (die+0x0/0x300) from [<c058709c>] (__do_kernel_fault.part.5+0x6c/0x                                                                                                                                                             7c)
[<c0587030>] (__do_kernel_fault.part.5+0x0/0x7c) from [<c004465c>] (do_page_faul                                                                                                                                                             t+0x12c/0x3a8)
 r7:00000001 r3:e783be40
[<c0044530>] (do_page_fault+0x0/0x3a8) from [<c0044a20>] (do_translation_fault+0                                                                                                                                                             xa4/0xa8)
[<c004497c>] (do_translation_fault+0x0/0xa8) from [<c0035248>] (do_DataAbort+0x4                                                                                                                                                             0/0xa0)
 r6:c004497c r5:00000005 r4:c07aaa68 r3:60000093
[<c0035208>] (do_DataAbort+0x0/0xa0) from [<c003b750>] (__dabt_svc+0x70/0xa0)
Exception stack(0xe783be40 to 0xe783be88)
be40: 00000001 c10b0040 00000000 20000013 00000001 e7802200 000000d0 00000003
be60: 00000003 00000001 c07c37d0 e783bea4 0000025b e783be88 c031508c c00f6e7c
be80: 60000093 ffffffff
 r8:00000003 r7:00000003 r6:000000d0 r5:00000005 r4:0000040f
[<c00f6e04>] (kmem_cache_alloc+0x0/0xd0) from [<c031508c>] (con_insert_unipair+0                                                                                                                                                             xc0/0x10c)
 r6:e786d780 r5:e78bc5e4 r4:00002665 r3:c0887dd8
[<c0314fcc>] (con_insert_unipair+0x0/0x10c) from [<c0315d70>] (con_set_default_u                                                                                                                                                             nimap+0xf4/0x18c)
 r7:00000003 r6:e786d780 r5:00000001 r4:00000000
[<c0315c7c>] (con_set_default_unimap+0x0/0x18c) from [<c001e220>] (console_map_i                                                                                                                                                             nit+0x4c/0x58)
[<c001e1d4>] (console_map_init+0x0/0x58) from [<c001e734>] (vty_init+0x194/0x1a4                                                                                                                                                             )
 r6:00000001 r5:c08953b4 r4:00000000 r3:00000000
[<c001e5a0>] (vty_init+0x0/0x1a4) from [<c001dcd8>] (tty_init+0x134/0x14c)
 r8:00000000 r7:00000013 r6:c0627944 r5:00000000 r4:c0894ef8
[<c001dba4>] (tty_init+0x0/0x14c) from [<c001f2f8>] (chr_dev_init+0xd0/0xdc)
 r5:c0896500 r4:0000000c
[<c001f228>] (chr_dev_init+0x0/0xdc) from [<c003549c>] (do_one_initcall+0x128/0x                                                                                                                                                             180)
 r6:00000001 r5:e783a020 r4:c07efa00
[<c0035374>] (do_one_initcall+0x0/0x180) from [<c0008b44>] (kernel_init+0x10c/0x                                                                                                                                                             190)
[<c0008a38>] (kernel_init+0x0/0x190) from [<c006c9fc>] (do_exit+0x0/0x754)
<0>Rebooting in 10 seconds..

A:

Looks like infamous ARM memset() bug. Check this bugreport for solution: https://bugs.linaro.org/show_bug.cgi?id=928#c7
This is a kernel bug, which was fixed in year 2013 by following commits in mainline Linux repository:

455bd4c430b0c0a361f38e8658a0d6cb469942b5 ARM: 7668/1: fix memset-related crashes caused by recent GCC (4.7.2) optimizations
418df63adac56841ef6b0f1fcf435bc64d4ed177 ARM: 7670/1: fix the memset fix

The problem should be fixed by backporting those patches (in most cases patches could be applied without any modifications), or can be worked around with -fno-builtin-memset

