0%

Just finished reviewing a paper talking about Electrocardiography (ECG) biometrics 10 minutes ago. Let’s continue having some fun of ECG right away.

Fundamental Knowledge About ECG

Details can be found on ACLS Medical Training. Let’s cite the key graph as follows:

ECG Basics

BioSPPy

BioSppy is a Python tool which can display various types of biosignals. Its source code can be found on github.

Installation

1
2
3
4
5
6
7
8
9
10
11
12
13
➜  ~ pip install -U biosppy --user
......
➜ ~ pip show biosppy
Name: biosppy
Version: 0.6.1
Summary: A toolbox for biosignal processing written in Python.
Home-page: https://github.com/PIA-Group/BioSPPy
Author: Instituto de Telecomunicacoes
Author-email: carlos.carreiras@lx.it.pt
License: BSD 3-clause
Location: /home/lvision/.local/lib/python3.7/site-packages
Requires: scipy, numpy, matplotlib, scikit-learn, h5py, six, shortuuid, bidict
Required-by:

Test

A sample ECG data can be found at BioSPPy example.

1
2
3
4
5
6
7
8
from biosppy import storage
from biosppy.signals import ecg

# load raw ECG signal
signal, mdata = storage.load_txt('./examples/ecg.txt')

# process it and plot
out = ecg.ecg(signal=signal, sampling_rate=1000., show=True)

ECG Summary

Three things you need to verify:

1. Contents In File /usr/share/qtchooser/qt5-x86_64-linux-gnu.conf

1
2
3
4
5
6
7
8
9
➜  ~ cd /usr/share/qtchooser
➜ qtchooser ls
qt4-x86_64-linux-gnu.conf qt5-x86_64-linux-gnu.conf
➜ qtchooser cat qt4-x86_64-linux-gnu.conf
/usr/lib/x86_64-linux-gnu/qt4/bin
/usr/lib/x86_64-linux-gnu
➜ qtchooser cat qt5-x86_64-linux-gnu.conf
/opt/Qt/Current/gcc_64/bin
/opt/Qt/Current/gcc_64/lib

2. Use Qt5 By Default: /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf

1
2
3
4
5
6
7
➜  qtchooser cd /usr/lib/x86_64-linux-gnu/qt-default/qtchooser 
➜ qtchooser ll
total 0
lrwxrwxrwx 1 root root 53 Apr 5 21:21 default.conf -> ../../../../share/qtchooser/qt5-x86_64-linux-gnu.conf
➜ qtchooser cat default.conf
/opt/Qt/Current/gcc_64/bin
/opt/Qt/Current/gcc_64/lib

3. Doublecheck /usr/lib/x86_64-linux-gnu/qtchooser

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
➜  qtchooser cd /usr/lib/x86_64-linux-gnu/qtchooser
➜ qtchooser pwd
/usr/lib/x86_64-linux-gnu/qtchooser
➜ qtchooser ll
total 0
lrwxrwxrwx 1 root root 50 Dec 21 2017 4.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 Dec 21 2017 5.conf -> ../../../share/qtchooser/qt5-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 Dec 21 2017 qt4.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 Dec 21 2017 qt5.conf -> ../../../share/qtchooser/qt5-x86_64-linux-gnu.conf
➜ qtchooser cat 4.conf
/usr/lib/x86_64-linux-gnu/qt4/bin
/usr/lib/x86_64-linux-gnu
➜ qtchooser cat 5.conf
/opt/Qt/Current/gcc_64/bin
/opt/Qt/Current/gcc_64/lib

Today I’d love to talk about Pixy Cam a bit, which I do NOT recommend at all. There are several reasons:

  • Price: As you can see from Amazon, it’s comparatively expensive, $95 USD.
  • Warranty period: 90 days from date of purchase
  • Size: too big

Actually, I purchased PIXY (with pan tilt mount base) in 2016 from amazon.com. However, it went died long time ago. What’s more, I’ve tested ALL possible solutions from Pixycam Troubleshooting, but the 90-day warranty is easy to pass.

I do NOT want to talk more about Pixy Cam, and here is **my conclusion:
Please use esp32-cam instead.

It’s almost July 10, let me continue testing something else: OpenMV. I used to have purchased 2 OpenMV cameras, respectively:

No matter which version of OpenMV is connected to the laptop via USB, command lsusb is able to list the device out as:

1
Bus 001 Device 020: ID 1209:abd1 InterBiometrics 

Dilemma of OpenMV-IDE

Conclusion FIRST: NEVER build OpenMV-IDE from scratch using a different version of Qt!!!

To build OpenMV-IDE is seriously headache.

1
2
3
4
5
6
7
➜  openmv ./openmv-ide-linux-x86_64-2.2.0.run
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, xcb.

Reinstalling the application may fix this problem.

Test OpenMV

In the following, we ONLY use picocom to carry out the test.

1. OpenMV Cam M4 V2 (OPENMV2 with STM32F427)

Current Contents In OpenMV Cam M4 V2

OpenMV Cam M4 V2 Properties

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
➜  ~ picocom /dev/ttyACM0
picocom v3.1

port is : /dev/ttyACM0
flowcontrol : none
baudrate is : 9600
parity is : none
databits are : 8
stopbits are : 1
escape is : C-a
local echo is : no
noinit is : no
noreset is : no
hangup is : no
nolock is : no
send_cmd is : sz -vv
receive_cmd is : rz -vv -E
imap is :
omap is :
emap is : crcrlf,delbs,
logfile is : none
initstring : none
exit_after is : not set
exit is : no

Type [C-a] [C-h] to see available commands
Terminal ready
MicroPython v1.9.3-4922-ge0f81c867 on 2018-04-23; OPENMV2 with STM32F427
Type "help()" for more information.
>>>

Press Ctrl+A then Ctrl+x, picocom will terminate its execution.

1
2
3
>>> 
Terminating...
Thanks for using picocom

2. OpenMV Cam M7 (OPENMV3 with STM32F765)

Current Contents In OpenMV Cam M7

OpenMV Cam M7 Properties

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
➜  ~ picocom /dev/ttyACM0
picocom v3.1

port is : /dev/ttyACM0
flowcontrol : none
baudrate is : 9600
parity is : none
databits are : 8
stopbits are : 1
escape is : C-a
local echo is : no
noinit is : no
noreset is : no
hangup is : no
nolock is : no
send_cmd is : sz -vv
receive_cmd is : rz -vv -E
imap is :
omap is :
emap is : crcrlf,delbs,
logfile is : none
initstring : none
exit_after is : not set
exit is : no

Type [C-a] [C-h] to see available commands
Terminal ready
MicroPython v1.9.4-4510-g23e8457de on 2018-06-29; OPENMV3 with STM32F765
Type "help()" for more information.
>>>
Terminating...
Thanks for using picocom
➜ ~

Flash OpenMV Firmware Onto OpenMV Board

1. Entering DFU Mode

Similar to what’s discussed in our previous blog, we need to enter DFU mode before flashing.

  • Disconnect the power for OpenMV board FIRST
  • Connect BOOT pin and RST pin afterwards
  • Then, reconnect the USB cable for flashing.

Before entering DFU mode:

1
2
3
4
➜  ~ lsusb
...
Bus 001 Device 027: ID 1209:abd1 InterBiometrics
...

After entering DFU mode:

1
2
3
4
➜  ~ lsusb
...
Bus 001 Device 028: ID 0483:df11 STMicroelectronics STM Device in DFU Mode
...

2. Flashing OpenMV’s Firmware

Checkout the NEWEST OpenMV. Find the corrensponding version of OpenMV board, flash it by command python pydfu.py -u <firmware.dfu>.

1) OpenMV Cam M4 V2 (OPENMV2 with STM32F427)

1
2
3
4
5
6
7
8
9
10
11
➜  openmv git:(master) python ./tools/pydfu.py -u firmware/OPENMV2/firmware.dfu 
./tools/pydfu.py:80: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
if 'length' in inspect.getargspec(usb.util.get_string).args:
File: firmware/OPENMV2/firmware.dfu
b'DfuSe' v1, image size: 834757, targets: 1
b'Target' 0, alt setting: 0, name: "ST...", size: 834472, elements: 1
0, address: 0x08010000, size: 834464
usb: 0483:df11, device: 0x0000, dfu: 0x011a, b'UFD', 16, 0x9dfe8e73
Writing memory...
0x08010000 834464 [=========================] 100%
Exiting DFU...

Let’s try picocom directly:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
➜  openmv git:(master) picocom /dev/ttyACM0
picocom v3.1

port is : /dev/ttyACM0
flowcontrol : none
baudrate is : 9600
parity is : none
databits are : 8
stopbits are : 1
escape is : C-a
local echo is : no
noinit is : no
noreset is : no
hangup is : no
nolock is : no
send_cmd is : sz -vv
receive_cmd is : rz -vv -E
imap is :
omap is :
emap is : crcrlf,delbs,
logfile is : none
initstring : none
exit_after is : not set
exit is : no

Type [C-a] [C-h] to see available commands
Terminal ready
6792
18.86792
18.86792
18.86792
18.86792
18.86792
18.86792
......
Traceback (most recent call last):
File "/main.py", line 51, in <module>
KeyboardInterrupt:
MicroPython v1.9.4-4553-gb4eccdfe3 on 2019-05-02; OPENMV2 with STM32F427
Type "help()" for more information.
>>>
Terminating...
Thanks for using picocom

Check file main.py, which starts running automatically while testing with picocom.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Face Detection Example
#
# This example shows off the built-in face detection feature of the OpenMV Cam.
#
# Face detection works by using the Haar Cascade feature detector on an image. A
# Haar Cascade is a series of simple area contrasts checks. For the built-in
# frontalface detector there are 25 stages of checks with each stage having
# hundreds of checks a piece. Haar Cascades run fast because later stages are
# only evaluated if previous stages pass. Additionally, your OpenMV Cam uses
# a data structure called the integral image to quickly execute each area
# contrast check in constant time (the reason for feature detection being
# grayscale only is because of the space requirment for the integral image).

import sensor, time, image

# Reset sensor
sensor.reset()

# Sensor settings
sensor.set_contrast(1)
sensor.set_gainceiling(16)
# HQVGA and GRAYSCALE are the best for face tracking.
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)

# Load Haar Cascade
# By default this will use all stages, lower satges is faster but less accurate.
face_cascade = image.HaarCascade("frontalface", stages=25)
print(face_cascade)

# FPS clock
clock = time.clock()

while (True):
clock.tick()

# Capture snapshot
img = sensor.snapshot()

# Find objects.
# Note: Lower scale factor scales-down the image more and detects smaller objects.
# Higher threshold results in a higher detection rate, with more false positives.
objects = img.find_features(face_cascade, threshold=0.75, scale_factor=1.25)

# Draw objects
for r in objects:
img.draw_rectangle(r)

# Print FPS.
# Note: Actual FPS is higher, streaming the FB makes it slower.
print(clock.fps())

2) OpenMV Cam M7 (OPENMV3 with STM32F765)

1
2
3
4
5
6
7
8
9
10
11
➜  openmv git:(master) python ./tools/pydfu.py -u firmware/OPENMV3/firmware.dfu
./tools/pydfu.py:80: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
if 'length' in inspect.getargspec(usb.util.get_string).args:
File: firmware/OPENMV3/firmware.dfu
b'DfuSe' v1, image size: 1297173, targets: 1
b'Target' 0, alt setting: 0, name: "ST...", size: 1296888, elements: 1
0, address: 0x08020000, size: 1296880
usb: 0483:df11, device: 0x0000, dfu: 0x011a, b'UFD', 16, 0xeff0bf62
Writing memory...
0x08020000 1296880 [=========================] 100%
Exiting DFU...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
➜  openmv git:(master) picocom /dev/ttyACM0
picocom v3.1

port is : /dev/ttyACM0
flowcontrol : none
baudrate is : 9600
parity is : none
databits are : 8
stopbits are : 1
escape is : C-a
local echo is : no
noinit is : no
noreset is : no
hangup is : no
nolock is : no
send_cmd is : sz -vv
receive_cmd is : rz -vv -E
imap is :
omap is :
emap is : crcrlf,delbs,
logfile is : none
initstring : none
exit_after is : not set
exit is : no

Type [C-a] [C-h] to see available commands
Terminal ready
MicroPython v1.9.4-4553-gb4eccdfe3 on 2019-05-02; OPENMV3 with STM32F765
Type "help()" for more information.
>>>
Terminating...
Thanks for using picocom
➜ openmv git:(master)

As you can see, firmware has NOW been updated to MicroPython v1.9.4-4553-gb4eccdfe3 on 2019-05-02.

Stream OpenMV Video without OpenMV-IDE

1. Snapshot

We FIRST test OpenMV snapshot code on OpenMV Cam M4 V2 (OPENMV2 with STM32F427).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Snapshot Example
#
# Note: You will need an SD card to run this example.
#
# You can use your OpenMV Cam to save image files.

import sensor, image, pyb

RED_LED_PIN = 1
BLUE_LED_PIN = 3

sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others)
sensor.skip_frames(time = 2000) # Let new settings take affect.

pyb.LED(RED_LED_PIN).on()
sensor.skip_frames(time = 2000) # Give the user time to get ready.

pyb.LED(RED_LED_PIN).off()
pyb.LED(BLUE_LED_PIN).on()

print("You're on camera!")
sensor.snapshot().save("example.jpg") # or "example.bmp" (or others)

pyb.LED(BLUE_LED_PIN).off()
print("Done! Reset the camera to see the saved image.")

Snapshot on OpenMV Cam M4 V2

2. Video Recording

We THEN test OpenMV video recording on OpenMV Cam M7 (OPENMV3 with STM32F765).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# MJPEG Video Recording Example
#
# Note: You will need an SD card to run this demo.
#
# You can use your OpenMV Cam to record mjpeg files. You can either feed the
# recorder object JPEG frames or RGB565/Grayscale frames. Once you've finished
# recording a Mjpeg file you can use VLC to play it. If you are on Ubuntu then
# the built-in video player will work too.

import sensor, image, time, mjpeg, pyb

RED_LED_PIN = 1
BLUE_LED_PIN = 3

sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others)
sensor.skip_frames(time = 2000) # Let new settings take affect.
clock = time.clock() # Tracks FPS.

pyb.LED(RED_LED_PIN).on()
sensor.skip_frames(time = 2000) # Give the user time to get ready.

pyb.LED(RED_LED_PIN).off()
pyb.LED(BLUE_LED_PIN).on()

m = mjpeg.Mjpeg("example.mjpeg")

print("You're on camera!")
for i in range(200):
clock.tick()
m.add_frame(sensor.snapshot())
print(clock.fps())

m.close(clock.fps())
pyb.LED(BLUE_LED_PIN).off()
print("Done! Reset the camera to see the saved recording.")

Video recorded on OpenMV Cam M7

It looks it’s NOT easy to demo with the SD card. Please refer to my symptoms on the OpenMV forum.

3. Wifi Module

As expected, OpenMV NOW also privides its Wifi module now. Let’s just test the example code from openmv’s repo.

OpenMV Wifi Shield Connection

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Connect Example
#
# This example shows how to connect your OpenMV Cam with a WiFi shield to the net.

import network

SSID='' # Network SSID
KEY='' # Network key

# Init wlan module and connect to network
print("Trying to connect... (may take a while)...")

wlan = network.WINC()
wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)

# We should have a valid IP now via DHCP
print(wlan.ifconfig())

However, it’s NOT that handy to have the Wifi module tested.

My conclusion: Please use esp32-cam instead.

Skill 3 Embed Jupyter Notebook into Hexo Post

I got the Intel Wireless-AC 9260 today, and a proper 128G micro SD card, finally… Let’s try out Jetson Nano.

PART A: Install JetPack onto Jetson Nano

Let’s simply use the command dd to have JetPack installed onto the micro SD card as follows:

1
2
3
4
5
➜  JetPack sudo dd bs=4M if=jetson-nano-sd-r32.1.1-2019-05-31.img of=/dev/mmcblk0 conv=fsync
[sudo] password for lvision:
3072+0 records in
3072+0 records out
12884901888 bytes (13 GB, 12 GiB) copied, 311.804 s, 41.3 MB/s

PART B: Boot Into Jetson Nano and Test it Out

1. First Boot

It seems GUI is a must for Jetson Nano’s FIRST BOOT, which is ignored in this blog.

2. SSH into Jetson Nano

For now, Jetson Nano is wired connected onto the Internet. And it seems Intel Wireless-AC 9260 is NOT working properly with Jetson Nano yet. Details can be found at https://devtalk.nvidia.com/default/topic/1050449/jetson-nano/intel-9260-wifi-on-jetson-nano-jetbot

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
➜  ~ ssh lvision@192.168.1.71
lvision@192.168.1.71's password:
Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.9.140-tegra aarch64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, you can run the 'unminimize' command.

450 packages can be updated.
210 updates are security updates.

Last login: Sat Jul 6 18:41:11 2019 from 192.168.1.200
lvision@lvision-desktop:~$

3. Check JetPack OS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
lvision@lvision-desktop:~$ uname -a
Linux lvision-desktop 4.9.140-tegra #1 SMP PREEMPT Wed Mar 13 00:32:22 PDT 2019 aarch64 aarch64 aarch64 GNU/Linux
lvision@lvision-desktop:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
ilvision@lvision-desktop:~$ ip -c address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 9a:c2:3a:84:96:66 brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:04:4b:e4:12:59 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.71/24 brd 192.168.1.255 scope global dynamic noprefixroute eth0
valid_lft 85183sec preferred_lft 85183sec
inet6 2001:569:7ef8:d600:858b:9c23:db05:7b3a/64 scope global temporary dynamic
valid_lft 7476sec preferred_lft 7176sec
inet6 2001:569:7ef8:d600:509c:9fe9:1cb7:2b7f/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 7476sec preferred_lft 7176sec
inet6 fe80::1714:cd7d:771d:a4/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: rndis0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master l4tbr0 state DOWN group default qlen 1000
link/ether da:d4:ee:c5:ed:e9 brd ff:ff:ff:ff:ff:ff
5: usb0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master l4tbr0 state DOWN group default qlen 1000
link/ether da:d4:ee:c5:ed:eb brd ff:ff:ff:ff:ff:ff
6: l4tbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether da:d4:ee:c5:ed:e9 brd ff:ff:ff:ff:ff:ff
inet 192.168.55.1/24 brd 192.168.55.255 scope global l4tbr0
valid_lft forever preferred_lft forever
inet6 fe80::1/128 scope link
valid_lft forever preferred_lft forever
inet6 fe80::a495:bff:fe21:2ad0/64 scope link
valid_lft forever preferred_lft forever

4. Update and Upgrade All Upgradable Packages

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
lvision@lvision-desktop:~$ sudo apt upgrade
[sudo] password for lvision:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
apt-clone archdetect-deb busybox-static cryptsetup-bin dpkg-repack gir1.2-timezonemap-1.0 gir1.2-xkl-1.0 grub-common
kde-window-manager kinit kio kpackagetool5 kwayland-data kwin-common kwin-data kwin-x11 libdebian-installer4 libkdecorations2-5v5
libkdecorations2private5v5 libkf5activities5 libkf5attica5 libkf5completion-data libkf5completion5 libkf5declarative-data
libkf5declarative5 libkf5doctools5 libkf5globalaccel-data libkf5globalaccel5 libkf5globalaccelprivate5 libkf5idletime5
libkf5jobwidgets-data libkf5jobwidgets5 libkf5kcmutils-data libkf5kcmutils5 libkf5kiocore5 libkf5kiontlm5 libkf5kiowidgets5
libkf5newstuff-data libkf5newstuff5 libkf5newstuffcore5 libkf5package-data libkf5package5 libkf5plasma5 libkf5quickaddons5
libkf5solid5 libkf5solid5-data libkf5sonnet5-data libkf5sonnetcore5 libkf5sonnetui5 libkf5textwidgets-data libkf5textwidgets5
libkf5waylandclient5 libkf5waylandserver5 libkf5xmlgui-bin libkf5xmlgui-data libkf5xmlgui5 libkscreenlocker5
libkwin4-effect-builtins1 libkwineffects11 libkwinglutils11 libkwinxrenderutils11 libllvm6.0 libqgsttools-p1 libqt5designer5
libqt5help5 libqt5multimedia5 libqt5multimedia5-plugins libqt5multimediaquick-p5 libqt5multimediawidgets5 libqt5opengl5
libqt5positioning5 libqt5printsupport5 libqt5qml5 libqt5quick5 libqt5quickwidgets5 libqt5sensors5 libqt5sql5 libqt5test5
libqt5webchannel5 libqt5webkit5 libxcb-composite0 libxcb-cursor0 libxcb-damage0 os-prober python3-dbus.mainloop.pyqt5 python3-icu
python3-pam python3-pyqt5 python3-pyqt5.qtsvg python3-pyqt5.qtwebkit python3-sip qml-module-org-kde-kquickcontrolsaddons
qml-module-qtmultimedia qml-module-qtquick2 rdate
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
containerd gstreamer1.0-gtk3 libdrm-etnaviv1 libllvm8 python3-dateutil runc
The following packages will be upgraded:
......
Setting up update-notifier (3.192.1.7) ...
Setting up ubuntu-desktop (1.417.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for resolvconf (1.79ubuntu10.18.04.3) ...
Processing triggers for initramfs-tools (0.130ubuntu3.8) ...
update-initramfs: Generating /boot/initrd.img-4.9.140-tegra
Warning: couldn't identify filesystem type for fsck hook, ignoring.
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/aarch64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/aarch64-linux-gnu_GL.conf: No such file or directory
Processing triggers for dbus (1.12.2-1ubuntu1.1) ...

Happy 2019’s Canada Day.

Happy Canada Day

Having simply demoed two Arduino-controlled robotic arms the other day, I had some videos updated onto Longer Vision Robot’s Facebook today, namely, 2019’s Canada Day.

Overview of OWI 535 Cable Connection to Arduino

OWI 535 Cable Connection & Arduino IDE

Triggered Motor Actions

Metal Robotic Arm Left/Right Turn Metal Robotic Arm Clipper Motor - Open/Close
Metal Robotic Arm Left/Right Turn Metal Robotic Arm Clipper Motor - Open/Close
OWI 535 Clipper Motor - Open/Close OWI 535 Motor Upper Knot
OWI 535 Clipper Motor - Open/Close OWI 535 Motor Upper Knot
OWI 535 Motor Middle Knot OWI 535 Motor Lower Knot
OWI 535 Motor Middle Knot OWI 535 Motor Lower Knot

By following our previous blog Build GCC, we should be able to CROSS-BUILD GCC for various ARM architectures. Today, we are building GCC 9.1.0 for Hikey 970, which is of aarch64 architecture. (More details about aarch64 can be found on ARM architecture )

Start Building

Binutils

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
➜  aarch64 mkdir build-binutils
➜ aarch64 cd build-binutils
lvision@hikey970:~/Downloads/Programming/GCC/build-binutils$ ../binutils-2.32/configure --prefix=/opt/aarch64 --enable-shared --enable-vtable-verify
checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking target system type... aarch64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... yes
checking for gnatbind... gnatbind
checking for gnatmake... gnatmake
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for isl 0.15 or later... yes
checking for default BUILD_CONFIG...
checking for --enable-vtable-verify... yes
checking for bison... bison -y
checking for bison... bison
checking for gm4... no
checking for gnum4... no
checking for m4... m4
checking for flex... flex
checking for flex... flex
checking for makeinfo... makeinfo
checking for expect... expect
checking for runtest... no
checking for ar... ar
checking for as... as
checking for dlltool... no
checking for ld... ld
checking for lipo... no
checking for nm... nm
checking for ranlib... ranlib
checking for strip... strip
checking for windres... no
checking for windmc... no
checking for objcopy... objcopy
checking for objdump... objdump
checking for readelf... readelf
checking for cc... cc
checking for c++... c++
checking for gcc... gcc
checking for gfortran... gfortran
checking for gccgo... gccgo
checking for ar... ar
checking for as... as
checking for dlltool... no
checking for ld... ld
checking for lipo... no
checking for nm... nm
checking for objcopy... objcopy
checking for objdump... objdump
checking for ranlib... ranlib
checking for readelf... readelf
checking for strip... strip
checking for windres... no
checking for windmc... no
checking where to find the target ar... just compiled
checking where to find the target as... just compiled
checking where to find the target cc... host tool
checking where to find the target c++... host tool
checking where to find the target c++ for libstdc++... host tool
checking where to find the target dlltool... just compiled
checking where to find the target gcc... host tool
checking where to find the target gfortran... host tool
checking where to find the target gccgo... host tool
checking where to find the target ld... just compiled
checking where to find the target lipo... host tool
checking where to find the target nm... just compiled
checking where to find the target objcopy... just compiled
checking where to find the target objdump... just compiled
checking where to find the target ranlib... just compiled
checking where to find the target readelf... just compiled
checking where to find the target strip... just compiled
checking where to find the target windres... just compiled
checking where to find the target windmc... just compiled
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile
➜ build-binutils make -j4
......
➜ build-binutils make install
➜ build-binutils cd ..

Linux Kernel Headers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
➜  aarch64 cd linux-5.1.12
➜ linux-5.1.12 make ARCH=arm64 INSTALL_HDR_PATH=/opt/aarch64/aarch64-linux headers_install
INSTALL include/asm-generic (36 files)
INSTALL include/drm (26 files)
INSTALL include/linux/android (2 files)
INSTALL include/linux/byteorder (2 files)
INSTALL include/linux/caif (2 files)
INSTALL include/linux/can (6 files)
INSTALL include/linux/cifs (1 file)
INSTALL include/linux/dvb (8 files)
INSTALL include/linux/genwqe (1 file)
INSTALL include/linux/hdlc (1 file)
INSTALL include/linux/hsi (2 files)
INSTALL include/linux/iio (2 files)
INSTALL include/linux/isdn (1 file)
INSTALL include/linux/mmc (1 file)
INSTALL include/linux/netfilter/ipset (4 files)
INSTALL include/linux/netfilter (88 files)
INSTALL include/linux/netfilter_arp (2 files)
INSTALL include/linux/netfilter_bridge (17 files)
INSTALL include/linux/netfilter_ipv4 (9 files)
INSTALL include/linux/netfilter_ipv6 (13 files)
INSTALL include/linux/nfsd (5 files)
INSTALL include/linux/raid (2 files)
INSTALL include/linux/sched (1 file)
INSTALL include/linux/spi (1 file)
INSTALL include/linux/sunrpc (1 file)
INSTALL include/linux/tc_act (15 files)
INSTALL include/linux/tc_ematch (5 files)
INSTALL include/linux/usb (13 files)
INSTALL include/linux/wimax (1 file)
INSTALL include/linux (505 files)
INSTALL include/misc (4 files)
INSTALL include/mtd (5 files)
INSTALL include/rdma/hfi (2 files)
INSTALL include/rdma (25 files)
INSTALL include/scsi/fc (4 files)
INSTALL include/scsi (5 files)
INSTALL include/sound (16 files)
INSTALL include/video (3 files)
INSTALL include/xen (4 files)
INSTALL include/asm (37 files)
➜ linux-5.1.12 cd ..

C/C++ Compilers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
➜  aarch64 mkdir -p build-gcc
➜ aarch64 cd build-gcc
$ ../gcc-9.1.0/configure --prefix=/opt/aarch64 --enable-multiarch --enable-languages=c,c++,fortran,go --disable-multilib --disable-libvtv --enable-vtable-verify
checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking target system type... aarch64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for libhsail-rt support... no
checking for libphobos support... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... yes
checking for gnatbind... gnatbind
checking for gnatmake... gnatmake
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for the correct version of gmp.h... yes
checking for the correct version of mpfr.h... yes
checking for the correct version of mpc.h... yes
checking for the correct version of the gmp/mpfr/mpc libraries... yes
checking for isl 0.15 or later... yes
*** This configuration is not supported in the following subdirectories:
gnattools target-libada target-libhsail-rt target-libphobos target-zlib target-libobjc target-liboffloadmic target-libvtv
(Any other directories should still work fine.)
checking for default BUILD_CONFIG... bootstrap-debug
checking for --enable-vtable-verify... yes
checking for bison... bison -y
checking for bison... bison
checking for gm4... no
checking for gnum4... no
checking for m4... m4
checking for flex... flex
checking for flex... flex
checking for makeinfo... makeinfo
checking for expect... expect
checking for runtest... no
checking for ar... ar
checking for as... as
checking for dlltool... no
checking for ld... ld
checking for lipo... no
checking for nm... nm
checking for ranlib... ranlib
checking for strip... strip
checking for windres... no
checking for windmc... no
checking for objcopy... objcopy
checking for objdump... objdump
checking for otool... no
checking for readelf... readelf
checking for cc... cc
checking for c++... c++
checking for gcc... gcc
checking for gfortran... gfortran
checking for gccgo... gccgo
checking for gdc... no
checking for ar... /opt/aarch64/aarch64-unknown-linux-gnu/bin/ar
checking for as... /opt/aarch64/aarch64-unknown-linux-gnu/bin/as
checking for dlltool... no
checking for dlltool... no
checking for ld... /opt/aarch64/aarch64-unknown-linux-gnu/bin/ld
checking for lipo... no
checking for lipo... no
checking for nm... /opt/aarch64/aarch64-unknown-linux-gnu/bin/nm
checking for objcopy... /opt/aarch64/aarch64-unknown-linux-gnu/bin/objcopy
checking for objdump... /opt/aarch64/aarch64-unknown-linux-gnu/bin/objdump
checking for otool... no
checking for otool... no
checking for ranlib... /opt/aarch64/aarch64-unknown-linux-gnu/bin/ranlib
checking for readelf... /opt/aarch64/aarch64-unknown-linux-gnu/bin/readelf
checking for strip... /opt/aarch64/aarch64-unknown-linux-gnu/bin/strip
checking for windres... no
checking for windres... no
checking for windmc... no
checking for windmc... no
checking where to find the target ar... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin
checking where to find the target as... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin
checking where to find the target cc... just compiled
checking where to find the target c++... just compiled
checking where to find the target c++ for libstdc++... just compiled
checking where to find the target dlltool... host tool
checking where to find the target gcc... just compiled
checking where to find the target gfortran... just compiled
checking where to find the target gccgo... just compiled
checking where to find the target gdc... host tool
checking where to find the target ld... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin
checking where to find the target lipo... host tool
checking where to find the target nm... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin
checking where to find the target objcopy... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin
checking where to find the target objdump... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin
checking where to find the target otool... host tool
checking where to find the target ranlib... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin
checking where to find the target readelf... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin
checking where to find the target strip... pre-installed in /opt/aarch64/aarch64-unknown-linux-gnu/bin
checking where to find the target windres... host tool
checking where to find the target windmc... host tool
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile
➜ build-gcc make -j4 all-gcc
➜ build-gcc make install-gcc
➜ build-gcc cd ..

GLibc

1
2
3
4
5
6
7
8
9
➜  aarch64 mkdir -p build-glibc
➜ aarch64 cd build-glibc
➜ build-glibc ../glibc-2.29/configure --prefix=/opt/aarch64/aarch64-linux --build=$MACHTYPE --host=aarch64-linux --target=aarch64-linux --with-headers=/opt/aarch64/aarch64-linux/include --enable-multiarch --disable-multilib --disable-libvtv --with-selinux=no --enable-vtable-verify libc_cv_forced_unwind=yes
➜ build-glibc make install-bootstrap-headers=yes install-headers
➜ build-glibc make -j4 csu/subdir_lib
➜ build-glibc install csu/crt1.o csu/crti.o csu/crtn.o /opt/aarch64/aarch64-linux/lib
➜ build-glibc /opt/aarch64/bin/aarch64-linux-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /opt/aarch64/aarch64-linux/lib/libc.so
➜ build-glibc touch /opt/aarch64/aarch64-linux/include/gnu/stubs.h
➜ build-glibc cd ..

Compiler Support Library

1
2
3
4
➜  aarch64 cd build-gcc
➜ build-gcc make -j4 all-target-libgcc
➜ build-gcc make install-target-libgcc
➜ build-gcc cd ..

Build Standard C Library

1
2
3
4
➜  aarch64 cd build-glibc
➜ build-glibc make -j4
➜ build-glibc make install
➜ build-glibc cd ..

Build Standard C++ Library

1
2
3
4
➜  aarch64 cd build-gcc
➜ build-gcc make -j4
➜ build-gcc make install
➜ build-gcc cd ..

Finishing and Test

Check GCC Version

1
2
3
4
5
6
7
8
➜  /opt/aarch64/bin/aarch64-linux-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/aarch64/bin/aarch64-linux-gcc
COLLECT_LTO_WRAPPER=/opt/aarch64/libexec/gcc/aarch64-linux/9.1.0/lto-wrapper
Target: aarch64-linux
Configured with: ../gcc-9.1.0/configure --prefix=/opt/aarch64 --target=aarch64-linux --enable-languages=c,c++,fortran,go --disable-multilib --enable-vtable-verify : (reconfigured) ../gcc-9.1.0/configure --prefix=/opt/aarch64 --target=aarch64-linux --enable-multiarch --enable-languages=c,c++,fortran,go --disable-multilib --enable-vtable-verify : (reconfigured) ../gcc-9.1.0/configure --prefix=/opt/aarch64 --target=aarch64-linux --enable-multiarch --enable-languages=c,c++,fortran,go --disable-multilib --disable-libvtv --enable-vtable-verify
Thread model: posix
gcc version 9.1.0 (GCC)

Copy Built GCC 9.1.0 Onto Hikey 970

I actually copied some of the built folder under https://www.longervision.cc/arm/aarch64/gcc-9.1.0/. You are welcome to go try the toolchain.

Run Hello World on Hikey970

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
➜  GCC cat test.cpp 
#include <iostream>

int main(int argc, char** argv)
{
std::cout << "Hello World!" << std::endl;
return EXIT_SUCCESS;
}
➜ GCC x86_64-linux-gnu-c++ -std=c++17 test.cpp
➜ GCC x86_64-linux-gnu-c++ -std=c++17 test.cpp -o test
➜ GCC ls
a.out test test.cpp
➜ GCC ./test
Hello World!
➜ GCC

Today, let’s try to build the MOST RECENT GCC 9.1. We strictly follow the TERRIFIC blog How to Build a GCC Cross-Compiler with trivial modifications for my x86_64 desktop instead of aarch64 cross compile.

Preparations

Packages Required on HOST

Some packages are required to install on the host computer, including:

  • g++
  • make
  • gawk
  • bison
  • flex
  • expect
  • gnat
    etc.

Get ALL Packages for Building GCC

A wget-list.txt file is provided to download ALL required packages up-to-date. After having downloaded this single text file, the UNIQUE command to download all files is as follows:

1
➜  gcc ✗ wget -i wget-list.txt

You can of course download the files one by one. All concerned files are listed below:

Then, we extract all .tar files in whatever way you prefer.

1
2
3
4
5
6
7
➜  cd gcc-9.1.0
➜ gcc-9.1.0 ln -s ../mpfr-4.0.2 mpfr
➜ gcc-9.1.0 ln -s ../gmp-6.1.2 gmp
➜ gcc-9.1.0 ln -s ../mpc-1.1.0 mpc
➜ gcc-9.1.0 ln -s ../isl-0.18 isl
➜ gcc-9.1.0 ln -s ../cloog-0.18.1 cloog
➜ gcc-9.1.0 cd ..

Prepare Build Target Folder

1
2
➜  gcc mkdir -p /opt/native
➜ gcc export PATH=/opt/native/bin:$PATH

Start Building

Binutils

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
➜  gcc mkdir build-binutils
➜ gcc cd build-binutils
➜ build-binutils ../binutils-2.32/configure --prefix=/opt/native --target=x86_64-linux-gnu --enable-vtable-verify
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... gawk
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... yes
checking for gnatbind... gnatbind
checking for gnatmake... gnatmake
checking whether compiler driver understands Ada... yes
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for isl 0.15 or later... no
required isl version is 0.15 or later
checking for default BUILD_CONFIG...
checking for --enable-vtable-verify... yes
checking for bison... bison -y
checking for bison... bison
checking for gm4... no
checking for gnum4... no
checking for m4... m4
checking for flex... flex
checking for flex... flex
checking for makeinfo... makeinfo
checking for expect... expect
checking for runtest... no
checking for ar... ar
checking for as... as
checking for dlltool... no
checking for ld... ld
checking for lipo... no
checking for nm... nm
checking for ranlib... ranlib
checking for strip... strip
checking for windres... no
checking for windmc... no
checking for objcopy... objcopy
checking for objdump... objdump
checking for readelf... readelf
checking for x86_64-linux-gnu-cc... no
checking for cc... cc
checking for x86_64-linux-gnu-c++... no
checking for c++... c++
checking for x86_64-linux-gnu-gcc... x86_64-linux-gnu-gcc
checking for x86_64-linux-gnu-gfortran... x86_64-linux-gnu-gfortran
checking for x86_64-linux-gnu-gccgo... no
checking for gccgo... no
checking for x86_64-linux-gnu-ar... x86_64-linux-gnu-ar
checking for x86_64-linux-gnu-as... x86_64-linux-gnu-as
checking for x86_64-linux-gnu-dlltool... no
checking for dlltool... no
checking for x86_64-linux-gnu-ld... x86_64-linux-gnu-ld
checking for x86_64-linux-gnu-lipo... no
checking for lipo... no
checking for x86_64-linux-gnu-nm... x86_64-linux-gnu-nm
checking for x86_64-linux-gnu-objcopy... x86_64-linux-gnu-objcopy
checking for x86_64-linux-gnu-objdump... x86_64-linux-gnu-objdump
checking for x86_64-linux-gnu-ranlib... x86_64-linux-gnu-ranlib
checking for x86_64-linux-gnu-readelf... x86_64-linux-gnu-readelf
checking for x86_64-linux-gnu-strip... x86_64-linux-gnu-strip
checking for x86_64-linux-gnu-windres... no
checking for windres... no
checking for x86_64-linux-gnu-windmc... no
checking for windmc... no
checking where to find the target ar... just compiled
checking where to find the target as... just compiled
checking where to find the target cc... host tool
checking where to find the target c++... host tool
checking where to find the target c++ for libstdc++... host tool
checking where to find the target dlltool... just compiled
checking where to find the target gcc... host tool
checking where to find the target gfortran... host tool
checking where to find the target gccgo... host tool
checking where to find the target ld... just compiled
checking where to find the target lipo... host tool
checking where to find the target nm... just compiled
checking where to find the target objcopy... just compiled
checking where to find the target objdump... just compiled
checking where to find the target ranlib... just compiled
checking where to find the target readelf... just compiled
checking where to find the target strip... just compiled
checking where to find the target windres... just compiled
checking where to find the target windmc... just compiled
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile
➜ build-binutils make -j4
......
➜ build-binutils make install
➜ build-binutils cd ..

Linux Kernel Headers

1
2
3
➜  gcc cd linux-5.1.12
➜ linux-5.1.12 make ARCH=x86 INSTALL_HDR_PATH=/opt/native/linux headers_install
➜ linux-5.1.12 cd ..

C/C++ Compilers

1
2
3
4
5
6
➜  gcc mkdir -p build-gcc
➜ gcc cd build-gcc
➜ build-gcc ../gcc-9.1.0/configure --prefix=/opt/native --target=x86_64-linux-gnu --enable-languages=c,c++,fortran,go --disable-multilib --enable-vtable-verify
➜ build-gcc make -j4 all-gcc
➜ build-gcc make install-gcc
➜ build-gcc cd ..

GLibc

1
2
3
4
5
6
7
8
9
10
➜  gcc mkdir -p build-glibc
➜ gcc cd build-glibc
➜ build-glibc ../glibc-2.29/configure --prefix=/opt/native/linux --build=$MACHTYPE --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-headers=/opt/native/linux/include --disable-multilib --with-selinux=no --enable-vtable-verify libc_cv_forced_unwind=yes
➜ build-glibc make install-bootstrap-headers=yes install-headers
➜ build-glibc make -j4 csu/subdir_lib
➜ build-glibc mkdir /opt/native/linux/lib
➜ build-glibc install csu/crt1.o csu/crti.o csu/crtn.o /opt/native/linux/lib
➜ build-glibc /opt/native/bin/x86_64-linux-gnu-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /opt/native/linux/lib/libc.so
➜ build-glibc touch /opt/native/linux/include/gnu/stubs.h
➜ build-glibc cd ..

Compiler Support Library

1
2
3
4
➜  gcc cd build-gcc
➜ build-gcc make -j4 all-target-libgcc
➜ build-gcc make install-target-libgcc
➜ build-gcc cd ..

Build Standard C Library

1
2
3
4
➜  gcc cd build-glibc
➜ build-glibc make -j4
➜ build-glibc make install
➜ build-glibc cd ..

Build Standard C++ Library

1
2
3
4
➜  gcc cd build-gcc
➜ build-gcc make -j4
➜ build-gcc make install
➜ build-gcc cd ..

Finishing and Test

Check GCC Version

1
2
3
4
5
6
7
8
➜  build-gcc x86_64-linux-gnu-c++ -v
Using built-in specs.
COLLECT_GCC=x86_64-linux-gnu-c++
COLLECT_LTO_WRAPPER=/opt/native/libexec/gcc/x86_64-linux-gnu/9.1.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../gcc-9.1.0/configure --prefix=/opt/native --target=x86_64-linux-gnu --enable-languages=c,c++,python,fortran,go --disable-multilib --enable-vtable-verify
Thread model: posix
gcc version 9.1.0 (GCC)

Run Hello World

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
➜  GCC cat test.cpp 
#include <iostream>

int main(int argc, char** argv)
{
std::cout << "Hello World!" << std::endl;
return EXIT_SUCCESS;
}
➜ GCC x86_64-linux-gnu-c++ -std=c++17 test.cpp
➜ GCC x86_64-linux-gnu-c++ -std=c++17 test.cpp -o test
➜ GCC ls
a.out test test.cpp
➜ GCC ./test
Hello World!
➜ GCC