Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kirkwood: add ZyXEL NSA310b #656

Closed

Conversation

Projects
None yet
3 participants
@bobafetthotmail
Copy link
Contributor

bobafetthotmail commented Dec 31, 2016

kirkwood: add ZyXEL NSA310b

The ZyXEL NSA310 device is a Kirkwood based NAS:

  • SoC: Marvell 88F6702 1200Mhz
  • SDRAM memory: 256MB DDR2 400Mhz
  • Gigabit ethernet: Realtek (over pcie)
  • Flash memory: 128MB
  • 1 Power button
  • 1 Power LED (blue)
  • 5 Status LED (green/red)
  • 1 Copy/Sync button
  • 1 Reset button
  • 2 SATA II port (1 internal and 1 external)
  • 2 USB 2.0 ports (1 front and 1 back)
  • Smart fan

The stock u-boot cannot read ubi so it should be replaced with the
LEDE/OpenWRT's u-boot or with a u-boot from here
https://github.com/mibodhi/u-boot-kirkwood

This device's boot ROM supports "kwboot" tool
(in mainline u-boot, built automatically if CONFIG_KIRKWOOD is declared)
that sends an uboot image to the board over serial connection, it is very easy to unbrick.

The stock bootloader can use usb and read from FAT filesystems,
so the installation process is simple, place the uboot file on a USB flashdrive
formatted as FAT (here it is "openwrt-kirkwood-nsa310.bin", then connect TTL
to the board and write the following commands in the bootloader console:

usb reset
fatload usb 0 0x1000000 openwrt-kirkwood-nsa310.bin
nand write 0x1000000 0x00000 0x100000
reset

Now you are rebooting in the new u-boot, write this in its console to install the firmware:

usb reset
fatload usb 0 0x2000000 lede-kirkwood-nsa310b-squashfs-factory.bin
nand erase.part ubi
nand write 0x2000000 ubi 0x600000

If your firmware file is bigger than 6 MiBs you should write its size in hex
instead of 0x600000 above, or remove that number entirely (it will take a while in this case).

If you are using another uboot that can read ubi, set mtdparts like this

mtdparts=mtdparts=orion_nand:0x100000(uboot),0x80000(uboot_env),0x100000(second_stage_uboot),0x7b80000(ubi)

And set your bootcmd to be like this

bootcmd=run setenv bootargs; ubi part ubi; ubi read 0x800000 kernel; bootm 0x800000

Then you can install the firmware as described above.

After you installed (or configured) the u-boot for booting the firmware,
write the device's mac address in the ethaddr u-boot env.
The MAC address is usually on a sticker under the device (one of the two codes is the serial),
it should begin with "107BEF" as it is assigned to ZyXEL.

write in the u-boot console (use your MAC address instead of the example)

setenv ethaddr 10:7B:EF:00:00:00
saveenv

to save the mac address in the u-boot.

Signed-off-by: Alberto Bursi alberto.bursi@outlook.it

@kofec

This comment has been minimized.

Copy link

kofec commented Dec 31, 2016

hi bobafetthotmail,
After your latest changes in kirkwood section. I don't see uImage for default profile. I use it to start LEDE on my Zyxel NSA310 and it works great(just need to add ethernet module). I'm also using bodhi uboot. which uImage I should use now?

@bobafetthotmail

This comment has been minimized.

Copy link
Contributor Author

bobafetthotmail commented Jan 1, 2017

That change was actually done by nbd168 , all kirkwood devices have kernel (uimage) inside the ubi image now, so there is no separate uimage.
You flash the single ubi image to a mtdpartition called "ubi" and boot them with (uboot commands)
"ubi part ubi; ubi read 0x800000 kernel; bootm 0x800000"
if your uboot is able to read ubi (bodhi's can read ubi, stock uboot cannot), and there are correct mtdparts set in the dtb file (or passed through the bootargs) so the kernel can find the root on its own as usual for LEDE.

This PR for nsa310 generates an uimage (the kernel) and a ubi with rootfs+rootfs_data that works the same as older way, as when I tried to make it with kernel in ubi like for other kirkwoods, the kernel fails to mount the ubi partition even if uboot can mount it and read it fine.

to boot it with bodhi's uboot (and also with stock uboot with minor adjustments) you must set these envs

setenv mtdparts 'mtdparts=orion_nand:0x100000(uboot),0x80000(uboot_env),0x0500000(kernel),0x7980000(ubi)'
setenv bootcmd_lede 'run bootargs_lede; nand read 0x800000 kernel; bootm 0x800000'
senenv bootargs_lede 'setenv bootargs'

then append "; run bootcmd_lede" to the list in your bootcmd, mine is
bootcmd=run bootcmd_uenv; run scan_disk; run bootcmd_linux; run bootcmd_lede;

@nbd168

This comment has been minimized.

Copy link
Contributor

nbd168 commented Jan 11, 2017

@bobafetthotmail
When you tried to boot using KERNEL_IN_UBI, how did you flash it in the first place?
Did you try simply using sysupgrade from initramfs?

In this pull request it seems odd to have a factory.bin that does not contain the kernel

@bobafetthotmail

This comment has been minimized.

Copy link
Contributor Author

bobafetthotmail commented Jan 11, 2017

I flashed from bootloader with (there is a partition named "ubi" in the mtdparts):
usb reset; fatload usb 0 0x2000000 lede-kirkwood-nsa310b-squashfs-factory.bin; nand erase.part ubi; nand write 0x2000000 ubi 0x7e00000;

I used same commands (different partitions) to flash the kernel and the lede-kirkwood-nsa310b-squashfs-factory.bin that has only rootfs+rootfs_data and that boots fine.

Did you try simply using sysupgrade from initramfs?

No. I tried now and yes it works fine if I install it like that. Thanks.
Is it normal that sysupgrade from initramfs is different from flashing raw from bootloader?

Will update the PR later as I also need to make a second-stage bootloader now.
Stock bootloader cannot read ubi partitions like for most other kirkwoods anyway.

@nbd168

This comment has been minimized.

Copy link
Contributor

nbd168 commented Jan 11, 2017

I just pushed a change that should resolve the issue with flashing UBI images from u-boot, please test.

@bobafetthotmail

This comment has been minimized.

Copy link
Contributor Author

bobafetthotmail commented Jan 11, 2017

I just pushed a change that should resolve the issue with flashing UBI images from u-boot, please test.

It's working. I can flash the image from uboot and it boots correctly with latest sources. Thanks.

@bobafetthotmail bobafetthotmail force-pushed the bobafetthotmail:kirkwood branch 3 times, most recently from 7f4b652 to 724e086 Jan 13, 2017

@bobafetthotmail

This comment has been minimized.

Copy link
Contributor Author

bobafetthotmail commented Jan 13, 2017

Updated with KERNEL_IN_UBI configuration, mtdparts have a partition for the second-stage uboot but I haven't yet added a second-stage uboot for this device in this PR.

@kofec

This comment has been minimized.

Copy link

kofec commented Jan 20, 2017

@bobafetthotmail
Are you going to back to/finish this PR ? thanks in advance.
I tried you commit but i was not able to merge it locally:
git fetch origin pull/656/head:NSA310
fatal: Couldn't find remote ref pull/656/head

kofec@E5420Mint ~/openwrt/LEDEnsa310 $ git branch -a
  lede-17.01
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/lede-17.01
  remotes/origin/master
kofec@E5420Mint ~/openwrt/LEDEnsa310 $ git config -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://git.lede-project.org/source.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.fetch=+refs/pull/*/head:refs/remotes/origin/pr/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.lede-17.01.remote=origin
branch.lede-17.01.merge=refs/heads/lede-17.01

So I do it manually and received:
18M Jan 20 22:16 lede-kirkwood-nsa310b-squashfs-factory.bin
18M Jan 20 22:16 lede-kirkwood-nsa310b-squashfs-sysupgrade.tar
1,9M Jan 20 22:15 lede-kirkwood-nsa310b-uImage

but the devices didn't boot up - I don't have time to connect via serial.

@bobafetthotmail

This comment has been minimized.

Copy link
Contributor Author

bobafetthotmail commented Jan 20, 2017

@kofec yes, this weekend I'm going to try again at making the uboot for it.

@kofec

This comment has been minimized.

Copy link

kofec commented Jan 20, 2017

OK When I find I while I will start wiki for this device. Like for other already exist:
https://wiki.openwrt.org/toh/seagate/dockstar?s[]=kirkwood
https://wiki.openwrt.org/toh/seagate/goflexnet?s[]=kirkwood
itd.

@bobafetthotmail bobafetthotmail force-pushed the bobafetthotmail:kirkwood branch from 724e086 to 42ecab0 Jan 22, 2017

@bobafetthotmail

This comment has been minimized.

Copy link
Contributor Author

bobafetthotmail commented Jan 22, 2017

Updated, now also power button and smart fan work correctly.
I opened a new PR for its uboot. #728
Installation instructions are in the commit message.

EDIT: hmmm, while it works, mac address is set as 00:00:00:00:00:30, which is not the right one. Here stock uboot can't set mac addresses as it does not initialize the eth, but it does have a variable with a mac. I guess I'll have to set uboot-envtools too and read from old envs to get the right mac.

@bobafetthotmail bobafetthotmail force-pushed the bobafetthotmail:kirkwood branch from 42ecab0 to 6fc9a8d Jan 23, 2017

@bobafetthotmail

This comment has been minimized.

Copy link
Contributor Author

bobafetthotmail commented Jan 23, 2017

ok, updated. Now it loads the mac address from u-boot's variable "ethaddr".

Since stock firmware is using a random mac and there is no mac stored anywhere (the mac in stock uboot is bogus, it's the same for all nsa310 devices, I looked at hexdumps of all stock partitions, no mac address anywhere), the user has to read the mac from the sticker under the NAS and set himself the ethaddr variable to uboot after installation.
Since to install LEDE he needs to install a new u-boot anyway, it's not a major issue imho.

I opened yet another PR here #731 to add support for this device to uboot-envtools, that PR is obviously a prerequisite for this PR.

@bobafetthotmail

This comment has been minimized.

Copy link
Contributor Author

bobafetthotmail commented Jan 23, 2017

please wait again as I need to change mtdparts due to feedback in another PR.

kirkwood: add ZyXEL NSA310b
The ZyXEL NSA310 device is a Kirkwood based NAS:

- SoC: Marvell 88F6702 1200Mhz
- SDRAM memory: 256MB DDR2 400Mhz
- Gigabit ethernet: Realtek (over pcie)
- Flash memory: 128MB
- 1 Power button
- 1 Power LED (blue)
- 5 Status LED (green/red)
- 1 Copy/Sync button
- 1 Reset button
- 2 SATA II port (1 internal and 1 external)
- 2 USB 2.0 ports (1 front and 1 back)
- Smart fan

The stock u-boot cannot read ubi so it should be replaced with the
LEDE/OpenWRT's u-boot or with a u-boot from here
https://github.com/mibodhi/u-boot-kirkwood

This device's boot ROM supports "kwboot" tool
(in mainline u-boot, built automatically if CONFIG_KIRKWOOD is declared)
that sends an uboot image to the board over serial connection, it is very easy to unbrick.

The stock bootloader can use usb and read from FAT filesystems,
so the installation process is simple, place the uboot file on a USB flashdrive
formatted as FAT (here it is "openwrt-kirkwood-nsa310.bin", then connect TTL
to the board and write the following commands in the bootloader console:

usb reset
fatload usb 0 0x1000000 openwrt-kirkwood-nsa310.bin
nand write 0x1000000 0x00000 0x100000
reset

Now you are rebooting in the new u-boot, write this in its console to install the firmware:

usb reset
fatload usb 0 0x2000000 lede-kirkwood-nsa310b-squashfs-factory.bin
nand erase.part ubi
nand write 0x2000000 ubi 0x600000

If your firmware file is bigger than 6 MiBs you should write its size in hex
instead of 0x600000 above, or remove that number entirely (it will take a while in this case).

If you are using another uboot that can read ubi, set mtdparts like this

mtdparts=mtdparts=orion_nand:0x00c0000(uboot),0x80000(uboot_env),0x7ec0000(ubi)

And set your bootcmd to be like this

bootcmd=run setenv bootargs; ubi part ubi; ubi read 0x800000 kernel; bootm 0x800000

Then you can install the firmware as described above.

After you installed (or configured) the u-boot for booting the firmware,
write the device's mac address in the ethaddr u-boot env.
The MAC address is usually on a sticker under the device (one of the two codes is the serial),
it should begin with "107BEF" as it is assigned to ZyXEL.

write in the u-boot console (use your MAC address instead of the example)

setenv ethaddr 10:7B:EF:00:00:00
saveenv

to save the mac address in the u-boot.

Signed-off-by: Alberto Bursi <alberto.bursi@outlook.it>

@bobafetthotmail bobafetthotmail force-pushed the bobafetthotmail:kirkwood branch from 6fc9a8d to 367da4e Jan 23, 2017

@bobafetthotmail

This comment has been minimized.

Copy link
Contributor Author

bobafetthotmail commented Jan 23, 2017

ok updated to actually have uboot envs in the uboot env partition (changed mtdparts), and removed the partition for second-stage uboot as it does not seem to work anyway.

@nbd168

This comment has been minimized.

Copy link
Contributor

nbd168 commented Jan 24, 2017

Merged to my staging tree, thanks.

@nbd168 nbd168 closed this Jan 24, 2017

@bobafetthotmail bobafetthotmail deleted the bobafetthotmail:kirkwood branch Jan 24, 2017

@kofec

This comment has been minimized.

Copy link

kofec commented Jan 24, 2017

@bobafetthotmail
Your changes are commit on master so I'm going to test it. Do I have to connect via serial cabel? I'm able to run LEDE from USB on my nsa310. So maybe I can use mtd ... commands ?

@bobafetthotmail

This comment has been minimized.

Copy link
Contributor Author

bobafetthotmail commented Jan 24, 2017

It depends from how your custom LEDE is set up.
If you use the serial cable is better, also in case of mistakes it's easier to recover.

Imho it would be better if you use LEDE forum for most questions about that. I'm "bobafetthotmail" also in the forum.

@kofec

This comment has been minimized.

Copy link

kofec commented Jan 24, 2017

@kofec

This comment has been minimized.

Copy link

kofec commented Jan 25, 2017

@kofec

This comment has been minimized.

Copy link

kofec commented Feb 21, 2017

@bobafetthotmail
Hi, I found 2 issue on latest version of lede (kernel modules not loaded). On which forum we can continue topic ? doozan or lede ?

@bobafetthotmail

This comment has been minimized.

Copy link
Contributor Author

bobafetthotmail commented Feb 21, 2017

lede forums, development section. Write @bobafetthotmail so I get notified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.