[AR300M] OpenWRT and NOR vs NAND


I’d like to get a bit better understanding of the software on the AR300M. From what I’ve read in the AR300M.md[1] the default used storage is NAND with a fallback to the NOR in case of 9 failed bootups.

In this manner I have a few questions:

  1. How does it check if it successfully booted? Does a script flip something via sysfs to let know ‘below’ that the system has booted or only if the uboot managed to execute the kernel? I wonder if it would fallback to the NOR flash in case of broken network scripts/uci config on the NAND-hosted system.

  2. Does NOR and NAND systems share configuration, or they’re completely unrelated and as such, after falling back to the NOR the system will not have my latest configuration?

  3. Can I intentionally boot from NOR instead of NAND? (Beside using uboot prompt via serial console)

  4. When I flash new software, do I need to have both NOR and NAND matched, ex with the same OpenWRT version, or one can have stock software and another vanilla OpenWRT?

My ordered unit will most likely take a week or two to be shipped, so I cannot check on above myself just yet.

Thanks in advance!

[1] https://github.com/domino-team/docs/blob/master/mini/ar300m.md

Good questions. I’ve had the AR300M for several weeks now and have been playing around but have not been able to answer many of these. Documentation is somewhat sparse…
I did something to corrupt my NAND and it did boot over to NOR. That was great but I was not able to figure out how to flash NAND from NOR. I managed to do this from Uboot and got everything back up and running but that raised questions as to how to force boot from one to the other and flash different firmware.

@alzhao friendly bump. Please be so kind and respond.

  1. It use script to write uboot environment variables. If the system boots successfully, it will write the count as 0. Each time uboot boot will increase this number. Actually now it only count up to 3 failed boots and will fallback to Nor.

  2. They are completely separately and unrelated.

  3. In nand firmware, you can use fw_printenv to display the uboot env variables. You can use fw_setenv to set the value. Just set bootcount to 3 and reboot, it will enter Nor firmware. The nor firmware will reset this flag as well. Be sure to set it to 3 everytime you want to boot into Nor.

  4. These two firmware is unrelated. When upgrade from on firmware, it only upgrade the version for Nor or Nand, but not both. So no problem you can manipulate two firmware.

When you flash via uboot web UI, it will only flash Nand version, not Nor. Of course the UI should be improved so that you can upload different firmware.

Another thing is that you can use the switch to control which firmware you will need to boot into. The switch can trigger script to write the uboot env bootcount. In order to do this, there is three files you need to modify.

(1) /etc/init.d/initswitch, this script now does nothing but it contains the basic structure you need to make the switch work. The switch GPIO is BTN_1. If switch is left, you can set bootcount=0 so that next time it boot into Nand, if switch is right, you can set bootcount=3 so that next time it boot into Nor.

(2) /etc/rc.button/BNT_1, this script should do the same as above. This script will be called when you move the switch, but not when the system boot.

(3) /etc/diag.sh, search for “gl-ar300m” and remove the 3 lines in this section

You need to do this in both the Nor and Nand version. Of course we can do this in uboot, without touching these files. When uboot boot it will detect the switch position and decide which firmware to boot. But this will break the failback function. This is useful only for advanced users who want to different firmware and want to switch frequently.

@alzhao: What happens on the fourth failed boot? Will it try NAND again or continue trying NOR? Also, does flashing a new firmware via U-Boot reset the counter?

As I read your last reply, one could get stuck if the NOR firmware is broken, as there’s no way to try NAND again and U-Boot web only allows fixing NAND.

flashing a new firmware doesn’t reset the counter. If it is 4 then it always boot into Nor. When the Nor firmware boot it will clear this count. If nor firmware cannot boot then you cannot clear this counter.

If this happens then the only way to repair is to use serial connector.

We modified the uboot again now and you can choose to update Nor or Nand firmware from the web UI now. So this problem can be fixed. But only with the new uboot.