├── .gitignore ├── LICENSE ├── README.md ├── build.config ├── build.config.amd64 ├── build.config.arm32_vexpress ├── build.config.arm64_qemuvirt ├── build.config.arm64_rpi3b_cm3 ├── build_SEALS.sh ├── cleanall ├── color.sh ├── common.sh ├── err_common.sh ├── install.sh ├── kgdb_qemu_run.sh ├── mount_rootfs.sh ├── run-qemu.sh ├── run_and_log ├── show_curr_config.sh ├── test ├── build.config ├── build.config.amd64 ├── build.config.arm32_vexpress ├── build.config.arm64_qemuvirt ├── build.config.arm64_rpi3b_cm3 ├── build_SEALS.sh ├── cleanall ├── color.sh ├── common.sh ├── err_common.sh ├── install.sh ├── mount_rootfs.sh ├── run-qemu.sh ├── shellcheck_run └── show_curr_config.sh └── tutorial_pics ├── bb1.png ├── bb2.png ├── bb3.png ├── first-time-error.png ├── gen_rootfs.png ├── install.png ├── k1.png ├── k2.png ├── k3.png ├── k4.png ├── k5.png ├── menu-selected4.png ├── menu.png ├── notes1.txt ├── platform-config-review-screen.png ├── run1.png ├── run2.png ├── run3.png ├── run4.png └── select_platform.png /.gitignore: -------------------------------------------------------------------------------- 1 | bkp/ 2 | .*.swp 3 | *.bkp 4 | tags 5 | log* 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Kaiwan N Billimoria 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SEALS 2 | ===== 3 | SEALS is an abbreviation for _Simple Embedded ARM Linux System_. 4 | It uses the powerful and FOSS *Qemu* (quick emulator!) to emulate a few target boards, helping us learn how to build a small (skeletal, really) embedded Linux system pretty muc from scratch! 5 |
6 | 7 | **NEW! (Oct / Dec 2023) : SEALS now supports:**
8 | - A simple GUI at startup to select the target machine to deploy
9 | - New machines (platforms)!
10 | - the good 'ol PC (x86_64 or amd64) [Dec 2023]
11 | - the Raspberry Pi 3B (shows as the Compute Model 3 - CM3) 12 | 13 | (Jan 2023): SEALS now supports both AArch32 and AArch64 platforms 14 | 15 | The SEALS project consists of scripts that will enable you to build a simple 16 | yet complete skeletal ARM\*/Linux system, emulated using the powerful [QEMU][2] 17 | emulator. The SEALS scripts automate the following tasks: 18 | 19 | - Using a simple ASCII text config file to precisely customize your environment 20 | - Using a cross-compiler 21 | - ARM\* / Linux kernel config and build 22 | - Creating a skeletal root filesystem from scratch 23 | - Integrating the components together, using QEMU (qemu-system-arm, 24 | particularly) to run the same in an emulated environment. 25 | 26 | \*ARM can now be AArch32 or AArch64 platforms.
27 | From v0.3, SEALS also supports the x86_64 / amd64 PC platform (so it isn't strictly only 'ARM' now!) 28 |
29 | 30 | # Getting Started 31 | Please, FIRST READ
32 | - [the SEALS Getting Going! Tutorial](https://github.com/kaiwan/seals#a-very-brief-tutorial-on-getting-going-with-seals)
33 | 34 | Then, in the Wiki section, the:
35 | - [SEAL's Wiki page - intro to SEALS][0], and
36 | - [SEAL's HOWTO page][1]
37 | to better understand how to build and use this project. 38 | 39 | *SEALS can prove very useful for developers / testers to prototype, try things out in a custom ARM/\*Linux or emulated x86 PC simple guest system.* 40 |
41 | 42 | ## Install 43 | - Clone this repository:
44 | `git clone https://github.com/kaiwan/seals.git` 45 | - Run the `run_and_log` script. 46 |
47 | 48 | # A very brief tutorial on getting going with SEALS 49 | 50 | I assume you're running in GUI mode (via Xorg or Xwayland). 51 | 52 | *Step 1.* Perform the git clone (as mentioned above)
53 | 54 | *Step 2.* If you immediately run the `run_and_log` script, it typically results in an error, saying that the "staging, busybox and kernel source folders" aren't present. 55 | This is typically the case when you start out. 56 |
57 | 58 | ***FAQ: Where are the staging and other folders designated?***
59 | In the all-important **build config** file!
60 | This file is, by default, named `build.config` and is a symbolic (or soft) link to the `build.config.arm32_vexpress` build config file - to build and run the (emulated) ARM-32 Verstaile Express board! 61 | 62 | $ ls -l build.config 63 | lrwxrwxrwx. 1 kaiwan kaiwan 18 Dec 14 15:43 build.config -> build.config.arm32_vexpress 64 | 65 | *It's very important to familiarize yourself with the board config files! Please browse through them, they're quite self-explanatory (with a lot of comments).* 66 | 67 | Here's a snippet from the `build.config.arm32_vexpress` file showing how these folders are designated: 68 | 69 | STG=~/seals_staging/seals_staging_arm32 70 | ROOTFS=${STG}/rootfs 71 | IMAGES_FOLDER=${STG}/images 72 | IMAGES_BKP_FOLDER=${STG}/images_bkp 73 | CONFIGS_FOLDER=${STG}/configs 74 | 75 | You're free to edit it... typically, just set the `STG` variable to point to your staging location on your build host's disk, the rest follow under it... (In a similar fashion, the board config files use simple shell variables to designate various board attributes, the root fs and kernel stuff, and more; you must browse through them. 76 | 77 | So, back to the setup. To fix possible errors the first time you run SEALS, install the busybox and kernel folders and their source trees **by running the `install.sh` script**; here's a screenshot: 78 | 79 | ![install script](tutorial_pics/install.png) 80 | 81 | (The script detects and deletes old source if required). 82 | When it's done, you should have the Linux busybox project and the Linux kernel source tree installed. 83 |
84 | 85 | You can change the target board of course... by either manually updating the soft link, or, better, via our GUI! These are the 'prebuilt' target board config files we provide:
86 | 87 | $ ls build.config* 88 | build.config@ build.config.amd64 build.config.arm32_vexpress build.config.arm64_qemuvirt build.config.arm64_rpi3b_cm3 89 | 90 | The one that the `build.config` soft link points to is the current one, the one that will get built and run (via Qemu). You can even define your own board config files using these as a template! (of course, introducing new variables will require your editing the `build_SEALS.sh` script as well). When you do do this and it works, consider contributing it! 91 | 92 |
93 | 94 | *Step 3.* Run the `run_and_log` script. 95 | Now, *if you do NOT* have the staging, busybox and kernel source folders installed (*Step 2*), you'll get the following (or similar) error message (notice how it's both via the GUI and on the console (terminal window)): 96 | 97 | ![first time error](tutorial_pics/first-time-error.png) 98 | 99 | (Hey, this is expected! Read it carefully; the project expects you to minimally setup a 'staging area' or work area (where the stuff gtes built at runtime) like this:
100 | 101 |
102 | |--- linux-kernel-source-tree
103 | |--- busybox-git-source-tree 104 | 105 | ). 106 | 107 | Assuming these folders and the sources are in place (typically achived by running the `install.sh` script), all will be well and execution continues... 108 | The `build_SEALS.sh` script is the primary script (invoked by the `run_and_log` script) and the first thing it does is show you the currently selected target platform, and allows you to change it via this gui: 109 | 110 | ![select target board](tutorial_pics/select_platform.png) 111 | 112 | (TODO: A slight issue: when you select another board, the highlight bar still stays on the first one, but that's okay). 113 | 114 | To go ahead with the current selection, simply press `Esc` here... Else, select another board by turning on it's radio button and thenclick on `Select`; a confirmation dialog pops up. 115 | (TODO: the new target board selection procedure's only via the GUI currently; need to update the console mode for it as well). 116 | 117 | *Step 4.* You are now shown the currently selected target board configuration in detail (both via a gui dialog box and on the console): 118 | 119 | ![config review](tutorial_pics/platform-config-review-screen.png) 120 | 121 | The config details are picked up from the `board.config.` file pertaining to the current board. 122 | This dialog allows you to review the current settings for it and decide if the current board config is fine; if your answer is: 123 | 124 | * Yes, it's fine: simply click the `Yes` button 125 | * No, I need to edit it: click the `No` button, and the script aborts. Edit the relevant `build.config.` file to your satisfaction, and then rerun the script. 126 | 127 | *Step 5.* When happy with the state of the build config file, run the script: 128 | 129 | After the 'usual' GUI dialogs, (the ones you've seen in the earlier steps), you will get the main menu GUI dialog: 130 | 131 | ![main menu](tutorial_pics/menu.png) 132 | 133 | Read the (blue color) notes on top carefully. Go ahead and select whichever options you'd like SEALS to perform! Click on `OK` when done.
134 | 135 | Here's an example showing some selections made: 136 | 137 | ![main menu sample selection](tutorial_pics/menu-selected4.png) 138 | 139 | ***FAQ> What do the `Wipe kernel / busybox config (Careful!*)` options do?***
140 | Ans> Essentially, they have the underlying kbuild menu system to run it's `make ARCH= defconfig` thus setting all config values to their default. So, it's typically useful to do this the first time you're performing the build. Once you've saved your won config, you can disable these toggles, thereby keeping your config (also, FYI, the config files, among others, can be saved / backed up (the second-to-last option).
141 | If running in console (non-gui, on a terminal window) mode, it still works and will interactively ask you to select what you want it to do. 142 |
143 | Perhaps it still generates errors. This could be due to missing packages (we only automate installation of required host packages on Ubuntu). More likely, the absence of the **cross toolchain** - specified in the board config file - is the issue (see the FAQ below). 144 | 145 |
146 | 147 | ***FAQ> I'm getting errors regarding the toolchain***
148 | Ans> The (cross) toolchain is a required component when using any of the ARM-based boards. 149 | You'll have to install it on your build host (which can be a Linux VM, np). [The detailed documentation to do so is in the Wiki section](https://github.com/kaiwan/seals/wiki/SEALs-HOWTO). 150 | 151 |
152 | 153 | 154 | # Example screenshots 155 | All are wrt the default build config platform, the ARM-32 Versatile Express: 156 | (FYI, all carried out in an x86_64 Ubuntu 23.04 VirtualBox guest). 157 | 158 | **Kernel Build Portion**:- 159 | 160 | * A screenshot showing a portion of the kernel build step, just before entering the kernel config: 161 | 162 | ![kernel build sample 1](tutorial_pics/k1.png) 163 | 164 | * A screenshot showing a portion of the kernel build step, the kernel config: 165 | 166 | ![kernel menuconfig sample](tutorial_pics/k2.png) 167 | 168 | * Some sample output while the kernel build just begins: 169 | 170 | ![kernel pre build sample](tutorial_pics/k3.png) 171 | 172 | * Some sample output while the kernel is building: 173 | 174 | ![kernel build sample](tutorial_pics/k4.png) 175 | 176 | * Some sample output after the kernel build is done: 177 | 178 | ![kernel after build sample](tutorial_pics/k5.png) 179 | 180 | **Busybox (generates part of the target root fs: /bin, /sbin, /usr) config**:- 181 | 182 | * Some sample output of the Busybox config menu: 183 | 184 | ![bb config sample](tutorial_pics/bb1.png) 185 | 186 | * Some sample output of the Busybox completion: 187 | 188 | ![bb done sample](tutorial_pics/bb2.png) 189 | 190 | * Some sample output of the Busybox step, *root filesystem generation* by SEALS: 191 | 192 | ![bb rootfs sample](tutorial_pics/bb3.png) 193 | 194 | **Sample output from the 'Generate Root Filesystem EXT4 image' menu** : 195 | 196 | 197 | ![gen ext4 image sample](tutorial_pics/gen_rootfs.png) 198 | 199 | 200 | # Running it! 201 | 202 | * Some sample output just prior to running the AArch32 Vexpress target board under Qemu (via it's GUI menu; notice the complete Qemu command line!): 203 | (You can also run it via the `run-qemu.sh 0` command). 204 | 205 | ![pre run sample](tutorial_pics/run1.png) 206 | 207 | * Some sample output when running the AArch32 Vexpress target board under Qemu (notice the kernel startup, all the kernel printk's being emitted as it boots...) : 208 | 209 | ![run sample](tutorial_pics/run2.png) 210 | 211 | * Some sample output running the AArch32 Vexpress target board under Qemu; once we reach our Busybox shell via (busybox) init : 212 | 213 | ![post run sample](tutorial_pics/run3.png) 214 | 215 | * Some sample output running the AArch32 Vexpress target board under Qemu; on the Busybox shell : 216 | 217 | ![post run sample 2](tutorial_pics/run4.png) 218 | 219 | Excellent; we're running the ARM-32 Vexpress platform. 220 |
221 | 222 | ***FAQ: Can I clean up everything (for the current board)?*** 223 | 224 | Yes! You can do so via the `cleanall` script; but **be CAREFUL**; it will ask for confimation and then delete stuff (via the typical `make clean` type of command for the source, and via `rm -rf ...` for the root fs, images, etc). 225 | 226 | # Issues, Contribution 227 | This project, like most FOSS ones, is ever-evolving... I urge you to not hesitate, to write in your comments, suggestions or anything. 228 | Please do raise issues or bugs in the [Issues section of the GitHub repo](https://github.com/kaiwan/seals/issues). 229 | Any contributions would be awesome (have a look at the current `Issues`)! I solicit your participation and help to make this project better! 230 | 231 | [0]: https://github.com/kaiwan/seals/wiki 232 | [1]: https://github.com/kaiwan/seals/wiki/SEALs-HOWTO "SEALS HOWTO Page" 233 | [2]: https://www.qemu.org/ "QEMU Homepage" 234 | -------------------------------------------------------------------------------- /build.config: -------------------------------------------------------------------------------- 1 | build.config.arm32_vexpress -------------------------------------------------------------------------------- /build.config.amd64: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ####################################################################### 3 | # build.config 4 | # 5 | # Part of the SEALs project. 6 | # This is the configuration file; all config variables must go here. 7 | # 8 | # !! IMP NOTE TO THE END-USER OF THIS PROJECT !! 9 | # You are responsible for editing this configuration file, setting the 10 | # variables to sane values. 11 | # To help you out, the place in the source below which has the config 12 | # variables that you MUST update have been marked with a comment line 13 | # as follows: 14 | # # @@@@@ 15 | # So, you could just search for this string '@@@@@' (excluding the quotes of course), 16 | # and make sure you update the following config variable(s) to the sane value 17 | # for your box. 18 | # !! 19 | #--- 20 | # Author: Kaiwan N Billimoria 21 | # (C) kaiwanTECH 22 | #--- 23 | ####################################################################### 24 | # 25 | #---------------------- 26 | # !!!VERY IMPORTANT!!! 27 | #---------------------- 28 | # Pl read the documentation here, at least once: 29 | # https://github.com/kaiwan/seals/wiki 30 | #---------------------- 31 | # 32 | # Generic Config file. 33 | # For a minimal QEMU-ARM project, we Expect that: 34 | # 35 | # - an x86_64-to-ARM32 toolchain is installed and working, and setup in the config below 36 | # details: https://github.com/kaiwan/seals/wiki/HOWTO-Install-required-packages-on-the-Host-for-SEALS 37 | # - a recent version of the Linux kernel source tree is available and setup in the config below 38 | # - a recent version of busybox source tree is available and setup in the config below 39 | ############## 40 | 41 | set -a # auto export all vars 42 | 43 | ##################### UPDATE as required 44 | # @@@@@ 45 | CONFIG_NAME_STR="SEALs config file for the PC ! (AMD64 / x86_64)" 46 | COLOR=1 # terminal color support? Assume yes.. 47 | GUI_MODE=0 # auto-detects GUI / console mode 48 | DEBUG=0 # set to 1 to get debug messages displayed 49 | VERBOSE_MSG=0 # set to 1 to get more verbose messages displayed 50 | # [loglevel][date-timestamp] 51 | LOGFILE_COMMON=log_seals.txt 52 | 53 | ###------### 54 | TOPDIR=$(pwd) 55 | 56 | ### Locations on Disk ### 57 | ### UPDATE ### on your system! 58 | # @@@@@ 59 | STG=$(realpath ~/seals_staging/seals_staging_pc) 60 | STG=$(realpath ~/SEALS_staging/stg_x86_64/) 61 | # Recommendation: if running a cloud-sync service (like pCloud/Dropbox), 62 | # keep the staging area outside it. 63 | 64 | # Okay, so under the ${STG} folder, we expect you have extracted the 65 | # Toolchain: the toolchain to use; expect that it is installed and the PATH is setup.. 66 | # @@@@@ 67 | # For the PC, we don't need a special toolchain; the native one on the build host is fine! 68 | CXX="" 69 | # CXX_LOC is the location of the x86-to-ARM toolchain on disk 70 | # (used to setup the PATH and locate the ARM shared libraries within the toolchain) 71 | # @@@@@ 72 | CXX_LOC="" 73 | 74 | # Toolchain in the PATH 75 | #PATH=$PATH:${CXX_LOC}/bin 76 | 77 | # Verbose build? (if 1, we run as 'make V=1 ...') 78 | VERBOSE_BUILD=0 79 | 80 | 81 | # Also under the ${STG} folder, we expect you have extracted the 82 | # source of busybox into the folder ${BB_FOLDER} ver ${BB_VER}. 83 | # (Update the variables below to reflect your settings and installation). 84 | # @@@@@ 85 | BB_VER="1.33.2" 86 | # 1.29 : build failing with a linker error 87 | BB_FOLDER=${STG}/busybox 88 | SHELL2RUN=/bin/sh #/bin/bash 89 | ROOTFS=${STG}/rootfs 90 | ROOTFS_PC=${STG}/rootfs_pc 91 | IMAGES_FOLDER=${STG}/images 92 | IMAGES_BKP_FOLDER=${STG}/images_bkp 93 | CONFIGS_FOLDER=${STG}/configs 94 | 95 | 96 | ##### 97 | # @@@@@ 98 | # Set to exactly one of: 99 | # arc arm64 csky hexagon m68k mips nios2 parisc riscv sh um x86_64 100 | # alpha arm c6x h8300 ia64 microblaze nds32 openrisc powerpc s390 sparc x86 xtensa 101 | # TODO / RELOOK - do we need this ?? 102 | ARCH_SPEC=x86_64 103 | 104 | # Select the platform (to build the kernel for). Choices: 105 | # For the purpose of a "real" example, this file is pre-populated with values 106 | # relevant to the Qemu Verastile Express (vexpress) platform (ARMv7 Cortex-A9). 107 | # @@@@@ 108 | # English-like name 109 | ARCH_PLATFORM_STR="AMD64" 110 | 111 | # ! IMPORTANT ! 112 | # Pl set the variable ARCH_PLATFORM carefully; it will be used to setup 113 | # the inital config and is therefore very critical that it's given correctly: 114 | # make ARCH=${ARCH_SPEC} ${ARCH_PLATFORM}_defconfig 115 | # So, check under /arch//configs/ 116 | # for the best match to your platform, in the form 117 | # _defconfig 118 | # and put it here.. 119 | # For AMD64, put 'x86_64' 120 | ARCH_PLATFORM=x86_64 121 | 122 | # ARCH_PLATFORM_OPT is the value passed via the -M switch to Qemu 123 | # Look for it via qemu-system-arm -M ? ; eg. 124 | # qemu-system-arm -M ? |grep -i "i.mx" 125 | # For AMD64, comment it out! 126 | #ARCH_PLATFORM_OPT=vexpress-a9 127 | 128 | # For this platform - AMD64 (or x86_64) - many options are simply NULL 129 | ARCH="x86" 130 | CPU_MODEL="pc" # -M option to Qemu ; becomes 'Standard PC (i440FX + PIIX, 1996) (alias of pc-i440fx-7.2)' 131 | ARM_PLATFORM="" 132 | ARM_PLATFORM_STR="" 133 | DTB_BLOB="" 134 | DTB_BLOB_PATHNAME="" 135 | 136 | ### UPDATE ### on your system! 137 | # Okay, so under the ${STG} folder (or other), we expect you have extracted the 138 | # source of the Linux kernel into ${KERNEL_FOLDER} , ver ${KERNELVER}. 139 | # (Update the variables below to reflect your settings and installation). 140 | # @@@@@ 141 | KERNELVER=6.1.25 142 | KERNEL_FOLDER=${STG}/linux-${KERNELVER}/ 143 | 144 | # @@@@@ 145 | # Set to 1 to build the initramfs image and use it at boot 146 | USE_INITRAMFS=0 147 | 148 | # @@@@@ 149 | # DTB: specify the Device Tree Blob .dtb 150 | #DTB_BLOB=vexpress-v2p-ca9.dtb 151 | ##### 152 | 153 | ##### 154 | # @@@@@ 155 | # SEALs (virtual) "Hardware" 156 | SEALS_RAM=1024 # MB 157 | 158 | ##### 159 | # ROOTFS 160 | # !Careful! Set to 1 to force a rebuild of the rootfs; implies OVERWRITING any 161 | # existing rootfs 162 | RFS_FORCE_REBUILD=0 163 | # Rootfs size: Recommendation: if using a kdump kernel, as a rough thumb rule, 164 | # make it ~ 150% of the size of RAM on the platform (so for eg. if the RAM is 512M, 165 | # make the rootfs size ~ >= 768 MB). 166 | # Else (no kdump), 512 MB is fine for the Vexpress. 167 | RFS_SZ_MB=1024 #512 168 | 169 | MYPRJ=myprj 170 | 171 | ##### 172 | # @@@@@ 173 | # SEALs kernel command-line 174 | SERIAL_CONSOLE=ttyS0 175 | SEALS_K_CMDLINE="console=${SERIAL_CONSOLE} console=ttyS1 tsc=reliable no_timer_check nokaslr root=/dev/sda rw init=/sbin/init" #/bin/bash" #/sbin/init" 176 | #SEALS_K_CMDLINE="debug console=ttyS0 console=ttyS1 tsc=reliable no_timer_check nokaslr root=/dev/sda rw init=${INIT}" #/bin/bash" #/sbin/init" 177 | 178 | # if 512M RAM, reserve 32M for crashk, else if 256M RAM, reserve 16M 179 | #K_CMDLINE_XTRA="crashkernel=32M" # works with 32M not 16M [?] 180 | #K_CMDLINE_XTRA="initcall_debug ignore_loglevel debug" 181 | K_CMDLINE_XTRA="" 182 | [ ! -z "${K_CMDLINE_XTRA}" ] && SEALS_K_CMDLINE="${SEALS_K_CMDLINE} ${K_CMDLINE_XTRA}" 183 | 184 | ##### Config vars for what to build 185 | # VAR=1 : 'do' the work 'VAR' 186 | # VAR=0 : 'do Not' do the work 'VAR' 187 | BUILD_KERNEL=0 188 | BUILD_ROOTFS=0 189 | GEN_EXT4_ROOTFS_IMAGE=0 190 | SAVE_BACKUP_IMG_CONFIGS=0 191 | RUN_QEMU=0 192 | 193 | 194 | ### "WIPE_*_CONFIG" directives 195 | # Set var to '1' implies any existing kernel configuration is wiped out. 196 | # Suggestion: set to '1' for the FIRST build with a clean kernel source tree.. 197 | # @@@@@ 198 | WIPE_KERNEL_CONFIG=0 199 | 200 | # Set var to '1' implies any existing busybox configuration is wiped out. 201 | # Suggestion: set to '1' for the FIRST build with a clean busybox source tree.. 202 | # @@@@@ 203 | WIPE_BUSYBOX_CONFIG=0 204 | 205 | # Set var to '1' implies that the busybox configuration will be set to have 206 | # all config options OFF/No by default. 207 | # Suggestion: set to '1' when you want an 'as tiny as possible' busybox binary 208 | # and know how to configure it 209 | # @@@@@ 210 | TINY_BUSYBOX_CONFIG=0 211 | 212 | QEMUNAME=qemu-system-x86_64 213 | KGDB_MODE=0 # make '1' to have qemu run with the '-s -S' switch (waits for client GDB to 'connect') 214 | SMP_EMU_MODE=1 # make '1' to have qemu run w/ 2 emulated cores 215 | 216 | #--- End build.config 217 | -------------------------------------------------------------------------------- /build.config.arm32_vexpress: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ####################################################################### 3 | # build.config.arm32_vexpress 4 | # 5 | # Part of the SEALs project. 6 | # This is the configuration file; all config variables must go here. 7 | # 8 | # !! IMP NOTE TO THE END-USER OF THIS PROJECT !! 9 | # You are responsible for editing this configuration file, setting the 10 | # variables to sane values. 11 | # To help you out, the place in the source below which has the config 12 | # variables that you MUST update have been marked with a comment line 13 | # as follows: 14 | # # @@@@@ 15 | # So, you could just search for this string '@@@@@' (excluding the quotes of course), 16 | # and make sure you update the following config variable(s) to the sane value 17 | # for your box. 18 | # !! 19 | #--- 20 | # Author: Kaiwan N Billimoria 21 | # (C) kaiwanTECH 22 | #--- 23 | ####################################################################### 24 | # 25 | #---------------------- 26 | # !!!VERY IMPORTANT!!! 27 | #---------------------- 28 | # Pl read the documentation here, at least once: 29 | # https://github.com/kaiwan/seals/wiki 30 | #---------------------- 31 | # 32 | # Generic Config file. 33 | # For a minimal QEMU-ARM project, we Expect that: 34 | # 35 | # - an appropriate toolchain is installed and working, and setup in the config below 36 | # details: https://github.com/kaiwan/seals/wiki/HOWTO-Install-required-packages-on-the-Host-for-SEALS 37 | # - a recent version of the Linux kernel source tree is available and setup in the config below 38 | # - a recent version of busybox source tree is available and setup in the config below 39 | ############## 40 | 41 | set -a # auto export all vars 42 | 43 | #--------GENERIC CONFIG OPTIONS------------------------------------------------------------ 44 | ##################### UPDATE as required 45 | # @@@@@ 46 | CONFIG_NAME_STR="SEALs config file for ARM-32 Versatile Express (vexpress-a15) board" 47 | COLOR=1 # terminal color support? Assume yes.. 48 | GUI_MODE=0 # auto-detects GUI / console mode 49 | DEBUG=0 # set to 1 to get debug messages displayed 50 | [ ${DEBUG} -eq 1 ] && export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' 51 | VERBOSE_MSG=0 # set to 1 to get more verbose messages displayed 52 | # [loglevel][date-timestamp] 53 | LOGFILE_COMMON=log_seals.txt 54 | 55 | ###------### 56 | TOPDIR=$(pwd) 57 | #------------------------------------------------------------------------------ 58 | 59 | #--------KEY DISK LOCATIONS and Settings--------------------------------------- 60 | ### Locations on Disk ### 61 | ### UPDATE ### on your system! 62 | # @@@@@ 63 | STG=$(realpath ~/seals_staging/seals_staging_arm32) 64 | STG=$(realpath ~/SEALS_staging/SEALS_staging_vexpress/) 65 | # Recommendation: if running a cloud-sync service (like Dropbox), keep the 66 | # staging area outside it. 67 | ROOTFS=${STG}/rootfs 68 | IMAGES_FOLDER=${STG}/images 69 | IMAGES_BKP_FOLDER=${STG}/images_bkp 70 | CONFIGS_FOLDER=${STG}/configs 71 | # Verbose build (for the kernel and busybox)? (if 1, we run as 'make V=1 ...') 72 | VERBOSE_BUILD=0 73 | #------------------------------------------------------------------------------ 74 | 75 | #--------'HARDWARE'------------------------------------------------------------ 76 | # SEALs (virtual) "Hardware" 77 | # @@@@@ 78 | # Select the CPU arch (to build the kernel for); the value to specify is the 79 | # name of the dir under /arch/XXX 80 | ARCH=arm 81 | ARCH_PLATFORM="" 82 | QEMUNAME=qemu-system-arm 83 | 84 | CPU_MODEL=cortex-a15 85 | SEALS_RAM=512 # MB 86 | 87 | # Select the platform (to build the kernel for). 88 | # @@@@@ 89 | # English-like name 90 | ARM_PLATFORM_STR="Versatile Express (A15)" 91 | 92 | # ! IMPORTANT ! 93 | # Selecting the platform varies with the ARCH: 94 | # ===> For Aarch32 (ARM): 95 | # Pl set the variable ARM_PLATFORM carefully; it will be used to setup 96 | # the inital config and is therefore very critical that it's given correctly: 97 | # make ARCH=arm ${ARM_PLATFORM}_defconfig 98 | # So, check under /arch//configs/ 99 | # for the best match to your platform, in the form 100 | # _defconfig 101 | # and put it here.. F.e.: 102 | ARM_PLATFORM=vexpress 103 | # 104 | # ===> For Aarch64 (arm64): 105 | # On Aarch64, all platforms will be selected by default. 106 | # (Can see them within the 'Platform selection' menu). 107 | # Either build it this way or deselect all and enable only the platform(s) you want to support... 108 | # So here, we leave the variable ARM_PLATFORM as NULL to fulfill the default case (all platforms) 109 | #ARM_PLATFORM= 110 | 111 | # ARM_PLATFORM_OPT is the value passed via the -M (machine) switch to Qemu 112 | # Look for it via qemu-system-arm -M ? ; eg. 113 | # qemu-system-arm -M ? |grep -i "i.mx" 114 | ARM_PLATFORM_OPT=vexpress-a15 115 | 116 | SMP_EMU_MODE=1 # make '1' to have qemu run w/ 4 emulated cores 117 | # (only works on appropriate h/w-emulated platforms) 118 | #------------------------------------------------------------------------------ 119 | 120 | 121 | # Okay, so under the ${STG} folder, we expect you have extracted the: 122 | 123 | #--------TOOLCHAIN------------------------------------------------------------ 124 | # The toolchain to use; expect that it is installed and the PATH is setup.. 125 | # @@@@@ 126 | CXX=arm-none-linux-gnueabihf- # toolchain prefix 127 | # CXX_LOC is the location of the x86-to-ARM toolchain on disk 128 | # (used to setup the PATH and locate the ARM shared libraries within the toolchain) 129 | # @@@@@ 130 | CXX_LOC=~/tc/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-linux-gnueabihf/bin 131 | # Keep your toolchain in the PATH 132 | PATH=$PATH:${CXX_LOC}/bin 133 | #------------------------------------------------------------------------------ 134 | 135 | #--------KERNEL------------------------------------------------------------ 136 | ### UPDATE ### on your system! 137 | # Okay, so under the ${STG} folder (or other), we expect you have extracted the 138 | # source of the Linux kernel into ${KERNEL_FOLDER} , ver ${KERNELVER}. 139 | # (Update the variables below to reflect your settings and installation). 140 | # @@@@@ 141 | KERNELVER=6.1.25 142 | KERNEL_FOLDER=${STG}/linux-${KERNELVER}/ 143 | 144 | # @@@@@ 145 | # DTB: specify the Device Tree Blob .dtb 146 | # (Leave empty for the Aarch64 Qemu virt system) 147 | DTB_BLOB=vexpress-v2p-ca15_a7.dtb 148 | ##### 149 | 150 | # @@@@@ 151 | # SEALs kernel command-line 152 | SERIAL_CONSOLE=ttyAMA0 153 | SEALS_K_CMDLINE="console=${SERIAL_CONSOLE} root=/dev/mmcblk0 rw init=/sbin/init" 154 | # if 512M RAM, reserve 32M for crashk, else if 256M RAM, reserve 16M 155 | K_CMDLINE_XTRA="" 156 | #K_CMDLINE_XTRA="crashkernel=32M" # works with 32M not 16M [?] 157 | #K_CMDLINE_XTRA="initcall_debug ignore_loglevel debug" 158 | [ ! -z "${K_CMDLINE_XTRA}" ] && SEALS_K_CMDLINE="${SEALS_K_CMDLINE} ${K_CMDLINE_XTRA}" 159 | 160 | #--------BUSYBOX and ROOTFS------------------------------------------------------------ 161 | # Also under the ${STG} folder, we expect you have extracted the 162 | # source of busybox into the folder ${BB_FOLDER} ver ${BB_VER}. 163 | # (Update the variables below to reflect your settings and installation). 164 | # @@@@@ 165 | BB_FOLDER=${STG}/busybox # the src seems to reside only in the dir named 'busybox' and ! 'busybox-' 166 | SHELL2RUN=/bin/sh #/bin/bash 167 | 168 | ## RootFS 169 | # !Careful! Set to 1 to force a rebuild of the rootfs; implies OVERWRITING any 170 | # existing rootfs 171 | RFS_FORCE_REBUILD=0 172 | # Rootfs size: Recommendation: if using a kdump kernel, as a rough thumb rule, 173 | # make it ~ 150% of the size of RAM on the platform (so for eg. if the RAM is 512M, 174 | # make the rootfs size ~ >= 768 MB). 175 | # Else (no kdump), 512 MB is fine for the Vexpress. 176 | RFS_SZ_MB=512 177 | MYPRJ=myprj 178 | #------------------------------------------------------------------------------ 179 | 180 | #--------MISC / REMAINING Options------------------------------------------------------------ 181 | ##### Config vars for what to build 182 | # VAR=1 : 'do' the work 'VAR' 183 | # VAR=0 : 'do Not' do the work 'VAR' 184 | BUILD_KERNEL=0 185 | BUILD_ROOTFS=0 186 | GEN_EXT4_ROOTFS_IMAGE=0 187 | SAVE_BACKUP_IMG_CONFIGS=0 188 | RUN_QEMU=0 189 | #SHELL_PROMPT_STR="qarm64 \w # " 190 | 191 | ### "WIPE_*_CONFIG" directives 192 | # Set var to '1' implies any existing kernel configuration is wiped out. 193 | # Suggestion: set to '1' for the FIRST build with a clean kernel source tree.. 194 | # @@@@@ 195 | WIPE_KERNEL_CONFIG=0 196 | 197 | # Set var to '1' implies any existing busybox configuration is wiped out. 198 | # Suggestion: set to '1' for the FIRST build with a clean busybox source tree.. 199 | # @@@@@ 200 | WIPE_BUSYBOX_CONFIG=0 201 | 202 | # Set var to '1' implies that the busybox configuration will be set to have 203 | # all config options OFF/No by default. 204 | # Suggestion: set to '1' when you want an 'as tiny as possible' busybox binary 205 | # and know how to configure it 206 | # @@@@@ 207 | TINY_BUSYBOX_CONFIG=0 208 | 209 | ### 210 | # Config vars for when we run QEMU: 211 | KGDB_MODE=0 # make '1' to have qemu run w/ the '-S' switch (waits for gdb to 'connect') 212 | #------------------------------------------------------------------------------ 213 | 214 | #--- End build.config 215 | -------------------------------------------------------------------------------- /build.config.arm64_qemuvirt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ####################################################################### 3 | # build.config.arm64_qemuvirt 4 | # 5 | # Part of the SEALs project. 6 | # This is the configuration file; all config variables must go here. 7 | # 8 | # !! IMP NOTE TO THE END-USER OF THIS PROJECT !! 9 | # You are responsible for editing this configuration file, setting the 10 | # variables to sane values. 11 | # To help you out, the place in the source below which has the config 12 | # variables that you MUST update have been marked with a comment line 13 | # as follows: 14 | # # @@@@@ 15 | # So, you could just search for this string '@@@@@' (excluding the quotes of course), 16 | # and make sure you update the following config variable(s) to the sane value 17 | # for your box. 18 | # !! 19 | #--- 20 | # Author: Kaiwan N Billimoria 21 | # (C) kaiwanTECH 22 | #--- 23 | ####################################################################### 24 | # 25 | #---------------------- 26 | # !!!VERY IMPORTANT!!! 27 | #---------------------- 28 | # Pl read the documentation here, at least once: 29 | # https://github.com/kaiwan/seals/wiki 30 | #---------------------- 31 | # 32 | # Generic Config file. 33 | # For a minimal QEMU-ARM project, we Expect that: 34 | # 35 | # - an appropriate toolchain is installed and working, and setup in the config below 36 | # details: https://github.com/kaiwan/seals/wiki/HOWTO-Install-required-packages-on-the-Host-for-SEALS 37 | # - a recent version of the Linux kernel source tree is available and setup in the config below 38 | # - a recent version of busybox source tree is available and setup in the config below 39 | ############## 40 | 41 | set -a # auto export all vars 42 | 43 | #--------GENERIC CONFIG OPTIONS------------------------------------------------------------ 44 | ##################### UPDATE as required 45 | # @@@@@ 46 | CONFIG_NAME_STR="SEALs config file for generic AArch64 (ARM64) Virt system" 47 | COLOR=1 # terminal color support? Assume yes.. 48 | GUI_MODE=0 # auto-detects GUI / console mode 49 | DEBUG=0 # set to 1 to get debug messages displayed 50 | [ ${DEBUG} -eq 1 ] && export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' 51 | VERBOSE_MSG=0 # set to 1 to get more verbose messages displayed 52 | # [loglevel][date-timestamp] 53 | LOGFILE_COMMON=log_seals.txt 54 | 55 | ###------### 56 | TOPDIR=$(pwd) 57 | #------------------------------------------------------------------------------ 58 | 59 | #--------KEY DISK LOCATIONS and Settings--------------------------------------- 60 | ### Locations on Disk ### 61 | ### UPDATE ### on your system! 62 | # @@@@@ 63 | STG=$(realpath ./SEALS_staging/SEALS_staging_arm64_qemuvirt) 64 | # Recommendation: if running a cloud-sync service (like pCloud/Dropbox), keep the 65 | # staging area outside it. 66 | ROOTFS=${STG}/rootfs 67 | IMAGES_FOLDER=${STG}/images 68 | IMAGES_BKP_FOLDER=${STG}/images_bkp 69 | CONFIGS_FOLDER=${STG}/configs 70 | # Verbose build (for the kernel and busybox)? (if 1, we run as 'make V=1 ...') 71 | VERBOSE_BUILD=0 72 | #------------------------------------------------------------------------------ 73 | 74 | #--------'HARDWARE'------------------------------------------------------------ 75 | # SEALs (virtual) "Hardware" 76 | # @@@@@ 77 | # Select the CPU arch (to build the kernel for); the value to specify is the 78 | # name of the dir under /arch/XXX 79 | ARCH=arm64 80 | QEMUNAME=qemu-system-aarch64 81 | 82 | CPU_MODEL=cortex-a57 83 | SEALS_RAM=512 # MB 84 | 85 | # Select the platform (to build the kernel for). 86 | ARCH_PLATFORM="" 87 | # @@@@@ 88 | # English-like name 89 | ARM_PLATFORM_STR="Qemu Virt" 90 | 91 | # ! IMPORTANT ! 92 | # Selecting the platform varies with the ARCH: 93 | # ===> For Aarch32 (ARM): 94 | # Pl set the variable ARM_PLATFORM carefully; it will be used to setup 95 | # the inital config and is therefore very critical that it's given correctly: 96 | # make ARCH=arm ${ARM_PLATFORM}_defconfig 97 | # So, check under /arch//configs/ 98 | # for the best match to your platform, in the form 99 | # _defconfig 100 | # and put it here.. F.e.: 101 | #ARM_PLATFORM=vexpress-a9 102 | # 103 | # ===> For Aarch64 (arm64): 104 | # On Aarch64, all platforms will be selected by default. 105 | # (Can see them within the 'Platform selection' menu). 106 | # Either build it this way or deselect all and enable only the platform(s) you want to support... 107 | # So here, we leave the variable ARM_PLATFORM as NULL to fulfill the default case (all platforms) 108 | ARM_PLATFORM= 109 | 110 | # ARM_PLATFORM_OPT is the value passed via the -M (machine) switch to Qemu 111 | # Look for it via qemu-system-arm -M ? ; eg. 112 | # qemu-system-arm -M ? |grep -i "i.mx" 113 | ARM_PLATFORM_OPT=virt 114 | 115 | SMP_EMU_MODE=1 # make '1' to have qemu run w/ 4 emulated cores 116 | # (only works on appropriate h/w-emulated platforms) 117 | #------------------------------------------------------------------------------ 118 | 119 | 120 | # Okay, so under the ${STG} folder, we expect you have extracted the: 121 | 122 | #--------TOOLCHAIN------------------------------------------------------------ 123 | # The toolchain to use; expect that it is installed and the PATH is setup.. 124 | # @@@@@ 125 | CXX=aarch64-none-linux-gnu- # toolchain prefix 126 | # CXX_LOC is the location of the x86-to-ARM toolchain on disk 127 | # (used to setup the PATH and locate the ARM shared libraries within the toolchain) 128 | # @@@@@ 129 | CXX_LOC=~/tc/arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64-none-linux-gnu/bin/ 130 | # Keep your toolchain in the PATH 131 | PATH=$PATH:${CXX_LOC}/bin 132 | #------------------------------------------------------------------------------ 133 | 134 | #--------KERNEL------------------------------------------------------------ 135 | ### UPDATE ### on your system! 136 | # Okay, so under the ${STG} folder (or other), we expect you have extracted the 137 | # source of the Linux kernel into ${KERNEL_FOLDER} , ver ${KERNELVER}. 138 | # (Update the variables below to reflect your settings and installation). 139 | # @@@@@ 140 | KERNELVER=6.1.25 141 | KERNEL_FOLDER=${STG}/linux-${KERNELVER}/ 142 | 143 | # @@@@@ 144 | # DTB: specify the Device Tree Blob .dtb 145 | # (Leave empty for the Aarch64 Qemu virt system) 146 | DTB_BLOB= 147 | ##### 148 | 149 | # @@@@@ 150 | # SEALs kernel command-line 151 | SERIAL_CONSOLE=ttyAMA0 152 | SEALS_K_CMDLINE="console=${SERIAL_CONSOLE} root=/dev/vda rw init=/sbin/init" 153 | # if 512M RAM, reserve 32M for crashk, else if 256M RAM, reserve 16M 154 | K_CMDLINE_XTRA="" 155 | #K_CMDLINE_XTRA="crashkernel=32M" # works with 32M not 16M [?] 156 | #K_CMDLINE_XTRA="initcall_debug ignore_loglevel debug" 157 | [ ! -z "${K_CMDLINE_XTRA}" ] && SEALS_K_CMDLINE="${SEALS_K_CMDLINE} ${K_CMDLINE_XTRA}" 158 | 159 | #--------BUSYBOX and ROOTFS------------------------------------------------------------ 160 | # Also under the ${STG} folder, we expect you have extracted the 161 | # source of busybox into the folder ${BB_FOLDER} ver ${BB_VER}. 162 | # (Update the variables below to reflect your settings and installation). 163 | # @@@@@ 164 | BB_FOLDER=${STG}/busybox # with the GitHub ver 165 | SHELL2RUN=/bin/sh #/bin/bash 166 | 167 | ## RootFS 168 | # !Careful! Set to 1 to force a rebuild of the rootfs; implies OVERWRITING any 169 | # existing rootfs 170 | RFS_FORCE_REBUILD=0 171 | # Rootfs size: Recommendation: if using a kdump kernel, as a rough thumb rule, 172 | # make it ~ 150% of the size of RAM on the platform (so for eg. if the RAM is 512M, 173 | # make the rootfs size ~ >= 768 MB). 174 | # Else (no kdump), 512 MB is fine for the ARM-32 Vexpress. 175 | # Increase RFS size for the AArch64 (esp since modules can take up close to 250 MB!) 176 | RFS_SZ_MB=1024 177 | MYPRJ=myprj 178 | #------------------------------------------------------------------------------ 179 | 180 | #--------MISC / REMAINING Options------------------------------------------------------------ 181 | ##### Config vars for what to build 182 | # VAR=1 : 'do' the work 'VAR' 183 | # VAR=0 : 'do Not' do the work 'VAR' 184 | BUILD_KERNEL=0 185 | BUILD_ROOTFS=0 186 | GEN_EXT4_ROOTFS_IMAGE=0 187 | SAVE_BACKUP_IMG_CONFIGS=0 188 | RUN_QEMU=0 189 | #SHELL_PROMPT_STR="qarm64 \w # " 190 | 191 | ### "WIPE_*_CONFIG" directives 192 | # Set var to '1' implies any existing kernel configuration is wiped out. 193 | # Suggestion: set to '1' for the FIRST build with a clean kernel source tree.. 194 | # @@@@@ 195 | WIPE_KERNEL_CONFIG=0 196 | # Set var to '1' implies any existing busybox configuration is wiped out. 197 | # Suggestion: set to '1' for the FIRST build with a clean busybox source tree.. 198 | # @@@@@ 199 | WIPE_BUSYBOX_CONFIG=0 200 | # Set var to '1' implies that the busybox configuration will be set to have 201 | # all config options OFF/No by default. 202 | # Suggestion: set to '1' when you want an 'as tiny as possible' busybox binary 203 | # and know how to configure it 204 | # @@@@@ 205 | TINY_BUSYBOX_CONFIG=0 206 | 207 | ### 208 | # Config vars for when we run QEMU: 209 | KGDB_MODE=0 # make '1' to have qemu run w/ the '-S' switch (waits for gdb to 'connect') 210 | #------------------------------------------------------------------------------ 211 | 212 | #--- End build.config 213 | -------------------------------------------------------------------------------- /build.config.arm64_rpi3b_cm3: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ####################################################################### 3 | # build.config.arm64_rpi3b_cm3 4 | # 5 | # Part of the SEALs project. 6 | # This is the configuration file; all config variables must go here. 7 | # 8 | # !! IMP NOTE TO THE END-USER OF THIS PROJECT !! 9 | # You are responsible for editing this configuration file, setting the 10 | # variables to sane values. 11 | # To help you out, the place in the source below which has the config 12 | # variables that you MUST update have been marked with a comment line 13 | # as follows: 14 | # # @@@@@ 15 | # So, you could just search for this string '@@@@@' (excluding the quotes of course), 16 | # and make sure you update the following config variable(s) to the sane value 17 | # for your box. 18 | # !! 19 | #--- 20 | # Author: Kaiwan N Billimoria 21 | # (C) kaiwanTECH 22 | #--- 23 | ####################################################################### 24 | # 25 | #---------------------- 26 | # !!!VERY IMPORTANT!!! 27 | #---------------------- 28 | # Pl read the documentation here, at least once: 29 | # https://github.com/kaiwan/seals/wiki 30 | #---------------------- 31 | # 32 | # Generic Config file. 33 | # For a minimal QEMU-ARM project, we Expect that: 34 | # 35 | # - an appropriate toolchain is installed and working, and setup in the config below 36 | # details: https://github.com/kaiwan/seals/wiki/HOWTO-Install-required-packages-on-the-Host-for-SEALS 37 | # - a recent version of the Linux kernel source tree is available and setup in the config below 38 | # - a recent version of busybox source tree is available and setup in the config below 39 | ############## 40 | 41 | set -a # auto export all vars 42 | 43 | #--------GENERIC CONFIG OPTIONS------------------------------------------------------------ 44 | ##################### UPDATE as required 45 | # @@@@@ 46 | CONFIG_NAME_STR="SEALs config file for the Raspberry Pi 3B AArch64 (or RPi CM3 Compute Model 3)" 47 | COLOR=1 # terminal color support? Assume yes.. 48 | GUI_MODE=0 # auto-detects GUI / console mode 49 | DEBUG=0 # set to 1 to get debug messages displayed 50 | [ ${DEBUG} -eq 1 ] && export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' 51 | VERBOSE_MSG=0 # set to 1 to get more verbose messages displayed 52 | # [loglevel][date-timestamp] 53 | LOGFILE_COMMON=log_seals.txt 54 | 55 | ###------### 56 | TOPDIR=$(pwd) 57 | #------------------------------------------------------------------------------ 58 | 59 | #--------KEY DISK LOCATIONS and Settings--------------------------------------- 60 | ### Locations on Disk ### 61 | ### UPDATE ### on your system! 62 | # @@@@@ 63 | STG=$(realpath ~/seals_staging/seals_staging_rpi3b) 64 | STG=$(realpath ~/SEALS_staging/SEALS_staging_rpi3b_arm64) 65 | # Recommendation: if running a cloud-sync service (like Dropbox), keep the 66 | # staging area outside it. 67 | ROOTFS=${STG}/rootfs 68 | IMAGES_FOLDER=${STG}/images 69 | IMAGES_BKP_FOLDER=${STG}/images_bkp 70 | CONFIGS_FOLDER=${STG}/configs 71 | # Verbose build (for the kernel and busybox)? (if 1, we run as 'make V=1 ...') 72 | VERBOSE_BUILD=0 73 | #------------------------------------------------------------------------------ 74 | 75 | #--------'HARDWARE'------------------------------------------------------------ 76 | # SEALs (virtual) "Hardware" 77 | # @@@@@ 78 | # Select the CPU arch (to build the kernel for); the value to specify is the 79 | # name of the dir under /arch/XXX 80 | ARCH=arm64 81 | ARCH_PLATFORM="" 82 | QEMUNAME=qemu-system-aarch64 83 | 84 | CPU_MODEL=cortex-a53 85 | SEALS_RAM=1G 86 | 87 | # Select the platform (to build the kernel for). 88 | # @@@@@ 89 | # English-like name 90 | ARM_PLATFORM_STR="Qemu Rpi3B" 91 | 92 | # ! IMPORTANT ! 93 | # Selecting the platform varies with the ARCH: 94 | # ===> For Aarch32 (ARM): 95 | # Pl set the variable ARM_PLATFORM carefully; it will be used to setup 96 | # the inital config and is therefore very critical that it's given correctly: 97 | # make ARCH=arm ${ARM_PLATFORM}_defconfig 98 | # So, check under /arch//configs/ 99 | # for the best match to your platform, in the form 100 | # _defconfig 101 | # and put it here.. F.e.: 102 | #ARM_PLATFORM=vexpress-a9 103 | # 104 | # ===> For Aarch64 (arm64): 105 | # On Aarch64, all platforms will be selected by default. 106 | # (Can see them within the 'Platform selection' menu). 107 | # Either build it this way or deselect all and enable only the platform(s) you want to support... 108 | # So here, we leave the variable ARM_PLATFORM as NULL to fulfill the default case (all platforms) 109 | ARM_PLATFORM= 110 | 111 | # ARM_PLATFORM_OPT is the value passed via the -M (machine) switch to Qemu 112 | # Look for it via qemu-system-arm -M ? ; eg. 113 | # qemu-system-arm -M ? |grep -i "i.mx" 114 | ARM_PLATFORM_OPT=raspi3b 115 | 116 | SMP_EMU_MODE=0 # make '1' to have qemu run w/ 4 emulated cores 117 | # (only works on appropriate h/w-emulated platforms) 118 | #------------------------------------------------------------------------------ 119 | 120 | 121 | # Okay, so under the ${STG} folder, we expect you have extracted the: 122 | 123 | #--------TOOLCHAIN------------------------------------------------------------ 124 | # The toolchain to use; expect that it is installed and the PATH is setup.. 125 | # @@@@@ 126 | CXX=aarch64-none-linux-gnu- # toolchain prefix 127 | # CXX_LOC is the location of the x86-to-ARM toolchain on disk 128 | # (used to setup the PATH and locate the ARM shared libraries within the toolchain) 129 | # @@@@@ 130 | CXX_LOC=~/tc/arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64-none-linux-gnu/bin/ 131 | # Keep your toolchain in the PATH 132 | PATH=$PATH:${CXX_LOC}/bin 133 | #------------------------------------------------------------------------------ 134 | 135 | #--------KERNEL------------------------------------------------------------ 136 | ### UPDATE ### on your system! 137 | # Okay, so under the ${STG} folder (or other), we expect you have extracted the 138 | # source of the Linux kernel into ${KERNEL_FOLDER} , ver ${KERNELVER}. 139 | # (Update the variables below to reflect your settings and installation). 140 | # @@@@@ 141 | KERNELVER=6.1.25 142 | KERNEL_FOLDER=${STG}/linux-${KERNELVER}/ 143 | 144 | # @@@@@ 145 | # DTB: specify the Device Tree Blob .dtb 146 | # (Leave empty for the Aarch64 Qemu virt system) 147 | DTB_BLOB=broadcom/bcm2837-rpi-cm3-io3.dtb 148 | #DTB_BLOB=broadcom/bcm2837-rpi-3-b.dtb 149 | ##### 150 | 151 | # @@@@@ 152 | # SEALs kernel command-line 153 | SERIAL_CONSOLE=ttyAMA0 154 | SEALS_K_CMDLINE="console=${SERIAL_CONSOLE} root=/dev/mmcblk0 rw init=/sbin/init" 155 | # if 512M RAM, reserve 32M for crashk, else if 256M RAM, reserve 16M 156 | K_CMDLINE_XTRA="" 157 | #K_CMDLINE_XTRA="crashkernel=32M" # works with 32M not 16M [?] 158 | #K_CMDLINE_XTRA="initcall_debug ignore_loglevel debug" 159 | [ ! -z "${K_CMDLINE_XTRA}" ] && SEALS_K_CMDLINE="${SEALS_K_CMDLINE} ${K_CMDLINE_XTRA}" 160 | 161 | #--------BUSYBOX and ROOTFS------------------------------------------------------------ 162 | # Also under the ${STG} folder, we expect you have extracted the 163 | # source of busybox into the folder ${BB_FOLDER} ver ${BB_VER}. 164 | # (Update the variables below to reflect your settings and installation). 165 | # @@@@@ 166 | BB_FOLDER=${STG}/busybox # with the GitHub ver 167 | SHELL2RUN=/bin/sh #/bin/bash 168 | 169 | ## RootFS 170 | # !Careful! Set to 1 to force a rebuild of the rootfs; implies OVERWRITING any 171 | # existing rootfs 172 | RFS_FORCE_REBUILD=0 173 | # Rootfs size: Recommendation: if using a kdump kernel, as a rough thumb rule, 174 | # make it ~ 150% of the size of RAM on the platform (so for eg. if the RAM is 512M, 175 | # make the rootfs size ~ >= 768 MB). 176 | # Else (no kdump), 512 MB is fine for the Vexpress. 177 | RFS_SZ_MB=512 178 | MYPRJ=myprj 179 | #------------------------------------------------------------------------------ 180 | 181 | #--------MISC / REMAINING Options------------------------------------------------------------ 182 | ##### Config vars for what to build 183 | # VAR=1 : 'do' the work 'VAR' 184 | # VAR=0 : 'do Not' do the work 'VAR' 185 | BUILD_KERNEL=0 186 | BUILD_ROOTFS=0 187 | GEN_EXT4_ROOTFS_IMAGE=0 188 | SAVE_BACKUP_IMG_CONFIGS=0 189 | RUN_QEMU=0 190 | #SHELL_PROMPT_STR="qarm64 \w # " 191 | 192 | ### "WIPE_*_CONFIG" directives 193 | # Set var to 'y' implies any existing kernel configuration is wiped out. 194 | # Suggestion: set to 'y' for the FIRST build with a clean kernel source tree.. 195 | # @@@@@ 196 | WIPE_KERNEL_CONFIG=0 197 | 198 | # Set var to '1' implies any existing busybox configuration is wiped out. 199 | # Suggestion: set to '1' for the FIRST build with a clean busybox source tree.. 200 | # @@@@@ 201 | WIPE_BUSYBOX_CONFIG=0 202 | 203 | # Set var to '1' implies that the busybox configuration will be set to have 204 | # all config options OFF/No by default. 205 | # Suggestion: set to '1' when you want an 'as tiny as possible' busybox binary 206 | # and know how to configure it 207 | # @@@@@ 208 | TINY_BUSYBOX_CONFIG=0 209 | 210 | ### 211 | # Config vars for when we run QEMU: 212 | KGDB_MODE=0 # make '1' to have qemu run w/ the '-S' switch (waits for gdb to 'connect') 213 | #------------------------------------------------------------------------------ 214 | 215 | #--- End build.config 216 | -------------------------------------------------------------------------------- /build_SEALS.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # The SEALS Opensource Project 4 | # SEALS : Simple Embedded Arm Linux System 5 | # Author and Maintainer : Kaiwan N Billimoria 6 | # https://amazon.com/author/kaiwanbillimoria 7 | # Project URL: 8 | # https://github.com/kaiwan/seals 9 | #---------------------------------------------------------------------- 10 | # Important: 11 | # To get started, please read: 12 | # https://github.com/kaiwan/seals/wiki 13 | # (and follow the links on the right panel of the Wiki page). 14 | #---------------------------------------------------------------------- 15 | # A helper script designed to build: 16 | # a custom kernel + root filesystem for an "embedded" QEMU/ARM Linux system. 17 | # By default, this helper script uses the 'default config' found in the file 18 | # 'build.config'. For convenience, build.config is simply a soft (symbolic) link 19 | # to the actual config file (of the form build.config.FOO). 20 | # The build.config holds the configuration for building: 21 | # - a Linux kernel (+DTB) and root filesystem for: 22 | # - the ARM Versatile Express (Cortex-A9) platform (supported by Qemu). 23 | # By tweaking build.config , you can use the SEALS project to build something else.. 24 | #---------------------------------------------------------------------- 25 | # Cmdline: 26 | # ./build_seals.sh [-c] 27 | # -c : run in console mode only (no gui) [optional] 28 | # 29 | # Ref: 30 | # (old but still) very good References (by 'Balau'): 31 | # Kernel: 32 | # http://balau82.wordpress.com/2012/03/31/compile-linux-kernel-3-2-for-arm-and-emulate-with-qemu/ 33 | # [OLDer LINK]: http://balau82.wordpress.com/2010/03/22/compiling-linux-kernel-for-qemu-arm-emulator/ 34 | # Busybox: http://balau82.wordpress.com/2010/03/27/busybox-for-arm-on-qemu/ 35 | # 36 | # (c) Kaiwan N Billimoria 37 | # (c) kaiwanTECH 38 | # 39 | # License: MIT 40 | # 41 | # TODO / ISSUES 42 | # [ ] networking 43 | # ref- https://github.com/MichielDerhaeg/build-linux 44 | # [+] installer- for busybox & kernel source trees 45 | # [+] signals (like SIGINT ^C, SIGQUIT ^\, etc) not being handled within the Qemu guest ? 46 | # (Fix: use a console device ttyS0/ttyAMA0; see commit fd38085d05ea82e) 47 | # [+] GUI for target machine selection 48 | # [+] PC : AMD64 / x86_64 platform 49 | # [ ] Kernel 50 | # [ ] Do the kbuild outside k src tree (w/ the O=... ); 51 | # this way we can reuse the same k src tree for diff builds! 52 | # [ ] x86/pc: option to perform the 'localmodconfig' build (quicker) 53 | # [ ] Only GUI menu for target board selection; fix for console mode (in config_symlink_setup()) 54 | # [.] Testing/Q&A: Add test/ folder 55 | # [+] shellcheck 56 | # [+] for all boards: generate everything & run 57 | # [ ] Minor / various / misc 58 | # [ ] unattended run (non-interactive) 59 | # [ ] use sudo, not via wrapper mysudo 60 | # 61 | #---------------------------------------------------------------------- 62 | 63 | # Turn on Bash 'strict mode'! 64 | # ref: http://redsymbol.net/articles/unofficial-bash-strict-mode/ 65 | set -euo pipefail 66 | export name=$(basename $0) 67 | 68 | ############################# 69 | # ${BUILD_CONFIG_FILE} : a configuration script that specifies 70 | # folder locations, toolchain PATH, kernel & busybbox versions and locations, 71 | # memory sizes, any other configs as required. 72 | ############################# 73 | export BUILD_CONFIG_FILE=./build.config 74 | [[ ! -f ${BUILD_CONFIG_FILE} ]] && { 75 | echo " 76 | *** FATAL *** Couldn't find build.config 77 | 78 | Check: 79 | - Is the relevant board config file present? 80 | - Does the symbolic link 'build.config' point to it? 81 | 82 | Tip: If new to SEALS, we urge you, read the documentation here and then proceed: 83 | https://github.com/kaiwan/seals/wiki 84 | https://github.com/kaiwan/seals/wiki/SEALs-HOWTO" 85 | exit 1 86 | } 87 | source ${BUILD_CONFIG_FILE} || { 88 | echo "${name}: ${BUILD_CONFIG_FILE} missing, creating it (to the default platform, the AArch32 VExpress)" 89 | ln -sf build.config.arm32_vexpress build.config || exit 1 # set to default 90 | } 91 | source ./common.sh || { 92 | echo "${name}: source failed! ./common.sh missing or invalid?" 93 | exit 1 94 | } 95 | color_reset 96 | 97 | ### "Globals" 98 | export PRJ_TITLE="SEALS - Simple Embedded ARM Linux System" 99 | 100 | # Message strings 101 | export MSG_GIVE_PSWD_IF_REQD="If asked, please enter password" 102 | export MSG_EXITING=" 103 | All done, exiting. 104 | Thanks for using SEALS, hope you like it. 105 | Please do consider contributing your feedback, ideas, and code! 106 | https://github.com/kaiwan/seals" 107 | 108 | STEPS=5 109 | export CPU_CORES=$(getconf -a|grep _NPROCESSORS_ONLN|awk '{print $2}') 110 | [ -z "${CPU_CORES}" ] && CPU_CORES=2 111 | 112 | # Signals 113 | trap 'wecho "User Abort. ${MSG_EXITING}" ; dumpstack ; [ ${COLOR} -eq 1 ] && color_reset ; exit 2' HUP INT QUIT 114 | 115 | 116 | ##-------------------- Functions Start -------------------------------- 117 | 118 | kernel_uname_r() 119 | { 120 | # /lib/modules/`uname -r` required for rmmod to function 121 | # FIXME - when kernel ver has '-extra' it doesn't take it into account.. 122 | local KDIR=$(echo ${KERNELVER} | cut -d'-' -f2) 123 | # get the EXTRAVERSION component from the kernel config 124 | local XV=$(grep "^CONFIG_LOCALVERSION=" ${KERNEL_FOLDER}/.config |cut -d'=' -f2|tr -d '"') 125 | KDIR=${KDIR}${XV} 126 | echo "${KDIR}" 127 | } 128 | 129 | set_kernelimg_var() 130 | { 131 | # TODO : put this in individual build.config* files 132 | export KIMG=arch/${ARCH}/boot/zImage 133 | [ "${ARCH}" = "arm64" ] && KIMG=arch/${ARCH}/boot/Image.gz 134 | set +u 135 | [ "${ARCH_PLATFORM}" = "x86_64" ] && KIMG=arch/x86/boot/bzImage 136 | set -u 137 | #echo "@@@ KIMG = ${KIMG}" 138 | 139 | # Set the kernel modules install location 140 | # Careful! see https://www.kernel.org/doc/Documentation/kbuild/modules.txt 141 | # ... 142 | # A prefix can be added to the installation path using the variable INSTALL_MOD_PATH: 143 | # $ make INSTALL_MOD_PATH=/frodo modules_install 144 | # => Install dir: /frodo/lib/modules/$(KERNELRELEASE)/kernel/ 145 | # ... 146 | export KMODDIR=${ROOTFS_DIR} 147 | #echo "KMODDIR = ${KMODDIR}" 148 | 149 | # Device Tree Blob (DTB) pathname 150 | [[ "${ARCH_PLATFORM}" != "x86_64" ]] && \ 151 | export DTB_BLOB_PATHNAME=${KERNEL_FOLDER}/arch/${ARCH}/boot/dts/${DTB_BLOB} || true # gen within kernel src tree 152 | } 153 | 154 | install_kernel_modules() 155 | { 156 | # Have the kernel modules been generated? 157 | echo -n " 158 | Checking kernel modules ... " 159 | find ${KERNEL_FOLDER} -name "*.ko" >/dev/null 2>&1 || 160 | FatalError "Dependency: need to build+install the kernel+modules for correct root fs generation. 161 | Please enable the kernel build step and retry." 162 | echo "[Yes]" 163 | set_kernelimg_var 164 | echo "[+] Install kernel modules 165 | ( into dir: ${KMODDIR}/lib/modules/$(kernel_uname_r)/ )" 166 | 167 | [[ ! -d ${KMODDIR} ]] && mkdir -p ${KMODDIR} 168 | cd ${KERNEL_FOLDER} || FatalError "cd to kernel dir failed" 169 | sudo make INSTALL_MOD_PATH=${KMODDIR} modules_install || \ 170 | FatalError "Kernel modules install step failed; have you performed the kernel build step?" 171 | } 172 | 173 | # x86-64 only, and invoked only if USE_INITRAMFS=1 in the board config file 174 | setup_initramfs() 175 | { 176 | local INITRD=${ROOTFS_DIR}/initrd.img 177 | echo "[+] PC (x86-64/AMD64): Install initramfs (initrd)" 178 | [[ -z "${KMODDIR}" ]] && set_kernelimg_var 179 | hash mkinitramfs >/dev/null 2>&1 && { 180 | rm -f ${INITRD} 181 | echo "Generating (Ubuntu-flavor) initramfs image..." 182 | cd ${KERNEL_FOLDER} || FatalError "cd to kernel dir failed" 183 | mkinitramfs -o ${ROOTFS_DIR}/initrd.img || FatalError "failed to generate initramfs image" 184 | sudo chown root:root ${ROOTFS_DIR}/initrd.img 185 | cp -au ${ROOTFS_DIR}/initrd.img ${IMAGES_FOLDER}/ || FatalError "copying initrd to images failed?" 186 | ls -lh ${IMAGES_FOLDER}/initrd.img 187 | cd - 188 | } || FatalError "Cannot generate initramfs (mkinitramfs missing or it's not an Ubuntu build host?)" 189 | # TODO - Fedora/CentOS/RH - use mkinird 190 | 191 | echo "Installing boot files into the root fs..." 192 | sudo make INSTALL_PATH=${ROOTFS_DIR} install || FatalError "PC: 'sudo make install' step failed" 193 | } 194 | 195 | #------------------ b u i l d _ k e r n e l --------------------------- 196 | build_kernel() 197 | { 198 | report_progress 199 | local DIR=$(pwd) 200 | cd ${KERNEL_FOLDER} || FatalError "Couldn't cd to kernel source tree dir \"${KERNEL_FOLDER}\"" 201 | ShowTitle "KERNEL: Configure and Build [kernel ver ${KERNELVER}] now ..." 202 | 203 | if [ -z "${ARM_PLATFORM}" ] ; then # arm64 and x86_64 204 | PLATFORM=defconfig # by default all platforms selected 205 | else 206 | PLATFORM=${ARM_PLATFORM}_defconfig 207 | fi 208 | if [ ${WIPE_KERNEL_CONFIG} -eq 1 ]; then 209 | ShowTitle "Setting default kernel config" 210 | echo "make defconfig" 211 | make defconfig 212 | #make mrproper 213 | make V=${VERBOSE_BUILD} ARCH=${ARCH} ${PLATFORM} || \ 214 | FatalError "Kernel config for platform failed.." 215 | fi 216 | 217 | #set -x 218 | aecho "[Optional] Kernel Manual Configuration: 219 | Edit the kernel config as required, Save & Exit... 220 | " 221 | [ "${ARCH}" = "arm64" ] && aecho "TIP: On AArch64, with recent kernels, *all* platforms will be selected by default. 222 | (Can see them within the 'Platform selection' menu). 223 | Either build it this way or deselect all and enable only the platform(s) you want to support..." 224 | Prompt "" 225 | 226 | USE_QT=n # make 'y' to use a GUI Qt configure environment 227 | # if 'y', you'll require the Qt runtime installed.. 228 | if [ ${USE_QT} = "y" ]; then 229 | make V=${VERBOSE_BUILD} ARCH=${ARCH} xconfig || { 230 | FatalError "make xconfig failed.." 231 | } 232 | else 233 | make V=${VERBOSE_BUILD} ARCH=${ARCH} menuconfig || { 234 | FatalError "make menuconfig failed.." 235 | } 236 | fi 237 | 238 | # Tip- On many Ubuntu/Deb systems, we need to turn Off the 239 | # SYSTEM_REVOCATION_KEYS config option, else the build fails 240 | echo "[+] scripts/config --disable SYSTEM_REVOCATION_LISTS" 241 | scripts/config --disable SYSTEM_REVOCATION_LISTS || echo "Warning! Disabling SYSTEM_REVOCATION_LISTS failed" 242 | echo "[+] scripts/config --disable SYSTEM_REVOCATION_LIST" 243 | scripts/config --disable SYSTEM_REVOCATION_LIST || echo "Warning! Disabling SYSTEM_REVOCATION_LIST failed" 244 | echo "[+] scripts/config --disable SYSTEM_REVOCATION_KEYS" 245 | scripts/config --disable SYSTEM_REVOCATION_KEYS || echo "Warning! Disabling SYSTEM_REVOCATION_KEYS failed" 246 | echo "[+] scripts/config --disable WERROR" # turn off 'treat warnings as errors' 247 | scripts/config --disable WERROR || echo "Warning! Disabling WERROR failed" 248 | 249 | ShowTitle "Kernel Build:" 250 | 251 | #iecho "--- # detected CPU cores is ${CPU_CORES}" ; read 252 | CPU_OPT=$((${CPU_CORES}*2)) 253 | 254 | #Prompt 255 | # make all => kernel image, modules, dtbs (device-tree-blobs), ... - all will be built! 256 | local CMD="time make V=${VERBOSE_BUILD} -j${CPU_OPT} ARCH=${ARCH} CROSS_COMPILE=${CXX} all" 257 | set +u 258 | if [[ "${ARCH_PLATFORM}" = "x86_64" ]] ; then 259 | CMD="time make V=${VERBOSE_BUILD} -j${CPU_OPT}" 260 | fi 261 | set -u 262 | aecho "Doing: ${CMD}" 263 | eval ${CMD} || { 264 | FatalError "Kernel build failed! Aborting ..." 265 | } && true 266 | 267 | install_kernel_modules 268 | [[ "${ARCH_PLATFORM}" = "x86_64" && ${USE_INITRAMFS} -eq 1 ]] && setup_initramfs 269 | # echo "[-] Skipping initramfs generation" 270 | 271 | # Refresh our variables! 272 | set_kernelimg_var 273 | 274 | #echo "KIMG = ${KIMG}" 275 | ls -lh ${KIMG}* 276 | \cp -f ${KIMG}* ${DIR}/${IMAGES_FOLDER}/ || FatalError "copying kernel image failed" 277 | 278 | [[ "${ARCH_PLATFORM}" != "x86_64" && -f ${DTB_BLOB_PATHNAME} ]] && { 279 | echo; ls -lh ${DTB_BLOB_PATHNAME} 280 | cp -u ${DTB_BLOB_PATHNAME} ${IMAGES_FOLDER}/ || FatalError "copying DTB failed" 281 | } || true 282 | aecho "... and done." 283 | cd ${TOPDIR} 284 | } # end build_kernel() 285 | 286 | #--------------- b u i l d _ c o p y _ b u s y b o x ------------------ 287 | build_copy_busybox() 288 | { 289 | report_progress 290 | cd ${BB_FOLDER} || exit 1 291 | 292 | ShowTitle "BUSYBOX: Configure and Build Busybox now ... [$(basename ${BB_FOLDER})]" 293 | iecho " [Sanity chk: ROOTFS_DIR=${ROOTFS_DIR}]" 294 | # safety check! 295 | #if [ -z "${ROOTFS_DIR}" -o ! -d ${ROOTFS_DIR} -o "${ROOTFS_DIR}" = "/" ]; then 296 | [[ -z "${ROOTFS_DIR}" ]] && FatalError "SEALS: ROOTFS_DIR has dangerous value of null. Aborting..." 297 | [[ "${ROOTFS_DIR}" = "/" ]] && FatalError "SEALS: ROOTFS_DIR has dangerous value of /. Aborting..." 298 | #[[ ! -d "${ROOTFS_DIR}" ]] && FatalError "SEALS: ROOTFS_DIR is not a directory? Aborting..." 299 | 300 | if [ ${WIPE_BUSYBOX_CONFIG} -eq 1 ]; then 301 | ShowTitle "BusyBox default config:" 302 | make V=${VERBOSE_BUILD} ARCH=${ARCH} CROSS_COMPILE=${CXX} defconfig 303 | fi 304 | [[ ${TINY_BUSYBOX_CONFIG} -eq 1 ]] && { 305 | ShowTitle "BusyBox 'tiny' config - begin with all options set to No:" 306 | make V=${VERBOSE_BUILD} ARCH=${ARCH} CROSS_COMPILE=${CXX} allnoconfig 307 | } 308 | 309 | aecho "Edit the BusyBox config as required, Save & Exit..." 310 | Prompt " " ${MSG_EXITING} 311 | 312 | USE_QT=n # make 'y' to use a GUI Qt configure environment 313 | if [ ${USE_QT} = "y" ]; then 314 | make V=${VERBOSE_BUILD} ARCH=${ARCH} CROSS_COMPILE=${CXX} xconfig 315 | else 316 | make V=${VERBOSE_BUILD} ARCH=${ARCH} CROSS_COMPILE=${CXX} menuconfig 317 | fi 318 | 319 | # Ensure CONFIG_BASH_IS_ASH=y (so that we can run bash) 320 | sed -i '/# CONFIG_BASH_IS_ASH/d' .config 321 | cat >> .config << @MYMARKER@ 322 | CONFIG_BASH_IS_ASH=y 323 | @MYMARKER@ 324 | 325 | ShowTitle "BusyBox Build:" 326 | aecho "If prompted like this: 'Choose which shell is aliased to 'bash' name' 327 | select option 1 : ' 1. hush (BASH_IS_ASH)'" 328 | Prompt "" 329 | 330 | local CMD="time make V=${VERBOSE_BUILD} -j${CPU_CORES} ARCH=${ARCH} CROSS_COMPILE=${CXX} install" 331 | set +u 332 | if [[ "${ARCH_PLATFORM}" = "x86_64" ]] ; then 333 | CMD="time make V=${VERBOSE_BUILD} -j${CPU_CORES} install" 334 | fi 335 | set -u 336 | #set -x 337 | aecho "Doing: ${CMD}" 338 | eval ${CMD} || { 339 | FatalError "Building and/or Installing busybox failed!" 340 | } && true 341 | 342 | mysudo "SEALS Build:Step 1 of ${STEPS}: Copying of required busybox files. ${MSG_GIVE_PSWD_IF_REQD}" \ 343 | cp -af ${BB_FOLDER}/_install/* ${ROOTFS_DIR}/ || \ 344 | FatalError "Copying required folders from busybox _install/ failed! 345 | [Tip: Ensure busybox has been successfully built]. Aborting..." 346 | aecho "SEALS Build: busybox files copied across successfully ..." 347 | } # end build_copy_busybox() 348 | 349 | #---------- s e t u p _ e t c _ i n _ r o o t f s --------------------- 350 | setup_etc_in_rootfs() 351 | { 352 | report_progress 353 | cd ${ROOTFS_DIR} 354 | aecho "SEALS Build: Manually generating required SEALS rootfs /etc files ..." 355 | 356 | # /etc/inittab 357 | cat > etc/inittab << @MYMARKER@ 358 | ::sysinit:/etc/init.d/rcS 359 | #tty1::respawn:/sbin/getty 38400 tty1 360 | #::respawn:/sbin/getty 115200 ttyS0 361 | @MYMARKER@ 362 | 363 | # Using '${SERIAL_CONSOLE}::askfirst:...' ensures that 364 | # (a) the correct serial console (besides /dev/console ) is used allowing for signal handling ^C/^\/... 365 | # (btw, SERIAL_CONSOLE=ttyAMA0 or ttyS0 by default; it's in the build.config_foo file) 366 | # (b) 'askfirst' has it prompt for a shell & if Enter pressed it's spawned 367 | # Custom prompt str (PS1)! 368 | # Earlier ensured that CONFIG_BASH_IS_ASH=y (so that we can run bash) 369 | if [[ "${ARCH}" = "arm" ]]; then 370 | cat >> etc/inittab << @MYMARKER@ 371 | ${SERIAL_CONSOLE}::askfirst:env PS1='arm \w \$ ' ${SHELL2RUN} 372 | @MYMARKER@ 373 | # this one - rpi3b - should come before the 'arm64' one... 374 | elif [[ "${ARM_PLATFORM_STR}" = "Qemu Rpi3B" ]]; then 375 | cat >> etc/inittab << @MYMARKER@ 376 | ${SERIAL_CONSOLE}::askfirst:env PS1='rpi3b \w \$ ' ${SHELL2RUN} 377 | @MYMARKER@ 378 | elif [[ "${ARCH}" = "arm64" ]]; then 379 | cat >> etc/inittab << @MYMARKER@ 380 | ${SERIAL_CONSOLE}::askfirst:env PS1='arm64 \w \$ ' ${SHELL2RUN} 381 | @MYMARKER@ 382 | elif [[ "${ARCH_PLATFORM}" = "x86_64" ]]; then 383 | cat >> etc/inittab << @MYMARKER@ 384 | ${SERIAL_CONSOLE}::askfirst:env PS1='pc \w \$ ' ${SHELL2RUN} 385 | @MYMARKER@ 386 | fi 387 | 388 | cat >> etc/inittab << @MYMARKER@ 389 | ::restart:/sbin/init 390 | ::shutdown:/bin/umount -a -r 391 | @MYMARKER@ 392 | 393 | # rcS master script 394 | cat > etc/init.d/rcS << @MYMARKER@ 395 | echo "SEALS: /etc/init.d/rcS running now ..." 396 | /bin/mount -a 397 | ## remount / as rw; requires CONFIG_LBDAF (old stuff) 398 | #/bin/mount -o remount,rw / 399 | 400 | # networking : don't try until n/w is properly setup in SEALS 401 | #ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up 402 | 403 | # Misc 404 | if [ $(id -u) -eq 0 ]; then 405 | # guarantee all printk's appear on console device 406 | echo "7 4 1 7" > /proc/sys/kernel/printk 407 | # better core-file pathname 408 | echo "core_%h_%E_%p_%s_%u" > /proc/sys/kernel/core_pattern 409 | # Kexec (for kdump/crashkernel facility) 410 | if [ -x /kx.sh ]; then 411 | /kx.sh 412 | fi 413 | fi 414 | @MYMARKER@ 415 | 416 | chmod +x etc/init.d/rcS 417 | 418 | # etc/fstab 419 | # Ensure that procfs and sysfs are mounted. 420 | cat > etc/fstab << @MYMARKER@ 421 | # device directory type options 422 | none /proc proc nodev,noexec 423 | none /sys sysfs noexec 424 | none /sys/kernel/debug debugfs 425 | @MYMARKER@ 426 | } # end setup_etc_in_rootfs 427 | 428 | #-------- s e t u p _ l i b _ i n _ r o o t f s ----------------------- 429 | setup_lib_in_rootfs() 430 | { 431 | report_progress 432 | aecho "SEALS Build: copying across shared objects, etc to SEALS /lib /sbin /usr ..." 433 | 434 | if [[ "${ARCH_PLATFORM}" = "x86_64" ]] ; then 435 | #echo "@@@ x86-64 ROOTFS lib @@@" 436 | # if busybox built as a dynamic executable... requires: 437 | # linux-vdso.so.1 <---------- via kernel so ignore 438 | # libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 439 | # libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 440 | # libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 441 | # /lib64/ld-linux-x86-64.so.2 442 | 443 | # libgcc* ?? 444 | # busybox says 445 | #... 446 | # Static linking against glibc, can't use --gc-sections 447 | #Trying libraries: crypt m resolv rt 448 | # Library crypt is not needed, excluding it 449 | # Library m is needed, can't exclude it (yet) 450 | # Library resolv is needed, can't exclude it (yet) 451 | # Library rt is not needed, excluding it 452 | # Library m is needed, can't exclude it (yet) 453 | # Library resolv is needed, can't exclude it (yet) 454 | #Final link with: m resolv 455 | 456 | # Loader: /lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 457 | mkdir -p ${ROOTFS_DIR}/lib/x86_64-linux-gnu 458 | cp -au /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ${ROOTFS_DIR}/lib64/ || FatalError "copying ld-linux* failed" 459 | 460 | #cp -au /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ${ROOTFS_DIR}/lib/x86_64-linux-gnu/ 461 | 462 | # std c lib: libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 463 | cp -au /lib/x86_64-linux-gnu/libc.so.6 ${ROOTFS_DIR}/lib/x86_64-linux-gnu/ || FatalError "copying glibc failed" 464 | 465 | # libresolv 466 | cp -au /lib/x86_64-linux-gnu/libresolv.so.2 ${ROOTFS_DIR}/lib/x86_64-linux-gnu/ || FatalError "copying libresolv failed" 467 | 468 | # libm 469 | cp -au /lib/x86_64-linux-gnu/libm.so.6 ${ROOTFS_DIR}/lib/x86_64-linux-gnu/ || FatalError "copying libm failed" 470 | 471 | return 472 | fi 473 | 474 | #--- NON-X86 475 | 476 | # First, get the 'sysroot' from the compiler itself 477 | SYSROOT=${GCC_SYSROOT}/ 478 | echo "[Sanity check: 479 | ROOTFS_DIR=${ROOTFS_DIR} 480 | SYSROOT = ${SYSROOT} ]" 481 | 482 | set +u 483 | if [ -z "${SYSROOT}" -o ! -d ${SYSROOT} -o "${SYSROOT}" = "/" ]; then 484 | cd ${TOPDIR} 485 | FatalError "Toolchain shared library locations invalid (NULL or '/')? Aborting..." 486 | fi 487 | set -u 488 | 489 | # 'Which (shared) libraries do we copy into the rootfs?' 490 | # Quick solution: just copy _all_ the shared libraries, etc from the toolchain 491 | # into the rfs/lib. 492 | # EXCEPTION : the x86_64 493 | set +u 494 | if [[ "${ARCH_PLATFORM}" != "x86_64" ]] ; then 495 | mysudo "SEALS Build:Step 2 of ${STEPS}: [SEALS rootfs]:setup of library objects. ${MSG_GIVE_PSWD_IF_REQD}" \ 496 | cp -a ${SYSROOT}/lib/* ${ROOTFS_DIR}/lib || { 497 | FatalError "Copying required libs [/lib] from toolchain failed!" 498 | } 499 | mysudo "SEALS Build:Step 3 of ${STEPS}: [SEALS rootfs]:setup of /sbin. ${MSG_GIVE_PSWD_IF_REQD}" \ 500 | cp -a ${SYSROOT}/sbin/* ${ROOTFS_DIR}/sbin || { 501 | FatalError "Copying required libs [/sbin] from toolchain failed!" 502 | } 503 | mysudo "SEALS Build:Step 4 of ${STEPS}: [SEALS rootfs]:setup of /usr. ${MSG_GIVE_PSWD_IF_REQD}" \ 504 | cp -a ${SYSROOT}/usr/* ${ROOTFS_DIR}/usr || { 505 | FatalError "Copying required libs [/sbin] from toolchain failed!" 506 | } 507 | sudo mkdir -p ${ROOTFS_DIR}/lib64 || true 508 | mysudo "SEALS Build:Step 4.2 of ${STEPS}: [SEALS rootfs]:setup of /lib64. ${MSG_GIVE_PSWD_IF_REQD}" \ 509 | cp -a ${SYSROOT}/lib64/* ${ROOTFS_DIR}/lib64 || { 510 | FatalError "Copying required libs [/sbin] from toolchain failed!" 511 | } 512 | mysudo "SEALS Build:Step 4.3 of ${STEPS}: [SEALS rootfs]:setup of /var. ${MSG_GIVE_PSWD_IF_REQD}" \ 513 | cp -a ${SYSROOT}/var/* ${ROOTFS_DIR}/var || { 514 | FatalError "Copying required libs [/sbin] from toolchain failed!" 515 | } 516 | # RELOOK: 517 | # $ ls rootfs/usr/ 518 | # bin/ include/ lib/ libexec/ sbin/ share/ 519 | # $ 520 | # usr/include - not really required? 521 | fi 522 | } # end setup_lib_in_rootfs 523 | 524 | #------ s e t u p _ d e v _ i n _ r o o t f s ------------------------- 525 | setup_dev_in_rootfs() 526 | { 527 | report_progress 528 | #---------- Device Nodes [static only] 529 | aecho "SEALS Build: Manually generating required Device Nodes in /dev ..." 530 | cd ${ROOTFS_DIR}/dev 531 | 532 | cat > mkdevtmp.sh << @MYMARKER@ 533 | #!/bin/sh 534 | rm -f * 535 | 536 | mknod -m 600 mem c 1 1 537 | mknod -m 600 kmem c 1 2 538 | mknod -m 666 null c 1 3 539 | mknod -m 666 zero c 1 5 540 | mknod -m 644 random c 1 8 541 | mknod -m 644 urandom c 1 9 542 | 543 | mknod -m 666 tty c 5 0 544 | mknod -m 666 tty0 c 4 0 545 | mknod -m 666 tty1 c 4 1 546 | mknod -m 666 tty2 c 4 2 547 | mknod -m 666 tty3 c 4 3 548 | mknod -m 666 tty4 c 4 4 549 | mknod -m 666 console c 5 1 550 | mknod -m 666 ttyS0 c 4 64 551 | mknod -m 666 ttyAMA0 c 204 64 552 | mknod -m 660 fb0 c 29 0 553 | 554 | mknod -m 660 ram b 1 0 555 | mknod -m 660 loop b 7 0 556 | mknod -m 640 mmcblk0 b 179 0 557 | 558 | mknod -m 660 hda b 3 0 559 | mknod -m 660 sda b 8 0 560 | 561 | # FIXME / TODO :: FAILS 562 | ## recommended slinks 563 | #ln -s /proc/self/fd fd 564 | #ln -s /proc/self/fd/0 stdin 565 | #ln -s /proc/self/fd/1 stdout 566 | #ln -s /proc/self/fd/2 stderr 567 | @MYMARKER@ 568 | 569 | chmod u+x ${ROOTFS_DIR}/dev/mkdevtmp.sh 570 | mysudo "SEALS Build:Step 5 of ${STEPS}: [SEALS rootfs]:setup of device nodes. ${MSG_GIVE_PSWD_IF_REQD}" \ 571 | ${ROOTFS_DIR}/dev/mkdevtmp.sh || { 572 | rm -f mkdevtmp.sh 573 | FatalError "Setup of device nodes failed!" 574 | } 575 | rm -f mkdevtmp.sh 576 | } # end setup_dev_in_rootfs 577 | 578 | #---------- r o o t f s _ x t r a s ----------------------------------- 579 | rootfs_xtras() 580 | { 581 | report_progress 582 | # To be copied into the RFS..any special cases 583 | # strace, tcpdump, gdb[server], misc scripts (strace, gdb copied from buildroot build) 584 | 585 | # Copy configs into the rootfs 586 | mkdir -p ${ROOTFS_DIR}/configs 2>/dev/null 587 | [[ -f ${KERNEL_FOLDER}/.config ]] && cp ${KERNEL_FOLDER}/.config ${ROOTFS_DIR}/configs/kernel_config 588 | [[ -f ${BB_FOLDER}/.config ]] && cp ${BB_FOLDER}/.config ${ROOTFS_DIR}/configs/busybox_config 589 | 590 | if [ -d ${TOPDIR}/xtras ]; then 591 | aecho "SEALS Build: Copying 'xtras' (goodies!) into the root filesystem..." 592 | cd ${TOPDIR}/xtras 593 | 594 | [ -f strace ] && cp strace ${ROOTFS_DIR}/usr/bin 595 | [ -f tcpdump ] && cp tcpdump ${ROOTFS_DIR}/usr/sbin 596 | 597 | # for gdb on-board, we need libncurses* & libz* (for gdb v7.1) 598 | mkdir -p ${ROOTFS_DIR}/usr/lib 599 | cp -a libncurses* libz* ${ROOTFS_DIR}/usr/lib 600 | [ -f gdb ] && cp gdb ${ROOTFS_DIR}/usr/bin 601 | 602 | # misc 603 | [ -f 0setup ] && cp 0setup ${ROOTFS_DIR}/ 604 | [ -f procshow.sh ] && chmod +x procshow.sh 605 | #cp common.sh procshow.sh pidshow.sh ${ROOTFS_DIR}/${MYPRJ} 606 | 607 | # useful for k debug stuff 608 | cp ${KERNEL_FOLDER}/System.map ${ROOTFS_DIR}/ 609 | fi 610 | } # end rootfs_xtras 611 | 612 | # r o o t f s _ d i r s ( ) 613 | # Create the minimal rootfs directories 614 | rootfs_dirs() 615 | { 616 | cd ${ROOTFS_DIR} 617 | mkdir -p dev etc/init.d lib lib64 ${MYPRJ} proc root/dev run srv sys tmp 2>/dev/null || true 618 | chmod 1777 tmp || true 619 | chmod 0700 root || true 620 | rmdir home/root 2>/dev/null || true 621 | } 622 | 623 | #------------------ b u i l d _ r o o t f s --------------------------- 624 | # 625 | # NOTE: The root filesystem is now populated in the ${ROOTFS_DIR} folder under ${TOPDIR} 626 | # 627 | build_rootfs() 628 | { 629 | report_progress 630 | # First reset the 'rootfs' staging area so that regular user can update 631 | mysudo "SEALS Build: reset SEALS root fs. ${MSG_GIVE_PSWD_IF_REQD}" \ 632 | chown -R ${LOGNAME}:${LOGNAME} ${ROOTFS_DIR}/* 633 | 634 | #---------Generate necessary pieces for the rootfs 635 | build_copy_busybox 636 | rootfs_dirs 637 | setup_etc_in_rootfs 638 | setup_lib_in_rootfs 639 | setup_dev_in_rootfs 640 | rootfs_xtras 641 | #else 642 | # pc_build_rootfs_debootstrap 643 | 644 | aecho "SEALS Build: enable final setup of SEALS root fs. ${MSG_GIVE_PSWD_IF_REQD}" 645 | sudo chown -R root:root ${ROOTFS_DIR}/* || FatalError "SEALS Build: chown on ${ROOTFS_DIR}/ failed!" 646 | 647 | cd ${TOPDIR}/ 648 | ShowTitle "Done! Platform root filesystem toplevel content follows:" 649 | ls -lh ${ROOTFS_DIR}/ 650 | local RFS_ACTUAL_SZ_MB=$(du -ms ${ROOTFS_DIR}/ 2>/dev/null |awk '{print $1}') 651 | aecho "SEALS root fs: actual size = ${RFS_ACTUAL_SZ_MB} MB" 652 | } # end build_rootfs() 653 | 654 | #------- g e n e r a t e _ r o o t f s _ i m g _ e x t 4 -------------- 655 | generate_rootfs_img_ext4() 656 | { 657 | report_progress 658 | cd ${ROOTFS_DIR} || FatalError "generate_rootfs_img_ext4(): cd failed" 659 | 660 | ShowTitle "SEALS ROOT FS: Generating ext4 image for root fs now:" 661 | 662 | # RFS should be the final one ie the one in images/ 663 | local RFS=${IMAGES_FOLDER}/rfs.img 664 | local MNTPT=/mnt/tmp 665 | # Size of the rootfs 'file' is in the build.config file 666 | local COUNT=$((${RFS_SZ_MB}*256)) # for given blocksize (bs) of 4096 667 | 668 | [ ! -d ${MNTPT} ] && { 669 | mysudo "SEALS Build: root fs image generation: enable mount dir creation. ${MSG_GIVE_PSWD_IF_REQD}" \ 670 | mkdir -p ${MNTPT} 671 | } 672 | # If config option RFS_FORCE_REBUILD is set -OR- the RootFS file does not exist, 673 | # create from scratch. If it does exist, just loop mount and update. 674 | if [ ${RFS_FORCE_REBUILD} -eq 1 -o ! -f ${RFS} ]; then 675 | aecho "SEALS Build: *** Deleting and re-creating raw RFS image file now *** [dd, mkfs.ext4]" 676 | rm -f ${RFS} 677 | dd if=/dev/zero of=${RFS} bs=4096 count=${COUNT} 678 | mysudo "SEALS Build: root fs image generation (via mkfs). ${MSG_GIVE_PSWD_IF_REQD}" \ 679 | mkfs.ext4 -F -L qemu_rfs_SEALS ${RFS} || FatalError "mkfs failed!" 680 | fi 681 | 682 | # Keep FORCE_RECREATE_RFS to 0 by default!! 683 | # Alter at your Own Risk!! 684 | local FORCE_RECREATE_RFS=0 685 | 686 | sync 687 | mysudo "SEALS Build: root fs image generation: enable umount. ${MSG_GIVE_PSWD_IF_REQD}" \ 688 | umount ${MNTPT} 2>/dev/null 689 | mysudo "SEALS Build: root fs image generation: enable mount. ${MSG_GIVE_PSWD_IF_REQD}" \ 690 | mount -o loop ${RFS} ${MNTPT} || { 691 | wecho "### $name: !WARNING! Loop mounting rootfs image file Failed! ###" 692 | if [ ${FORCE_RECREATE_RFS} -eq 0 ]; then 693 | aecho "-- Aborting this function! --" 694 | aecho "To *force* root filesystem creation by deleting current RFS, set" 695 | aecho "the FORCE_RECREATE_RFS in the script to 1." 696 | return 697 | else 698 | wecho " 699 | ### $name: !WARNING! FORCE_RECREATE_RFS flag is non-zero! Now *deleting* current RFS image and re-creating it... 700 | " 701 | rm -f ${RFS} 2>/dev/null 702 | #dd if=/dev/zero of=${RFS} bs=4096 count=16384 703 | dd if=/dev/zero of=${RFS} bs=4096 count=${COUNT} 704 | mysudo "SEALS Build: root fs image generation: enable mkfs (in force_recreate_rfs). ${MSG_GIVE_PSWD_IF_REQD}" \ 705 | mkfs.ext4 -F -L qemu_rfs_SEALS ${RFS} || exit 1 706 | mysudo "SEALS Build: root fs image generation: enable mount (in force_recreate_rfs). ${MSG_GIVE_PSWD_IF_REQD}" \ 707 | mount -o loop ${RFS} ${MNTPT} || { 708 | FatalError " !!! The loop mount RFS failed Again !!! Wow. Too bad. See ya :-/" 709 | } 710 | fi 711 | } 712 | 713 | aecho " Now copying across all rootfs data to ${RFS} ..." 714 | sudo cp -au ${ROOTFS_DIR}/* ${MNTPT}/ || FatalError "Copying all rootfs content failed" 715 | 716 | mysudo "SEALS Build: root fs image generation: enable unmount. ${MSG_GIVE_PSWD_IF_REQD}" \ 717 | umount ${MNTPT} 718 | sync 719 | ls -lh ${RFS} 720 | aecho "... and done." 721 | cd ${TOPDIR} 722 | } # end generate_rootfs_img_ext4() 723 | 724 | #-------- s a v e _ i m a g e s _ c o n f i g s ----------------------- 725 | # fn to place final images in images/ and save imp config files as well... 726 | save_images_configs() 727 | { 728 | report_progress 729 | ShowTitle "BACKUP: kernel, busybox images and config files now (as necessary) ..." 730 | cd ${TOPDIR} 731 | set_kernelimg_var 732 | unalias cp 2>/dev/null || true 733 | 734 | cp -afu ${IMAGES_FOLDER}/ ${IMAGES_BKP_FOLDER} || FatalError "copying images to backup folder failed" 735 | # backup! 736 | cp -u ${KERNEL_FOLDER}/${KIMG} ${IMAGES_FOLDER}/ || FatalError "copying kernel image to backup folder failed" 737 | [ -f ${DTB_BLOB_PATHNAME} ] && cp -u ${DTB_BLOB_PATHNAME} ${IMAGES_FOLDER}/ || true 738 | cp ${KERNEL_FOLDER}/.config ${CONFIGS_FOLDER}/kernel_config || FatalError "copying k config to backup folder failed" 739 | cp ${BB_FOLDER}/.config ${CONFIGS_FOLDER}/busybox_config || FatalError "copying bb config to backup folder failed" 740 | 741 | aecho " ... and done." 742 | } # end save_images_configs() 743 | 744 | #-------------- r u n _ q e m u _ S E A L S --------------------------- 745 | # Wrapper over the run-qemu.sh script 746 | run_qemu_SEALS() 747 | { 748 | [[ ! -f ${TOPDIR}/run-qemu.sh ]] && { 749 | FatalError "run script run-qemu.sh not found? Aborting..." 750 | } 751 | ${TOPDIR}/run-qemu.sh 0 752 | } # end run_qemu_SEALS() 753 | 754 | #------ s e a l s _ m e n u _ c o n s o l e m o d e ------------------- 755 | seals_menu_consolemode() 756 | { 757 | report_progress 758 | becho "SEALS :: Console Menu 759 | " 760 | 761 | # get_yn_reply() returns 0 on 'y', 1 on 'n' answer 762 | get_yn_reply "1. Build Linux kernel? : " y 763 | [ $? -eq 0 ] && BUILD_KERNEL=1 764 | # First-time kernel build? then ensure config is wiped 765 | [ ! -f ${KERNEL_FOLDER}/vmlinux ] && { 766 | echo "First-time kernel build (?), recommend keeping wipe-config On" 767 | } 768 | get_yn_reply " a) Wipe Linux kernel current configuration clean? : " n 769 | [ $? -eq 0 ] && WIPE_KERNEL_CONFIG=1 || WIPE_KERNEL_CONFIG=0 770 | 771 | get_yn_reply "2. Build Root Filesystem? : " y 772 | [ $? -eq 0 ] && BUILD_ROOTFS=1 773 | 774 | # First-time busybox build? then ensure config is wiped 775 | [ ! -d ${BB_FOLDER}/_install ] && { 776 | echo "First-time busybox build (?), recommend keeping wipe-config On" 777 | } 778 | get_yn_reply " a) Wipe Busybox current configuration clean? : " n 779 | [ $? -eq 0 ] && WIPE_BUSYBOX_CONFIG=1 || WIPE_BUSYBOX_CONFIG=0 780 | get_yn_reply " a) Set all Busybox config options to Off/No by default? : " n 781 | [ $? -eq 0 ] && TINY_BUSYBOX_CONFIG=1 || TINY_BUSYBOX_CONFIG=0 782 | 783 | get_yn_reply " b) Generate Root Filesystem ext4 image? [y/n] : " y 784 | [ $? -eq 0 ] && GEN_EXT4_ROOTFS_IMAGE=1 785 | get_yn_reply "3. Backup kernel & busybox images & configs? [y/n] : " y 786 | [ $? -eq 0 ] && SAVE_BACKUP_IMG_CONFIGS=1 787 | get_yn_reply "4. Run emulated system with Qemu? [y/n] : " y 788 | [ $? -eq 0 ] && RUN_QEMU=1 789 | } # end seals_menu_consolemode() 790 | 791 | display_current_config() 792 | { 793 | report_progress 794 | 795 | echo -n " Build kernel :: " 796 | yesorno_color ${BUILD_KERNEL} 797 | 798 | echo -n " Wipe kernel config clean :: " 799 | yesorno_color ${WIPE_KERNEL_CONFIG} 800 | 801 | echo -n " Build Root Filesystem :: " 802 | yesorno_color ${BUILD_ROOTFS} 803 | 804 | echo -n " Wipe busybox config clean :: " 805 | yesorno_color ${WIPE_BUSYBOX_CONFIG} 806 | echo -n " Tiny busybox config :: " 807 | yesorno_color ${TINY_BUSYBOX_CONFIG} 808 | 809 | echo -n " Generate rootfs ext4 image :: " 810 | yesorno_color ${GEN_EXT4_ROOTFS_IMAGE} 811 | 812 | echo -n " Backup kernel & rootfs images/configs :: " 813 | yesorno_color ${SAVE_BACKUP_IMG_CONFIGS} 814 | 815 | echo -n " Run the Qemu emulator :: " 816 | yesorno_color ${RUN_QEMU} 817 | } 818 | 819 | # Set up the config.build symbolic (soft) link to point to the appropriate platform build.config. file 820 | config_symlink_setup() 821 | { 822 | aecho "config_symlink_setup()" 823 | # Match the current config to set it to selected state 824 | #set -x 825 | local arm32_vexpress_state=False arm64_qemuvirt_state=False arm64_rpi3b_cm3_state=False amd64_state=False 826 | local CONFIG_CURR="$(basename "$(realpath ${BUILD_CONFIG_FILE})")" 827 | local CONFIG_FILE=$(ls "${CONFIG_CURR}") 828 | [[ -z "${CONFIG_FILE}" ]] && FatalError "Couldn't get config file" || true 829 | 830 | case "${CONFIG_FILE}" in 831 | build.config.arm32_vexpress) arm32_vexpress_state=True ;; 832 | build.config.arm64_qemuvirt) arm64_qemuvirt_state=True ;; 833 | build.config.arm64_rpi3b_cm3) arm64_rpi3b_cm3_state=True ;; 834 | build.config.amd64) amd64_state=True ;; 835 | esac 836 | 837 | # Fmt of radio btn: Bool "label str" value_when_selected 838 | local OUT=$(yad --on-top --center --title "Select the target machine to deploy via Qemu; press Esc / Cancel to keep the current one, or select a new target platform to build" \ 839 | --width 500 --height 210 \ 840 | --text "The current machine is the one that's now selected; press Esc / Cancel to keep the current one, or select a new target platform to build" \ 841 | --list --radiolist --columns=3 \ 842 | --column " Select " --column " Machine " --column " Machine number - Do Not Display":HD \ 843 | ${arm32_vexpress_state} "ARM-32 Versatile Express (vexpress-cortex a15)" arm32_vexpress \ 844 | ${arm64_qemuvirt_state} "ARM-64 Qemu Virt" arm64_qemuvirt \ 845 | ${arm64_rpi3b_cm3_state} "ARM-64 Raspberry Pi 3B (CM3)" arm64_rpi3b_cm3 \ 846 | ${amd64_state} "PC (x86_64 or AMD64) Qemu Standard PC (i440FX + PIIX, 1996)" amd64 \ 847 | --print-column=2 --print-column 3 \ 848 | --buttons-layout=center --button="Select":2 --button=gtk-cancel:1) 849 | 850 | if [ -z "${OUT}" -o $? = "1" ]; then return; fi; # Cancel clicked (or Esc); keep current m/c and return 851 | 852 | # Retrieve the just-selected machine 853 | local TARGET MACH=$(echo ${OUT} | cut -d '|' -f1) MACH_STR 854 | local MACH_CURR=$(echo ${CONFIG_CURR} |cut -d'.' -f3) 855 | # Short circuit, return if it's the same machine that's selected 856 | if [ "${MACH}" = "${MACH_CURR}" ]; then return; fi; 857 | 858 | # (Re)create the build.config soft link to point to the selected machine's config file 859 | # ln [OPTION]... [-T] TARGET LINK_NAME 860 | case "${MACH}" in 861 | arm32_vexpress) TARGET=build.config.arm32_vexpress 862 | MACH_STR="AArch32: ARM Versatile Express for Cortex-A15" ;; 863 | arm64_qemuvirt) TARGET=build.config.arm64_qemuvirt 864 | MACH_STR="AArch64: (ARM-64) Qemu Virtual Machine" ;; 865 | arm64_rpi3b_cm3) TARGET=build.config.arm64_rpi3b_cm3 866 | MACH_STR="AArch32: Raspberry Pi 3B" ;; 867 | amd64) TARGET=build.config.amd64 868 | MACH_STR="x86-64 or AMD64: Qemu Standard PC (i440FX + PIIX, 1996)" ;; 869 | esac 870 | [[ ! -f ${TARGET} ]] && FatalError "Couldn't find the required build.config file : ${TARGET}" 871 | ln -sf ${TARGET} build.config || FatalError "Couldn't setup new build.config symlink" 872 | sync ; sleep .5 # ? but it MUST be refreshed via the 'source ${BUILD_CONFIG_FILE}' below... 873 | BUILD_CONFIG_FILE=$(realpath ./build.config) 874 | [[ ! -f ${BUILD_CONFIG_FILE} ]] && FatalError "Couldn't setup new build.config (is the relevant config file present?)" 875 | # IMP : Must refresh (source) the newly selected config 876 | # Side effect: GUI_MODE can get reset to 0; so do a save & restore 877 | local saved_guimode=${GUI_MODE} 878 | source ${BUILD_CONFIG_FILE} || echo "*Warning* Couldn't source the just-set build.config file ${BUILD_CONFIG_FILE}" 879 | GUI_MODE=${saved_guimode} 880 | 881 | yad --center --title "Target Machine Confirmation" --text-info \ 882 | --text="CONFIRM :: Target machine is now set to ${MACH_STR}" \ 883 | --width 500 --height 50 \ 884 | --wrap --justify=center --button=OK:0 885 | #set +x 886 | } 887 | 888 | #---------- c o n f i g _ s e t u p ----------------------------------- 889 | # config_setup 890 | # Based on values in the build.config file, 891 | # display the current configurables, and, 892 | # allow the end-user to _change_ what is done by the script now. 893 | # The change applies ONLY for this run, i.e., it is volatile and NOT 894 | # written into the build.config file. 895 | # Parameters: 896 | # -none- 897 | config_setup() 898 | { 899 | local msg1="" 900 | local gccver=$(${CXX}gcc --version |head -n1 |cut -f2- -d" ") 901 | 902 | report_progress 903 | 904 | msg1=" 905 | Config file : ${BUILD_CONFIG_FILE} -> $(basename "$(realpath ${BUILD_CONFIG_FILE})")\ 906 | [edit it to change any settings shown below] 907 | Config name : ${CONFIG_NAME_STR} 908 | 909 | Toolchain prefix : ${CXX} 910 | Toolchain version: ${gccver} 911 | Staging folder : ${STG} 912 | 913 | CPU Arch : ${ARCH} 914 | ARM Platform : ${ARM_PLATFORM_STR} 915 | Platform RAM : ${SEALS_RAM} MB 916 | 917 | RootFS force rebuild : ${RFS_FORCE_REBUILD} 918 | RootFS size : ${RFS_SZ_MB} MB [note: new size applied only on 'RootFS force rebuild' being True (1)] 919 | 920 | Linux kernel to use : ${KERNELVER} 921 | Linux kernel codebase location : ${KERNEL_FOLDER} 922 | Kernel command-line : \"${SEALS_K_CMDLINE}\" 923 | 924 | Verbose Build : ${VERBOSE_BUILD} 925 | 926 | Busybox location: ${BB_FOLDER} 927 | 928 | Qemu: KGDB mode: ${KGDB_MODE} | SMP mode: ${SMP_EMU_MODE} 929 | 930 | Diplay: 931 | Terminal Colors mode: ${COLOR} | DEBUG mode: ${DEBUG} | VERBOSE mode: ${VERBOSE_MSG} 932 | Log file : ${LOGFILE_COMMON}" 933 | 934 | local msg1_2=" 935 | ------------------------------------------------------------- 936 | To change any of the above configs, abort now and edit the 937 | config file: ${BUILD_CONFIG_FILE} 938 | -------------------------------------------------------------- " 939 | 940 | # Same message text for the yad GUI display - font attributes are added on... 941 | # !NOTE! !Keep them - msg1 and msg1_yad - in SYNC! 942 | local msg1_yad="\ 943 | SEALS Config :: Please Review Carefully\ 944 | 945 | 946 | Config file : ${BUILD_CONFIG_FILE} -> $(basename "$(realpath ${BUILD_CONFIG_FILE})")\ 947 | [edit it to change any settings shown below] 948 | Config name : ${CONFIG_NAME_STR}\ 949 | 950 | Staging folder : ${STG} 951 | \ 952 | Toolchain prefix : ${CXX} 953 | Toolchain version: ${gccver} 954 | \ 955 | CPU Arch : ${ARCH} 956 | ARM Platform : ${ARM_PLATFORM_STR} 957 | Platform RAM : ${SEALS_RAM} MB 958 | \ 959 | RootFS force rebuild : ${RFS_FORCE_REBUILD} 960 | RootFS size : ${RFS_SZ_MB} MB [note: new size applied only on 'RootFS force rebuild' being True (1)] 961 | \ 962 | Linux kernel to use : ${KERNELVER} 963 | Linux kernel codebase location : ${KERNEL_FOLDER} 964 | Kernel command-line : \"${SEALS_K_CMDLINE}\" 965 | Verbose Build : ${VERBOSE_BUILD} 966 | \ 967 | Busybox location: ${BB_FOLDER} 968 | \ 969 | Qemu: KGDB mode: ${KGDB_MODE} | SMP mode: ${SMP_EMU_MODE} 970 | \ 971 | Diplay: 972 | Terminal Colors mode: ${COLOR} | DEBUG mode: ${DEBUG} | VERBOSE mode: ${VERBOSE_MSG} 973 | \ 974 | Log file : ${LOGFILE_COMMON} 975 | 976 | To change any of these, please abort now, edit the config file ${BUILD_CONFIG_FILE} \ 977 | appropriately, and rerun.\ 978 | 979 | \ 980 | Press 'Yes' (or Enter) to proceed, 'No' (or Esc) to abort 981 | " 982 | 983 | 984 | if [ ${GUI_MODE} -eq 0 ] ; then 985 | becho " 986 | [[ SEALS Config :: Please Review Carefully ]]" 987 | iecho "${msg1}" 988 | aecho "${msg1_2}" 989 | Prompt "" 990 | else 991 | #wecho "WIDTHxHT=$CAL_WIDTH x ${CAL_HT} " 992 | iecho "${msg1}" # also show it on the terminal window.. 993 | echo 994 | #set -x 995 | YAD_COMMON_OPTS="--on-top --center" 996 | yad ${YAD_COMMON_OPTS} --image "dialog-question" --title "${PRJ_TITLE} : $(basename "$(realpath ${BUILD_CONFIG_FILE})")" \ 997 | --text "${msg1_yad}" \ 998 | --button=gtk-yes:0 --button=gtk-no:1 \ 999 | --fixed 1000 | # Oh Wow! we need '--fixed' to keep the height sane and show the buttons !! 1001 | local ret=$? 1002 | echo "ret=$?" 1003 | if [[ ${ret} -eq 1 || ${ret} -eq 252 ]] ; then 1004 | aecho "Aborting. Edit the config file ${BUILD_CONFIG_FILE} as required and re-run." 1005 | exit 1 1006 | fi 1007 | fi 1008 | 1009 | if [ ${GUI_MODE} -eq 1 ] ; then 1010 | #--- YAD 1011 | local disp_kernel="FALSE" 1012 | [ ${BUILD_KERNEL} -eq 1 ] && disp_kernel="TRUE" 1013 | 1014 | local disp_kwipe="FALSE" 1015 | [ ${WIPE_KERNEL_CONFIG} -eq 1 ] && disp_kwipe="TRUE" 1016 | 1017 | local disp_rootfs="FALSE" 1018 | [ ${BUILD_ROOTFS} -eq 1 ] && disp_rootfs="TRUE" 1019 | 1020 | local disp_bbwipe="FALSE" 1021 | [ ${WIPE_BUSYBOX_CONFIG} -eq 1 ] && disp_bbwipe="TRUE" 1022 | 1023 | local disp_bbtiny="FALSE" 1024 | [ ${TINY_BUSYBOX_CONFIG} -eq 1 ] && disp_bbtiny="TRUE" 1025 | 1026 | local disp_genrfsimg="FALSE" 1027 | [ ${GEN_EXT4_ROOTFS_IMAGE} -eq 1 ] && disp_genrfsimg="TRUE" 1028 | 1029 | local disp_bkp="FALSE" 1030 | [ "${SAVE_BACKUP_IMG_CONFIGS}" -eq 1 ] && disp_bkp="TRUE" 1031 | 1032 | local disp_run="FALSE" 1033 | [ ${RUN_QEMU} -eq 1 ] && disp_run="TRUE" 1034 | 1035 | local MSG_CONFIG_VOLATILE="The settings you make now are volatile, i.e., they will take 1036 | effect for ONLY this run. Once completed, the default (build.config) settings resume. 1037 | To change settings permenantly, please edit the build.config file. 1038 | 1039 | * Wiping out the kernel / busybox config: 1040 | - only has an effect when the corresponding build option is selected 1041 | - if selected and wipe, implies that you will lose your existing config, of course. 1042 | " 1043 | 1044 | local yad_dothis=$(yad ${YAD_COMMON_OPTS} --form \ 1045 | --width 800 --height 220 \ 1046 | --field="Build Kernel (ver ${KERNELVER})":CHK \ 1047 | --field=" Wipe kernel config (Careful!*)":CHK \ 1048 | --field="Build Root Filesystem":CHK \ 1049 | --field=" Wipe busybox config (Careful!*)":CHK \ 1050 | --field=" Begin with all options set to Off (to get an tiny-as-poss busybox)":CHK \ 1051 | --field="Generate Root Filesystem EXT4 image file":CHK \ 1052 | --field="Backup the kernel and root fs images and configs":CHK \ 1053 | --field="Run QEMU":CHK \ 1054 | ${disp_kernel} ${disp_kwipe} ${disp_rootfs} ${disp_bbwipe} ${disp_bbtiny} \ 1055 | ${disp_genrfsimg} ${disp_bkp} ${disp_run} \ 1056 | --title="${PRJ_TITLE} : Configure this Run" \ 1057 | --center --width=${CAL_WIDTH} --on-top --no-escape \ 1058 | --text="${MSG_CONFIG_VOLATILE}") 1059 | 1060 | BUILD_KERNEL=$(echo "${yad_dothis}" |awk -F"|" '{print $1}') 1061 | WIPE_KERNEL_CONFIG=$(echo "${yad_dothis}" |awk -F"|" '{print $2}') 1062 | BUILD_ROOTFS=$(echo "${yad_dothis}" |awk -F"|" '{print $3}') 1063 | WIPE_BUSYBOX_CONFIG=$(echo "${yad_dothis}" |awk -F"|" '{print $4}') 1064 | TINY_BUSYBOX_CONFIG=$(echo "${yad_dothis}" |awk -F"|" '{print $5}') 1065 | GEN_EXT4_ROOTFS_IMAGE=$(echo "${yad_dothis}" |awk -F"|" '{print $6}') 1066 | SAVE_BACKUP_IMG_CONFIGS=$(echo "${yad_dothis}" |awk -F"|" '{print $7}') 1067 | RUN_QEMU=$(echo "${yad_dothis}" |awk -F"|" '{print $8}') 1068 | 1069 | # yad has the (rather unpleasant) side-effect of changing our build 1070 | # variables to the strings "TRUE" or "FALSE"; we'd like it to be integer 1071 | # values 1 or 0. 1072 | # Rationalize the 'build variables' to integer values 1073 | [ "${BUILD_KERNEL}" = "TRUE" ] && BUILD_KERNEL=1 || BUILD_KERNEL=0 1074 | [ "${WIPE_KERNEL_CONFIG}" = "TRUE" ] && WIPE_KERNEL_CONFIG=1 || WIPE_KERNEL_CONFIG=0 1075 | [ "${BUILD_ROOTFS}" = "TRUE" ] && BUILD_ROOTFS=1 || BUILD_ROOTFS=0 1076 | [ "${WIPE_BUSYBOX_CONFIG}" = "TRUE" ] && WIPE_BUSYBOX_CONFIG=1 || WIPE_BUSYBOX_CONFIG=0 1077 | [ "${TINY_BUSYBOX_CONFIG}" = "TRUE" ] && TINY_BUSYBOX_CONFIG=1 || TINY_BUSYBOX_CONFIG=0 1078 | [ "${GEN_EXT4_ROOTFS_IMAGE}" = "TRUE" ] && GEN_EXT4_ROOTFS_IMAGE=1 || GEN_EXT4_ROOTFS_IMAGE=0 1079 | [ "${SAVE_BACKUP_IMG_CONFIGS}" = "TRUE" ] && SAVE_BACKUP_IMG_CONFIGS=1 || SAVE_BACKUP_IMG_CONFIGS=0 1080 | [ "${RUN_QEMU}" = "TRUE" ] && RUN_QEMU=1 || RUN_QEMU=0 1081 | 1082 | display_current_config 1083 | 1084 | else # console mode 1085 | 1086 | seals_menu_consolemode 1087 | becho " 1088 | Confirm your choices please :: 1089 | " 1090 | display_current_config 1091 | 1092 | echo 1093 | get_yn_reply "Proceed? (if you say No, you can reenter choices)" y 1094 | [ $? -eq 1 ] && seals_menu_consolemode 1095 | fi 1096 | 1097 | } # end config_setup() 1098 | 1099 | install_deb_pkgs() 1100 | { 1101 | # For libncurses lib: have to take into account whether running on Ubuntu/Deb 1102 | # or Fedora/RHEL/CentOS 1103 | lsb_release -a|grep -w "Ubuntu" >/dev/null 2>&1 1104 | if [ $? -ne 0 ] ; then 1105 | echo "install_deb_pkgs(): this build host isn't Ubuntu/Debian, returning..." 1106 | return 1107 | fi 1108 | # Ubuntu/Debian 1109 | local pkg 1110 | for pkg in "$@" 1111 | do 1112 | set +e # Bash strict mode side effects 1113 | dpkg -l |grep ${pkg} >/dev/null 2>&1 1114 | # don't use grep -q here: see https://stackoverflow.com/a/19120438/779269 1115 | local ret=$? #; echo "ret=$ret" 1116 | set -e 1117 | if [ ${ret} -ne 0 ]; then 1118 | # installing libgmp3-dev libmpc-dev regardless of ARCH=arm here... should be ok? 1119 | sudo apt -y install ${pkg} 1120 | fi 1121 | done 1122 | } 1123 | 1124 | #--------- c h e c k _ i n s t a l l e d _ p k g ---------------------- 1125 | # + use superior checking func (fr CQuATS code) 1126 | # TODO 1127 | # - gather and install required packages 1128 | # - check for and install openssl-* (trouble is, the exact pkg name depends 1129 | # on the distro [??]) 1130 | check_installed_pkg() 1131 | { 1132 | report_progress || true 1133 | #set -x 1134 | # Toolchain 1135 | set +e 1136 | hash ${CXX}gcc >/dev/null 2>&1 1137 | res=$? 1138 | set -e 1139 | [[ ${res} -ne 0 ]] && { 1140 | FatalError " 1141 | There is an issue with the toolchain 1142 | (as specified in your build.config: ${CXX}). 1143 | *** It doesn't seem to be installed *** 1144 | 1145 | We insist you install a complete proper toolchain (Linux x86_64 host to AArch32 or 1146 | AArch64 target) as appropriate. To do so, please read: 1147 | 1148 | https://github.com/kaiwan/seals/wiki/SEALs-HOWTO 1149 | 1150 | It has detailed instructions. 1151 | 1152 | TIPs: 1153 | - is the toolchain in the PATH? 1154 | - have you correctly updated the relevant build.config file? 1155 | 1156 | Thanks. 1157 | " 1158 | } 1159 | 1160 | GCC_SYSROOT=$(${CXX}gcc --print-sysroot) || true 1161 | if [[ "${ARCH_PLATFORM}" != "x86_64" ]] ; then 1162 | if [ -z "${GCC_SYSROOT}" -o "${GCC_SYSROOT}" = "/" ] ; then 1163 | FatalError "There is an issue with the provided toolchain. 1164 | 1165 | It appears to not have the toolchain 'sysroot' libraries, sbin and usr 1166 | components within it. This could (and usually does) happen if it was installed 1167 | via a simple package manager cmd similar to 'sudo apt install ${ARCH}-linux-gnueabi'. 1168 | 1169 | We insist you install a complete proper toolchain; to do so, please follow the 1170 | detailed instructions provided here: 1171 | https://github.com/kaiwan/seals/wiki/SEALs-HOWTO 1172 | 1173 | Thanks. 1174 | " 1175 | fi 1176 | fi 1177 | 1178 | hash ${CXX}gcc > /dev/null || { 1179 | FatalError "Cross toolchain does not seem to be valid! PATH issue? 1180 | 1181 | Tip 1: If new to SEALS, we urge you, read the documentation here and then proceed: 1182 | https://github.com/kaiwan/seals/wiki 1183 | https://github.com/kaiwan/seals/wiki/SEALs-HOWTO 1184 | 1185 | Tip 2: Install the cross toolchain first, update the build.config to reflect it and rerun. 1186 | 1187 | Tip 3: (Less likely) This error can be thrown when you run the script with sudo (the 1188 | env vars are not setup. So run from a root shell where the PATH is correctly setup). 1189 | Aborting..." 1190 | } 1191 | 1192 | check_deps_fatal "${QEMUNAME} mkfs.ext4 lzop bison flex bc yad make" 1193 | # lzop(1) required for the IMX6 kernel build 1194 | [ ${GUI_MODE} -eq 1 ] && check_deps_fatal "yad xrandr" 1195 | 1196 | ## TODO : the dpkg & rpm -qa are very time consuming! 1197 | ## so do this only on 'first-time'. 1198 | 1199 | # TODO - more pkgs to check for on these distros... 1200 | if [ -f /etc/fedora-release ] || [ -f /etc/fedora ] ; then 1201 | # Fedora/RHEL/CentOS - probably :) 1202 | rpm -qa |grep ncurses-devel >/dev/null 1203 | [ $? -ne 0 ] && { 1204 | FatalError "The 'ncurses-devel' package does not seem to be installed. 1205 | (Required for kernel config UI). 1206 | Pl install the package (with dnf/yum/rpm) & re-run. Aborting..." 1207 | } 1208 | else # Debian / Ubuntu - probably :-) 1209 | install_deb_pkgs libncurses-dev libssl-dev libgmp3-dev libmpc-dev 1210 | fi 1211 | 1212 | # Terminal 'color' support? 1213 | hash tput > /dev/null || { 1214 | COLOR=0 1215 | wecho "tput does not seem to be installed, no color support..." 1216 | } && { 1217 | local numcolor=$(tput colors) 1218 | [ ${numcolor} -ge 8 ] && COLOR=1 1219 | } 1220 | } # end check_installed_pkg() 1221 | ##----------------------------- Functions End ------------------------- 1222 | 1223 | testColor() 1224 | { 1225 | ShowTitle "testing... KERNEL: Configure and Build [kernel ver ${KERNELVER}] now ..." 1226 | # FatalError "Testing ; the libncurses-dev dev library and headers does not seem to be installed." 1227 | Echo "Echo : a quick test ..." 1228 | decho "decho : a quick test ..." 1229 | iecho "cecho : a quick test ..." 1230 | aecho "aecho : a quick test ..." 1231 | wecho "wecho : a quick test ..." 1232 | #fecho "wecho : a quick test ..." 1233 | fg_grey; echo "rep progres ..." 1234 | color_reset 1235 | } 1236 | 1237 | 1238 | ### "main" here 1239 | 1240 | mysudo # warmup sudo 1241 | mysudo "SEALS Build:setup logfile ${LOGFILE_COMMON}. ${MSG_GIVE_PSWD_IF_REQD}" \ 1242 | touch ${LOGFILE_COMMON} 1243 | mysudo "" \ 1244 | chown ${USER}:${USER} ${LOGFILE_COMMON} 1245 | 1246 | GUI_MODE=$(is_gui_supported) # || true 1247 | # If we pass '-c' on cmdline, force console mode 1248 | mode_opt=${1:--g} 1249 | if [ $# -ge 1 -a "${mode_opt}" = "-c" ] ; then 1250 | GUI_MODE=0 1251 | fi 1252 | [ ${GUI_MODE} -eq 1 ] && echo "[+] Running in GUI mode.. (use '-c' option switch to run in console-only mode)" || echo "[+] Running in console mode.." 1253 | echo "[+] ${name}: initializing, please wait ..." 1254 | 1255 | #testColor 1256 | #exit 0 1257 | 1258 | hash tput >/dev/null 2>&1 && color_reset 1259 | unalias cp 2>/dev/null || true 1260 | 1261 | TESTMODE=0 1262 | [ ${TESTMODE} -eq 1 ] && { 1263 | FatalError "some issue blah ..." 1264 | exit 0 1265 | } 1266 | 1267 | config_symlink_setup 1268 | check_installed_pkg 1269 | [ ${GUI_MODE} -eq 1 ] && gui_init 1270 | 1271 | # NOTE: From now on we use the var ROOTFS_DIR as the rootfs dir 1272 | export ROOTFS_DIR=${ROOTFS} 1273 | [[ "${ARCH_PLATFORM}" = "x86_64" ]] && ROOTFS_DIR=${ROOTFS_PC} 1274 | 1275 | 1276 | ### 1277 | # !NOTE! 1278 | # The script expects that these folders are pre-populated with 1279 | # appropriate content, i.e., the source code for their resp projects: 1280 | # STG : staging folder (where all build work happens) 1281 | # KERNEL_FOLDER : kernel source tree 1282 | # BB_FOLDER : busybox source tree 1283 | ### 1284 | report_progress 1285 | 1286 | [ ! -d ${STG} ] && { 1287 | FatalError " 1288 | !!! SEALS Staging folder (STG) not present !!! 1289 | Currently, STG is set to \"${STG}\" 1290 | 1291 | IMPORTANT :: 1292 | Fix this by: 1293 | - First verifying that the staging folder pathname is correct within your SEALS build config file 1294 | - Then running the install script (install.sh). 1295 | 1296 | FYI, we expect a project 'staging area' is setup and pre-populated with appropriate content, 1297 | i.e., the source code for their resp projects, as follows: 1298 | STG : the project staging folder 1299 | KERNEL_FOLDER : kernel source tree 1300 | BB_FOLDER : busybox source tree 1301 | 1302 | *You must fix this by running the install.sh script* 1303 | 1304 | Tip: the place to update these folder pathnames is within the above-mentioned 1305 | config file. 1306 | " 1307 | } 1308 | 1309 | check_folder_createIA ${ROOTFS_DIR} 1310 | check_folder_createIA ${IMAGES_FOLDER} 1311 | check_folder_createIA ${IMAGES_BKP_FOLDER} 1312 | check_folder_createIA ${CONFIGS_FOLDER} 1313 | 1314 | config_setup 1315 | 1316 | # Conditionally verify that the kernel and busybox src trees are indeed under STG 1317 | CHK_SRCTREES="" 1318 | [ ${BUILD_KERNEL} -eq 1 ] && CHK_SRCTREES="${KERNEL_FOLDER}/kernel" 1319 | [ ${BUILD_ROOTFS} -eq 1 ] && CHK_SRCTREES="${CHK_SRCTREES} ${BB_FOLDER}/applets" 1320 | 1321 | i=1 1322 | for dir in ${CHK_SRCTREES} 1323 | do 1324 | if [ ! -d ${dir} ] ; then 1325 | [[ ${dir} = *kernel* ]] && { 1326 | err="kernel" 1327 | errdir=${KERNEL_FOLDER} 1328 | } || { 1329 | err="busybox" 1330 | errdir=${BB_FOLDER} 1331 | } 1332 | FatalError " 1333 | We expect the ${err} source tree to be present here: 1334 | ${errdir} 1335 | 1336 | It appears to be invalid or missing! 1337 | 1338 | IMPORTANT :: 1339 | Fix this by: 1340 | - First verifying that the ${err} source version is correct within your SEALS build config file 1341 | - Then running the install script (install.sh). 1342 | 1343 | " 1344 | fi 1345 | let i=i+1 1346 | done 1347 | 1348 | ### Which of the functions below run depends on the 1349 | # config specified in the Build Config file! 1350 | # So just set it there man ... 1351 | ### 1352 | [ ${BUILD_KERNEL} -eq 1 ] && { 1353 | check_folder_AIA ${KERNEL_FOLDER} 1354 | set_kernelimg_var 1355 | build_kernel 1356 | } 1357 | [ ${BUILD_ROOTFS} -eq 1 ] && { 1358 | [[ ! -d ${BB_FOLDER} ]] && FatalError "Busybox source folder not found?" 1359 | build_rootfs 1360 | } 1361 | [ ${GEN_EXT4_ROOTFS_IMAGE} -eq 1 ] && { 1362 | # First ensure that kernel modules have been generated into the rootfs 1363 | if [[ ${BUILD_KERNEL} -eq 0 ]] ; then 1364 | [[ -z $(ls -A ${ROOTFS_DIR}/lib/modules/"$(kernel_uname_r)") ]] && install_kernel_modules 1365 | fi 1366 | generate_rootfs_img_ext4 1367 | } 1368 | [ ${SAVE_BACKUP_IMG_CONFIGS} -eq 1 ] && save_images_configs 1369 | [ ${RUN_QEMU} -eq 1 ] && run_qemu_SEALS 1370 | 1371 | aecho "${MSG_EXITING}" 1372 | color_reset 1373 | exit 0 1374 | -------------------------------------------------------------------------------- /cleanall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Part of the SEALS project 3 | # cleanall 4 | # *CAREFUL*! WIPES all builds 5 | # Set Bash unofficial 'strict mode'; _really_ helps catch bugs 6 | # ref: http://redsymbol.net/articles/unofficial-bash-strict-mode/ 7 | set -euo pipefail 8 | name=$(basename $0) 9 | 10 | # Fetch the SEALs env 11 | source ./build.config || { 12 | echo "${name}: ./build.config file missing or invalid? using defaults if they exist..." 13 | if [ -d ./images ]; then 14 | STG=./ 15 | else 16 | echo "No ./images/ dir, aborting..." 17 | exit 1 18 | fi 19 | } 20 | source ./common.sh || { 21 | echo "${name}: source failed! ./common.sh missing or invalid?" 22 | exit 1 23 | } 24 | 25 | 26 | clean_kernel() 27 | { 28 | aecho "Cleaning kernel source tree now..." 29 | [[ ! -d ${KERNEL_FOLDER} ]] && { 30 | echo "*** ERROR: kernel folder \"${KERNEL_FOLDER}\" not found ***" 31 | return 32 | } 33 | cd ${KERNEL_FOLDER} || FatalError "cd to kernel folder failed" 34 | local CMD="make mrproper" 35 | runcmd "${CMD}" 36 | cd ${TOPDIR} 37 | } 38 | 39 | clean_bb() 40 | { 41 | aecho "Cleaning Busybox source tree now..." 42 | [[ ! -d ${BB_FOLDER} ]] && { 43 | echo "*** ERROR: busybox folder \"${BB_FOLDER}\" not found ***" 44 | return 45 | } 46 | cd ${BB_FOLDER} || FatalError "cd to busybox folder failed" 47 | local CMD="make mrproper" 48 | runcmd "${CMD}" 49 | cd ${TOPDIR} 50 | } 51 | 52 | clean_rootfs() 53 | { 54 | aecho "About to Wipe rootfs source tree now..." 55 | [[ ! -d ${ROOTFS_DIR} ]] && { 56 | echo "*** ERROR: rootfs folder \"${ROOTFS_DIR}\" not found ***" 57 | return 58 | } 59 | cd ${ROOTFS_DIR} || FatalError "cd to rootfs folder failed" 60 | # !!! BE VERY CAREFUL !!! 61 | local CMD="sudo rm -rf *" 62 | get_yn_reply "PLEASE RECHECK and CONFIRM !? Completely wipe root fs staging folder (here: ${ROOTFS_DIR})" n 63 | [[ $? -eq 0 ]] && { 64 | echo "In $(pwd)" 65 | runcmd "${CMD}" 66 | } 67 | cd ${TOPDIR} 68 | } 69 | 70 | clean_images() 71 | { 72 | aecho "Wiping the images folder now..." 73 | [[ ! -d ${IMAGES_FOLDER} ]] && { 74 | echo "*** ERROR: images folder \"${IMAGES_FOLDER}\" not found ***" 75 | return 76 | } 77 | cd ${IMAGES_FOLDER} || FatalError "cd to images folder failed" 78 | # !!! BE VERY CAREFUL !!! 79 | local CMD="sudo rm -rf *" 80 | [[ $? -eq 0 ]] && { 81 | echo "In $(pwd)" 82 | runcmd "${CMD}" 83 | } 84 | cd ${TOPDIR} 85 | } 86 | 87 | clean_images_bkp() 88 | { 89 | aecho "Wiping the images backup folder now..." 90 | [[ ! -d ${IMAGES_BKP_FOLDER} ]] && { 91 | echo "*** ERROR: images backup folder \"${IMAGES_BKP_FOLDER}\" not found ***" 92 | return 93 | } 94 | cd ${IMAGES_BKP_FOLDER} || FatalError "cd to images backup folder failed" 95 | # !!! BE VERY CAREFUL !!! 96 | local CMD="sudo rm -rf *" 97 | [[ $? -eq 0 ]] && { 98 | echo "In $(pwd)" 99 | runcmd "${CMD}" 100 | } 101 | cd ${TOPDIR} 102 | } 103 | 104 | 105 | 106 | ### --- 'main' 107 | TOPDIR=$(pwd) 108 | ShowTitle "SEALS :: CLEAN ALL Script" 109 | 110 | echo "FYI, this is the current SEALS config: 111 | " 112 | ./show_curr_config.sh 113 | Prompt "" #[Enter] to continue, ^C to abort..." 114 | 115 | echo 116 | get_yn_reply "COMPLETELY CLEAN kernel source tree (here: ${KERNEL_FOLDER}) 117 | (this will also wipe any kernel config files) 118 | [make mrproper] ?" n 119 | [[ $? -eq 0 ]] && clean_kernel 120 | 121 | echo 122 | get_yn_reply "COMPLETELY CLEAN busybox source tree (here: ${BB_FOLDER}) 123 | (this will also wipe any busybox config files) 124 | [make mrproper] ?" n 125 | [[ $? -eq 0 ]] && clean_bb 126 | 127 | echo 128 | [[ "${ARCH_PLATFORM}" != "x86_64" ]] && ROOTFS_DIR=${ROOTFS} || ROOTFS_DIR=${ROOTFS_PC} 129 | get_yn_reply "COMPLETELY WIPE root fs staging folder (here: ${ROOTFS_DIR}) 130 | ?" n 131 | [[ $? -eq 0 ]] && clean_rootfs 132 | 133 | echo 134 | get_yn_reply "COMPLETELY WIPE images folder (here: ${IMAGES_FOLDER}) 135 | ?" n 136 | [[ $? -eq 0 ]] && clean_images 137 | 138 | echo 139 | get_yn_reply "COMPLETELY WIPE images backup folder (here: ${IMAGES_BKP_FOLDER}) 140 | ?" n 141 | [[ $? -eq 0 ]] && clean_images_bkp 142 | 143 | # configs? 144 | #CONFIGS_FOLDER=${STG}/configs 145 | 146 | exit 0 147 | -------------------------------------------------------------------------------- /color.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #------------------------------------------------------------------ 3 | # color.sh 4 | # 5 | # Common convenience routines for color support in bash. 6 | # 7 | # (c) Kaiwan N Billimoria 8 | # kaiwan -at- kaiwantech -dot- com 9 | # MIT / GPL v2 10 | #------------------------------------------------------------------ 11 | # The SEALS Opensource Project 12 | # SEALS : Simple Embedded Arm Linux System 13 | # Maintainer : Kaiwan N Billimoria 14 | # kaiwan -at- kaiwantech -dot- com 15 | # Project URL: 16 | # https://github.com/kaiwan/seals 17 | 18 | #------------------- Colors!! Yay :-) ----------------------------------------- 19 | # Ref: https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux 20 | # [Ans by Drew Noakes] 21 | #--- Foreground Colors 22 | fg_black() { tput setaf 0 23 | } 24 | fg_red() { tput setaf 1 25 | } 26 | fg_green() { tput setaf 2 27 | } 28 | fg_yellow() { tput setaf 3 29 | } 30 | fg_blue() { tput setaf 4 31 | } 32 | fg_magenta() { tput setaf 5 33 | } 34 | fg_cyan() { tput setaf 6 35 | } 36 | fg_white() { tput setaf 7 37 | } 38 | fg_grey() { tput setaf 8 39 | } 40 | 41 | #--- Background Colors 42 | bg_white() { tput setab 7 43 | } 44 | bg_red() { tput setab 1 45 | } 46 | bg_yellow() { tput setab 3 47 | } 48 | bg_blue() { tput setab 4 49 | } 50 | bg_cyan() { tput setab 6 51 | } 52 | 53 | #--- Text Attributes <-- NOK! 54 | #tb=$(tput bold) # bold 55 | #tsb=$(tput smso) # enter standout bold mode 56 | #trb=$(tput rmso) # exit standout bold mode 57 | #trev=$(tput rev) # reverse video 58 | #tdim=$(tput dim) # half-brightness 59 | #tBell=$(tput bel) # sound bell! 60 | 61 | #--- Composite text attribs [ta] <-- NOK! 62 | #taErr="${tb}${fg_red}${bg_white}${tBell}" 63 | #taTitle="${tb}${fg_black}${bg_yellow}" 64 | #taReg="" # 'regular' msgs 65 | #taBold="$(tput bold)" 66 | #taBold="${tb}" 67 | #taAbnormal="${fg_white}${bg_blue}" # 'Abnormal' msgs - error msgs,... 68 | #taDebug="${tdim}" 69 | 70 | # Reset text attributes to normal without clearing screen. 71 | color_reset() 72 | { 73 | tput sgr0 74 | } 75 | 76 | #--------------------- E c h o ---------------------------------------- 77 | # The _base_ echo/logging function. 78 | # Parameters: 79 | # $1 : a tag that speicifies the logging level 80 | # $2 ... $n : message to echo (to stdout and logfile) 81 | # 82 | # Logging Levels (from low->high 'criticality') are: 83 | # -------- -------- 84 | # LogLevel Function 85 | # -------- -------- 86 | # DDEBUG decho 87 | # INFO iecho 88 | # ALERT aecho [bold] 89 | # WARN wecho 90 | # CRIT cecho 91 | # TITL techo <-- exception: this is NOT really a loglevel, 92 | # it's a special display attribute 93 | # !WARNING! 94 | # Ensure you don't call any of the x[Ee]cho functions from here, as they 95 | # call this func and it becomes infinitely recursive. 96 | Echo() 97 | { 98 | local SEP=" " name=$(basename $0) 99 | # echo "# = $# : params: $@" 100 | [ $# -eq 0 ] && return 1 101 | local numparams=$# 102 | local tag="${1}" 103 | [ ${numparams} -gt 1 ] && shift # get rid of the tag, so that we can access the txt msg 104 | 105 | # Prefix the logging level : debug/info/warn/critical 106 | local loglevel 107 | # maintaining 4-char strings for 'loglevel' alleviates the need for more 108 | # code with printf etc 109 | case "${tag}" in 110 | DDEBUG) loglevel="dbug" 111 | ;; 112 | INFO) loglevel="info" 113 | ;; 114 | ALERT) loglevel="alrt" 115 | ;; 116 | WARN) loglevel="warn" 117 | ;; 118 | CRIT) loglevel="crit" 119 | ;; 120 | TITL) loglevel="titl" 121 | ;; 122 | *) loglevel=" " 123 | ;; 124 | esac 125 | 126 | local dt_log="[$(date +%a_%d%b%Y_%T.%N)]" 127 | #local dt_disp 128 | #[ "${VERBOSE_MSG}" -eq 1 ] && dt_disp=${dt_log} 129 | 130 | local msgpfx1_log="[${loglevel}]${SEP}${dt_log}" 131 | local msgpfx1_disp="${dt_log}" 132 | [ "${VERBOSE_MSG}" -eq 1 ] && msgpfx1_disp="${msgpfx1_log}" 133 | 134 | local msgpfx2_log="${SEP}${name}:${FUNCNAME[ 1 ]}()${SEP}" 135 | local msgpfx2_disp="" 136 | [ "${VERBOSE_MSG}" -eq 1 ] && msgpfx2_disp="${msgpfx2_log}" 137 | 138 | local msgtxt="$*" 139 | local msgfull_log="${msgpfx1_log}${msgpfx2_log}${msgtxt}" 140 | local msg_disp="${msgpfx1_disp}${SEP}${msgtxt}" 141 | [ "${VERBOSE_MSG}" -eq 1 ] && msg_disp="${msgfull_log}" 142 | 143 | sudo bash -c "echo \"${msgfull_log}\" >> ${LOGFILE_COMMON}" # lets log it first anyhow 144 | 145 | if [ ${numparams} -eq 1 -o ${COLOR} -eq 0 ]; then # no color/text attribute 146 | [ ${DEBUG} -eq 1 ] && echo "${msgfull_log}" || echo "${msg_disp}" 147 | return 0 148 | fi 149 | 150 | #--- 'color' or text attrib present! 151 | fg_green 152 | echo -n "${msgpfx1_disp}${SEP}" 153 | [ ${DEBUG} -eq 1 -o ${VERBOSE_MSG} -eq 1 ] && { 154 | fg_blue 155 | echo -n "${msgpfx2_disp}" 156 | } 157 | color_reset # Reset to normal. 158 | 159 | case "${tag}" in 160 | DDEBUG) tput dim #; fg_magenta 161 | ;; 162 | INFO) #tput # Deliberate: no special attribs for 'info' 163 | ;; 164 | ALERT) tput bold 165 | ;; 166 | WARN) #fg_white ; bg_red ; tput bold 167 | fg_red ; bg_yellow ; tput bold 168 | ;; 169 | CRIT) fg_white ; bg_red ; tput bold 170 | ;; 171 | TITL) fg_black ; bg_yellow ; tput bold 172 | ;; 173 | esac 174 | echo "${msgtxt}" 175 | color_reset # Reset to normal. 176 | return 0 177 | } # end Echo() 178 | 179 | #--- Wrappers over Echo follow --- 180 | # Parameters: 181 | # $1 : message to echo (to stdout and logfile) 182 | 183 | #--------------------- d e c h o -------------------------------------- 184 | # DEBUG-level echo :-) 185 | decho() 186 | { 187 | [ ${DEBUG} -eq 1 ] && Echo DDEBUG "$1" || true 188 | } 189 | #--------------------- i e c h o --------------------------------------- 190 | # INFO-level / regular Color-echo. 191 | iecho () 192 | { 193 | Echo INFO "$1" 194 | } 195 | #--------------------- a e c h o --------------------------------------- 196 | # ALERT-level Color-echo. 197 | aecho () 198 | { 199 | Echo ALERT "$1" 200 | } 201 | #--------------------- b e c h o --------------------------------------- 202 | # BOLD Color-echo. 203 | becho () 204 | { 205 | Echo ALERT "$1" 206 | } 207 | #--------------------- w e c h o --------------------------------------- 208 | # WARN-level Color-echo. 209 | wecho () 210 | { 211 | Echo WARN "$1" 212 | } 213 | #--------------------- c e c h o --------------------------------------- 214 | # CRITical-level Color-echo. 215 | cecho () 216 | { 217 | Echo CRIT "$1" 218 | } 219 | 220 | #--------------------- t e c h o --------------------------------------- 221 | # Title Color-echo. 222 | techo () 223 | { 224 | Echo TITL "$1" 225 | } 226 | #--- 227 | 228 | # ShowTitle 229 | # Display a string in "title" form 230 | # Parameter(s): 231 | # $1 : String to display [required] 232 | ShowTitle() 233 | { 234 | techo "$1" 235 | } 236 | 237 | 238 | test_256() 239 | { 240 | for i in $(seq 0 255) 241 | do 242 | tput setab $i 243 | printf '%03d ' $i 244 | done 245 | color_reset 246 | } 247 | 248 | test_color_echos() 249 | { 250 | techo "Sample of the 'techo()' - title echo - color output" 251 | echo 252 | cecho "Sample of the 'cecho()' - color echo - color output" 253 | echo 254 | wecho "Sample of the 'wecho()' - warn echo - color output" 255 | echo 256 | becho "Sample of the 'becho()' - bold echo - color output" 257 | echo 258 | aecho "Sample of the 'aecho()' - alert echo - color output" 259 | echo 260 | iecho "Sample of the 'iecho()' - info echo - color output" 261 | echo 262 | decho "Sample of the 'decho()' - debug echo - color output" 263 | echo 264 | } 265 | -------------------------------------------------------------------------------- /common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #------------------------------------------------------------------ 3 | # common.sh 4 | # 5 | # Common convenience routines 6 | # 7 | # (c) Kaiwan N Billimoria 8 | # kaiwan -at- kaiwantech -dot- com 9 | # MIT / GPL v2 10 | #------------------------------------------------------------------ 11 | # The SEALS Opensource Project 12 | # SEALS : Simple Embedded Arm Linux System 13 | # Maintainer : Kaiwan N Billimoria 14 | # kaiwan -at- kaiwantech -dot- com 15 | # Project URL: 16 | # https://github.com/kaiwan/seals 17 | 18 | export TOPDIR=$(pwd) 19 | #ON=1 20 | #OFF=0 21 | 22 | ### UPDATE for your box 23 | source ./err_common.sh || { 24 | echo "$name: could not source err_common.sh, aborting..." 25 | exit 1 26 | } 27 | source ./color.sh || { 28 | echo "$name: could not source color.sh, aborting..." 29 | exit 1 30 | } 31 | 32 | #-------------- r u n c m d ------------------------------------------- 33 | # Display and run the provided command. 34 | # Parameter 1 : the command to run 35 | runcmd() 36 | { 37 | local SEP="------------------------------" 38 | [ $# -eq 0 ] && return 39 | echo "${SEP} 40 | $* 41 | ${SEP}" 42 | eval "$@" 43 | } 44 | 45 | # yesorno 46 | # $1 : variable to test 47 | # if 0, say 'no' 48 | # if 1, say 'yes' 49 | yesorno() 50 | { 51 | [[ $# -ne 1 ]] && return 52 | [[ $1 -eq 0 ]] && echo "no" 53 | [[ $1 -eq 1 ]] && echo "yes" 54 | } 55 | 56 | # yesorno_color 57 | # $1 : variable to test 58 | # if 0, say 'no' in red color 59 | # if 1, say 'yes' in green color 60 | yesorno_color() 61 | { 62 | [[ $# -ne 1 ]] && return 63 | [[ ${1} -eq 1 ]] && { 64 | fg_green ; echo "Yes" ; color_reset 65 | } || { 66 | fg_red ; echo " No" ; color_reset 67 | } 68 | } 69 | 70 | is_gui_supported() 71 | { 72 | local GUI_MODE=0 73 | xdpyinfo >/dev/null 2>&1 && GUI_MODE=1 74 | # On Fedora (26), xdpyinfo fails when run as root; so lets do another check as well 75 | ps -e|egrep -w "X|Xorg|Xwayland" >/dev/null 2>&1 && GUI_MODE=1 || GUI_MODE=0 76 | #echo "GUI_MODE $GUI_MODE" 77 | echo ${GUI_MODE} 78 | } 79 | 80 | # If we're not in a GUI (X Windows) display, abort (reqd for yad) 81 | gui_init() 82 | { 83 | hash xdpyinfo > /dev/null 2>&1 || { 84 | FatalError "xdpyinfo (package x11-utils) does not seem to be installed. Aborting... 85 | [Tip: try running as a regular user, not root]" 86 | } 87 | xdpyinfo >/dev/null 2>&1 || { 88 | FatalError "Sorry, we're not running in a GUI display environment. Aborting... 89 | [Tip: try running as a regular user, not root]" 90 | } 91 | hash xrandr > /dev/null 2>&1 || { 92 | FatalError "xrandr (package x11-server-utils) does not seem to be installed. Aborting..." 93 | } 94 | 95 | #--- Screen Resolution stuff 96 | res_w=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f1 | head -n1) 97 | res_h=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f2 | tail -n1) 98 | # let centre_x=${res_w}/3 99 | # let centre_y=$res_h/3 100 | # let centre_y=$centre_y-100 101 | 102 | CAL_WIDTH=$((${res_w}/3)) 103 | let CAL_WIDTH=$CAL_WIDTH+200 104 | [ -z ${CAL_WIDTH} ] && CAL_WIDTH=600 105 | let CAL_HT=$res_h/2 106 | [ -z ${CAL_HT} -o ${CAL_HT} -lt 300 ] && CAL_HT=300 || true 107 | #echo "res_w=${res_w} res_h=${res_h} CAL_WIDTH=${CAL_WIDTH} CAL_HT=${CAL_HT}" 108 | } 109 | 110 | # logfile_post_process 111 | # Issue: using the 'color' routines (like wecho, aecho, techo, etc) causes 112 | # escape chars to get embedded into the logfile. This addresses how to get 113 | # rid of the color escape sequences. 114 | # $1 : logfile 115 | logfile_post_process() 116 | { 117 | sed -i.bkp "/###\:\:\:/d" ${1} # take a backup & get rid of the signature line 118 | sed -i "s/\x1b.....//g" ${1} # get rid of the ^[(B^[[m characters ! 119 | # '\x1b' is ESC ! Find it, and then delete it and the following 5 chars 120 | # (the five .'s that follow specify this) 121 | } 122 | 123 | # genLogFilename 124 | # Generates a logfile name that includes the date/timestamp 125 | # Format: 126 | # ddMmmYYYY[_HHMMSS] 127 | # Parameter(s) 128 | # #$1 : String to prefix to log filename, null okay as well [required] 129 | # $1 : Include time component or not [required] 130 | # $1 = 0 : Don't include the time component (only date) in the log filename 131 | # $1 = 1 : include the time component in the log filename 132 | genLogFilename() 133 | { 134 | [ $1 -eq 0 ] && log_filename=$(date +%d%b%Y) 135 | [ $1 -eq 1 ] && log_filename=$(date +%d%b%Y_%H%M%S) 136 | echo ${log_filename} 137 | } 138 | 139 | # mysudo 140 | # Simple front end to gksudo/sudo 141 | # Parameter(s): 142 | # $1 : descriptive message 143 | # $2 ... $n : command to execute 144 | mysudo() 145 | { 146 | [ $# -lt 2 ] && { 147 | #echo "Usage: mysudo " 148 | return 149 | } || true 150 | local msg=$1 151 | shift 152 | local cmd="$*" 153 | aecho "${LOGNAME}: ${msg}" 154 | [ ${DEBUG} -eq 1 ] && echo "mysudo():cmd: \"${cmd}\"" || true 155 | sudo --preserve-env bash -c "${cmd}" && true 156 | true 157 | } 158 | 159 | # check_root_AIA 160 | # Check whether we are running as root user; if not, exit with failure! 161 | # Parameter(s): 162 | # None. 163 | # "AIA" = Abort If Absent :-) 164 | check_root_AIA() 165 | { 166 | if [ $(id -u) -ne 0 ]; then 167 | Echo "Error: need to run as root! Aborting..." 168 | exit 1 169 | fi 170 | } 171 | 172 | # check_file_AIA 173 | # Check whether the file, passed as a parameter, exists; if not, exit with failure! 174 | # Parameter(s): 175 | # $1 : Pathname of file to check for existence. [required] 176 | # "AIA" = Abort If Absent :-) 177 | # Returns: 0 on success, 1 on failure 178 | check_file_AIA() 179 | { 180 | [ $# -ne 1 ] && return 1 181 | [ ! -f $1 ] && { 182 | Echo "Error: file \"$1\" does not exist. Aborting..." 183 | exit 1 184 | } || true 185 | } 186 | 187 | # check_folder_AIA 188 | # Check whether the directory, passed as a parameter, exists; if not, exit with failure! 189 | # Parameter(s): 190 | # $1 : Pathname of folder to check for existence. [required] 191 | # "AIA" = Abort If Absent :-) 192 | # Returns: 0 on success, 1 on failure 193 | check_folder_AIA() 194 | { 195 | [ $# -ne 1 ] && return 1 196 | [ ! -d $1 ] && { 197 | Echo "Error: folder \"$1\" does not exist. Aborting..." 198 | exit 1 199 | } || true 200 | } 201 | 202 | # check_folder_createIA 203 | # Check whether the directory, passed as a parameter, exists; if not, create it! 204 | # Parameter(s): 205 | # $1 : Pathname of folder to check for existence. [required] 206 | # "IA" = If Absent :-) 207 | # Returns: 0 on success, 1 on failure 208 | check_folder_createIA() 209 | { 210 | [ $# -ne 1 ] && return 1 211 | [ ! -d $1 ] && { 212 | Echo "Folder \"$1\" does not exist. Creating it..." 213 | mkdir -p $1 && return 0 || return 1 214 | } || true 215 | } 216 | 217 | 218 | # GetIP 219 | # Extract IP address from ifconfig output 220 | # Parameter(s): 221 | # $1 : name of network interface (string) 222 | # Returns: IPaddr on success, non-zero on failure 223 | GetIP() 224 | { 225 | [ $# -ne 1 ] && return 1 226 | ifconfig $1 >/dev/null 2>&1 || return 2 227 | ifconfig $1 |grep 'inet addr'|awk '{print $2}' |cut -f2 -d':' 228 | } 229 | 230 | # get_yn_reply 231 | # User's reply should be Y or N. 232 | # Parameters :: 233 | # $1 : prompt string to display 234 | # $2 = 'y' : default is 'y', meaning, if user presses '[Enter]' key 235 | # $2 = 'n' : default is 'n', meaning, if user presses '[Enter]' key 236 | # Returns: 237 | # 0 => user has answered 'Y' 238 | # 1 => user has answered 'N' 239 | # Lookup the value via $? in the caller. 240 | get_yn_reply() 241 | { 242 | set +e # temporarily turn off 'bash safe mode -e' 243 | str="${1}" 244 | while true 245 | do 246 | echo -n "${str}" 247 | if [ "$2" = "y" ] ; then 248 | echo " [y]" 249 | elif [ "$2" = "n" ] ; then 250 | echo " [n]" 251 | fi 252 | [ $# -eq 1 ] && echo 253 | 254 | read -s -n1 reply # -s: don't echo ; -n1 : read only 1 char 255 | 256 | case "$reply" in 257 | y | yes | Y | YES ) 258 | echo "" 259 | return 0 260 | ;; 261 | n | N ) 262 | echo "" 263 | return 1 264 | ;; 265 | "" ) 266 | [ $# -eq 1 ] && { 267 | echo "" 268 | continue 269 | } 270 | echo "<$2>" 271 | [ "$2" = "y" ] && return 0 272 | [ "$2" = "n" ] && return 1 273 | ;; 274 | *) aecho "*** Pl type 'Y' or 'N' ***" 275 | esac 276 | done 277 | set -e 278 | } 279 | 280 | # MountPartition 281 | # Mounts the partition supplied as $1 282 | # Parameters: 283 | # $1 : device node of partition to mount 284 | # $2 : mount point 285 | # Returns: 286 | # 0 => mount successful 287 | # 1 => mount failed 288 | MountPartition() 289 | { 290 | [ $# -ne 2 ] && { 291 | aecho "MountPartition: parameter(s) missing!" 292 | return 1 293 | } 294 | 295 | DEVNODE=$1 296 | [ ! -b ${DEVNODE} ] && { 297 | aecho "MountPartition: device node $1 does not exist?" 298 | return 1 299 | } 300 | 301 | MNTPT=$2 302 | [ ! -d ${MNTPT} ] && { 303 | aecho "MountPartition: folder $2 does not exist?" 304 | return 1 305 | } 306 | 307 | mount |grep ${DEVNODE} >/dev/null || { 308 | #echo "The partition is not mounted, attempting to mount it now..." 309 | mount ${DEVNODE} -t auto ${MNTPT} || { 310 | wecho "Could not mount the '$2' partition!" 311 | return 1 312 | } 313 | } 314 | return 0 315 | } 316 | 317 | ## is_kernel_thread 318 | # Param: PID 319 | # Returns: 320 | # 1 if $1 is a kernel thread, 0 if not, 127 on failure. 321 | is_kernel_thread() 322 | { 323 | [ $# -ne 1 ] && { 324 | aecho "is_kernel_thread: parameter missing!" 1>&2 325 | return 127 326 | } 327 | 328 | prcs_name=$(ps aux |awk -v pid=$1 '$2 == pid {print $11}') 329 | #echo "prcs_name = ${prcs_name}" 330 | [ -z ${prcs_name} ] && { 331 | wecho "is_kernel_thread: could not obtain process name!" 1>&2 332 | return 127 333 | } 334 | 335 | firstchar=$(echo "${prcs_name:0:1}") 336 | #echo "firstchar = ${firstchar}" 337 | len=${#prcs_name} 338 | let len=len-1 339 | lastchar=$(echo "${prcs_name:${len}:1}") 340 | #echo "lastchar = ${lastchar}" 341 | [ ${firstchar} = "[" -a ${lastchar} = "]" ] && return 1 || return 0 342 | } 343 | 344 | #---------- c h e c k _ d e p s --------------------------------------- 345 | # Checks passed packages - are they installed? (just using 'hash'; 346 | # using the pkg management utils (apt/dnf/etc) would be too time consuming) 347 | # Parameters: 348 | # $1 : 1 => fatal error, exit 349 | # 0 => warn only 350 | # [.. $@ ..] : space-sep string of all packages to check 351 | # Eg. check_deps "make perf spatch xterm" 352 | check_deps() 353 | { 354 | local util needinstall=0 355 | local severity=$1 356 | shift 357 | 358 | for util in $@ 359 | do 360 | set +e 361 | hash ${util} > /dev/null 2>&1 362 | [[ $? -ne 0 ]] && { 363 | [ ${needinstall} -eq 0 ] && wecho "The following utilit[y|ies] or package(s) do NOT seem to be installed:" 364 | iecho "[!] ${util}" 365 | needinstall=1 366 | continue 367 | } 368 | set -e 369 | done 370 | [ ${needinstall} -eq 1 ] && { 371 | [ ${severity} -eq 1 ] && { 372 | FatalError "Kindly first install the required package(s) shown above \ 373 | (check console and/or log output) and then retry, thanks. Aborting now..." 374 | } || { 375 | wecho "WARNING! The package(s) shown above are not present" 376 | } 377 | } || true 378 | } # end check_deps() 379 | 380 | # Simple wrappers over check_deps(); 381 | # Recall, the fundamental theorem of software engineering FTSE: 382 | # "We can solve any problem by introducing an extra level of indirection." 383 | # -D Wheeler 384 | # ;-) 385 | check_deps_fatal() 386 | { 387 | check_deps 1 "$@" 388 | } 389 | 390 | check_deps_warn() 391 | { 392 | check_deps 0 "$@" 393 | } 394 | 395 | #---------------------------------------------------------------------- 396 | report_progress() 397 | { 398 | local frame=1 399 | fg_grey 400 | printf "$(date +%F.%H%M%S):${BASH_SOURCE[${frame}]}:${FUNCNAME[${frame}]}:${BASH_LINENO[0]}\n" 401 | color_reset 402 | } 403 | -------------------------------------------------------------------------------- /err_common.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #------------------------------------------------------------------ 3 | # err_common.sh 4 | # 5 | # Common error handling routines. 6 | # 7 | # (c) Kaiwan N Billimoria 8 | # kaiwan -at- kaiwantech -dot- com 9 | # MIT / GPL v2 10 | #------------------------------------------------------------------ 11 | # The SEALS Opensource Project 12 | # SEALS : Simple Embedded Arm Linux System 13 | # Maintainer : Kaiwan N Billimoria 14 | # kaiwan -at- kaiwantech -dot- com 15 | # Project URL: 16 | # https://github.com/kaiwan/seals 17 | 18 | export TOPDIR="$(pwd)" 19 | SEALS_REPORT_ERROR_EMAIL=kaiwan.billimoria@gmail.com 20 | #SEALS_REPORT_ERROR_URL=https://github.com/kaiwan/seals/issues 21 | 22 | #--- Icons 23 | # src: /usr/share/icons/Humanity/actions/ 24 | ICON_NEXT=go-next 25 | ICON_BACK=go-previous 26 | ICON_YES=add #go-next 27 | ICON_NO=remove #gtk-remove 28 | ICON_ADD=add #gtk-add 29 | ICON_REGISTER=player_record 30 | ICON_SIGNIN=format-text-direction-ltr 31 | ICON_EXIT=stock_mark #system-log-out 32 | 33 | 34 | # QP 35 | # QuickPrint ;-) 36 | # Print timestamp, script name, line#. Useful for debugging. 37 | # [RELOOK / FIXME : not really useful as it doen't work as a true macro; 38 | # just prints _this_ script name, line#.] 39 | QP() 40 | { 41 | _ERR_HDR_FMT="%.23s %s[%s]: " 42 | _ERR_MSG_FMT="${_ERR_HDR_FMT}%s\n" 43 | [ ${COLOR} -eq 1 ] && fg_blue 44 | printf " QP: $_ERR_MSG_FMT" $(date +%F.%T.%N) " ${BASH_SOURCE[1]##*/}:${FUNCNAME[2]}" |tee -a ${LOGFILE_COMMON} 45 | dumpstack 46 | #printf " QP: $_ERR_MSG_FMT" $(date +%F.%T.%N) " ${BASH_SOURCE[1]##*/}:${BASH_LINENO[0]}" |tee -a ${LOGFILE_COMMON} 47 | [ ${COLOR} -eq 1 ] && color_reset 48 | unset _ERR_HDR_FMT 49 | unset _ERR_MSG_FMT 50 | } 51 | 52 | STACK_MAXDEPTH=32 # arbit? 53 | dumpstack() 54 | { 55 | #for frame in $(seq 1 $1) 56 | local frame=1 57 | local funcname 58 | 59 | ShowTitle " Stack Call-trace:" 60 | [ ${COLOR} -eq 1 ] && fg_blue 61 | while [ true ] 62 | do 63 | funcname=${FUNCNAME[${frame}]} 64 | printf " [frame #${frame}] ${BASH_SOURCE[${frame}]}:${funcname}:${BASH_LINENO[${frame}]}" 65 | #printf " [frame #${frame}] ${funcname}" 66 | [ ${frame} -ne 1 ] && printf "\n" || { 67 | [ ${COLOR} -eq 1 ] && fg_magenta 68 | printf " <-- top of stack\n" 69 | [ ${COLOR} -eq 1 ] && fg_blue 70 | } 71 | [ "${funcname}" = "main" ] && break # stop, reached 'main' 72 | [ ${frame} -ge ${STACK_MAXDEPTH} ] && break # just in case ... 73 | let frame=frame+1 74 | done |tee -a ${LOGFILE_COMMON} 75 | [ ${COLOR} -eq 1 ] && color_reset 76 | } 77 | 78 | # params: the error message 79 | cli_handle_error() 80 | { 81 | #QP 82 | if [ $# -lt 1 ] ; then 83 | cecho "FatalError :: " 84 | else 85 | cecho "FatalError :: $*" 86 | fi 87 | dumpstack 88 | [ ${COLOR} -eq 1 ] && color_reset 89 | exit 1 90 | } 91 | 92 | #--------------------- F a t a l E r r o r ---------------------------- 93 | # Exits with exit status 1 ! 94 | # Parameters: 95 | # $1 : error message [optional] 96 | # 97 | # !NOTE! Do NOT use metacharacter (like /\<> etc) in the message body; 98 | # yad fails to interpret them.. 99 | # 100 | # TODO / BUG :: 101 | # the entire background is filled with a blue-ish color; why?? yad bug? us? 102 | FatalError() 103 | { 104 | local msgpre_gui="Sorry, SEALS has encountered a fatal error.\n\n" 105 | local msgpre_con="Sorry, SEALS has encountered a fatal error." # con: console-mode 106 | 107 | local errmsg_gui="Details:\n$(date):${name}:${FUNCNAME[ 1 ]}()" 108 | local errmsg_con="Details: $(date):${name}:${FUNCNAME[ 1 ]}()" 109 | 110 | local msgpost_gui="\n\ 111 | If you feel this is a bug or issue, kindly file a bug report here: 112 | https://github.com/kaiwan/seals/issues 113 | (Or simply copy the full output above and email it here: 114 | ${SEALS_REPORT_ERROR_EMAIL}\n 115 | Many thanks. 116 | " 117 | local msgpost_con="If you feel this is a bug or issue, *please* do raise it as an Issue on this project's GitHub repo 118 | (https://github.com/kaiwan/seals/issues) and copy/paste the full output, adding any relevant details... 119 | Many thanks. 120 | " 121 | local msg_gui msg_con 122 | 123 | [ $# -ne 1 ] && { 124 | msg_gui="${msgpre_gui}${errmsg_gui}\n${msgpost_gui}" 125 | msg_con="${msgpre_con} 126 | ${errmsg_con} 127 | ${msgpost_con}" 128 | } || { 129 | msg_gui="${msgpre_gui}${errmsg_gui}\n \"${1}\"\n${msgpost_gui}" 130 | msg_con="${msgpre_con} 131 | ${errmsg_con} 132 | ${1} 133 | ${msgpost_con}" 134 | } 135 | #cecho "Fatal Error! Details: ${errmsg} ${1}" 136 | 137 | [ ${GUI_MODE} -eq 1 ] && { 138 | 139 | #echo "${msg_con}" 140 | 141 | local title="SEALS: FATAL ERROR!" 142 | yad --title="${title}" --image=dialog-warning --text="${msg_gui}" \ 143 | --button="Close!${ICON_NO}:0" \ 144 | --wrap --text-align=center --button-layout=center --center \ 145 | --selectable-labels --no-escape --dialog-sep --sticky --on-top --skip-taskbar 2>/dev/null & 146 | # also show on the console 147 | cli_handle_error "${msg_con}" #"$@" 148 | } || { 149 | cli_handle_error "${msg_con}" #"$@" 150 | } 151 | exit 1 152 | } # end FatalError() 153 | 154 | # Prompt 155 | # Interactive: prompt the user to continue by pressing ENTER or 156 | # abort by pressing Ctrl-C 157 | # Parameter(s): 158 | # $1 : string to display (string) [required] 159 | # $2 : string to display on signal trap [optional] 160 | Prompt() 161 | { 162 | local msg="*** User Abort detected! ***" x 163 | 164 | trap 'wecho "${msg}" ; dumpstack ; color_reset ; exit 3' HUP INT QUIT 165 | 166 | [ ${COLOR} -eq 1 ] && fg_magenta 167 | echo -n "$1 168 | [Press ENTER to continue, or Ctrl-C to abort now...] " 169 | 170 | # Failed with: read: read error: 0: Resource temporarily unavailable 171 | # sol: https://stackoverflow.com/questions/54775816/read-read-error-0-resource-temporarily-unavailable 172 | exec 3<&0 < /dev/tty #/dev/null 173 | read -r x 174 | # reset 175 | exec 0<&0 < /dev/tty #/dev/null 176 | 177 | [ ${COLOR} -eq 1 ] && color_reset 178 | } # end Prompt() 179 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Part of the SEALs project 3 | # https://github.com/kaiwan/seals 4 | # (c) kaiwanTECH 5 | # Set Bash unofficial 'strict mode'; _really_ helps catch bugs 6 | # ref: http://redsymbol.net/articles/unofficial-bash-strict-mode/ 7 | set -euo pipefail 8 | 9 | name=$(basename $0) 10 | # Fetch the SEALs env 11 | source ./build.config || { 12 | echo "${name}: ./build.config file missing or invalid? using defaults if they exist..." 13 | if [ -d ./images ]; then 14 | STG=./ 15 | else 16 | echo "No ./images/ dir, aborting..." 17 | exit 1 18 | fi 19 | } 20 | source ./common.sh || { 21 | echo "${name}: source failed! ./common.sh missing or invalid?" 22 | exit 1 23 | } 24 | 25 | ShowTitle "SEALS :: Install Script" 26 | [[ -z "${STG}" ]] && { 27 | aecho "${name}: SEALS staging folder isn't defined? You Must correct this and retry..." 28 | aecho "Tip: read the docs (wiki pages), recheck / edit the build.config file" 29 | color_reset 30 | exit 1 31 | } 32 | [[ -d "${STG}" ]] && { 33 | wecho "The staging directory already exists (${STG}). 34 | 35 | OVERWRITE it ? Doing so will DESTROY it's content, you can't recover it: 36 | (As a safety measure, you'll again be prompted before wiping Busybox and the kernel source trees) 37 | y/N ? " 38 | get_yn_reply "" n 39 | [ $? -eq 1 ] && exit 0 40 | } 41 | 42 | aecho "Creating the staging dir..." 43 | mkdir -p ${STG} || FatalError "Creating the staging dir failed (permission issues?). Aborting..." 44 | 45 | #-------------------- Busybox 46 | #BB_INSTALLED=0 47 | echo 48 | set +e # work-around for bash strict mode 49 | get_yn_reply "Pl confirm: Install (and possibly overwrite) busybox source tree (to ${BB_FOLDER}) now? Y/n" y 50 | ans=$? 51 | set -e 52 | 53 | #set -x 54 | if [[ ${ans} -eq 0 ]] ; then # ans 'y' 55 | aecho "Installing the busybox source tree" 56 | [[ -d ${BB_FOLDER} ]] && { 57 | aecho "Deleting old content..." 58 | rm -rf ${BB_FOLDER} "$(dirname ${BB_FOLDER})/busybox" 59 | } 60 | mkdir -p ${BB_FOLDER} # abs pathname #|| FatalError "Creating the staging dir failed (permission issues?). Aborting..." 61 | cd ${STG} 62 | runcmd "git clone --depth=1 https://github.com/mirror/busybox" 63 | rmdir ${BB_FOLDER} || true 64 | #BB_INSTALLED=1 65 | aecho "[+] Busybox source tree installed" 66 | fi 67 | 68 | #-------------------- Linux kernel 69 | #KSRC_INSTALLED=0 70 | echo 71 | set +e # work-around for bash strict mode 72 | get_yn_reply "Pl confirm: Install (and possibly overwrite) kernel source tree (to ${KERNEL_FOLDER}) now? Y/n" y 73 | ans=$? 74 | set -e 75 | 76 | if [[ ${ans} -eq 0 ]] ; then # ans 'y' 77 | aecho "Installing the Linux kernel source tree" 78 | cd ${STG} # abs pathname 79 | # have to figure the URL based on kernel ver... 80 | # f.e. if kver is 3.16.68: 81 | # https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/linux-3.16.68.tar.xz 82 | # support only >=3.x 83 | K_MJ=$(echo ${KERNELVER} | cut -d'.' -f1) 84 | [[ ${K_MJ} -lt 3 ]] && FatalError "Your specified kernel ver (${KERNELVER}) is too old! 85 | SEALS supports only kernel ver >= 3.x. 86 | Pl change the kernel ver (in the build.config) and rerun" 87 | 88 | mkdir -p ${KERNEL_FOLDER} #|| FatalError "Creating the staging dir failed (permission issues?). Aborting..." 89 | #K_MN=$(echo ${KERNELVER} | cut -d'.' -f2) 90 | #K_PL=$(echo ${KERNELVER} | cut -d'.' -f3) 91 | K_URL_BASE=https://mirrors.edge.kernel.org/pub/linux/kernel 92 | K_URL_TARXZ=${K_URL_BASE}/v${K_MJ}.x/linux-${KERNELVER}.tar.xz 93 | 94 | # TODO / FIXME : if the tar.xz file exists, don't wget it... 95 | 96 | [[ -d ${KERNEL_FOLDER} ]] && { 97 | aecho "Deleting old content..." 98 | rm -f "$(basename ${K_URL_TARXZ})"* 99 | rm -rf ${KERNEL_FOLDER} 100 | } 101 | 102 | echo "wget ${K_URL_TARXZ}" 103 | wget ${K_URL_TARXZ} || FatalError "Failed to fetch kernel source." 104 | # TODO - verify integrity 105 | # Uncompress 106 | echo "tar xf $(basename ${K_URL_TARXZ})" 107 | tar xf "$(basename ${K_URL_TARXZ})" || FatalError "Failed to extract kernel source." 108 | #KSRC_INSTALLED=1 109 | aecho "[+] Kernel source tree linux-${KERNELVER} installed" 110 | fi 111 | 112 | # TODO - toolchain install 113 | echo "To install the toolchain (Linux x86_64 host to AArch32 or AArch64 target), pl see: 114 | https://github.com/kaiwan/seals/wiki/SEALs-HOWTO 115 | It has detailed instructions. 116 | " 117 | 118 | aecho "${name}: all done. 119 | You can now run the build_SEALS.sh script." 120 | color_reset 121 | 122 | exit 0 123 | -------------------------------------------------------------------------------- /kgdb_qemu_run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The SEALS Opensource Project 3 | # SEALS : Simple Embedded Arm Linux System 4 | # Maintainer : Kaiwan N Billimoria 5 | # kaiwan -at- kaiwantech -dot- com 6 | # Project URL: 7 | # https://github.com/kaiwan/seals 8 | # (c) kaiwanTECH 9 | name=$(basename $0) 10 | ############################# 11 | # ${BUILD_CONFIG_FILE} : a configuration script that asks the user for and sets up 12 | # folder locations, toolchain PATH, any other configs as required. 13 | ############################# 14 | export BUILD_CONFIG_FILE=./build.config 15 | source ${BUILD_CONFIG_FILE} || { 16 | echo "${name}: source failed! ${BUILD_CONFIG_FILE} missing or invalid?" 17 | exit 1 18 | } 19 | source ./common.sh || { 20 | echo "${name}: source failed! ./common.sh missing or invalid?" 21 | exit 1 22 | } 23 | color_reset 24 | 25 | if [ $# -ne 1 ]; then 26 | echo "Usage: $name kernel-[b]zImage (compiled with -g)" 27 | exit 1 28 | fi 29 | [ ! -f $1 ] && { 30 | echo "$1 invalid.." 31 | exit 1 32 | } 33 | 34 | echo 35 | echo "REMEMBER this kernel is run w/ the -S QEMU switch: it *waits* for a gdb client to connect to it..." 36 | echo 37 | echo "You are expected to run (in another terminal window): 38 | $ ${CXX}gdb /vmlinux # <-- built w/ -g 39 | ... 40 | # and then have gdb connect to the target kernel using 41 | (gdb) target remote :1235 42 | ... 43 | " 44 | echo 45 | 46 | #ARMPLAT=vexpress-a9 ## make sure it's right! ## 47 | # It's IMPORTANT to pass along the Device Tree Blob ! 48 | DTB=${STG}/images/vexpress-v2p-ca9.dtb 49 | PORT=1235 50 | 51 | [ ! -f ${DTB} ] && { 52 | echo "${name}: FATAL: DTB file \"${DTB}\" not present?" 53 | exit 1 54 | } 55 | 56 | cmd="qemu-system-arm -m 256 -M ${ARM_PLATFORM_OPT} -kernel $1 \ 57 | -drive file=${STG}/images/rfs.img,if=sd,format=raw \ 58 | -append \"console=ttyAMA0 root=/dev/mmcblk0 init=/sbin/init\" -nographic \ 59 | -gdb tcp::${PORT} -S \ 60 | -dtb ${DTB}" 61 | # qemu help: 62 | # -gdb dev wait for gdb connection on 'dev' 63 | # -S freeze CPU at startup (use 'c' to start execution) 64 | echo "Running: ${cmd}" 65 | eval "${cmd}" 66 | # 67 | # If you get this error:: 68 | # 69 | # inet_listen_opts: bind(ipv4,0.0.0.0,1234): Address already in use 70 | #inet_listen_opts: bind(ipv6,::,1234): Address already in use 71 | #inet_listen_opts: FAILED 72 | #chardev: opening backend "socket" failed 73 | ## 74 | # try using a different port # (and do 75 | # (gdb) target remote : 76 | -------------------------------------------------------------------------------- /mount_rootfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # The SEALS Opensource Project 4 | # SEALS : Simple Embedded Arm Linux System 5 | # Maintainer : Kaiwan N Billimoria 6 | # kaiwan -at- kaiwantech -dot- com 7 | # Project URL: 8 | # https://github.com/kaiwan/seals 9 | # (c) kaiwanTECH 10 | # 11 | # Loop Mount the QEMU ext4 fs so that one can easily update it.. 12 | # Pl ENSURE that the VM is Not running when you use this script!! 13 | # -the image will/might get corrupted! 14 | # 15 | MNTPT=/mnt/tmp 16 | name=$(basename $0) 17 | LSOF_CHECK=0 18 | 19 | [ $# -ne 1 ] && { 20 | echo "Usage: ${name} " 21 | exit 1 22 | } 23 | [ ! -f $1 ] && { 24 | echo "${name}: root filesystem image file \"${1}\" unavailable, aborting..." 25 | exit 1 26 | } 27 | IMG=$1 28 | 29 | echo "${name}: Rootfs image file: ${IMG}" 30 | 31 | [ ${LSOF_CHECK} -eq 1 ] && { 32 | echo "${name}: Please wait... checking if rootfs image file above is currently in use ..." 33 | sudo lsof 2>/dev/null |grep ${IMG} && { 34 | echo "${name}: Rootfs image file \"${IMG}\" currently in use, aborting..." 35 | echo " Is it being used by a QEMU instance perhaps? If so, shut it down and retry this." 36 | exit 1 37 | } 38 | } 39 | 40 | sudo mkdir -p ${MNTPT} 2>/dev/null 41 | echo "${name}: Okay, loop mounting rootfs image file now ..." 42 | sudo mount |grep -iq ${MNTPT} && { 43 | sync 44 | sudo umount ${MNTPT} 45 | } 46 | sudo mkdir -p ${MNTPT} 2>/dev/null 47 | sudo mount -o loop -t ext4 ${IMG} ${MNTPT} && { 48 | echo "${IMG} loop mounted at ${MNTPT}" 49 | mount |grep "${IMG}" 50 | echo 51 | echo "Update fs contents, then remember you MUST umount it ..." 52 | echo 53 | echo "ls ${MNTPT} :" 54 | sudo ls ${MNTPT} 55 | } || { 56 | echo "${name}: ${IMG} loop mounting failed! aborting..." 57 | exit 1 58 | } 59 | # Once done updating, just umount & run with QEMU via the build script 60 | # (or the run-direct.sh script). 61 | -------------------------------------------------------------------------------- /run-qemu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Part of the SEALs project 3 | # https://github.com/kaiwan/seals 4 | # (c) kaiwanTECH 5 | # Set Bash unofficial 'strict mode'; _really_ helps catch bugs 6 | # ref: http://redsymbol.net/articles/unofficial-bash-strict-mode/ 7 | set -euo pipefail 8 | 9 | name=$(basename $0) 10 | # Fetch the SEALs env 11 | source ./build.config || { 12 | echo "${name}: ./build.config file missing or invalid? using defaults if they exist..." 13 | if [ -d ./images ]; then 14 | STG=./ 15 | else 16 | echo "No ./images/ dir, aborting..." 17 | exit 1 18 | fi 19 | } 20 | [ -z "${STG}" -o ! -d "${STG}" ] && { 21 | echo "${name}: SEALS staging folder \"${STG}\" invalid, pl correct and retry..." 22 | echo "Tip: check/edit the build.config file" 23 | exit 1 24 | } 25 | source ./common.sh || { 26 | echo "${name}: source failed! ./common.sh missing or invalid?" 27 | exit 1 28 | } 29 | color_reset 30 | 31 | cd ${TOPDIR} || exit 1 32 | 33 | SMP_EMU="" 34 | if [ ${SMP_EMU_MODE} -eq 1 ]; then 35 | # Using the "-smp n,sockets=n" QEMU options lets us emulate n processors! 36 | # (can do this only for appropriate platforms) 37 | SMP_EMU="-smp 4,sockets=2" 38 | fi 39 | 40 | KGDB_MODE=0 41 | [ $# -ne 1 ] && { 42 | echo "Usage: ${name} boot-option 43 | boot-option == 0 : normal console boot; use this unless you want a KGDB session 44 | boot-option == 1 : console boot in KGDB mode (-s -S, waits for GDB client to connect) 45 | Expect you've configured a kernel for KGDB and have the vmlinux handy; 46 | If booting in KGDB mode, the emulator will wait (via the embedded GDB server within the kernel!); 47 | you're expected to run ${CXX}gdb in another terminal window 48 | and issue the 49 | (gdb) target remote :1234 50 | command to connect to the ARM/Linux kernel." 51 | exit 1 52 | } 53 | [ $1 -eq 1 ] && KGDB_MODE=1 54 | 55 | echo "TIP: 56 | *** If another hypervisor (like VirtualBox) is running, Qemu run with KVM support won't work properly *** 57 | " 58 | ShowTitle " 59 | RUN: Running ${QEMUNAME} now ..." 60 | 61 | # Device Tree Blob (DTB) pathname 62 | DTB_BLOB_IMG="" 63 | [[ ! -z "${DTB_BLOB}" ]] && { 64 | export DTB_BLOB_PATHNAME=${IMAGES_FOLDER}/${DTB_BLOB} # gen within kernel src tree 65 | DTB_BLOB_IMG=${IMAGES_FOLDER}/$(basename ${DTB_BLOB}) # within image folder 66 | } 67 | 68 | # TODO - when ARCH is x86[_64], use Qemu's --enable-kvm to give a big speedup! 69 | 70 | # TODO : Networking 71 | # ref: https://gist.github.com/extremecoders-re/e8fd8a67a515fee0c873dcafc81d811c#example-tap-network 72 | 73 | RUNCMD="" 74 | if [ "${ARCH}" = "arm" ]; then 75 | RUNCMD="${QEMUNAME} -m ${SEALS_RAM} -M ${ARM_PLATFORM_OPT} \ 76 | -cpu max ${SMP_EMU} -cpu ${CPU_MODEL} \ 77 | -kernel ${IMAGES_FOLDER}/zImage \ 78 | -drive file=${IMAGES_FOLDER}/rfs.img,if=sd,format=raw \ 79 | -append \"${SEALS_K_CMDLINE}\" -nographic -no-reboot" 80 | [ -f ${DTB_BLOB_PATHNAME} ] && RUNCMD="${RUNCMD} -dtb ${DTB_BLOB_PATHNAME}" 81 | 82 | elif [ "${ARCH}" = "arm64" ]; then 83 | 84 | RUNCMD="${QEMUNAME} -m ${SEALS_RAM} -M ${ARM_PLATFORM_OPT} \ 85 | -cpu max ${SMP_EMU} -cpu ${CPU_MODEL} \ 86 | -kernel ${IMAGES_FOLDER}/Image.gz \ 87 | -drive file=${IMAGES_FOLDER}/rfs.img,format=raw,id=drive0 \ 88 | -append \"${SEALS_K_CMDLINE}\" -nographic -no-reboot" 89 | # no DTB for the 'dummy,virt' platform 90 | #set -x 91 | #echo "DTB_BLOB_IMG = ${DTB_BLOB_IMG}" 92 | [[ -f ${DTB_BLOB_IMG} && -n "${DTB_BLOB_IMG}" ]] && RUNCMD="${RUNCMD} -dtb ${DTB_BLOB_IMG}" 93 | 94 | elif [ "${ARCH_PLATFORM}" = "x86_64" ]; then 95 | 96 | # echo "SEALS_K_CMDLINE = ${SEALS_K_CMDLINE}" 97 | RUNCMD="${QEMUNAME} -M ${CPU_MODEL} -m ${SEALS_RAM} \ 98 | -cpu max ${SMP_EMU} \ 99 | -kernel ${IMAGES_FOLDER}/bzImage \ 100 | -drive file=${IMAGES_FOLDER}/rfs.img,format=raw,id=drive0 \ 101 | -append \"${SEALS_K_CMDLINE}\" \ 102 | -nographic -no-reboot" 103 | [[ ${USE_INITRAMFS} -eq 1 ]] && RUNCMD="${RUNCMD} -initrd ${IMAGES_FOLDER}/initrd.img" 104 | fi 105 | 106 | [[ -z "${RUNCMD}" ]] && { 107 | echo "${name}: FATAL: no run command defined, aborting..." 108 | exit 1 109 | } 110 | 111 | # Run it! 112 | if [ ${KGDB_MODE} -eq 1 ]; then 113 | # KGDB/QEMU cmdline 114 | ShowTitle "Running ${QEMUNAME} in KGDB mode now ..." 115 | RUNCMD="${RUNCMD} -s -S" 116 | # qemu-system-xxx(1) : 117 | # -S Do not start CPU at startup (you must type 'c' in the monitor). 118 | # -s Shorthand for -gdb tcp::1234, i.e. open a gdbserver on TCP port 1234. 119 | aecho " 120 | @@@@@@@@@@@@ NOTE NOTE NOTE @@@@@@@@@@@@ 121 | REMEMBER this qemu instance is run with the -S option: it *waits* for a GDB client to connect to it... 122 | 123 | You are expected to run (in another terminal window): 124 | $ ${CXX}gdb /vmlinux <-- built w/ -g 125 | ... 126 | and then have GDB connect to the target kernel using 127 | (gdb) target remote :1234 128 | ... 129 | @@@@@@@@@@@@ NOTE NOTE NOTE @@@@@@@@@@@@" 130 | fi 131 | 132 | echo "${RUNCMD}" |tee -a ${LOGFILE_COMMON} 133 | #echo "${RUNCMD}" > cmd1 134 | #aecho "${RUNCMD} 135 | #" 136 | Prompt "Ok? (after pressing ENTER, give it a moment ...) 137 | 138 | Also, please exit the Qemu VM by properly shutting down: 139 | use the 'poweroff' command to do so. 140 | (Worst case, typing Ctrl-a x (abruptly) shuts Qemu - and thus the guest platform - down). 141 | " 142 | # if we're still here, it's about to run! 143 | eval ${RUNCMD} |tee -a ${LOGFILE_COMMON} 144 | 145 | aecho " 146 | ... and done." 147 | -------------------------------------------------------------------------------- /run_and_log: -------------------------------------------------------------------------------- 1 | # SEALS : run-and-log 2 | # Part of the SEALS opensource project (https://github.com/kaiwan/seals) 3 | # logfile_post_process 4 | # Issue: using the 'color' routines (like wecho, aecho, techo, etc) causes 5 | # escape chars to get embedded into the logfile. This addresses how to get 6 | # rid of the color escape sequences. 7 | 8 | # Set Bash unofficial 'strict mode'; _really_ helps catch bugs 9 | # ref: http://redsymbol.net/articles/unofficial-bash-strict-mode/ 10 | set -euo pipefail 11 | 12 | logfile_post_process() 13 | { 14 | sed -i.bkp "/###\:\:\:/d" ${1} # take a backup & get rid of the signature line 15 | sed -i "s/\x1b.....//g" ${1} # get rid of the ^[(B^[[m characters ! 16 | # '\x1b' is ESC ! Find it, and then delete it and the following 5 chars 17 | # (the five .'s that follow specify this) 18 | } 19 | 20 | LOG=log_seals.txt 21 | # stderr to tee is causing issues with 'menuconfig' target 22 | # but now no stderr logging?? 23 | ./build_SEALS.sh | tee -a ${LOG} 24 | logfile_post_process ${LOG} 25 | ls -lh ${LOG} 26 | -------------------------------------------------------------------------------- /show_curr_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Part of the SEALS opensource Project 3 | # SEALS : Simple Embedded Arm Linux System 4 | # Author and Maintainer : Kaiwan N Billimoria 5 | # Project URL: 6 | # https://github.com/kaiwan/seals 7 | #---------------------------------------------------------------------- 8 | # Important: 9 | # To get started, pl read: 10 | # https://github.com/kaiwan/seals/wiki 11 | # (and follow the links on the right panel of the Wiki page). 12 | #---------------------------------------------------------------------- 13 | # ${BUILD_CONFIG_FILE} : a configuration script that asks the user for and sets up 14 | # folder locations, toolchain PATH, any other configs as required. 15 | ############################# 16 | 17 | # Turn on Bash 'strict mode'! 18 | # ref: http://redsymbol.net/articles/unofficial-bash-strict-mode/ 19 | set -euo pipefail 20 | 21 | export name=$(basename $0) 22 | export BUILD_CONFIG_FILE=./build.config 23 | source ${BUILD_CONFIG_FILE} || { 24 | echo "${name}: source failed! ${BUILD_CONFIG_FILE} missing or invalid?" 25 | exit 1 26 | } 27 | source ./common.sh || { 28 | echo "${name}: source failed! ./common.sh missing or invalid?" 29 | exit 1 30 | } 31 | 32 | show_curr_build_config() 33 | { 34 | local gccver=$(${CXX}gcc --version |head -n1 |cut -f2- -d" ") 35 | 36 | aecho " ---------------- Current Configuration -----------------" 37 | local msg1=" 38 | Config file : build.config -> $(realpath ${BUILD_CONFIG_FILE}) [edit it to change any settings shown below] 39 | Config name : ${CONFIG_NAME_STR} 40 | 41 | Toolchain prefix : ${CXX} 42 | Toolchain version: ${gccver} 43 | Staging folder : ${STG} 44 | 45 | CPU arch : ${ARCH} 46 | CPU model : ${CPU_MODEL}" 47 | 48 | local msg2="ARM Platform : ${ARM_PLATFORM_STR}" 49 | 50 | local msg3=" 51 | Platform RAM : ${SEALS_RAM} MB 52 | 53 | RootFS force rebuild : $(yesorno ${RFS_FORCE_REBUILD}) 54 | RootFS size : ${RFS_SZ_MB} MB [note: new size applied only on 'RootFS force rebuild'] 55 | 56 | Linux kernel to use : ${KERNELVER} 57 | Linux kernel codebase location : ${KERNEL_FOLDER} 58 | Kernel command-line : \"${SEALS_K_CMDLINE}\" 59 | Verbose Build : $(yesorno ${VERBOSE_BUILD}) 60 | Busybox location: ${BB_FOLDER} 61 | 62 | Qemu: KGDB mode: $(yesorno ${KGDB_MODE}) | SMP mode: $(yesorno ${SMP_EMU_MODE}) 63 | 64 | Diplay: 65 | Terminal Colors mode: $(yesorno ${COLOR}) | DEBUG mode: $(yesorno ${DEBUG}) | VERBOSE mode: $(yesorno ${VERBOSE_MSG}) 66 | Log file : ${LOGFILE_COMMON}" 67 | 68 | echo "${msg1}" 69 | [[ "${ARCH}" != "x86" ]] && echo "${msg2}" 70 | echo "${msg3}" 71 | echo "----------------------------------------------------------" 72 | } 73 | 74 | show_stg() 75 | { 76 | [[ ! -d ${STG} ]] && { 77 | becho "!WARNING! Staging dir ${STG} not present." 78 | return 79 | } 80 | becho "Staging area ::" 81 | ls ${STG}/ 82 | echo 83 | becho "Latest images ::" 84 | ls -lth ${STG}/images 85 | } 86 | 87 | 88 | #--- 'main' 89 | color_reset 90 | export PRJ_TITLE="SEALS: Simple Embedded ARM Linux System" 91 | techo "${PRJ_TITLE}" 92 | 93 | if [[ "${ARCH}" != "x86" ]] ; then 94 | which ${CXX}gcc >/dev/null || becho "!WARNING! Toolchain ${CXX}* doesn't seem to be installed correctly" 95 | fi 96 | show_curr_build_config 97 | show_stg 98 | exit 0 99 | -------------------------------------------------------------------------------- /test/build.config: -------------------------------------------------------------------------------- 1 | build.config.arm64_rpi3b_cm3 -------------------------------------------------------------------------------- /test/build.config.amd64: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ####################################################################### 3 | # build.config 4 | # 5 | # *TEST* config 6 | # 7 | # Part of the SEALs project. 8 | # This is the configuration file; all config variables must go here. 9 | # 10 | # !! IMP NOTE TO THE END-USER OF THIS PROJECT !! 11 | # You are responsible for editing this configuration file, setting the 12 | # variables to sane values. 13 | # To help you out, the place in the source below which has the config 14 | # variables that you MUST update have been marked with a comment line 15 | # as follows: 16 | # # @@@@@ 17 | # So, you could just search for this string '@@@@@' (excluding the quotes of course), 18 | # and make sure you update the following config variable(s) to the sane value 19 | # for your box. 20 | # !! 21 | #--- 22 | # Author: Kaiwan N Billimoria 23 | # (C) kaiwanTECH 24 | #--- 25 | ####################################################################### 26 | # 27 | #---------------------- 28 | # !!!VERY IMPORTANT!!! 29 | #---------------------- 30 | # Pl read the documentation here, at least once: 31 | # https://github.com/kaiwan/seals/wiki 32 | #---------------------- 33 | # 34 | # Generic Config file. 35 | # For a minimal QEMU-ARM project, we Expect that: 36 | # 37 | # - an x86_64-to-ARM32 toolchain is installed and working, and setup in the config below 38 | # details: https://github.com/kaiwan/seals/wiki/HOWTO-Install-required-packages-on-the-Host-for-SEALS 39 | # - a recent version of the Linux kernel source tree is available and setup in the config below 40 | # - a recent version of busybox source tree is available and setup in the config below 41 | ############## 42 | 43 | set -a # auto export all vars 44 | 45 | ##################### UPDATE as required 46 | # @@@@@ 47 | CONFIG_NAME_STR="SEALs config file for the PC ! (AMD64 / x86_64)" 48 | COLOR=1 # terminal color support? Assume yes.. 49 | GUI_MODE=0 # auto-detects GUI / console mode 50 | DEBUG=0 # set to 1 to get debug messages displayed 51 | VERBOSE_MSG=0 # set to 1 to get more verbose messages displayed 52 | # [loglevel][date-timestamp] 53 | LOGFILE_COMMON=log_seals.txt 54 | 55 | ###------### 56 | TOPDIR=$(pwd) 57 | 58 | ### Locations on Disk ### 59 | ### UPDATE ### on your system! 60 | # @@@@@ 61 | STG=~/seals_staging/seals_staging_pc 62 | # Recommendation: if running a cloud-sync service (like pCloud/Dropbox), 63 | # keep the staging area outside it. 64 | 65 | # Okay, so under the ${STG} folder, we expect you have extracted the 66 | # Toolchain: the toolchain to use; expect that it is installed and the PATH is setup.. 67 | # @@@@@ 68 | # For the PC, we don't need a special toolchain; the native one on the build host is fine! 69 | CXX="" 70 | # CXX_LOC is the location of the x86-to-ARM toolchain on disk 71 | # (used to setup the PATH and locate the ARM shared libraries within the toolchain) 72 | # @@@@@ 73 | CXX_LOC="" 74 | 75 | # Toolchain in the PATH 76 | PATH=$PATH:${CXX_LOC}/bin 77 | 78 | # Verbose build? (if 1, we run as 'make V=1 ...') 79 | VERBOSE_BUILD=0 80 | 81 | 82 | # Also under the ${STG} folder, we expect you have extracted the 83 | # source of busybox into the folder ${BB_FOLDER} ver ${BB_VER}. 84 | # (Update the variables below to reflect your settings and installation). 85 | # @@@@@ 86 | BB_VER="1.33.2" 87 | # 1.29 : build failing with a linker error 88 | BB_FOLDER=${STG}/busybox 89 | SHELL2RUN=/bin/sh #/bin/bash 90 | ROOTFS=${STG}/rootfs 91 | ROOTFS_PC=${STG}/rootfs_pc 92 | IMAGES_FOLDER=${STG}/images 93 | IMAGES_BKP_FOLDER=${STG}/images_bkp 94 | CONFIGS_FOLDER=${STG}/configs 95 | 96 | 97 | ##### 98 | # @@@@@ 99 | # Set to exactly one of: 100 | # arc arm64 csky hexagon m68k mips nios2 parisc riscv sh um x86_64 101 | # alpha arm c6x h8300 ia64 microblaze nds32 openrisc powerpc s390 sparc x86 xtensa 102 | # TODO / RELOOK - do we need this ?? 103 | ARCH_SPEC=x86_64 104 | 105 | # Select the platform (to build the kernel for). Choices: 106 | # For the purpose of a "real" example, this file is pre-populated with values 107 | # relevant to the Qemu Verastile Express (vexpress) platform (ARMv7 Cortex-A9). 108 | # @@@@@ 109 | # English-like name 110 | ARCH_PLATFORM_STR="AMD64" 111 | 112 | # ! IMPORTANT ! 113 | # Pl set the variable ARCH_PLATFORM carefully; it will be used to setup 114 | # the inital config and is therefore very critical that it's given correctly: 115 | # make ARCH=${ARCH_SPEC} ${ARCH_PLATFORM}_defconfig 116 | # So, check under /arch//configs/ 117 | # for the best match to your platform, in the form 118 | # _defconfig 119 | # and put it here.. 120 | # For AMD64, put 'x86_64' 121 | ARCH_PLATFORM=x86_64 122 | 123 | # ARCH_PLATFORM_OPT is the value passed via the -M switch to Qemu 124 | # Look for it via qemu-system-arm -M ? ; eg. 125 | # qemu-system-arm -M ? |grep -i "i.mx" 126 | # For AMD64, comment it out! 127 | #ARCH_PLATFORM_OPT=vexpress-a9 128 | 129 | # For this platform - AMD64 (or x86_64) - many options are simply NULL 130 | ARCH="x86" #x86_64" 131 | CPU_MODEL="pc" # -M option to Qemu ; becomes 'Standard PC (i440FX + PIIX, 1996) (alias of pc-i440fx-7.2)' 132 | ARM_PLATFORM="" 133 | ARM_PLATFORM_STR="" 134 | DTB_BLOB="" 135 | DTB_BLOB_PATHNAME="" 136 | 137 | ### UPDATE ### on your system! 138 | # Okay, so under the ${STG} folder (or other), we expect you have extracted the 139 | # source of the Linux kernel into ${KERNEL_FOLDER} , ver ${KERNELVER}. 140 | # (Update the variables below to reflect your settings and installation). 141 | # @@@@@ 142 | KERNELVER=6.6.6 #6.1.25 143 | KERNEL_FOLDER=${STG}/linux-${KERNELVER}/ 144 | 145 | # @@@@@ 146 | # Set to 1 to build the initramfs image and use it at boot 147 | USE_INITRAMFS=1 148 | 149 | # @@@@@ 150 | # DTB: specify the Device Tree Blob .dtb 151 | #DTB_BLOB=vexpress-v2p-ca9.dtb 152 | ##### 153 | 154 | ##### 155 | # @@@@@ 156 | # SEALs (virtual) "Hardware" 157 | SEALS_RAM=1024 # MB 158 | 159 | ##### 160 | # ROOTFS 161 | # !Careful! Set to 1 to force a rebuild of the rootfs; implies OVERWRITING any 162 | # existing rootfs 163 | RFS_FORCE_REBUILD=0 164 | # Rootfs size: Recommendation: if using a kdump kernel, as a rough thumb rule, 165 | # make it ~ 150% of the size of RAM on the platform (so for eg. if the RAM is 512M, 166 | # make the rootfs size ~ >= 768 MB). 167 | # Else (no kdump), 512 MB is fine for the Vexpress. 168 | RFS_SZ_MB=512 169 | 170 | MYPRJ=myprj 171 | 172 | ##### 173 | # @@@@@ 174 | # SEALs kernel command-line 175 | SEALS_K_CMDLINE="console=ttyS0 console=ttyS1 tsc=reliable no_timer_check nokaslr root=/dev/sda rw init=/sbin/init" #/bin/bash" #/sbin/init" 176 | 177 | # if 512M RAM, reserve 32M for crashk, else if 256M RAM, reserve 16M 178 | #K_CMDLINE_XTRA="crashkernel=32M" # works with 32M not 16M [?] 179 | #K_CMDLINE_XTRA="initcall_debug ignore_loglevel debug" 180 | K_CMDLINE_XTRA="" 181 | [ ! -z "${K_CMDLINE_XTRA}" ] && SEALS_K_CMDLINE="${SEALS_K_CMDLINE} ${K_CMDLINE_XTRA}" 182 | 183 | ##### Config vars for what to build 184 | # VAR=1 : 'do' the work 'VAR' 185 | # VAR=0 : 'do Not' do the work 'VAR' 186 | BUILD_KERNEL=1 187 | BUILD_ROOTFS=1 188 | GEN_EXT4_ROOTFS_IMAGE=1 189 | SAVE_BACKUP_IMG_CONFIGS=1 190 | RUN_QEMU=1 191 | 192 | 193 | 194 | ### "WIPE_*_CONFIG" directives 195 | # Set var to 'y' implies any existing kernel configuration is wiped out. 196 | # Suggestion: set to 'y' for the FIRST build with a clean kernel source tree.. 197 | # @@@@@ 198 | WIPE_KERNEL_CONFIG=1 199 | # Set var to 'y' implies any existing busybox configuration is wiped out. 200 | # Suggestion: set to 'y' for the FIRST build with a clean busybox source tree.. 201 | # @@@@@ 202 | WIPE_BUSYBOX_CONFIG=1 203 | 204 | 205 | ### 206 | # Config vars for when we run QEMU: 207 | QEMUPKG=qemu-system-${ARCH_PLATFORM} 208 | KGDB_MODE=0 # make '1' to have qemu run with the '-s -S' switch (waits for client GDB to 'connect') 209 | SMP_EMU_MODE=1 # make '1' to have qemu run w/ 2 emulated cores 210 | 211 | #--- End build.config 212 | -------------------------------------------------------------------------------- /test/build.config.arm32_vexpress: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ####################################################################### 3 | # build.config.arm32_vexpress 4 | # 5 | # *TEST* config 6 | # 7 | # Part of the SEALs project. 8 | # This is the configuration file; all config variables must go here. 9 | # 10 | # !! IMP NOTE TO THE END-USER OF THIS PROJECT !! 11 | # You are responsible for editing this configuration file, setting the 12 | # variables to sane values. 13 | # To help you out, the place in the source below which has the config 14 | # variables that you MUST update have been marked with a comment line 15 | # as follows: 16 | # # @@@@@ 17 | # So, you could just search for this string '@@@@@' (excluding the quotes of course), 18 | # and make sure you update the following config variable(s) to the sane value 19 | # for your box. 20 | # !! 21 | #--- 22 | # Author: Kaiwan N Billimoria 23 | # (C) kaiwanTECH 24 | #--- 25 | ####################################################################### 26 | # 27 | #---------------------- 28 | # !!!VERY IMPORTANT!!! 29 | #---------------------- 30 | # Pl read the documentation here, at least once: 31 | # https://github.com/kaiwan/seals/wiki 32 | #---------------------- 33 | # 34 | # Generic Config file. 35 | # For a minimal QEMU-ARM project, we Expect that: 36 | # 37 | # - an appropriate toolchain is installed and working, and setup in the config below 38 | # details: https://github.com/kaiwan/seals/wiki/HOWTO-Install-required-packages-on-the-Host-for-SEALS 39 | # - a recent version of the Linux kernel source tree is available and setup in the config below 40 | # - a recent version of busybox source tree is available and setup in the config below 41 | ############## 42 | 43 | set -a # auto export all vars 44 | 45 | #--------GENERIC CONFIG OPTIONS------------------------------------------------------------ 46 | ##################### UPDATE as required 47 | # @@@@@ 48 | CONFIG_NAME_STR="SEALs config file for ARM-32 Versatile Express (vexpress-a15) board" 49 | COLOR=1 # terminal color support? Assume yes.. 50 | GUI_MODE=0 # auto-detects GUI / console mode 51 | DEBUG=0 # set to 1 to get debug messages displayed 52 | [ ${DEBUG} -eq 1 ] && export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' 53 | VERBOSE_MSG=0 # set to 1 to get more verbose messages displayed 54 | # [loglevel][date-timestamp] 55 | LOGFILE_COMMON=log_seals.txt 56 | 57 | ###------### 58 | TOPDIR=$(pwd) 59 | #------------------------------------------------------------------------------ 60 | 61 | #--------KEY DISK LOCATIONS and Settings--------------------------------------- 62 | ### Locations on Disk ### 63 | ### UPDATE ### on your system! 64 | # @@@@@ 65 | STG=~/seals_staging/seals_staging_arm32 66 | # Recommendation: if running a cloud-sync service (like Dropbox), keep the 67 | # staging area outside it. 68 | ROOTFS=${STG}/rootfs 69 | IMAGES_FOLDER=${STG}/images 70 | IMAGES_BKP_FOLDER=${STG}/images_bkp 71 | CONFIGS_FOLDER=${STG}/configs 72 | # Verbose build (for the kernel and busybox)? (if 1, we run as 'make V=1 ...') 73 | VERBOSE_BUILD=0 74 | #------------------------------------------------------------------------------ 75 | 76 | #--------'HARDWARE'------------------------------------------------------------ 77 | # SEALs (virtual) "Hardware" 78 | # @@@@@ 79 | # Select the CPU arch (to build the kernel for); the value to specify is the 80 | # name of the dir under /arch/XXX 81 | ARCH=arm 82 | ARCH_PLATFORM="" 83 | #ARCH=arm64 84 | QEMUPKG=qemu-system-${ARCH} 85 | [[ "${ARCH}" = "arm64" ]] && QEMUPKG=qemu-system-aarch64 86 | 87 | CPU_MODEL=cortex-a15 88 | SEALS_RAM=512 # MB 89 | 90 | # Select the platform (to build the kernel for). 91 | # @@@@@ 92 | # English-like name 93 | ARM_PLATFORM_STR="Versatile Express (A15)" 94 | 95 | # ! IMPORTANT ! 96 | # Selecting the platform varies with the ARCH: 97 | # ===> For Aarch32 (ARM): 98 | # Pl set the variable ARM_PLATFORM carefully; it will be used to setup 99 | # the inital config and is therefore very critical that it's given correctly: 100 | # make ARCH=arm ${ARM_PLATFORM}_defconfig 101 | # So, check under /arch//configs/ 102 | # for the best match to your platform, in the form 103 | # _defconfig 104 | # and put it here.. F.e.: 105 | ARM_PLATFORM=vexpress 106 | # 107 | # ===> For Aarch64 (arm64): 108 | # On Aarch64, all platforms will be selected by default. 109 | # (Can see them within the 'Platform selection' menu). 110 | # Either build it this way or deselect all and enable only the platform(s) you want to support... 111 | # So here, we leave the variable ARM_PLATFORM as NULL to fulfill the default case (all platforms) 112 | #ARM_PLATFORM= 113 | 114 | # ARM_PLATFORM_OPT is the value passed via the -M (machine) switch to Qemu 115 | # Look for it via qemu-system-arm -M ? ; eg. 116 | # qemu-system-arm -M ? |grep -i "i.mx" 117 | ARM_PLATFORM_OPT=vexpress-a15 118 | 119 | SMP_EMU_MODE=1 # make '1' to have qemu run w/ 4 emulated cores 120 | # (only works on appropriate h/w-emulated platforms) 121 | #------------------------------------------------------------------------------ 122 | 123 | 124 | # Okay, so under the ${STG} folder, we expect you have extracted the: 125 | 126 | #--------TOOLCHAIN------------------------------------------------------------ 127 | # The toolchain to use; expect that it is installed and the PATH is setup.. 128 | # @@@@@ 129 | CXX=arm-none-linux-gnueabihf- # toolchain prefix 130 | # CXX_LOC is the location of the x86-to-ARM toolchain on disk 131 | # (used to setup the PATH and locate the ARM shared libraries within the toolchain) 132 | # @@@@@ 133 | CXX_LOC=~/tc/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-linux-gnueabihf/bin 134 | # Keep your toolchain in the PATH 135 | PATH=$PATH:${CXX_LOC}/bin 136 | #------------------------------------------------------------------------------ 137 | 138 | #--------KERNEL------------------------------------------------------------ 139 | ### UPDATE ### on your system! 140 | # Okay, so under the ${STG} folder (or other), we expect you have extracted the 141 | # source of the Linux kernel into ${KERNEL_FOLDER} , ver ${KERNELVER}. 142 | # (Update the variables below to reflect your settings and installation). 143 | # @@@@@ 144 | KERNELVER=6.1.25 145 | KERNEL_FOLDER=${STG}/linux-${KERNELVER}/ 146 | 147 | # @@@@@ 148 | # DTB: specify the Device Tree Blob .dtb 149 | # (Leave empty for the Aarch64 Qemu virt system) 150 | DTB_BLOB=vexpress-v2p-ca15_a7.dtb 151 | ##### 152 | 153 | # @@@@@ 154 | # SEALs kernel command-line 155 | SEALS_K_CMDLINE="console=ttyAMA0 root=/dev/mmcblk0 rw init=/sbin/init" 156 | # if 512M RAM, reserve 32M for crashk, else if 256M RAM, reserve 16M 157 | K_CMDLINE_XTRA="" 158 | #K_CMDLINE_XTRA="crashkernel=32M" # works with 32M not 16M [?] 159 | #K_CMDLINE_XTRA="initcall_debug ignore_loglevel debug" 160 | [ ! -z "${K_CMDLINE_XTRA}" ] && SEALS_K_CMDLINE="${SEALS_K_CMDLINE} ${K_CMDLINE_XTRA}" 161 | 162 | #--------BUSYBOX and ROOTFS------------------------------------------------------------ 163 | # Also under the ${STG} folder, we expect you have extracted the 164 | # source of busybox into the folder ${BB_FOLDER} ver ${BB_VER}. 165 | # (Update the variables below to reflect your settings and installation). 166 | # @@@@@ 167 | BB_FOLDER=${STG}/busybox # the src seems to reside only in the dir named 'busybox' and ! 'busybox-' 168 | SHELL2RUN=/bin/sh #/bin/bash 169 | 170 | ## RootFS 171 | # !Careful! Set to 1 to force a rebuild of the rootfs; implies OVERWRITING any 172 | # existing rootfs 173 | RFS_FORCE_REBUILD=0 174 | # Rootfs size: Recommendation: if using a kdump kernel, as a rough thumb rule, 175 | # make it ~ 150% of the size of RAM on the platform (so for eg. if the RAM is 512M, 176 | # make the rootfs size ~ >= 768 MB). 177 | # Else (no kdump), 512 MB is fine for the Vexpress. 178 | RFS_SZ_MB=512 179 | MYPRJ=myprj 180 | #------------------------------------------------------------------------------ 181 | 182 | #--------MISC / REMAINING Options------------------------------------------------------------ 183 | ##### Config vars for what to build 184 | # VAR=1 : 'do' the work 'VAR' 185 | # VAR=0 : 'do Not' do the work 'VAR' 186 | BUILD_KERNEL=1 187 | BUILD_ROOTFS=1 188 | GEN_EXT4_ROOTFS_IMAGE=1 189 | SAVE_BACKUP_IMG_CONFIGS=1 190 | RUN_QEMU=1 191 | #SHELL_PROMPT_STR="qarm64 \w # " 192 | 193 | ### "WIPE_*_CONFIG" directives 194 | # Set var to 'y' implies any existing kernel configuration is wiped out. 195 | # Suggestion: set to 'y' for the FIRST build with a clean kernel source tree.. 196 | # @@@@@ 197 | WIPE_KERNEL_CONFIG=1 198 | # Set var to 'y' implies any existing busybox configuration is wiped out. 199 | # Suggestion: set to 'y' for the FIRST build with a clean busybox source tree.. 200 | # @@@@@ 201 | WIPE_BUSYBOX_CONFIG=1 202 | 203 | ### 204 | # Config vars for when we run QEMU: 205 | KGDB_MODE=0 # make '1' to have qemu run w/ the '-S' switch (waits for gdb to 'connect') 206 | #------------------------------------------------------------------------------ 207 | 208 | #--- End build.config 209 | -------------------------------------------------------------------------------- /test/build.config.arm64_qemuvirt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ####################################################################### 3 | # build.config.arm64_qemuvirt 4 | # 5 | # *TEST* config 6 | # 7 | # Part of the SEALs project. 8 | # This is the configuration file; all config variables must go here. 9 | # 10 | # !! IMP NOTE TO THE END-USER OF THIS PROJECT !! 11 | # You are responsible for editing this configuration file, setting the 12 | # variables to sane values. 13 | # To help you out, the place in the source below which has the config 14 | # variables that you MUST update have been marked with a comment line 15 | # as follows: 16 | # # @@@@@ 17 | # So, you could just search for this string '@@@@@' (excluding the quotes of course), 18 | # and make sure you update the following config variable(s) to the sane value 19 | # for your box. 20 | # !! 21 | #--- 22 | # Author: Kaiwan N Billimoria 23 | # (C) kaiwanTECH 24 | #--- 25 | ####################################################################### 26 | # 27 | #---------------------- 28 | # !!!VERY IMPORTANT!!! 29 | #---------------------- 30 | # Pl read the documentation here, at least once: 31 | # https://github.com/kaiwan/seals/wiki 32 | #---------------------- 33 | # 34 | # Generic Config file. 35 | # For a minimal QEMU-ARM project, we Expect that: 36 | # 37 | # - an appropriate toolchain is installed and working, and setup in the config below 38 | # details: https://github.com/kaiwan/seals/wiki/HOWTO-Install-required-packages-on-the-Host-for-SEALS 39 | # - a recent version of the Linux kernel source tree is available and setup in the config below 40 | # - a recent version of busybox source tree is available and setup in the config below 41 | ############## 42 | 43 | set -a # auto export all vars 44 | 45 | #--------GENERIC CONFIG OPTIONS------------------------------------------------------------ 46 | ##################### UPDATE as required 47 | # @@@@@ 48 | CONFIG_NAME_STR="SEALs config file for generic AArch64 (ARM64) Virt system" 49 | COLOR=1 # terminal color support? Assume yes.. 50 | GUI_MODE=0 # auto-detects GUI / console mode 51 | DEBUG=0 # set to 1 to get debug messages displayed 52 | [ ${DEBUG} -eq 1 ] && export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' 53 | VERBOSE_MSG=0 # set to 1 to get more verbose messages displayed 54 | # [loglevel][date-timestamp] 55 | LOGFILE_COMMON=log_seals.txt 56 | 57 | ###------### 58 | TOPDIR=$(pwd) 59 | #------------------------------------------------------------------------------ 60 | 61 | #--------KEY DISK LOCATIONS and Settings--------------------------------------- 62 | ### Locations on Disk ### 63 | ### UPDATE ### on your system! 64 | # @@@@@ 65 | STG=~/seals_staging/seals_staging_aarch64 66 | # Recommendation: if running a cloud-sync service (like pCloud/Dropbox), keep the 67 | # staging area outside it. 68 | ROOTFS=${STG}/rootfs 69 | IMAGES_FOLDER=${STG}/images 70 | IMAGES_BKP_FOLDER=${STG}/images_bkp 71 | CONFIGS_FOLDER=${STG}/configs 72 | # Verbose build (for the kernel and busybox)? (if 1, we run as 'make V=1 ...') 73 | VERBOSE_BUILD=0 74 | #------------------------------------------------------------------------------ 75 | 76 | #--------'HARDWARE'------------------------------------------------------------ 77 | # SEALs (virtual) "Hardware" 78 | # @@@@@ 79 | # Select the CPU arch (to build the kernel for); the value to specify is the 80 | # name of the dir under /arch/XXX 81 | ARCH=arm64 82 | QEMUPKG=qemu-system-aarch64 83 | [[ "${ARCH}" = "arm64" ]] && QEMUPKG=qemu-system-aarch64 84 | 85 | CPU_MODEL=cortex-a57 86 | SEALS_RAM=512 # MB 87 | 88 | # Select the platform (to build the kernel for). 89 | ARCH_PLATFORM="" 90 | # @@@@@ 91 | # English-like name 92 | ARM_PLATFORM_STR="Qemu Virt" 93 | 94 | # ! IMPORTANT ! 95 | # Selecting the platform varies with the ARCH: 96 | # ===> For Aarch32 (ARM): 97 | # Pl set the variable ARM_PLATFORM carefully; it will be used to setup 98 | # the inital config and is therefore very critical that it's given correctly: 99 | # make ARCH=arm ${ARM_PLATFORM}_defconfig 100 | # So, check under /arch//configs/ 101 | # for the best match to your platform, in the form 102 | # _defconfig 103 | # and put it here.. F.e.: 104 | #ARM_PLATFORM=vexpress-a9 105 | # 106 | # ===> For Aarch64 (arm64): 107 | # On Aarch64, all platforms will be selected by default. 108 | # (Can see them within the 'Platform selection' menu). 109 | # Either build it this way or deselect all and enable only the platform(s) you want to support... 110 | # So here, we leave the variable ARM_PLATFORM as NULL to fulfill the default case (all platforms) 111 | ARM_PLATFORM= 112 | 113 | # ARM_PLATFORM_OPT is the value passed via the -M (machine) switch to Qemu 114 | # Look for it via qemu-system-arm -M ? ; eg. 115 | # qemu-system-arm -M ? |grep -i "i.mx" 116 | ARM_PLATFORM_OPT=virt 117 | 118 | SMP_EMU_MODE=1 # make '1' to have qemu run w/ 4 emulated cores 119 | # (only works on appropriate h/w-emulated platforms) 120 | #------------------------------------------------------------------------------ 121 | 122 | 123 | # Okay, so under the ${STG} folder, we expect you have extracted the: 124 | 125 | #--------TOOLCHAIN------------------------------------------------------------ 126 | # The toolchain to use; expect that it is installed and the PATH is setup.. 127 | # @@@@@ 128 | CXX=aarch64-none-linux-gnu- # toolchain prefix 129 | # CXX_LOC is the location of the x86-to-ARM toolchain on disk 130 | # (used to setup the PATH and locate the ARM shared libraries within the toolchain) 131 | # @@@@@ 132 | CXX_LOC=~/tc/arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64-none-linux-gnu/bin/ 133 | # Keep your toolchain in the PATH 134 | PATH=$PATH:${CXX_LOC}/bin 135 | #------------------------------------------------------------------------------ 136 | 137 | #--------KERNEL------------------------------------------------------------ 138 | ### UPDATE ### on your system! 139 | # Okay, so under the ${STG} folder (or other), we expect you have extracted the 140 | # source of the Linux kernel into ${KERNEL_FOLDER} , ver ${KERNELVER}. 141 | # (Update the variables below to reflect your settings and installation). 142 | # @@@@@ 143 | KERNELVER=6.1.25 144 | KERNEL_FOLDER=${STG}/linux-${KERNELVER}/ 145 | 146 | # @@@@@ 147 | # DTB: specify the Device Tree Blob .dtb 148 | # (Leave empty for the Aarch64 Qemu virt system) 149 | DTB_BLOB= 150 | ##### 151 | 152 | # @@@@@ 153 | # SEALs kernel command-line 154 | SEALS_K_CMDLINE="console=ttyAMA0 root=/dev/vda rw init=/sbin/init" 155 | # if 512M RAM, reserve 32M for crashk, else if 256M RAM, reserve 16M 156 | K_CMDLINE_XTRA="" 157 | #K_CMDLINE_XTRA="crashkernel=32M" # works with 32M not 16M [?] 158 | #K_CMDLINE_XTRA="initcall_debug ignore_loglevel debug" 159 | [ ! -z "${K_CMDLINE_XTRA}" ] && SEALS_K_CMDLINE="${SEALS_K_CMDLINE} ${K_CMDLINE_XTRA}" 160 | 161 | #--------BUSYBOX and ROOTFS------------------------------------------------------------ 162 | # Also under the ${STG} folder, we expect you have extracted the 163 | # source of busybox into the folder ${BB_FOLDER} ver ${BB_VER}. 164 | # (Update the variables below to reflect your settings and installation). 165 | # @@@@@ 166 | BB_FOLDER=${STG}/busybox # with the GitHub ver 167 | SHELL2RUN=/bin/sh #/bin/bash 168 | 169 | ## RootFS 170 | # !Careful! Set to 1 to force a rebuild of the rootfs; implies OVERWRITING any 171 | # existing rootfs 172 | RFS_FORCE_REBUILD=1 173 | # Rootfs size: Recommendation: if using a kdump kernel, as a rough thumb rule, 174 | # make it ~ 150% of the size of RAM on the platform (so for eg. if the RAM is 512M, 175 | # make the rootfs size ~ >= 768 MB). 176 | # Else (no kdump), 512 MB is fine for the Vexpress. 177 | # Increase RFS size for the AArch64 (esp since modules can take up close to 250 MB!) 178 | RFS_SZ_MB=1024 179 | MYPRJ=myprj 180 | #------------------------------------------------------------------------------ 181 | 182 | #--------MISC / REMAINING Options------------------------------------------------------------ 183 | ##### Config vars for what to build 184 | # VAR=1 : 'do' the work 'VAR' 185 | # VAR=0 : 'do Not' do the work 'VAR' 186 | BUILD_KERNEL=1 187 | BUILD_ROOTFS=1 188 | GEN_EXT4_ROOTFS_IMAGE=1 189 | SAVE_BACKUP_IMG_CONFIGS=1 190 | RUN_QEMU=1 191 | #SHELL_PROMPT_STR="qarm64 \w # " 192 | 193 | ### "WIPE_*_CONFIG" directives 194 | # Set var to 'y' implies any existing kernel configuration is wiped out. 195 | # Suggestion: set to 'y' for the FIRST build with a clean kernel source tree.. 196 | # @@@@@ 197 | WIPE_KERNEL_CONFIG=1 198 | # Set var to 'y' implies any existing busybox configuration is wiped out. 199 | # Suggestion: set to 'y' for the FIRST build with a clean busybox source tree.. 200 | # @@@@@ 201 | WIPE_BUSYBOX_CONFIG=1 202 | 203 | ### 204 | # Config vars for when we run QEMU: 205 | KGDB_MODE=0 # make '1' to have qemu run w/ the '-S' switch (waits for gdb to 'connect') 206 | #------------------------------------------------------------------------------ 207 | 208 | #--- End build.config 209 | -------------------------------------------------------------------------------- /test/build.config.arm64_rpi3b_cm3: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ####################################################################### 3 | # build.config.arm64_rpi3b_cm3 4 | # 5 | # *TEST* config 6 | # 7 | # Part of the SEALs project. 8 | # This is the configuration file; all config variables must go here. 9 | # 10 | # !! IMP NOTE TO THE END-USER OF THIS PROJECT !! 11 | # You are responsible for editing this configuration file, setting the 12 | # variables to sane values. 13 | # To help you out, the place in the source below which has the config 14 | # variables that you MUST update have been marked with a comment line 15 | # as follows: 16 | # # @@@@@ 17 | # So, you could just search for this string '@@@@@' (excluding the quotes of course), 18 | # and make sure you update the following config variable(s) to the sane value 19 | # for your box. 20 | # !! 21 | #--- 22 | # Author: Kaiwan N Billimoria 23 | # (C) kaiwanTECH 24 | #--- 25 | ####################################################################### 26 | # 27 | #---------------------- 28 | # !!!VERY IMPORTANT!!! 29 | #---------------------- 30 | # Pl read the documentation here, at least once: 31 | # https://github.com/kaiwan/seals/wiki 32 | #---------------------- 33 | # 34 | # Generic Config file. 35 | # For a minimal QEMU-ARM project, we Expect that: 36 | # 37 | # - an appropriate toolchain is installed and working, and setup in the config below 38 | # details: https://github.com/kaiwan/seals/wiki/HOWTO-Install-required-packages-on-the-Host-for-SEALS 39 | # - a recent version of the Linux kernel source tree is available and setup in the config below 40 | # - a recent version of busybox source tree is available and setup in the config below 41 | ############## 42 | 43 | set -a # auto export all vars 44 | 45 | #--------GENERIC CONFIG OPTIONS------------------------------------------------------------ 46 | ##################### UPDATE as required 47 | # @@@@@ 48 | CONFIG_NAME_STR="SEALs config file for the Raspberry Pi 3B AArch64 (or RPi CM3 Compute Model 3)" 49 | COLOR=1 # terminal color support? Assume yes.. 50 | GUI_MODE=0 # auto-detects GUI / console mode 51 | DEBUG=0 # set to 1 to get debug messages displayed 52 | [ ${DEBUG} -eq 1 ] && export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' 53 | VERBOSE_MSG=0 # set to 1 to get more verbose messages displayed 54 | # [loglevel][date-timestamp] 55 | LOGFILE_COMMON=log_seals.txt 56 | 57 | ###------### 58 | TOPDIR=$(pwd) 59 | #------------------------------------------------------------------------------ 60 | 61 | #--------KEY DISK LOCATIONS and Settings--------------------------------------- 62 | ### Locations on Disk ### 63 | ### UPDATE ### on your system! 64 | # @@@@@ 65 | STG=~/seals_staging/seals_staging_rpi3b 66 | # Recommendation: if running a cloud-sync service (like pCloud/Dropbox), keep the 67 | # staging area outside it. 68 | ROOTFS=${STG}/rootfs 69 | IMAGES_FOLDER=${STG}/images 70 | IMAGES_BKP_FOLDER=${STG}/images_bkp 71 | CONFIGS_FOLDER=${STG}/configs 72 | # Verbose build (for the kernel and busybox)? (if 1, we run as 'make V=1 ...') 73 | VERBOSE_BUILD=0 74 | #------------------------------------------------------------------------------ 75 | 76 | #--------'HARDWARE'------------------------------------------------------------ 77 | # SEALs (virtual) "Hardware" 78 | # @@@@@ 79 | # Select the CPU arch (to build the kernel for); the value to specify is the 80 | # name of the dir under /arch/XXX 81 | ARCH=arm64 82 | ARCH_PLATFORM="" 83 | QEMUPKG=qemu-system-aarch64 84 | 85 | CPU_MODEL=cortex-a53 86 | SEALS_RAM=1G 87 | 88 | # Select the platform (to build the kernel for). 89 | # @@@@@ 90 | # English-like name 91 | ARM_PLATFORM_STR="Qemu Rpi3B" 92 | 93 | # ! IMPORTANT ! 94 | # Selecting the platform varies with the ARCH: 95 | # ===> For Aarch32 (ARM): 96 | # Pl set the variable ARM_PLATFORM carefully; it will be used to setup 97 | # the inital config and is therefore very critical that it's given correctly: 98 | # make ARCH=arm ${ARM_PLATFORM}_defconfig 99 | # So, check under /arch//configs/ 100 | # for the best match to your platform, in the form 101 | # _defconfig 102 | # and put it here.. F.e.: 103 | #ARM_PLATFORM=vexpress-a9 104 | # 105 | # ===> For Aarch64 (arm64): 106 | # On Aarch64, all platforms will be selected by default. 107 | # (Can see them within the 'Platform selection' menu). 108 | # Either build it this way or deselect all and enable only the platform(s) you want to support... 109 | # So here, we leave the variable ARM_PLATFORM as NULL to fulfill the default case (all platforms) 110 | ARM_PLATFORM= 111 | 112 | # ARM_PLATFORM_OPT is the value passed via the -M (machine) switch to Qemu 113 | # Look for it via qemu-system-arm -M ? ; eg. 114 | # qemu-system-arm -M ? |grep -i "i.mx" 115 | ARM_PLATFORM_OPT=raspi3b 116 | 117 | SMP_EMU_MODE=0 # make '1' to have qemu run w/ 4 emulated cores 118 | # (only works on appropriate h/w-emulated platforms) 119 | #------------------------------------------------------------------------------ 120 | 121 | 122 | # Okay, so under the ${STG} folder, we expect you have extracted the: 123 | 124 | #--------TOOLCHAIN------------------------------------------------------------ 125 | # The toolchain to use; expect that it is installed and the PATH is setup.. 126 | # @@@@@ 127 | CXX=aarch64-none-linux-gnu- # toolchain prefix 128 | # CXX_LOC is the location of the x86-to-ARM toolchain on disk 129 | # (used to setup the PATH and locate the ARM shared libraries within the toolchain) 130 | # @@@@@ 131 | CXX_LOC=~/tc/arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64-none-linux-gnu/bin/ 132 | # Keep your toolchain in the PATH 133 | PATH=$PATH:${CXX_LOC}/bin 134 | #------------------------------------------------------------------------------ 135 | 136 | #--------KERNEL------------------------------------------------------------ 137 | ### UPDATE ### on your system! 138 | # Okay, so under the ${STG} folder (or other), we expect you have extracted the 139 | # source of the Linux kernel into ${KERNEL_FOLDER} , ver ${KERNELVER}. 140 | # (Update the variables below to reflect your settings and installation). 141 | # @@@@@ 142 | KERNELVER=6.1.25 143 | KERNEL_FOLDER=${STG}/linux-${KERNELVER}/ 144 | 145 | # @@@@@ 146 | # DTB: specify the Device Tree Blob .dtb 147 | # (Leave empty for the Aarch64 Qemu virt system) 148 | DTB_BLOB=broadcom/bcm2837-rpi-cm3-io3.dtb 149 | #DTB_BLOB=broadcom/bcm2837-rpi-3-b.dtb 150 | ##### 151 | 152 | # @@@@@ 153 | # SEALs kernel command-line 154 | SEALS_K_CMDLINE="console=ttyAMA0 root=/dev/mmcblk0 rw init=/sbin/init" 155 | # if 512M RAM, reserve 32M for crashk, else if 256M RAM, reserve 16M 156 | K_CMDLINE_XTRA="" 157 | #K_CMDLINE_XTRA="crashkernel=32M" # works with 32M not 16M [?] 158 | #K_CMDLINE_XTRA="initcall_debug ignore_loglevel debug" 159 | [ ! -z "${K_CMDLINE_XTRA}" ] && SEALS_K_CMDLINE="${SEALS_K_CMDLINE} ${K_CMDLINE_XTRA}" 160 | 161 | #--------BUSYBOX and ROOTFS------------------------------------------------------------ 162 | # Also under the ${STG} folder, we expect you have extracted the 163 | # source of busybox into the folder ${BB_FOLDER} ver ${BB_VER}. 164 | # (Update the variables below to reflect your settings and installation). 165 | # @@@@@ 166 | BB_FOLDER=${STG}/busybox # with the GitHub ver 167 | SHELL2RUN=/bin/sh #/bin/bash 168 | 169 | ## RootFS 170 | # !Careful! Set to 1 to force a rebuild of the rootfs; implies OVERWRITING any 171 | # existing rootfs 172 | RFS_FORCE_REBUILD=0 173 | # Rootfs size: Recommendation: if using a kdump kernel, as a rough thumb rule, 174 | # make it ~ 150% of the size of RAM on the platform (so for eg. if the RAM is 512M, 175 | # make the rootfs size ~ >= 768 MB). 176 | # Else (no kdump), 512 MB is fine for the Vexpress. 177 | # Increase RFS size for the AArch64 (esp since modules can take up close to 250 MB!) 178 | RFS_SZ_MB=1024 179 | MYPRJ=myprj 180 | #------------------------------------------------------------------------------ 181 | 182 | #--------MISC / REMAINING Options------------------------------------------------------------ 183 | ##### Config vars for what to build 184 | # VAR=1 : 'do' the work 'VAR' 185 | # VAR=0 : 'do Not' do the work 'VAR' 186 | BUILD_KERNEL=1 187 | BUILD_ROOTFS=1 188 | GEN_EXT4_ROOTFS_IMAGE=1 189 | SAVE_BACKUP_IMG_CONFIGS=1 190 | RUN_QEMU=1 191 | #SHELL_PROMPT_STR="qarm64 \w # " 192 | 193 | ### "WIPE_*_CONFIG" directives 194 | # Set var to 'y' implies any existing kernel configuration is wiped out. 195 | # Suggestion: set to 'y' for the FIRST build with a clean kernel source tree.. 196 | # @@@@@ 197 | WIPE_KERNEL_CONFIG=1 198 | # Set var to 'y' implies any existing busybox configuration is wiped out. 199 | # Suggestion: set to 'y' for the FIRST build with a clean busybox source tree.. 200 | # @@@@@ 201 | WIPE_BUSYBOX_CONFIG=1 202 | 203 | ### 204 | # Config vars for when we run QEMU: 205 | KGDB_MODE=0 # make '1' to have qemu run w/ the '-S' switch (waits for gdb to 'connect') 206 | #------------------------------------------------------------------------------ 207 | 208 | #--- End build.config 209 | -------------------------------------------------------------------------------- /test/build_SEALS.sh: -------------------------------------------------------------------------------- 1 | ../build_SEALS.sh -------------------------------------------------------------------------------- /test/cleanall: -------------------------------------------------------------------------------- 1 | ../cleanall -------------------------------------------------------------------------------- /test/color.sh: -------------------------------------------------------------------------------- 1 | ../color.sh -------------------------------------------------------------------------------- /test/common.sh: -------------------------------------------------------------------------------- 1 | ../common.sh -------------------------------------------------------------------------------- /test/err_common.sh: -------------------------------------------------------------------------------- 1 | ../err_common.sh -------------------------------------------------------------------------------- /test/install.sh: -------------------------------------------------------------------------------- 1 | ../install.sh -------------------------------------------------------------------------------- /test/mount_rootfs.sh: -------------------------------------------------------------------------------- 1 | ../mount_rootfs.sh -------------------------------------------------------------------------------- /test/run-qemu.sh: -------------------------------------------------------------------------------- 1 | ../run-qemu.sh -------------------------------------------------------------------------------- /test/shellcheck_run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # shellcheck_run 3 | # Part of the SEALS project. 4 | 5 | echo "*** Test 1 *** " 6 | echo "ShellCheck !" 7 | 8 | shellcheck -e SC2155,SC2063,SC2166,SC1090 -S warning *.sh 9 | # https://www.shellcheck.net/wiki/ 10 | # -e : exclude warning 11 | # SC2155 : Declare and assign separately to avoid masking return values. 12 | # SC2063 : (warning): Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. 13 | # SC2166 : (warning): Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. 14 | # SC1090 (warning): ShellCheck can't follow non-constant source. Use a directive to specify location 15 | 16 | -------------------------------------------------------------------------------- /test/show_curr_config.sh: -------------------------------------------------------------------------------- 1 | ../show_curr_config.sh -------------------------------------------------------------------------------- /tutorial_pics/bb1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/bb1.png -------------------------------------------------------------------------------- /tutorial_pics/bb2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/bb2.png -------------------------------------------------------------------------------- /tutorial_pics/bb3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/bb3.png -------------------------------------------------------------------------------- /tutorial_pics/first-time-error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/first-time-error.png -------------------------------------------------------------------------------- /tutorial_pics/gen_rootfs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/gen_rootfs.png -------------------------------------------------------------------------------- /tutorial_pics/install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/install.png -------------------------------------------------------------------------------- /tutorial_pics/k1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/k1.png -------------------------------------------------------------------------------- /tutorial_pics/k2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/k2.png -------------------------------------------------------------------------------- /tutorial_pics/k3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/k3.png -------------------------------------------------------------------------------- /tutorial_pics/k4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/k4.png -------------------------------------------------------------------------------- /tutorial_pics/k5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/k5.png -------------------------------------------------------------------------------- /tutorial_pics/menu-selected4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/menu-selected4.png -------------------------------------------------------------------------------- /tutorial_pics/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/menu.png -------------------------------------------------------------------------------- /tutorial_pics/notes1.txt: -------------------------------------------------------------------------------- 1 | [Sat_16Dec2023_13:05:08.512144803] Doing: time make V=0 -j12 ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- all 2 | SYNC include/config/auto.conf.cmd 3 | * 4 | * Restart config... 5 | * 6 | * 7 | * Kernel Features 8 | * 9 | Symmetric Multi-Processing (SMP) [Y/n/?] y 10 | Allow booting SMP kernel on uniprocessor systems (SMP_ON_UP) [Y/n/?] y 11 | 12 | 13 | -------------------------------------------------------------------------------- /tutorial_pics/platform-config-review-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/platform-config-review-screen.png -------------------------------------------------------------------------------- /tutorial_pics/run1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/run1.png -------------------------------------------------------------------------------- /tutorial_pics/run2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/run2.png -------------------------------------------------------------------------------- /tutorial_pics/run3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/run3.png -------------------------------------------------------------------------------- /tutorial_pics/run4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/run4.png -------------------------------------------------------------------------------- /tutorial_pics/select_platform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kaiwan/seals/826816da9c22323e1091e2889b52d8ea1868fa15/tutorial_pics/select_platform.png --------------------------------------------------------------------------------