MikroTik RB493G port ar71>ath79 kernel hangs initramfs

Hi,

I'm attempting to build an ath79 image for a MikroTik RB493G (currently supported under ar71xx).

I've started by making an incredibly simple config here (n.b. most of the .dts is commented out, I've just kept the bootargs) and built the initramfs image.

So far so good.

Binwalk shows my new image:

DECIMAL       HEXADECIMAL     DESCRIPTION                                                                                               
--------------------------------------------------------------------------------                                                        
0             0x0             ELF, 32-bit MSB MIPS-I executable, MIPS, version 1 (SYSV)                                                 
9532          0x253C          Copyright string: "Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>"                                   
9740          0x260C          LZMA compressed data, properties: 0x6D, dictionary size: 8388608 bytes, uncompressed size: 12739582 bytes 

Which looks kinda ok, as this is the 19.07 ar71xx initramfs:

DECIMAL       HEXADECIMAL     DESCRIPTION                                                                                                
--------------------------------------------------------------------------------                                                         
0             0x0             ELF, 32-bit MSB MIPS-I executable, MIPS, version 1 (SYSV)                                                  
9580          0x256C          Copyright string: "Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>"                                    
9788          0x263C          LZMA compressed data, properties: 0x6D, dictionary size: 8388608 bytes, uncompressed size: 7543556 bytes   

Anyway, my problem is the ath79 image doesn't even begin to boot:

RouterBOOT booter 6.41

RouterBoard 493G

CPU frequency: 680 MHz
  Memory size: 256 MiB
    NAND size: 128 MiB

Press any key within 2 seconds to enter setup..
trying bootp protocol..... OK
Got IP address: 192.168.1.104
resolved mac address 
Gateway: 192.168.1.10
transfer started ............................... transfer ok, time=1.95s
setting up elf image... OK
jumping to kernel code


OpenWrt kernel loader for AR7XXX/AR9XXX
Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
Decompressing kernel... done!
Starting kernel at 80060000...

That's all I get, it just hangs. The ar71xx also says "Starting kernel at 80060000" and then Linux kernel appears.

Questions:

  1. Have I done something really stupid?
  2. Have I somehow got this new image to load in the wrong place and corrupt the running bootloader?
  3. Do I need "kernel2minor" in the initramfs image build process?
  4. Something else?

Thanks for any pointers.

1 Like

start with;

  • tweaking the serial definitions in the dts
  • compile in and enable earlyconsole
  • or passing alternate console devs on the cmdline if possible

alternatively, pick a similar device (or three) that is already ported and compare ar71-vs-ath79 to extrapolate key dts definitions. ( i.e.; if it is "ar7100.dtsi" based. then ref clock seems sensible etc. )

Thanks. I do see on the ar71xx build, the console boot log contains the following output

Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled                                  
console [ttyS0] disabled                                                                  
serial8250.0: ttyS0 at MMIO 0x18020000 (irq = 11, base_baud = 10625000) is a 16550A       
console [ttyS0] enabled                                                                   
bootconsole [early0] disabled                                                             

And I added these to the dts "chosen" section in my new ath79 build:

bootargs = "earlycon=uart8250,mmio,0x18020000 console=ttyS0,115200 earlyprintk";

However I still see exactly the same thing on the serial port, "Starting kernel at 80060000..." then nothing.

in that case the other thing to check would be loadaddr overflow...

your new initramfs = 12739582 bytes
the ar71 = 7543556 bytes

thats close to double the size... so you might need to shrink it or load somewhere else etc.

possibly get in touch with these guys;

git log | grep -i -C30 rotik | grep -i -C30 support | head -n600 | more

I'll try slimming it down.

Considering this device has 256MB of RAM I was hoping to avoid running into things like this!

So I had another look at this today, and I've noticed that the generated image files have different internals.

ar71xx, unpacked:

$ tree _openwrt-19.07.0-ar71xx-mikrotik-vmlinux-initramfs-lzma.elf.extracted/ | head -20
_openwrt-19.07.0-ar71xx-mikrotik-vmlinux-initramfs-lzma.elf.extracted/
├── 263C
├── 263C.7z
└── _263C.extracted
    ├── 45DB88.xz
    ├── 4F2D34
    ├── 4F2D34.7z
    └── _4F2D34.extracted
        ├── 0.cpio
        └── cpio-root
            ├── bin
            │   ├── ash -> busybox
            │   ├── board_detect
            │   ├── busybox
            │   ├── cat -> busybox
            │   ├── chgrp -> busybox
            │   ├── chmod -> busybox
            │   ├── chown -> busybox
            │   ├── config_generate
            │   ├── cp -> busybox

Whereas the ath79 image:

$ tree _openwrt-ath79-nand-mikrotik_routerboard-rb493g-initramfs-kernel.bin.extracted/
├── 260C
├── 260C.7z
└── _260C.extracted
    ├── [
    ├── [[
    ├── 00-netstate
    ├── 00_preinit.conf
    ├── 00-sysctl
    ├── 00-wifi-migration
    ├── 01_leds
    ├── 02_default_set_state
    ├── 02_network
    ├── 02_sysinfo
    ├── 0b26f36ae0f4106d
<snip>
    ├── 540B28.xz
    ├── 5D3B84.cpio
<snip>
    ├── cpio-root
    │   ├── bin
    │   │   ├── ash -> busybox
    │   │   ├── board_detect
    │   │   ├── busybox
    │   │   ├── cat -> busybox

Ok, some progress that I'll record here for future reference.

After turning on Target Images -> ramdisk -> lzma compression, and re-building I get a smaller image that now unpacks like the ar71xx above:

DECIMAL       HEXADECIMAL     DESCRIPTION                                                                                              
--------------------------------------------------------------------------------                                                       
0             0x0             ELF, 32-bit MSB MIPS-I executable, MIPS, version 1 (SYSV)                                                
9532          0x253C          Copyright string: "Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>"                                  
9740          0x260C          LZMA compressed data, properties: 0x6D, dictionary size: 8388608 bytes, uncompressed size: 8314839 bytes 

And more importantly some console output:

[    0.000000] Linux version 4.19.101 (openwrt@home.lan) (gcc version 8.3.0 (OpenWrt GCC 8.3.0 r12212-39a49c2d6a)) #0 Wed Feb 19 02:56:24 2020
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019374 (MIPS 24Kc)
[    0.000000] MIPS: machine is MikroTik RouterBOARD RB493G
[    0.000000] SoC: Atheros AR7161 rev 2
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 10000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x000000000fffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x000000000fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000000fffffff]
[    0.000000] random: get_random_bytes called from start_kernel+0x98/0x4a8 with crng_init=0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 64960
[    0.000000] Kernel command line: console=ttyS0,115200 rootfstype=squashfs,jffs2
[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Writing ErrCtl register=00000000
[    0.000000] Readback ErrCtl register=00000000
[    0.000000] Memory: 249824K/262144K available (4578K kernel code, 169K rwdata, 1056K rodata, 3340K init, 206K bss, 12320K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 51
[    0.000000] CPU clock: 680.000 MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 5621354254 ns
[    0.000008] sched_clock: 32 bits at 340MHz, resolution 2ns, wraps every 6316128254ns
[    0.007810] Calibrating delay loop... 452.19 BogoMIPS (lpj=2260992)
[    0.074072] pid_max: default: 32768 minimum: 301
[    0.078926] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.085536] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.097181] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.107066] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.113297] pinctrl core: initialized pinctrl subsystem
[    0.119029] NET: Registered protocol family 16
[    0.147053] clocksource: Switched to clocksource MIPS
[    0.153230] NET: Registered protocol family 2
[    0.158397] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes)
[    0.166081] TCP established hash table entries: 2048 (order: 1, 8192 bytes)
[    0.173123] TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
[    0.179508] TCP: Hash tables configured (established 2048 bind 2048)
[    0.186003] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.191893] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.198530] NET: Registered protocol family 1
[    2.567064] random: fast init done
[    3.562419] Crashlog allocated RAM at address 0x3f00000
[    3.569090] workingset: timestamp_bits=14 max_order=16 bucket_order=2
[    3.582113] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    3.587994] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    3.738568] io scheduler noop registered
[    3.742487] io scheduler deadline registered (default)
[    3.748527] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
[    3.755514] console [ttyS0] disabled
[    3.759186] 18020000.uart: ttyS0 at MMIO 0x18020000 (irq = 10, base_baud = 10625000) is a 16550A
[    3.767997] console [ttyS0] enabled
[    3.767997] console [ttyS0] enabled
[    3.774948] bootconsole [early0] disabled
[    3.774948] bootconsole [early0] disabled
[    3.789083] m25p80 spi0.0: unrecognized JEDEC id bytes: 00, 00, 00
[    3.795286] m25p80: probe of spi0.0 failed with error -2

It then halts at this point, however I now have something to work with! :slight_smile: