OpenWrt 的世界︰樹莓派 3B 【路由器】移星轉斗《五》編譯 三

如果曾經有過『經驗』

 Sreehari

A map of the Linux kernel

 

I just finished my first assignment for a course on Advanced Operating Systems. And I decided to document my approach for building the Linux kernel from source and implementing my own system call.

There are a number of blogs that already tell you how to go about doing this, but some of them are outdated, and some seem unnecessarily complicated. My goal is to present a straightforward approach for doing this, which should hopefully help you save a lot of time.

Compiling the Linux Kernel from source can seem like a daunting task, even to someone who’s pretty comfortable with computers in general. It can also get really irritating if you aren’t following the right instructions.

So, here’s a guide to help you through the process of building the kernel from source, and it’s a guide that works! You will not have to worry about messing up your system or wasting your time.

Why build the kernel from source?

If you plan to work on the internals of the Linux kernel or change its behavior, you’ll need to recompile the kernel on your system.

Here are a few specific cases where you’ll need to know how to work with the kernel’s source code:

  1. You want to write a really cool ‘Hello world’ program. (Each time you implement your own system call or modify kernel source code, you will need to recompile the kernel to implement the changes)
  2. You want to enable experimental features on your kernel that are not enabled by default (or, disable default features that you don’t want)
  3. You want to debug kernel source code, enable support for a new piece of hardware, or make modifications to its existing configurations
  4. You’re doing a course on Advanced Operating Systems and have no choice but to do this!

In each of the above situations, learning how to build the kernel from source will come in handy.

………

可能容易掌握 OpenWrt 

Build system – Usage

:!: Do everything as normal user, don’t use root user or sudo!
:!: Do not build in a directory that has spaces in its full path
write all command line commands for build system commands in a terminal window opened in the <buildsystem root> directory, e.g. ~/source/ if you wrote the git clone command in your home folder (default terminal location)

  1. Update the sources.
  2. Update and install package feeds.
  3. Configure the firmware image you want to obtain.
  4. Start the build. (automatically compile toolchain, cross-compile sources, package packages, and generate an image ready to be flashed).
  5. Proceed with the firmware flashing instructions: Factory install or Sysupgrade

……

Image Configuration

Typical actions:

  1. run make menuconfig and set target;
  2. run make defconfig to set default config for build system and device;
  3. run make menuconfig and modify set of package;
  4. run make download (download all dependency source files before final make, enables multi-core compilation);
  5. run scripts/diffconfig.sh >mydiffconfig (save your changes in the text file mydiffconfig);

 

假使祇是添加程式庫已有的軟件

 

認識

Make menuconfig

The build system configuration interface handles the selection of the target platform, packages to be compiled, packages to be included in the firmware file, some kernel options, etc.
Start the build system configuration interface by writing the following command:

make menuconfig

This will update the dependencies of your existing configuration automatically, and you can now proceed to build your updated images.

You will see a list of options. This list is really the top of a tree. You can select a list item, and descend into its tree.

To search for the package or feature in the tree, you can type the “/” key, and search for a string. This will give you its locations within the tree.

For most packages and features, you have three options: y, m, n which are represented as follows:

  • pressing y sets the <*> built-in label
    This package will be compiled and included in the firmware image file.
  • pressing m sets the <M> package label
    This package will be compiled, but not included in the firmware image file. (E.g. to be installed with opkg after flashing the firmware image file to the device.)
  • pressing n sets the < > excluded label
    The source code will not be processed.

When you save your configuration, the file <buildroot dir>/.config will be created according to your configuration.

When you open menuconfig you will need to set the build settings in this order (also shown in this order in menuconfig‘s interface):

  1. Target system (general category of similar devices)
  2. Subtarget (subcategory of Target system, grouping similar devices)
  3. Target profile (each specific device)
  4. Package selection
  5. Build system settings
  6. Kernel modules

Select your device’s Target system first, then select the right Subtarget, then you can find your device in the Target profile‘s list of supported platforms.

………

或許足夠矣◎

欲求新創者,最好先閱讀

Development Articles

 

知其體系也☆

 

 

 

 

 

 

 

OpenWrt 的世界︰樹莓派 3B 【路由器】移星轉斗《五》編譯 二

幸而經過一夜折騰,總算大功告成︰

pi@raspberrypi:~/openwrt make  make[1] world  make[2] toolchain/compile  make[3] -C toolchain/gdb compile  make[3] -C toolchain/binutils compile  make[3] -C toolchain/gcc/initial compile  make[3] -C toolchain/kernel-headers compile  make[3] -C toolchain/musl compile  make[3] -C toolchain/gcc/final compile  make[3] -C toolchain/fortify-headers compile  make[2] target/compile  make[3] -C target/linux compile  make[2] diffconfig  make[2] package/cleanup  make[2] package/compile  make[3] -C package/libs/libjson-c host-compile  make[3] -C package/libs/libubox host-compile  make[3] -C package/system/opkg host-compile  make[3] -C package/libs/toolchain compile  make[3] -C package/libs/libnl-tiny compile  make[3] -C package/libs/libjson-c compile  make[3] -C package/utils/lua compile  make[3] -C package/libs/libubox compile  make[3] -C package/system/ubus compile  make[3] -C package/system/uci compile  make[3] -C package/network/config/netifd compile  make[3] -C package/firmware/linux-firmware compile  make[3] -C package/firmware/prism54-firmware compile  make[3] -C package/kernel/linux compile  make[3] -C package/system/ubox compile  make[3] -C package/libs/ncurses host-compile  make[3] -C package/libs/zlib compile  make[3] -C package/libs/ncurses compile  make[3] -C package/utils/util-linux compile  make[3] -C package/system/fstools compile  make[3] -C package/system/fwtool host-compile  make[3] -C package/system/fwtool compile  make[3] -C package/system/procd compile  make[3] -C package/system/usign host-compile  make[3] -C package/system/ucert host-compile  make[3] -C package/utils/jsonfilter compile  make[3] -C package/system/openwrt-keyring compile  make[3] -C package/system/usign compile  make[3] -C package/base-files compile  make[3] -C package/firmware/brcmfmac-board-rpi compile  make[3] -C package/firmware/wireless-regdb compile  make[3] -C package/kernel/brcm2708-gpu-fw compile  make[3] -C package/firmware/b43legacy-firmware compile  make[3] -C package/libs/openssl compile  make[3] -C package/libs/gettext compile  make[3] -C package/libs/libiconv compile  make[3] -C package/libs/libtool compile  make[3] -C package/libs/wolfssl compile  make[3] -C package/network/services/hostapd compile  make[3] -C package/network/utils/iw compile  make[3] -C package/kernel/mac80211 compile  make[3] -C package/libs/mbedtls compile  make[3] -C package/libs/ustream-ssl compile  make[3] -C package/libs/uclient compile  make[3] -C package/network/utils/iptables compile  make[3] -C package/network/config/firewall compile  make[3] -C package/network/ipv6/odhcp6c compile  make[3] -C package/network/services/dnsmasq compile  make[3] -C package/network/services/dropbear compile  make[3] -C package/network/services/odhcpd compile  make[3] -C package/libs/libpcap compile  make[3] -C package/network/utils/linux-atm compile  make[3] -C package/network/utils/resolveip compile  make[3] -C package/network/services/ppp compile  make[3] -C package/network/utils/iwinfo compile  make[3] -C package/system/mtd compile  make[3] -C package/system/opkg compile  make[3] -C package/utils/busybox compile  make[3] -C package/utils/e2fsprogs host-compile  make[3] -C package/utils/e2fsprogs compile  make[3] -C package/utils/f2fs-tools compile  make[2] package/install  make[2] target/install  make[3] -C target/linux install  make[2] package/index  make[2] checksum pi@raspberrypi:~/openwrt 

 

不過,一則掛慮所剩空間無幾︰

pi@raspberrypi:~/openwrt df -h 檔案系統        容量  已用  可用 已用% 掛載點 /dev/root        15G   14G  737M   95% / devtmpfs        460M     0  460M    0% /dev tmpfs           464M     0  464M    0% /dev/shm tmpfs           464M   13M  452M    3% /run tmpfs           5.0M  4.0K  5.0M    1% /run/lock tmpfs           464M     0  464M    0% /sys/fs/cgroup /dev/mmcblk0p1   44M   23M   22M   51% /boot tmpfs            93M  4.0K   93M    1% /run/user/1000 </pre>    <span style="color: #666699;">再則擔心昨天所遇『莫名事件』︰</span> <pre class="lang:default decode:true "> make[3] -C toolchain/gcc/initial compile make -r world: build failed. Please re-run make with -j1 V=s or V=sc for a higher verbosity level to see what's going on /home/pi/openwrt/include/toplevel.mk:216: recipe for target 'world' failed make: *** [world] Error 1 pi@raspberrypi:~/openwrt make
 make[1] world
 make[2] toolchain/compile
 make[3] -C toolchain/gdb compile
 make[3] -C toolchain/binutils compile
 make[3] -C toolchain/gcc/initial compile

【demsg】

[ 7002.114849] Workqueue: events_freezable mmc_rescan
[ 7002.114867] [<8079ef70>] (__schedule) from [<8079f5d8>] (schedule+0x50/0xa8)
[ 7002.114875] [<8079f5d8>] (schedule) from [<8061a2d0>] (__mmc_claim_host+0xb8/0x1cc)
[ 7002.114884] [<8061a2d0>] (__mmc_claim_host) from [<8061a414>] (mmc_get_card+0x30/0x34)
[ 7002.114891] [<8061a414>] (mmc_get_card) from [<80623010>] (mmc_sd_detect+0x20/0x74)
[ 7002.114898] [<80623010>] (mmc_sd_detect) from [<8061ccdc>] (mmc_rescan+0x1c8/0x394)
[ 7002.114907] [<8061ccdc>] (mmc_rescan) from [<801379b4>] (process_one_work+0x158/0x454)
[ 7002.114914] [<801379b4>] (process_one_work) from [<80137d14>] (worker_thread+0x64/0x5b8)
[ 7002.114921] [<80137d14>] (worker_thread) from [<8013dd98>] (kthread+0x13c/0x16c)
[ 7002.114930] [<8013dd98>] (kthread) from [<801080ac>] (ret_from_fork+0x14/0x28)

 

況且依據

Workqueue: kmmcd mmc_rescan crash with Raspbian kernel 4.4.38-v7 #1885

kkpdk commented Oct 10, 2018

I had the idea to test this on various models, to see if multicore or wifi was the trigger: No, it is Pi3/Pi3B+.

Pi 0W (4pcs): 48 hours runtime, no failures
I tested 4 cards (Sandisk A1, SanDisk industrial, NetList SLC, Panasonic Industrial), one in each 0W, with wifi enabled and talking, for a total of 192 card-hours.

Pi 2 original (1pc): 48 hours runtime, no failures
If this is a locking bug, maybe it would fail on the Pi2. This is the first Pi2, not using the Pi3 SoC.

Pi 3 original (1pc): 8 hours runtime, 6 failures, throttled=0x0
This is powered from a really nice and clean 5V 5A supply, with short fat wires, and a large heatsink.

Pi 3B+ (3pcs): Highly variable. The best has 6 days of runtime and only a single failure, the worst fails once per hour on average.

Various things tried:
330uF extra on 3.3V. 5V supplied to header. Disabling wifi. Iperf3 on wifi while copying. No difference.

 

所言,實有隱憂☻

故耳決定測之以 USD HDD 『開機系統』呦。

pi@raspberrypi:~ df -h 檔案系統        容量  已用  可用 已用% 掛載點 /dev/root        57G   14G   42G   25% / devtmpfs        460M     0  460M    0% /dev tmpfs           464M     0  464M    0% /dev/shm tmpfs           464M   13M  452M    3% /run tmpfs           5.0M  4.0K  5.0M    1% /run/lock tmpfs           464M     0  464M    0% /sys/fs/cgroup /dev/sda1        44M   23M   22M   51% /boot tmpfs            93M  4.0K   93M    1% /run/user/1000 </pre>    <span style="color: #666699;">還好目前沒見著什麼問題哩☺</span> <pre class="lang:default decode:true ">pi@raspberrypi:~/openwrt make -j 4
 make[1] world
 make[2] package/cleanup
 make[2] target/compile
 make[3] -C target/linux compile
 make[2] diffconfig
 make[2] package/compile
 make[3] -C package/libs/libjson-c host-compile
 make[3] -C package/libs/ncurses host-compile
 make[3] -C package/libs/toolchain compile
 make[3] -C package/system/fwtool host-compile
 make[3] -C package/system/usign host-compile
 make[3] -C package/utils/e2fsprogs host-compile
 make[3] -C package/libs/libubox host-compile
 make[3] -C package/libs/libnl-tiny compile
 make[3] -C package/libs/libjson-c compile
 make[3] -C package/utils/lua compile
 make[3] -C package/firmware/linux-firmware compile
 make[3] -C package/firmware/prism54-firmware compile
 make[3] -C package/libs/zlib compile
 make[3] -C package/system/fwtool compile
 make[3] -C package/system/ucert host-compile
 make[3] -C package/system/openwrt-keyring compile
 make[3] -C package/firmware/brcmfmac-board-rpi compile
 make[3] -C package/firmware/wireless-regdb compile
 make[3] -C package/kernel/brcm2708-gpu-fw compile
 make[3] -C package/firmware/b43legacy-firmware compile
 make[3] -C package/libs/openssl compile
 make[3] -C package/libs/gettext compile
 make[3] -C package/libs/libiconv compile
 make[3] -C package/libs/libtool compile
 make[3] -C package/network/utils/iw compile
 make[3] -C package/libs/mbedtls compile
 make[3] -C package/network/services/dropbear compile
 make[3] -C package/libs/libpcap compile
 make[3] -C package/network/utils/linux-atm compile
 make[3] -C package/network/utils/resolveip compile
 make[3] -C package/utils/busybox compile
 make[3] -C package/system/opkg host-compile
 make[3] -C package/libs/libubox compile
 make[3] -C package/libs/ncurses compile
 make[3] -C package/libs/wolfssl compile
 make[3] -C package/utils/util-linux compile
 make[3] -C package/utils/f2fs-tools compile
 make[3] -C package/utils/e2fsprogs compile
 make[3] -C package/system/ubus compile
 make[3] -C package/system/uci compile
 make[3] -C package/utils/jsonfilter compile
 make[3] -C package/system/usign compile
 make[3] -C package/network/services/hostapd compile
 make[3] -C package/libs/ustream-ssl compile
 make[3] -C package/network/ipv6/odhcp6c compile
 make[3] -C package/network/services/dnsmasq compile
 make[3] -C package/network/services/odhcpd compile
 make[3] -C package/network/utils/iwinfo compile
 make[3] -C package/system/mtd compile
 make[3] -C package/network/config/netifd compile
 make[3] -C package/kernel/linux compile
 make[3] -C package/system/ubox compile
 make[3] -C package/libs/uclient compile
 make[3] -C package/system/procd compile
 make[3] -C package/system/opkg compile
 make[3] -C package/system/fstools compile
 make[3] -C package/kernel/mac80211 compile
 make[3] -C package/network/services/ppp compile
 make[3] -C package/network/utils/iptables compile
 make[3] -C package/base-files compile
 make[3] -C package/network/config/firewall compile
 make[2] package/install
 make[2] target/install
 make[3] -C target/linux install
 make[2] package/index
 make[2] checksum
pi@raspberrypi:~/openwrt </pre>    <span style="color: #666699;">將可仔細瀏覽一下現今 openwrt 目錄結構︰</span> <pre class="lang:default decode:true ">pi@raspberrypi:~/openwrt ls
bin          dl                  key-build.pub           package      target
BSDmakefile  feeds               key-build.ucert         README       tmp
build_dir    feeds.conf.default  key-build.ucert.revoke  rules.mk     toolchain
config       include             LICENSE                 scripts      tools
Config.in    key-build           Makefile                staging_dir

 

回想其與昔日的

Build system – Features

  • Makes it easy to port software
  • Uses kconfig (Linux Kernel menuconfig) for configuration of features
  • Provides integrated cross-compiler toolchain (gcc, ld, …)
  • Provides abstraction for autotools (automake, autoconf), cmake, scons
  • Handles standard download, patch, configure, compile and packaging workflow
  • Provides a number of common fixups for badly behaving packages

Build system – Make Targets

  • Offers a number of high level make targets for standard package workflows
  • Targets always in the format “component/name/action”, e.g. “toolchain/gdb/compile” or “package/mtd/install”
  • Prepare a package source tree: package/foo/prepare
  • Compile a package: package/foo/compile
  • Clean a package: package/foo/clean

Build system – Build sequence

  1. tools – automake, autoconf, sed, cmake
  2. toolchain/binutils – as, ld, …
  3. toolchain/gcc – gcc, g++, cpp, …
  4. target/linux – kernel modules
  5. package – core and feed packages
  6. target/linux – kernel image
  7. target/linux/image – firmware image file generation

Patch management

  • Many packages will not work as-is and need patches to work on the target or to even compile
  • the build system integrates quilt for easy patch management
  • Turn package patches into quilt series: make package/foo/prepare QUILT=1
  • Update patches from modified series: make package/foo/update
  • Automatically rebase patches after an update: make package/foo/refresh

Packaging considerations

  • Main objective is small memory and size footprint
  • Features that make no sense on embedded systems are disabled through configure or patched out
  • Packages must be compilable regardless of the host system, they should be self contained
  • Shipped “configure” scripts are often faulty or unusable in a cross-compile setting, autoreconf or patching is often needed
  • Build variants and kconfig includes allow for configurable compile-time settings
  • There is no standard way for porting software, in many cases it “just works” but often the package build process needs tweaks

Documentation

History

 

是否有所差異也◎

 

 

 

 

 

 

 

OpenWrt 的世界︰樹莓派 3B 【路由器】移星轉斗《五》編譯 一

為求盡快確認『樹莓派 3B+』當作 OpenWrt 開發系統之『可行性』 ?憑藉過往回憶,選擇了 16G 的 SD 卡【※約有 9-10 G 空間】!

然後依據

Quick Image Building Guide

文件打造

The build systemAbout

The build system is a set of Makefiles and patches that allows users to easily generate both a cross-compilation toolchain and a root filesystem for embedded systems. The cross-compilation toolchain uses musl, a tiny C standard library.

A compilation toolchain is the set of tools used to compile code for your system. It consists of:

  • a compiler (in our case, gcc )
  • binary utils like assembler and linker (in our case, binutils )
  • a C standard library (for example GNU Libc, musl-libc, uClibc or dietlibc).

A compilation toolchain generates code for the same processor’s instruction set architecture (ISA) it runs on (in the case of most PCs and servers, for an x86 processor).
On most Linux systems, the compilation toolchain uses the GNU libc as C standard library. This is called the “host compilation toolchain”, and the machine it is running on is called the “host system”. The host compilation toolchain is provided by the Linux distribution running on the host system, and has nothing to do with the actual build system.

Embedded systems use a different processor and require a cross-compilation toolchain – a compilation toolchain that runs on a host system but that generates code for a target system (and target processor’s instruction set architecture (ISA)). For example, if your host system uses x86 and your target system uses MIPS32, the cross-compilation toolchain runs on x86 but generates code for MIPS32.

While it is possible to manually configure and compile your own software, this is complex and does not guarantee reproducible builds. LEDE’s build system automates this process and provides a 100% reproducible build.

While the build system was designed for developers, inexperienced users can also use it to easily build their own custom firmware!

The build system’s Makefiles have their own syntax, different from the conventional Makefiles of Linux make tool.
The Makefiles define the meta information of the package, where to download the package, how to compile, where to install the compiled binaries, etc.

………

 

接著查詢『目標』︰

Raspberry Pi

The Raspberry Pi is a single-board computer without an Ethernet Network Switch. There are many more Single-board computers without one.

OpenWrt for Raspberry Pi 2 is compiled with the ARM hard-float kernel ABI (armhf). This means that non-integer math is done in hardware instead of in software. Raspberry Pi 1 (and Zero) support only soft-float (armel) which is slower than hard float.

Supported Versions

The Raspberry Pi is supported in the brcm2708 target.
Subtargets are bcm2708 for Raspberry Pi 1, bcm2709 for the Raspberry Pi 2, bcm2710 for the Raspberry Pi 3.

Model Version Current Release Unsupported Functions OEM Info Forum Topic Technical Data
Raspberry Pi A 18.06.1       View/Edit data
Raspberry Pi B 18.06.1       View/Edit data
Raspberry Pi B+ 18.06.1       View/Edit data
Raspberry Pi 2 B 18.06.1     forum.openwrt.org View/Edit data
Raspberry Pi 3 B 18.06.1 Country Code setting pi-3-model-b   View/Edit data
Raspberry Pi 3 B+ 18.06.1 Country Code setting, WiFi 2.4GHz, WiFi 5GHz, WIP pi-3-model-b-plus forum.openwrt.org View/Edit data
Raspberry Pi Zero W   18.06.1   pi-zero-wireless   View/Edit data

 

決定了︰

make menuconfig

“Target System” ⇒ “Broadcom BCM27xx”
“Subtarget” ⇒ “BCM2710 64 bit based boards”
“Target Profile” ⇒ “Raspberry Pi 3B/3B+”

 

心想樹莓派 3B+ 既有四顆 arm CPU 內核,何不用

make -j 4 呢☺

pi@raspberrypi:~/openwrt make -j 4 time: target/linux/prereq#0.32#0.11#0.42  make[1] world  make[2] tools/compile  make[2] package/cleanup  make[3] -C tools/flock compile  make[3] -C tools/sed compile  make[3] -C tools/patch compile  make[3] -C tools/xz compile  make[3] -C tools/tar compile  make[3] -C tools/m4 compile  make[3] -C tools/pkg-config compile  make[3] -C tools/expat compile  make[3] -C tools/sstrip compile  make[3] -C tools/patch-image compile  make[3] -C tools/scons compile  make[3] -C tools/mtools compile  make[3] -C tools/lzma compile  make[3] -C tools/autoconf compile  make[3] -C tools/missing-macros compile  make[3] -C tools/automake compile  make[3] -C tools/libressl compile  make[3] -C tools/dosfstools compile  make[3] -C tools/libtool compile  make[3] -C tools/cmake compile  make[3] -C tools/mkimage compile  make[3] -C tools/gmp compile  make[3] -C tools/libelf compile  make[3] -C tools/flex compile  make[3] -C tools/mklibs compile  make[3] -C tools/e2fsprogs compile  make[3] -C tools/mm-macros compile  make[3] -C tools/gengetopt compile  make[3] -C tools/patchelf compile  make[3] -C tools/mpfr compile  make[3] -C tools/bison compile  make[3] -C tools/findutils compile  make[3] -C tools/bc compile  make[3] -C tools/mpc compile ...</pre>    <img class="alignnone size-full wp-image-93081" src="http://www.freesandal.org/wp-content/uploads/pi@raspberrypi-top_1.png" alt="" width="737" height="518" />     <span style="color: #666699;">還可邀讀者想想</span> <div class="os-article__top"> <div class="os-article__top-inner"> <div class="panel-pane pane-node-title"> <h1><span style="color: #666699;"><a style="color: #666699;" href="https://opensource.com/article/18/6/embedded-linux-build-tools">4 tools for building embedded Linux systems</a></span></h1> </div> <div class="panel-pane pane-entity-field pane-node-field-article-subhead"> <div class="field field-name-field-article-subhead field-type-text-long field-label-hidden"> <div class="field-items"> <h2><span style="color: #ff9900;">Explore Yocto, Buildroot, OpenWRT, and adapted desktop distros to determine the right option for your project.</span></h2> </div> </div> </div> <div class="panel-pane pane-os-content-article-byline"> <div class="byline">  <span style="color: #808080;"><span class="byline__date">15 Jun 2018</span> <span class="byline__author-name"><a class="username" style="color: #808080;" title="View user profile." xml:lang="" href="https://opensource.com/users/drewmoseley">Drew Moseley</a> <span class="byline__feed"><a style="color: #808080;" href="https://opensource.com/user/233466/feed">Feed</a></span> </span></span> <div id="rate-node-45541-1-1" class="rate-widget-1 rate-widget clear-block rate-average rate-widget-thumbs_up rate-5b071800954428c09e83b5c45b481502 rate-node-45541-1-1 rate-processed"> <div class="rate-info"><span style="color: #808080;">51</span></div> <span style="color: #808080;"><a id="rate-button-1" class="rate-button rate-thumbs-up-btn-up" style="color: #808080;" title="up" href="https://opensource.com/article/18/6/embedded-linux-build-tools?rate=85BtO_Dp0DXA1MtBCFsLWxWAEd1Z0RO76uCg4psUojc" rel="nofollow">up</a></span>  </div> <span class="byline__comment-count" style="color: #808080;"><a style="color: #808080;" href="https://opensource.com/article/18/6/embedded-linux-build-tools#comments">1 comment</a></span>  </div> </div> </div> </div> <div class="os-article__image"> <div class="panel-pane pane-entity-field pane-node-field-lead-image"> <div class="field field-name-field-lead-image field-type-image field-label-hidden"> <div class="field-items"> <div class="field-item even"><img class="image-full-size" title="4 tools for building embedded Linux systems" src="https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/desk_clock_job_work.jpg?itok=Nj4fuhl6" alt="4 tools for building embedded Linux systems" width="520" height="292" /></div> </div> </div> </div> </div> <div class="field-label"><span style="color: #999999;">Image by :  opensource.com</span></div> <div class="os-article__top"></div> <span style="color: #008080;">Linux is being deployed into a much wider array of devices than Linus Torvalds anticipated when he was working on it in his dorm room. The variety of supported chip architectures is astounding and has led to Linux in devices large and small; from <a style="color: #008080;" href="https://en.wikipedia.org/wiki/Linux_on_z_Systems" target="_blank" rel="noopener noreferrer">huge IBM mainframes</a> to <a style="color: #008080;" href="http://www.picotux.com/" target="_blank" rel="noopener noreferrer">tiny devices</a> no bigger than their connection ports and everything in between. It is used in large enterprise data centers, internet infrastructure devices, and personal development systems. It also powers consumer electronics, mobile phones, and many Internet of Things devices.</span>  <span style="color: #008080;">When building Linux software for desktop and enterprise-class devices, developers typically use a desktop distribution such as <a style="color: #008080;" href="https://www.ubuntu.com/" target="_blank" rel="noopener noreferrer">Ubuntu</a> on their build machines to have an environment as close as possible to the one where the software will be deployed. Tools such as <a style="color: #008080;" href="https://www.virtualbox.org/" target="_blank" rel="noopener noreferrer">VirtualBox</a> and <a style="color: #008080;" href="https://www.docker.com/" target="_blank" rel="noopener noreferrer">Docker</a> allow even better alignment between development, testing, and productions environments.</span>  <span style="color: #808080;">………</span>     <span style="color: #666699;">優缺點比較!讀讀總覽︰</span> <h2 id="quick_overview_of_openwrt_s_internals" class="sectionedit2"><span style="color: #ff9900;">Quick overview of OpenWrt's internals</span></h2> <h2 id="overview" class="sectionedit1"><span style="color: #ff9900;"><a style="color: #ff9900;" href="https://openwrt.org/docs/guide-developer/overview">Overview</a></span></h2> <div class="level2">  <span style="color: #339966;">If you are already familiar with Linux systems, you will find your way pretty easily, if you are not, then we will need to start from basic concepts first.</span>  <span style="color: #339966;">You might have read that OpenWrt is a Linux distribution (or ``distro'') aimed at embedded devices.</span> <span style="color: #339966;"> A Linux ``<strong>distribution</strong>'' is a project that creates and maintains packages used to create a linux operating system tailored to the user's needs.</span> <span style="color: #339966;"> A ``<strong>package</strong>'' is a compressed archive containing a program or some scripts, its accompanying configuration files and also the information used to integrate it in the operating system. These packages are handled by a <strong>package manager</strong>, (opkg in OpenWrt) a program that downloads/opens/installs/uninstalls the packages.</span> <span style="color: #339966;"> So, a OpenWrt firmware is made by assembling packages around a Linux kernel.</span>  <span style="color: #339966;">Each package is compiled separately and then when it's all done the needed packages are ``installed'' in a temporary folder that will then be compressed to become the compressed-read-only partition (squashfs) in the device firmware.</span>  <span style="color: #339966;">Also the kernel is handled like a package, but is added to the firmware image in the special way each device's bootloader expects it, so you can replace the stock firmware without touching the bootloader itself (that is dangerous and not always possible).</span>  <span style="color: #339966;">The last step in the building process is actually creating a firmware file, (the files you use to install OpenWrt or to upgrade it).</span> <span style="color: #339966;"> This file is usually a disk image ready to be written raw in the internal flash storage of the device, so you will find many developers that just call it ``image'' on <abbr title="Internet Relay Chat">IRC</abbr> or in the mailing list.</span>  </div> <h3 id="how_a_package_is_compiled" class="sectionedit2"><span style="color: #339966;">How a package is compiled</span></h3> <div class="level3">  <span style="color: #339966;">If you look at a package Makefile (the file defining settings for building a specific package), <a class="urlextern" style="color: #339966;" title="https://github.com/openwrt/openwrt/blob/master/package/utils/busybox/Makefile" href="https://github.com/openwrt/openwrt/blob/master/package/utils/busybox/Makefile" rel="nofollow">https://github.com/openwrt/openwrt/blob/master/package/utils/busybox/Makefile</a> you will notice that it states the official download link for the sources that will be compiled, a SHA256 hash to check the integrity of such download, and two version numbers (one for upstream and one for OpenWrt). On some other packages it will state git commit/timestamp or other way to identify the same source to pull down and build. They generally favor archives with sources from official releases, but some upstream projects don't always have that.</span>  <span style="color: #339966;">In /patches folder of each package's folder you will find any patches that will be applied to the source after downloading it, before compiling it: <a class="urlextern" style="color: #339966;" title="https://github.com/openwrt/openwrt/tree/master/package/utils/busybox/patches" href="https://github.com/openwrt/openwrt/tree/master/package/utils/busybox/patches" rel="nofollow">https://github.com/openwrt/openwrt/tree/master/package/utils/busybox/patches</a> There are also other folders for configuration files or for uci integration (not always present).</span>  <span style="color: #339966;">The kernel's makefile is a bit more complex because of reasons, but you can see that it still uses the same structure, pulling down the same kernel version (depending from device) every time.<a class="urlextern" style="color: #339966;" title="https://github.com/openwrt/openwrt/blob/master/package/kernel/linux/Makefile" href="https://github.com/openwrt/openwrt/blob/master/package/kernel/linux/Makefile" rel="nofollow">https://github.com/openwrt/openwrt/blob/master/package/kernel/linux/Makefile</a></span>  <span style="color: #339966;">All packages are compiled by OpenWrt's own toolchain, which is again handled like packages (see /toolchain and /tools in the source) so you will always have the same compiler/tools as everyone else as they get downloaded from the same sources at the same version.</span>  <span style="color: #339966;">When you run a <strong>make</strong> the OpenWrt build system will use your system's existing building infrastructure to compile the OpenWrt's toolchain first, and then use that to compile the packages. This also has the major benefit of not requiring the user to set up a cross-compiling toolchain that is rather annoying and relatively complex.</span>  </div> <h3 id="package_feeds" class="sectionedit3"><span style="color: #339966;">Package feeds</span></h3> <div class="level3">  <span style="color: #339966;">Not all packages you can install in OpenWrt are from OpenWrt project proper, in fact most packages are not.</span>  <span style="color: #339966;">The packages from OpenWrt's main repository are maintained directly by core developers (and they are the more important or even essential components of OpenWrt firmware, or parts of the build system), and ``<strong>package feeds</strong>'' that are source repositories that contain additional packages, maintained by the community (each package has its own maintainer). This is OpenWrt's main repo (on github) <a class="urlextern" style="color: #339966;" title="https://github.com/openwrt/openwrt" href="https://github.com/openwrt/openwrt" rel="nofollow">https://github.com/openwrt/openwrt</a></span>  <span style="color: #339966;">These are official package feeds: <a class="urlextern" style="color: #339966;" title="https://github.com/openwrt/luci" href="https://github.com/openwrt/luci" rel="nofollow">https://github.com/openwrt/luci</a> <a class="urlextern" style="color: #339966;" title="https://github.com/openwrt/telephony" href="https://github.com/openwrt/telephony" rel="nofollow">https://github.com/openwrt/telephony</a> <a class="urlextern" style="color: #339966;" title="https://github.com/openwrt-routing/packages" href="https://github.com/openwrt-routing/packages" rel="nofollow">https://github.com/openwrt-routing/packages</a> <a class="urlextern" style="color: #339966;" title="https://github.com/openwrt/packages" href="https://github.com/openwrt/packages" rel="nofollow">https://github.com/openwrt/packages</a></span>  <span style="color: #339966;">Being ``official feeds'', the packages therein will be compiled and offered by the official download server, but they are not technically OpenWrt proper, they are community-maintained. The ``package feed'' system is designed to allow easy addition of your own custom feeds too in your custom firmware images, but you will have to compile them and host them on your own servers, of course.</span>  <span style="color: #339966;">If you look at the built packages here on the download server (this is the same server opkg uses to download packages in a live OpenWrt system), <a class="urlextern" style="color: #339966;" title="https://downloads.openwrt.org/releases/18.06.1/packages/x86_64/" href="https://downloads.openwrt.org/releases/18.06.1/packages/x86_64/" rel="nofollow">https://downloads.openwrt.org/releases/18.06.1/packages/x86_64/</a></span>  <span style="color: #339966;">They are divided by feed name, packages in ``base'' come from main repository, and also from main repository you get packages that are found in target-specific folders, like for example here<a class="urlextern" style="color: #339966;" title="https://downloads.openwrt.org/releases/18.06.1/packages/x86_64/packages/" href="https://downloads.openwrt.org/releases/18.06.1/packages/x86_64/packages/" rel="nofollow">https://downloads.openwrt.org/releases/18.06.1/packages/x86_64/packages/</a> that you see has mostly kmod-* and other drivers.</span>  </div> <h3 id="package_versions" class="sectionedit4"><span style="color: #339966;">Package Versions</span></h3> <div class="level3">  <span style="color: #339966;">As said above, package makefiles have PKG_VERSION that shows the upstream version (major version) and PKG_RELEASE that is used to show changes on the OpenWrt side (the minor version). If you see a package that lists version as 123-1, its major version is 123 and its minor version is 1.</span>  <span style="color: #339966;">Packages with a timestamp use that instead of major version, and they still have a minor version, for example 2016-09-21-42ad5367-1 where the last ``1'' is the minor version.</span>  <span style="color: #339966;">You can see all versions used in the first page of the table of packages in the wiki <a class="urlextern" style="color: #339966;" title="https://openwrt.org/packages/start" href="https://openwrt.org/packages/start" rel="nofollow">https://openwrt.org/packages/start</a></span>  <span style="color: #339966;">Or by browsing a Package.manifest in the package download folders <a class="urlextern" style="color: #339966;" title="https://downloads.openwrt.org/releases/18.06.1/packages/mips_24kc/base/Packages.manifest" href="https://downloads.openwrt.org/releases/18.06.1/packages/mips_24kc/base/Packages.manifest" rel="nofollow">https://downloads.openwrt.org/releases/18.06.1/packages/mips_24kc/base/Packages.manifest</a></span>  </div> <h3 id="repeatable_builds" class="sectionedit5"><span style="color: #339966;">Repeatable builds</span></h3> <div class="level3">  <span style="color: #339966;">Most of the above system allows repeatable builds, the hashes and time stamps of source archives or commits are written in the package's makefile in the git repository (either main repo or community package feeds), you can see full history of changes to that file with git.</span>  <span style="color: #339966;">There is a cache server that stores source archives because it's more convenient than having the build bots spamming upstream download servers and it is a fallback if the upstream download disappears, it should keep the source packages for a long while (as long as the release is supported for sure, as it is used by build bots).</span>  <span style="color: #339966;">It is here <a class="urlextern" style="color: #339966;" title="https://sources.openwrt.org/" href="https://sources.openwrt.org/" rel="nofollow">https://sources.openwrt.org/</a></span>  <span style="color: #339966;">Source cache server is <a class="urlextern" style="color: #339966;" title="https://downloads.openwrt.org/sources/" href="https://downloads.openwrt.org/sources/" rel="nofollow">https://downloads.openwrt.org/sources/</a></span>  </div> <span style="color: #808080;">………</span>     <span style="color: #666699;">,怎知卻遭遇莫名事件☻</span> <pre class="lang:default decode:true "> make[3] -C toolchain/gcc/initial compile make -r world: build failed. Please re-run make with -j1 V=s or V=sc for a higher verbosity level to see what's going on /home/pi/openwrt/include/toplevel.mk:216: recipe for target 'world' failed make: *** [world] Error 1 pi@raspberrypi:~/openwrt make
 make[1] world
 make[2] toolchain/compile
 make[3] -C toolchain/gdb compile
 make[3] -C toolchain/binutils compile
 make[3] -C toolchain/gcc/initial compile

【demsg】

[ 7002.114849] Workqueue: events_freezable mmc_rescan
[ 7002.114867] [<8079ef70>] (__schedule) from [<8079f5d8>] (schedule+0x50/0xa8)
[ 7002.114875] [<8079f5d8>] (schedule) from [<8061a2d0>] (__mmc_claim_host+0xb8/0x1cc)
[ 7002.114884] [<8061a2d0>] (__mmc_claim_host) from [<8061a414>] (mmc_get_card+0x30/0x34)
[ 7002.114891] [<8061a414>] (mmc_get_card) from [<80623010>] (mmc_sd_detect+0x20/0x74)
[ 7002.114898] [<80623010>] (mmc_sd_detect) from [<8061ccdc>] (mmc_rescan+0x1c8/0x394)
[ 7002.114907] [<8061ccdc>] (mmc_rescan) from [<801379b4>] (process_one_work+0x158/0x454)
[ 7002.114914] [<801379b4>] (process_one_work) from [<80137d14>] (worker_thread+0x64/0x5b8)
[ 7002.114921] [<80137d14>] (worker_thread) from [<8013dd98>] (kthread+0x13c/0x16c)
[ 7002.114930] [<8013dd98>] (kthread) from [<801080ac>] (ret_from_fork+0x14/0x28)

 

也只好鼻子摸著明天看結果吧★

pi@raspberrypi:~/openwrt $ make
 make[1] world
 make[2] toolchain/compile
 make[3] -C toolchain/gdb compile
 make[3] -C toolchain/binutils compile
 make[3] -C toolchain/gcc/initial compile
 make[3] -C toolchain/kernel-headers compile
 make[3] -C toolchain/musl compile
 make[3] -C toolchain/gcc/final compile
...

 

 

 

 

 

 

 

 

OpenWrt 的世界︰樹莓派 3B 【路由器】移星轉斗《五》編譯

OpenWrt 旅程即將結束之際,踟躕著怎樣介紹『編譯』環境也☻

Quick Image Building Guide

This is a very short guide on how to compile your first OpenWrt snapshot firmware. It does not cover any pitfalls, but provides a quick way if everything goes well. Alternative guides to achieving the same goal: Using the Image Builder, Beginners guide to building your own firmware.

The development branch can contain experimental code that is under active development and should not be used for production environments. Snapshot images may support additional hardware; however, it is experimental, considered unstable, and sometimes won’t compile.

Prebuilt snapshot images do not come with any web interface or GUI. You will need to be comfortable using a command line and remote shell to install one yourself →How to install LuCI

→ Read more…

First we need to make sure the dependencies are installed (for Debian/Ubuntu):

sudo apt-get install subversion g++ zlib1g-dev build-essential git python rsync man-db
sudo apt-get install libncurses5-dev gawk gettext unzip file libssl-dev wget zip time

Get the OpenWrt source code:

git clone https://git.openwrt.org/openwrt/openwrt.git/
cd openwrt

./scripts/feeds update -a
./scripts/feeds install -a

make menuconfig

The last command will open a menu.

If you want to build images for the “TL-WR841N v11” Wifi-Router, select:

  • “Target System” ⇒ “Atheros AR7xxx/AR9xxx”
  • “Target Profile” ⇒ “TP-LINK TL-WR841N/ND v11”

Select exit and save your settings. Now build images. That may take some time:

make

Afterwards, the images can be found in ./bin/targets/ar71xx/generic/ – done. 8-)

  • The *-factory.bin images are for the first installation.
  • The *-sysupgrade.bin images are for the updating existing OpenWrt installations.

Notes:

  • For recompiling the images, just execute make again.
  • For faster compiling, use make -j N, where N is the number of CPU cores + 1. Be aware that this method is prone to errors during compiling. In case you encounter compile errors, your very first step is to compile again without -j N. Use of make download prior to parallel compilation is recommended to prevent some of these errors (-jN is generally safe for the download step for those with faster Internet connectivity.)
  • Change settings with make menuconfig and compile again.
  • You can include custom files in your image by placing them in <buildroot>/files, e.g. if you want to have my_config included in your image in the directory /etc/config/<buildroot>/files/etc/config/my_config. If the filesdirectory doesn’t exist on your buildsystem, then create it.

 

由於過去經驗,總落在 x86

Using the toolchain

 

裡!日前見着

A NEW RASPBIAN UPDATE: MULTIMEDIA, PYTHON AND MORE

Posted by Simon Long
Senior Principal Software Engineer
UX engineer & cruciverbalist

Today we’re releasing a new update for Raspbian, including a multimedia player, updated Thonny, and more. Here’s Simon with everything you need to know.

 

嘗試玩後

Raspbian Stretch with desktop and recommended software

RASPBIAN STRETCH WITH DESKTOP AND RECOMMENDED SOFTWARE

Image with desktop and recommended software based on Debian Stretch
Version:November 2018
Release date:2018-11-13
Kernel version:4.14
Release notes:Link

 

儼然一台小 PC 呦?

何不嘗試把它當成 PC 呢☺

 

 

 

 

 

 

 

OpenWrt 的世界︰樹莓派 3B 【路由器】移星轉斗《四‧七》FruityWiFi

樹莓λ

人參果

Raspberryλ◇樹莓λ
傳說中的概念人參果是一種抽象神器!!

西遊記  明 ‧ 吳承恩  第二十四回
萬壽山大仙留故友 五莊觀行者竊人參

卻說這座山名喚萬壽山,山中有一座觀,名喚五莊觀,觀裏有一尊仙,道號鎮元子,混名與世同君。那觀裏出一般異寶,乃是混沌初分,鴻濛始判,天地末開之際,產成這顆靈根。蓋天下四大部洲,惟西牛賀洲五莊觀出此,喚名「草還丹」,又名「人參果」。三千年一開花,三千年一結果,再三千年才得熟,短頭一萬年方得喫。似這萬年,只結得三十個果子。果子的模樣,就如三朝未滿的小孩相似,四肢俱全,五官咸備。人若有緣,得那果子聞了一聞,就活三百六十歲:喫一個,就活四萬七千年。

─── 《RASPBERRYΛ◇樹莓Λ

 

雖說已經談過許多『網路攻防』軟件,一直沒有正寫『無線網路』工具。特於篇章結尾之時,介紹一下這個『水果味 WiFi』!

OVERVIEW

FruityWifi is an open source tool to audit wireless networks. It allows the user to deploy advanced attacks by directly using the web interface or by sending messages to it.

Initialy the application was created to be used with the Raspberry-Pi, but it can be installed on any Debian based system.

FruityWifi v2.0 has many upgrades. A new interface, new modules, Realtek chipsets support, Mobile Broadband (3G/4G) support, a new control panel, and more.

A more flexible control panel. Now it is possible to use FruityWifi combining multiple networks and setups:

– Ethernet Ethernet,
– Ethernet 3G/4G,
– Ethernet Wifi,
– Wifi Wifi,
– Wifi 3G/4G, etc.

Within the new options on the control panel we can change the AP mode between Hostapd or Airmon-ng allowing to use more chipsets like Realtek.

It is possible customize each one of the network interfaces which allows the user to keep the current setup or change it completely.

……

 

原本種於樹莓派園子裡,後會五行通,四野已生根?

/FruityWifi

FruityWiFi is a wireless network auditing tool. The application can be installed in any Debian based system (Jessie) adding the extra packages. Tested in Debian, Kali Linux, Kali Linux ARM (Raspberry Pi), Raspbian (Raspberry Pi), Pwnpi (Raspberry Pi), Bugtraq, NetHunter.http://www.fruitywifi.com

FruityWiFi

Wireless network auditing tool http://www.fruitywifi.com/

Important Note (Debian Stretch):

Use Debian Jessie based systems until I can update dependencies for Debian Stretch.

FruityWifi is an open source tool to audit wireless networks. It allows the user to deploy advanced attacks by directly using the web interface or by sending messages to it.

Initialy the application was created to be used with the Raspberry-Pi, but it can be installed on any Debian based system.

Status

A more flexible control panel. Now it is possible to use FruityWifi combining multiple networks and setups:

Within the new options on the control panel we can change the AP mode between Hostapd or Airmon-ng allowing to use more chipsets like Realtek.

It is possible customize each one of the network interfaces which allows the user to keep the current setup or change it completely.

Config

FruityWifi is based on modules making it more flexible. These modules can be installed from the control panel to provide FruityWifi with new functionalities.

Within the available modules you can find URLsnarf, DNSspoof, Kismet, mdk3, ngrep, nmap, Squid3 y SSLstrip (code injection functionality), Captive Portal, AutoSSH, Meterpreter, Tcpdump and more.

Note: New modules are being developed continuously and can be installed from the modules page.

───

 

Kali Linux 中更優遊自在☺

Install

Kali Linux Version

FruityWifi is now part of Kali Linux repositories.

  • apt-get install fruitywifi
  • /etc/init.d/fruitywifi start
  • /etc/init.d/php5-fpm start

Go to http://localhost:8000 (for http)
Go to https://localhost:8443 (for https)

user: admin
pass: admin

Note: installing fruitywifi will install all modules. If you want to install only some modules, you can install fruitywifi-core first and then each module, for example fruitywifi-module-dnsspoof.

 

追跡雪泥鴻爪

root@kali:~# /etc/init.d/fruitywifi start
[ ok ] Starting fruitywifi (via systemctl): fruitywifi.service.

root@kali:~# /etc/init.d/php7.2-fpm start
[ ok ] Starting php7.2-fpm (via systemctl): php7.2-fpm.service.

root@kali:~# firefox http://localhost:8000

 

自可一睹顏容☀