Output stderr /stdout from preinit script?

Is there a way to debug preinit scripts?

I'm trying to mount a ubi filesystem and the mount command fails but I can't see why, I can successfully run the code from terminal, but the same code won't run in a preinit script.

I tried using &>> /tmp/log.txt in the ubi attach and mount command and it broke the init script and i had to patch the board_name in tmp to be able to flash from luci again.

From what I recall echo "just works"? I think that's what I did when doing my preinit stuff.

A quick google says there used to be preinit_echo function? I found preinit_net_echo ?

I did try prienit_echo as below but I got no output in the log in luci.
I tried to edit the preinit.conf and it did not seem to work either there was stuff about preinit ip and interface and I did not see it in the wiki what it was supposed to do or how it worked:

pi_suppress_stderr="n"

pi_init_suppress_stderr="n"
#!/bin/sh

preinit_mount_factory_data() {
	local mtd_path

	. /lib/functions.sh
	. /lib/functions/system.sh

	case $(board_name) in
	tplink,deco-x80-5g)
		mtd_path=$(find_mtd_chardev "factory_data")
		ubiattach --dev-path="$mtd_path" --devn=1
		mkdir /tmp/factory_data
		mount -o ro,noatime -t ubifs /dev/ubi1_0 /tmp/factory_data
		preinit_echo "mounting factory_data"
		;;

	tplink,eap660hd-v1)
		mtd_path=$(find_mtd_chardev "factory_data")
		ubiattach --dev-path="$mtd_path" --devn=1
		mkdir /tmp/factory_data
		mount -o ro,noatime -t ubifs ubi1:ubi_factory_data /tmp/factory_data
		;;
	esac
}

boot_hook_add preinit_main preinit_mount_factory_data

to clarify what I was saying. Preinit echo isn't there. But preinit_net_echo is still there in the code. I was trying to get you to use echo?

My recollection was I tried preinit_echo and it iddn't work. But then I tried echo and it worked.

I'm accounting for stdin/stdout in preinit is the serial port?
I know in the build system there's preinit options for setting ip address. I haven't tried or looked into the net-echo stuff.

I'm going to have to try to replicate your problem as it's been a bit since I was doing preinit stuff haha.

All else fails, you have pr_info in the kernel? What exactly are you trying to do in preinit?

Echo did not seem to work either; I'm just going to try the preinit_net_echo command and see what happens.
I'm guessing it redirects the preinit output to a seperate ssh connection on an alternative IP going off the preinit.conf contents.

Redirecting output to a file using &> actually trashed the preinit process and a whole lot of stuff broke like dropbear etc... I'm lucky i managed to recover it by running selective preinit commands from terminal using ttyd to fix it.