Chadster766 / McDebian

Linksys WRT3200ACM, WRT1900AC, WRT1900ACS, WRT1200AC and WRT32X Router Debian Implementation
98 stars 14 forks source link

[Discussion] Keep boot from a partition #36

Closed zhouruixi closed 4 years ago

zhouruixi commented 7 years ago

You had suggest flash McDebian kernel image both to mtd4 and mtd6 in your wiki. (My router is WRT1200AC v1.)

However, I want use mtd4 for LEDE and mtd6 for McDebian. But my router with McDebian will change boot_part after boot 3 times.

How LEDE keep boot from a same partition? I found that LEDE use "mtd resetbc s_env" to reset bootcount which saved in /dev/mtd2.

More information: https://github.com/lede-project/source/blob/master/target/linux/mvebu/base-files/etc/init.d/linksys_recovery https://github.com/lede-project/source/blob/master/package/system/mtd/src/linksys_bootcount.c

There is no mtd(support resetbc) command provide by debian. So I had do somthing below:

  1. Build LEDE with glibc.
  2. Taken mtd from mtd.ipk, libubox.so from libubox.ipk.
  3. Put libubox.so into /lib, put mtd into /usr/sbin.
  4. Add "sleep 5 && /usr/sbin/mtd resetbc s_env" to /etc/rc.local

I had test it for several times and it works well.

Redferne commented 6 years ago

I'm in the same boat. Can you please provide a link to your binaries? I really don't have the time or energy to build LEDE for glibc. Thank you!

Chadster766 commented 6 years ago

Why not just put the firmware in both image partitions like I recommend since you have USB to TTL access.

zhouruixi commented 6 years ago

@Chadster766 I use Mcdebian for most time, but sometimes I just need a simple and easy router system(LEDE or offical firmware). Dual system is more useful to me. So, It's just a personal needs. Nerver mind : )

zhouruixi commented 6 years ago

@Redferne You can download from here: https://1drv.ms/f/s!AtB5-c6zgutCvw2isYte0LwkLboX

Have fun~

Redferne commented 6 years ago

Thanks! 😊

Chadster766 commented 6 years ago

I've decided to try and implement this because McDebian does support the WRT32X but in order for me to publish the load process for it I need to make sure the Linksys firmware can be left on in one of the image partitions.

This is because Linksys has not released a u-boot loadable firmware for the WRT32x leaving no way for a user to switch back to Linksys firmware after using open source firmware.

ericwoud commented 5 years ago

You could give the following file a try:

https://github.com/ericwoud/buildWubuntu/blob/master/custom/tools/linksys_bootcount.c

It is the source from openwrt shrunk down to the bootcount part only.

Use the Makefile located in the same folder. Compile it with make running on the linksys, so you do not need to cross-compile.

Chadster766 commented 4 years ago

@ericwoud Thank you very much for providing the link to the code and makefile for the linksys_bootcount.

I've successfully compiled and tested it with a change of cross compiler and a couple of small -I and -L added to the flags.

This will be implemented in the buster rootfs coming soon.

Chadster766 commented 4 years ago

Hi @Redferne, I've released the McDebian Buster beta for testing. https://github.com/Chadster766/McDebian/issues/62