OnionIoT / openwrt-imagebuilder-wrapper

Easily build firmware images using the OpenWRT Build System
MIT License
1 stars 3 forks source link

Not booting when adding custom config files #12

Closed TT-E1NFACH closed 1 year ago

TT-E1NFACH commented 1 year ago

Problem

It seems as soon as i add "files/etc/config" to "additions" the created firmware won't boot. Doesn't matter if there are files inside the directory or not. Tested on Omega2 Pro.

To Reproduce

1) Add the folder "additions/files/etc/config" 2) Build the firmware 3) Transfer the firmware to /tmp on the Omega 4) Run sysupgrade -n -F /tmp/firmware.bin

This was the output when booting

`Boot Linux from Flash NO RESET PRESSED.

Booting image at bc050000 ...

Image Name: MIPS OpenWrt Linux-5.10.161 Image Type: MIPS Linux Kernel Image (lzma compressed) Data Size: 2227344 Bytes = 2.1 MB Load Address: 80000000 Entry Point: 80000000 Verifying Checksum ... OK Uncompressing Kernel Image ... OK No initrd

Transferring control to Linux (at address 80000000) ...

Giving linux memsize in MB, 128

Starting kernel ...

[ 0.000000] Linux version 5.10.161 (builder@buildhost) (mipsel-openwrt-linux-musl-gcc (OpenWrt GCC 11.2.0 r20028-43d71ad93e) 11.2.0, GNU ld (GNU Binutils) 2.37) #0 Tue Jan 3 00:24:21 2023 [ 0.000000] Board has DDR2 [ 0.000000] Analog PMU set to hw control [ 0.000000] Digital PMU set to hw control [ 0.000000] SoC Type: MediaTek MT7688 ver:1 eco:2 [ 0.000000] printk: bootconsole [early0] enabled [ 0.000000] CPU0 revision is: 00019655 (MIPS 24KEc) [ 0.000000] MIPS: machine is Onion Omega2+ [ 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, PIPT, no aliases, linesize 32 bytes [ 0.000000] Zone ranges: [ 0.000000] Normal [mem 0x0000000000000000-0x0000000007ffffff] [ 0.000000] Movable zone start for each node [ 0.000000] Early memory node ranges [ 0.000000] node 0: [mem 0x0000000000000000-0x0000000007ffffff] [ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000007ffffff] [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 32480 [ 0.000000] Kernel command line: console=ttyS0,115200 rootfstype=squashfs,jffs2 [ 0.000000] Dentry cache hash table entries: 16384 (order: 4, 65536 bytes, linear) [ 0.000000] Inode-cache hash table entries: 8192 (order: 3, 32768 bytes, linear) [ 0.000000] Writing ErrCtl register=0007e670 [ 0.000000] Readback ErrCtl register=0007e670 [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off [ 0.000000] Memory: 121196K/131072K available (5751K kernel code, 622K rwdata, 700K rodata, 1236K init, 210K bss, 9876K reserved, 0K cma-reserved) [ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [ 0.000000] NR_IRQS: 256 [ 0.000000] intc: using register map from devicetree [ 0.000000] CPU Clock: 580MHz [ 0.000000] timer_probe: no matching timers found [ 0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 6590553264 ns [ 0.000011] sched_clock: 32 bits at 290MHz, resolution 3ns, wraps every 7405115902ns [ 0.007659] Calibrating delay loop... 385.84 BogoMIPS (lpj=1929216) [ 0.073587] pid_max: default: 32768 minimum: 301 [ 0.078256] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.085275] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.095424] dyndbg: Ignore empty _ddebug table in a CONFIG_DYNAMIC_DEBUG_CORE build [ 0.107436] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns [ 0.116951] futex hash table entries: 256 (order: -1, 3072 bytes, linear) [ 0.123592] pinctrl core: initialized pinctrl subsystem [ 0.133880] NET: Registered protocol family 16 [ 0.139064] thermal_sys: Registered thermal governor 'step_wise' [ 0.215647] clocksource: Switched to clocksource MIPS [ 0.227929] NET: Registered protocol family 2 [ 0.232411] IP idents hash table entries: 2048 (order: 2, 16384 bytes, linear) [ 0.240429] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear) [ 0.248601] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.255984] TCP bind hash table entries: 1024 (order: 0, 4096 bytes, linear) [ 0.262760] TCP: Hash tables configured (established 1024 bind 1024) [ 0.269068] UDP hash table entries: 256 (order: 0, 4096 bytes, linear) [ 0.275352] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear) [ 0.282472] NET: Registered protocol family 1 [ 0.286715] PCI: CLS 0 bytes, default 32 [ 0.299022] workingset: timestamp_bits=14 max_order=15 bucket_order=1 [ 0.311026] squashfs: version 4.0 (2009/01/31) Phillip Lougher [ 0.316665] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc. [ 0.328430] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252) [ 0.338270] mt7621_gpio 10000600.gpio: registering 32 gpios [ 0.343870] mt7621_gpio 10000600.gpio: registering 32 gpios [ 0.349615] mt7621_gpio 10000600.gpio: registering 32 gpios [ 0.355284] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled [ 0.364529] printk: console [ttyS0] disabled [ 0.368777] 10000c00.uartlite: ttyS0 at MMIO 0x10000c00 (irq = 28, base_baud = 2500000) is a 16550A [ 0.377517] printk: console [ttyS0] enabled [ 0.377517] printk: console [ttyS0] enabled [ 0.385922] printk: bootconsole [early0] disabled [ 0.385922] printk: bootconsole [early0] disabled [ 0.396323] 10000d00.uart1: ttyS1 at MMIO 0x10000d00 (irq = 29, base_baud = 2500000) is a 16550A [ 0.406192] 10000e00.uart2: ttyS2 at MMIO 0x10000e00 (irq = 30, base_baud = 2500000) is a 16550A [ 0.416849] spi-mt7621 10000b00.spi: sys_freq: 193333333 [ 0.446498] spi-nor spi0.0: w25q256 (32768 Kbytes) [ 0.451437] 4 fixed-partitions partitions found on MTD device spi0.0 [ 0.458018] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions [ 0.465453] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions [ 0.473456] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions [ 0.480957] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions [ 0.488638] Creating 4 MTD partitions on "spi0.0": [ 0.493516] 0x000000000000-0x000000030000 : "u-boot" [ 0.502402] 0x000000030000-0x000000040000 : "u-boot-env" [ 0.509206] 0x000000040000-0x000000050000 : "factory" [ 0.517674] 0x000000050000-0x000002000000 : "firmware" [ 0.524319] 2 uimage-fw partitions found on MTD device firmware [ 0.530416] Creating 2 MTD partitions on "firmware": [ 0.535462] 0x000000000000-0x00000021fcd0 : "kernel" [ 0.540523] mtd: partition "kernel" doesn't end on an erase/write block -- force read-only [ 0.552100] 0x00000021fcd0-0x000001fb0000 : "rootfs" [ 0.557228] mtd: partition "rootfs" doesn't start on an erase/write block boundary -- force read-only [ 0.567846] mtd: setting mtd5 (rootfs) as root device [ 0.574064] 1 squashfs-split partitions found on MTD device rootfs [ 0.580433] 0x000000fd0000-0x000001fb0000 : "rootfs_data" [ 0.643823] rt3050-esw 10110000.esw: mediatek esw at 0xb0110000, irq 25 initialized [ 0.652610] mtk_soc_eth 10100000.ethernet eth0: mediatek frame engine at 0xb0100000, irq 5 [ 0.663097] NET: Registered protocol family 10 [ 0.673905] Segment Routing with IPv6 [ 0.677872] NET: Registered protocol family 17 [ 0.682503] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this. [ 0.695684] 8021q: 802.1Q VLAN Support v1.8 [ 0.708824] VFS: Mounted root (squashfs filesystem) readonly on device 31:5. [ 0.723131] Freeing unused kernel memory: 1236K [ 0.727773] This architecture does not have kernel memory protection. [ 0.734316] Run /sbin/init as init process [ 1.430701] init: Console is alive [ 1.434777] init: - watchdog - [ 3.188897] kmodloader: loading kernel modules from /etc/modules-boot.d/ [ 3.380511] usbcore: registered new interface driver usbfs [ 3.386286] usbcore: registered new interface driver hub [ 3.391797] usbcore: registered new device driver usb [ 3.438559] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 3.454550] SCSI subsystem initialized [ 3.466838] ehci-fsl: Freescale EHCI Host controller driver [ 3.474572] ehci-platform: EHCI generic platform driver [ 3.490489] phy phy-10120000.usbphy.0: remote usb device wakeup disabled [ 3.497308] phy phy-10120000.usbphy.0: UTMI 16bit 30MHz [ 3.502610] ehci-platform 101c0000.ehci: EHCI Host Controller [ 3.508479] ehci-platform 101c0000.ehci: new USB bus registered, assigned bus number 1 [ 3.516681] ehci-platform 101c0000.ehci: irq 26, io mem 0x101c0000 [ 3.545679] ehci-platform 101c0000.ehci: USB 2.0 started, EHCI 1.00 [ 3.553230] hub 1-0:1.0: USB hub found [ 3.558130] hub 1-0:1.0: 1 port detected [ 3.571059] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver [ 3.579146] ohci-platform: OHCI generic platform driver [ 3.584896] ohci-platform 101c1000.ohci: Generic Platform OHCI controller [ 3.591906] ohci-platform 101c1000.ohci: new USB bus registered, assigned bus number 2 [ 3.600093] ohci-platform 101c1000.ohci: irq 26, io mem 0x101c1000 [ 3.680845] hub 2-0:1.0: USB hub found [ 3.685599] hub 2-0:1.0: 1 port detected [ 3.739101] sdhci: Secure Digital Host Controller Interface driver [ 3.745406] sdhci: Copyright(c) Pierre Ossman [ 3.752367] sdhci-pltfm: SDHCI platform and OF driver helper [ 3.763795] usbcore: registered new interface driver usb-storage [ 3.775342] kmodloader: done loading kernel modules from /etc/modules-boot.d/ [ 3.793384] init: - preinit - [ 3.983054] usb 1-1: new high-speed USB device number 2 using ehci-platform [ 4.090208] mmc0: new high speed MMC card at address 0001 [ 4.103149] mmcblk0: mmc0:0001 DG4008 7.28 GiB [ 4.113850] mmcblk0boot0: mmc0:0001 DG4008 partition 1 4.00 MiB [ 4.125964] mmcblk0boot1: mmc0:0001 DG4008 partition 2 4.00 MiB [ 4.134054] mmcblk0: p1 [ 4.365342] random: procd: uninitialized urandom read (4 bytes read) [ 4.374790] usb-storage 1-1:1.0: USB Mass Storage device detected [ 4.397419] scsi host0: usb-storage 1-1:1.0 [ 5.198833] random: jshn: uninitialized urandom read (4 bytes read) [ 5.319585] random: jshn: uninitialized urandom read (4 bytes read) [ 5.443225] random: jshn: uninitialized urandom read (4 bytes read) [ 5.456906] scsi 0:0:0:0: Direct-Access VendorCo ProductCode 2.00 PQ: 0 ANSI: 4 [ 5.478370] sd 0:0:0:0: [sda] 61440000 512-byte logical blocks: (31.5 GB/29.3 GiB) [ 5.495814] sd 0:0:0:0: [sda] Write Protect is off [ 5.501681] sd 0:0:0:0: [sda] No Caching mode page found [ 5.507150] sd 0:0:0:0: [sda] Assuming drive cache: write through [ 5.541219] sda: sda1 sda2 [ 5.549457] sd 0:0:0:0: [sda] Attached SCSI removable disk [ 5.569909] random: jshn: uninitialized urandom read (4 bytes read) [ 5.627707] random: jshn: uninitialized urandom read (4 bytes read) Press the [f] key and hit [enter] to enter failsafe mode Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level [ 10.455160] mount_root: loading kmods from internal overlay [ 10.512723] kmodloader: loading kernel modules from //etc/modules-boot.d/ [ 10.528202] kmodloader: done loading kernel modules from //etc/modules-boot.d/ [ 11.472842] block: attempting to load /etc/config/fstab [ 11.487282] block: unable to load configuration (fstab: Entry not found) [ 11.494627] block: no usable configuration [ 11.500192] mount_root: jffs2 not ready yet, using temporary tmpfs overlay [ 11.525770] urandom-seed: Seed file not found (/etc/urandom.seed) [ 11.672518] procd: - early - [ 11.676025] procd: - watchdog - [ 12.558954] procd: - watchdog - [ 12.573326] random: jshn: uninitialized urandom read (4 bytes read) [ 12.582763] procd: - ubus - Failed to connect to ubus [ 13.077965] random: jshn: uninitialized urandom read (4 bytes read) [ 13.353520] random: jshn: uninitialized urandom read (4 bytes read) `

At this point the boot process get stucked.

greenbreakfast commented 1 year ago

@jempatel can you please look into this when you get a chance?

jempatel commented 1 year ago

@TT-E1NFACH, is this a full locally built firmware image, from the log it shows Failed to connect to ubus, which seems to be an issue with where it had picked up ubus ipk when the image was built. Here, files/etc/config does not change any libs/binaries in firmware.

TT-E1NFACH commented 1 year ago

@jempatel , i tried it again with a clean omega3 pro (0.3.3 on it), and it crashes with kernel panic if i put the custom build firmware on it. Anyway this is a known problem when using custom firmware. So i put your firmware (from http://repo.onioniot.com/omega2/images/openwrt-22.03/) on it an it boots. Then i tried again with my custom build and the config folder in it, and it works.

So i figured out that my ubuntu system was using DOS new lines and so the config files were corrupted. I think that was the problem. I think you can close this one.

Failed to connect to ubus: When building i found this: Installing ubus (2022-06-01-2bebf93c-1) to root... Copying /home/osboxes/openwrt-imagebuilder-wrapper/openwrt-imagebuilder/dl/ubus_2022-06-01-2bebf93c-1_mipsel_24kc.ipk. But no errors found related to ubus.

Failed to connect to ubus happens also in a running custom firmware. We used this firmware and detected no problems when working with it. Anyway is there a way to find out where the problem comes from, or how to check if ubus is working correctly?

greenbreakfast commented 1 year ago

Closing this issue - root cause of issue was non-unix new lines in additional config files added to the firmware.

@TT-E1NFACH I suggest using ps to check that the ubus process is running, and logread to check for any error messages. Other than that, my best advice would be to check/post on the OpenWRT forums to see if others have encountered the same problem.