Welcome! Log In Create A New Profile

Advanced

Debian and U-boot on NSA325

Posted by alex_barborica 
alex_barborica
Debian and U-boot on NSA325
October 05, 2022 09:24AM
Hello, I have 2 of these NSA325 devices and since metarepository went offline they are essentially dead weight. I am very interested in putting debian on them but I have reached an issue when following the U-boot flash tutorial. I am currently just doing a dry run and have not flashed anything yet.
1. So first of all, do I need to do this all over serial? I currently have telnet access since I was trying to avoid opening it up. (but this is not an issue, if needed I can hook up serial directly to the board)
2. Following the tutorial some things don't match up. First of all my mtds are as follows:
```
dev: size erasesize name
mtd0: 00100000 00020000 "uboot"
mtd1: 00080000 00020000 "uboot_env"
mtd2: 00080000 00020000 "key_store"
mtd3: 00080000 00020000 "info"
mtd4: 00a00000 00020000 "etc"
mtd5: 00a00000 00020000 "kernel_1"
mtd6: 02fc0000 00020000 "rootfs1"
mtd7: 00a00000 00020000 "kernel_2"
mtd8: 02fc0000 00020000 "rootfs2"
```
the primary difference to the tutorial is that I have a separate mtd1 that holds the u-boot envs as I understand it.
also my fw_env.config holds the following:
```
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundand
# environment sector is assumed present.
# Notice, that the "Number of sectors" is ignored on NOR.

# MTD device name Device offset Env. size Flash sector size Number of sectors
# NAND example
/dev/mtd1 0x0000 0x20000 0x20000 4
```
Where in the tutorial /dev/mtd0 is defined as above.
So my confusion comes from how the tutorial tell me to erase mtd0 instead of mtd1 for the envs:
```
/usr/sbin/flash_erase /dev/mtd0 0xc0000 1
/usr/sbin/nandwrite -s 786432 /dev/mtd0 uboot.2016.05-tld-1.environment.img
```
shouldn't I erase and flash mtd0?

Also I have the following bad blocks:
```
Scanning device for bad blocks
Bad eraseblock 100 at 0x000000c80000
Bad eraseblock 200 at 0x000001900000
```

How should I proceed?
Re: Debian and U-boot on NSA325
October 05, 2022 11:19AM
alex_barborica,


> 1. So first of all, do I need to do this all over
> serial? I currently have telnet access since I was
> trying to avoid opening it up. (but this is not an
> issue, if needed I can hook up serial directly to
> the board)

You can flash u-boot from stock OS. Serial console is recommended, but not need to flash u-boot.

> 2. Following the tutorial some things don't match
> up. First of all my mtds are as follows:
> the primary difference to the tutorial is that I
> have a separate mtd1 that holds the u-boot envs as
> I understand it.

That's stock envs. The new u-boot uses a new envs location inside mtd0.

> So my confusion comes from how the tutorial tell
> me to erase mtd0 instead of mtd1 for the envs:

The u-boot flashing instruction shows how to erase and flash u-boot image and u-boot envs image correctly. Also, the fw_env.config in the instruction contains the correct location for the envs in mtd0.

> Also I have the following bad blocks:
> ```
> Scanning device for bad blocks
> Bad eraseblock 100 at 0x000000c80000
> Bad eraseblock 200 at 0x000001900000

These bad blocks are OK. They are not in mtd0.

> How should I proceed?

Just follow the instruction as it was written. The mtd0 is the only one used for new u-boot.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
alex_barborica
Re: Debian and U-boot on NSA325
October 05, 2022 01:43PM
bodhi Wrote:
-------------------------------------------------------

> You can flash u-boot from stock OS. Serial console
> is recommended, but not need to flash u-boot.

Ok I will try over telnet first

> That's stock envs. The new u-boot uses a new envs
> location inside mtd0.

Oh ok now I understand.

> The u-boot flashing instruction shows how to erase
> and flash u-boot image and u-boot envs image
> correctly. Also, the fw_env.config in the
> instruction contains the correct location for the
> envs in mtd0.

Ok so then should I replace my fw_env.config with the one in the tutorial before i proceed?

> > Also I have the following bad blocks:
> > ```
> > Scanning device for bad blocks
> > Bad eraseblock 100 at 0x000000c80000
> > Bad eraseblock 200 at 0x000001900000
>
> These bad blocks are OK. They are not in mtd0.
>
> > How should I proceed?
>
> Just follow the instruction as it was written. The
> mtd0 is the only one used for new u-boot.

Ok thanks very much for your help. I will proceed with the tutorial and post back if I encounter problems.
alex_barborica
Re: Debian and U-boot on NSA325
October 06, 2022 12:27PM
I just wanted to post back and say that IT WORKED! I just followed the u-boot tutorial to the dot and everything worked out perfectly. The only problem I encountered up to now is that u-boot-utils no longer contains fw_setenv or fw_printenv. So I ended up having to hook up serial in order to change u-boot envs.

Anyway once u-boot was installed everything became very familiar as I worked with raspberry pis a lot. The only truly complicated part was indeed getting u-boot on the device.

Thank you so much for breathing new life into these old devices.
Re: Debian and U-boot on NSA325
October 07, 2022 12:36AM
alex_barborica,

> The only problem
> I encountered up to now is that u-boot-utils no
> longer contains fw_setenv or fw_printenv. So I
> ended up having to hook up serial in order to
> change u-boot envs.

You've missed this release note:

Quote
https://forum.doozan.com/read.php?2,12096
Updated 26 Sept 2021:

Basic Debian bullseye Kirkwood rootfs for most Kirwood plugs:

- tarball size: 234M
- install size: 668M
- The init system used in this rootfs is sysvinit . To boot with systemd, see Notes below.
- Installed packages: nano, avahi, ntp, busybox-syslogd (log to RAM), htop, isc-dhcp-client, dialog, bzip2, nfs server/client, iperf, ethtool, sysvinit-core, sysvinit, sysvinit-utils, u-boot-tools, and mtd-utils.
- see LED controls examples in /etc/rc.local, and /etc/init.d/halt
- see some useful aliases in /root/.profile
- root password: root

Important Correction:

After releasing this rootfs,

1. I realized I've missed one package that needs to be installed in order to make fw_printenv and fw_setenv available (these binaries have been moved to package libubootenv-tool in bullseye) . So do this if you want to list or set envs in Debian.
apt-get install libubootenv-tool


>
> Anyway once u-boot was installed everything became
> very familiar as I worked with raspberry pis a
> lot. The only truly complicated part was indeed
> getting u-boot on the device.
>
> Thank you so much for breathing new life into
> these old devices.

Cool!

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
PeterR
Re: Debian and U-boot on NSA325
October 22, 2022 10:35AM
Just a question here, the note on step 8. of the instruction says:
"if you can't set up your configuration to satisfy the following 4 requirements, then don't flash this defaut envs image"

Since the NSA325 has 2 x partitions for rootfs and 2 x partitions for kernel.

Q: Did you flash the default envs image?
Re: Debian and U-boot on NSA325
October 23, 2022 12:29AM
PeterR,

> Since the NSA325 has 2 x partitions for rootfs and
> 2 x partitions for kernel.
>

That's stock FW, and has nothing to do with fashing new u-boot. The partitions refered to in the instruction are disk drive partitions, where we store Debian rootfs and kernel files.

The new u-boot is installed in the first NAND flash mtd0 partition, and the default envs for new u-boot are also in mtd0.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: