« Back to all recent discussions

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

TriuTriu Posts: 46  Junior Member
edited June 11 in Discussions
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>
set tftpserver <ip2>
tftp uImage <some-address>
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
Tagged:
«13456

Comments

  • MijzelfMijzelf Posts: 726  Heroic Warrior Member
    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.
  • TriuTriu Posts: 46  Junior 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) ;)
  • TriuTriu Posts: 46  Junior Member
    edited May 12
    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.
  • MijzelfMijzelf Posts: 726  Heroic Warrior Member
    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
    bootm $kdev
    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
    addpart /dev/ram0 [email protected](kernelraw)
    addpart /dev/ram0 [email protected](kernel)
    netload="/dev/ram0.kernel"
    tftp uimage $netload
    bootm $netload
    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.

  • TriuTriu Posts: 46  Junior Member
    edited May 13
    Output of"addpart /dev/ram0 [email protected](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
    [email protected] 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?
  • MijzelfMijzelf Posts: 726  Heroic Warrior Member
    Output of"addpart /dev/ram0 [email protected](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

    file uImage
    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.

  • TriuTriu Posts: 46  Junior 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.




  • MijzelfMijzelf Posts: 726  Heroic Warrior Member
    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.






  • TriuTriu Posts: 46  Junior Member
    edited May 17
    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".

  • MijzelfMijzelf Posts: 726  Heroic Warrior Member
    mount none ramfs /mnt
    And after that you can tftp your uImage to /mnt

  • TriuTriu Posts: 46  Junior Member
    edited May 17
    Unfortunately this gives me: "No such file or directory".
    Then i tried: "mount ramfs /mnt"
    But that shows me the Usage text again. "Usage: mount [<device> <fstype> <mountpoint>]"

  • MijzelfMijzelf Posts: 726  Heroic Warrior Member
    Bummer. I assume the /mnt directory exists?

    According to the barebox site barebox can also mount fat filesystems. Does a disk showup in /dev when you boot the box with a disk and/or usb stick inserted? And can it be mounted?
  • TriuTriu Posts: 46  Junior Member
    edited May 18
    O M G . I really forgot that. (Too much testing with reboot every 30sec and a hairdryer next to me.) Now something is right, cause i get no error. Instead i get only a new prompt line. Then i tftp into the /mnt folder. After that i used "bootm /mnt/uImage.521", this gets me the same ERROR: Out of memory.
    With USB, i formated a stick with fat32, plugged it in but i don't know how to find it. Dmesg and lsusb doesn't work on barebox. Couldn't find him in /env nor in /dev. I found something about automount here: https://www.barebox.org/doc/latest/user/automount.html
    My system tells me "unknown command 'automount'
    Seems this barebox.org/doc is outdated, or can barebox be adjusted? I mean could Zyxel make an own barebox with only the most necessary stuff they want?

  • MijzelfMijzelf Posts: 726  Heroic Warrior Member
    edited May 20
    this gets me the same ERROR: Out of memory.

    Again? Does 'mount' show the ramfs is actually mounted? Does the 'meminfo' command show the available and used memory? Is the ramfs subtracted from the main memory?

    And does another uImage (for instance that Debian one) boot?

    can barebox be adjusted?

    AFAIK yes. The manual tells you can configure it with 'make menuconfig'. Which is also the way you can enable or disable applets in the Linux kernel or busybox.

    With USB, i formated a stick with fat32, plugged it in but i don't know how to find it.

    How about the usb command?



  • TriuTriu Posts: 46  Junior Member
    edited May 20
    The usb command doesn't work here (unkown command). I also couldn't find anything related to USB in the Command-List. Also meminfo doesn't work. I found the command "md" but it shows me:
    Barebox-C2K >/ md
    00000000: ffffffff ffffffff ffffffff ffffffff                ................
    00000010: ffffffff ffffffff ffffffff ffffffff                ................
    00000020: ffffffff ffffffff ffffffff ffffffff                ................
    00000030: ffffffff ffffffff ffffffff ffffffff                ................
    00000040: ffffffff ffffffff ffffffff ffffffff                ................
    00000050: ffffffff ffffffff ffffffff ffffffff                ................
    00000060: ffffffff dfffffff ffffffff ffffffff                ................
    00000070: ffffffff ffffffff ffffffff ffffffff                ................
    00000080: ffffffff ffffffff ffffffff ffffffff                ................
    00000090: ffffffff ffffffff ffffffff ffffffff                ................
    000000a0: ffffffff ffffffff ffffffff ffffffff                ................
    000000b0: ffffffff ffffffff ffffffff ffffffff                ................
    000000c0: ffffffff ffffffff ffffffff ffffffff                ................
    000000d0: ffffffff ffffffff ffffffff ffffffff                ................
    000000e0: ffffffff ffffffff ffffffff ffffffff                ................
    000000f0: ffffffff ffffffff ffffffff ffffffff                ................

    It does not change after mount a ramfs.

    With the output of devinfo i can see the new ramfs1 at the end of devices which wasn't there before.

    Barebox-C2K >/ devinfo
    devices:
    |----ramfs0
    |----devfs0
    |----mem0 (defaultenv)
    |----mem1 (mem)
    |----fast_uart0
    |----cs0
    |----c2k_i2c0
    |----eeprom0
    |----c2k_spi0
    |----S25FL064A0
    |----comcerto_spi10
    |----comcerto_spi20
    |----legerity0
    |----c2k_otp0
    |----c2000_eth0
    |----miidev0 (phy0)
    |----eth0
    |----c2000_eth1
    |----eth1
    |----cfi_flash0
    |----csi_flash0 (spi0, env0, spi0.uloader, spi0.barebox, spi0.env)
    |----comcerto_nand0
    |----nand0 (nand0, nand_oob0, self_raw, nand0.config, nand0.kernel1, nand0.rootfs1, nand0.kernel2, nand0.rootfs2, nand0.reserved)
    |----ramfs1

    drivers:
     fast_uart
         ramfs
         devfs
        miidev
     c2000_eth
    comcerto_nand
     cfi_flash
       c2k_spi
    c2k_fast_spi
     csi_flash
       c2k_i2c
       c2k_otp
           mem
        cramfs
    Also the mount command tells it is there: (before&after)
    Barebox-C2K >/ mount
    none on / type ramfs
    none on /dev type devfs
    Barebox-C2K >/ mk mnt
    Barebox-C2K >/ mount none ramfs /mnt
    Barebox-C2K >/ mount
    none on / type ramfs
    none on /dev type devfs
    none on /mnt type ramfs

    Seems i do not have to make a ramfs cause "/" is already one.

    I tried "mtest" but that tells me: "Usage: <start> <end>". But nothing worked: "mtest -start", "mtest start", "mtest 1", "mtest <start>" , "mtest".

    Then i copied a Debian uImage without "mount" and "/mnt" only with "tftp uImage1". After "bootm uImage1" it started booting, but ends up in a "Kernel panic error". Attached is the boot-log.

    At the beginning of the boot-log: "Memory: 44MB 960MB = 1004MB total" "Memory: 1012108k/1012108k available, 36468k reserved, 0K highmem". There should be enough memory, i think.

    Thank you for your help. Hope this NAS will work again.


Sign In or Register to comment.