FAQ repost, and putting FreeBSD 11 on a raspberry pi

32 views
Skip to first unread message

Big Bad Bob

unread,
Dec 14, 2016, 5:49:12 PM12/14/16
to
It's been a while. I'll start with my obgligatory hack (aka 'ObHack')
as all posts made to this newsgroup MUST have an actual hack in them.

[this is actually several hacks]

Putting FreeBSD 11 on a Raspberry Pi
====================================

The first thing you'll need to do is boot up a Linux or FreeBSD machine
and download the correct image. FBSD has 2 SD card images, both of
which will expand out to fill the SD card on first bootup. These are:

for the model 1 'B':

ftp://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/11.0/FreeBSD-11.0-RELEASE-arm-armv6-RPI-B.img.xz

for the model 2 (and later?):

ftp://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/11.0/FreeBSD-11.0-RELEASE-arm-armv6-RPI2.img.xz

note: you might want to visit freebsd.org and pick a different mirror
site before downloading.
See https://www.freebsd.org/releases/11.0R/announce.html for more


Then, on a linux or FreeBSD machine, attach an SD card to the computer
(typically via a USB adaptor).

You'll see multiple device entries show up when you attach the SD card,
such as:

/dev/ad4
/dev/ad4s1
(possibly more entries, etc. - similar for Linux)

The one you'll want to use is the one with the shortest name, in this
case '/dev/ad4'. The image will contain partition information, and you
need to overwrite the device's partition information with the
information in the image.

Typically, you'll discover which device is the SD card, and use a
command similar to the following (assuming /dev/ad4 is correct)

dd if=imagefile.img of=/dev/ad4 bs=1M

(the 'bs=1M' makes the process go a bit faster, assuming 1M block sizes,
but it will still take a while, as writing to SD cards is notoriously
slow by comparison)


At this point you'll have an SD card with a bootable image on it. You
can test this image and customize it by installing it on a raspberry pi
and booting it up.

If you run it 'headless' like I did, the network name depends on the
image. As I recall, it's "RPi2" and "RPi-B", respectively. You can
then ssh in, and user/pass is raspberry/raspberry . Then edit config
files to your mind's content.


more detail here:
https://wiki.freebsd.org/FreeBSD/arm/Raspberry%20Pi
https://www.freebsdfoundation.org/freebsd/how-to-guides/installing-freebsd-for-raspberry-pi/
http://www.raspbsd.org/index.html


now here is where it becomes more of a hack...


It's difficult to know when the system has safely shut down without a
serial console [or a monitor attached]. For a headless system, like
your typical micro-controlled "thingy" might have, you'll need to be
able to do this without corrupting the SD card.

There ARE external boards available to assist you with shutting down the
RPi safely.

In order to support boards like THIS:
https://lowpowerlab.com/guide/atxraspi/

you'll need to reset the GPIO pins on shutdown, so it can detect you
shut down. This is the behavior that Raspian Linux has, incidentally,
so why FreeBSD is different might be to give too much 'favor' to certain
code committers who insist they need it for "their particular hardware"
to leave the I/O pins alone on shutdown (i.e. leave outputs as outputs
in whatever state they were in). THAT should be a kernel option, in my
opinion.

Anyway, you can build the kernel source on a FreeBSD 11 machine. Don't
do it on the pi because it will take too long. You CAN use a virtualbox
VM [I did] if you want. Here's how I did it:

a) obtain kernel source via subversion using the method outlined in the
FreeBSD handbook http://freebsd.org/handbook

https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/svn.html

(you can use svn.freebsd.org/base/release/11.0.1
or svn.freebsd.org/base/stable/11 )

You should check it out into /usr/src

After this, you can set up cross-compiling [let it run for a few hours]
by doing this (as root):


setenv TARGET arm
setenv TARGET_ARCH armv6
make -j 4 buildworld

then

make -j 4 buildkernel KERNCONF=RPI-B
or
make -j 4 buildkernel KERNCONF=RPI2

depending on the kernel you want. Following this you can mount the
image file (image file copied from the SD card using 'dd' after booting
and 'safely' shutting down) from within FreeBSD 11 like this:

mdconfig -a -t vnode -f imagefile.img

this will create a memory device /dev/md# (probably md0; the device
name is spat out on the console after being created). Then, mount it
like this:

mount -t ufs /dev/md0s2a /mnt

this will mount the UFS partition 'md0s2a' onto /mnt .


Then, with the '.img' file mounted on /mnt

make installkernel KERNCONF=RPI-B DESTDIR=/mnt
or
make installkernel KERNCONF=RPI2 DESTDIR=/mnt

then

make installworld DESTDIR=/mnt

mergemaster -i -F -U -A arm -D /mnt

[note: mergemaster is a little tricky, but you'll want to inspect all
of the changes most likely. just follow the prompts, you'll catch on]

Finally, unmount the file as follows:

umount /mnt

and delete the memory device

mdconfig -d -u 0

This detaches the file, and you can NOW use 'dd' to re-write it back to
the SD card with the new kernel [and matching 'world'].

NOW, if you want to patch the kernel, extract the patch file from the
following bug report:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211979

then apply it (from the /usr/src directory) like this:

patch -p0 <patchfile.patch (where 'patchfile.patch' is the patch file)

then, build the kernel and install, as before.


If you've managed to do all of this stuff on your own, you understand
why this is really 'a hack' and qualifies as an ObHack.


[hopefully I didn't make any mistake]


AND NOW... the FAQ re-post [for those who forgot]

-----------

PUBLIC SERVICE RE-POST BY ONE OF THOSE WHO REMEMBER!
( original post by "Hippykill" <mik...@nospam.digex.net> 27 Feb 1998
23:32:10 GMT )

NOTE: some (or maybe all) of the links may no longer function... sorry.

The UNOFFICIAL
Alt.hackers FREQUENTLY ASKED QUESTIONS file
Last updated 3/27/1997, formatting cleaned up 11/02/2001

TABLE OF CONTENTS

A. ADMINISTRIVIA
1) What is this document?
2) Where can I find another copy of it?
3) Who the hell are you and why are you posting this?
4) Isn't there already a FAQ for this group?

B. IMPORTANT QUESTIONS
1) What is alt.hackers for?
2) What is a hacker?
3) Why can't I post to this group?
4) What is an Obhack, and why do I need one?
5) Where can I get more information on hacking and hackers?
6) But where do I find the k-rad 3l1t3 hacks, d00d?

A. ADMINISTRIVIA

1) What is this document?

This document answers the Frequently Asked Questions (FAQ) on the
Usenet newsgroup alt.hackers. This is an unofficial FAQ--there is an
official one that is available on the World Wide Web (see below).
This document is not covered by any copyright whatsoever--feel free
to copy it, distribute it freely, change it, or sell it for dollars.

2) Where can I find another copy of it?

Most FAQs are available for anonymous ftp from the archive site

ftp://rtfm.mit.edu

I have made it available at my personal website. Here is a URL that
should get you a copy:

http://www.access.digex.net/~mikelea/hackfaq.txt

3) Who the hell are you and why are you posting this?

My name is Michael Lea, and I'm posting this because no one else is.
There is an official FAQ that is available on the web and is
supposedly posted every two weeks to the group--however, I haven't
seen it posted in a long time, so I wrote this unofficial FAQ.

4) Isn't there already a FAQ for this group?

Yes. It is available on the Web at the following URL:

http://www.fullfeed.com/~gregc/alt-hackers-faq.html

There is also an official maintainer of the official FAQ, who mailed
me a slight flame about my posting of my unofficial FAQ, but I lost
his address. I'd like to continue posting this document, because I
never see the official FAQ posted to the group. If anyone has serious
problems with me posting this, mail me at mik...@access.digex.net.

B. IMPORTANT QUESTIONS

1) What is alt.hackers for?

Alt.hackers is a forum for hackers to discuss (i.e. brag about)
current, past, and future projects. It is also a place to ask for
help in your current projects, _not_ including your homework!
The only limitation to this discussion is that it should relate in
some way to hacking (see next question) and include a
description of a hack you've done (see the discussion of
Obhacks, further down).

2) What is a hacker?

Good question. A hacker is someone who hacks. What is hacking?
Well, there is a definition of hack in the Jargon File/New Hacker's
Dictionary that tries to cover it. The Jargon File is an awesome
resource for anyone interested in computers, so you should go read it.
Here's the URL:

HTTP://www.ccil.org/jargon/jargon.html

In short, hacking is about using available technology in a creative
way to solve a problem. It can be a stupid problem and an ugly
solution, as long as it is a new and creative solution. Hacking
extends to all forms of technology, not just computers--using the
thighbone of an antelope to bash in the head of another antelope was
an excellent hack. Now that I've given a short definition of what
hacking is, I can try and tell you what isn't a hack. Hacking is not
about breaking things. It isn't about denial of service attacks or
pirated software or deleting or stealing other people's data. If you
are interested in doing any of these things, alt.hackers is going to
bore you. Try the alt.2600.* hierarchy if you're looking for that
sort of conversation. And call yourself a cracker, not a hacker.

3) Why can't I post to this group?

Because we don't want you here <grin>. Actually, alt.hackers is a
moderated group, so you'll have to figure out how to get around the
moderator to post here. No, I'm not the moderator and you're not
going to find out who is. It is a trivial hack to post here, so you're
going to look really stupid if you mail me or anyone else on the group
asking how to do it. Figure it out for yourself! One caveat:
Please don't post a million test messages to the group. Use
alt.dev.null for testing purposes. It is set up just like
alt.hackers, and you won't look stupid if you post a million test
messages there. If you can post to alt.dev.null but can't post to
alt.hackers, tell your newsadmin that alt.dev.null is set up wrong on
your machines. Thanks to Andrew Gierth <and...@erlenstar.demon.co.uk>
for the current status of alt.dev.null!

4) What is an Obhack, and why do I need one?

Obhack is short for Obligatory Hack. Every post in alt.hackers is
required to include some sort of discussion of hacking, so most
people put an Obhack on the end of their message to meet this
requirement. If you don't include a hack with your message, you are
going to look really stupid and you're going to get a lot of email
telling you that you need to have one. Do you really want all the
other hackers who read the group to think that you are too stupid
to come up with a hack? BTW, posting to the group is not considered
to be a hack. You will be flamed if you try to use that as your
Obhack.

5) Where can I get more information on hacking and hackers?

As noted above, the Jargon File/New Hacker's Dictionary is an
excellent source. For information on the Internet, check out the
RFC's. These are the documents that describe every protocol and
most of the services available on the Internet. David Cary
<ca...@agora.rdrop.com> was nice enough to mail me some URLs that
point to sources of the RFCs:

[begin quote from David Cary]

Index to RFCs
http://www.cis.ohio-state.edu/hypertext/information/rfc.html

Some more RFCs
ftp://ftp.ietf.org/internet-drafts/

You can ftp to:
ftp://nic.ddn.mil/rfc

or you could get it off the web at:
http://www.cis.ohio-state.edu/htbin/rfc/rfc-index.html

http://ds.internic.net/ds/rfc-index.html
"gives access to all published RFC's."

[end quote]

And Daniel Brown <d...@eskimo.com> was nice enough to mail me
this info:

[begin quote from Daniel Brown]

Check out the hacking-related documentation on Eric Raymond's FAQ
collection (http://www.ccil.org/~esr/faqs/index.html).
"How To Become A Hacker" and "A Brief History of Hackerdom" are
articles which you should take a look at.

[end quote]


6) But where do I find the k-rad 3l1t3 hacks, d00d?

A lot of people have mailed me looking for information on breaking
into computers and other security issues. Remember, if you break
something on purpose, you're not a hacker.
If you are looking for information on "the computer underground" and
aren't really interested in intelligent conversation, alt.2600.* is
for you. If you really are interested in computer security issues
and think that you are smart enough to understand these issues, you
should check out:

http://www.l0pht.com
http://underground.org
comp.security.misc
comp.security.unix
Also, check out the Jargon File:
http://locke.ccil.org/jargon/index.html
and look up the entries for "hacker" and "cracker" and then look at
the sections on "Helping Hacker Culture Grow" and "Crackers, Phreaks,
and Lamers".
(thanks to Phil Edwards <pedw...@cs.wright.edu> for help with this
answer)
--
*mik...@access.digex.net* "imperious, angry, furious, extreme in
all things, with a disturbance in the moral imagination unlike any
the world has ever known-there you have me in a nutshell: and one
more thing, kill me or take me as I am, because I will not
change." - de Sade
Reply all
Reply to author
Forward
0 new messages