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:

2 Likes

Really looking forward to this.. RB450 and RB493G are quite similar boards, so im sure there may be some code to borrow from other development.

Keep up the great job!

I actually have a working PR out for the 493G here https://github.com/openwrt/openwrt/pull/2796#

You are welcome to test with it.

1 Like

hi @chill

sorry to review this old thread

i wanted to play with rb450g and started with very minimal/bare .config and very minimal DTS based on 493G

after stripping down packages, initramfs is 3.4 MB
but ...
boot process hang on with
Starting kernel at 80060000...

any advice ?
tested with primary and with backup booter

Wow, this is a blast from the past (and I no longer have any of these devices). If you're trying to boot it with the lzma-loader, here are the limitations that were found back then.

My advice - save time and energy and get something more modern.

well, it is a hobby :slight_smile: so ...
few wasted hours would not hurts

after further reducing initramfs, there is small success
booting is OK from primary (7.8) and backup booter (3.1)
ethernet looks OK at first glance, but something is wrong with NAND

[    2.896532] rb4xx-gpio mikrotik,rb4xx-gpio: DMA mask not set
[    2.903507] rb4xx-nand mikrotik,rb4xx-nand: DMA mask not set
[    2.915241] nand: device found, Manufacturer ID: 0xec, Chip ID: 0xdc
[    2.921659] nand: Samsung NAND 512MiB 3,3V 8-bit
[    2.926269] nand: 512 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    2.933900] ------------[ cut here ]------------
[    2.938535] WARNING: CPU: 0 PID: 1 at drivers/mtd/nand/raw/nand_base.c:5297 nand_scan_with_ids+0x171c/0x1848
[    2.948356] Unsupported ECC algorithm!
[    2.952109] Modules linked in:
[    2.955168] CPU: 0 PID: 1 Comm: swapper Not tainted 5.10.176 #0
[    2.961075] Stack : 806e0000 806157fc 00000000 00000000 80c2dbec 80970000 80660000 805e7a5c
[    2.969447]         80c28328 80665627 809732b8 00000001 000000ec 00000001 80c2dba0 edec230e
[    2.977818]         00000000 00000000 805e7a5c 80c2da40 ffffefff 00000000 00000000 ffffffea
[    2.986185]         00000050 80c2da4c 00000050 8066b288 00000000 00000009 80c2dc80 803d64e8
[    2.994548]         00000009 000000ec 00000000 20000000 00000018 80391c54 00000000 80970000
[    3.002912]         ...
[    3.005355] Call Trace:
[    3.007816] [<80066e84>] show_stack+0x30/0x100
[    3.012270] [<800855bc>] __warn+0xb0/0x11c
[    3.016357] [<800856b4>] warn_slowpath_fmt+0x8c/0xac
[    3.021310] [<803d64e8>] nand_scan_with_ids+0x171c/0x1848
[    3.026716] [<803e0174>] rb4xx_nand_probe+0x1e8/0x328
[    3.031776] [<803a33cc>] platform_drv_probe+0x40/0x94
[    3.036836] [<803a14ac>] really_probe+0x108/0x4d8
[    3.041542] [<803a1fdc>] device_driver_attach+0x120/0x130
[    3.046931] [<803a2068>] __driver_attach+0x7c/0x158
[    3.051809] [<8039f5b8>] bus_for_each_dev+0x68/0xa4
[    3.056683] [<803a0888>] bus_add_driver+0x1e4/0x234
[    3.061559] [<803a2660>] driver_register+0x98/0x154
[    3.066431] [<80060a38>] do_one_initcall+0x50/0x1b8
[    3.071303] [<806eff7c>] kernel_init_freeable+0x1e0/0x278
[    3.076718] [<80563c18>] kernel_init+0x10/0xf8
[    3.081152] [<80062258>] ret_from_kernel_thread+0x14/0x1c
[    3.086552]
[    3.088077] ---[ end trace eec00409caf33858 ]---

any advice ?

I recall there's a major problem with the flash handling of bad blocks (i.e. it doesn't) so it's possible you have a bad nand chip.

If not, you may have found a bug [here]?(https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ath79/files/drivers/mtd/nand/raw/nand_rb4xx.c;hb=HEAD#l138)

Did you ever get anywhere with this @NPeca75 as I also have a RB450G and was wondering if I could load a newer build than 19.x onto it. There could be similar issues that I have had with other Routerboards that loading firmware newer than 6.45 then it just fails to boot. It's probably not worth the effort but with a device that has so much ram/flash it should be fine even though it is old.

Same issue here, RB493G with the official image at http://downloads.openwrt.org/releases/23.05.3/targets/ath79/mikrotik/
Anything I can do to make it work ?