├── .gitignore ├── LICENSE ├── README.md ├── README_CN.md ├── VERSION ├── config └── hobot_config.sh ├── download_deb_pkgs.sh ├── download_samplefs.sh ├── hobot_customize_rootfs.sh ├── mk_debs.sh ├── mk_kernel.sh ├── pack_image.sh ├── samplefs ├── .gitignore ├── focal │ ├── ubuntu-base-arm64-packages │ ├── ubuntu-desktop-arm64-packages │ └── ubuntu-server-arm64-packages ├── jammy │ ├── ubuntu-base-arm64-packages │ ├── ubuntu-desktop-arm64-packages │ └── ubuntu-server-arm64-packages ├── make_ubuntu_samplefs.sh └── ros-archive-keyring.gpg └── source_sync.sh /.gitignore: -------------------------------------------------------------------------------- 1 | source/ 2 | deploy/ 3 | rootfs/ 4 | rootfs_server 5 | deb_packages/ 6 | .repo/ 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Development Environment Setup and Compilation Instructions 2 | 3 | ## Overview 4 | 5 | This section introduces the requirements and setup for a cross-compilation development environment, as well as instructions for compiling system images. 6 | 7 | ## Development Environment 8 | 9 | Cross-compilation refers to the process of developing and building software on a host machine and then deploying the built software onto a development board. The host machine generally has higher performance and memory compared to the development board, which can accelerate code builds and allow for the installation of additional development tools, facilitating development. 10 | 11 | **Host Compilation Environment Requirements** 12 | 13 | It is recommended to use an Ubuntu operating system. If you are using a different system version, adjustments to the compilation environment may be necessary. 14 | 15 | For Ubuntu 18.04, install the following packages: 16 | 17 | ```shell 18 | sudo apt-get install -y build-essential make cmake libpcre3 libpcre3-dev bc bison \ 19 | flex python-numpy mtd-utils zlib1g-dev debootstrap \ 20 | libdata-hexdumper-perl libncurses5-dev zip qemu-user-static \ 21 | curl git liblz4-tool apt-cacher-ng libssl-dev checkpolicy autoconf \ 22 | android-tools-fsutils mtools parted dosfstools udev rsync 23 | ``` 24 | 25 | For Ubuntu 20.04, install the following packages: 26 | 27 | ```shell 28 | sudo apt-get install -y build-essential make cmake libpcre3 libpcre3-dev bc bison \ 29 | flex python-numpy mtd-utils zlib1g-dev debootstrap \ 30 | libdata-hexdumper-perl libncurses5-dev zip qemu-user-static \ 31 | curl git liblz4-tool apt-cacher-ng libssl-dev checkpolicy autoconf \ 32 | android-sdk-libsparse-utils android-sdk-ext4-utils mtools parted dosfstools udev rsync 33 | ``` 34 | 35 | For Ubuntu 22.04, install the following packages: 36 | 37 | ```shell 38 | sudo apt-get install -y build-essential make cmake libpcre3 libpcre3-dev bc bison \ 39 | flex python3-numpy mtd-utils zlib1g-dev debootstrap \ 40 | libdata-hexdumper-perl libncurses5-dev zip qemu-user-static \ 41 | curl repo git liblz4-tool apt-cacher-ng libssl-dev checkpolicy autoconf \ 42 | android-sdk-libsparse-utils mtools parted dosfstools udev rsync 43 | ``` 44 | 45 | **Installing the Cross-Compilation Toolchain** 46 | 47 | Execute the following command to download the cross-compilation toolchain: 48 | 49 | ```shell 50 | curl -fO http://archive.d-robotics.cc//toolchain/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz 51 | ``` 52 | 53 | Extract and install the toolchain. It is recommended to install it in the /opt directory. Typically, writing to the /opt directory requires sudo permissions. For example: 54 | 55 | ```shell 56 | sudo tar -xvf gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz -C /opt 57 | ``` 58 | 59 | Configure the environment variables for the cross-compilation toolchain: 60 | 61 | ```shell 62 | export CROSS_COMPILE=/opt/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/bin/aarch64-linux-gnu- 63 | export LD_LIBRARY_PATH=/opt/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH 64 | export PATH=$PATH:/opt/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/bin/ 65 | export ARCH=arm64 66 | ``` 67 | 68 | The above commands set the environment variables temporarily. To make the configuration permanent, you can add these commands to the end of the environment variable files ~/.profile or ~/.bash_profile. 69 | 70 | ## rdk-gen 71 | 72 | `rdk-gen` is used to build a customized operating system image for the D-robotics RDK X3. It provides an extensible framework that allows users to tailor and build the Ubuntu operating system for the RDK X3 according to their specific requirements. 73 | 74 | Download the source code: 75 | 76 | ```shell 77 | git clone https://github.com/D-Robotics/rdk-gen.git 78 | ``` 79 | 80 | After the download is complete, the directory structure of rdk-gen is as follows: 81 | 82 | | **Directory** | **Description** | 83 | | ------------------------- | ------------------------------------------------------------ | 84 | | pack_image.sh | The entry point for building the system image code is: | 85 | | download_samplefs.sh | Download the pre-built base Ubuntu file system: | 86 | | download_deb_pkgs.sh | Download the D-robotics `.deb` software packages that need to be pre-installed in the system image, including the kernel, multimedia libraries, example code, `tros.bot`, and other components. | 87 | | hobot_customize_rootfs.sh | Customizes and modifies the Ubuntu file system. | 88 | | source_sync.sh | Downloads source code, including bootloader, U-Boot, kernel, example code, etc. | 89 | | mk_kernel.sh | Compiles the kernel, device tree, and driver modules. | 90 | | mk_debs.sh | Generates .deb software packages. | 91 | | make_ubuntu_samplefs.sh | Creates the Ubuntu system file system; this script can be modified to customize the sample file system. | 92 | | config | Contains content to be placed in the system image's /hobot/config directory. It is a VFAT root partition. If the system boots from an SD card, users can modify this partition's content directly in Windows. | 93 | 94 | ## Building the System Image 95 | 96 | Run the following command to package the system image: 97 | 98 | ```shell 99 | cd rdk-gen 100 | sudo ./pack_image.sh 101 | ``` 102 | 103 | You need sudo permissions to compile. Upon successful compilation, an *.img system image file will be generated in the deploy directory. 104 | 105 | ### Overview of the pack_image.sh Compilation Process 106 | 107 | 1. Calls download_samplefs.sh and download_deb_pkgs.sh scripts to download the sample file system and required .deb packages from D-robotics' file server. 108 | 2. Extracts the sample file system and uses the hobot_customize_rootfs.sh script to customize the file system configuration. 109 | 3. Installs the .deb packages into the file system. 110 | 4. Generates the system image. 111 | 112 | ## Downloading Source Code 113 | 114 | The source code for rdk-linux-related kernel, bootloader, and hobot-xxx software packages is hosted on GitHub. Before downloading the code, please register and log in to GitHub, and add the SSH key for the development server to your user settings via Generating a new SSH key and adding it to the ssh-agent. 115 | 116 | The source_sync.sh script is used to download the source code, including bootloader, U-Boot, kernel, example code, etc. This script downloads all the source code locally by executing git clone git@github.com:xxx.git. 117 | 118 | Execute the following command to download the main branch code: 119 | 120 | ```shell 121 | ./source_sync.sh -t feat-ubuntu22.04 122 | ``` 123 | 124 | By default, the program will download the source code to the `source` directory: 125 | 126 | ``` 127 | source 128 | ├── bootloader 129 | ├── hobot-boot 130 | ├── hobot-bpu-drivers 131 | ├── hobot-camera 132 | ├── hobot-configs 133 | ├── hobot-display 134 | ├── hobot-dnn 135 | ├── hobot-dtb 136 | ├── hobot-io 137 | ├── hobot-io-samples 138 | ├── hobot-kernel-headers 139 | ├── hobot-multimedia 140 | ├── hobot-multimedia-dev 141 | ├── hobot-spdev 142 | ├── hobot-sp-samples 143 | ├── hobot-utils 144 | ├── hobot-wifi 145 | └── kernel 146 | ``` 147 | 148 | ## kernel 149 | 150 | Execute the following command to compile the Linux kernel: 151 | 152 | ```shell 153 | ./mk_kernel.sh 154 | ``` 155 | 156 | After compilation, the kernel image, driver modules, device tree, and kernel header files will be generated in the `deploy/kernel` directory. 157 | 158 | ```shell 159 | dtb Image Image.lz4 kernel_headers modules 160 | ``` 161 | 162 | These contents will be used by the hobot-boot, hobot-dtb, and hobot-kernel-headers Debian packages. Therefore, if you want to customize these three software packages, you need to compile the kernel first. 163 | 164 | ## hobot-xxx.deb 165 | 166 | hobot-xxx.deb are Debian software packages maintained by D-robotics. After downloading the source code, you can use the mk_deb.sh script to rebuild the Debian packages. 167 | 168 | The help information is as follows: 169 | 170 | ```shell 171 | $ ./mk_debs.sh help 172 | The debian package named by help is not supported, please check the input parameters. 173 | ./mk_deb.sh [all] | [deb_name] 174 | hobot-multimedia-dev, Version 2.0.0 175 | hobot-wifi, Version 2.0.0 176 | hobot-camera, Version 2.0.0 177 | hobot-dtb, Version 2.0.0 178 | hobot-configs, Version 2.0.0 179 | hobot-io, Version 2.0.0 180 | hobot-spdev, Version 2.0.0 181 | hobot-boot, Version 2.0.0 182 | hobot-sp-samples, Version 2.0.0 183 | hobot-bpu-drivers, Version 2.0.0 184 | hobot-multimedia-samples, Version 2.0.0 185 | hobot-dnn, Version 2.0.0 186 | hobot-io-samples, Version 2.0.0 187 | hobot-kernel-headers, Version 2.0.0 188 | hobot-utils, Version 2.0.0 189 | hobot-multimedia, Version 2.0.0 190 | hobot-display, Version 2.0.0 191 | ``` 192 | 193 | ### Full Build 194 | 195 | Execute the following command to rebuild all the Debian packages (ensure that the kernel has been compiled first): 196 | 197 | ```shell 198 | ./mk_deb.sh 199 | ``` 200 | 201 | After the build is complete, the `.deb` packages will be generated in the `deploy/deb_pkgs` directory. 202 | 203 | ### Building Individual Packages 204 | 205 | The mk_deb.sh script supports building specific packages individually by providing the package name as a parameter during execution. For example: 206 | 207 | ```shell 208 | ./mk_deb.sh hobot-configs 209 | ``` 210 | 211 | ## bootloader 212 | 213 | The bootloader source code is used to generate a minimal boot image, miniboot.img, which includes the partition table, SPL, DDR, BL31, and U-Boot in a single boot firmware. 214 | 215 | The minimal boot image for the RDK X3 is typically maintained and released by D-robotics,You can download the corresponding version from (http://archive.d-robotics.cc/downloads/miniboot/). 216 | 217 | Follow these steps to recompile and generate miniboot: 218 | 219 | ### Sync U-Boot Code 220 | 221 | Execute the following command to download the U-Boot source code: 222 | 223 | ```shell 224 | git submodule init 225 | git submodule update 226 | ``` 227 | 228 | ### Select the hardware configuration file: 229 | 230 | ```shell 231 | cd build 232 | ./xbuild.sh lunch 233 | 234 | You're building on #221-Ubuntu SMP Tue Apr 18 08:32:52 UTC 2023 235 | Lunch menu... pick a combo: 236 | 0. horizon/x3/board_ubuntu_emmc_sdcard_config.mk 237 | 1. horizon/x3/board_ubuntu_emmc_sdcard_samsung_4GB_config.mk 238 | 2. horizon/x3/board_ubuntu_nand_sdcard_config.mk 239 | 3. horizon/x3/board_ubuntu_nand_sdcard_samsung_4GB_config.mk 240 | Which would you like? [0] : 241 | ``` 242 | 243 | Select the board-level configuration file according to the prompt. 244 | 245 | The pre-configured files are designed for different hardware configurations of development boards, varying in aspects such as whether miniboot is burned to eMMC or NAND, the DDR model and capacity, and the root file system: 246 | 247 | | Board-Level Configuration File | Memory | rootfs | Minimum Boot Image Storage | Main Storage | 248 | | ---------------------------------------------- | ------------------ | ------------ | ------------------ | ----------- | 249 | | board_ubuntu_emmc_sdcard_config.mk | LPDDR4 2GB | ubuntu-20.04 | emmc | sdcard | 250 | | board_ubuntu_emmc_sdcard_samsung_4GB_config.mk | LPDDR4 4GB | ubuntu-20.04 | emmc | sdcard | 251 | | board_ubuntu_nand_sdcard_config.mk | LPDDR4 2GB | ubuntu-20.04 | nand | sdcard/emmc | 252 | | board_ubuntu_nand_sdcard_samsung_4GB_config.mk | LPDDR4 4GB | ubuntu-20.04 | nand | sdcard/emmc | 253 | 254 | **Minimum Boot Image Storage:** The storage where miniboot is burned. Users of RDK X3 and RDK X3 Module should choose the NAND flash method. 255 | 256 | **Main Storage: ** The storage for the Ubuntu system image. SD cards and eMMC are interchangeable, meaning that an image burned to a microSD card can also be burned to eMMC. 257 | 258 | 259 | 260 | The `lunch` command also supports specifying a number and board-level configuration file name to complete the configuration directly. 261 | 262 | ```shell 263 | $ ./xbuild.sh lunch 2 264 | 265 | You're building on #221-Ubuntu SMP Tue Apr 18 08:32:52 UTC 2023 266 | You are selected board config: horizon/x3/board_ubuntu_nand_sdcard_config.mk 267 | 268 | $ ./xbuild.sh lunch board_ubuntu_nand_sdcard_config.mk 269 | 270 | You're building on #221-Ubuntu SMP Tue Apr 18 08:32:52 UTC 2023 271 | You are selected board config: horizon/x3/board_ubuntu_nand_sdcard_config.mk 272 | ``` 273 | 274 | ### Full Build 275 | 276 | Navigate to the `build` directory and execute `xbuild.sh` to perform the overall build: 277 | 278 | ```shell 279 | cd build 280 | ./xbuild.sh 281 | ``` 282 | 283 | After a successful build, the following image files will be generated in the output directory (e.g., deploy_ubuntu_xxx): 284 | miniboot.img 285 | uboot.img 286 | disk_nand_minimum_boot.img 287 | Among these, disk_nand_minimum_boot.img is the minimal boot image file. 288 | 289 | ### Modular Compilation 290 | 291 | Compile individual modules using the xbuild.sh script. The resulting image files will be output to the build output directory (e.g., deploy_ubuntu_xxx). 292 | 293 | ```shell 294 | ./xbuild.sh miniboot | uboot 295 | ``` 296 | 297 | **miniboot:** use mk_miniboot.sh get miniboot.img 298 | 299 | **uboot:** use mk_uboot.sh get uboot.img 300 | 301 | After modular compilation, you can use the pack command to package the disk_nand_minimum_boot.img. 302 | 303 | ```shell 304 | ./xbuild.sh pack 305 | ``` 306 | 307 | ## Ubuntu File System Creation 308 | 309 | This section describes how to create the samplefs_desktop-v3.0.0.tar.gz file system. D-robotics maintains this file system, but if you have customization needs, you will need to recreate it according to the instructions in this chapter. 310 | 311 | ### Environment Setup 312 | 313 | It is recommended to use an Ubuntu host for creating the Ubuntu file system for the development board. First, install the following packages in the host environment: 314 | 315 | ```shell 316 | sudo apt-get install wget ca-certificates device-tree-compiler pv bc lzop zip binfmt-support \ 317 | build-essential ccache debootstrap ntpdate gawk gcc-arm-linux-gnueabihf qemu-user-static \ 318 | u-boot-tools uuid-dev zlib1g-dev unzip libusb-1.0-0-dev fakeroot parted pkg-config \ 319 | libncurses5-dev whiptail debian-keyring debian-archive-keyring f2fs-tools libfile-fcntllock-perl \ 320 | rsync libssl-dev nfs-kernel-server btrfs-progs ncurses-term p7zip-full kmod dosfstools \ 321 | libc6-dev-armhf-cross imagemagick curl patchutils liblz4-tool libpython2.7-dev linux-base swig acl \ 322 | python3-dev python3-distutils libfdt-dev locales ncurses-base pixz dialog systemd-container udev \ 323 | lib32stdc++6 libc6-i386 lib32ncurses5 lib32tinfo5 bison libbison-dev flex libfl-dev cryptsetup gpg \ 324 | gnupg1 gpgv1 gpgv2 cpio aria2 pigz dirmngr python3-distutils distcc git dos2unix apt-cacher-ng 325 | ``` 326 | 327 | ### Tools Introduction 328 | 329 | #### debootstrap 330 | 331 | debootstrap is a tool for Debian/Ubuntu systems used to create a basic system (root file system). The generated directory conforms to the Linux Filesystem Hierarchy Standard (FHS), including directories like /boot, /etc, /bin, /usr, etc. However, it is much smaller than a full Linux distribution and has limited functionality, serving only as a "basic system" that can be customized to meet specific needs. 332 | 333 | Installing debootstrap on Ubuntu (PC) 334 | 335 | ```shell 336 | sudo apt-get install debootstrap 337 | ``` 338 | 339 | Usage method 340 | 341 | ```shell 342 | # Can add parameters to specify the source 343 | sudo debootstrap [options] [mirror] 344 | ``` 345 | 346 | #### chroot 347 | 348 | chroot,Change root directory. In Linux systems, the default directory structure starts with '/', which is the root. After using chroot, the system's directory structure will use the specified location as the `/` position. 349 | 350 | #### parted 351 | 352 | parted is a powerful disk partitioning and partition resizing tool developed by the GNU organization. Unlike fdisk, it supports resizing partitions. As a tool designed for Linux, it is not built to handle multiple partition types associated with fdisk, but it can handle the most common partition formats, including ext2, ext3, fat16, fat32, NTFS, ReiserFS, JFS, XFS, UFS, HFS, and Linux swap partitions. 353 | 354 | ### Creating Ubuntu rootfs script code 355 | 356 | Execute the following command to generate the Ubuntu file system: 357 | 358 | build desktop ubuntu 359 | ```shell 360 | cd samplefs 361 | sudo ./make_ubuntu_rootfs.sh 362 | ``` 363 | 364 | The output result of successful compilation: 365 | 366 | ```shell 367 | desktop/ # compile output directory 368 | ├── jammy-xj3-arm64 # After successful compilation, the generated root file system will have a large number of temporary system files 369 | ├── samplefs_desktop-v3.0.0.tar.gz # Compress and package the required content in jammy-xj3-arm64 370 | └── samplefs_desktop-v3.0.0.tar.gz.info # Which apt packages are currently installed on the system 371 | ``` 372 | 373 | build server ubuntu 374 | ```shell 375 | cd samplefs 376 | sudo ./make_ubuntu_rootfs.sh server 377 | ``` 378 | 379 | The output result of successful compilation: 380 | 381 | ```shell 382 | server/ # compile output directory 383 | ├── jammy-xj3-arm64 # After successful compilation, the generated root file system will have a large number of temporary system files 384 | ├── samplefs_server-v3.0.0.tar.gz # Compress and package the required content in jammy-xj3-arm64 385 | └── samplefs_server-v3.0.0.tar.gz.info # Which apt packages are currently installed on the system 386 | ``` 387 | 388 | After decompressing samplefs_desktop-v3.0.0.tar.gz or samplefs_server-v3.0.0.tar.gz should be included 389 | 390 | ```shell 391 | rootfs/ 392 | ├── app 393 | ├── bin -> usr/bin 394 | ├── boot 395 | ├── dev 396 | ├── etc 397 | ├── home 398 | ├── lib -> usr/lib 399 | ├── media 400 | ├── mnt 401 | ├── opt 402 | ├── proc 403 | ├── root 404 | ├── run 405 | ├── sbin -> usr/sbin 406 | ├── srv 407 | ├── sys 408 | ├── tmp 409 | ├── userdata 410 | ├── usr 411 | └── var 412 | 413 | 21 directories, 5 files 414 | ``` 415 | 416 | ### Customized modifications 417 | 418 | Definition of key variables in the code: 419 | 420 | **PYTHON_PACKAGE_LIST**: Installed Python package 421 | 422 | **DEBOOTSTRAP_LIST**:The Debian package installed during the execution of Bootstrap 423 | 424 | **BASE_PACKAGE_LIST**: The most basic Debian package required for UBuntu system installation 425 | 426 | **SERVER_PACKAGE_LIST**:Server versions of Ubuntu systems will install additional Debian packages on top of the base version 427 | 428 | **DESKTOP_PACKAGE_LIST**: Software packages that need to be installed to support desktop graphical interfaces 429 | 430 | The 'samplefs_desktop' file system maintained by D-robotics will contain the contents of all the configuration packages mentioned above, and users can add or delete them according to their own needs. 431 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # 开发环境搭建及编译说明 2 | 3 | ## 概述 4 | 5 | 介绍交叉编译开发环境的要求及搭建,系统镜像的编译说明。 6 | 7 | ## 开发环境 8 | 9 | 交叉编译是指在主机上开发和构建软件,然后把构建的软件部署到开发板上运行。主机一般拥有比开发板更高的性能和更多的内存,可以高效完成代码的构建,可以安装更多的开发工具。 10 | 11 | **主机编译环境要求** 12 | 13 | 推荐使用 Ubuntu 22.04 操作系统,保持和RDK X3相同的系统版本,减少因版本差异产生的依赖问题。 14 | 15 | Ubuntu 22.04 系统安装以下软件包: 16 | 17 | ```shell 18 | sudo apt-get install -y build-essential make cmake libpcre3 libpcre3-dev bc bison \ 19 | flex python3-numpy mtd-utils zlib1g-dev debootstrap \ 20 | libdata-hexdumper-perl libncurses5-dev zip qemu-user-static \ 21 | curl repo git liblz4-tool apt-cacher-ng libssl-dev checkpolicy autoconf \ 22 | android-sdk-libsparse-utils mtools parted dosfstools udev rsync 23 | ``` 24 | 25 | **安装交叉编译工具链** 26 | 27 | 执行以下命令下载交叉编译工具链: 28 | 29 | ```shell 30 | curl -fO http://archive.d-robotics.cc/toolchain/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz 31 | ``` 32 | 33 | 解压并安装到 /opt 目录下: 34 | 35 | ```shell 36 | sudo tar -xvf gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz -C /opt 37 | ``` 38 | 39 | ## 下载源码 40 | 41 | rdk-linux 相关的内核、bootloader、hobot-xxx 软件包源码都托管在 [GitHub](https://github.com/) 上。在下载代码前,请先注册、登录 [GitHub](https://github.com/),并通过 [Generating a new SSH key and adding it to the ssh-agent](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) 方式添加开发服务器的`SSH Key`到用户设置中。 42 | 43 | 首先,临时更换repo为国内源 44 | ```shell 45 | export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/' 46 | ``` 47 | 48 | 执行以下命令初始化主线分支仓库清单 与官方发布的最新系统镜像版本对应: 49 | 50 | ```shell 51 | repo init -u git@github.com:D-Robotics/manifest.git -b main 52 | ``` 53 | 54 | 执行以下命令同步代码 55 | 56 | ```shell 57 | repo sync 58 | ``` 59 | 60 | 也可以下载其他分支代码,比如,使用`-b develop`初始化`develop`分支仓库清单,开发分支的代码会不断新增特性与修复 bug,但是稳定性没有主分支代码高 61 | 62 | ## 源码目录结构 63 | 64 | 下载完成后,rdk-gen的目录结构如下: 65 | 66 | | **目录** | **说明** | 67 | | ------------------------- | ------------------------------------------------------------ | 68 | | pack_image.sh | 构建系统镜像的代码入口 | 69 | | download_samplefs.sh | 下载预先制作的基础ubuntu文件系统 | 70 | | download_deb_pkgs.sh | 下载D-robotics的deb软件包,需要预装到系统镜像中,包括内核、多媒体库、示例代码、tros.bot等 | 71 | | hobot_customize_rootfs.sh | 定制化修改ubuntu文件系统 | 72 | | source_sync.sh | 下载源码,包括bootloader、uboot、kernel、示例代码等源码 | 73 | | mk_kernel.sh | 编译内核、设备树和驱动模块 | 74 | | mk_debs.sh | 生成deb软件包 | 75 | | make_ubuntu_samplefs.sh | 制作ubuntu系统filesystem的代码,可以修改本脚本定制samplefs | 76 | | config | 存放需要放到系统镜像/hobot/config目录下的内容,一个vfat根式的分区,如果是sd卡启动方式,用户可以在windows系统下直接修改该分区的内容。 | 77 | 78 | ## 编译系统镜像 79 | 80 | 运行以下命令进行系统镜像的打包: 81 | 82 | ```shell 83 | cd rdk-gen 84 | sudo ./pack_image.sh 85 | ``` 86 | 87 | 需要有sudo权限进行编译,成功后会在deploy目录下生成 `*.img` 的系统镜像文件。 88 | 89 | ### pack_image.sh 编译过程介绍 90 | 91 | 1. 调用 download_samplefs.sh 和 download_deb_pkgs.sh 两个脚本从D-robotics的文件服务器上下载samplefs和需要预装的deb软件包 92 | 2. 解压samplefs,并调用 hobot_customize_rootfs.sh 脚本对filesystem做定制化配置 93 | 3. 把deb安装进filesystem 94 | 4. 生成系统镜像 95 | 96 | 97 | ## 了解source目录 98 | 99 | ``` 100 | source 101 | ├── bootloader 102 | ├── hobot-boot 103 | ├── hobot-bpu-drivers 104 | ├── hobot-camera 105 | ├── hobot-configs 106 | ├── hobot-display 107 | ├── hobot-dnn 108 | ├── hobot-dtb 109 | ├── hobot-io 110 | ├── hobot-io-samples 111 | ├── hobot-kernel-headers 112 | ├── hobot-multimedia 113 | ├── hobot-multimedia-dev 114 | ├── hobot-spdev 115 | ├── hobot-sp-samples 116 | ├── hobot-utils 117 | ├── hobot-wifi 118 | └── kernel 119 | ``` 120 | 121 | ## kernel 122 | 123 | 执行以下命令编译linux内核: 124 | 125 | ```shell 126 | ./mk_kernel.sh 127 | ``` 128 | 129 | 编译完成后,会在`deploy/kernel`目录下生成内核镜像、驱动模块、设备树、内核头文件。 130 | 131 | ```shell 132 | dtb Image Image.lz4 kernel_headers modules 133 | ``` 134 | 135 | 这些内容会被hobot-boot、hobot-dtb和hobot-kernel-headers三个debian包所使用,所以如果想要自定义修改这三个软件包,需要先编译内核。 136 | 137 | ## hobot-xxx软件包 138 | 139 | hobot-xxx软件包是D-robotics维护的debian软件包的源码和配置,下载源码后,可以执行 `mk_deb.sh` 重新构建debian包。 140 | 141 | 帮助信息如下: 142 | 143 | ```shell 144 | $ ./mk_debs.sh help 145 | The debian package named by help is not supported, please check the input parameters. 146 | ./mk_deb.sh [all] | [deb_name] 147 | hobot-multimedia-dev, Version 2.0.0 148 | hobot-wifi, Version 2.0.0 149 | hobot-camera, Version 2.0.0 150 | hobot-dtb, Version 2.0.0 151 | hobot-configs, Version 2.0.0 152 | hobot-io, Version 2.0.0 153 | hobot-spdev, Version 2.0.0 154 | hobot-boot, Version 2.0.0 155 | hobot-sp-samples, Version 2.0.0 156 | hobot-bpu-drivers, Version 2.0.0 157 | hobot-multimedia-samples, Version 2.0.0 158 | hobot-dnn, Version 2.0.0 159 | hobot-io-samples, Version 2.0.0 160 | hobot-kernel-headers, Version 2.0.0 161 | hobot-utils, Version 2.0.0 162 | hobot-multimedia, Version 2.0.0 163 | hobot-display, Version 2.0.0 164 | ``` 165 | 166 | ### 整体构建 167 | 168 | 执行以下命令会重新全部构建所有的debian包(需要先完成kernel的编译): 169 | 170 | ```shell 171 | ./mk_deb.sh 172 | ``` 173 | 174 | 构建完成后,会在`deploy/deb_pkgs`目录下生成deb软件包。 175 | 176 | ### 构建单独软件包 177 | 178 | `mk_deb.sh` 支持单独构建指定的软件包,在执行时带包名参数即可,例如: 179 | 180 | ```shell 181 | ./mk_deb.sh hobot-configs 182 | ``` 183 | 184 | ## bootloader 185 | 186 | `bootloader`源码用于生成最小启动镜像`miniboot.img`,生成包含分区表、spl、ddr、bl31、uboot一体的启动固件。 187 | 188 | RDK X3的最小启动镜像一般会由D-robotics官方进行维护发布,可以从 [miniboot](http://archive.d-robotics.cc/downloads/miniboot/) 下载对应的版本。 189 | 190 | 按照以下步骤重新编译生成miniboot。 191 | 192 | ### 选择硬件配置文件 193 | 194 | ```shell 195 | cd build 196 | ./xbuild.sh lunch 197 | 198 | You're building on #221-Ubuntu SMP Tue Apr 18 08:32:52 UTC 2023 199 | Lunch menu... pick a combo: 200 | 0. horizon/x3/board_ubuntu_emmc_sdcard_config.mk 201 | 1. horizon/x3/board_ubuntu_emmc_sdcard_samsung_4GB_config.mk 202 | 2. horizon/x3/board_ubuntu_nand_sdcard_config.mk 203 | 3. horizon/x3/board_ubuntu_nand_sdcard_samsung_4GB_config.mk 204 | Which would you like? [0] : 205 | ``` 206 | 207 | 根据提示选择板级配置文件。 208 | 209 | 以上预置配置文件都是适配不同的开发板的硬件配置,区别在于使用的emmc或者nand烧录miniboot、ddr型号和容量、根文件系统不同: 210 | 211 | | 板级配置文件 | 内存 | rootfs | 最小启动镜像存储器 | 主存储器 | 212 | | ---------------------------------------------- | ------------------ | ------------ | ------------------ | ----------- | 213 | | board_ubuntu_emmc_sdcard_config.mk | LPDDR4 2GB | ubuntu-20.04 | emmc | sdcard | 214 | | board_ubuntu_emmc_sdcard_samsung_4GB_config.mk | LPDDR4 4GB | ubuntu-20.04 | emmc | sdcard | 215 | | board_ubuntu_nand_sdcard_config.mk | LPDDR4 2GB | ubuntu-20.04 | nand | sdcard/emmc | 216 | | board_ubuntu_nand_sdcard_samsung_4GB_config.mk | LPDDR4 4GB | ubuntu-20.04 | nand | sdcard/emmc | 217 | 218 | **最小启动镜像存储器:** 烧录miniboot的存储器,RDK X3、RDK X3 Module的用户统一选择nand flash方式 219 | 220 | **主存储器:** ubuntu系统镜像的存储器,sdcard和eMMC相互兼容,即烧录到Micro sd存储卡的镜像也可以烧录到eMMC 221 | 222 | 223 | 224 | lunch命令还支持指定数字和板级配置文件名直接完成配置。 225 | 226 | ```shell 227 | $ ./xbuild.sh lunch 2 228 | 229 | You're building on #221-Ubuntu SMP Tue Apr 18 08:32:52 UTC 2023 230 | You are selected board config: horizon/x3/board_ubuntu_nand_sdcard_config.mk 231 | 232 | $ ./xbuild.sh lunch board_ubuntu_nand_sdcard_config.mk 233 | 234 | You're building on #221-Ubuntu SMP Tue Apr 18 08:32:52 UTC 2023 235 | You are selected board config: horizon/x3/board_ubuntu_nand_sdcard_config.mk 236 | ``` 237 | 238 | ### 整体编译 239 | 240 | 进入到build目录下,执行 xbuild.sh 进行整体编译: 241 | 242 | ```shell 243 | cd build 244 | ./xbuild.sh 245 | ``` 246 | 247 | 编译成功后,会在编译镜像输出目录(deploy_ubuntu_xxx) 目录下生成 miniboot.img, uboot.img, disk_nand_minimum_boot.img等镜像文件。其中disk_nand_minimum_boot.img即最小启动镜像文件。 248 | 249 | ### 模块化编译 250 | 251 | 通过 xbuild.sh 脚本编译单独模块,生成的镜像文件会输出到编译镜像输出目录(deploy_ubuntu_xxx)下。 252 | 253 | ```shell 254 | ./xbuild.sh miniboot | uboot 255 | ``` 256 | 257 | **miniboot:** 调用mk_miniboot.sh 生成 miniboot.img 258 | 259 | **uboot:** 调用mk_uboot.sh 生成 uboot.img 260 | 261 | 模块化编译后,可以执行 pack 命令打包 disk_nand_minimum_boot.img 262 | 263 | ```shell 264 | ./xbuild.sh pack 265 | ``` 266 | 267 | ## Ubuntu 文件系统制作 268 | 269 | 本章节介绍如何制作 `samplefs_desktop-v3.0.0.tar.gz` 文件系统,D-robotics会维护该文件系统,如果有定制化需求,则需按照本章说明重新制作。 270 | 271 | ### 环境配置 272 | 273 | 建议使用ubuntu主机进行开发板ubuntu文件系统的制作,首先在主机环境安装以下软件包: 274 | 275 | ```shell 276 | sudo apt-get install wget ca-certificates device-tree-compiler pv bc lzop zip binfmt-support \ 277 | build-essential ccache debootstrap ntpdate gawk gcc-arm-linux-gnueabihf qemu-user-static \ 278 | u-boot-tools uuid-dev zlib1g-dev unzip libusb-1.0-0-dev fakeroot parted pkg-config \ 279 | libncurses5-dev whiptail debian-keyring debian-archive-keyring f2fs-tools libfile-fcntllock-perl \ 280 | rsync libssl-dev nfs-kernel-server btrfs-progs ncurses-term p7zip-full kmod dosfstools \ 281 | libc6-dev-armhf-cross imagemagick curl patchutils liblz4-tool libpython2.7-dev linux-base swig acl \ 282 | python3-dev python3-distutils libfdt-dev locales ncurses-base pixz dialog systemd-container udev \ 283 | lib32stdc++6 libc6-i386 lib32ncurses5 lib32tinfo5 bison libbison-dev flex libfl-dev cryptsetup gpg \ 284 | gnupg1 gpgv1 gpgv2 cpio aria2 pigz dirmngr python3-distutils distcc git dos2unix apt-cacher-ng 285 | ``` 286 | 287 | ### 重点工具介绍 288 | 289 | #### debootstrap 290 | 291 | debootstrap是debian/ubuntu下的一个工具,用来构建一套基本的系统(根文件系统)。生成的目录符合Linux文件系统标准(FHS),即包含了 /boot、 /etc、 /bin、 /usr 等等目录,但它比发行版本的Linux体积小很多,当然功能也没那么强大,因此只能说是“基本的系统”,因此可以按照自身需求定制相应对ubuntu系统。 292 | 293 | ubuntu系统(PC)下安装debootstrap 294 | 295 | ```shell 296 | sudo apt-get install debootstrap 297 | ``` 298 | 299 | 使用方式 300 | 301 | ```shell 302 | # 可加参数指定源 303 | sudo debootstrap --arch [平台] [发行版本代号] [目录] [源] 304 | ``` 305 | 306 | #### chroot 307 | 308 | chroot,即 change root directory (更改 root 目录)。在 linux 系统中,系统默认的目录结构都是以 `/`,即是以根 (root) 开始的。而在使用 chroot 之后,系统的目录结构将以指定的位置作为 `/` 位置。 309 | 310 | #### parted 311 | 312 | parted命令是由GNU组织开发的一款功能强大的磁盘分区和分区大小调整工具,与fdisk不同,它支持调整分区的大小。作为一种设计用于Linux的工具,它没有构建成处理与fdisk关联的多种分区类型,但是,它可以处理最常见的分区格式,包括:ext2、ext3、fat16、fat32、NTFS、ReiserFS、JFS、XFS、UFS、HFS以及Linux交换分区。 313 | 314 | ### 制作Ubuntu rootfs脚本代码 315 | 316 | 执行以下命令生成ubuntu文件系统: 317 | 318 | 制作desktop系统 319 | ```shell 320 | cd samplefs 321 | sudo ./make_ubuntu_rootfs.sh 322 | ``` 323 | 324 | 编译成功的输出结果: 325 | 326 | ```shell 327 | desktop/ # 编译输出目录 328 | ├── jammy-xj3-arm64 # 编译成功后生成的根文件系统,会有比较多的系统临时文件 329 | ├── samplefs_desktop-v3.0.0.tar.gz # 压缩打包 jammy-xj3-arm64 内需要的内容 330 | └── samplefs_desktop-v3.0.0.tar.gz.info # 当前系统安装了哪些 apt 包 331 | ``` 332 | 333 | 制作server系统 334 | ```shell 335 | cd samplefs 336 | sudo ./make_ubuntu_rootfs.sh server 337 | ``` 338 | 339 | 编译成功的输出结果: 340 | 341 | ```shell 342 | server/ # 编译输出目录 343 | ├── jammy-xj3-arm64 # 编译成功后生成的根文件系统,会有比较多的系统临时文件 344 | ├── samplefs_server-v3.0.0.tar.gz # 压缩打包 jammy-xj3-arm64 内需要的内容 345 | └── samplefs_server-v3.0.0.tar.gz.info # 当前系统安装了哪些 apt 包 346 | ``` 347 | 348 | 解压 samplefs_desktop-v3.0.0.tar.gz 或者 samplefs_server-v3.0.0.tar.gz 后应该包含以下文件 349 | 350 | ```shell 351 | rootfs/ 352 | ├── app 353 | ├── bin -> usr/bin 354 | ├── boot 355 | ├── dev 356 | ├── etc 357 | ├── home 358 | ├── lib -> usr/lib 359 | ├── media 360 | ├── mnt 361 | ├── opt 362 | ├── proc 363 | ├── root 364 | ├── run 365 | ├── sbin -> usr/sbin 366 | ├── srv 367 | ├── sys 368 | ├── tmp 369 | ├── userdata 370 | ├── usr 371 | └── var 372 | 373 | 21 directories, 5 files 374 | ``` 375 | 376 | ### 定制化修改 377 | 378 | 代码中的关键变量定义: 379 | 380 | **PYTHON_PACKAGE_LIST**: 安装的python包 381 | 382 | **DEBOOTSTRAP_LIST**:debootstrap执行时安装的Debian软件包 383 | 384 | **BASE_PACKAGE_LIST**: 最基本的UBuntu系统所需要安装的Debian软件包 385 | 386 | **SERVER_PACKAGE_LIST**:Server 版本的Ubuntu系统会在基本版本上多安装的Debian软件包 387 | 388 | **DESKTOP_PACKAGE_LIST**: 支持桌面图形化界面需要安装的软件包 389 | 390 | D-robotics官方维护的 `samplefs_desktop` 文件系统会包含以上所有配置包的内容,用户可以根据自己的需求进行增、删。 391 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 3.0.0 2 | -------------------------------------------------------------------------------- /config/hobot_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # By default this script does nothing. 4 | 5 | exit 0 6 | -------------------------------------------------------------------------------- /download_deb_pkgs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### 3 | # COPYRIGHT NOTICE 4 | # Copyright 2023 Horizon Robotics, Inc. 5 | # All rights reserved. 6 | # @Date: 2023-03-15 15:58:13 7 | # @LastEditTime: 2023-05-15 14:50:53 8 | ### 9 | 10 | archive_url="http://archive.d-robotics.cc/ubuntu-rdk" 11 | 12 | deb_pkg_list=(hobot-multimedia-samples \ 13 | hobot-sp-samples \ 14 | hobot-io-samples \ 15 | hobot-bpu-drivers \ 16 | hobot-kernel-headers \ 17 | hobot-miniboot \ 18 | hobot-configs hobot-utils \ 19 | hobot-display hobot-wifi \ 20 | hobot-models-basic \ 21 | tros ) 22 | 23 | download_pkg_list=() 24 | 25 | download_file() 26 | { 27 | pkg_file="$1" 28 | pkg_url="$2" 29 | md5sum="$3" 30 | 31 | # Download the deb package 32 | echo "Downloading ${pkg_file} ..." 33 | if ! curl -fs -O --connect-timeout 5 "$PKG_URL"; then 34 | echo "Error: Unable to download ${pkg_file}" >&2 35 | rm -f ${pkg_file} 36 | return 1 37 | fi 38 | 39 | # Calculate the md5sum of the downloaded file 40 | DOWNLOADED_MD5SUM=$(md5sum "${pkg_file}" | awk '{print $1}') 41 | 42 | # Verify the md5sum value of the downloaded file 43 | if [[ "${md5sum}" == "${DOWNLOADED_MD5SUM}" ]]; then 44 | echo "File ${pkg_file} verify successfully" 45 | else 46 | echo "File ${pkg_file} verify md5sum failed, Expected to be ${md5sum}, actually ${DOWNLOADED_MD5SUM}" 47 | rm ${pkg_file} 48 | return -1 49 | fi 50 | } 51 | 52 | # Download the latest version of the deb package 53 | get_download_pkg_list() 54 | { 55 | pkg_list=($@) 56 | 57 | # Loop through each package name in the list 58 | for pkg_name in ${pkg_list[@]} 59 | do 60 | # if pkg_name in download_pkg_list, skip add it 61 | if [[ ${download_pkg_list[@]} =~ "${pkg_name}," ]]; then 62 | continue 63 | fi 64 | 65 | # Get the latest version number from the Packages file 66 | VERSION=$(cat Packages | awk -v pkg=${pkg_name} '$1 == "Package:" && $2 == pkg {getline; print}' | awk '{print $2}' | sort -V | tail -n1) 67 | FILENAME=$(grep -A 10 -E "^Package: ${pkg_name}$" Packages | grep -A 9 -B 1 -E "Version: ${VERSION}$" | grep '^Filename: ' | cut -d ' ' -f 2 | sort -V | tail -n1) 68 | MD5SUM=$(grep -A 10 -B 1 -E "Package: ${pkg_name}$" Packages | grep -A 9 -B 1 -E "Version: ${VERSION}$" | grep '^MD5sum: ' | cut -d ' ' -f 2 | sort -V | tail -n1) 69 | DEPENDS=$(grep -A 10 -B 1 -E "Package: ${pkg_name}$" Packages | grep -A 9 -B 1 -E "Version: ${VERSION}$" | grep '^Depends: ' | cut -d ' ' -f 2- | sed 's/,/ /g') 70 | 71 | # echo "Package: ${pkg_name} Version: ${VERSION} FILENAME: ${FILENAME} MD5SUM: ${MD5SUM} DEPENDS: ${DEPENDS}" 72 | 73 | if [[ -z "$VERSION" ]]; then 74 | echo "Error: Unable to retrieve version number for $pkg_name" >&2 75 | return 1 76 | fi 77 | 78 | # Construct the name of the deb package 79 | PKG_FILE=$(basename "${FILENAME}") 80 | 81 | # Construct the download URL for the deb package 82 | PKG_URL="${archive_url}/${FILENAME}" 83 | 84 | # Add ${pkg_name},${PKG_FILE},${PKG_URL},${MD5SUM} into download_pkg_list 85 | download_pkg_list+=("${pkg_name},${VERSION},${PKG_FILE},${PKG_URL},${MD5SUM}") 86 | 87 | # delete name dose not start with "hobot" abd "tros" 88 | DEPENDS=$(echo ${DEPENDS} | awk '{for(i=1;i<=NF;i++) if($i ~ /^hobot/ || $i ~ /^tros/) print $i}') 89 | 90 | # delete head and tail empty string 91 | DEPENDS=$(echo "${DEPENDS[@]}" | sed 's/^ *//g' | sed 's/ *$//g') 92 | # if depends not null, recursively parse dependent packages 93 | [ ! -z "${DEPENDS[@]}" ] && get_download_pkg_list "${DEPENDS[@]}" 94 | done 95 | } 96 | 97 | download_deb_pkgs() 98 | { 99 | pkg_list=($@) 100 | 101 | # Loop through each package name in the list 102 | for pkg_info in ${pkg_list[@]} 103 | do 104 | # parse pkg_info into pkg_name, pkg_file, pkg_url, md5sum 105 | pkg_name=$(echo ${pkg_info} | cut -d ',' -f 1) 106 | VERSION=$(echo ${pkg_info} | cut -d ',' -f 2) 107 | PKG_FILE=$(echo ${pkg_info} | cut -d ',' -f 3) 108 | PKG_URL=$(echo ${pkg_info} | cut -d ',' -f 4) 109 | MD5SUM=$(echo ${pkg_info} | cut -d ',' -f 5) 110 | 111 | # Get a list of all .deb files in the current directory with the same package name as pkg_name 112 | FILES=$(ls ${pkg_name}_*.deb 2>/dev/null || true) 113 | 114 | # Loop through each file and delete any with a lower version number than the latest version 115 | for file in $FILES; do 116 | file_version=$(echo ${file} | sed "s/${pkg_name}_\(.*\)_arm64.deb/\1/") 117 | if [[ $file_version < $VERSION ]]; then 118 | echo "Deleting older version of ${file}" 119 | rm "${file}" 120 | fi 121 | done 122 | 123 | # Check if the package has already been downloaded 124 | if [[ -f "$PKG_FILE" ]]; then 125 | echo "$PKG_FILE already exists. Skipping download." 126 | continue 127 | fi 128 | 129 | download_file ${PKG_FILE} ${PKG_URL} ${MD5SUM} 130 | if [ $? -ne 0 ]; then 131 | echo "Error: Unable to download ${PKG_FILE}" >&2 132 | return 1 133 | fi 134 | done 135 | } 136 | 137 | main() 138 | { 139 | #./download_deb_pkgs.sh 140 | #deb_dir must first 141 | #-u focal/jammy default focal 142 | #-d release/beta default release 143 | ubuntu_version="focal" 144 | develop_version="release" 145 | 146 | if [ $# -ge 1 ] ; then 147 | dep_pkg_dir="$1" 148 | shift 149 | echo "usag: ./download_deb_pkgs.sh dep_pkg_dir -u jammy -d release" 150 | else 151 | echo "failed!!!" 152 | echo "usag: ./download_deb_pkgs.sh dep_pkg_dir -u jammy -d release" 153 | return 154 | fi 155 | 156 | while (($# > 0)) 157 | do 158 | if [ "$1" == "-u" ] ; then 159 | shift 160 | ubuntu_version=$1 161 | fi 162 | if [ "$1" == "-d" ] ; then 163 | shift 164 | develop_version=$1 165 | fi 166 | shift 167 | done 168 | 169 | if [ "$develop_version" == "beta" ] ; then 170 | archive_url="http://archive.d-robotics.cc//ubuntu-rdk-beta" 171 | fi 172 | 173 | if [ "$ubuntu_version" == "jammy" ] ; then 174 | deb_pkg_list=(hobot-multimedia-samples \ 175 | hobot-sp-samples \ 176 | hobot-io-samples \ 177 | hobot-bpu-drivers \ 178 | hobot-kernel-headers \ 179 | hobot-miniboot \ 180 | hobot-configs hobot-utils \ 181 | hobot-display hobot-wifi \ 182 | hobot-models-basic \ 183 | tros-humble ) 184 | fi 185 | 186 | package_url="/dists/""$ubuntu_version""/main/binary-arm64/Packages" 187 | 188 | [ ! -z ${dep_pkg_dir} ] && [ ! -d ${dep_pkg_dir} ] && mkdir ${dep_pkg_dir} 189 | cd ${dep_pkg_dir} 190 | 191 | if curl -sfO --connect-timeout 5 "${archive_url}${package_url}"; then 192 | echo "Packages downloaded successfully" 193 | else 194 | echo "Packages downloaded failed" 195 | return -1 196 | fi 197 | 198 | get_download_pkg_list "${deb_pkg_list[@]}" 199 | # delete same item in download_pkg_list 200 | download_pkg_list=($(echo "${download_pkg_list[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')) 201 | 202 | download_deb_pkgs "${download_pkg_list[@]}" 203 | } 204 | 205 | main $@ 206 | -------------------------------------------------------------------------------- /download_samplefs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### 3 | # COPYRIGHT NOTICE 4 | # Copyright 2023 Horizon Robotics, Inc. 5 | # All rights reserved. 6 | # @Date: 2023-03-24 21:02:31 7 | # @LastEditTime: 2023-05-15 14:35:12 8 | ### 9 | 10 | set -e 11 | 12 | main() 13 | { 14 | #./download_samplefs.sh 15 | #rootfs_dir must first 16 | #-t desktop/server default desktop 17 | #-u focal/jammy default focal 18 | #-v v2.0.0/v2.1.0 default latest 19 | ubuntu_version="focal" 20 | ubuntufs_src="desktop" 21 | samplefs_version="latest" 22 | 23 | if [ $# -ge 1 ] ; then 24 | rootfs_dir="$1" 25 | shift 26 | echo "usag: ./download_samplefs.sh rootfs_dir -u jammy -t desktop -v latest or v2.1.0" 27 | else 28 | echo "failed!!!" 29 | echo "usag: ./download_samplefs.sh rootfs_dir -u jammy -t desktop -v latest or v2.1.0" 30 | return 31 | fi 32 | 33 | while (($# > 0)) 34 | do 35 | if [ "$1" == "-t" ] ; then 36 | shift 37 | ubuntufs_src=$1 38 | fi 39 | if [ "$1" == "-u" ] ; then 40 | shift 41 | ubuntu_version=$1 42 | fi 43 | if [ "$1" == "-v" ] ; then 44 | shift 45 | samplefs_version=$1 46 | fi 47 | shift 48 | done 49 | 50 | echo $rootfs_dir $ubuntu_version $ubuntufs_src $samplefs_version 51 | 52 | [ ! -z ${rootfs_dir} ] && [ ! -d ${rootfs_dir} ] && mkdir ${rootfs_dir} 53 | cd ${rootfs_dir} 54 | 55 | # Set the URL of the file server 56 | SERVER_URL="http://archive.d-robotics.cc/samplefs" 57 | 58 | FILE_NAME="samplefs_""$ubuntufs_src" 59 | echo "FILE_NAME: " $FILE_NAME 60 | 61 | if [ "$samplefs_version" == "latest" ] ; then 62 | VERSION_FILE="samplefs_""$ubuntufs_src""_""$ubuntu_version""_latest.txt" 63 | 64 | echo "VERSION_FILE: "$VERSION_FILE 65 | 66 | # Download the version information file 67 | if curl -fs -O --connect-timeout 5 "${SERVER_URL}/${FILE_NAME}/${ubuntu_version}/${VERSION_FILE}"; then 68 | echo "File ${VERSION_FILE} downloaded successfully" 69 | else 70 | echo "File ${VERSION_FILE} downloaded failed" 71 | return -1 72 | fi 73 | 74 | # Extract the list of files to download from the version information file 75 | FILE=$(cat "$VERSION_FILE" | grep -v "^#") 76 | else 77 | FILE="samplefs_""$ubuntufs_src""_""$ubuntu_version""-""$samplefs_version"".tar.gz" 78 | fi 79 | 80 | echo "FILE: "$FILE 81 | MD5_FILE=${FILE::-6}"md5sum" 82 | echo "MD5_FILE: " $MD5_FILE 83 | 84 | # Check if the file has already been downloaded 85 | if [[ -f "${FILE}" ]]; then 86 | echo "File ${FILE} already exists, skipping download" 87 | return 0 88 | fi 89 | 90 | # Download the md5sum file for the file 91 | if curl -fs -O --connect-timeout 5 "${SERVER_URL}/${FILE_NAME}/${ubuntu_version}/${MD5_FILE}"; then 92 | echo "File ${MD5_FILE} downloaded successfully" 93 | else 94 | echo "File ${MD5_FILE} downloaded failed" 95 | return -1 96 | fi 97 | 98 | # Extract the file name and md5sum value from the md5sum file 99 | FILE_MD5SUM=$(cat "${MD5_FILE}" | grep ${FILE_NAME} | cut -d " " -f1) 100 | 101 | # Download the file 102 | echo "Downloading ${FILE} ..." 103 | if curl -f -O --connect-timeout 5 "${SERVER_URL}/${FILE_NAME}/${ubuntu_version}/${FILE}"; then 104 | echo "File ${FILE} downloaded successfully" 105 | else 106 | echo "File ${FILE} downloaded failed" 107 | rm -f ${FILE} 108 | return -1 109 | fi 110 | 111 | # Calculate the md5sum of the downloaded file 112 | DOWNLOADED_MD5SUM=$(md5sum "${FILE}" | awk '{print $1}') 113 | 114 | # Verify the md5sum value of the downloaded file 115 | if [[ "${FILE_MD5SUM}" == "${DOWNLOADED_MD5SUM}" ]]; then 116 | echo "File ${FILE} verify successfully" 117 | else 118 | echo "File ${FILE} verify md5sum failed, Expected to be ${FILE_MD5SUM}, actually ${DOWNLOADED_MD5SUM}" 119 | rm ${FILE} 120 | return -1 121 | fi 122 | 123 | 124 | return 0 125 | } 126 | 127 | main $@ 128 | -------------------------------------------------------------------------------- /hobot_customize_rootfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | function hobot_customize_rootfs() 6 | { 7 | DST_ROOTFS_DIR="${1}" 8 | 9 | CONSOLE_CHAR="UTF-8" 10 | DEST_LANG="en_US.UTF-8" 11 | 12 | # Configure hostname 13 | HOST="ubuntu" 14 | echo "$HOST" > ${DST_ROOTFS_DIR}/etc/hostname 15 | echo "127.0.1.1 ${HOST}" >> "${DST_ROOTFS_DIR}/etc/hosts" 16 | 17 | # Configure ssh 18 | # permit root login via SSH for the first boot 19 | sed -i 's/#\?PermitRootLogin .*/PermitRootLogin yes/' "${DST_ROOTFS_DIR}"/etc/ssh/sshd_config 20 | # enable PubkeyAuthentication 21 | sed -i 's/#\?PubkeyAuthentication .*/PubkeyAuthentication yes/' "${DST_ROOTFS_DIR}"/etc/ssh/sshd_config 22 | 23 | # console fix due to Debian bug 24 | sed -e 's/CHARMAP=".*"/CHARMAP="'$CONSOLE_CHAR'"/g' -i "${DST_ROOTFS_DIR}"/etc/default/console-setup 25 | 26 | # add the /dev/urandom path to the rng config file 27 | echo "HRNGDEVICE=/dev/urandom" >> "${DST_ROOTFS_DIR}"/etc/default/rng-tools 28 | 29 | # configure network manager 30 | sed "s/managed=\(.*\)/managed=true/g" -i "${DST_ROOTFS_DIR}"/etc/NetworkManager/NetworkManager.conf 31 | 32 | # Just regular DNS and maintain /etc/resolv.conf as a file 33 | sed "/dns/d" -i "${DST_ROOTFS_DIR}"/etc/NetworkManager/NetworkManager.conf 34 | sed "s/\[main\]/\[main\]\ndns=default\nrc-manager=file/g" -i "${DST_ROOTFS_DIR}"/etc/NetworkManager/NetworkManager.conf 35 | if [[ -n $NM_IGNORE_DEVICES ]]; then 36 | mkdir -p "${DST_ROOTFS_DIR}"/etc/NetworkManager/conf.d/ 37 | cat <<-EOF > "${DST_ROOTFS_DIR}"/etc/NetworkManager/conf.d/10-ignore-interfaces.conf 38 | [keyfile] 39 | unmanaged-devices=$NM_IGNORE_DEVICES 40 | EOF 41 | fi 42 | 43 | # Resize the size of the tty 44 | cat <<-EOF >> "${DST_ROOTFS_DIR}"/etc/skel/.bashrc 45 | # Make sure we are on a serial console (i.e. the device used starts with 46 | # /dev/tty[A-z]), otherwise we confuse e.g. the eclipse launcher which tries do 47 | # use ssh 48 | case \$(tty 2>/dev/null) in 49 | /dev/tty[A-z]*) [ -x /usr/bin/resize_tty ] && /usr/bin/resize_tty >/dev/null;; 50 | esac 51 | EOF 52 | 53 | # most likely we don't need to wait for nm to get online 54 | # Disabling NetworkManager-wait-online.service 55 | echo "Disabling NetworkManager-wait-online.service" 56 | if [ -h "${DST_ROOTFS_DIR}/etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service" ]; then 57 | rm "${DST_ROOTFS_DIR}/etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service" 58 | fi 59 | 60 | # Remove the spawning of ondemand service 61 | if [ -h "${DST_ROOTFS_DIR}/etc/systemd/system/multi-user.target.wants/ondemand.service" ]; then 62 | rm -f "${DST_ROOTFS_DIR}/etc/systemd/system/multi-user.target.wants/ondemand.service" 63 | fi 64 | 65 | # initial date for fake- 66 | # Configure fake-hwclock 67 | date '+%Y-%m-%d %H:%M:%S' > "${DST_ROOTFS_DIR}"/etc/fake-hwclock.data 68 | 69 | # Disable unattended upgrade 70 | if [ -e "${DST_ROOTFS_DIR}/etc/apt/apt.conf.d/20auto-upgrades" ]; then 71 | sed -i "s/Unattended-Upgrade \"1\"/Unattended-Upgrade \"0\"/" \ 72 | "${DST_ROOTFS_DIR}/etc/apt/apt.conf.d/20auto-upgrades" 73 | fi 74 | 75 | # Disable release upgrade 76 | if [ -e "${DST_ROOTFS_DIR}/etc/update-motd.d/91-release-upgrade" ]; then 77 | rm -f "${DST_ROOTFS_DIR}/etc/update-motd.d/91-release-upgrade" 78 | fi 79 | if [ -e "${DST_ROOTFS_DIR}/etc/update-manager/release-upgrades" ]; then 80 | sed -i "s/Prompt=lts/Prompt=never/" \ 81 | "${DST_ROOTFS_DIR}/etc/update-manager/release-upgrades" 82 | fi 83 | 84 | groups_list="audio gpio i2c video misc vps ipu jpu graphics weston-launch lightdm gdm render vpu kmem dialout disk" 85 | extra_groups="EXTRA_GROUPS=\"${groups_list}\"" 86 | sed -i "/\=/ s/^.*/${extra_groups}/" \ 87 | "${DST_ROOTFS_DIR}/etc/adduser.conf" 88 | sed -i "/\=/ s/^.*/ADD_EXTRA_GROUPS=1/" \ 89 | "${DST_ROOTFS_DIR}/etc/adduser.conf" 90 | 91 | for group_name in ${groups_list} 92 | do 93 | chroot "${DST_ROOTFS_DIR}" /bin/bash -c "groupadd -rf ${group_name} || true" 94 | done 95 | 96 | # Create User 97 | SUN_USERNAME="sunrise" 98 | ROOTPWD="root" 99 | SUN_PWD="sunrise" 100 | chroot "${DST_ROOTFS_DIR}" /bin/bash -c "(echo $ROOTPWD;echo $ROOTPWD;) | passwd root" 101 | chroot "${DST_ROOTFS_DIR}" /bin/bash -c "useradd -U -m -d /home/${SUN_USERNAME} -k /etc/skel/ -s /bin/bash -G sudo,${groups_list//' '/','} ${SUN_USERNAME}" 102 | chroot "${DST_ROOTFS_DIR}" /bin/bash -c "(echo ${SUN_PWD};echo ${SUN_PWD};) | passwd ${SUN_USERNAME}" 103 | 104 | chroot "${DST_ROOTFS_DIR}" /bin/bash -c "cp -aRf /etc/skel/. /root/" 105 | chroot "${DST_ROOTFS_DIR}" /bin/bash -c "cp -aRf /etc/skel/. /home/${SUN_USERNAME}" 106 | } 107 | -------------------------------------------------------------------------------- /mk_debs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # set -x 4 | set -euo pipefail 5 | 6 | export HR_LOCAL_DIR=$(realpath $(cd $(dirname $0); pwd)) 7 | 8 | # 编译出来的镜像保存位置 9 | export IMAGE_DEPLOY_DIR=${HR_LOCAL_DIR}/deploy 10 | export CROSS_COMPILE=/opt/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- 11 | [ ! -z ${IMAGE_DEPLOY_DIR} ] && [ ! -d $IMAGE_DEPLOY_DIR ] && mkdir $IMAGE_DEPLOY_DIR 12 | 13 | ARCH=arm64 14 | 15 | pkg_build_time=$(date '+%Y%m%d%H%M%S') 16 | 17 | function gen_contrl_file() { 18 | control_path="$1" 19 | Package="$2" 20 | Version="$3" 21 | Description="$4" 22 | Architecture="$ARCH" 23 | Maintainer="technical_support@horizon.cc" 24 | if [ ! -f ${control_path}/control ];then 25 | touch ${control_path}/control 26 | fi 27 | cat <<-EOF > ${control_path}/control 28 | Package: ${Package} 29 | Version: ${Version} 30 | Architecture: ${ARCH} 31 | Maintainer: ${Maintainer} 32 | Depends: "" 33 | Installed-Size: 0 34 | Description: ${Description} 35 | 36 | EOF 37 | } 38 | 39 | function gen_conffiles() { 40 | local dir="$1" 41 | echo "Generate the conffiles, and add the files in the ${dir} directory to it" 42 | touch ${control_path}/conffiles 43 | 44 | cd ${deb_dst_dir} 45 | for file in $(find "./${dir}" -type f); do 46 | # Append each file to the conffiles file 47 | echo "/${file#./}" >> ${control_path}/conffiles 48 | done 49 | } 50 | 51 | function gen_copyright() { 52 | echo "Generate the copyright" 53 | mkdir -p ${deb_dst_dir}/usr/share/doc/${Package} 54 | cat < "${deb_dst_dir}/usr/share/doc/${Package}/copyright" 55 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 56 | 57 | Files: * 58 | Copyright: 2023, Horizon Robotics 59 | EOF 60 | } 61 | 62 | function gen_changelog() { 63 | echo "Generate the changelog" 64 | changelog=$(mktemp) 65 | 66 | cat < "${changelog}" 67 | ${Package} ($Version) 68 | 69 | * Refer to Package Release Notes for details: https://developer.horizon.ai/api/v1/fileData/documents_pi/index.html 70 | 71 | -- ${Maintainer} 72 | 73 | EOF 74 | mkdir -p ${deb_dst_dir}/usr/share/doc/${Package} 75 | original="${deb_dst_dir}/usr/share/doc/${Package}/changelog.Debian.gz" 76 | if [ -f ${original} ]; then 77 | zcat "${original}" >> "${changelog}" 78 | fi 79 | gzip -9nf -c "${changelog}" > "${original}" 80 | } 81 | 82 | function gen_md5sum() { 83 | echo "Calulating md5sum" 84 | pushd "${deb_dst_dir}" > /dev/null 85 | find . -type f ! -path "./${control_path##*/}/*" ! -path "./etc/*" | LC_ALL=C sort | xargs md5sum | \ 86 | sed -e 's@\./@ @' > "${control_path}/md5sums" 87 | popd > /dev/null 88 | } 89 | 90 | function calc_installed_size() 91 | { 92 | echo "Calulating the installed size" 93 | installed_size=0 94 | list=($(find "${deb_dst_dir}" \( -type f -o -type l \) \ 95 | ! -path "*/${control_path##*/}/control" ! -path "*/${control_path##*/}/md5sums")) 96 | for file in "${list[@]}"; do 97 | size=$(stat -c %s "${file}") 98 | if [ ${size} -gt 0 ];then 99 | ((installed_size+=(${size}+1023)/1024)) 100 | fi 101 | done 102 | 103 | ((installed_size+=$(find "${deb_dst_dir}" ! \( -type f -o -type l \) | wc -l))) 104 | sed -ri "s/(^Installed-Size:) ([0-9]*)$/\1 ${installed_size}/" "${control_path}/control" 105 | # echo "Installed-Size: ${installed_size}" >> "${control_path}/control" 106 | } 107 | 108 | debian_src_dir="${HR_LOCAL_DIR}/source" 109 | debian_dst_dir="${IMAGE_DEPLOY_DIR}/deb_pkgs" 110 | 111 | function get_version() { 112 | if [ $# -ne 1 ]; then 113 | echo "Usage: get_version " 114 | return 1 115 | fi 116 | 117 | local dir_path="$1" 118 | local version_file="$dir_path/VERSION" 119 | 120 | if [ ! -d "$dir_path" ]; then 121 | echo "Error: Directory '$dir_path' does not exist." 122 | return 1 123 | fi 124 | 125 | if [ ! -f "$version_file" ]; then 126 | echo "Error: VERSION file not found in '$dir_path'." 127 | return 1 128 | fi 129 | 130 | local version=$(cat "$version_file") 131 | echo "$version" 132 | } 133 | 134 | 135 | function make_debian_deb() { 136 | pkg_name=${1} 137 | pkg_version=$(get_version ${debian_src_dir}/${pkg_name})-${pkg_build_time} 138 | 139 | #命名规范:hobot-包名_版本_架构 140 | deb_name=${pkg_name}_${pkg_version}_${ARCH} 141 | deb_dst_dir=${debian_dst_dir}/${deb_name} 142 | deb_src_dir=${debian_src_dir}/${pkg_name}/debian 143 | rm -rf ${debian_dst_dir}/${pkg_name}_* 144 | echo deb_dst_dir = ${deb_dst_dir} 145 | mkdir -p ${deb_dst_dir} 146 | cp -a ${deb_src_dir}/* ${deb_dst_dir}/ 147 | 148 | echo start ${FUNCNAME} : ${deb_dst_dir}/${deb_name}.deb 149 | 150 | is_allowed=0 151 | case ${pkg_name} in 152 | hobot-boot) 153 | KERNEL_DEPLOY_DIR=${IMAGE_DEPLOY_DIR}/kernel 154 | if [ ! -d "${KERNEL_DEPLOY_DIR}" ]; then 155 | echo "Directory ${KERNEL_DEPLOY_DIR} does not exist, please build kernel." 156 | exit 1 157 | fi 158 | 159 | pkg_description="Kernel Package. Provides kernel image and drivers." 160 | 161 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 162 | 163 | # set Depends 164 | sed -i 's/Depends: .*$/Depends: hobot-dtb/' ${deb_dst_dir}/DEBIAN/control 165 | 166 | boot_dest_dir=${deb_dst_dir}/boot 167 | mkdir -p ${boot_dest_dir} 168 | cp -arf ${IMAGE_DEPLOY_DIR}/kernel/Image ${boot_dest_dir}/ 169 | cp -arf ${KERNEL_DEPLOY_DIR}/modules/* ${deb_dst_dir}/ 170 | 171 | is_allowed=1 172 | ;; 173 | hobot-kernel-headers) 174 | KERNEL_DEPLOY_DIR=${IMAGE_DEPLOY_DIR}/kernel 175 | if [ ! -d "${KERNEL_DEPLOY_DIR}" ]; then 176 | echo "Directory ${KERNEL_DEPLOY_DIR} does not exist, please build kernel." 177 | exit 1 178 | fi 179 | 180 | pkg_description="Linux kernel headers for 4.14.87 on arm64 181 | This package provides kernel header files for 4.14.87 on arm64. 182 | This is useful for people who need to build external modules. 183 | Generally used for building out-of-tree kernel modules." 184 | 185 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 186 | 187 | # set Depends 188 | sed -i 's/Depends: .*$/Depends: hobot-boot/' ${deb_dst_dir}/DEBIAN/control 189 | 190 | cp -arf ${IMAGE_DEPLOY_DIR}/kernel/kernel_headers/* ${deb_dst_dir}/ 191 | is_allowed=1 192 | ;; 193 | hobot-dtb) 194 | KERNEL_DEPLOY_DIR=${IMAGE_DEPLOY_DIR}/kernel 195 | if [ ! -d "${KERNEL_DEPLOY_DIR}" ]; then 196 | echo "Directory ${KERNEL_DEPLOY_DIR} does not exist, please build kernel." 197 | exit 1 198 | fi 199 | 200 | pkg_description="Kernel DTB Package, This package provides kernel device tree." 201 | 202 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 203 | 204 | # set Depends 205 | sed -i 's/Depends: .*$/Depends: /' ${deb_dst_dir}/DEBIAN/control 206 | 207 | dtb_dest_dir=${deb_dst_dir}/boot/hobot 208 | mkdir -p ${dtb_dest_dir} 209 | cp -arf ${IMAGE_DEPLOY_DIR}/kernel/dtb/* ${dtb_dest_dir}/ 210 | 211 | is_allowed=1 212 | ;; 213 | hobot-bpu-drivers) 214 | pkg_description="Horizon BPU Drivers" 215 | 216 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 217 | 218 | # set Depends 219 | sed -i 's/Depends: .*$/Depends: hobot-boot/' ${deb_dst_dir}/DEBIAN/control 220 | 221 | is_allowed=1 222 | ;; 223 | hobot-configs) 224 | pkg_description="Horizon custom system configuration" 225 | 226 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 227 | 228 | # set Depends 229 | sed -i 's/Depends: .*$/Depends: hobot-boot, udisks2, hobot-audio-config/' ${deb_dst_dir}/DEBIAN/control 230 | 231 | is_allowed=1 232 | ;; 233 | hobot-utils) 234 | pkg_description="Horizon Software Toolset" 235 | 236 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 237 | 238 | # set Depends 239 | sed -i 's/Depends: .*$/Depends: hobot-boot/' ${deb_dst_dir}/DEBIAN/control 240 | 241 | cd ${debian_src_dir}/${pkg_name}/hbutils 242 | # real build 243 | make || { 244 | echo "make failed" 245 | exit 1 246 | } 247 | 248 | make install || { 249 | echo "make install failed" 250 | exit 1 251 | } 252 | 253 | mkdir -p $deb_dst_dir/usr/bin 254 | ls ${debian_src_dir}/${pkg_name}/hbutils/_install/hrut* > /dev/null 255 | if [ $? -eq 0 ];then 256 | echo "cp -a ${debian_src_dir}/${pkg_name}/hbutils/_install/hrut* $deb_dst_dir/usr/bin" 257 | cp -a ${debian_src_dir}/${pkg_name}/hbutils/_install/hrut* $deb_dst_dir/usr/bin 258 | fi 259 | cp -a ${debian_src_dir}/${pkg_name}/hbutils/utility/prebuilds/hrut* $deb_dst_dir/usr/bin 260 | is_allowed=1 261 | ;; 262 | hobot-display) 263 | pkg_description="Display Support Package" 264 | 265 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 266 | 267 | # set Depends 268 | sed -i 's/Depends: .*$/Depends: /' ${deb_dst_dir}/DEBIAN/control 269 | 270 | cd ${debian_src_dir}/${pkg_name}/hobot_display_services 271 | make || { 272 | echo "make failed" 273 | exit 1 274 | } 275 | 276 | mkdir -p $deb_dst_dir/usr/bin 277 | cp -a ${debian_src_dir}/${pkg_name}/hobot_display_services/display $deb_dst_dir/usr/bin/hobot_display_service 278 | cp -a ${debian_src_dir}/${pkg_name}/hobot_display_services/get_edid_raw_data $deb_dst_dir/usr/bin 279 | cp -a ${debian_src_dir}/${pkg_name}/hobot_display_services/get_hdmi_res $deb_dst_dir/usr/bin 280 | cp -a ${debian_src_dir}/${pkg_name}/hobot_display_services/hobot_parse_std_timing $deb_dst_dir/usr/bin 281 | mkdir -p $deb_dst_dir/usr/lib 282 | cp -a ${debian_src_dir}/${pkg_name}/hobot_display_services/liblt8618.so $deb_dst_dir/usr/lib 283 | 284 | is_allowed=1 285 | ;; 286 | hobot-wifi) 287 | pkg_description="Wi-Fi Support Package" 288 | 289 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 290 | 291 | # set Depends 292 | sed -i 's/Depends: .*$/Depends: /' ${deb_dst_dir}/DEBIAN/control 293 | 294 | is_allowed=1 295 | ;; 296 | hobot-io) 297 | pkg_description="IO Support Package" 298 | 299 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 300 | 301 | # set Depends 302 | sed -i 's/Depends: .*$/Depends: hobot-boot/' ${deb_dst_dir}/DEBIAN/control 303 | 304 | mkdir -p $deb_dst_dir/usr/bin 305 | hb_dtb_tool_dir=${debian_src_dir}/${pkg_name}/hb_dtb_tool 306 | cd ${debian_src_dir}/${pkg_name}/hb_dtb_tool 307 | make || { 308 | echo "make failed" 309 | exit 1 310 | } 311 | 312 | if [ -f ${hb_dtb_tool_dir}/hb_dtb_tool ];then 313 | echo "cp -a ${hb_dtb_tool_dir}/hb_dtb_tool $deb_dst_dir/usr/bin" 314 | cp -a ${hb_dtb_tool_dir}/hb_dtb_tool $deb_dst_dir/usr/bin 315 | fi 316 | 317 | echo "cp -af ${hb_dtb_tool_dir}/*pi-config $deb_dst_dir/usr/bin" 318 | cp -af ${hb_dtb_tool_dir}/*pi-config $deb_dst_dir/usr/bin 319 | 320 | if [ -d ${debian_src_dir}/${pkg_name}/hb_gpio_py/hobot-gpio ];then 321 | echo "cp -arf ${debian_src_dir}/${pkg_name}/hb_gpio_py/hobot-gpio $deb_dst_dir/usr/lib/" 322 | mkdir -p $deb_dst_dir/usr/lib/ 323 | cp -arf ${debian_src_dir}/${pkg_name}/hb_gpio_py/hobot-gpio $deb_dst_dir/usr/lib/ 324 | fi 325 | 326 | is_allowed=1 327 | ;; 328 | hobot-io-samples) 329 | pkg_description="Example of Peripheral Interface" 330 | 331 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 332 | 333 | # set Depends 334 | sed -i 's/Depends: .*$/Depends: hobot-io/' ${deb_dst_dir}/DEBIAN/control 335 | 336 | is_allowed=1 337 | ;; 338 | hobot-multimedia) 339 | pkg_description="Multimedia Support Package" 340 | 341 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 342 | 343 | # set Depends 344 | sed -i 's/Depends: .*$/Depends: hobot-boot/' ${deb_dst_dir}/DEBIAN/control 345 | 346 | cp -ar ${debian_src_dir}/${pkg_name}/usr "$deb_dst_dir/" 347 | cp -ar ${debian_src_dir}/${pkg_name}/etc "$deb_dst_dir/" 348 | 349 | is_allowed=1 350 | ;; 351 | hobot-multimedia-dev) 352 | pkg_description="Multimedia Development Support Package" 353 | 354 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 355 | 356 | # set Depends 357 | sed -i 's/Depends: .*$/Depends: hobot-multimedia,hobot-camera/' ${deb_dst_dir}/DEBIAN/control 358 | 359 | cp -ar ${debian_src_dir}/${pkg_name}/usr "$deb_dst_dir/" 360 | 361 | is_allowed=1 362 | ;; 363 | hobot-camera) 364 | pkg_description="Camera Sensor Support Package" 365 | 366 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 367 | 368 | # set Depends 369 | sed -i 's/Depends: .*$/Depends: hobot-boot/' ${deb_dst_dir}/DEBIAN/control 370 | 371 | cd ${debian_src_dir}/${pkg_name}/drivers 372 | make || { 373 | echo "make failed" 374 | exit 1 375 | } 376 | 377 | mkdir -p $deb_dst_dir/usr/lib/sensorlib 378 | cp -a ${debian_src_dir}/${pkg_name}/drivers/*.so $deb_dst_dir/usr/lib/sensorlib 379 | 380 | find ${debian_src_dir}/${pkg_name}/camera_configs -name "*.so" -exec cp {} $deb_dst_dir/usr/lib/sensorlib/ \; 381 | 382 | mkdir -p $deb_dst_dir/app/ 383 | cp -ar ${debian_src_dir}/${pkg_name}/camera_configs $deb_dst_dir/app/ 384 | 385 | mkdir -p "$deb_dst_dir/usr/bin/" 386 | cp ${debian_src_dir}/${pkg_name}/camera_configs/common/initweb.sh "$deb_dst_dir/usr/bin/" 387 | is_allowed=1 388 | ;; 389 | hobot-dnn) 390 | pkg_description="BPU Runtime Support Package" 391 | 392 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 393 | 394 | # set Depends 395 | sed -i 's/Depends: .*$/Depends: hobot-boot/' ${deb_dst_dir}/DEBIAN/control 396 | 397 | cp -ar ${debian_src_dir}/${pkg_name}/usr "$deb_dst_dir/" 398 | 399 | is_allowed=1 400 | ;; 401 | hobot-spdev) 402 | pkg_description="Python and C/C++ Development Interface" 403 | 404 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 405 | 406 | # set Depends 407 | sed -i 's/Depends: .*$/Depends: hobot-multimedia,hobot-camera,hobot-dnn/' ${deb_dst_dir}/DEBIAN/control 408 | 409 | cd ${debian_src_dir}/${pkg_name} 410 | 411 | ./build.sh || { 412 | echo "build.sh failed" 413 | exit 1 414 | } 415 | 416 | mkdir -p $deb_dst_dir/usr/lib 417 | cp -arf ${debian_src_dir}/${pkg_name}/output/*.so $deb_dst_dir/usr/lib/ 418 | mkdir -p $deb_dst_dir/usr/include 419 | cp -arf ${debian_src_dir}/${pkg_name}/output/include/*.h $deb_dst_dir/usr/include/ 420 | mkdir -p $deb_dst_dir/usr/lib/hobot_spdev/ 421 | cp -arf ${debian_src_dir}/${pkg_name}/output/*.whl $deb_dst_dir/usr/lib/hobot_spdev/ 422 | is_allowed=1 423 | ;; 424 | hobot-sp-samples) 425 | pkg_description="Example of Python and C/C++ Development Interface" 426 | 427 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 428 | 429 | # set Depends 430 | sed -i 's/Depends: .*$/Depends: hobot-spdev,hobot-models-basic/' ${deb_dst_dir}/DEBIAN/control 431 | 432 | is_allowed=1 433 | ;; 434 | hobot-multimedia-samples) 435 | pkg_description="Example of Multimedia (Hapi)" 436 | 437 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 438 | 439 | # set Depends 440 | sed -i 's/Depends: .*$/Depends: hobot-multimedia-dev,hobot-multimedia/' ${deb_dst_dir}/DEBIAN/control 441 | 442 | is_allowed=1 443 | ;; 444 | hobot-audio-config) 445 | pkg_description="Configuration files and dtbo files of audio hat" 446 | 447 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 448 | 449 | # set Depends 450 | sed -i 's/Depends: .*$/Depends: hobot-boot,hobot-dtb/' ${deb_dst_dir}/DEBIAN/control 451 | cd ${debian_src_dir}/${pkg_name}/debian/boot/overlays 452 | 453 | make || { 454 | echo "make failed" 455 | exit 1 456 | } 457 | cd ${debian_src_dir}/${pkg_name}/audio_gadget 458 | make || { 459 | echo "make failed" 460 | exit 1 461 | } 462 | mkdir $deb_dst_dir/usr/bin -p 463 | cp -arf ${debian_src_dir}/${pkg_name}/audio_gadget/audio_gadget $deb_dst_dir/usr/bin 464 | 465 | mkdir -p $deb_dst_dir/boot/overlays 466 | cp -arf ${debian_src_dir}/${pkg_name}/debian/boot/overlays/*.dtbo $deb_dst_dir/boot/overlays 467 | rm $deb_dst_dir/boot/overlays/Makefile 468 | is_allowed=1 469 | ;; 470 | hobot-miniboot) 471 | pkg_description="RDK Miniboot updater" 472 | 473 | gen_contrl_file "${deb_dst_dir}/DEBIAN" "${pkg_name}" "${pkg_version}" "${pkg_description}" 474 | 475 | # set Depends 476 | sed -i 's/Depends: .*$/Depends: /' ${deb_dst_dir}/DEBIAN/control 477 | 478 | is_allowed=1 479 | ;; 480 | *) 481 | echo "Error: Make package ${pkg_name}-${pkg_version} failed" 482 | is_allowed=0 483 | ;; 484 | esac 485 | if [ $is_allowed == 1 ];then 486 | gen_changelog 487 | gen_copyright 488 | gen_md5sum 489 | calc_installed_size 490 | echo "#################### control ####################" 491 | cat ${deb_dst_dir}/DEBIAN/control 492 | echo "#################################################" 493 | fakeroot dpkg -b ${deb_dst_dir} ${deb_dst_dir}.deb 494 | fi 495 | } 496 | 497 | deb_pkg_list=( 498 | "hobot-boot" 499 | "hobot-kernel-headers" 500 | "hobot-dtb" 501 | "hobot-bpu-drivers" 502 | "hobot-configs" 503 | "hobot-utils" 504 | "hobot-display" 505 | "hobot-wifi" 506 | "hobot-io" 507 | "hobot-io-samples" 508 | "hobot-multimedia" 509 | "hobot-multimedia-dev" 510 | "hobot-camera" 511 | "hobot-dnn" 512 | "hobot-spdev" 513 | "hobot-sp-samples" 514 | "hobot-multimedia-samples" 515 | "hobot-miniboot" 516 | "hobot-audio-config" 517 | ) 518 | 519 | function help_msg 520 | { 521 | echo "./mk_deb.sh [all] | [deb_name]" 522 | for pkg_name in ""${deb_pkg_list[@]}""; do 523 | echo " ${pkg_name}" 524 | done 525 | } 526 | 527 | 528 | if [ $# -eq 0 ];then 529 | # clear all 530 | rm -rf $debian_dst_dir 531 | mkdir -p $debian_dst_dir 532 | # make all 533 | for pkg_name in "${deb_pkg_list[@]}"; do 534 | echo "Make package ${pkg_name}" 535 | make_debian_deb ${pkg_name} 536 | done 537 | elif [ $# -eq 1 ];then 538 | key_name=${1} 539 | found=false 540 | for pkg_name in "${deb_pkg_list[@]}"; do 541 | if [[ "${pkg_name}" == "${key_name}" ]]; then 542 | found=true 543 | mkdir -p $debian_dst_dir 544 | echo "Make package ${pkg_name}" 545 | make_debian_deb ${pkg_name} 546 | break 547 | fi 548 | done 549 | 550 | if ! $found; then 551 | echo "The debian package named by '${key_name}' is not supported, please check the input parameters." 552 | help_msg 553 | fi 554 | else 555 | help_msg 556 | exit 1 557 | fi 558 | -------------------------------------------------------------------------------- /mk_kernel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### 3 | # COPYRIGHT NOTICE 4 | # Copyright 2023 Horizon Robotics, Inc. 5 | # All rights reserved. 6 | # @Date: 2023-03-16 15:02:28 7 | # @LastEditTime: 2023-03-22 18:52:51 8 | ### 9 | 10 | set -e 11 | 12 | export CROSS_COMPILE=/opt/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu- 13 | export LD_LIBRARY_PATH=/opt/gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu/lib64:$LD_LIBRARY_PATH 14 | export ARCH=arm64 15 | export HR_TOP_DIR=$(realpath $(cd $(dirname $0); pwd)) 16 | export HR_LOCAL_DIR=$(realpath $(cd $(dirname $0); pwd)) 17 | 18 | 19 | # 编译出来的镜像保存位置 20 | export IMAGE_DEPLOY_DIR=${HR_TOP_DIR}/deploy 21 | [ -n "${IMAGE_DEPLOY_DIR}" ] && [ ! -d "$IMAGE_DEPLOY_DIR" ] && mkdir "$IMAGE_DEPLOY_DIR" 22 | 23 | KERNEL_BUILD_DIR=${IMAGE_DEPLOY_DIR}/kernel 24 | [ -n "${IMAGE_DEPLOY_DIR}" ] && [ ! -d ""${KERNEL_BUILD_DIR}"" ] && mkdir "$KERNEL_BUILD_DIR" 25 | 26 | N=$(($(grep -c 'processor' /proc/cpuinfo) - 2 )) 27 | 28 | # 默认使用emmc配置,对于nor、nand需要使用另外的配置文件 29 | kernel_config_file=xj3_perf_ubuntu_defconfig 30 | kernel_image_name="Image.lz4" 31 | 32 | KERNEL_SRC_DIR=${HR_TOP_DIR}/source/kernel 33 | 34 | kernel_version=$(awk "/^VERSION =/{print \$3}" "${KERNEL_SRC_DIR}"/Makefile) 35 | kernel_patch_lvl=$(awk "/^PATCHLEVEL =/{print \$3}" "${KERNEL_SRC_DIR}"/Makefile) 36 | kernel_sublevel=$(awk "/^SUBLEVEL =/{print \$3}" "${KERNEL_SRC_DIR}"/Makefile) 37 | export KERNEL_VER="${kernel_version}.${kernel_patch_lvl}.${kernel_sublevel}" 38 | 39 | function pre_pkg_preinst() { 40 | # Get the signature algorithm used by the kernel. 41 | module_sig_hash="$(grep -Po '(?<=CONFIG_MODULE_SIG_HASH=").*(?=")' "${KERNEL_SRC_DIR}/.config")" 42 | # Get the key file used by the kernel. 43 | module_sig_key="$(grep -Po '(?<=CONFIG_MODULE_SIG_KEY=").*(?=")' "${KERNEL_SRC_DIR}/.config")" 44 | module_sig_key="${module_sig_key:-certs/hobot_fixed_signing_key.pem}" 45 | # Path to the key file or PKCS11 URI 46 | if [[ "${module_sig_key#pkcs11:}" == "${module_sig_key}" && "${module_sig_key#/}" == "${module_sig_key}" ]]; then 47 | local key_path="${KERNEL_SRC_DIR}/${module_sig_key}" 48 | else 49 | local key_path="${module_sig_key}" 50 | fi 51 | # Certificate path 52 | local cert_path="${KERNEL_SRC_DIR}/certs/signing_key.x509" 53 | # Sign all installed modules before merging. 54 | find "${KO_INSTALL_DIR}"/lib/modules/"${KERNEL_VER}"/ -name "*.ko" -exec "${KERNEL_SRC_DIR}/scripts/sign-file" "${module_sig_hash}" "${key_path}" "${cert_path}" '{}' \; 55 | } 56 | 57 | function make_kernel_headers() { 58 | SRCDIR=${KERNEL_SRC_DIR} 59 | HDRDIR="${KERNEL_BUILD_DIR}"/kernel_headers/usr/src/linux-headers-4.14.87 60 | mkdir -p "${HDRDIR}" 61 | 62 | cd "${SRCDIR}" 63 | 64 | mkdir -p "${HDRDIR}"/arch 65 | cp -Rf "${SRCDIR}"/arch/arm64 "${HDRDIR}"/arch/ 66 | cp -Rf "${SRCDIR}"/include "${HDRDIR}" 67 | cp -Rf "${SRCDIR}"/scripts "${HDRDIR}" 68 | cp -Rf "${SRCDIR}"/Module.symvers "${HDRDIR}" 69 | cp -Rf "${SRCDIR}"/Makefile "${HDRDIR}" 70 | cp -Rf "${SRCDIR}"/System.map "${HDRDIR}" 71 | cp -Rf "${SRCDIR}"/.config "${HDRDIR}" 72 | cp -Rf "${SRCDIR}"/security "${HDRDIR}" 73 | cp -Rf "${SRCDIR}"/tools "${HDRDIR}" 74 | cp -Rf "${SRCDIR}"/certs "${HDRDIR}" 75 | 76 | rm -rf "${HDRDIR}"/arch/arm64/boot 77 | 78 | cd "${SRCDIR}" 79 | find . -iname "KConfig*" -print0 | while IFS= read -r -d '' file; do 80 | cp --parents -Rf "$file" "${HDRDIR}" 81 | done 82 | 83 | find . -iname "Makefile*" -print0 | while IFS= read -r -d '' file; do 84 | cp --parents -Rf "$file" "${HDRDIR}" 85 | done 86 | 87 | find . -iname "*.pl" -print0 | while IFS= read -r -d '' file; do 88 | cp --parents -Rf "$file" "${HDRDIR}" 89 | done 90 | cd "${HR_LOCAL_DIR}" 91 | 92 | find "${HDRDIR}" -depth -name '.svn' -type d -exec rm -rf {} \; 93 | 94 | find "${HDRDIR}" -depth -name '*.c' -type f -exec rm -rf {} \; 95 | 96 | exclude=("*.c" \ 97 | "*.o" \ 98 | "*.S" \ 99 | "*.s" \ 100 | "*.ko" \ 101 | "*.cmd" \ 102 | "*.a" \ 103 | "modules.builtin" \ 104 | "modules.order") 105 | for element in "${exclude[@]}" 106 | do 107 | find "${HDRDIR}" -depth -name "${element}" -type f -exec rm -rf {} \; 108 | done 109 | 110 | cd "${SRCDIR}" 111 | find . -iname "*.c" -print0 | while IFS= read -r -d '' file; do 112 | cp --parents -Rf "$file" "${HDRDIR}" 113 | done 114 | make M="${HDRDIR}"/scripts clean 115 | 116 | cd "${HR_LOCAL_DIR}" 117 | rm -rf "${HDRDIR}"/arch/arm64/mach* 118 | rm -rf "${HDRDIR}"/arch/arm64/plat* 119 | 120 | mv "${HDRDIR}"/include/asm-generic/ "${HDRDIR}"/ 121 | rm -rf "${HDRDIR}"/inclde/asm-* 122 | mv "${HDRDIR}"/asm-generic "${HDRDIR}"/include/ 123 | 124 | rm -rf "${HDRDIR}"/arch/arm64/configs 125 | 126 | rm -rf "${HDRDIR}"/debian 127 | } 128 | 129 | function build_all() 130 | { 131 | # 生成内核配置.config 132 | make $kernel_config_file || { 133 | echo "make $config failed" 134 | exit 1 135 | } 136 | 137 | # 编译生成 zImage.lz4 和 dtb.img 138 | make ${kernel_image_name} dtbs -j${N} || { 139 | echo "make ${kernel_image_name} failed" 140 | exit 1 141 | } 142 | 143 | # 编译内核模块 144 | make modules -j${N} || { 145 | echo "make modules failed" 146 | exit 1 147 | } 148 | 149 | # 安装内核模块 150 | KO_INSTALL_DIR="${KERNEL_BUILD_DIR}"/modules 151 | [ ! -d "${KO_INSTALL_DIR}" ] && mkdir -p "${KO_INSTALL_DIR}" 152 | rm -rf "${KO_INSTALL_DIR:?}"/* 153 | 154 | make INSTALL_MOD_PATH="${KO_INSTALL_DIR}" INSTALL_MOD_STRIP=1 modules_install -j${N} || { 155 | echo "make modules_install to INSTALL_MOD_PATH for release ko failed" 156 | exit 1 157 | } 158 | 159 | # strip 内核模块, 去掉debug info 160 | # ${CROSS_COMPILE}strip -g ${KO_INSTALL_DIR}/lib/modules/${KERNEL_VER}/*.ko 161 | find "${KO_INSTALL_DIR}"/lib/modules/"${KERNEL_VER}"/ -name "*.ko" -exec ${CROSS_COMPILE}strip -g '{}' \; 162 | 163 | rm -rf "${KO_INSTALL_DIR}"/lib/modules/"${KERNEL_VER}"/{build,source} 164 | 165 | # ko 签名 166 | pre_pkg_preinst 167 | 168 | # 拷贝 内核 zImage.lz4 169 | cp -f "arch/arm64/boot/${kernel_image_name}" "${KERNEL_BUILD_DIR}"/ 170 | # 拷贝 内核 Image 171 | cp -f "arch/arm64/boot/Image" "${KERNEL_BUILD_DIR}"/ 172 | 173 | # 生成 dtb 镜像 174 | mkdir -p "${KERNEL_BUILD_DIR}"/dtb 175 | cp -arf arch/arm64/boot/dts/hobot/*.dtb "${KERNEL_BUILD_DIR}"/dtb 176 | cp -arf arch/arm64/boot/dts/hobot/*.dts "${KERNEL_BUILD_DIR}"/dtb 177 | cp -arf arch/arm64/boot/dts/hobot/*.dtsi "${KERNEL_BUILD_DIR}"/dtb 178 | 179 | path=./tools/dtbmapping 180 | 181 | cd $path 182 | 183 | export TARGET_KERNEL_DIR="${KERNEL_BUILD_DIR}"/dtb 184 | # build dtb 185 | python2 makeimg.py || { 186 | echo "make failed" 187 | exit 1 188 | } 189 | 190 | # 生成内核头文件 191 | make_kernel_headers 192 | } 193 | 194 | function build_clean() 195 | { 196 | make clean 197 | } 198 | 199 | function build_distclean() 200 | { 201 | make distclean 202 | } 203 | 204 | # 进入内核目录 205 | cd "${KERNEL_SRC_DIR}" 206 | # 根据命令参数编译 207 | if [ $# -eq 0 ] || [ "$1" = "all" ]; then 208 | build_all 209 | elif [ "$1" = "clean" ]; then 210 | build_clean 211 | elif [ "$1" = "distclean" ]; then 212 | build_distclean 213 | fi 214 | -------------------------------------------------------------------------------- /pack_image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### 3 | # COPYRIGHT NOTICE 4 | # Copyright 2023 Horizon Robotics, Inc. 5 | # All rights reserved. 6 | # @Date: 2023-04-15 00:47:08 7 | # @LastEditTime: 2023-05-23 16:56:41 8 | ### 9 | 10 | set -e 11 | 12 | export HR_LOCAL_DIR=$(realpath $(cd $(dirname $0); pwd)) 13 | 14 | this_user="$(whoami)" 15 | if [ "${this_user}" != "root" ]; then 16 | echo "[ERROR]: This script requires root privileges. Please execute it with sudo." 17 | exit 1 18 | fi 19 | 20 | 21 | # 编译出来的镜像保存位置 22 | export IMAGE_DEPLOY_DIR=${HR_LOCAL_DIR}/deploy 23 | [ ! -z ${IMAGE_DEPLOY_DIR} ] && [ ! -d $IMAGE_DEPLOY_DIR ] && mkdir $IMAGE_DEPLOY_DIR 24 | 25 | IMG_FILE="${IMAGE_DEPLOY_DIR}/ubuntu-preinstalled-desktop-arm64.img" 26 | ROOTFS_ORIG_DIR=${HR_LOCAL_DIR}/rootfs 27 | ROOTFS_BUILD_DIR=${IMAGE_DEPLOY_DIR}/rootfs 28 | 29 | if [[ $# -ge 1 && "$1" = "server" ]]; then 30 | IMG_FILE="${IMAGE_DEPLOY_DIR}/ubuntu-preinstalled-server-arm64.img" 31 | ROOTFS_ORIG_DIR=${HR_LOCAL_DIR}/rootfs_server 32 | ROOTFS_BUILD_DIR=${IMAGE_DEPLOY_DIR}/rootfs_server 33 | fi 34 | 35 | rm -rf ${ROOTFS_BUILD_DIR} 36 | [ ! -d $ROOTFS_BUILD_DIR ] && mkdir ${ROOTFS_BUILD_DIR} 37 | 38 | 39 | function install_deb_chroot() 40 | { 41 | local package=$1 42 | local dst_dir=$2 43 | 44 | cd "${dst_dir}/app/hobot_debs" 45 | echo "###### Installing" "${package} ######" 46 | depends=$(dpkg-deb -f "${package}" Depends | sed 's/([^()]*)//g') 47 | if [ -f ${package} ];then 48 | chroot "${dst_dir}" /bin/bash -c "dpkg --ignore-depends=${depends// /} -i /app/hobot_debs/${package}" 49 | fi 50 | echo "###### Installed" "${package} ######" 51 | } 52 | 53 | function install_packages() 54 | { 55 | local dst_dir=$1 56 | if [ ! -d ${dst_dir} ]; then 57 | echo "dst_dir is not exist!" "${dst_dir}" 58 | exit -1 59 | fi 60 | 61 | echo "Start install hobot packages" 62 | 63 | cd "${dst_dir}/app/hobot_debs" 64 | deb_list=$(ls) 65 | 66 | for deb_name in ${deb_list[@]} 67 | do 68 | install_deb_chroot "${deb_name}" "${dst_dir}" 69 | done 70 | 71 | chroot ${dst_dir} /bin/bash -c "apt clean" 72 | echo "Install hobot packages is finished" 73 | } 74 | 75 | function unmount(){ 76 | if [ -z "$1" ]; then 77 | DIR=$PWD 78 | else 79 | DIR=$1 80 | fi 81 | 82 | while mount | grep -q "$DIR"; do 83 | local LOCS 84 | LOCS=$(mount | grep "$DIR" | cut -f 3 -d ' ' | sort -r) 85 | for loc in $LOCS; do 86 | umount "$loc" 87 | done 88 | done 89 | } 90 | 91 | function unmount_image(){ 92 | sync 93 | sleep 1 94 | LOOP_DEVICE=$(losetup --list | grep "$1" | cut -f1 -d' ') 95 | if [ -n "$LOOP_DEVICE" ]; then 96 | for part in "$LOOP_DEVICE"p*; do 97 | if DIR=$(findmnt -n -o target -S "$part"); then 98 | unmount "$DIR" 99 | fi 100 | done 101 | losetup -d "$LOOP_DEVICE" 102 | fi 103 | } 104 | 105 | # 制作 ubuntu 根文件系统镜像 106 | function make_ubuntu_image() 107 | { 108 | # ubuntu 系统直接解压制作image 109 | echo "tar -xzf ${ROOTFS_ORIG_DIR}/samplefs*.tar.gz -C ${ROOTFS_BUILD_DIR}" 110 | tar --same-owner --numeric-owner -xzpf ${ROOTFS_ORIG_DIR}/samplefs*.tar.gz -C ${ROOTFS_BUILD_DIR} 111 | mkdir -p ${ROOTFS_BUILD_DIR}/{home,home/root,mnt,root,usr/lib,var,media,tftpboot,var/lib,var/volatile,dev,proc,tmp,run,sys,userdata,app,boot/hobot,boot/config} 112 | cat "${HR_LOCAL_DIR}/VERSION" > ${ROOTFS_BUILD_DIR}/etc/version 113 | 114 | # Custom Special Modifications 115 | echo "Custom Special Modifications" 116 | source hobot_customize_rootfs.sh 117 | hobot_customize_rootfs ${ROOTFS_BUILD_DIR} 118 | 119 | # install debs 120 | echo "Install hobot debs in /app/hobot_debs" 121 | mkdir -p ${ROOTFS_BUILD_DIR}/app/hobot_debs 122 | [ -d "${HR_LOCAL_DIR}/deb_packages" ] && find "${HR_LOCAL_DIR}/deb_packages" -maxdepth 1 -type f -name '*.deb' -exec cp -f {} "${ROOTFS_BUILD_DIR}/app/hobot_debs" \; 123 | [ -d "${HR_LOCAL_DIR}/third_packages" ] && find "${HR_LOCAL_DIR}/third_packages" -maxdepth 1 -type f -name '*.deb' -exec cp -f {} "${ROOTFS_BUILD_DIR}/app/hobot_debs" \; 124 | # merge deploy deb packages to rootfs, they are customer packages 125 | [ -d "${HR_LOCAL_DIR}/deploy/deb_pkgs" ] && find "${HR_LOCAL_DIR}/deploy/deb_pkgs" -maxdepth 1 -type f -name '*.deb' -exec cp -f {} "${ROOTFS_BUILD_DIR}/app/hobot_debs" \; 126 | # delete same deb packages, keep the latest version 127 | cd "${ROOTFS_BUILD_DIR}/app/hobot_debs" 128 | deb_list=$(ls -1 *.deb | sort) 129 | for file in ${deb_list[@]}; do 130 | # Extract package name and version 131 | package=$(echo $file | awk -F"_" '{print $1}') 132 | version=$(echo $file | awk -F"_" '{print $2}') 133 | 134 | # If the current package name is different from the previous one, keep the current file (latest version) 135 | if [ "$package" != "$previous_package" ]; then 136 | previous_file="$file" 137 | previous_package="$package" 138 | previous_version="$version" 139 | else 140 | # If the current package name is the same as the previous one, compare versions and delete older version files 141 | if dpkg --compare-versions "$version" gt "$previous_version"; then 142 | # Current version is newer, delete previous version files 143 | rm "${previous_file}" 144 | previous_file="$file" 145 | previous_version="$version" 146 | else 147 | # Previous version is newer, delete the current version file 148 | rm "$file" 149 | fi 150 | fi 151 | done 152 | 153 | install_packages ${ROOTFS_BUILD_DIR} 154 | rm ${ROOTFS_BUILD_DIR}/app/hobot_debs/ -rf 155 | rm -rf ${ROOTFS_BUILD_DIR}/lib/aarch64-linux-gnu/dri/ 156 | 157 | unmount_image "${IMG_FILE}" 158 | rm -f "${IMG_FILE}" 159 | 160 | ROOTFS_DIR=${IMAGE_DEPLOY_DIR}/rootfs_mount 161 | rm -rf "${ROOTFS_DIR}" 162 | mkdir -p "${ROOTFS_DIR}" 163 | 164 | CONFIG_SIZE="$((256 * 1024 * 1024))" 165 | ROOT_SIZE=$(du --apparent-size -s "${ROOTFS_BUILD_DIR}" --exclude var/cache/apt/archives --exclude boot/config --block-size=1 | cut -f 1) 166 | # All partition sizes and starts will be aligned to this size 167 | ALIGN="$((4 * 1024 * 1024))" 168 | # Add this much space to the calculated file size. This allows for 169 | # some overhead (since actual space usage is usually rounded up to the 170 | # filesystem block size) and gives some free space on the resulting 171 | # image. 172 | ROOT_MARGIN="$(echo "($ROOT_SIZE * 0.2 + 200 * 1024 * 1024) / 1" | bc)" 173 | 174 | CONFIG_PART_START=$((ALIGN)) 175 | CONFIG_PART_SIZE=$(((CONFIG_SIZE + ALIGN - 1) / ALIGN * ALIGN)) 176 | ROOT_PART_START=$((CONFIG_PART_START + CONFIG_PART_SIZE)) 177 | ROOT_PART_SIZE=$(((ROOT_SIZE + ROOT_MARGIN + ALIGN - 1) / ALIGN * ALIGN)) 178 | IMG_SIZE=$((CONFIG_PART_START + CONFIG_PART_SIZE + ROOT_PART_SIZE)) 179 | 180 | truncate -s "${IMG_SIZE}" "${IMG_FILE}" 181 | 182 | cd "${HR_LOCAL_DIR}" 183 | parted --script "${IMG_FILE}" mklabel msdos 184 | parted --script "${IMG_FILE}" unit B mkpart primary fat32 "${CONFIG_PART_START}" "$((CONFIG_PART_START + CONFIG_PART_SIZE - 1))" 185 | parted --script "${IMG_FILE}" unit B mkpart primary ext4 "${ROOT_PART_START}" "$((ROOT_PART_START + ROOT_PART_SIZE - 1))" 186 | # 设置为启动分区 187 | parted "${IMG_FILE}" set 2 boot on 188 | 189 | echo "Creating loop device..." 190 | cnt=0 191 | until LOOP_DEV="$(losetup --show --find --partscan "$IMG_FILE")"; do 192 | if [ $cnt -lt 5 ]; then 193 | cnt=$((cnt + 1)) 194 | echo "Error in losetup. Retrying..." 195 | sleep 5 196 | else 197 | echo "ERROR: losetup failed; exiting" 198 | exit 1 199 | fi 200 | done 201 | 202 | CONFIG_DEV="${LOOP_DEV}p1" 203 | ROOT_DEV="${LOOP_DEV}p2" 204 | 205 | ROOT_FEATURES="^huge_file" 206 | for FEATURE in 64bit; do 207 | if grep -q "$FEATURE" /etc/mke2fs.conf; then 208 | ROOT_FEATURES="^$FEATURE,$ROOT_FEATURES" 209 | fi 210 | done 211 | mkdosfs -n CONFIG -F 32 -s 4 -v "$CONFIG_DEV" > /dev/null 212 | mkfs.ext4 -L rootfs -O "$ROOT_FEATURES" "$ROOT_DEV" > /dev/null 213 | 214 | mount -v "$ROOT_DEV" "${ROOTFS_DIR}" -t ext4 215 | mkdir -p "${ROOTFS_DIR}/boot/config" 216 | mount -v "$CONFIG_DEV" "${ROOTFS_DIR}/boot/config" -t vfat 217 | 218 | cd "${HR_LOCAL_DIR}" 219 | rsync -aHAXx --exclude /var/cache/apt/archives --exclude /boot/config "${ROOTFS_BUILD_DIR}/" "${ROOTFS_DIR}/" 220 | rsync -rtx "${HR_LOCAL_DIR}/config/" "${ROOTFS_DIR}/boot/config" 221 | sync 222 | unmount_image "${IMG_FILE}" 223 | rm -rf "${ROOTFS_DIR}" 224 | 225 | md5sum "${IMG_FILE}" > ${IMG_FILE}.md5sum 226 | 227 | echo "Make Ubuntu Image successfully" 228 | 229 | exit 0 230 | } 231 | 232 | if [[ $# -eq 0 || ( $# -eq 1 && "$1" = "server" ) ]]; then 233 | if [[ $# -eq 1 && "$1" = "server" ]]; then 234 | ${HR_LOCAL_DIR}/download_samplefs.sh ${ROOTFS_ORIG_DIR} "-u" "jammy" "-t" "server" 235 | else 236 | ${HR_LOCAL_DIR}/download_samplefs.sh ${ROOTFS_ORIG_DIR} "-u" "jammy" 237 | fi 238 | ${HR_LOCAL_DIR}/download_deb_pkgs.sh ${HR_LOCAL_DIR}/deb_packages "-u" "jammy" 239 | fi 240 | 241 | make_ubuntu_image 242 | 243 | -------------------------------------------------------------------------------- /samplefs/.gitignore: -------------------------------------------------------------------------------- 1 | desktop 2 | server 3 | base 4 | 5 | -------------------------------------------------------------------------------- /samplefs/focal/ubuntu-base-arm64-packages: -------------------------------------------------------------------------------- 1 | alsa-utils 2 | base-files 3 | base-passwd 4 | bison 5 | bluetooth 6 | bluez 7 | build-essential 8 | busybox 9 | bzip2 10 | cifs-utils 11 | console-setup 12 | cpio 13 | crda 14 | cryptsetup 15 | device-tree-compiler 16 | diffutils 17 | dos2unix 18 | dosfstools 19 | e2fsprogs 20 | ethtool 21 | ffmpeg 22 | flex 23 | fonts-wqy-microhei 24 | i2c-tools 25 | ifupdown 26 | iperf3 27 | iputils-ping 28 | isc-dhcp-client 29 | iw 30 | language-pack-gnome-zh-hans 31 | libaio1 32 | libasio-dev 33 | libasound2 34 | libasound2-dev 35 | libattr1 36 | libavcodec58 37 | libavcodec-dev 38 | libavdevice58 39 | libavfilter7 40 | libavformat58 41 | libavformat-dev 42 | libavutil56 43 | libavutil-dev 44 | libblkid1 45 | libboost-date-time-dev 46 | libboost-dev 47 | libboost-thread-dev 48 | libbullet-dev 49 | libc6 50 | libc6-dev 51 | libcap2 52 | libcjson1 53 | libcjson-dev 54 | libcom-err2 55 | libcrypt1 56 | libcrypt-dev 57 | libcrypto++6 58 | libcrypto++-dev 59 | libcurl4-openssl-dev 60 | libdbus-1-3 61 | libdevmapper1.02.1 62 | libedit2 63 | libexpat1 64 | libext2fs2 65 | libflac8 66 | libgcc1 67 | libgcc-s1-arm64-cross 68 | libgcrypt20 69 | libgdbm6 70 | libgdbm-compat4 71 | libgl1-mesa-glx 72 | libgmp10 73 | libgnutls30 74 | libgpg-error0 75 | libidn2-0 76 | libion0 77 | libjson-c4 78 | libjsoncpp1 79 | libjsoncpp-dev 80 | libkcapi1 81 | libkmod2 82 | liblog4cxx-dev 83 | liblzo2-2 84 | libmenu-cache3 85 | libmount1 86 | libncurses5 87 | libncursesw5 88 | libnl-3-200 89 | libnl-genl-3-200 90 | libnss-db 91 | libogg0 92 | libpcap0.8 93 | libpcre3 94 | libperl-dev 95 | libpopt0 96 | libpostproc55 97 | libreadline8 98 | libsamplerate0 99 | libsndfile1 100 | libsqlite3-dev 101 | libss2 102 | libssl1.1 103 | libssl-dev 104 | libstdc++-10-dev 105 | libstdc++6 106 | libswresample3 107 | libswresample-dev 108 | libswscale5 109 | libtinfo5 110 | libtinyxml2-dev 111 | libtirpc3 112 | libturbojpeg 113 | libturbojpeg0-dev 114 | libudev1 115 | libunistring2 116 | libunwind8 117 | libusb-1.0-0 118 | libuuid1 119 | libvorbis0a 120 | libwhoopsie0 121 | libwhoopsie-preferences0 122 | libwrap0 123 | libx11-6 124 | libxau6 125 | libxcb1 126 | libxdmcp6 127 | libxext6 128 | libxv1 129 | libz1 130 | libz-dev 131 | libzmq3-dev 132 | libzmq5 133 | mtd-utils 134 | ncurses-base 135 | ncurses-term 136 | netbase 137 | netplan.io 138 | net-tools 139 | network-manager 140 | nfs-common 141 | openssh-server 142 | openssh-sftp-server 143 | openssl 144 | parted 145 | perl 146 | perl-base 147 | psmisc 148 | python-is-python3 149 | python3 150 | python3-click 151 | python3-colorama 152 | python3-dev 153 | python3-pip 154 | rpcbind 155 | rsync 156 | rsyslog 157 | screen 158 | sed 159 | sqlite3 160 | ssh 161 | strace 162 | symlinks 163 | sysfsutils 164 | sysstat 165 | tcpdump 166 | tftpd-hpa 167 | tftp-hpa 168 | toilet 169 | trace-cmd 170 | tzdata 171 | u-boot-tools 172 | ubuntu-advantage-tools 173 | udisks2 174 | usbutils 175 | uuid 176 | v4l-utils 177 | vim 178 | watchdog 179 | whiptail 180 | whoopsie 181 | whoopsie-preferences 182 | wireless-regdb 183 | wireless-tools 184 | wpasupplicant 185 | xfonts-intl-chinese 186 | -------------------------------------------------------------------------------- /samplefs/focal/ubuntu-desktop-arm64-packages: -------------------------------------------------------------------------------- 1 | blueman 2 | fcitx 3 | fcitx-config-gtk 4 | fcitx-frontend-gtk2 5 | fcitx-frontend-gtk3 6 | fcitx-frontend-qt5 7 | fcitx-module-cloudpinyin 8 | fcitx-pinyin 9 | fcitx-sunpinyin 10 | fcitx-table-wubi 11 | fcitx-ui-classic 12 | fcitx-ui-qimpanel 13 | firefox 14 | firefox-locale-zh-hans 15 | fonts-arphic-ukai 16 | fonts-arphic-uming 17 | fonts-noto-cjk 18 | fonts-noto-cjk-extra 19 | galculator 20 | geany 21 | ibus-libpinyin 22 | ibus-table-wubi 23 | libminizip1 24 | libvulkan1 25 | libxnvctrl0 26 | mousepad 27 | network-manager-gnome 28 | pavucontrol 29 | pulseaudio 30 | pulseaudio-module-bluetooth 31 | ristretto 32 | thonny 33 | tightvncserver 34 | x11vnc 35 | xarchiver 36 | xfce4-pulseaudio-plugin 37 | xfce4-taskmanager 38 | xfce4-terminal 39 | xserver-xorg-video-fbdev 40 | xubuntu-desktop 41 | -------------------------------------------------------------------------------- /samplefs/focal/ubuntu-server-arm64-packages: -------------------------------------------------------------------------------- 1 | aptitude 2 | apt-show-versions 3 | base-files 4 | base-passwd 5 | cmake 6 | curl 7 | file 8 | file 9 | g++ 10 | gcc 11 | gdb 12 | gdbserver 13 | git 14 | git-man 15 | hostapd 16 | htop 17 | iotop 18 | iptables 19 | joystick 20 | libatlas-base-dev 21 | libcairo2-dev 22 | libgflags-dev 23 | libgoogle-glog-dev 24 | liblua5.2-dev 25 | libluabind-dev 26 | libprotobuf-dev 27 | libsuitesparse-dev 28 | libtinyxml-dev 29 | lrzsz 30 | lsb-release 31 | lshw 32 | lsof 33 | lua5.2 34 | luajit 35 | make 36 | memstat 37 | nano 38 | ncdu 39 | nftables 40 | ntfs-3g 41 | protobuf-compiler 42 | python3-wstool 43 | rfkill 44 | samba-libs 45 | stow 46 | tasksel 47 | tree 48 | unzip 49 | vlc 50 | wget 51 | zstd 52 | -------------------------------------------------------------------------------- /samplefs/jammy/ubuntu-base-arm64-packages: -------------------------------------------------------------------------------- 1 | alsa-utils 2 | base-files 3 | base-passwd 4 | bison 5 | bluetooth 6 | bluez 7 | build-essential 8 | busybox 9 | bzip2 10 | cifs-utils 11 | console-setup 12 | cpio 13 | cryptsetup 14 | device-tree-compiler 15 | diffutils 16 | dos2unix 17 | dosfstools 18 | e2fsprogs 19 | ethtool 20 | ffmpeg 21 | flex 22 | fonts-wqy-microhei 23 | i2c-tools 24 | ifupdown 25 | iperf3 26 | iputils-ping 27 | isc-dhcp-client 28 | iw 29 | language-pack-gnome-zh-hans 30 | libaio1 31 | libasio-dev 32 | libasound2 33 | libasound2-dev 34 | libattr1 35 | libavcodec58 36 | libavcodec-dev 37 | libavdevice58 38 | libavfilter7 39 | libavformat58 40 | libavformat-dev 41 | libavutil56 42 | libavutil-dev 43 | libblkid1 44 | libboost-date-time-dev 45 | libboost-dev 46 | libboost-thread-dev 47 | libbullet-dev 48 | libc6 49 | libc6-dev 50 | libcap2 51 | libcjson1 52 | libcjson-dev 53 | libcom-err2 54 | libcrypt1 55 | libcrypt-dev 56 | libcrypto++8 57 | libcrypto++-dev 58 | libcurl4-openssl-dev 59 | libdbus-1-3 60 | libdevmapper1.02.1 61 | libedit2 62 | libexpat1 63 | libext2fs2 64 | libflac8 65 | libgcc1 66 | libgcc-s1-arm64-cross 67 | libgcrypt20 68 | libgdbm6 69 | libgdbm-compat4 70 | libgl1-mesa-glx 71 | libgmp10 72 | libgnutls30 73 | libgpg-error0 74 | libidn2-0 75 | libion0 76 | libjson-c5 77 | libjsoncpp-dev 78 | libkcapi1 79 | libkmod2 80 | liblog4cxx-dev 81 | liblzo2-2 82 | libmenu-cache3 83 | libmount1 84 | libncurses5 85 | libncursesw5 86 | libnl-3-200 87 | libnl-genl-3-200 88 | libnss-db 89 | libogg0 90 | libpcap0.8 91 | libpcre3 92 | libperl-dev 93 | libpopt0 94 | libpostproc55 95 | libreadline8 96 | libsamplerate0 97 | libsndfile1 98 | libsqlite3-dev 99 | libss2 100 | libssl-dev 101 | libstdc++-10-dev 102 | libstdc++6 103 | libswresample3 104 | libswresample-dev 105 | libswscale5 106 | libtinfo5 107 | libtinyxml2-dev 108 | libtirpc3 109 | libturbojpeg 110 | libturbojpeg0-dev 111 | libudev1 112 | libunistring2 113 | libunwind8 114 | libusb-1.0-0 115 | libuuid1 116 | libvorbis0a 117 | libwhoopsie0 118 | libwhoopsie-preferences0 119 | libwrap0 120 | libx11-6 121 | libxau6 122 | libxcb1 123 | libxdmcp6 124 | libxext6 125 | libxv1 126 | libz1 127 | libz-dev 128 | libzmq3-dev 129 | libzmq5 130 | mtd-utils 131 | ncurses-base 132 | ncurses-term 133 | netbase 134 | netplan.io 135 | net-tools 136 | network-manager 137 | nfs-common 138 | openssh-server 139 | openssh-sftp-server 140 | openssl 141 | parted 142 | perl 143 | perl-base 144 | psmisc 145 | python-is-python3 146 | python3 147 | python3-click 148 | python3-colorama 149 | python3-dev 150 | python3-pip 151 | rpcbind 152 | rsync 153 | rsyslog 154 | screen 155 | sed 156 | sqlite3 157 | ssh 158 | strace 159 | symlinks 160 | sysfsutils 161 | sysstat 162 | tcpdump 163 | tftpd-hpa 164 | tftp-hpa 165 | toilet 166 | trace-cmd 167 | tzdata 168 | u-boot-tools 169 | ubuntu-advantage-tools 170 | udisks2 171 | usbutils 172 | uuid 173 | v4l-utils 174 | vim 175 | watchdog 176 | whiptail 177 | whoopsie 178 | whoopsie-preferences 179 | wireless-regdb 180 | wireless-tools 181 | wpasupplicant 182 | xfonts-intl-chinese 183 | -------------------------------------------------------------------------------- /samplefs/jammy/ubuntu-desktop-arm64-packages: -------------------------------------------------------------------------------- 1 | blueman 2 | fcitx 3 | fcitx-config-gtk 4 | fcitx-frontend-gtk2 5 | fcitx-frontend-gtk3 6 | fcitx-frontend-qt5 7 | fcitx-module-cloudpinyin 8 | fcitx-pinyin 9 | fcitx-sunpinyin 10 | fcitx-table-wubi 11 | fcitx-ui-classic 12 | fcitx-ui-qimpanel 13 | firefox 14 | firefox-locale-zh-hans 15 | fonts-arphic-ukai 16 | fonts-arphic-uming 17 | fonts-noto-cjk 18 | fonts-noto-cjk-extra 19 | galculator 20 | geany 21 | ibus-libpinyin 22 | ibus-table-wubi 23 | libminizip1 24 | libvulkan1 25 | libxnvctrl0 26 | mousepad 27 | network-manager-gnome 28 | pavucontrol 29 | pulseaudio 30 | pulseaudio-module-bluetooth 31 | ristretto 32 | thonny 33 | tightvncserver 34 | x11vnc 35 | xarchiver 36 | xfce4-pulseaudio-plugin 37 | xfce4-taskmanager 38 | xfce4-terminal 39 | xserver-xorg-video-fbdev 40 | xubuntu-desktop 41 | -------------------------------------------------------------------------------- /samplefs/jammy/ubuntu-server-arm64-packages: -------------------------------------------------------------------------------- 1 | aptitude 2 | apt-show-versions 3 | base-files 4 | base-passwd 5 | cmake 6 | curl 7 | file 8 | file 9 | g++ 10 | gcc 11 | gdb 12 | gdbserver 13 | git 14 | git-man 15 | hostapd 16 | htop 17 | iotop 18 | iptables 19 | joystick 20 | libatlas-base-dev 21 | libcairo2-dev 22 | libgflags-dev 23 | libgoogle-glog-dev 24 | liblua5.2-dev 25 | libluabind-dev 26 | libprotobuf-dev 27 | libsuitesparse-dev 28 | libtinyxml-dev 29 | lrzsz 30 | lsb-release 31 | lshw 32 | lsof 33 | lua5.2 34 | luajit 35 | make 36 | memstat 37 | nano 38 | ncdu 39 | nftables 40 | ntfs-3g 41 | protobuf-compiler 42 | python3-wstool 43 | rfkill 44 | samba-libs 45 | stow 46 | tasksel 47 | tree 48 | unzip 49 | vlc 50 | wget 51 | zstd 52 | -------------------------------------------------------------------------------- /samplefs/make_ubuntu_samplefs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | this_user="$(whoami)" 6 | if [ "${this_user}" != "root" ]; then 7 | echo "[ERROR]: This script requires root privileges. Please execute it with sudo." 8 | exit 1 9 | fi 10 | 11 | BUILD_USER=$(logname) 12 | echo "current build user:${BUILD_USER}." 13 | LOCAL_DIR="$( cd "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && pwd )" 14 | 15 | # Ubuntu 20.04 16 | # RELEASE="focal" 17 | # Ubuntu 22.04 18 | RELEASE="jammy" 19 | ARCH=arm64 20 | DEBOOTSTRAP_COMPONENTS="main,universe" 21 | UBUNTU_MIRROR="mirrors4.tuna.tsinghua.edu.cn/ubuntu-ports/" 22 | 23 | # To use a local proxy to cache apt packages, you need to install apt-cacher-ng 24 | apt_mirror="http://localhost:3142/${UBUNTU_MIRROR}" 25 | apt_extra="-o Acquire::http::Proxy=\"http://localhost:3142\"" 26 | 27 | PYTHON_PACKAGE_LIST="numpy==1.26.4 opencv-python pySerial i2cdev spidev matplotlib pillow \ 28 | websocket websockets lark-parser netifaces google protobuf==3.20.1 " 29 | 30 | DEBOOTSTRAP_LIST="systemd sudo locales apt-utils init dbus kmod udev bash-completion ntp libjsoncpp-dev libjson-c-dev rapidjson-dev" 31 | 32 | get_package_list() 33 | { 34 | package_list_file="${LOCAL_DIR}/${RELEASE}/ubuntu-${1}-${ARCH}-packages" 35 | if [ ! -f "${package_list_file}" ]; then 36 | echo "ERROR: package list file - ${package_list_file} not found" > /dev/stderr 37 | exit 1 38 | fi 39 | PACKAGE_LIST=$(sed ':a;N;$!ba;s/\n/ /g' < "${package_list_file}") 40 | echo "${PACKAGE_LIST}" 41 | } 42 | 43 | # The default version is Ubuntu Desktop 44 | ADD_PACKAGE_LIST="$(get_package_list "base") $(get_package_list "server") $(get_package_list "desktop") " 45 | ubuntufs_src="${LOCAL_DIR}/desktop" 46 | samplefs_version="v3.0.0" 47 | tar_file=${ubuntufs_src}/samplefs_desktop-${samplefs_version}.tar.gz 48 | 49 | 50 | if [ $# -ge 1 ] ; then 51 | # Ubuntu Desktop 52 | if [[ $1 == "d"* ]] ; then 53 | ADD_PACKAGE_LIST="$(get_package_list "base") $(get_package_list "server") $(get_package_list "desktop") " 54 | ubuntufs_src="${LOCAL_DIR}/desktop" 55 | tar_file=${ubuntufs_src}/samplefs_desktop-${samplefs_version}.tar.gz 56 | fi 57 | 58 | # Ubuntu Server 59 | if [[ $1 == "s"* ]] ; then 60 | ADD_PACKAGE_LIST="$(get_package_list "base") $(get_package_list "server") " 61 | ubuntufs_src="${LOCAL_DIR}/server" 62 | tar_file=${ubuntufs_src}/samplefs_server-${samplefs_version}.tar.gz 63 | fi 64 | 65 | # Ubuntu Base 66 | if [[ $1 == "b"* ]] ; then 67 | ADD_PACKAGE_LIST="$(get_package_list "base") " 68 | ubuntufs_src="${LOCAL_DIR}/base" 69 | tar_file=${ubuntufs_src}/samplefs_base-${samplefs_version}.tar.gz 70 | fi 71 | fi 72 | 73 | echo "Make ${tar_file}" 74 | 75 | root_path=${ubuntufs_src}/${RELEASE}-xj3-${ARCH} 76 | 77 | # Release specific packages 78 | case $RELEASE in 79 | bionic) 80 | # Dependent debootstarp packages 81 | DEBOOTSTRAP_COMPONENTS="main,universe" 82 | DEBOOTSTRAP_LIST+=" module-init-tools" 83 | ADD_PACKAGE_LIST+=" android-tools-adbd" 84 | ;; 85 | focal) 86 | # Dependent debootstarp packages 87 | DEBOOTSTRAP_COMPONENTS="main,universe" 88 | DEBOOTSTRAP_LIST+="" 89 | ADD_PACKAGE_LIST+="ros-foxy-ros-base" 90 | ;; 91 | jammy) 92 | # Dependent debootstarp packages 93 | DEBOOTSTRAP_COMPONENTS="main,universe" 94 | DEBOOTSTRAP_LIST+="" 95 | ADD_PACKAGE_LIST+="" 96 | ;; 97 | esac 98 | 99 | echo "${ADD_PACKAGE_LIST}" 100 | 101 | log_out() 102 | { 103 | # log function parameters to install.log 104 | local tmp="" 105 | [[ -n $2 ]] && tmp="[\e[0;33m $2 \x1B[0m]" 106 | 107 | case $3 in 108 | err) 109 | echo -e "[\e[0;31m error \x1B[0m] $1 $tmp" 110 | ;; 111 | 112 | wrn) 113 | echo -e "[\e[0;35m warn \x1B[0m] $1 $tmp" 114 | ;; 115 | 116 | ext) 117 | echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0m $tmp" 118 | ;; 119 | 120 | info) 121 | echo -e "[\e[0;32m o.k. \x1B[0m] $1 $tmp" 122 | ;; 123 | 124 | *) 125 | echo -e "[\e[0;32m .... \x1B[0m] $1 $tmp" 126 | ;; 127 | esac 128 | } 129 | 130 | # mount_chroot 131 | # 132 | # helper to reduce code duplication 133 | # 134 | mount_chroot() 135 | { 136 | local target=$1 137 | log_out "Mounting" "$target" "info" 138 | mount -t proc chproc "${target}"/proc 139 | mount -t sysfs chsys "${target}"/sys 140 | mount -t devtmpfs chdev "${target}"/dev || mount --bind /dev "${target}"/dev 141 | mount -t devpts chpts "${target}"/dev/pts 142 | } 143 | 144 | # unmount_on_exit 145 | # 146 | # helper to reduce code duplication 147 | # 148 | unmount_on_exit() 149 | { 150 | local target=$1 151 | trap - INT TERM EXIT 152 | umount_chroot "${target}/" 153 | # rm -rf ${target} 154 | } 155 | 156 | 157 | # umount_chroot 158 | # 159 | # helper to reduce code duplication 160 | # 161 | umount_chroot() 162 | { 163 | local target=$1 164 | log_out "Unmounting" "$target" "info" 165 | while grep -Eq "${target}.*(dev|proc|sys)" /proc/mounts 166 | do 167 | umount -l --recursive "${target}"/dev >/dev/null 2>&1 168 | umount -l "${target}"/proc >/dev/null 2>&1 169 | umount -l "${target}"/sys >/dev/null 2>&1 170 | sleep 5 171 | done 172 | } 173 | 174 | create_base_sources_list() 175 | { 176 | local release=$1 177 | local basedir=$2 178 | [[ -z $basedir ]] && log_out "No basedir passed to create_base_sources_list" " " "err" 179 | cat <<-EOF > "${basedir}"/etc/apt/sources.list 180 | # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to 181 | # newer versions of the distribution. 182 | deb http://${UBUNTU_MIRROR} $release main restricted universe multiverse 183 | #deb-src http://${UBUNTU_MIRROR} $release main restricted universe multiverse 184 | EOF 185 | echo "deb [arch=arm64 signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://mirrors4.tuna.tsinghua.edu.cn/ros2/ubuntu ${release} main" | tee "${basedir}"/etc/apt/sources.list.d/ros2.list >/dev/null 186 | cp -af "${LOCAL_DIR}"/ros-archive-keyring.gpg "${basedir}"/usr/share/keyrings/ 187 | } 188 | 189 | 190 | create_sources_list() 191 | { 192 | local release=$1 193 | local basedir=$2 194 | [[ -z $basedir ]] && log_out "No basedir passed to create_sources_list" " " "err" 195 | # cp /etc/apt/sources.list "${basedir}"/etc/apt/sources.list 196 | cat <<-EOF > "${basedir}"/etc/apt/sources.list 197 | # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to 198 | # newer versions of the distribution. 199 | deb http://${UBUNTU_MIRROR} $release main restricted universe multiverse 200 | #deb-src http://${UBUNTU_MIRROR} $release main restricted universe multiverse 201 | 202 | deb http://${UBUNTU_MIRROR} ${release}-security main restricted universe multiverse 203 | #deb-src http://${UBUNTU_MIRROR} ${release}-security main restricted universe multiverse 204 | 205 | deb http://${UBUNTU_MIRROR} ${release}-updates main restricted universe multiverse 206 | #deb-src http://${UBUNTU_MIRROR} ${release}-updates main restricted universe multiverse 207 | 208 | deb http://${UBUNTU_MIRROR} ${release}-backports main restricted universe multiverse 209 | #deb-src http://${UBUNTU_MIRROR} ${release}-backports main restricted universe multiverse 210 | EOF 211 | } 212 | 213 | end_debootstrap() 214 | { 215 | local target=$1 216 | } 217 | 218 | compress_base_root() { 219 | local tar_file=$1 220 | local src_dir=$2 221 | if [ ! -d "$src_dir" ];then 222 | log_out "Dir is not exist!" "${src_dir}" "err" 223 | exit 1 224 | fi 225 | log_out "Start compress" "${tar_file} from ${src_dir}" "info" 226 | tar --numeric-owner -czpf "${tar_file}" -C "$src_dir"/ --exclude='./dev/*' --exclude='./proc/*' \ 227 | --exclude='./run/*' --exclude='./tmp/*' --exclude='./sys/*' --exclude='./usr/lib/aarch64-linux-gnu/dri/*' . 228 | } 229 | 230 | install_package() 231 | { 232 | retry=0 233 | retry_max=5 234 | 235 | echo "Install ${1}" 236 | while true 237 | do 238 | eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -y $apt_extra --no-install-recommends install ${1}"' 239 | if [[ $? -eq 0 ]]; then 240 | return 0 241 | else 242 | retry=$(("$retry" + 1)) 243 | if [ "${retry}" == "${retry_max}" ]; then 244 | return 1 245 | else 246 | sleep 1 247 | echo "Retrying ${1} package install" 248 | fi 249 | fi 250 | done 251 | } 252 | 253 | # install_package() 254 | # { 255 | # retry=0 256 | # retry_max=5 257 | 258 | # package_name=${1} 259 | 260 | # # Check if package is available 261 | # eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "apt-cache show ${package_name}"' 262 | # if [[ $? -ne 0 ]]; then 263 | # echo "[ERROR]: Package ${package_name} not found or not available. " 264 | # fi 265 | # } 266 | 267 | 268 | make_base_root() { 269 | local dst_dir=$1 270 | rm -rf "$dst_dir" 271 | mkdir -p "$dst_dir" 272 | trap 'unmount_on_exit "${dst_dir}"' INT TERM EXIT 273 | log_out "Installing base system : " "Stage 2/1" "info" 274 | debootstrap --variant=minbase \ 275 | --include="${DEBOOTSTRAP_LIST// /,}" \ 276 | --arch=${ARCH} \ 277 | --components=${DEBOOTSTRAP_COMPONENTS} \ 278 | --foreign ${RELEASE} \ 279 | "$dst_dir" \ 280 | $apt_mirror 281 | if [[ $? -ne 0 ]] || [[ ! -f $dst_dir/debootstrap/debootstrap ]];then 282 | log_out "Debootstrap base system first stage failed" "err" 283 | exit 1 284 | fi 285 | if [ ! -f /usr/bin/qemu-aarch64-static ];then 286 | log_out "File is not exist!" "Please install qemu-user-static with apt first" "err" 287 | exit 1 288 | else 289 | log_out "Copy qemu-aarch64-static to" "$dst_dir/usr/bin" "info" 290 | cp /usr/bin/qemu-aarch64-static "$dst_dir"/usr/bin 291 | fi 292 | 293 | log_out "Installing base system : " "Stage 2/2" "info" 294 | chroot "${dst_dir}" /bin/bash -c "/debootstrap/debootstrap --second-stage" 295 | if [[ $? -ne 0 ]] || [[ ! -f $dst_dir/bin/bash ]];then 296 | log_out "Debootstrap base system second stage failed" "err" 297 | exit 1 298 | fi 299 | mount_chroot "${dst_dir}" 300 | 301 | # this should fix resolvconf installation failure in some cases 302 | chroot "${dst_dir}" /bin/bash -c 'echo "resolvconf resolvconf/linkify-resolvconf boolean false" | debconf-set-selections' 303 | 304 | if [ "${RELEASE}" == "focal" ]; then 305 | # base for gcc 9.3 306 | create_base_sources_list ${RELEASE} "${dst_dir}" 307 | log_out "Updating base packages" "${dst_dir}" "info" 308 | eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -q -y $apt_extra update"' 309 | [[ $? -ne 0 ]] && exit 1 310 | log_out "Upgrading base packages" "${dst_dir}" "info" 311 | eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -q -y $apt_extra upgrade"' 312 | [[ $? -ne 0 ]] && exit 1 313 | log_out "Installing base packages" "${dst_dir}" "info" 314 | package_list="${ADD_PACKAGE_LIST}" 315 | if [ -n "${package_list}" ]; then 316 | for package in ${package_list} 317 | do 318 | if ! install_package "${package}"; then 319 | echo "ERROR: Failed to install ${package}" 320 | exit 1 321 | fi 322 | done 323 | fi 324 | 325 | # Fixed GCC version: 9.3.0 326 | chroot "${dst_dir}" /bin/bash -c "apt-mark hold cpp-9 g++-9 gcc-9-base gcc-9 libasan5 libgcc-9-dev libstdc++-9-dev" 327 | fi 328 | 329 | if [ "${RELEASE}" == "jammy" ]; then 330 | # base for gcc 11.x 331 | create_base_sources_list ${RELEASE} "${dst_dir}" 332 | log_out "Updating base packages" "${dst_dir}" "info" 333 | eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -q -y $apt_extra update"' 334 | [[ $? -ne 0 ]] && exit 1 335 | log_out "Upgrading base packages" "${dst_dir}" "info" 336 | eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -q -y $apt_extra upgrade"' 337 | [[ $? -ne 0 ]] && exit 1 338 | log_out "Installing base packages" "${dst_dir}" "info" 339 | package_list="${ADD_PACKAGE_LIST}" 340 | if [ -n "${package_list}" ]; then 341 | for package in ${package_list} 342 | do 343 | if ! install_package "${package}"; then 344 | echo "ERROR: Failed to install ${package}" 345 | exit 1 346 | fi 347 | done 348 | fi 349 | 350 | # Fixed GCC version: 11.x.x 351 | chroot "${dst_dir}" /bin/bash -c "apt-mark hold cpp-11 g++-11 gcc-11-base gcc-11 libasan5 libgcc-11-dev libstdc++-11-dev" 352 | 353 | # Add soft links to be compatible with different versions of cross-compilation toolchains 354 | chroot "${dst_dir}" /bin/bash -c "ln -sf aarch64-linux-gnu/ /lib/aarch64-none-linux-gnu" 355 | # Add 11.2.1 and 11.3.1 soft links to itself 356 | chroot "${dst_dir}" /bin/bash -c "ln -sf . /lib/aarch64-none-linux-gnu/11.2.1" 357 | chroot "${dst_dir}" /bin/bash -c "ln -sf . /lib/aarch64-none-linux-gnu/11.3.1" 358 | 359 | # Ubuntu Desktop Add firefox from xtradeb/apps 360 | if [[ $ubuntufs_src == "${LOCAL_DIR}/desktop" ]] ; then 361 | chroot "${dst_dir}" /bin/bash -c "apt remove firefox -y" 362 | chroot "${dst_dir}" /bin/bash -c "apt install gpg-agent -y" 363 | chroot "${dst_dir}" /bin/bash -c "apt-get install software-properties-common -y" 364 | chroot "${dst_dir}" /bin/bash -c "add-apt-repository ppa:xtradeb/apps -y" 365 | chroot "${dst_dir}" /bin/bash -c "apt install firefox -y" 366 | # ppa can not use apt_extra,so install here 367 | chroot "${dst_dir}" /bin/bash -c "apt install firefox-locale-zh-hans -y" 368 | chroot "${dst_dir}" /bin/bash -c "add-apt-repository --remove ppa:xtradeb/apps -y" 369 | fi 370 | fi 371 | 372 | # upgrade packages 373 | create_sources_list ${RELEASE} "${dst_dir}" 374 | log_out "Updating focal-updates and focal-security packages" "${dst_dir}" "info" 375 | eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -q -y $apt_extra update"' 376 | [[ $? -ne 0 ]] && exit 1 377 | log_out "Upgrading base packages" "${dst_dir}" "info" 378 | eval 'LC_ALL=C LANG=C chroot ${dst_dir} /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get -q -y $apt_extra upgrade"' 379 | [[ $? -ne 0 ]] && exit 1 380 | log_out "Installing base packages" "${dst_dir}" "info" 381 | package_list="${ADD_PACKAGE_LIST}" 382 | if [ -n "${package_list}" ]; then 383 | for package in ${package_list} 384 | do 385 | if ! install_package "${package}"; then 386 | echo "ERROR: Failed to install ${package}" 387 | exit 1 388 | fi 389 | done 390 | fi 391 | 392 | if [ "${RELEASE}" == "jammy" ]; then 393 | chroot "${dst_dir}" /bin/bash -c "apt install ros-humble-ros-base -y" 394 | chroot "${dst_dir}" /bin/bash -c "apt install ros-humble-cv-bridge -y" 395 | fi 396 | 397 | chroot "${dst_dir}" /bin/bash -c "dpkg --get-selections" | grep -v deinstall | awk '{print $1}' | cut -f1 -d':' | sort > "${tar_file}".info 398 | 399 | chroot "${dst_dir}" /bin/bash -c "pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple" 400 | chroot "${dst_dir}" /bin/bash -c "pip3 config set install.trusted-host https://pypi.tuna.tsinghua.edu.cn" 401 | chroot "${dst_dir}" /bin/bash -c "pip3 install ${PYTHON_PACKAGE_LIST}" 402 | py_pkg_list="${PYTHON_PACKAGE_LIST}" 403 | if [ -n "${py_pkg_list}" ]; then 404 | for package in ${py_pkg_list} 405 | do 406 | chroot "${dst_dir}" /bin/bash -c "pip3 install ${package}" 407 | done 408 | fi 409 | chroot "${dst_dir}" /bin/bash -c "rm -rf /root/.cache" 410 | 411 | DEST_LANG="en_US.UTF-8" 412 | DEST_LANG_CN="zh_CN.UTF-8" 413 | log_out "Configuring locales" "${DEST_LANG}" "${DEST_LANG_CN}" "info" 414 | if [ -f "${dst_dir}"/etc/locale.gen ];then 415 | sed -i "s/^# $DEST_LANG/$DEST_LANG/" "$dst_dir"/etc/locale.gen 416 | sed -i "s/^# $DEST_LANG_CN/$DEST_LANG_CN/" "$dst_dir"/etc/locale.gen 417 | fi 418 | eval 'LC_ALL=C LANG=C chroot $dst_dir /bin/bash -c "locale-gen $DEST_LANG"' 419 | eval 'LC_ALL=C LANG=C chroot $dst_dir /bin/bash -c "locale-gen $DEST_LANG_CN"' 420 | eval 'LC_ALL=C LANG=C chroot $dst_dir /bin/bash -c "update-locale LANG=$DEST_LANG LANGUAGE=$DEST_LANG"' 421 | 422 | chroot "${dst_dir}" /bin/bash -c "systemctl disable hostapd NetworkManager-wait-online.service" 423 | 424 | chroot "${dst_dir}" /bin/bash -c "sed 's/5min/2sec/g' /lib/systemd/system/networking.service > /tmp/networking.service" 425 | chroot "${dst_dir}" /bin/bash -c "mv /tmp/networking.service /lib/systemd/system/networking.service" 426 | 427 | chroot "${dst_dir}" /bin/bash -c "apt clean" 428 | 429 | chroot "${dst_dir}" /bin/bash -c "rm -f /var/lib/apt/lists/mirrors*" 430 | chroot "${dst_dir}" /bin/bash -c "rm -rf /home/${BUILD_USER}" 431 | 432 | umount_chroot "${dst_dir}" 433 | end_debootstrap "${dst_dir}" 434 | 435 | trap - INT TERM EXIT 436 | } 437 | 438 | log_out "Build ubuntu base" "root_path=$root_path tar_file=$tar_file" "info" 439 | log_out "Start build" "ubuntu base :${RELEASE}-xj3-${ARCH}" "info" 440 | 441 | if [ ! -f "${tar_file}0" ];then 442 | make_base_root "${root_path}" 443 | sync 444 | compress_base_root "${tar_file}" "${root_path}" 445 | sync 446 | else 447 | sync 448 | fi 449 | 450 | log_out "End build ubuntu" "${ubuntufs_src}" "info" 451 | exit 0 452 | -------------------------------------------------------------------------------- /samplefs/ros-archive-keyring.gpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-Robotics/rdk-gen/29547392f12d58ed2ce2ba404b1219b8e3b56917/samplefs/ros-archive-keyring.gpg -------------------------------------------------------------------------------- /source_sync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### 3 | # COPYRIGHT NOTICE 4 | # Copyright 2023 Horizon Robotics, Inc. 5 | # All rights reserved. 6 | # @Date: 2022-12-18 16:06:50 7 | # @LastEditTime: 2023-04-25 12:14:22 8 | ### 9 | 10 | set -e 11 | 12 | # 13 | # This script synchronizes the kernel, bootloader and debian package 14 | # sources in the horizon public git repository. 15 | # The script also provides opportunities to the sync to a specific tag 16 | # so that the binaries shipped with a release can be replicated. 17 | # 18 | # Usage: 19 | # By default it will download all the listed sources 20 | # ./source_sync.sh 21 | # Use the -t option to provide the TAG to be used to sync all the sources. 22 | # Use the -k option to download only the kernel and device tree repos and optionally sync to TAG 23 | # For detailed usage information run with -h option. 24 | # 25 | 26 | # verify that git is installed 27 | if ! which git > /dev/null ; then 28 | echo "ERROR: git is not installed. If your linux distro is 10.04 or later," 29 | echo "git can be installed by 'sudo apt-get install git-core'." 30 | exit 1 31 | fi 32 | 33 | # source dir 34 | RDK_DIR=$(cd `dirname $0` && pwd) 35 | RDK_DIR="${RDK_DIR}/source" 36 | # script name 37 | SCRIPT_NAME=`basename $0` 38 | # info about sources. 39 | # NOTE: *Add only kernel repos here. Add new repos separately below. Keep related repos together* 40 | SOURCE_INFO=" 41 | k:kernel:D-Robotics/kernel.git: 42 | o:bootloader:D-Robotics/bootloader.git: 43 | o:hobot-miniboot:D-Robotics/hobot-miniboot.git: 44 | o:hobot-boot:D-Robotics/hobot-boot.git: 45 | o:hobot-bpu-drivers:D-Robotics/hobot-bpu-drivers.git: 46 | o:hobot-camera:D-Robotics/hobot-camera.git: 47 | o:hobot-configs:D-Robotics/hobot-configs.git: 48 | o:hobot-dnn:D-Robotics/hobot-dnn.git: 49 | o:hobot-dtb:D-Robotics/hobot-dtb.git: 50 | o:hobot-display:D-Robotics/hobot-display.git: 51 | o:hobot-io:D-Robotics/hobot-io.git: 52 | o:hobot-io-samples:D-Robotics/hobot-io-samples.git: 53 | o:hobot-kernel-headers:D-Robotics/hobot-kernel-headers.git: 54 | o:hobot-multimedia:D-Robotics/hobot-multimedia.git: 55 | o:hobot-multimedia-dev:D-Robotics/hobot-multimedia-dev.git: 56 | o:hobot-spdev:D-Robotics/hobot-spdev.git: 57 | o:hobot-sp-samples:D-Robotics/hobot-sp-samples.git: 58 | o:hobot-utils:D-Robotics/hobot-utils.git: 59 | o:hobot-wifi:D-Robotics/hobot-wifi.git: 60 | o:hobot-multimedia-samples:D-Robotics/hobot-multimedia-samples.git: 61 | o:hobot-audio-config:D-Robotics/hobot-audio-config.git: 62 | " 63 | 64 | # exit on error on sync 65 | EOE=0 66 | # after processing SOURCE_INFO 67 | NSOURCES=0 68 | declare -a SOURCE_INFO_PROCESSED 69 | # download all? 70 | DALL=1 71 | 72 | function Usages { 73 | local ScriptName=$1 74 | local LINE 75 | local OP 76 | local DESC 77 | local PROCESSED=() 78 | local i 79 | 80 | echo "Use: $1 [options]" 81 | echo "Available general options are," 82 | echo " -h : help" 83 | echo " -e : exit on sync error" 84 | echo " -d [DIR] : root of source is DIR" 85 | echo " -t [TAG] : Git tag that will be used to sync all the sources" 86 | echo "" 87 | echo "By default, all sources are downloaded." 88 | echo "Only specified sources are downloaded, if one or more of the following options are mentioned." 89 | echo "" 90 | echo "$SOURCE_INFO" | while read LINE; do 91 | if [ ! -z "$LINE" ]; then 92 | OP=$(echo "$LINE" | cut -f 1 -d ':') 93 | DESC=$(echo "$LINE" | cut -f 2 -d ':') 94 | if [[ ! " ${PROCESSED[@]} " =~ " ${OP} " ]]; then 95 | echo " -${OP} [TAG]: Download $DESC source and optionally sync to TAG" 96 | PROCESSED+=("${OP}") 97 | else 98 | echo " and download $DESC source and sync to the same TAG" 99 | fi 100 | fi 101 | done 102 | echo "" 103 | } 104 | 105 | function ProcessSwitch { 106 | local SWITCH="$1" 107 | local TAG="$2" 108 | local i 109 | local found=0 110 | 111 | for ((i=0; i < NSOURCES; i++)); do 112 | local OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':') 113 | if [ "-${OP}" == "$SWITCH" ]; then 114 | SOURCE_INFO_PROCESSED[i]="${SOURCE_INFO_PROCESSED[i]}${TAG}:y" 115 | DALL=0 116 | found=1 117 | fi 118 | done 119 | 120 | if [ "$found" == 1 ]; then 121 | return 0 122 | fi 123 | 124 | echo "Terminating... wrong switch: ${SWITCH}" >&2 125 | Usages "$SCRIPT_NAME" 126 | exit 1 127 | } 128 | 129 | function UpdateTags { 130 | local SWITCH="$1" 131 | local TAG="$2" 132 | local i 133 | 134 | for ((i=0; i < NSOURCES; i++)); do 135 | local OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':') 136 | if [ "${OP}" == "$SWITCH" ]; then 137 | SOURCE_INFO_PROCESSED[i]=$(echo "${SOURCE_INFO_PROCESSED[i]}" \ 138 | | awk -F: -v OFS=: -v var="${TAG}" '{$4=var; print}') 139 | fi 140 | done 141 | } 142 | 143 | function DownloadAndSync { 144 | local WHAT_SOURCE="$1" 145 | local RDK_SOURCE_DIR="$2" 146 | local REPO_URL="$3" 147 | local TAG="$4" 148 | local OPT="$5" 149 | local RET=0 150 | 151 | if [ -d "${RDK_SOURCE_DIR}" ]; then 152 | echo "Directory for $WHAT, ${RDK_SOURCE_DIR}, already exists!" 153 | pushd "${RDK_SOURCE_DIR}" > /dev/null 154 | git status 2>&1 >/dev/null 155 | if [ $? -ne 0 ]; then 156 | echo "But the directory is not a git repository -- clean it up first" 157 | echo "" 158 | echo "" 159 | popd > /dev/null 160 | return 1 161 | fi 162 | git fetch --all 2>&1 >/dev/null 163 | local_head=$(git rev-parse HEAD) 164 | remote_head=$(git rev-parse @{u}) 165 | if [[ $local_head != $remote_head ]]; then 166 | echo "There are remote updates for $WHAT, pulling latest code..." 167 | git pull --ff-only 168 | fi 169 | popd > /dev/null 170 | else 171 | echo "Downloading default $WHAT source..." 172 | 173 | git clone "$REPO_URL" -n ${RDK_SOURCE_DIR} 2>&1 >/dev/null 174 | if [ $? -ne 0 ]; then 175 | echo "$2 source sync failed!" 176 | echo "" 177 | echo "" 178 | return 1 179 | fi 180 | 181 | echo "The default $WHAT source is downloaded in: ${RDK_SOURCE_DIR}" 182 | fi 183 | 184 | if [ -z "$TAG" ]; then 185 | echo "Please enter a tag to sync $2 source to" 186 | echo -n "(enter nothing to skip): " 187 | read TAG 188 | TAG=$(echo $TAG) 189 | UpdateTags $OPT $TAG 190 | fi 191 | 192 | if [ ! -z "$TAG" ]; then 193 | if [ "xmain" == x"$TAG" ] || [ "xdevelop" == x"$TAG" ] || [ "xfeat-ubuntu22.04" == x"$TAG" ]; then 194 | # checkout main or develop 195 | pushd ${RDK_SOURCE_DIR} > /dev/null 196 | echo "Syncing up with branch origin/$TAG..." 197 | git checkout ${TAG} 198 | echo "$2 source sync'ed to branch origin/$TAG successfully!" 199 | popd > /dev/null 200 | else 201 | pushd ${RDK_SOURCE_DIR} > /dev/null 202 | git tag -l 2>/dev/null | grep -q -P "^$TAG\$" 203 | if [ $? -eq 0 ]; then 204 | echo "Syncing up with tag $TAG..." 205 | git checkout -b mybranch_$(date +%Y-%m-%d-%s) $TAG 206 | echo "$2 source sync'ed to tag $TAG successfully!" 207 | else 208 | echo "Couldn't find tag $TAG" 209 | echo "$2 source sync to tag $TAG failed!" 210 | RET=1 211 | fi 212 | popd > /dev/null 213 | fi 214 | fi 215 | echo "" 216 | echo "" 217 | 218 | return "$RET" 219 | } 220 | 221 | # prepare processing .... 222 | GETOPT=":ehd:t:" 223 | 224 | OIFS="$IFS" 225 | IFS=$(echo -en "\n\b") 226 | SOURCE_INFO_PROCESSED=($(echo "$SOURCE_INFO")) 227 | IFS="$OIFS" 228 | NSOURCES=${#SOURCE_INFO_PROCESSED[*]} 229 | 230 | for ((i=0; i < NSOURCES; i++)); do 231 | OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':') 232 | GETOPT="${GETOPT}${OP}:" 233 | done 234 | 235 | # parse the command line first 236 | while getopts "$GETOPT" opt; do 237 | case $opt in 238 | d) 239 | case $OPTARG in 240 | -[A-Za-z]*) 241 | Usages "$SCRIPT_NAME" 242 | exit 1 243 | ;; 244 | *) 245 | RDK_DIR="$OPTARG" 246 | ;; 247 | esac 248 | ;; 249 | e) 250 | EOE=1 251 | ;; 252 | h) 253 | Usages "$SCRIPT_NAME" 254 | exit 1 255 | ;; 256 | t) 257 | TAG="$OPTARG" 258 | PROCESSED=() 259 | for ((i=0; i < NSOURCES; i++)); do 260 | OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':') 261 | if [[ ! " ${PROCESSED[@]} " =~ " ${OP} " ]]; then 262 | UpdateTags $OP $TAG 263 | PROCESSED+=("${OP}") 264 | fi 265 | done 266 | ;; 267 | [A-Za-z]) 268 | case $OPTARG in 269 | -[A-Za-z]*) 270 | eval arg=\$$((OPTIND-1)) 271 | case $arg in 272 | -[A-Za-Z]-*) 273 | Usages "$SCRIPT_NAME" 274 | exit 1 275 | ;; 276 | *) 277 | ProcessSwitch "-$opt" "" 278 | OPTIND=$((OPTIND-1)) 279 | ;; 280 | esac 281 | ;; 282 | *) 283 | ProcessSwitch "-$opt" "$OPTARG" 284 | ;; 285 | esac 286 | ;; 287 | :) 288 | case $OPTARG in 289 | #required arguments 290 | d) 291 | Usages "$SCRIPT_NAME" 292 | exit 1 293 | ;; 294 | #optional arguments 295 | [A-Za-z]) 296 | ProcessSwitch "-$OPTARG" "" 297 | ;; 298 | esac 299 | ;; 300 | \?) 301 | echo "Terminating... wrong switch: $@" >&2 302 | Usages "$SCRIPT_NAME" 303 | exit 1 304 | ;; 305 | esac 306 | done 307 | shift $((OPTIND-1)) 308 | 309 | for ((i=0; i < NSOURCES; i++)); do 310 | OPT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':') 311 | WHAT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 2 -d ':') 312 | REPO=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 3 -d ':') 313 | TAG=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 4 -d ':') 314 | DNLOAD=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 5 -d ':') 315 | 316 | if [ $DALL -eq 1 -o "x${DNLOAD}" == "xy" ]; then 317 | DownloadAndSync "$WHAT" "${RDK_DIR}/${WHAT}" "git@github.com:${REPO}" "${TAG}" "${OPT}" 318 | tRET=$? 319 | if [ $tRET -ne 0 -a $EOE -eq 1 ]; then 320 | exit $tRET 321 | fi 322 | fi 323 | done 324 | 325 | exit 0 326 | --------------------------------------------------------------------------------