Debian Lenny on the NSA-220

Marvell Orion based
KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Mon Aug 08, 2011 2:01 pm

Here is another tip who took me a while to sort out so maybe it will help someone.

Since Midnight Commander (MC) is a must have for me it was the first thing installed. It worked as it should and was still usefull but with thoose wierd "frame characters" in the terminal.

After confirming that my terminal was set to Linux and UTF-8 but still not working. Lots of googling turned out that to fix it I have to install locale, so doing that with...

Code: Select all

apt-get install locale
and set "en_US.UTF-8" solved the issue for me.

/KC

KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Tue Aug 09, 2011 1:29 pm

Found a great source for newbie reading about Linux in general...

http://tldp.org/index.html

/KC

KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Tue Aug 09, 2011 3:36 pm

Thanks to the help from Mizjelf I managed to update the Kernel to a newer version and learned a bit more! Without him I would be totally lost among the bits & bytes in the Linux world - He's Da Man ;)

Will continue and see if I can get smartmontools working later and report back if anyone is interested?

/KC

KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Thu Aug 11, 2011 1:00 pm

After the kermel upgrade smartmontools works, only tried smartctl so far but it looks good :)

smartctl -a -d marvell /dev/sda

Code: Select all

smartctl version 5.38 [armv5tel-unknown-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

=== START OF INFORMATION SECTION ===
Device Model:     WDC WD10EADS-00L5B1
Serial Number:    WD-WCAU4D151439
Firmware Version: 01.01A01
User Capacity:    1,000,204,886,016 bytes
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   8
ATA Standard is:  Exact ATA specification draft version not indicated
Local Time is:    Tue Aug 10 17:33:05 2011 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
...
/KC

KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Thu Aug 11, 2011 5:35 pm

Anyone got any tips for a lightweight intrusion detection software? I've read up a bit about snort and it seems to be very capable and a bit overkill for me. Wondered if there was something else? I'm looking to add another security layer to my WiFi AP and would be great if NSA-220 could take care of that as well.

In short, I'm looking for something basic like AirSnare but for Linux.

http://home.comcast.net/~jay.deboer/airsnare/index.html

/KC

KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Sat Aug 13, 2011 3:53 pm

Anyone ever used the serial port on NSA-220+? Is it accessable on the PCB?

Code: Select all

serial8250: ttyS0 at MMIO 0x0 (irq = 3) is a 16550A
Edit: Right after posting I found this so I guess it's time to build a 3V3<>RS-232 interface ;)

viewtopic.php?f=131&t=21

/KC

KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Thu Aug 18, 2011 9:49 pm

Can the serial port (ttyS0) be used as a general I/O when it's configured as a serial console or must I disable that first?

I have the cable connected and I can login and also see syslog messages on ttyS0 but I can not figure out how to get bi-directional coms using minicom... Tried to find where to edit the kernel line but I can only find reference to "console=ttyS0,115200n8" in the binary file "reloaded-2.6.18.6.ko", is it harcoded?

/KC

Mijzelf
Posts: 6224
Joined: Mon Jun 16, 2008 10:45 am

Re: Debian Lenny on the NSA-220

Post by Mijzelf » Fri Aug 19, 2011 8:12 pm

No, it's not hardcoded. It's overruled by the cmdline= in the reload script.

Having said that, I don't know if the serial port will be freed when using another cmdline. Don't know what you want to do with it, but maybe an USB-to-serial convertor could help?

KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Fri Aug 19, 2011 10:02 pm

So if I understand correcty adding the line below to reload.sh would override default and make the consol output to tty0 instead (which will never bee seen since there is no monitor) or maybe it would add tty0 as a second consol output?

Code: Select all

...
echo Generate commandline...
# in case you want to boot from the usbstick
CMDLINE="root=${USBDEVICE} rw"
# in case you want to boot from an raidarray
# CMDLINE="root=/dev/md1 rw md=1,/dev/sdc2,/dev/sdd2"
# in case your rootfs in in a subdirectory
# CMDLINE="${CMDLINE} rootdir=subdir"

# >>>>>>>  New line below <<<<<<<<<
CMDLINE="${CMDLINE} console=tty0"

# Parse the firmware commandline
...
According to information here the console parameter can be given repeatedly.

http://tldp.org/HOWTO/Remote-Serial-Con ... NEL-SYNTAX

What I want to do in the end is to use the ttyS0 serial port to communicate with a PIC microcontroller but at the moment I just hooked it up to a laptop running a terminal program for testing.

A USB-to-serial convertor could be an option but it would be great to be able to use the one already built in.

/KC

Mijzelf
Posts: 6224
Joined: Mon Jun 16, 2008 10:45 am

Re: Debian Lenny on the NSA-220

Post by Mijzelf » Sat Aug 20, 2011 7:49 am

KeyCat wrote:So if I understand correcty adding the line below to reload.sh would override default and make the consol output to tty0 instead (which will never bee seen since there is no monitor) or maybe it would add tty0 as a second consol output?
I don't know. I never tried it. I don't think a second console output will be opened (it's a bit overdone to write an output duplicator for low-level logging). But maybe tty0 doesn't exist, and will the kernel end with a kernel panic. It could be better to just strip the console= line.
Anyway, you'll have to strip the current console param. In the script reload.sh the firmware commandline is parsed, and copied partly. Here you can add a line to strip the console line:

Code: Select all

# Parse the firmware commandline
for cmd in `cat /proc/cmdline`; do
    case ${cmd} in
	root=*)
	    ;;
	rootfstype=*)
	    # Who cares? It's autodetected anyway
	    ;;
	ro)
	    ;;
	init=*)
	    CMDLINE="${CMDLINE} init=/sbin/init"
	    ;;
	console=*)
	    ;;
	*)
	    CMDLINE="${CMDLINE} ${cmd}"
	    ;;
    esac
done
Another thing, the (userland) bootlog will still be directed to ttyS0. And /etc/inittab will open a shell or a getty on it. The latter can be edited, the first needs a change in the initrd, which is an cpio archive, which mounts the USB stick, and passes execution.
It's init now ends with:

Code: Select all

cd ${ROOTDIR}
exec switch_root -c /dev/ttyS0 . ${INIT} 

KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Sat Aug 20, 2011 8:20 am

Thank you! I will image the USB stick and read up on "cpio" then give it a go later.

/KC

KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Sun Aug 21, 2011 2:37 pm

A bit stuck (again)...

I managed to unpack initramfs (sym linked from initrd) using gzip -d and then cpio -i and edit the line in file "init" but how can I re-assemble a new cpio archive again with all files and directories correctly?

init now looks like below...

Code: Select all

...
# do the real action
cd ${ROOTDIR}
exec switch_root -c /dev/tty0 . ${INIT}
...
Also, looking in initab the lines that open a getty on ttyS0 is already commented out. Should I also remove the last line that creates the shell? I assume yes if "S0::.." refers to ttyS0?

Code: Select all

...
# Start a shell on the console
S0::respawn:/bin/sh
/KC

Mijzelf
Posts: 6224
Joined: Mon Jun 16, 2008 10:45 am

Re: Debian Lenny on the NSA-220

Post by Mijzelf » Sun Aug 21, 2011 5:54 pm

KeyCat wrote:how can I re-assemble a new cpio archive

Code: Select all

cd directory_containing_initramfs
su
find . | cpio -H newc -o > /tmp/initramfs.cpio
cd ..
cat /tmp/initramfs.cpio | gzip > myinitramfs
KeyCat wrote:Should I also remove the last line that creates the shell? I assume yes if "S0::.." refers to ttyS0?
Yes and yes.

KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Tue Aug 23, 2011 6:51 am

Thanks for your help Mijzelf! Now the serial port is free for general I/O use after boot.

It's still used as console in the beginning of the boot process until it gets the new "console=tty" at the end but thats OK since I can work around that in the MCU (or at least I hope so).

/KC

KeyCat
Posts: 70
Joined: Tue Apr 05, 2011 8:07 am

Re: Debian Lenny on the NSA-220

Post by KeyCat » Sat Oct 08, 2011 10:02 am

Below is a better config for lm-sensors. To set min/max values you must enter "sensors -s" once.

Edit or paste to "/etc/sensors3.conf" under the following section...

Code: Select all

...
#
# Sample configuration for the Intel S845WD1-E
# courtesy of Marcus Schopen 
#
chip "lm85c-*" "adm1027-*" "adt7463-*" "lm85-*" "lm85b-*"

################################################################################
#  NSA-220+
################################################################################
#
# Sample configuration for Zyxel NSA-220+
#
# Voltage inputs
   label in1   "VCore"
   label in2   "V3.3"
   label in3   "V5"
   label in4   "V12"

# Temperature inputs
   label temp1  "CPU Temp"
   label temp2  "Board Temp"
   label temp3  "Case Temp"

# Fan inputs
   label fan1   "Case Fan"

# Ignore sensors inputs NSA-220+ don't have
   ignore in0
   ignore cpu0_vid
   ignore fan2
   ignore fan3
   ignore fan4

# If needed adjust fans speeds for actual pulses per rev
#
# Examples
#   compute fan1  @ * 2,  @ / 2    # 1 pulse per rev
#   compute fan1  @ / 2,  @ * 2    # 4 pulse per rev

# Define min/max limits, must use "sensors -s" for new
# values to be active.
#
# Set voltage limits +/- 5%
   set in1_min  1.20 * 0.95
   set in1_max  1.20 * 1.05
   set in2_min  3.3 * 0.95
   set in2_max  3.3 * 1.05
   set in3_min  5.0 * 0.95
   set in3_max  5.0 * 1.05
   set in4_min   12 * 0.95
   set in4_max   12 * 1.05

# Set Fan limits
   set fan1_min 500

# Set Temp Limits
   set temp1_min 10
   set temp1_max 50
   set temp2_min 10
   set temp2_max 50
   set temp3_min 10
   set temp3_max 35
With this console output looks a bit cleaner and easier to read...

Code: Select all

VCore:       +1.19 V  (min =  +1.14 V, max =  +1.27 V)
V3.3:        +3.31 V  (min =  +3.13 V, max =  +3.47 V)
V5:          +5.09 V  (min =  +4.74 V, max =  +5.26 V)
V12:        +12.08 V  (min = +11.38 V, max = +12.62 V)
Case Fan:    970 RPM  (min =  500 RPM)
CPU Temp:    +37.2°C  (low  = +10.0°C, high = +50.0°C)  
Board Temp:  +36.2°C  (low  = +10.0°C, high = +50.0°C)  
Case Temp:   +26.0°C  (low  = +10.0°C, high = +35.0°C)  
I don't know if/how the alarm function works but will post if I figure it out.

/KC

Post Reply