Some old building instructions I found

66 views
Skip to first unread message

Andrew Hodel

unread,
Jan 26, 2020, 10:50:32 AM1/26/20
to XYZBots Support for GRBLWeb and RepRapWeb
I just wanted to post this for anyone that was trying to rebuild an image from source.

Here are some things I wrote down.

## debian jessie

http://sjoerd.luon.net/posts/2015/02/debian-jessie-on-rpi2/

art from being somewhat slow, one of the downsides of the original Raspberry Pi SoC was that it had an old ARM11 core which implements the ARMv6 architecture. This was particularly unfortunate as most common distributions (Debian, Ubuntu, Fedora, etc) standardized on the ARMv7-A architecture as a minimum for their ARM hardfloat ports. Which is one of the reasons for Raspbian and the various other RPI specific distributions.

Happily, with the new Raspberry Pi 2 using Cortex-A7 Cores (which implement the ARMv7-A architecture) this issue is out of the way, which means that a a standard Debian hardfloat userland will run just fine. So the obvious first thing to do when an RPI 2 appeared on my desk was to put together a quick Debian Jessie image for it.

The result of which can be found at: https://images.collabora.co.uk/rpi2/

Login as root with password debian (Obviously do change the password and create a normal user after booting). The image is 3G, so should fit on any SD card marketed as 4G or bigger. Using bmap-tools for flashing is recommended, otherwise you'll be waiting for 2.5G of zeros to be written to the card, which tends to be rather boring. Note that the image is really basic and will just get you to a login prompt on either serial or hdmi, batteries are very much not included, but can be apt-getted :).

Technically, this image is simply a Debian Jessie debootstrap with a extra packages for hardware support. Unlike Raspbian the first partition (which contains the firmware & kernel files to boot the system) is mounted on /boot/firmware rather then on /boot. This is because the VideoCore expects the first partition to be a FAT filesystem, but mounting FAT on /boot really doesn't work right on Debian systems as it contains files managed by dpkg (e.g. the kernel package) which requires a POSIX compatible filesystem. Essentially the same reason why Debian is using /boot/efi for the ESP partition on Intel systems rather the mounting it on /boot directly.

For reference, the RPI2 specific packages in this image are from https://repositories.collabora.co.uk/debian/ in the jessie distribution and rpi2 component (this repository is enabled by default on the image). The relevant packages there are:

linux: Current 3.18 based package from Debian experimental (3.18.5-1~exp1 at the time of this writing) with a stack of patches on top from the raspberrypi github repository and tweaked to build an rpi2 flavour as the patchset isn't multiplatform capable :(
raspberrypi-firmware-nokernel: Firmware package and misc libraries packages taken from Raspbian, with a slight tweak to install in /boot/firmware rather then /boot.
flash-kernel: Current flash-kernel package from debian experimental, with a small addition to detect the RPI 2 and "flash" the kernel to /boot/firmware/kernel7.img (which is what the GPU will try to boot on this board).
For the future, it would be nice to see the Raspberry Pi 2 support out of the box on Debian. For that to happen, the most important thing would be to have some mainline kernel support for this board (supporting multiplatform!) so it can be build as part of debians armmp kernel flavour. And ideally, having the firmware load a bootloader (such as u-boot) rather than a kernel directly to allow for a much more flexible boot sequence and support for using an initramfs (u-boot has some support for the original Raspberry Pi, so adding Raspberry Pi 2 support should hopefully not be too tricky)

## debian changes for xyzbots

####Setup MDNS/Zeroconf

```
apt-get install avahi-daemon
echo "xyzbots" > /etc/hostname
```

####Setup build environment

```
apt-get install build-essential python git curl zip unzip dh-autoreconf
```

####Build latest node

```
wget http://nodejs.org/dist/v0.12.3/node-v0.12.3.tar.gz
tar -xzvf node-v0.12.3.tar.gz
cd node-v0.12.3
./configure
make
make install
```

####Setup swap space on disk, there is none and npm runs OOM

```
fdisk /dev/mmcblk0

p to print
n for new, primary, next open partition number, first sector default, last sector +1024M
p to print again, notice type of new partition is Linux, we want swap
t to change type
select new partition (#3)
Enter Hex code 82 for Linux Swap
w to write

echo "/dev/mmcblk0p3 none swap sw 0 0" >> /etc/fstab
mkswap /dev/mmcblk0p3
swapon /dev/mmcblk0p3

reboot //need to reboot after setting up new partition, kernel still uses the old table...
```

####Build CuraEngine

For commit https://github.com/Ultimaker/CuraEngine/commit/64ddaf2ff50064800f1a1a6b514874df806ddf97

You have to build protobuf, libArcus and CuraEngine while disabling some things in protobuf and libArcus.

```
git clone https://github.com/google/protobuf.git
cd protobuf
#comment out lines 18-38 of autogen.sh
./autogen.sh
./configure
make
make install
cd

git clone https://github.com/Ultimaker/libArcus.git
cd libArcus

# COMMENT OUT IN CMakeLists.txt
#option(INSTALL_PYTHON_PACKAGE "Install the Python parts of Arcus" ON)
#option(BUILD_EXAMPLES "Build the example programs" ON)

mkdir build
cd build
cmake ..
make
make install
cd

// you have to use gcc/g++ 4.8 not 4.9 for CuraEngine
// otherwise it fails with extruder float math on Arm
// https://github.com/Ultimaker/CuraEngine/issues/203

apt-get install gcc-4.8 g++-4.8
rm /etc/alternatives/cc
rm /etc/alternative/c++
ln -s /usr/bin/gcc-4.8 /etc/alternatives/cc
ln -s /usr/bin/g++-4.8 /etc/alternative/c++

git clone https://github.com/Ultimaker/CuraEngine.git
cd CuraEngine
mkdir build
cd build
cmake ..
make
```

####Build Perl from source with threads, default perl doesn't work with Slic3r

```
wget http://www.cpan.org/src/5.0/perl-5.20.2.tar.gz
tar -xzf perl-5.20.2.tar.gz
cd perl-5.20.2
../Configure -des -Dprefix=$HOME/localperl -Dusethreads
make
make test
make install
cd
curl -L http://cpanmin.us | ./localperl/bin/perl - App::cpanminus

// you need this for Slic3r
./localperl/bin/cpanm --force ExtUtils::CppGuess
./localperl/bin/cpanm --force Module::Build::WithXSpp
```

####Build Slic3r

for commit https://github.com/alexrj/Slic3r/commit/6e8136085360f3d09bd3be9faa77760a24473e58 which is current stable branch

Current is not building at this time - https://travis-ci.org/alexrj/Slic3r/builds/31971847

```
cd
git clone https://github.com/alexrj/Slic3r.git
cd Slic3r
git checkout -b stable
../localperl/bin/perl Build.PL
```

####Setup RRW

```
git clone https://github.com/andrewhodel/reprapweb.git
cd reprapweb
npm install

// test that it's working
node server.js
```

####Note on updating RRW to support the latest CuraEngine

CuraEngine went from command line options to a json file named fdmprinter.json which comes with it.  I had to write an import and export routine to process this within RRW.  RRW now has fdmprinter.json as a file in it's directory and exports a file named currentCuraConfig.json which CuraEngine uses for settings.

####Setup GRBLWeb

```
git clone https://github.com/andrewhodel/grblweb.git
cd grblweb
npm install

// test that it's working
node server.js
```

####Build mjpeg-streamer for webcam streaming

```
apt-get install libjpeg-dev
git clone https://github.com/andrewhodel/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental

edit Makefile and comment out
#PLUGINS += input_raspicam.so

make clean all
./mjpg_streamer -i ./input_uvc.so -o "./output_http.so -n -w ./www"
```

Stream can then be accessed at http://xyzbots.local:8080/javascript_simple.html

####Install forever

```
npm install -g forever
```

####Setup wifi

```
apt-get install wireless-tools wpasupplicant

add this to /etc/network/interfaces

# uncomment the next 4 lines and set the correct wpa-ssid (network ssid) and wpa-psk (password)

#auto wlan0
#iface wlan0 inet dhcp
#	wpa-ssid ssid
#	wpa-psk password

It will start on boot this way, you can also ifup/ifdown wlan0
```

####Setup /etc/rc.local to start everything on boot

Just add this before exit 0

```
## XYZBOTS BOOT

# this starts the webcam
cd /root/mjpg-streamer/mjpg-streamer-experimental
# you need full paths for the libraries because daemon mode
# goes to the next command which is a path change before loading
# the libs
./mjpg_streamer -b -i "/root/mjpg-streamer/mjpg-streamer-experimental/input_uvc.so" -o "/root/mjpg-streamer/mjpg-streamer-experimental/output_http.so -n -w ./www"

# we sleep for 5 seconds after starting mjpg_streamer so that
# rrw and gw can automatically find if a camera is attached
sleep 5

# this will start either reprapweb or grblweb
# comment out the one you DO NOT want to start
cd /root/reprapweb
#cd /root/grblweb

# this actually starts the server with forever, it is the same script name for both
forever start server.js
```

####Add login message to the end of /etc/motd

```
###### XYZBOTS REPRAPWEB AND GRBLWEB ######

This image has a working copy of RepRapWeb and GRBLWeb

RepRapWeb runs by default on Port 80, to instead use GRBLWeb
you only need to edit /etc/rc.local (instructions inside)

nano /etc/rc.local

## USB Webcam ##

If you plug in a USB webcam and reboot it will show up in both RepRapWeb an GRBLWeb

## Serial Baud Rate ##

This setting can be changed in /root/reprapweb/config.js for RepRapWeb and in
/root/grblweb/config.js for GRBLWeb.

## Setup WiFi ##

Edit the file /etc/network/interfaces then reboot or run `/etc/init.d/networking restart`
or run ifup wlan0

## XYZBOTS.README ##

Read /root/XYZBOTS.README if you haven't already.
```

####XYZBOTS.README

This is in /root

```
Simple instructions on how to use the XYZBOTS RepRapWeb and GRBLWeb Image

This image only works with the Rapsberry Pi 2
(labeled on the physical board as B V1.1)

## Introduction

This is a single image file which you can download and flash to a Raspberry Pi 2
in order to control a 3d Printer or CNC Machine.

The image contains both RepRapWeb and GRBLWeb.  RepRapWeb is for controlling 3d
Printers and GRBLWeb is for controlling CNC Machines using GRBL.  They are both
created and maintained by XYZBots and can be found at http://xyzbots.com

The image also contains a MJPG webcam server which allows you to view your printer
or cnc machine through a USB camera directly from the RepRapWeb and GRBLWeb ui.

The image is based on Debian Jessie and is not the full (and bloated) raspbian img.

Please read this entire page in order to understand how to use and work with this
software.

## Getting the Image and Flashing

The image can be downloaded in any of 3 compressed formats:

* xz - (best compression, smallest file download)
* bz2 - (better compression, slightly larger download)
* zip - (most common compression, largest download)

You can download the format for which you have a tool to decompress the file with.

I will assume you can decompress the file and get the resulting .img file inside.

Using dd you can easily flash the img file to an SD card (/dev/sdc) using:

`dd if=xyzbots-reprapweb-grblweb-2015-may.img of=/dev/sdc bs=4M`

If you are not using a *nix based system or do not know how to use dd, there are
more instructions and links to GUI based flash tools on http://xyzbots.com which
can help you.

## Booting and Initial Configuration

Once the SD card has been flashed, insert it into the Raspberry Pi 2 then connect ethernet
, your printer or GRBL, and power to boot the device.

Automatically the device will request a DHCP address over ethernet.  By default RepRapWeb is
enabled on boot, you can access the RepRapWeb interface at http://xyzbots.local (MDNS)

You can also SSH to the device at http://xyzbots.local using the following credentials:

Username: root
Password: debian

Once you SSH into the device, it will display a message explaining how to switch between
RepRapWeb and GRBLWeb as well as how to setup WiFi.  A USB Camera is automatically enabled
when connected to the device.
```

#### Shrinking images

```
With the SD card in a computer, first move the build files off the SD

mount /dev/sdc2 /tmp/mnt
mkdir /tmp/xyzBuilds
cd /tmp/mnt/root
mv protobuf/ libArcus/ perl-5.20.2/ node-v0.12.3/ /tmp/xyzBuilds/

That saves 651M
```

#### Get rid of unused space in the image so it will fit in any 8gb SD

```
When you dd from an SD card to a file, the file will be the size of the whole SD card. If the partitions are smaller than the SD card, you can use truncate to shrink the image down to the size of the partitions.

You can shrink the size of the partition on an SD card with gparted very easily, then use the process below for truncate on the img after you have dd'd the SD card to a file.

First you have to find out the partition layout of the image with fdisk.

$ fdisk -l myimage.img
The output should look something like this:

Disk myimage.img: 7969 MB, 7969177600 bytes, 15564800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x417ee54b

      Device Boot      Start         End      Blocks   Id  System
myimage.img1            2048      186367       92160    c  W95 FAT32 (LBA)
myimage.img2          186368     3667967     1740800    5  Extended
myimage.img5          188416     3667967     1739776   83  Linux
The information you need is the unit size (512 bytes) and the largest end block number (3667967). Since block counting starts at 0, you need to add 1 to the number of blocks. Now you can use truncate to trim the image to the size of the actually used space.

$ truncate --size=$[(3667967+1)*512] myimage.img
```

#### Compressing images

```
xz -zk file.img // create xz archive and don't delete input file
```
Reply all
Reply to author
Forward
0 new messages