summaryrefslogtreecommitdiffstats
path: root/electronics/soekris.page
blob: 2daf6432cc88659a9bdbf770745d7014a2d9c498 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489

# Soekris net6051 Notes

http://soekris.com/products/net6501.html

Intel 82574L gigabit ethernet controller

Firmware updates: http://soekris.com/downloads.html

Boot drives:

0x80 = primary drive
0x81 = secondary drive
0x82 = tertiary drive
0x83 = quaternary drive
0x84 = quinary drive (etc.)
0xF0 = PXE boot (netboot)
0xFF = stop and go to comBIOS prompt

1. SATA Port 0 (J1)
2. SATA Port 1 (J2)
3. PCI Express connector (J3)
4. PCI Express riser (J4)
5. mSATA 0 socket (J5)
6. mSATA 1 socket (J6)
7. external USB connector (JP3)
8. internal USB connector (JP5)

Ethernet chipset is Intel 82574L, using e1000e driver on linux (not e1000).

miniPCIe WiFi card I have is the Intel 4965AGN.

Kernel needs ext2 and SATA ACHI (?) support at boot time to load root
filesystem.

### OpenWRT installation

http://wiki.openwrt.org/doku.php?id=oldwiki:soekrisport is out of date. Use 
http://wiki.openwrt.org/toh/pcengines/alix

Eg,

    dd if=openwrt-x86-generic-combined-ext2.img of=/dev/sdc

Then, use gparted to create another ext2 partition using unused space, and copy
over openwrt and pfSense images there.

Change /boot/menu.lst to include: 

    title   OpenWrt - Stick
    root    (hd1,0)
    kernel  /boot/vmlinuz root=/dev/sdb2 rootfstype=ext2 rootwait console=tty0 console=ttyS0,38400n8 noinitrd reboot=bios
    boot

[doesn't actually work...]

scx200: NatSemi SCx200 Driver                                                   
microcode: CPU0 sig=0x20661, pf=0x2, revision=0x104                             
Microcode Update Driver: v2.00 <tigran@aivazian.fsnet.co.uk>, Peter Oruba       
------------[ cut here ]------------                                            
WARNING: at arch/x86/mm/ioremap.c:148 0xc10199d8()                              
Modules linked in:                                                              
Pid: 1, comm: swapper Not tainted 2.6.32.27 #1                                  
Call Trace:                                                                     
 [<c10199d8>] ? 0xc10199d8                                                      
 [<c102271f>] ? 0xc102271f                                                      
 [<c10199d8>] ? 0xc10199d8                                                      
 [<c1022763>] ? 0xc1022763                                                      


Need to recompile a full image custom image a la:
http://superuser.com/questions/357401/how-to-install-openwrt-on-an-x86-computer-with-sata-hard-drive

http://www.syslinux.org/wiki/index.php/SYSLINUX#SERIAL_port_.5B.5Bbaudrate.5D_flowcontrol.5D

[this part does work]

temporary re-install instructions for soekris device:

boot up in debian
    scp openwrt-x86-generic-rootfs.tar.gz openwrt-x86-generic-vmlinuz <debian>
    mount /dev/sda4 /mnt
    cd /mnt
    tar xvf ~/openwrt-x86-generic-rootfs.tar.gz .
    cp ~/openwrt-x86-generic-vmlinuz /mnt/boot/vmlinuz # CAREFUL!
    cd
    umount /mnt

after boot up openwrt, for basic network config, edit /etc/config/network:

# Copyright (C) 2006 OpenWrt.org

config interface loopback
        option ifname   lo
        option proto    static
        option ipaddr   127.0.0.1
        option netmask  255.0.0.0

config interface wan
        option ifname   eth0
        option proto    dhcp

config interface lan
        option ifname   eth1
        option type     bridge
        option proto    static
        option ipaddr   192.168.5.1
        option netmask  255.255.255.0

edit /etc/resolve.conf and add 8.8.8.8 (google) (or, just start dnsmasq?)

edit /etc/opkg.conf, change fetch patch to x86_generic (not x86)

then scp over all built .ipkgs, install build-essential (which means gcc, make,
binutils, patch, diffutils).

Add /usr/local/bin to PATH:

    #.profile: PATH=$PATH:/usr/local/bin; export PATH
    source ~/.profile

copy crap over:
    scp ./staging_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.30.1/lib/uclibc_nonshared.a root@192.168.5.1:
    mv ~/uclibc_nonshared.a /usr/lib/

##### Recompiling openwrt kernel for LXC support

To enable gcc et al in OpenWRT backfire:
    http://www.pacificsimplicity.ca/comment/24#comment-24

Kernel flags (also network setup):
    http://lxc.teegra.net/#_configuration_options
    http://en.gentoo-wiki.com/wiki/LXC#Kernel_with_the_appropriate_LXC_options_enabled

LXC userspace tools:
    http://lxc.sourceforge.net/download/lxc/

So... this is all with backfire 10.03.1, kernel 2.6.32 or so

in menuconfig, disable binary stripping (under global build settings).

save and do:
    $ ./scripts/feeds install -d m build-essential

back in menuconfig, select devel/build-essentials as built-in (so don't need to
do package install).

enable AHCI SATA support in kernel menu

ended up just appending in kernel flags from above link to x86 kernel
configuration file.

if you get errors making, try going single threaded.

may need to apply this patch: 
    https://dev.openwrt.org/ticket/8646
    (apply to ./toolchain/gcc/patches/4.1.2/300-libstdc++-pic.patch)

### Recompiling OpenWRT Attitude Adjustment for Soekris net6501 w/LXC

make sure packages actually get updated and installed correctly

disable stripping

enable a bunch of stuff in menuconfig, including SATA support

select gcc 4.7 (not some random "linaro 4.6" crap)

if compiling build-essentials, might need:


    bnewbold@ziggy:~/code/openwrt_trunk$ cat /home/bnewbold/code/openwrt_trunk/toolchain/gcc/patches/4.7.0/209-automake-bullshit.patch
    --- a/config/override.m4
    +++ b/config/override.m4
    @@ -29,7 +29,7 @@
    
    dnl Ensure exactly this Autoconf version is used
    m4_ifndef([_GCC_AUTOCONF_VERSION],
    -  [m4_define([_GCC_AUTOCONF_VERSION], [2.64])])
    +  [m4_define([_GCC_AUTOCONF_VERSION], [2.68])])
    
    dnl Test for the exact version when AC_INIT is expanded.
    dnl This allows to update the tree in steps (for testing)

### Debian

http://wiki.soekris.info/Installing_Debian_Linux_5.0

on syslinux device, edit txt.cfg:

    default install
    label install
        menu label ^Install
        menu default
        kernel linux
        append vga=normal initrd=initrd.gz -- quiet console=ttyS0,38400 earlyprint=serial,ttyS0,38400

to enable pfsense as a boot option:

    menuentry 'pfsense' {
            set root='(hd0,0)'
            chainloader +1
    }

    menuentry 'openwrt' {
        set root='(hd0,3)'
        kernel /boot/vmlinuz root=/dev/sda4 rootfstype=ext2 init=/etc/preinit rootwait console=tty0 console=ttyS0,38400n8 noinitrd reboot=bios
    }


### pfSense [DID NOT WORK]

Install to flash stick with:

    dd if=pfSense-memstick-2.0.1-RELEASE-i386.img of=/dev/sdc

Plug in stick, boot up through comBIOS, then change console to 9600 8N1. Try to
boot from default. You should get through most of the kernel load, then get to
a mount error and console. DON'T press return or it will try to configure;
enter "?" then return to list devices. I saw only one device (ad4?) and
mounted that with ufs, then had a second mount error come up and did
ufs:ufs/pfsense0 (or was it pfsense1?). This finally worked and I went through
some business with LAN/WAN port configuration and finally was good to go.

When booting from disk:

    Setting up embedded specific environment... done.
    ad4: TIMEOUT - READ_MUL retrying (1 retry left) LBA=788719
    ad4: TIMEOUT - READ_MUL retrying (0 retries left) LBA=788719
    ad4: FAILURE - READ_MUL timed out LBA=788719
    g_vfs_done():ufs/pfsense0[READ(offset=403783680, length=18944)]error = 5
    vnode_pager_getpages: I/O read error
    /etc/rc: /usr/sbin/pwd_mkdb: Input/output error

### pfSense

forum thread on getting linux stuff working: http://www.digipedia.pl/usenet/thread/13078/936/

use random memstick-serial image found on the internet; dd it to USB stick and
boot. don't go to installer mode, continue to livecd then SSH in to get a
much better interface.

go through the install, partition with at least one extra linux partition (to
run the VM in), use the "embeded" kernel when that option comes up.

in base install, get packages like:

env PACKAGESITE=ftp://ftp6.jp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.1-release/Latest/ pkg_add -r screen

or, eg: 
    
    pkg_add -r http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/i386/8.1-RELEASE/packages/Latest/ezjail.tbz

but we need to use developer edition (FreeBSD 8.3 when written), so do an
upgrade through the web UI to the developer snapshot.

install some random packages (PACKAGESITE trick no longer necessary)

    http://forum.pfsense.org/index.php/topic,25331.5/wap2.html

[DON'T DO THIS PART]

    copy over lin*.ko from a FreeBSD .iso to /boot/kernel/

    add to /boot/loader.conf.local:

        verbose_loading="YES"
        linux_load="YES"
        linprocfs_load="YES"
        linux_enable="YES"
[/DON'T DO THIS PART]

copy over all the libraries required for sysinstall from FreeBSD 8.3 .iso (try
ldd /usr/sbin/sysinstall to get a list):

    scp libdialog* libncurses* libutil* libftpio* libdevinfo* root@192.168.1.1:/usr/lib/
    scp sysinstall root@192.168.1.1:sysinstall8

run sysinstall. do options and set "Release Name    8.3-RELEASE" (not -p3).
install system source (/src/sys) and ports collection.

then install base, though this could break everything (?)

go to /usr/src/sys/modules. for each of the following, enter and make && make install: 

    linux
    linprocfs
    fdescfs
    linsysfs
    tmpfs
    ext2fs

Things didn't work after a reboot. As a recovery, I grabbed the pfsense trunk
repository and copied over all the files in /etc/ and /boot/ which were
DIFFERENT between that and the FreeBSD-base install.

Unfortunately, I seem to have acquired the READ_MUL problem again, blech. This
did get me to boot. I had to override the DNS info (add 8.8.8.8 to
/etc/resolv.conf), but was then able to invoke an auto-update through the web
interface.

note: on this hardware, booting from soekris, takes about a minute to boot.
could shave 10-15 seconds optimizing comBIOS and selection menu, but can
freebsd boot be enhanced?

### Debian/kFreeBSD Inside

http://blog.vx.sk/archives/22-Tutorial-Debian-GNUkFreeBSD-in-a-FreeBSD-jail.html

http://phaq.phunsites.net/2007/01/06/debian-gnukfreebsd-inside-native-freebsd-jail/


### Install pfSense on Soekris

Grab a "memstick-serial" image, flash it to a USB stick:

    http://snapshots.pfsense.org/FreeBSD_RELENG_8_3/i386/pfSense_HEAD/livecd_installer/?C=M;O=D
    $ dd if=pfSense-memstick-serial-2.1-DEVELOPMENT-i386-20120720-0129.img of=/dev/sdb

Boot with serial console set to 38400 baud, select USB stick device. Eg,

    > boot 81

Switch to 9600 baud. Terminal output will be clunky/garbled, wait for it to try
to draw, maybe press enter a couple times. When kernel actually loads output
will be clearer.

After kernel loads, system will ask if you want to do install or boot.
Recommend that you boot, with basic configuration, then enable SSH and do
install over a network shell as ncurses will be much cleaner.

Hopefully install is self-explanitory. I created a 4GB "low-level"/slice
partition for pfSense (which got split into a 3GB partition and a 1GB swap
partition), a 16GB Linux/ext2 kFreeBSD partition (didn't create filesystem
yet), and the rest of the space as another Linux/ext2 partition.

I selected embedded kernel.

### Install kFreeBSD in pfSense

First, we'll upgrade the pfSense install to include the full FreeBSD userspace.

Use a 2.1 development image (based on FreeBSD 8.3), but not the most recent
one. Login to the web console and enable SSH access.

scp over sysinstall and required libraries from a FreeBSD 8.3 LiveCD. From this
point on DO NOT reboot until the end. 

Copy over all the libraries required for sysinstall from FreeBSD 8.3 .iso (try
ldd /usr/sbin/sysinstall to get a list):

    scp libdialog* libncurses* libutil* libftpio* libdevinfo* root@192.168.1.1:/usr/lib/
    scp sysinstall root@192.168.1.1:sysinstall8

Run sysinstall. do options and set "Release Name    8.3-RELEASE" (not -p3).
Install base, ports collection, and system kernel source (/src/sys).

Use the pfSense webconsole to upgrade to the most recent development image.

Now, reboot and hope everything comes back up with no disk errors.

Go to /usr/src/sys/modules. for each of the following, enter and make && make install: 

    linux
    linprocfs
    fdescfs
    linsysfs
    tmpfs
    ext2fs

Use sysintall to install the full "base" system and kernel sources.

Compile and install necessary kernel modules.

pkg_add -r any desired packages. Maybe also a linux_base?

    pkg_add -r linux_base-f10

Inspect /boot/loader.conf and make sure it's sane?

Reboot again and hope everything comes back up with no disk errors.  If it
does, ready for jail steps.

create a linux ext2 filesystem: 

    pkg_add -r e2fsprogs
    mke2fs /dev/ad6s2
    mount -t ext2fs /dev/ad6s2 /jail/debian/

FINALLY, following directions, do:
http://blog.vx.sk/archives/22-Tutorial-Debian-GNUkFreeBSD-in-a-FreeBSD-jail.html

    mkdir -p /jail/debian
    debootstrap wheezy /jail/debian http://cdn.debian.net/debian

    [2.1-BETA0][root@rooter0.rooter.is]/usr/src/sys/modules/tmpfs(42): jexec 1 /bin/bash
    root@debian0:/# uname -a
    GNU/kFreeBSD debian0.rooter.is 8.3-RELEASE-p3 FreeBSD 8.3-RELEASE-p3 #1: Wed Jul 18 19:29:09 EDT 2012     root@FreeBSD_8.3_pfSense_2.1.snaps.pfsense.org:/usr/obj./usr/pfSensesrc/src/sys/pfSense_wrap.8.i386 i386 i386 Genuine Intel(R) CPU        @ 1.00GHz GNU/kFreeBSD

Alright, after all that, some more config...

Add the iperf and pfJailCtl packages.

Add rc.conf.debian to /root/:

    jail_enable="YES"
    jail_list="debian"
    jail_debian_rootdir="/jail/debian"
    jail_debian_hostname="guest0.rooter.is"
    jail_debian_ip="127.0.0.1"
    jail_debian_devfs_enable="YES"
    jail_debian_exec_start="/etc/init.d/rc 3"
    jail_debian_flags="-l -u root"

Add start_debian.sh to /root/:

    #/bin/sh
    kldload linux fdescfs linprocfs linsysfs tmpfs
    mount -t ext2fs /dev/ad6s2 /jail/debian/
    mount -t linprocfs linprocfs /jail/debian/proc
    mount -t linsysfs linsysfs /jail/debian/sys
    mount -t tmpfs tmpfs /jail/debian/lib/init/rw
    ifconfig em1 alias 192.168.1.201/32
    cp /root/rc.conf.debian /etc/rc.conf
    /etc/rc.d/jail start debian
    jls

### More config

To allow ping inside kFreeBSD, add "security.jail.allow_raw_sockets=1" to
/etc/sysctl.conf.

### PROBLEMS/EXTRA?

http://wiki.freebsd.org/Jails

Jul 22 18:00:02  syslogd: /var/log/ppp.log: Operation not suppe

If you want to use shared memory in Linux applications, you need to set up
a link from /dev/shm to a suitable place, e.g. by adding the following line
to /etc/devfs.conf (takes effect on each boot):
        link /tmp shm

To make use of NIS you have to adjust yp.conf and nsswitch.conf in
/compat/linux/etc/ accordingly. For example:

Set your yp-server and yp-domainname in yp.conf:
        domainname      my.yp.domainname
        ypserver        my.yp.server

Let your lists for hosts, passwd and group be resolved via nsswitch.conf:
        passwd: files nis
        shadow: files nis
        group:  files nis
        hosts:  files dns nis

WARNING: doing work which needs to chroot into the linux base may not work.
In such cases (e.g. cross-development) you are better suited with a linux_dist
port.

# Links

http://www.macfreek.nl/memory/FreeBSD_9_on_Soekris_net6501

http://blog.vx.sk/archives/22-Tutorial-Debian-GNUkFreeBSD-in-a-FreeBSD-jail.html

"m0n0deb" and how monowall got small:
    http://www.docunext.com/blog/2007/07/m0n0deb.html

### LXC package notes

edited package/lxc/Makefile

did package update/install on just lxc

### ERRORS (for reference)

gcc wanted GMP?

i486-openwrt-linux-uclibc-gcc -DHAVE_CONFIG_H -I. -I../../src   -I/home/bnewbold/code/openwrt_trunk/staging_dir/target-i386_uClibc-0.9.33.2/usr/include -I/home/bnewbold/code/openwrt_trunk/staging_dir/target-i386_uClibc-0.9.33.2/include -I/home/bnewbold/code/openwrt_trunk/staging_dir/toolchain-i386_gcc-4.7.0_uClibc-0.9.33.2/usr/include -I/home/bnewbold/code/openwrt_trunk/staging_dir/toolchain-i386_gcc-4.7.0_uClibc-0.9.33.2/include  -fPIC -DPIC -I../../src -O2 -pipe -march=i486 -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -MT liblxc_so-utmp.o -MD -MP -MF .deps/liblxc_so-utmp.Tpo -c -o liblxc_so-utmp.o `test -f 'utmp.c' || echo './'`utmp.c
utmp.c:41:19: fatal error: utmpx.h: No such file or directory
compilation terminated.


======
attr makefile and patch
lxc makefile
install perl, file, vim
debootstrap --arch=i386 wheezy /lxc/debian/ http://ftp.us.debian.org/debian