| 113 | |
| 114 | |
| 115 | [=#overlay] |
| 116 | == Adding or modifying files in the rootfs |
| 117 | A common need is to add or modify existing files in the root filesystem. Buildroot makes this very easy by allowing a set of directories to be specified that it will overlay on the target root filesytem. |
| 118 | |
| 119 | Examples |
| 120 | * Add firmware for the Sterling LWB wireless module (obtained from https://www.lairdconnect.com/wireless-modules/wi-fi-bt-modules/sterling-lwb) |
| 121 | 1. make menuconfig and set BR2_ROOTFS_OVERLAY=files |
| 122 | 2. create an overlay directory. For example, add firmware for the LAIRD sterling-lwb wifi module: |
| 123 | {{{#!bash |
| 124 | mkdir -p files |
| 125 | tar xvf firmware-7.0.0.326.tar.bz2 -C files |
| 126 | }}} |
| 127 | 3. build with 'make' |
| 128 | 4. notice your files are now in output/target/lib/firmware/brcm |
| 129 | |
| 130 | If you wish to modify a file simply provide your version of it in your overlay and it will be copied over the original. If you wish to remove a file you can provide a 0-byte version of the file which may meet your needs. |
| 131 | |
| 132 | [=#init] |
| 133 | == Create a custom init script |
| 134 | The {{{init}}} program is the first userspace program started by the kernel (with PID 1) and is responsible for starting the userspace services. There are three different types of init provided by buildroot which can be chosen under 'System cnfiguration, Init system' but the default solution provided by busybox is usually just fine for embedded systems. |
| 135 | |
| 136 | The busybox init system is configured vi an /etc/inittab which has a fairly simple syntax. The important items in this file do the following: |
| 137 | * mount various psuedo-filesystems such as proc |
| 138 | * execute /etc/init.d/rcS on startup |
| 139 | * execute /etc/init.d/rcK on shutdown |
| 140 | * kick off a getty process on the console tty allowing login |
| 141 | |
| 142 | The /etc/init.d/rcS script executes the scripts in /etc/init.d which match the 'S??*' pattern. If you want a custom init script you can add one here. A good example to start with is the /etc/init.d/S40network example. |
| 143 | |
| 144 | For more information see the Buildroot user manual 'init system' section. |
| 145 | |