|
1 | | -# FunKey |
2 | 1 |
|
3 | | -Intro |
4 | | -===== |
| 2 | +# FunKey-OS |
| 3 | + |
| 4 | +## Intro |
| 5 | +This repository contains all the sources required to build FunKey-OS, the Open-Source firmware at the heart of the [FunKey S retro-gaming console](https://www.funkey-project.com/). |
| 6 | + |
| 7 | +As the FunKey-S console is based on a sophisticated [Allwinner V3s ARM Cortex-A7 1.2GHz CPU](http://www.allwinnertech.com/index.php?c=product&a=index&id=38), an Operating System is mandatory in order to access all the hardware resources without re-inventing the wheel. |
| 8 | + |
| 9 | +FunKey-OS is based on Linux, and is built from scratch using the [buildroot](http://nightly.buildroot.org/) tool that simplifies and automates the process of building a complete Linux system for an embedded system like this. |
| 10 | + |
| 11 | +Technically, Funkey-OS is a [buildroot (v2) based external tree](https://buildroot.org/downloads/manual/manual.html#outside-br-custom) for building the bootloader, the Linux kernel and user utilities, as well as the optimized retro-game launcher and console emulators. |
| 12 | + |
| 13 | +## Build host requirements |
| 14 | +Even if the resulting disk image and firmware update files are relatively small (202 MB and 55MB, respectively), the size of the corresponding sources and the compilation by-products tend to be rather large, such that an available disk space of at least 12GB is required during the build. |
| 15 | + |
| 16 | +And even if the resulting FunKey-OS boots in less than 5s, it still requires a considerable amount of time to compile: please account for 1 1/2 hour on a modern multi-core CPU with SSD drives and a decent Internet bandwidth. |
| 17 | + |
| 18 | +As the target CPU is probably different from the one running on your build host machine, a process known as [_cross-compilation_](https://en.wikipedia.org/wiki/Cross_compiler) is required for the build, and as the target system will eventually be Linux, this is much better handled on hosts running a Linux-based operating system too. |
| 19 | + |
| 20 | +As a matter of fact, the FunKey-OS is meant to be built on a native Ubuntu or Debian Linux host machine (Ubuntu 20.04 LTS in our case, but this should also work with other versions, too). And with only a few changes to the prerequisites, it can certainly be adapted to build on other common Linux distros. |
| 21 | + |
| 22 | +However, if your development machine does not match this setup, there are still several available solutions: |
| 23 | + - use a lightweight container system such as [Docker](https://www.docker.com/) and run an Ubuntu or Debian Linux container in it |
| 24 | + - use a VM (Virtual Machine) , such as provided by [VirtualBox](https://www.virtualbox.org/) and run an Ubuntu or Debian Linux in it |
| 25 | + - for Windows 10 users, use the [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install-win10) (Windows System for Linux 2) subsystem and run an Ubuntu Linux distro in it |
| 26 | + |
| 27 | +In order to install one of these virtualized environments on your machine, please refer to the corresponding documentation. |
| 28 | + |
| 29 | +## Build on a Physical/Virtual Machine |
| 30 | + |
| 31 | +### Prerequisites |
| 32 | +While Buildroot itself will build most host packages it needs for the compilation, some standard Linux utilities are expected to be already installed on the host system. If not already present, you will need to install the following packages beforehand: |
| 33 | + - bash |
| 34 | + - bc |
| 35 | + - binutils |
| 36 | + - build-essential |
| 37 | + - bzip2 |
| 38 | + - ca-certificates |
| 39 | + - cpio |
| 40 | + - cvs |
| 41 | + - expect |
| 42 | + - file |
| 43 | + - g++ |
| 44 | + - gcc |
| 45 | + - git |
| 46 | + - gzip |
| 47 | + - liblscp-dev |
| 48 | + - libncurses5-dev |
| 49 | + - locales |
| 50 | + - make |
| 51 | + - mercurial |
| 52 | + - openssh-client |
| 53 | + - patch |
| 54 | + - perl |
| 55 | + - procps |
| 56 | + - python |
| 57 | + - python-dev |
| 58 | + - python3 |
| 59 | + - python3-dev |
| 60 | + - python3-distutils |
| 61 | + - python3-setuptools |
| 62 | + - rsync |
| 63 | + - rsync |
| 64 | + - sed |
| 65 | + - subversion |
| 66 | + - sudo |
| 67 | + - tar |
| 68 | + - unzip |
| 69 | + - wget |
| 70 | + - which |
| 71 | + - xxd |
| 72 | + |
| 73 | +On Ubuntu/Debian Linux, this is achieved by running the following command: |
| 74 | +```bash |
| 75 | +$ sudo apt install bash bc binutils build-essential bzip2 ca-certificates cpio cvs expect file g++ gcc git gzip liblscp-dev libncurses5-dev locales make mercurial openssh-client patch perl procps python python-dev python3 python3-dev python3-distutils python3-setuptools rsync rsync sed subversion sudo tar unzip wget which xxd |
| 76 | +``` |
| 77 | + |
| 78 | +### How to get the sources |
| 79 | +When using either physical or virtual Linux machines, you must clone the FunKey OS repository from Github: |
| 80 | + |
| 81 | +```bash |
| 82 | +$ git clone https://github.com/FunKey-Project/FunKey-OS.git <FunKey directory> |
| 83 | +``` |
5 | 84 |
|
6 | | -This directory contains a buildroot-based external configuration for |
7 | | -building the FunKey. |
| 85 | +Then enter into the created directory: |
8 | 86 |
|
9 | | -How to get it |
10 | | -=============== |
| 87 | +```bash |
| 88 | +$ cd <FunKey directory> |
| 89 | +``` |
11 | 90 |
|
12 | | -Clone the FunKey OS repository from Github: |
| 91 | +### Build the disk image & firmware update files |
| 92 | +You may now build your FunKey with: |
13 | 93 |
|
14 | | - $ git clone https://github.com/FunKey-Project/FunKey-OS.git <Funkey directory> |
| 94 | +```bash |
| 95 | +$ make |
| 96 | +``` |
| 97 | +This may take a while, consider getting yourself a cup or glass of your favorite beverage ;-) |
15 | 98 |
|
16 | | -Then enter into the created directory: |
| 99 | +<ins>Note</ins>: you will need to have access to the network, since buildroot will download the package sources. |
17 | 100 |
|
18 | | - $ cd <Funkey directory> |
| 101 | +### Result of the build |
| 102 | +After building, you should obtain the SD Card image `sdcard.img` and the firmware update file `FunKey-rootfs-X.Y.fwu` in the `image` directory. |
19 | 103 |
|
20 | | -How to build it |
21 | | -=============== |
| 104 | +## Build in a container |
22 | 105 |
|
23 | | -Build the disk image & firmware update files |
24 | | --------------------------------------------- |
| 106 | +### Prerequisites |
| 107 | +When using a Docker container, all the prerequisites are automatically installed. |
25 | 108 |
|
26 | | -Note: you will need to have access to the network, since buildroot |
27 | | -will download the packages' sources. |
| 109 | +### How to get the sources |
| 110 | +When using a Docker container, you must first get the FunKey-OS [Dockerfile](https://raw.githubusercontent.com/Michel-FK/FunKey-Project/master/docker/Dockerfile) and Debian [apt-sources.list](https://raw.githubusercontent.com/Michel-FK/FunKey-Project/master/docker/apt-sources.list) and put them into a separate directory: |
28 | 111 |
|
29 | | -You may now build your FunKey with: |
| 112 | +```bash |
| 113 | +$ mkdir <FunKey directory> |
| 114 | +$ cd <FunKey directory> |
| 115 | +$ wget https://raw.githubusercontent.com/FunKey-Project/FunKey-OS/master/docker/Dockerfile |
| 116 | +$ wget https://raw.githubusercontent.com/FunKey-Project/FunKey-OS/master/docker/apt-sources.list |
| 117 | +``` |
| 118 | +You must then build the docker image (don't forget the final dot!): |
| 119 | +```bash |
| 120 | +$ docker build -t funkey-project/funkey-os . |
| 121 | +``` |
30 | 122 |
|
31 | | - $ make |
| 123 | +You are now ready to run interactively a new container based on this docker image: |
| 124 | +```bash |
| 125 | +$ docker run -d -it --name funkey-os funkey-project/funkey-os |
| 126 | +``` |
| 127 | +You can then clone the FunKey OS repository from Github in this brand new container: |
32 | 128 |
|
33 | | -(This may take a while, consider getting yourself a coffee ;-) ) |
| 129 | +```bash |
| 130 | +$ git clone https://github.com/FunKey-Project/FunKey-OS.git <FunKey directory> |
| 131 | +``` |
| 132 | +Then enter into the created directory: |
| 133 | + |
| 134 | +```bash |
| 135 | +$ cd <FunKey directory> |
| 136 | +``` |
34 | 137 |
|
35 | | -Result of the build |
36 | | -------------------- |
| 138 | +### Build the disk image & firmware update files |
| 139 | +You may now build your FunKey with: |
37 | 140 |
|
38 | | -After building, you should obtain this tree: |
| 141 | +```bash |
| 142 | +$ make |
| 143 | +``` |
| 144 | +This may take a while, consider getting yourself a cup or glass of your favorite beverage ;-) |
39 | 145 |
|
40 | | - images/ |
41 | | - +-- FunKey-rootfs-X.Y.fwu |
42 | | - `-- sdcard.img |
| 146 | +<ins>Note</ins>: you will need to have access to the network, since buildroot will download the package sources. |
43 | 147 |
|
44 | | -How to write the SD card |
45 | | -======================== |
| 148 | +### Result of the build |
| 149 | +After building, you can exit the container by typing Ctrl+D. |
46 | 150 |
|
47 | | -Once the build process is finished you will have an image called |
48 | | -"sdcard.img" in the images/ directory. |
| 151 | +You can copy the SD Card image `sdcard.img` and the firmware update file `FunKey-rootfs-X.Y.fwu` from the container into the host current directory: |
| 152 | +```bash |
| 153 | +$ docker cp funkey-os:/home/funkey/<FunKey directory>/images/sdcard.img ./ |
| 154 | +$ docker cp funkey-os:/home/funkey/<FunKey directory>/images/FunKey-rootfs-X.Y.fwu ./ |
| 155 | +``` |
49 | 156 |
|
50 | | -Copy the bootable "sdcard.img" onto an SD card with "dd": |
| 157 | +## How to write to the SD card |
| 158 | +You can copy the bootable "sdcard.img" onto an SD card using "dd": |
51 | 159 |
|
52 | | - $ sudo dd if=<Funkey directory>/images/sdcard.img of=/dev/sdX |
| 160 | +```bash |
| 161 | +$ sudo dd if=sdcard.img of=/dev/sdX |
| 162 | +``` |
| 163 | +<ins>Warning</ins>: Please make sure that */dev/sdX* device corresponds to your SD Card, otherwise you may wipe out one of your hard drive partitions! |
53 | 164 |
|
54 | | -Alternatively, you can use the Etcher graphical tool to burn the image |
| 165 | +Alternatively, you can use the Balena-Etcher graphical tool to burn the image |
55 | 166 | to the SD card safely and on any platform: |
56 | 167 |
|
57 | | -https://etcher.io/ |
| 168 | +https://www.balena.io/etcher/ |
58 | 169 |
|
59 | | -Once the SD card is burned, insert it into your FunKey board, and |
| 170 | +Once the SD card is burnt, insert it into your FunKey S console slot, and |
60 | 171 | power it up. Your new system should come up now and start a console on |
61 | | -the UART0 serial port. |
| 172 | +the UART0 serial port and display the retro game launcher on the graphical screen. |
0 commit comments