OK, made some good progress! Let me try to explain - I think I only have one nitpicky item left .
First, an observation. I was pulling my hair out, as I would set u-boot environment variables, and they seemed to be disappearing. Then I found it! In the serial logs, if I changed the boot_part value (dual partition router), and rebooted, I see (for example),
sync bootargs for ALT
..Erasing NAND Flash...
ranand_erase: start:80000, len:20000
.Writing to NAND Flash...
done
Well, dang it - there it is! Linksys u-boot is overwriting my environment, with it's defaults! But interestingly enough, bootargs is set as follows,
bootargs=console=ttyS1,115200n8 root=/dev/mtdblock6 ro rootfstype=jffs2 init=/sbin/init
Very close to what I want, and ... root is adjusted (automatically, by Linksys u-boot) to mtdblock6 or mtdblock8, depending on the value of boot_part. Sweet! So now I just need to have used in my router, to set the rootfs (ubi).
Then, I found how to get root set (and named to ubi, mounted), based on the root device in the command line. It takes 3 things,
- kernel configuration (kernel_menuconfig),
Extend dtb kernel arguments with bootloader arguments
. This allows me to read / use the input from u-boot.
- include the patch,
202-linksys-find-active-root.patch
. As it says right in it (and I just need the same)
The WRT1900AC among other Linksys routers uses a dual-firmware layout.
Dynamically rename the active partition to "ubi".
- OK, so the command line is read in (appended) from u-boot, I can use that information, just need to handle it. It turns out this just requires
CONFIG_MANGLE_BOOTARGS
. This extracts the mtdblock number, and uses it to (dyanmically) set ubi (rootfs). Great!
Checked, and confirmed to be working (on both partitions). Just a couple minor questions now,
- How to set
CONFIG_MANGLE_BOOTARGS
for this target (and not the entire family)?
- I end up with two consoles ... one from the u-boot command line (as above), the other from the kernel configuration. And with 2 of them enabled (Kernel command line), I see output like,
[ 4.157449] Run /sbin/init as init process
[ 4.157449] Run /sbin/init as init process
[ 4.165604] with arguments:
[ 4.165604] with arguments:
[ 4.171513] /sbin/init
[ 4.171513] /sbin/init
[ 4.176902] with environment:
[ 4.176902] with environment:
[ 4.183161] HOME=/
[ 4.183161] HOME=/
[ 4.187850] TERM=linux
[ 4.187850] TERM=linux
[ 4.193238] mangled_fs=jffs2
[ 4.193238] mangled_fs=jffs2
So everything is double output (to console). I'd remove the OpenWrt configured one, but it seems that the console provided by u-boot is output only, not input. Huh?
By all means yell if this all seems crazy . Thanks!
BTW, much of this I found from the ea3500, looking through that code. It's also a dual partition Linksys router.