NAS542 bootloop after Debian/OMV (get a new firmware) (solved)

Triu
Triu Posts: 46  Freshman Member
edited June 2019 in Personal Cloud Storage
I was 2 years on the Debian/OMV on SD-Card.
Now i saw new images from SCP here:http://seafile.servator.de/nas/zyxel/
I wanted to switch back to original firmware first with: sudo /firmware/sbin/info_setenv next_bootfrom 1
Since then i have a bootloop, no matter with, or without SD Card.

Afer a little bit fiddling i got a serial connection (RX and TX are mixed on http//zyxel.nas-central.org )
Log is attached.
Seems the first kernel has a bad checksum and the second is incomplete.
How can i get back the original Firmware?

I am really new to that stuff, i found this information here from Mijzelf
but don't understand that.
set ipaddress <ip1><br>set tftpserver <ip2><br>tftp uImage <some-address><br>mboot <some-address>
Do i need to setup a tftpserver on another machine or
is it just another PC in my Network with this uImage?
It should be V5.21 and found the Link from Mijzelf, but which file is what?

Would be nice if someone could explain it a little bit more detailed.
Thank you

#NAS_May_2019
«13456710

Comments

  • Mijzelf
    Mijzelf Posts: 2,763  Guru Member
    250 Answers 2500 Comments Friend Collector Seventh Anniversary
    Seeing the bootlog the firmware kernel in /dev/nand0.kernel1.bb is damaged (or was never there. Have you ever updated the firmware before installing Debian?), and the current environment doesn't specify the right rootfs for the Debian kernel.

    Do i need to setup a tftpserver on another machine or is it just another PC in my Network with this uImage?
    A tftpserver is software. It doesn't matter where it runs, as long as it's reachable over network from the NAS.
    The stock kernel has an internal initramfs, which can boot the box to the webinterface. So the idea is to provide a stock kernel over tftp (being the only network protocol u-boot supports. Don't know about bootbox), and boot that. Then you can use the webinterface to upgrade the firmware, which will flash a fresh kernel.
  • Triu
    Triu Posts: 46  Freshman Member
    Hi Mijzelf,
    thank you for this explanation.
    I am not shure if i updated the system before.
    I try (hopefully) this weekend to set up a tftpserver to get access with the NAS to it. Last time i got an IP from DHCP so this step should work.
    I don't know how to boot that file, i only saw a command "flash" from bootbox -help.

    (as i mentioned, no experience with work like that, only "beginner" skills with Linux, but they are growing) ;)
  • Triu
    Triu Posts: 46  Freshman Member
    edited May 2019
    So i explain everything for people like me which never had contact with TFTP. Maybe it helps someone.
    I have a Arch machine running where the uImage.521 should be provided by a TFTP-Server. I used dnsmasq for that. Everything explained here: https://wiki.archlinux.org/index.php/Dnsmasq  I disabled DNS by editing /etc/dnsmasq.conf and set "port=0" also i uncommented 1 line to enable TFTP (enable-tftp) and changed a line to "tftp-root=/srv/tftp". Then i've created a root folder for TFTP (/srv/tftp). After that you can start it with "systemctrl start dnsmasq.service", then i put the uImage.521 into /srv/tftp. To test locally if it is running type "journalctl -u dnsmasq.service"
    On the NAS, connected through serial, runs barebox (not bootbox as thought). Commands are attached. First i needed an ip-adress, this works with the command "dhcp", if you have a DHCP in your network. (If it doesn't work you can reboot your NAS, cause it has 2 LAN Ports and the other one is used or connect your LAN cable to the other port). If it works you get a warning about "No MAC adress" but you will get an IP. To check your settings type "devinfo eth0". My IP adress was 192.168.2.37 but the serverip was 192.168.1.70. I changed the serverip to the IP the Arch machine had with "eth0.serverip=192.168.2.58". Now i tried to get the uImage with "tftp uImage.521". Yeaaaahhhh, it's loading.
    If it is done you can check if the file is stored locally with "ls".
    Then i tried "bootm uImage.521" but got "ERROR: out of memory" and a reboot. I tried bootm because of Mijzelf said something about mboot on u-boot. Then i tried "bootu uImage.521", the output was:
    commandline: console=ttyS0,115200n8, init=/etc/preinit pcie_gen1_only=yes mac_addr=,,
    arch_number: 1094
    Followed by a reboot and nothing else has changed. At last i tested with "bootz uImage.521"
    invalid magic 0x2e332d78
    Followed by a reboot.
    What exactly is this uImage? I have the options bootm (boot an application image), bootu (start a raw linux image) and bootz (start a zImage).
    Maybe the CPU is getting to hot, at the moment i try to cool it with the original metal case on the CPU and a hairdryer, cause the NAS-Fan spins to slow.
  • Mijzelf
    Mijzelf Posts: 2,763  Guru Member
    250 Answers 2500 Comments Friend Collector Seventh Anniversary
    I looked at the files in http://seafile.servator.de/nas/zyxel/build, there is some file nas540-kernel-build-20180309.zip, which contains a file nas540-barebox-boot.tgz, which contains a script /barebox/bin/b0, which tells me barebox is a bit more complex than uboot.
    The box boots using the command
    <div>bootm $kdev<br></div>
    On u-boot $kdev would be an memory address, but on barebox it's a device. When I read the script well, the commands could be
    <div>addpart /dev/ram0 8M@0x8000(kernelraw)<br>addpart /dev/ram0 8M@8M(kernel)<br>netload="/dev/ram0.kernel"<br>tftp uimage $netload<br>bootm $netload<br></div>
    Here 2 devices are created, /dev/ram0.kernelraw and /dev/ram0.kernel. The first allocating memory for the raw kernel will be loaded, the second for uimage.

  • Triu
    Triu Posts: 46  Freshman Member
    edited May 2019
    Output of"addpart /dev/ram0 8M@0x8000(kernelraw)" => "No such file or directory"
    /dev/ files:
    zero, defaultenv, mem, phy0, spi0, env0, nand0, nand_oob0, self_raw, self0, spi0.uloader, spi0.barebox, spi0.env, nand0.config, nand0.kernel1, nand0.rootfs1, nand0.kernel2, nand0.rootfs2, nand0.reserved, nand0.reserved.bb, nand0.rootfs2.bb, nand0.config.bb, nand0.rootfs1.bb, nand0.kernel1.bb, nand0.config.bb

    Also i can't create a ram0 file manually, cause it is read-only file system.

    On boot it tolds me "booting kernel of type uimage from /dev/nand0.kernel1.bb". Isn't it possible to flash your uImage into that nand0.kernel1.bb? This is the one with the checksum error anyway.

    EDIT: I found this line as an example here: https://www.barebox.org/doc/latest/boards/imx.html
    barebox@Board Name:/ bootm /mnt/tftp/barebox-freescale-imx51-babbage.img
    So i think my first try with the file copied to local / and then "bootm uImage.521" should have been fine. What exactly ist this file? A uImage with the original Firmware from Zyxel on the NAS540 Vers.521AA? Maybe i need the older Vers. 520AA?
  • Mijzelf
    Mijzelf Posts: 2,763  Guru Member
    250 Answers 2500 Comments Friend Collector Seventh Anniversary
    Output of"addpart /dev/ram0 8M@0x8000(kernelraw)" => "No such file or directory"

    Apparently /dev/ram0 also has to be created. Don't know how that scrips in that tarball are called. You could have a look at the available scripts (in /env/bin?) to see if any of them creates /dev/ram0.
    On boot it tolds me "booting kernel of type uimage from /dev/nand0.kernel1.bb". Isn't it possible to flash your uImage into that nand0.kernel1.bb? This is the one with the checksum error anyway.

    You can try. But it seems unlikely that you can tftp directly to nand.

    So i think my first try with the file copied to local /

    You just wrote it's read only. I think you have to mount a ramfs somewhere. For instance on /mnt/tftp.

    What exactly ist this file? A uImage with the original Firmware from Zyxel on the NAS540 Vers.521AA? Maybe i need the older Vers. 520AA?

    That is the file I uploaded somewhere? It's a uImage extracted from a firmware file. On a full blown Linux platform you can see the filetype with

    <p>file uImage<br></p>
    And no, you don't need an older version. ZyXEL never (well, almost never) updates the bootloader. So this bootloader is suitable to boot 521.

  • Triu
    Triu Posts: 46  Freshman Member
    Thank you for your quick reply.
    The read only error was under /dev/* . In / i can put files (also TFTP put them here), but after a reboot they are gone. The first try was with the uImage.521 local shown under / and then typed "bootm uImage.521" but got "ERROR: out of memory"
    I came to the idea with flashing because of this commands: protect - enable flash write protection, unprotect - disable flash write protection, update_nand - Flash the NAND.
    But i have no clue if i can specify to the first or second or does this write on both? I don't want to destroy my NAS completely.  :open_mouth:
    Good to hear that the file should work anyway, so sorting out one error source.

    Seems i try to figure out what the scripts have done.




  • Mijzelf
    Mijzelf Posts: 2,763  Guru Member
    250 Answers 2500 Comments Friend Collector Seventh Anniversary
    The first try was with the uImage.521 local shown under / and then typed "bootm uImage.521" but got "ERROR: out of memory"

    That might have to be 'bootm /uImage.521'. But the out of memory suggests the barebox doesn't allocate too much memory for itself, and the uImage filled that up.

    Can you see if the size for /uImage.521 is right?

    But i have no clue if i can specify to the first or second or does this write on both?

    No. Somehow barebox has created flash partitions, and so writing to /dev/nand0.kernel1.bb will only touch the partition containing kernel1.

    I think there are two entries to that partition, /dev/nand0.kernel1.bb, and /dev/nand0.kernel1. I think one is raw flash (including metadata about the individual cells) and the other is filtered, as in, it outputs the expected binary. Complication, I don't know which of the two has to be written.






  • Triu
    Triu Posts: 46  Freshman Member
    edited May 2019
    I also tested with "bootm /uImage.521" but the output was the same (Error out of memory). I tried "ls -h" but this option doesn't work. With "ls -l" gives me 7311720 (blocksize). Don't know how to calculate it back. (ext4, standard settings)

    I found "mount" but it doesn't work. https://www.barebox.org/doc/latest/filesystems/tftp.html
    barebox:/ mount -t tftp 192.168.2.58 /mnt
    But i got this:
    Usage: mount [<device> <fstype> <mountpoint>]
    I created a folder with "mk mnt" and tried:
    mount 192.168.2.58 tftp /mnt
    mount \\192.168.2.58 tftp /mnt
    mount 192.168.2.58 /mnt
    But nothing works, "invalid argument".

  • Mijzelf
    Mijzelf Posts: 2,763  Guru Member
    250 Answers 2500 Comments Friend Collector Seventh Anniversary
    mount none ramfs /mnt
    And after that you can tftp your uImage to /mnt

Consumer Product Help Center