Syntax error DNS-320L.dts OpenWrt 22.03.3

I'm trying to build image for Dlink DNS-320L
I get error about syntax of DNS-320l.dts

arm-openwrt-linux-muslgnueabi-cpp -nostdinc -x assembler-with-cpp -I/home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/linux-5.10.161/arch/arm/boot/dts -I/home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/linux-5.10.161/arch/arm/boot/dts/include -I/home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/linux-5.10.161/include/ -undef -D__DTS__  -o /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/image-kirkwood-dns-320l.dtb.tmp /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/linux-5.10.161/arch/arm/boot/dts/kirkwood-dns-320l.dts
/home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/linux-5.10.161/scripts/dtc/dtc -O dtb -i/home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/linux-5.10.161/arch/arm/boot/dts/ -Wno-unit_address_vs_reg -Wno-simple_bus_reg -Wno-unit_address_format -Wno-pci_bridge -Wno-pci_device_bus_num -Wno-pci_device_reg -Wno-avoid_unnecessary_addr_size -Wno-alias_paths -Wno-graph_child_address -Wno-graph_port -Wno-unique_unit_address   -o /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/image-kirkwood-pogoplug-series-4.dtb /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/image-kirkwood-pogoplug-series-4.dtb.tmp
/home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/linux-5.10.161/scripts/dtc/dtc -O dtb -i/home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/linux-5.10.161/arch/arm/boot/dts/ -Wno-unit_address_vs_reg -Wno-simple_bus_reg -Wno-unit_address_format -Wno-pci_bridge -Wno-pci_device_bus_num -Wno-pci_device_reg -Wno-avoid_unnecessary_addr_size -Wno-alias_paths -Wno-graph_child_address -Wno-graph_port -Wno-unique_unit_address   -o /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/image-kirkwood-c200-v1.dtb /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/image-kirkwood-c200-v1.dtb.tmp
/home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/linux-5.10.161/scripts/dtc/dtc -O dtb -i/home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/linux-5.10.161/arch/arm/boot/dts/ -Wno-unit_address_vs_reg -Wno-simple_bus_reg -Wno-unit_address_format -Wno-pci_bridge -Wno-pci_device_bus_num -Wno-pci_device_reg -Wno-avoid_unnecessary_addr_size -Wno-alias_paths -Wno-graph_child_address -Wno-graph_port -Wno-unique_unit_address   -o /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/image-kirkwood-dns-320l.dtb /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/image-kirkwood-dns-320l.dtb.tmp
rm -f /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/image-kirkwood-pogoplug-series-4.dtb.tmp
Error: /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/linux-5.10.161/arch/arm/boot/dts/kirkwood-dns320.dts:2.1-9 syntax error
FATAL ERROR: Unable to parse input tree
make[5]: *** [Makefile:350: /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/image-kirkwood-dns-320l.dtb] Error 1
make[5]: *** Waiting for unfinished jobs....
rm -f /home/xapuk/openwrt/build_dir/target-arm_xscale_musl_eabi/linux-kirkwood/image-kirkwood-c200-v1.dtb.tmp
make[5]: Leaving directory '/home/xapuk/openwrt/target/linux/kirkwood/image'
make[4]: *** [Makefile:21: install] Error 2
make[4]: Leaving directory '/home/xapuk/openwrt/target/linux/kirkwood'
make[3]: *** [Makefile:11: install] Error 2
make[3]: Leaving directory '/home/xapuk/openwrt/target/linux'
time: target/linux/install#74.59#21.76#81.55
    ERROR: target/linux failed to build.
make[2]: *** [target/Makefile:30: target/linux/install] Error 1
make[2]: Leaving directory '/home/xapuk/openwrt'
make[1]: *** [target/Makefile:24: /home/xapuk/openwrt/staging_dir/target-arm_xscale_musl_eabi/stamp/.target_install] Error 2
make[1]: Leaving directory '/home/xapuk/openwrt'
make: *** [/home/xapuk/openwrt/include/toplevel.mk:230: world] Ошибка 2

And dns-320l.dts

/dts-v1/;

#include "kirkwood.dtsi"
#include "kirkwood-6281.dtsi"
#include "kirkwood-dns320.dts"

/ {
      model = "D-Link DNS-320L";
	compatible = "dlink,dns-320l", "marvell,kirkwood-88f6702", "marvell,kirkwood";

	memory {
		device_type = "memory";
		reg = <0x00000000 0x10000000>;
	};

	chosen {
		bootargs = "console=ttyS0,115200 earlyprintk";
	};

	ocp@f1000000 {
		serial@12000 {
			status = "okay";
		};

		serial@12100 {
			pinctrl-0 = <&pmx_uart1>;
			pinctrl-names = "default";
			status = "okay";
		};

		pinctrl: pin-controller@10000 {

			pinctrl-0 = <&pmx_button_power>;
			pinctrl-names = "default";

			pmx_sata0: pmx-sata0 {
				marvell,pins = "mpp20";
				marvell,function = "sata1";
			};
			pmx_sata1: pmx-sata1 {
				marvell,pins = "mpp21";
				marvell,function = "sata0";
			};
			pmx_led_red_right_hdd: pmx-led-red-right-hdd {
			    marvell,pins = "mpp22";
			    marvell,function = "gpio";
			};
			pmx_led_red_left_hdd: pmx-led-red-left-hdd {
			    marvell,pins = "mpp23";
			    marvell,function = "gpio";
			};
			pmx_power_sata: pmx-power-sata {
			    marvell,pins = "mpp24";
			    marvell,function = "gpio";
			};
			pmx_led_usb_blue: pmx-led-usb-blue {
			    marvell,pins = "mpp25";
			    marvell,function = "gpio";
			};
			pmx_led_usb_orange: pmx-led-usb-orange {
				marvell,pins = "mpp26";
				marvell,function = "gpio";
			};
			pmx_button_usb_copy: pmx-button-usb-copy {
				marvell,pins = "mpp27";
				marvell,function = "gpio";
			};			
			pmx_button_reset: pmx-button-reset {
				marvell,pins = "mpp28";
				marvell,function = "gpio";
			};
			pmx_button_power: pmx-button-power { // I can't get this one to trigger a button press...
				marvell,pins = "mpp29";
				marvell,function = "gpio";
			};						
		};
		sata@80000 {
			status = "okay";
			nr-ports = <2>;
		};

	};

	gpio_keys {
		compatible = "gpio-keys";
		pinctrl-0 = <&pmx_button_reset &pmx_button_usb_copy>;
		pinctrl-names = "default";
		#address-cells = <1>;
		#size-cells = <0>;

		button@1 {
			label = "Reset push button";
			linux,code = <0x198>;
			gpios = <&gpio0 28 1>;
		};
		button@2 {
			label = "USB unmount button";
			linux,code = <161>;
			gpios = <&gpio0 27 1>;
		};
	};

	gpio-leds {
		compatible = "gpio-leds";
		pinctrl-0 = <&pmx_led_usb_blue &pmx_led_usb_orange
			     &pmx_led_red_left_hdd &pmx_led_red_right_hdd>;
		pinctrl-names = "default";

		blue-usb {
			label = "dns320l:blue:usb";
			gpios = <&gpio0 25 0>; 
		};
		orange-l_hdd {
			label = "dns320l:orange:l_hdd";
			gpios = <&gpio0 22 0>; 
		};
		orange-r_hdd {
			label = "dns320l:orange:r_hdd";
			gpios = <&gpio0 23 0>; 
		};
		orange-usb {
			label = "dns320l:orange:usb";
			gpios = <&gpio0 26 0>; 
		};
	};

	regulators {
		compatible = "simple-bus";
		#address-cells = <1>;
		#size-cells = <0>;
		pinctrl-0 = <&pmx_power_sata>;
		pinctrl-names = "default";

		sata_power: regulator@1 {
			compatible = "regulator-fixed";
			reg = <1>;
			regulator-name = "SATA Power";
			regulator-min-microvolt = <5000000>;
			regulator-max-microvolt = <5000000>;
			enable-active-high;
			regulator-always-on;
			regulator-boot-on;
			gpio = <&gpio1 24 0>;
		};
	};
};

&nand {
	status = "okay";
	pinctrl-0 = <&pmx_nand>;
	pinctrl-names = "default";
	status = "okay";
	chip-delay = <40>;

			partition@0 {
				label = "u-boot";
				reg = <0x0000000 0x100000>;
			};

			partition@100000 {
				label = "uImage";
				reg = <0x0100000 0x400000>;
			};

			partition@500000 {
				label = "rootfs";
				reg = <0x0500000 0x2000000>;
			};

			partition@2500000 {
				label = "data";
				reg = <0x2500000 0x5b00000>;
			};
};

&mdio {
	status = "okay";

	ethphy0: ethernet-phy@0 {
		device_type = "ethernet-phy";
		reg = <0>;
	};
};

&eth0 {
	status = "okay";
	ethernet0-port@0 {
		phy-handle = <&ethphy0>;
	};
};

Can anybody help me?

Check the error message carefully: the error is in kirkwood-dns320.dts, not kirkwood-dns320l.dts

Are you sure that you need this include anyway?

Really!!! Thank You!
I've seen somewhere, dns320 has in-kernel support! There is no dns320.dts in devices, allthough it appears in menuconfig. That was what made me choose wrong way.

Exactly. The dns320 DTS is in the kernel, so you need to look for it in the kernel source (e.g. in the build_dir). The out-of-tree DTS files are copied to the build directory during build.

Ok, I've got image. After this I've unzipped it: CONTROL, kernel and root
After this I tried to write partitions "kernel" into "uImage" and "root" into "rootfs"
Here are my commands:

setenv ipaddr 192.168.1.1
setenv serverip 192.168.1.2
setenv bootargs_openwrt 'console=ttyS0,115200 earlyprintk root=/dev/mtdblock2'
setenv bootcmd_openwrt 'setenv bootargs $(bootargs_openwrt); nand read.e 0xa00000 0x100000 0x400000; bootm 0xa00000'
setenv to_openwrt 'setenv mainlineLinux yes; setenv bootcmd \'run bootcmd_openwrt\'; saveenv; reset'
tftp 0x6400000 kernel
nand erase 0x100000 0x400000
nand write.e 0x6400000 0x100000 0x400000
tftp 0x6400000 root
nand erase 0x500000 0x7b00000
nand write.e 0x6400000 0x500000 0x2000000
run to_openwrt

I get "kernel panic" after device tries to boot.

** MARVELL BOARD: DB-88F6702A-BP LE

U-Boot 1.1.4 (Aug 22 2012 - 17:06:54) Marvell version: 3.6.0.DNS-320L.01

U-Boot code: 00600000 -> 0067FFF0  BSS: -> 006CFB00

Soc: 88F6702 A1 CPU running @ 1000Mhz L2 running @ 500Mhz
SysClock = 400Mhz , TClock = 166Mhz

DRAM (DDR2) CAS Latency = 5 tRP = 5 tRAS = 18 tRCD=6
DRAM CS[0] base 0x00000000   size 256MB
DRAM Total size 256MB  16bit width
Addresses 8M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M - 7M): Done
NAND:128 MB
Flash:  0 kB

CPU : Marvell Feroceon (Rev 1)

Streaming disabled
Write allocate disabled


USB 0: host mode
PEX 0: interface detected no Link.
Net:   egiga0 [PRIME]
Hit any key to stop autoboot:  0

NAND read: device 0 offset 0x100000, size 0x400000
load addr ....  =a00000

 4194304 bytes read: OK
## Booting image at 00a00000 ...
   Image Name:   ARM OpenWrt Linux-5.10.176
   Created:      2023-04-09  12:27:46 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2734028 Bytes =  2.6 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.10.176 (xapuk@XAPUKSERGE) (arm-openwrt-linux-muslgnueabi-gcc (OpenWrt GCC 11.2.0 r20123-38ccc47687) 11.2.0, GNU ld (GNU Binutils) 2.37) #0 Sun Apr 9 12:27:46 2023
[    0.000000] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=0005397f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] OF: fdt: Machine model: D-Link DNS-320L
[    0.000000] Memory policy: Data cache writeback
[    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] Built 1 zonelists, mobility grouping on.  Total pages: 64960
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk root=/dev/mtdblock2
[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 249512K/262144K available (5740K kernel code, 592K rwdata, 1484K rodata, 1024K init, 206K bss, 12632K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] clocksource: orion_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 11467562657 ns
[    0.000009] sched_clock: 32 bits at 166MHz, resolution 6ns, wraps every 12884901885ns
[    0.000046] Switching to timer-based delay loop, resolution 6ns
[    0.000188] Calibrating delay loop (skipped), value calculated using timer frequency.. 333.33 BogoMIPS (lpj=1666666)
[    0.000218] pid_max: default: 32768 minimum: 301
[    0.000413] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.000439] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.001368] CPU: Testing write buffer coherency: ok
[    0.002555] Setting up static identity map for 0x100000 - 0x10003c
[    0.002819] mvebu-soc-id: MVEBU SoC ID=0x6702, Rev=0x3
[    0.003050] dyndbg: Ignore empty _ddebug table in a CONFIG_DYNAMIC_DEBUG_CORE build
[    0.006595] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.006628] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.006764] pinctrl core: initialized pinctrl subsystem
[    0.008351] NET: Registered protocol family 16
[    0.008937] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.010040] thermal_sys: Registered thermal governor 'step_wise'
[    0.010179] cpuidle: using governor ladder
[    0.010537] Feroceon L2: Enabling L2
[    0.010583] Feroceon L2: Cache support initialised.
[    0.020871] No ATAGs?
[    0.073938] SCSI subsystem initialized
[    0.075687] usbcore: registered new interface driver usbfs
[    0.075750] usbcore: registered new interface driver hub
[    0.075804] usbcore: registered new device driver usb
[    0.082245] clocksource: Switched to clocksource orion_clocksource
[    0.083091] NET: Registered protocol family 2
[    0.083316] IP idents hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.083936] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.083995] TCP established hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.084030] TCP bind hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.084062] TCP: Hash tables configured (established 2048 bind 2048)
[    0.084146] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.084175] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.084372] NET: Registered protocol family 1
[    0.084408] PCI: CLS 0 bytes, default 32
[    0.089474] workingset: timestamp_bits=14 max_order=16 bucket_order=2
[    0.093887] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.093906] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.097070] kirkwood-pinctrl f1010000.pin-controller: registered pinctrl driver
[    0.098776] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    0.099383] printk: console [ttyS0] disabled
[    0.099484] f1012000.serial: ttyS0 at MMIO 0xf1012000 (irq = 25, base_baud = 10416666) is a 16550A
[    0.510280] printk: console [ttyS0] enabled
[    0.515078] f1012100.serial: ttyS1 at MMIO 0xf1012100 (irq = 26, base_baud = 10416666) is a 16550A
[    0.525272] nand: device found, Manufacturer ID: 0xad, Chip ID: 0xf1
[    0.531599] nand: Hynix H27U1G8F2BTR-BC
[    0.535444] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    0.543006] Scanning device for bad blocks
[    0.652219] Bad eraseblock 950 at 0x0000076c0000
[    0.664955] 4 fixed-partitions partitions found on MTD device orion_nand
[    0.671628] Creating 4 MTD partitions on "orion_nand":
[    0.676761] 0x000000000000-0x000000100000 : "u-boot"
[    0.687298] 0x000000100000-0x000000500000 : "uImage"
[    0.692942] 0x000000500000-0x000002500000 : "ubi"
[    0.699685] 0x000002500000-0x000008000000 : "data"
[    0.719935] mv643xx_eth: MV-643xx 10/100/1000 ethernet driver version 1.4
[    0.731142] mv643xx_eth_port mv643xx_eth_port.0 eth0: port 0 with MAC address 00:50:43:00:02:02
[    1.762255] rtc-mv f1010300.rtc: internal RTC not ticking
[    1.767740] i2c /dev entries driver
[    1.771946] orion_wdt: Initial timeout 25 sec
[    1.784084] marvell-cesa f1030000.crypto: CESA device successfully registered
[    1.792054] NET: Registered protocol family 10
[    1.798592] Segment Routing with IPv6
[    1.802365] NET: Registered protocol family 17
[    1.807006] 8021q: 802.1Q VLAN Support v1.8
[    1.815891] UBI error: no valid UBI magic found inside mtd2
[    1.822133] /dev/root: Can't open blockdev
[    1.826256] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    1.833720] Please append a correct "root=" boot option; here are the available partitions:
[    1.842034] 1f00            1024 mtdblock0
[    1.842038]  (driver?)
[    1.848565] 1f01            4096 mtdblock1
[    1.848569]  (driver?)
[    1.855096] 1f02           32768 mtdblock2
[    1.855100]  (driver?)
[    1.861610] 1f03           93184 mtdblock3
[    1.861613]  (driver?)
[    1.868124] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    1.876352] Rebooting in 1 seconds..

What's wrong with my image?

Here are partitions from .dts

partition@0 {
				label = "u-boot";
				reg = <0x0000000 0x100000>;
			};

			partition@100000 {
				label = "uImage";
				reg = <0x0100000 0x400000>;
			};

			partition@500000 {
				label = "rootfs";
				reg = <0x0500000 0x2000000>;
			};

			partition@2500000 {
				label = "data";
				reg = <0x2500000 0x5b00000>;

Partitions from LOG are


0.676761] 0x000000000000-0x000000100000 : "u-boot"
[    0.687298] 0x000000100000-0x000000500000 : "uImage"
[    0.692942] 0x000000500000-0x000002500000 : "ubi"
[    0.699685] 0x000002500000-0x000008000000 : "data"

Maybe I have mistakes in writing images into device?

How did the image builder create the image, i.e. what did you put into Makefile?
Is this really an ubi image with ubinize?
Usually, you would create one flashable image, consisting of the kernel, a padding to the length of the kernel partition and then the ubi partition - that would be your factory image.
The ubi partition should be named "ubi" in the dts, not "rootfs", but I'm not sure if this is only required for the auto-detection or in general.

BUT: Before you start writing to flash, did you check whether everything works correctly?

Another approach often taken by other devices is: Run an initramfs image via U-Boot, transfer a sysupgrade image to the already-running OpenWrt and let sysupgrade handle the writing to the flash.

EDIT: Are you following my ancient instructions for the DNS-320L? If so, they are heavily outdated and were written for an OpenWrt version using JFFS2 and not UBI.

I used corrections for DNS-320-UBI using DNS_320L.dts file + Your old instructions how-to

Allthough 320-UBI has kernel partition and squashfs partition - ubi
I

I think that you are not creating a UBI partition - if I'm not mistaken, you need to set a few variables, e.g.

There is also the padding I was referring to in my previous post, how factory.bin is created.

If you want to get the buttons working and proper shutdown, you will need my daemon instead of the fan control script: https://www.aboehler.at/hg/dns320l-daemon/

NB: I never ran OpenWrt on this box for more than a few minutes for testing purposes, I had Arch Linux on it for years.

1 Like

Understood. What about daemon? Where to put it ?

I never prepared a proper OpenWrt package, this is something you should do. It's relatively easy (just a Makefile) and then you can install it like any other package.

I have made sysupgrade after booted initramfs.bin

ubiformat: formatting eraseblock 1010 -- 9[ 2788.775790] ubi0: attaching mtd1
ubiformat: formatting eraseblock 1015 -- 100 % complete
[ 2788.981496] ubi0: scanning is finished
[ 2788.998574] ubi0: attached mtd1 (name "ubi", size 127 MiB)
[ 2789.004076] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[ 2789.010941] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[ 2789.017609] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
[ 2789.024380] ubi0: good PEBs: 1015, bad PEBs: 1, corrupted PEBs: 0
[ 2789.030458] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
[ 2789.037648] ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 1263478351
[ 2789.046750] ubi0: available PEBs: 992, total reserved PEBs: 23, PEBs reserved for bad PEB handling: 19
[ 2789.056051] ubi0: background thread "ubi_bgt0d" started, PID 4442
UBI device number 0, total 1015 LEBs (130959360 bytes, 124.8 MiB), available 992 LEBs (127991808 bytes, 122.0 MiB), LEB size 129024 bytes (126.0 KiB)
Volume ID 0, size 21 LEBs (2709504 bytes, 2.5 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "kernel", alignment 1
Volume ID 1, size 23 LEBs (2967552 bytes, 2.8 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "rootfs", alignment 1
Set volume size to 122314752
Volume ID 2, size 948 LEBs (122314752 bytes, 116.6 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "rootfs_data", alignment 1
sysupgrade successful

And now I have problems with "setenv" param
I don't know how to make it to boot
I try different params but I allways have:

NAND read: device 0 offset 0x100000, size 0x14ac000
load addr ....  =a00000

 21676032 bytes read: OK
## Booting image at 00a00000 ...
Bad Magic Number

It means U-boot cannot find KERNEL in UBI partition

I try to boot with this params:

setenv bootargs_openwrt 'console=ttyS0,115200 earlyprintk root=ubi0 rootfstype=ubifs'
setenv bootcmd_openwrt 'setenv bootargs $(bootargs_openwrt);nand read.e 0xa00000 0x100000 14AC000; bootm 0xa00000'

where "14AC000" is size in HEX of Volume ID0(kernel) in UBI partition/
What do I do wrong?

On the OEM firmware, the kernel is not inside a UBI container, it's in a separate partition.

You have two options:

  1. If U-Boot supports booting from UBI, you need to change the boot command to load from an UBI partition (probably something with ubi read). Right now, your boot loader just reads the bytes at 0x100000 and tries to execute it - which fails if there is a UBI file system.
  2. Leave the kernel in its own partition and have the rootfs in UBI. This is what the OEM firmware does, judging from the boot log.

BuildRoot cannot create "kernel" and"rootfs" separately. Those can be unpacked from sysupgrade.bin, and kernel from unnpacked from "sysupgrade.bin" cannot find its rootfs, if it is on another partition.

That's only partially true: While they are both included in sysupgrade.bin, the sysupgrade script can flash the kernel to an MTD partition and the rootfs to a UBI partition if it's configured properly.

In your case, the kernel ended up in an UBI partition and the rootfs as well.

I suspect that your partition table in the .dts is either wrong (where the UBI partitino spans kernel and rootfs) or you set up the Makefile incorrectly. Without having a look at your code, this is a shot in the dark.

If the kernel cannot find its rootfs, then your bootargs are incorrect. You should be able to remove all information on the root/rootfs entirely, the kernel will do the right thing if your partition setup in the .dts is correct.

Hi. I've understood my stock u-boot has no ubi support. If you use linux on your DNS320l, you have upgraded your u-boot, so could you dump for me your upgraded u-boot? I'l try to use it. I don' have any fear in front of flashing u-boot, because I have allready unbricked my device once via serial port after flashing wrong u-boot.

P.S I have found how to compile new u-boot for dns320 without L, can I use it for DNS320L?

No, you still misunderstood the problem: You don't need UBI support in your U-Boot if you fix the way your OpenWrt image is compiled. There are a ton of devices that have the kernel in a regular MTD partition and only the rootfs in UBI. We can't help you here because we don't know your code. If you push your fork to github, I may be able to assist you.

NB: I'm relatively sure that you are missing this one line in your Makefile:

  KERNEL_IN_UBI :=

This unsets this variable which defaults to "1", forcing the kenel to be in its own partition. And your partition table needs to match this, so you need both, an UBI partition and a kernel partition.

Why should I have upgraded U-Boot!? Anyway, I replaced this device years ago.

If you want a brick, you can. Never, I repeat, never flash a U-Boot from a different device to yours unless you know exactly that it's going to work.

I did it twice, and after it bricked my device restored my own u-boot via serial. U-boot was taken from directory,where compiled firmware was placed by "make" while openwrt buildroot compilation.

I have understood the problem, I have to change partitions in "dts", but this will make me to upgrade openwrt "manually" every time. I'd like to use upgrade via Luci - safe and easy, that's why I am searching any way to do it so.

I have no any ideas how to do it. I'm noob

No, why should you have to? This is all handled by sysupgrade if you do it properly. OpenWrt supports your problem, you just have to tell it correctly how the partitions are set up.

Look, I did it how you said (kernel on an apart partition)


Bytes transferred = 5391447 (524457 hex)
Marvell>> bootm 0xa00000
## Booting image at 00a00000 ...
   Image Name:   ARM OpenWrt Linux-5.10.176
   Created:      2023-04-27  20:28:15 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    5391383 Bytes =  5.1 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.10.176 (xapuk@XAPUKSERGE) (arm-openwrt-linux-muslgnueabi-gcc (OpenWrt GCC 11.2.0 r20134-5f15225c1e) 11.2.0, GNU ld (GNU Binutils) 2.37) #0 Thu Apr 27 20:28:15 2023
[    0.000000] CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=0005397f
[    0.000000] CPU: VIVT data cache, VIVT instruction cache
[    0.000000] OF: fdt: Machine model: DNS-320L
[    0.000000] Memory policy: Data cache writeback
[    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] Built 1 zonelists, mobility grouping on.  Total pages: 64960
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk ubi.mtd=2 root=ubi0 rootfstype=ubifs
[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 241328K/262144K available (5780K kernel code, 592K rwdata, 1492K rodata, 9216K init, 206K bss, 20816K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] clocksource: orion_clocksource: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 11467562657 ns
[    0.000010] sched_clock: 32 bits at 166MHz, resolution 6ns, wraps every 12884901885ns
[    0.000046] Switching to timer-based delay loop, resolution 6ns
[    0.000193] Calibrating delay loop (skipped), value calculated using timer frequency.. 333.33 BogoMIPS (lpj=1666666)
[    0.000224] pid_max: default: 32768 minimum: 301
[    0.000425] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.000454] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.001377] CPU: Testing write buffer coherency: ok
[    0.002569] Setting up static identity map for 0x100000 - 0x10003c
[    0.002828] mvebu-soc-id: MVEBU SoC ID=0x6702, Rev=0x3
[    0.003058] dyndbg: Ignore empty _ddebug table in a CONFIG_DYNAMIC_DEBUG_CORE build
[    0.006552] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.006586] futex hash table entries: 256 (order: -1, 3072 bytes, linear)
[    0.006723] pinctrl core: initialized pinctrl subsystem
[    0.008332] NET: Registered protocol family 16
[    0.008940] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.010086] thermal_sys: Registered thermal governor 'step_wise'
[    0.010185] cpuidle: using governor ladder
[    0.010564] Feroceon L2: Enabling L2
[    0.010610] Feroceon L2: Cache support initialised.
[    0.019609] No ATAGs?
[    0.070926] SCSI subsystem initialized
[    0.072656] usbcore: registered new interface driver usbfs
[    0.072717] usbcore: registered new interface driver hub
[    0.072771] usbcore: registered new device driver usb
[    0.079170] clocksource: Switched to clocksource orion_clocksource
[    0.080094] NET: Registered protocol family 2
[    0.080328] IP idents hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.080935] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.080995] TCP established hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.081031] TCP bind hash table entries: 2048 (order: 1, 8192 bytes, linear)
[    0.081064] TCP: Hash tables configured (established 2048 bind 2048)
[    0.081149] UDP hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.081178] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.081376] NET: Registered protocol family 1
[    0.081412] PCI: CLS 0 bytes, default 32
[    0.191703] workingset: timestamp_bits=14 max_order=16 bucket_order=2
[    0.196081] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.196102] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.199410] kirkwood-pinctrl f1010000.pin-controller: registered pinctrl driver
[    0.201091] Serial: 8250/16550 driver, 2 ports, IRQ sharing disabled
[    0.201702] printk: console [ttyS0] disabled
[    0.201805] f1012000.serial: ttyS0 at MMIO 0xf1012000 (irq = 25, base_baud = 10416666) is a 16550A
[    0.614633] printk: console [ttyS0] enabled
[    0.620133] nand: device found, Manufacturer ID: 0xad, Chip ID: 0xf1
[    0.626466] nand: Hynix H27U1G8F2BTR-BC
[    0.630312] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[    0.637859] Scanning device for bad blocks
[    0.747115] Bad eraseblock 950 at 0x0000076c0000
[    0.759837] 3 fixed-partitions partitions found on MTD device orion_nand
[    0.766511] Creating 3 MTD partitions on "orion_nand":
[    0.771644] 0x000000000000-0x000000100000 : "u-boot"
[    0.780880] 0x000000100000-0x000000200000 : "kernel"
[    0.786464] 0x000000200000-0x000010000000 : "ubi"
[    0.791191] mtd: partition "ubi" extends beyond the end of device "orion_nand" -- size truncated to 0x7e00000
[    0.825413] mv643xx_eth: MV-643xx 10/100/1000 ethernet driver version 1.4
[    0.836648] mv643xx_eth_port mv643xx_eth_port.0 eth0: port 0 with MAC address c4:a8:1d:03:31:b5
[    1.929177] rtc-mv f1010300.rtc: internal RTC not ticking
[    1.934661] i2c /dev entries driver
[    1.938855] orion_wdt: Initial timeout 25 sec
[    1.950291] marvell-cesa f1030000.crypto: CESA device successfully registered
[    1.958259] NET: Registered protocol family 10
[    1.964793] Segment Routing with IPv6
[    1.968533] NET: Registered protocol family 17
[    1.973204] 8021q: 802.1Q VLAN Support v1.8
[    1.982199] ubi0: attaching mtd2
[    2.186662] ubi0: scanning is finished
[    2.204126] ubi0: attached mtd2 (name "ubi", size 126 MiB)
[    2.209622] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[    2.216469] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[    2.223162] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
[    2.229934] ubi0: good PEBs: 1007, bad PEBs: 1, corrupted PEBs: 0
[    2.236003] ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
[    2.243206] ubi0: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 717771903
[    2.252224] ubi0: available PEBs: 0, total reserved PEBs: 1007, PEBs reserved for bad PEB handling: 19
[    2.261831] ubi0: background thread "ubi_bgt0d" started, PID 403
[    2.268933] block ubiblock0_1: created from ubi0:1(rootfs)
[    2.274427] ubiblock: device ubiblock0_1 (rootfs) set to be root filesystem
[    2.308389] Freeing unused kernel memory: 9216K
[    2.312986] Run /init as init process
[    2.660085] init: Console is alive
[    2.663700] init: - watchdog -
[    2.676142] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    2.710215] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    2.721008] fsl-ehci: Freescale EHCI Host controller driver
[    2.730246] ehci-orion: EHCI orion driver
[    2.734428] orion-ehci f1050000.ehci: EHCI Host Controller
[    2.739955] orion-ehci f1050000.ehci: new USB bus registered, assigned bus number 1
[    2.747725] orion-ehci f1050000.ehci: irq 29, io mem 0xf1050000
[    2.779200] orion-ehci f1050000.ehci: USB 2.0 started, EHCI 1.00
[    2.785885] hub 1-0:1.0: USB hub found
[    2.790331] hub 1-0:1.0: 1 port detected
[    2.798642] ehci-platform: EHCI generic platform driver
[    2.814437] sata_mv f1080000.sata: slots 32 ports 2
[    2.824660] scsi host0: sata_mv
[    2.829160] scsi host1: sata_mv
[    2.832673] ata1: SATA max UDMA/133 irq 32
[    2.836753] ata2: SATA max UDMA/133 irq 32
[    3.170478] ata1: SATA link down (SStatus 0 SControl F300)
[    3.500461] ata2: SATA link down (SStatus 0 SControl F300)
[    3.506252] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    3.523801] init: - preinit -
[    3.731344] random: jshn: uninitialized urandom read (4 bytes read)
[    3.785873] random: jshn: uninitialized urandom read (4 bytes read)
[    3.812910] random: jshn: uninitialized urandom read (4 bytes read)
[    4.000152] mv643xx_eth_port mv643xx_eth_port.0 eth0: link up, 100 Mb/s, full duplex, flow control disabled
[    4.009885] mv643xx_eth_port mv643xx_eth_port.0 eth0: link down
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
[    5.750784] mv643xx_eth_port mv643xx_eth_port.0 eth0: link up, 100 Mb/s, full duplex, flow control disabled
[    5.760537] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[    8.136398] procd: - early -
[    8.140036] procd: - watchdog -
[    8.699295] procd: - watchdog -
[    8.702990] procd: - ubus -
[    8.711428] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.756284] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.763006] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.772544] procd: - init -
Please press Enter to activate this console.
[    9.244697] kmodloader: loading kernel modules from /etc/modules.d/*
[    9.402607] urngd: v1.0.2 started.
[    9.411164] PPP generic driver version 2.4.2
[    9.423905] NET: Registered protocol family 24
[    9.456412] kmodloader: done loading kernel modules from /etc/modules.d/*
[    9.536826] random: crng init done
[    9.540261] random: 28 urandom warning(s) missed due to ratelimiting
[   22.784525] br-lan: port 1(eth0) entered blocking state
[   22.789781] br-lan: port 1(eth0) entered disabled state
[   22.795228] device eth0 entered promiscuous mode
[   24.394480] mv643xx_eth_port mv643xx_eth_port.0 eth0: link up, 100 Mb/s, full duplex, flow control enabled
[   24.404226] br-lan: port 1(eth0) entered blocking state
[   24.409463] br-lan: port 1(eth0) entered forwarding state
[   24.424117] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready


Seems tio be OK untill I try to sysupgrade

- watchdog -
Watchdog does not have CARDRESET support
Tue May 30 05:41:53 UTC 2023 upgrade: Sending TERM to remaining processes ...
Tue May 30 05:41:57 UTC 2023 upgrade: Sending KILL to remaining processes ...
[  979.453313] stage2 (3902): drop_caches: 3
Tue May 30 05:42:03 UTC 2023 upgrade: Switching to ramdisk...
Tue May 30 05:42:05 UTC 2023 upgrade: Performing system upgrade...
Unlocking kernel ...

Writing from <stdin> to kernel ...  [e]Failed to get erase block status
tar: write error: Broken pipe
removing ubiblock0_1
[  982.755181] block ubiblock0_1: released
Volume ID 0, size 23 LEBs (2967552 bytes, 2.8 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "rootfs", alignment 1
Set volume size to 123992064
Volume ID 1, size 961 LEBs (123992064 bytes, 118.2 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "rootfs_data", alignment 1
sysupgrade successful
umount: can't unmount /dev: Resource busy
umount: can't unmount /tmp: Resource busy
[  984.341628] reboot: Restarting system

And certainly it cannot boot. After it I try to write "KERNEL" partition manually:

Marvell>> tftp 0x100000 kernel
Using egiga0 device
TFTP from server 192.168.1.2; our IP address is 192.168.1.1
Filename 'kernel'.
Load address: 0x100000
Loading: #################################################################
         #################################################################
         #################################################################
         ##########
done
Bytes transferred = 1048576 (100000 hex)
Marvell>> nand erase 0x100000 0x100000

NAND erase: device 0 offset 0x100000, size 0x100000
Erasing at 0x1e0000 -- 100% complete.
OK
Marvell>> nand write.e 0x100000 0x100000 0x100000

NAND write: device 0 offset 0x100000, size 0x100000
load addr ....  =100000

Writing data at 0x1ff800 -- 100% complete.
 1048576 bytes written: OK
Marvell>> run to_openwrt
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done


 ** MARVELL BOARD: DB-88F6702A-BP LE

U-Boot 1.1.4 (Apr 17 2012 - 19:36:21) Marvell version: 3.6.0.DNS-320L.01

U-Boot code: 00600000 -> 0067FFF0  BSS: -> 006CFB00

Soc: 88F6702 A1 CPU running @ 1000Mhz L2 running @ 500Mhz
SysClock = 400Mhz , TClock = 166Mhz

DRAM (DDR2) CAS Latency = 5 tRP = 5 tRAS = 18 tRCD=6
DRAM CS[0] base 0x00000000   size 256MB
DRAM Total size 256MB  16bit width
Addresses 8M - 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M - 7M): Done
NAND:128 MB
Flash:  0 kB

CPU : Marvell Feroceon (Rev 1)

Streaming disabled
Write allocate disabled


USB 0: host mode
PEX 0: interface detected no Link.
Net:   egiga0 [PRIME]
Hit any key to stop autoboot:  0

NAND read: device 0 offset 0x100000, size 0x100000
load addr ....  =a00000

 1048576 bytes read: OK
## Booting image at 00a00000 ...
   Image Name:   ARM OpenWrt Linux-5.10.176
   Created:      2023-04-27  20:28:15 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2754711 Bytes =  2.6 MB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... Bad Data CRC

What the....?