From e2973e8ea5c57bfa6ed41293e0250c68d29cfed9 Mon Sep 17 00:00:00 2001 From: ficus Date: Sat, 22 Sep 2012 18:07:42 +0200 Subject: backup WIP --- freedom-maker/README | 418 --------------------- freedom-maker/README.freedom-maker | 418 +++++++++++++++++++++ freedom-maker/TODO.freedom-maker | 25 ++ freedom-maker/bin/finalize | 8 +- freedom-maker/bin/packages | 35 ++ freedom-maker/bin/packages-chroot | 4 + freedom-maker/buildrootfs.sh | 122 ++++++ freedom-maker/copy2card.sh | 43 +++ freedom-maker/copy2img.sh | 23 ++ freedom-maker/mk_dreamplug_rootfs | 1 + .../multistrap-configs/torouter-armel.conf | 14 + .../multistrap-configs/torouter-base.conf | 29 ++ freedom-maker/source/etc/init.d/first-run | 6 +- freedom-maker/source/install.sh | 3 +- ...3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.apt-key | Bin 0 -> 3742 bytes 15 files changed, 723 insertions(+), 426 deletions(-) delete mode 100644 freedom-maker/README create mode 100644 freedom-maker/README.freedom-maker create mode 100644 freedom-maker/TODO.freedom-maker create mode 100755 freedom-maker/bin/packages create mode 100755 freedom-maker/bin/packages-chroot create mode 100755 freedom-maker/buildrootfs.sh create mode 100755 freedom-maker/copy2card.sh create mode 100755 freedom-maker/copy2img.sh create mode 100644 freedom-maker/multistrap-configs/torouter-armel.conf create mode 100644 freedom-maker/multistrap-configs/torouter-base.conf create mode 100644 freedom-maker/source/tmp/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.apt-key (limited to 'freedom-maker') diff --git a/freedom-maker/README b/freedom-maker/README deleted file mode 100644 index 6039861..0000000 --- a/freedom-maker/README +++ /dev/null @@ -1,418 +0,0 @@ -Freedom-Maker - Bdale's building tools for the FreedomBox project - -Welcome to the FreedomBox! This project is the central hub of the FreedomBox -project, it builds and installs the file-system image that turns any computer -into a FreedomBox. - -There are a couple ways to use this system: - -1. If you just want to use a FreedomBox and don't care about changing how it - works or mucking about in its insides (if you're like most people), you - should get a pre-built image from someone and copy it to an SD card or USB - drive. If you don't have a JTAG or don't know what one is, make sure to ask - for the SD card image. - -2. If you want to change and build on it, you can use: - - A. A USB stick. This requires a JTAG, but doesn't require opening up the - DreamPlug, or, - - B. A microSD card and adapter. You can use the one from inside the - DreamPlug. You won't need a JTAG, but you will need to open the DreamPlug - and void the warranty. - -*** -*** Warning! There are no "training wheels" here .. read the scripts and -*** understand what they're going to do before you run them... -*** - -# Recent Firmware Necessary! - -Modern kernels need a relatively recent version of the u-boot firmware. If -you still use old firmware (including what Global Scale ships on the units by -default), then you need to update, which requires having the JTAG dongle (to -gain console serial port access). One way to know you've got old firmware -is if booting a Linux kernel results in errors about corrupt gzip data and -a failure to launch the kernel. - -Note that re-flashing firmware will erase all configuration variables. If -preserving your exising boot config is important, use printenv and make notes -before proceeding. Also note that any time you're re-flashing boot firmware, -there is a slight chance you could 'brick' your device leaving it unbootable. -If that happens, the JTAG interface can be used to recover. - -The instructions for updating firmaware go something like this (thanks to -Ian Campbell for his notes): - - Using 2012.04.01-2 which is current Wheezy. Prep by mounting a USB stick. - - wget http://http.debian.net/debian/pool/main/u/u-boot/u-boot_2012.04.01-2_armel.deb - dpkg-deb -x u-boot_2012.04.01-2_armel.deb u-boot_2012.04.01-2_armel - cp u-boot_2012.04.01-2_armel/usr/lib/u-boot/dreamplug/* /media/usbdisk - - Move the USB stick to your DreamPlug. Flash the new firmare: - - usb start - fatload usb 2 0x6400000 u-boot.kwb - sf probe 0 - sf erase 0x0 0x80000 - sf write 0x6400000 0x0 0x${filesize} - - (You must, of course, fill in the size of the file you're loading in hex) - -At this point, you should be able to reset the DreamPlug and have it boot to -a serial console prompt. If that fails, you'll need real JTAG magic to try -again. - -Note that if you use the 'make usb' target to create a bootable USB stick -image, we include the required firmware in /boot/dreamplug, so the above -fatload command might be replaced with: - - fatload usb 2 0x6400000 dreamplug/u-boot.kwb - -# To Use It - -You'll need to copy the image to the memory card or USB stick: - -1. Figure out which device your card actually is. - - A. Unplug your card. - - B. Run "df" to show you the list of devices your computer actually knows - about. - - C. Plug your card in. - - D. Run "df" again, your computer should know about a new device or two: your - memory card. It's probably "/dev/sd(someletter)". It *won't be* - /dev/sda. - -2. Decompress the image: - - $ tar -xjvf freedombox-unstable_*.tar.bz2 - -3. Copy the image to your card. Whatever you do, make sure you don't copy it to - /dev/sda. That'll break your system. - - # dd bs=1M if=freedombox-unstable_*.img of=/dev/sd(thesameletter) - - When picking a device, use the drive-letter destination, like /dev/sdb, not a - numbered destination, like /dev/sdb1. The device-without-a-number refers to - the entire device, while the device-with-a-number refers to a specific - partition. We want to use the whole device. - -Now, what you need to do depends on whether you're using the microSD card or USB -stick method: - -- USB drive: You'll hook the JTAG up to the DreamPlug before booting and use the - JTAG to control the boot process, so we can boot from the USB drive. - -- microSD card: You'll put the microSD card into the DreamPlug's internal - microSD card slot and boot the DreamPlug. It'll restart once to finish the - install process, then it's ready to use. - -## Running from a microSD Card - -When DD has finished, take the microSD card out of your computer and plug it -into your DreamPlug. If you have a JTAG, you can watch it boot. You'll see it -restart once during the boot process. If you don't have a JTAG, wait a while (5 -minutes or less) and it'll be available over SSH (port 22). You might need to -use nmap to find it: - - $ nmap -p 22 --open -sV 192.168.0.0/24 - - ... - Interesting ports on 192.168.0.13: - PORT STATE SERVICE VERSION - 22/tcp open ssh OpenSSH 6.0p1 Debian 2 (protocol 2.0) - Service Info: OS: Linux - ... - -Once you've found it, SSH into the box: - - $ ssh root@192.168.0.13 - -## Running from a USB Stick - -Move the USB stick to the DreamPlug, obtain a serial console, and hit reset. A -good way to access the serial console (actually USB serial emulation provided by -the optional JTAG dongle), is to use 'screen', like so: - - screen /dev/ttyUSB0 115200 - -Interrupt the boot by pressing a key during the autoboot countdown, and type the -following to boot from the USB stick: - - setenv bootcmd '${x_bootcmd_usb}; ${x_bootcmd_kernel}; ${x_bootcmd_initrd}; setenv bootargs ${x_bootargs} ${x_bootargs_root}; bootm 0x6400000 0x6900000;' - setenv x_bootcmd_kernel fatload usb 2 0x6400000 uImage - setenv x_bootcmd_initrd fatload usb 2 0x6900000 uInitrd - setenv x_bootargs_root root=/dev/sdc2 rootdelay=10 - boot - -The system should boot to a login prompt, using only the bits on the stick. - -The default root password is 'freedom'. The normal user is "fbx" and the -password is "frdm". - -- - - - - - -To set things up to boot from the internal microSD card, once you're logged into -the system booted from root on USB stick you can use: - - /sbin/copy2dream - -Note that if you don't have a reasonable system date and time set in the -DreamPlug before running this command, you may see a long stream of warnings -from tar about timestamps being in the future. It is safe to ignore these. - -On reboot, you may want to interrupt the boot and type the following to ensure -you boot from the internal microSD by default. This bootcmd line elides the -time-consuming attempts to boot grom gigE, which makes boot go much faster: - - setenv bootcmd '${x_bootcmd_usb}; ${x_bootcmd_kernel}; ${x_bootcmd_initrd}; setenv bootargs ${x_bootargs} ${x_bootargs_root}; bootm 0x6400000 0x6900000;' - setenv x_bootcmd_kernel fatload usb 0 0x6400000 uImage - setenv x_bootcmd_initrd fatload usb 0 0x6900000 uInitrd - setenv x_bootargs_root root=/dev/sda2 rootdelay=10 - saveenv - reset - -# To Make It - -If you want to build your own image yourself, you're more than welcome to. -Whether you're using a USB drive or a microSD card, you'll need to ensure that -it's at least 2 GB in size and that it has two partitons: - -1. The stick must start with a 128 MB FAT partition for the boot directory. - -2. The rest of the stick is an EXT2 partition, for the main installation. - -The rest of the steps you need to follow depend on whether you're using a USB -stick or a microSD card. - -## Building on a USB Stick - -Partition a USB stick to have a small FAT partition and large ext2 partition, -create a /media/freedom mount point, and add entries to /etc/fstab like: - - /dev/sdb1 /media/freedom/boot vfat user,noauto 0 0 - /dev/sdb2 /media/freedom ext2 user,noauto 0 0 - -This will allow the Makefile to mount and unmount the stick at will. - -If you have a favorite Debian mirror, update the file fbx-base.conf setting the -source= line. - -To populate the stick with bits for a DreamPlug, just plug it in to your -computer and type: - - make - -This will build a file tree under build/dreamplug, representing the contents of -a root file system, then that content will be copied to the stick. - -## Building it on a microSD card. - -Changing the image and building your own is a simple 18 step process! Lots of -thanks to Nick Hardiman for putting these instructions together. - -### Get Ready - -1. Start your workstation. - -2. Use a Debian OS, the version doesn't matter. A virtual image, such - as a VirtualBox image, is fine. Usually. - -3. Use the root account. - -### Prepare an SD Card - -4. Find a microSD card with SD card holder. It must be at least 2GB - in size. - -5. Insert the card into your workstation. - -6. Install a partition editor. Install parted if you are a masochist. - - # apt-get install parted - -7. Create 2 partitions. Use cfdisk, parted, gparted or similar. - - # cfdisk /dev/sdb - - a. First partition: 128meg (no smaller or the kernel copy will run - out of room and make - see below - will end with an error). - - b. Second partition: The rest of the card (anything over 600 MB - should work). - -8. Make a note of the SD card’s device name. Mine is /dev/sdb (my - workstation’s layout is simple: one disk called /dev/sda and - nothing else defined). - -9. Format the two partitions. - - a. First partition: FAT - - # mkdosfs /dev/sdb1 - - b. Second partition: ext3 - - # mkfs.ext3 /dev/sdb2 - -10. Create the mountpoints on your workstation. - - # mkdir -p /media/freedom/boot - -11. Mount the second partition. - - # mount /dev/sdb2 /media/freedom/ - -12. Mount the first partition. - - # mount /dev/sdb1 /media/freedom/boot/ - -13. Check your work. - - # mount - - sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) - ... - /dev/sdb2 on /media/freedom type ext3 - (rw,relatime,errors=continue,barrier=1,data=ordered) - /dev/sdb1 on /media/freedom/boot type vfat - (rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=remount-ro) - -### Clone the Git Repository - -14. Install git. - - # apt-get install git - - Reading package lists... Done - ... - After this operation, 15.3 MB of additional disk space will be used. - Do you want to continue [Y/n]? - ... - -15. Clone Nick Daly’s repository. - - $ git clone https://github.com/NickDaly/freedom-maker.git - - Cloning into 'freedom-maker'... - - -### Create the Debian OS. - -16. Change to the new directory. - - $ cd ~/freedom-maker/ - -17. Kick off: - - $ make weekly-card - -18. Enter your password when asked by "sudo". If that fails, run: - - $ su -c "make weekly-card" - -If you do that, you'll need to enter the root password to build the image. - -The next part took about an hour, but required no input from me. Packages were -downloaded. Lots of commands were run. Many harmless errors were ignored: - - sysvinit: restarting...init: timeout opening/writing control channel /run/initctl - .init: timeout opening/writing control channel /run/initctl - ... - -There was good news: - - Multistrap system installed successfully... - Copying the source directory to the FreedomBox root. - -There was an enormous amount of this: - - bin/bash - 818092 100% 7.07MB/s 0:00:00 (xfer#1, to-check=1102/1123) - bin/cat - 42736 100% 362.91kB/s 0:00:00 (xfer#2, to-check=1101/1123) - bin/chgrp - 54996 100% 383.62kB/s 0:00:00 (xfer#3, to-check=1100/1123) - ... - -Finally an image is copied and zipped up for redistribution: - - dd if=/dev/sdb of="freedombox-unstable_`date +%Y.%m%d`.img" bs=1M - 3781+1 records in - 3781+1 records out - 3965190144 bytes (4.0 GB) copied, 266.174 s, 14.9 MB/s - Image copied. The microSD card may now be removed. - tar -cjvf "freedombox-unstable_`date +%Y.%m%d`.tar.bz2" - "freedombox-unstable_`date +%Y.%m%d`.img" - freedombox-unstable_2012.0705.img - -The end. Hooray! The SD card is ready for the DreamPlug. - -# To Understand It - -Be aware that this is a *very* imcomplete solution for now, suitable only -for developers .. you will want to at least do things like create unique -ssh host keys for your device! - -Digging into the code should be fairly straightforward. There are only six -files you need to be aware of: - -- /Makefile: The makefile that describes and builds the system. -- /mk_dreamplug_rootfs: Builds the DreamPlug's root file-system. -- /bin/projects: The place for external projects to hook into and customize - themselves before they're copied to the image. -- /bin/finalize: Finalizes and prepares the build for booting. -- /source: The root file system. -- /source/install.sh: Pre-boot configuration that needs to be run on the device - itself (from within a chroot). - -## Makefile - -There are three major targets to be aware of: - -- dreamstick: The default target. This loads an image to a USB drive that can - be used to install the FreedomBox without opening up your DreamPlug and - voiding the warranty. You'll need a JTAG, though. -- weekly-card: The target used to produce the weekly FreedomBox test release. - This will copy the image to a card that can be popped directly into the - microSD card slot in the DreamPlug. The DreamPlug will boot happily without - needing a JTAG. -- stamp-dreamplug-rootfs: The root file system itself. It doesn't get installed - anywhere (that's done by the other two targets), but is a good way to test - whether the image will actually build, without waiting for all that pesky - hardware I/O. - -## mk_dreamplug_rootfs - -Starts building the system by creating all the destination directories and -installing the base system. - -## /bin/projects - -Where projects that want to integrate into the FreedomBox should hook into. -Keep in mind, we aren't in a chroot at this point. The only environment -variables you'll probably need are: - -- user: The non-root user's name (uid = 1000). -- homedir: The non-root user's home-directory. - -## /bin/finalize - -Getting the system ready for boot, doing the things that don't need to be done -inside a chroot. You probably don't need to change this. - -## /source - -The root file system on the DreamPlug. Modify this, and you're modifying what -ends up on the FreedomBox. - -## /source/install.sh - -This is executed from a chroot during the build process to do configuration that -needs to be done on the device itself. You shouldn't need to modify this. If -you're installing a project that needs to change how the system configures -itself, you're probably doing something wrong. diff --git a/freedom-maker/README.freedom-maker b/freedom-maker/README.freedom-maker new file mode 100644 index 0000000..6039861 --- /dev/null +++ b/freedom-maker/README.freedom-maker @@ -0,0 +1,418 @@ +Freedom-Maker - Bdale's building tools for the FreedomBox project + +Welcome to the FreedomBox! This project is the central hub of the FreedomBox +project, it builds and installs the file-system image that turns any computer +into a FreedomBox. + +There are a couple ways to use this system: + +1. If you just want to use a FreedomBox and don't care about changing how it + works or mucking about in its insides (if you're like most people), you + should get a pre-built image from someone and copy it to an SD card or USB + drive. If you don't have a JTAG or don't know what one is, make sure to ask + for the SD card image. + +2. If you want to change and build on it, you can use: + + A. A USB stick. This requires a JTAG, but doesn't require opening up the + DreamPlug, or, + + B. A microSD card and adapter. You can use the one from inside the + DreamPlug. You won't need a JTAG, but you will need to open the DreamPlug + and void the warranty. + +*** +*** Warning! There are no "training wheels" here .. read the scripts and +*** understand what they're going to do before you run them... +*** + +# Recent Firmware Necessary! + +Modern kernels need a relatively recent version of the u-boot firmware. If +you still use old firmware (including what Global Scale ships on the units by +default), then you need to update, which requires having the JTAG dongle (to +gain console serial port access). One way to know you've got old firmware +is if booting a Linux kernel results in errors about corrupt gzip data and +a failure to launch the kernel. + +Note that re-flashing firmware will erase all configuration variables. If +preserving your exising boot config is important, use printenv and make notes +before proceeding. Also note that any time you're re-flashing boot firmware, +there is a slight chance you could 'brick' your device leaving it unbootable. +If that happens, the JTAG interface can be used to recover. + +The instructions for updating firmaware go something like this (thanks to +Ian Campbell for his notes): + + Using 2012.04.01-2 which is current Wheezy. Prep by mounting a USB stick. + + wget http://http.debian.net/debian/pool/main/u/u-boot/u-boot_2012.04.01-2_armel.deb + dpkg-deb -x u-boot_2012.04.01-2_armel.deb u-boot_2012.04.01-2_armel + cp u-boot_2012.04.01-2_armel/usr/lib/u-boot/dreamplug/* /media/usbdisk + + Move the USB stick to your DreamPlug. Flash the new firmare: + + usb start + fatload usb 2 0x6400000 u-boot.kwb + sf probe 0 + sf erase 0x0 0x80000 + sf write 0x6400000 0x0 0x${filesize} + + (You must, of course, fill in the size of the file you're loading in hex) + +At this point, you should be able to reset the DreamPlug and have it boot to +a serial console prompt. If that fails, you'll need real JTAG magic to try +again. + +Note that if you use the 'make usb' target to create a bootable USB stick +image, we include the required firmware in /boot/dreamplug, so the above +fatload command might be replaced with: + + fatload usb 2 0x6400000 dreamplug/u-boot.kwb + +# To Use It + +You'll need to copy the image to the memory card or USB stick: + +1. Figure out which device your card actually is. + + A. Unplug your card. + + B. Run "df" to show you the list of devices your computer actually knows + about. + + C. Plug your card in. + + D. Run "df" again, your computer should know about a new device or two: your + memory card. It's probably "/dev/sd(someletter)". It *won't be* + /dev/sda. + +2. Decompress the image: + + $ tar -xjvf freedombox-unstable_*.tar.bz2 + +3. Copy the image to your card. Whatever you do, make sure you don't copy it to + /dev/sda. That'll break your system. + + # dd bs=1M if=freedombox-unstable_*.img of=/dev/sd(thesameletter) + + When picking a device, use the drive-letter destination, like /dev/sdb, not a + numbered destination, like /dev/sdb1. The device-without-a-number refers to + the entire device, while the device-with-a-number refers to a specific + partition. We want to use the whole device. + +Now, what you need to do depends on whether you're using the microSD card or USB +stick method: + +- USB drive: You'll hook the JTAG up to the DreamPlug before booting and use the + JTAG to control the boot process, so we can boot from the USB drive. + +- microSD card: You'll put the microSD card into the DreamPlug's internal + microSD card slot and boot the DreamPlug. It'll restart once to finish the + install process, then it's ready to use. + +## Running from a microSD Card + +When DD has finished, take the microSD card out of your computer and plug it +into your DreamPlug. If you have a JTAG, you can watch it boot. You'll see it +restart once during the boot process. If you don't have a JTAG, wait a while (5 +minutes or less) and it'll be available over SSH (port 22). You might need to +use nmap to find it: + + $ nmap -p 22 --open -sV 192.168.0.0/24 + + ... + Interesting ports on 192.168.0.13: + PORT STATE SERVICE VERSION + 22/tcp open ssh OpenSSH 6.0p1 Debian 2 (protocol 2.0) + Service Info: OS: Linux + ... + +Once you've found it, SSH into the box: + + $ ssh root@192.168.0.13 + +## Running from a USB Stick + +Move the USB stick to the DreamPlug, obtain a serial console, and hit reset. A +good way to access the serial console (actually USB serial emulation provided by +the optional JTAG dongle), is to use 'screen', like so: + + screen /dev/ttyUSB0 115200 + +Interrupt the boot by pressing a key during the autoboot countdown, and type the +following to boot from the USB stick: + + setenv bootcmd '${x_bootcmd_usb}; ${x_bootcmd_kernel}; ${x_bootcmd_initrd}; setenv bootargs ${x_bootargs} ${x_bootargs_root}; bootm 0x6400000 0x6900000;' + setenv x_bootcmd_kernel fatload usb 2 0x6400000 uImage + setenv x_bootcmd_initrd fatload usb 2 0x6900000 uInitrd + setenv x_bootargs_root root=/dev/sdc2 rootdelay=10 + boot + +The system should boot to a login prompt, using only the bits on the stick. + +The default root password is 'freedom'. The normal user is "fbx" and the +password is "frdm". + +- - - - - + +To set things up to boot from the internal microSD card, once you're logged into +the system booted from root on USB stick you can use: + + /sbin/copy2dream + +Note that if you don't have a reasonable system date and time set in the +DreamPlug before running this command, you may see a long stream of warnings +from tar about timestamps being in the future. It is safe to ignore these. + +On reboot, you may want to interrupt the boot and type the following to ensure +you boot from the internal microSD by default. This bootcmd line elides the +time-consuming attempts to boot grom gigE, which makes boot go much faster: + + setenv bootcmd '${x_bootcmd_usb}; ${x_bootcmd_kernel}; ${x_bootcmd_initrd}; setenv bootargs ${x_bootargs} ${x_bootargs_root}; bootm 0x6400000 0x6900000;' + setenv x_bootcmd_kernel fatload usb 0 0x6400000 uImage + setenv x_bootcmd_initrd fatload usb 0 0x6900000 uInitrd + setenv x_bootargs_root root=/dev/sda2 rootdelay=10 + saveenv + reset + +# To Make It + +If you want to build your own image yourself, you're more than welcome to. +Whether you're using a USB drive or a microSD card, you'll need to ensure that +it's at least 2 GB in size and that it has two partitons: + +1. The stick must start with a 128 MB FAT partition for the boot directory. + +2. The rest of the stick is an EXT2 partition, for the main installation. + +The rest of the steps you need to follow depend on whether you're using a USB +stick or a microSD card. + +## Building on a USB Stick + +Partition a USB stick to have a small FAT partition and large ext2 partition, +create a /media/freedom mount point, and add entries to /etc/fstab like: + + /dev/sdb1 /media/freedom/boot vfat user,noauto 0 0 + /dev/sdb2 /media/freedom ext2 user,noauto 0 0 + +This will allow the Makefile to mount and unmount the stick at will. + +If you have a favorite Debian mirror, update the file fbx-base.conf setting the +source= line. + +To populate the stick with bits for a DreamPlug, just plug it in to your +computer and type: + + make + +This will build a file tree under build/dreamplug, representing the contents of +a root file system, then that content will be copied to the stick. + +## Building it on a microSD card. + +Changing the image and building your own is a simple 18 step process! Lots of +thanks to Nick Hardiman for putting these instructions together. + +### Get Ready + +1. Start your workstation. + +2. Use a Debian OS, the version doesn't matter. A virtual image, such + as a VirtualBox image, is fine. Usually. + +3. Use the root account. + +### Prepare an SD Card + +4. Find a microSD card with SD card holder. It must be at least 2GB + in size. + +5. Insert the card into your workstation. + +6. Install a partition editor. Install parted if you are a masochist. + + # apt-get install parted + +7. Create 2 partitions. Use cfdisk, parted, gparted or similar. + + # cfdisk /dev/sdb + + a. First partition: 128meg (no smaller or the kernel copy will run + out of room and make - see below - will end with an error). + + b. Second partition: The rest of the card (anything over 600 MB + should work). + +8. Make a note of the SD card’s device name. Mine is /dev/sdb (my + workstation’s layout is simple: one disk called /dev/sda and + nothing else defined). + +9. Format the two partitions. + + a. First partition: FAT + + # mkdosfs /dev/sdb1 + + b. Second partition: ext3 + + # mkfs.ext3 /dev/sdb2 + +10. Create the mountpoints on your workstation. + + # mkdir -p /media/freedom/boot + +11. Mount the second partition. + + # mount /dev/sdb2 /media/freedom/ + +12. Mount the first partition. + + # mount /dev/sdb1 /media/freedom/boot/ + +13. Check your work. + + # mount + + sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) + ... + /dev/sdb2 on /media/freedom type ext3 + (rw,relatime,errors=continue,barrier=1,data=ordered) + /dev/sdb1 on /media/freedom/boot type vfat + (rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=utf8,shortname=mixed,errors=remount-ro) + +### Clone the Git Repository + +14. Install git. + + # apt-get install git + + Reading package lists... Done + ... + After this operation, 15.3 MB of additional disk space will be used. + Do you want to continue [Y/n]? + ... + +15. Clone Nick Daly’s repository. + + $ git clone https://github.com/NickDaly/freedom-maker.git + + Cloning into 'freedom-maker'... + + +### Create the Debian OS. + +16. Change to the new directory. + + $ cd ~/freedom-maker/ + +17. Kick off: + + $ make weekly-card + +18. Enter your password when asked by "sudo". If that fails, run: + + $ su -c "make weekly-card" + +If you do that, you'll need to enter the root password to build the image. + +The next part took about an hour, but required no input from me. Packages were +downloaded. Lots of commands were run. Many harmless errors were ignored: + + sysvinit: restarting...init: timeout opening/writing control channel /run/initctl + .init: timeout opening/writing control channel /run/initctl + ... + +There was good news: + + Multistrap system installed successfully... + Copying the source directory to the FreedomBox root. + +There was an enormous amount of this: + + bin/bash + 818092 100% 7.07MB/s 0:00:00 (xfer#1, to-check=1102/1123) + bin/cat + 42736 100% 362.91kB/s 0:00:00 (xfer#2, to-check=1101/1123) + bin/chgrp + 54996 100% 383.62kB/s 0:00:00 (xfer#3, to-check=1100/1123) + ... + +Finally an image is copied and zipped up for redistribution: + + dd if=/dev/sdb of="freedombox-unstable_`date +%Y.%m%d`.img" bs=1M + 3781+1 records in + 3781+1 records out + 3965190144 bytes (4.0 GB) copied, 266.174 s, 14.9 MB/s + Image copied. The microSD card may now be removed. + tar -cjvf "freedombox-unstable_`date +%Y.%m%d`.tar.bz2" + "freedombox-unstable_`date +%Y.%m%d`.img" + freedombox-unstable_2012.0705.img + +The end. Hooray! The SD card is ready for the DreamPlug. + +# To Understand It + +Be aware that this is a *very* imcomplete solution for now, suitable only +for developers .. you will want to at least do things like create unique +ssh host keys for your device! + +Digging into the code should be fairly straightforward. There are only six +files you need to be aware of: + +- /Makefile: The makefile that describes and builds the system. +- /mk_dreamplug_rootfs: Builds the DreamPlug's root file-system. +- /bin/projects: The place for external projects to hook into and customize + themselves before they're copied to the image. +- /bin/finalize: Finalizes and prepares the build for booting. +- /source: The root file system. +- /source/install.sh: Pre-boot configuration that needs to be run on the device + itself (from within a chroot). + +## Makefile + +There are three major targets to be aware of: + +- dreamstick: The default target. This loads an image to a USB drive that can + be used to install the FreedomBox without opening up your DreamPlug and + voiding the warranty. You'll need a JTAG, though. +- weekly-card: The target used to produce the weekly FreedomBox test release. + This will copy the image to a card that can be popped directly into the + microSD card slot in the DreamPlug. The DreamPlug will boot happily without + needing a JTAG. +- stamp-dreamplug-rootfs: The root file system itself. It doesn't get installed + anywhere (that's done by the other two targets), but is a good way to test + whether the image will actually build, without waiting for all that pesky + hardware I/O. + +## mk_dreamplug_rootfs + +Starts building the system by creating all the destination directories and +installing the base system. + +## /bin/projects + +Where projects that want to integrate into the FreedomBox should hook into. +Keep in mind, we aren't in a chroot at this point. The only environment +variables you'll probably need are: + +- user: The non-root user's name (uid = 1000). +- homedir: The non-root user's home-directory. + +## /bin/finalize + +Getting the system ready for boot, doing the things that don't need to be done +inside a chroot. You probably don't need to change this. + +## /source + +The root file system on the DreamPlug. Modify this, and you're modifying what +ends up on the FreedomBox. + +## /source/install.sh + +This is executed from a chroot during the build process to do configuration that +needs to be done on the device itself. You shouldn't need to modify this. If +you're installing a project that needs to change how the system configures +itself, you're probably doing something wrong. diff --git a/freedom-maker/TODO.freedom-maker b/freedom-maker/TODO.freedom-maker new file mode 100644 index 0000000..184aca5 --- /dev/null +++ b/freedom-maker/TODO.freedom-maker @@ -0,0 +1,25 @@ +- [ ] initial boot configuration improvements, as there are a few + things we really do want to defer to first boot, or at least make it + trivial to fix up per-system + + - [X] ssh host keys + - [ ] root password +- [ ] add Sheeva as a build target +- [X] add x86 virtualized as a build target (use vmdebootstrap?) +- [ ] investigate and integrate software components that looks interesting + - channel-server, the buddycloud channels service for XMPP + - babeld, loop-free distance-vector routing protocol + - tahoe-lafs, secure distributed filesystem +- [ ] virtualbox should build with dreamplug configuration + +*** stuff to do for first feature release *** + + - [ ] pre-configured user interface + - [X] DHCP and HTTP servers on eth0 and/or eth1 + - [ ] plinth-based initial config interface + + - [ ] freedom buddy installed + - [ ] openvpn server setup + - [ ] the privoxy fork configured as a transparent proxy + - [ ] plinth configured to at display these config details and to + control whatever is feasible diff --git a/freedom-maker/bin/finalize b/freedom-maker/bin/finalize index 9995b77..a6cb7da 100755 --- a/freedom-maker/bin/finalize +++ b/freedom-maker/bin/finalize @@ -49,8 +49,8 @@ echo $hostname > $target/etc/hostname chown root:root $target/sbin/copy2dream chmod 744 $target/sbin/copy2dream -# prepare chroot project finalization -cp bin/projects-chroot $target/ +# prepare chroot package finalization +cp bin/packages-chroot $target/ echo "Using qemu-user-static to perform first-boot configuration now." chmod 755 $target/install.sh @@ -58,8 +58,8 @@ cp /usr/bin/qemu-arm-static $target/usr/bin echo "Running install script from source/install.sh" chroot $target /install.sh echo "Running install script from bin/projects-chroot" -chroot $target /projects-chroot +chroot $target /packages-chroot # clean up. -rm "${target}/projects-chroot" +rm "${target}/packages-chroot" rm "${target}/usr/bin/qemu-arm-static" diff --git a/freedom-maker/bin/packages b/freedom-maker/bin/packages new file mode 100755 index 0000000..15d17a4 --- /dev/null +++ b/freedom-maker/bin/packages @@ -0,0 +1,35 @@ +#! /bin/bash +# +# Copyright 2012 by Nick Daly +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# projects +# +# Installs external projects to the system. + + +# We don't tolerate errors. +set -e + +echo "Adding extra torouter stuff..." +mkdir -p $homedir/uap_hack +cp -v $basedir/../../uap_hack/* $homedir/uap_hack +mkdir -p $homedir/src +git clone $basedir/../.. $homedir/src/torouter +mkdir -p $target/tmp/dpkg +cp -v $basedir/../../packages/packages-for-upload/*.deb $target/tmp/dpkg + +chown -R 1000:1000 $homedir diff --git a/freedom-maker/bin/packages-chroot b/freedom-maker/bin/packages-chroot new file mode 100755 index 0000000..42020c4 --- /dev/null +++ b/freedom-maker/bin/packages-chroot @@ -0,0 +1,4 @@ +#! /bin/sh + +dpkg -i /tmp/dpkg/*.deb + diff --git a/freedom-maker/buildrootfs.sh b/freedom-maker/buildrootfs.sh new file mode 100755 index 0000000..856f49f --- /dev/null +++ b/freedom-maker/buildrootfs.sh @@ -0,0 +1,122 @@ +#!/bin/bash +# +# Copyright 2011 by Bdale Garbee +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# based on work by , who released his script under +# the following license terms: +# ---------------------------------------------------------------------------- +# "THE BEER-WARE LICENSE" (Revision 42): +# As long as you retain this notice you can do whatever you want with +# this stuff. If we meet some day, and you think this stuff is worth it, +# you can buy me a beer in return. +# ---------------------------------------------------------------------------- + +# mk_dreamplug_rootfs +# +# Runs multistrap and readies the resulting root filesystem to silently +# complete package configuration on the first boot-up. +# +# Accepts the multistrap config file name as an argument. + +# We don't tolerate errors. +set -e + +architecture=armel +if [ -n "$1" ] +then + architecture=$1 +fi + +config=multistrap-configs/torouter-$architecture.conf +if [ -n "$2" ] +then + config=$2 +fi + +# users +hostname='torouter' +rootpassword='freedom' +user='torouter' +userpassword='freedom' +export hostname +export rootpassword +export user +export userpassword + +# where to build images, etc +basedir=`pwd`/build +source=`pwd`/source +target=$basedir/$architecture +tmpdir=$basedir/tmp +pkgcache=$tmpdir/aptcache +homedir=$target/home/$user +export basedir +export source +export target +export tmpdir +export pkgcache +export homedir + +# clear any old cruft +if (mount | grep $target/var/cache/apt) +then + umount $target/var/cache/apt/ +fi + +# make the directories we'll need. +mkdir -p $target +rm -rf $target/* +mkdir -p $tmpdir +mkdir -p $pkgcache +mkdir -p $target/var/cache/apt/ && mount -o bind $pkgcache $target/var/cache/apt/ +mkdir -p $target/var/cache/apt/archives +mkdir -p $target/usr/bin +mkdir -p $homedir + +echo "Multistrapping..." +# XXX: DEATH: work around torrouter.torproject.org GPG key issue +# XXX: see also auth=false in multistrap config files +# multistrap -f $config -d $target +multistrap --no-auth -f $config -d $target +rm -f $target/etc/apt/sources.list.d/multistrap-debian.list + +# un-do the bind mount so we don't trip over it later +umount $target/var/cache/apt/ + +# copy! +echo "Copying the source directory to the torouter rootfs..." +rsync -av $source/ $target + +# add extra packages to the image +bin/packages + +# torouter! +echo "Explicitly copying some torouter files..." +# TODO: these should be redundant +# Override the above stuff - we know better +cp ../packages/torouter-prep/configs/interfaces $target/etc/network/interfaces +# Stop the libertas module from loading +cp ../packages/torouter-prep/configs/modprobe.d-blacklist.conf $target/etc/modprobe.d/blacklist.conf + +# cleanup and finalize the image so it boots correctly. +echo "Finalizing..." +bin/finalize + +# finish! +echo "Syncing..." +sync +echo "Finished. You may now copy the rootfs to the plug." diff --git a/freedom-maker/copy2card.sh b/freedom-maker/copy2card.sh new file mode 100755 index 0000000..0a5208d --- /dev/null +++ b/freedom-maker/copy2card.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +set -e + +if [ -n "`mount | grep 'mnt'`" ] +then + echo "/mnt mount point is in use?" + exit 1 +fi + +if ! [ -b "$1" ] +then + echo "need to specify a target boot partition (/dev/sdb1)" + exit 1 +else + BOOTDEV=$1 +fi + +if ! [ -b "$2" ] +then + echo "need to specify a target root partition (/dev/sdb2)" + exit 1 +else + ROOTDEV=$2 +fi + +echo "mounting rootdev..." +mount $ROOTDEV /mnt +echo "rsyncing over rootfs" +rsync -atv --progress --delete --exclude=boot build/armel/ /mnt/ +echo "sync filesystems..." +sync +echo "un-mounting rootdev..." +umount /mnt + +echo "mounting bootdev..." +mount $BOOTDEV /mnt +echo "copying boot files..." +cp -v build/armel/boot/* /mnt +echo "sync filesystems..." +sync +echo "un-mounting bootdev..." +umount /mnt diff --git a/freedom-maker/copy2img.sh b/freedom-maker/copy2img.sh new file mode 100755 index 0000000..c11b0a6 --- /dev/null +++ b/freedom-maker/copy2img.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +if [ -b "$1" ] +then + DEV=$1 +else + echo "need to specify a card device (eg, /dev/sdb)" + exit 1 +fi + +NAME="torouter-dev" +if [ -n "$2" ] +then + NAME=$2 +fi + +echo "dd-ing $DEV to $NAME.img" +dd if=$DEV of=$NAME.img bs=1M +echo "gzip compressing image" +gzip $NAME.img + diff --git a/freedom-maker/mk_dreamplug_rootfs b/freedom-maker/mk_dreamplug_rootfs index bc75855..0c452e4 100755 --- a/freedom-maker/mk_dreamplug_rootfs +++ b/freedom-maker/mk_dreamplug_rootfs @@ -85,6 +85,7 @@ mkdir -p $pkgcache mkdir -p $target/var/cache/apt/ && mount -o bind $pkgcache $target/var/cache/apt/ mkdir -p $target/var/cache/apt/archives mkdir -p $target/usr/bin +mkdir -p $homedir # multistrap echo "Multistrapping..." diff --git a/freedom-maker/multistrap-configs/torouter-armel.conf b/freedom-maker/multistrap-configs/torouter-armel.conf new file mode 100644 index 0000000..9931e1e --- /dev/null +++ b/freedom-maker/multistrap-configs/torouter-armel.conf @@ -0,0 +1,14 @@ +[General] +include=torouter-base.conf +arch=armel +aptsources=Debian torproject torouter armel +debootstrap=Debian torproject torouter armel + +[armel] +packages=linux-image-3.2.0-3-kirkwood flash-kernel u-boot-tools u-boot wireless-tools +source=http://http.debian.net/debian/ +keyring=debian-archive-keyring +suite=wheezy +components=main +omitdebsrc=false + diff --git a/freedom-maker/multistrap-configs/torouter-base.conf b/freedom-maker/multistrap-configs/torouter-base.conf new file mode 100644 index 0000000..acfa6ce --- /dev/null +++ b/freedom-maker/multistrap-configs/torouter-base.conf @@ -0,0 +1,29 @@ +[General] +cleanup=false +noauth=false +unpack=true +debootstrap=Debian torproject torouter +aptsources=Debian torproject torouter + +[Debian] +packages=base-files netbase openssh-server zile wget iproute net-tools hostname module-init-tools wget resolvconf udev isc-dhcp-client ifupdown devio initramfs-tools uboot-mkimage parted dosfstools apt iputils-ping haveged python pandoc python-simplejson make isc-dhcp-server dialog locales-all uaputl uapevent dnsmasq iptables vim-nox less screen lsof tcptraceroute traceroute mtr-tiny openntpd dnsmasq unbound python-augeas python-flask python-daemon +source=http://http.debian.net/debian/ +keyring=debian-archive-keyring +suite=wheezy +components=main +omitdebsrc=false + +[torproject] +packages=tor tor-geoipdb libnatpmp-dev libnatpmp1 libminiupnpc-dev libminiupnpc5 tor-arm +source=http://deb.torproject.org/torproject.org/ +keyring=deb.torproject.org-keyring +suite=wheezy +components=main +omitdebsrc=false + +[torouter] +packages=ttdnsd torouter-tui torouter-prep +source=http://torrouter.torproject.org/torrouter/ +suite=torrouter +components=main +omitdebsrc=false diff --git a/freedom-maker/source/etc/init.d/first-run b/freedom-maker/source/etc/init.d/first-run index 8df2c2d..c811ae0 100755 --- a/freedom-maker/source/etc/init.d/first-run +++ b/freedom-maker/source/etc/init.d/first-run @@ -64,8 +64,8 @@ create-keys # wifi-ap-setup # the last things we do before quitting. -tweak-kernel +#tweak-kernel remove-self -echo "Kernel flashed. Rebooting." -reboot +#echo "Kernel flashed. Rebooting." +#reboot diff --git a/freedom-maker/source/install.sh b/freedom-maker/source/install.sh index 76547ba..fc13d2b 100644 --- a/freedom-maker/source/install.sh +++ b/freedom-maker/source/install.sh @@ -19,7 +19,8 @@ dpkg --get-selections > /tmp/selections mkdir -p /sourcecode cd sourcecode cut -f 1 < /tmp/selections | cut -d ':' -f 1 > /tmp/packages -apt-get source --download-only `cat /tmp/packages` +# TODO: torouter +#apt-get source --download-only `cat /tmp/packages` # sshd may be left running by the postinst, clean that up /etc/init.d/ssh stop diff --git a/freedom-maker/source/tmp/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.apt-key b/freedom-maker/source/tmp/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.apt-key new file mode 100644 index 0000000..5b6a4d3 Binary files /dev/null and b/freedom-maker/source/tmp/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.apt-key differ -- cgit v1.2.3