# Building AltOS
The AltOS source tree has a fairly long list of build dependencies, because
-it builds firmware for at least 4 different processor cores, ground station
-software in Java, various utilities in C, etc. By *far* the easiest way to
-build from source is to start with a [Debian](http://debian.org) 'unstable'
-installation and take advantage of Debian tools and processes. From this
-platform, it is possible to build installable packages not only for Debian,
+it builds firmware for a number of different processor cores, ground station
+software in Java, various utilities in C, documentation, etc. Because Bdale
+and Keith are both [Debian GNU/Linux](https://debian.org) developers, by far
+the easiest way to build from source is to start with a
+Debian 'unstable' installation and take advantage of
+Debian tools and processes. From this platform, it is possible to build
+installable packages not only for Debian,
but also for Windows, Mac OS X, and generic Linux.
-## Compilers
-
-We use standard gcc and OpenJDK to build all of the ground software, but the
-situation for building the firmware is a bit more complicated. Because we
-realize many people may be only interested in working on the ground station
-software, or may only care about building firmware for a single target, we
-have crafted the Makefile contents to test for the presence of the various
-compilers... and will only build firmware for the targets we can find the
-right tools for!
-
-### cc1111
-
-The first generation of Altus Metrum products were all based on the TI cc1111,
-which has an 8051 core. We started out using standard SDCC, but Keith made a
-number of changes to better support the cc1111, and then SDCC 3.X changed code
-generation such that 8051 executables became significantly larger and our code
-just wouldn't fit in available flash any more!
-
-As a result, we maintain a fork of SDCC we call 'cc1111' that is based
-on the last upstream version of SDCC 2.X, plus a highly modified sdcdb with
-support for the cc1111 debugging interface. This is avilable as a package in
-Debian, or you can find the sources on [git.gag.com](http://git.gag.com)
-in the project [debian/cc1111](http://git.gag.com/?p=debian/cc1111;a=summary).
-
-### AVR
-
-We use the standard gcc-avr tools for this target, which thanks to the
-popularity of the [Arduino](http://arduino.cc) community are well taken care
-of in Debian.
-
-### ARM Cortex
-
-Most of the new products we're working on now are based on system on chip
-parts using ARM Cortex M3 or ARM Cortex M0 cores. These require a "bare metal"
-toolchain, not the standard ARM compiler and libraries used for ARM Linux. We
-continue to discuss our needs with others in the Debian community and have
-high hopes for a suitable toolchain to eventually be part of the main
-distribution. But, in the meantime, here's what it takes to build a suitable
-toolchain in /opt/cortex:
-
-* mkdir /opt/cortex, and ensure it's owned by you (so no root privs are needed)
-* clone our [cortex-toolchain](http://git.gag.com/?p=fw/cortex-toolchain;a=summary) with `git clone git://git.gag.com/fw/cortex-toolchain`
-* cd into the cortex-toolchain directory, review the list of build dependencies
- documented in the README file, then build using
- `./summon-arm-toolchain`. This will download all
- the source packages, unpack them, build everything, and install it all in
- /opt/cortex automatically. This takes a bunch of disk space and a lot of
- time, so be patient!
-* clone our [pdclib](http://git.gag.com/?p=fw/pdclib;a=summary) C library
- repository with `git clone git://git.gag.com/fw/pdclib`
-* cd into the pdclib directory, and build using `make ; make install` which
- will build the library using the just-installed cortex tools and deliver
- the results to the /opt/cortex tree
-
-That's it! You should now have an ARM toolchain targetting bare metal for
-both Cortex M0 and M3 variants including a minimal C runtime library.
+To do this, install [Debian](http://debian.org), upgrade to 'unstable', then
+type 'apt build-dep altos' and all of the required build dependencies
+should be automatically installed.
+
+Since many people prefer to use an actually released version of Debian,
+in October 2020 Bdale worked through the steps required to take a
+clean install of Debian 10 (buster) and get to a working build. Here's that
+recipe, as sent to a customer who asked how to do it:
+
+<pre>
+ I actually had to install a fresh buster instance in a VM so that I
+ could chase this down. And then there was an "of course!" moment.
+
+ The complication is based on the fact that Keith and I both run Debian
+ 'unstable', aka 'sid', all the time since we're Debian developers. And
+ it turns out that to build our master branch, you need an ARM cross tool
+ chain that's just newer than what's in buster. Fortunately, that can be
+ installed without perturbing the rest of the system much.
+
+ I took serious notes on how to go from nothing to a working build on
+ buster, here's the recipe:
+
+ # make sure we're on latest buster
+ apt update && apt upgrade
+
+ # set up build dependencies, etc .. the json lib is a new build dep
+ # since buster, so install it manually as 'apt build-dep' won't
+ apt install build-essential git libjson-c-dev
+ apt build-dep altos
+
+ # move from newlib to picolibc, requires updating cross compiler too
+ dpkg --purge libnewlib-nano-arm-none-eabi
+
+ - to get latest ARM cross toolchain, temporarily add to
+ /etc/apt/sources.list a line like:
+
+ deb http://deb.debian.org/debian/ sid main
+
+ apt update
+
+ # this pulls in the latest compiler, runtime library, and dependencies
+ # like gcc-10-base and two related libraries
+ apt install gcc-arm-none-eabi picolibc-arm-none-eabi
+
+ - probably safest to now comment out the sid line in sources.list, and
+ make sure the packaging system forgets about sid for now with
+ apt update
+
+ git clone git://git.gag.com/fw/altos
+ cd altos
+ git checkout master
+ ./autogen.sh
+ make
+
+ That happily ran to completion for me.
+
+ Hope this helps!
+</pre>
+
+The notes we use to do a complete build for release are in the file
+Releasing in the root of the source tree. You do *not* need to follow these
+instructions to do a build for yourself, but since that document is likely
+to be kept up to date better than this one, feel free to check there for
+hints on things that might have changed, and/or feel free to reach out to
+us for help if you get stuck.
+
+If you really want to try and build our source tree on a development platform
+other than Debian, feel free... just don't expect us to help! It's hard
+enough keeping everything working on one development platform...
+