0%

Today is sunny. ^_^... Let's write something about MicroPython PyBoard. In my test, I'm using a PyBv1.1, which embeddes a STM32F405RG microcontroller.

Overview

1. Contents In PyBoard

After connecting PyBv1.1 via USB cable, you will possibly see a folder prompt on the screen as follows:

Current Contents In PYBv1.1
PYBv1.1 Properties

2. Test Out 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
➜  ~ 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


FATAL: cannot open /dev/ttyACM0: Permission denied

It looks we need to change the permission of /dev/ttyACM0.

1
2
3
➜  ~ ll /dev/ttyACM0 
crw-rw---- 1 root dialout 166, 0 Jul 9 13:54 /dev/ttyACM0
➜ ~ sudo chmod 777 /dev/ttyACM0

Reconnect...

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.4 on 2018-05-11; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>>

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

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

3. Test Out screen

1
➜  ~ screen /dev/ttyACM0

Then you will see a micropython working console as:

1
2
3
1+1
2
>>>

It looks there is NO prompt after login via screen. That's why I did 1+1 as a test whenever logging in by screen.

Now, let's press Ctrl+A then Ctrl+d to quit screen.

1
2
3
➜  ~ screen /dev/ttyACM0
[detached from 5561.pts-5.lvision-GT72-6QE]
➜ ~

4. VERY Important

The code typed in the working console from either picocom or screen is corresponding to main.py in PYBFLASH.

Test

1. LED and Switch

The code is directly copied from MicroPython's homepage.

1
2
3
4
5
6
7
8
9
10
11
12
13
import pyb

sw = pyb.Switch()
led = pyb.LED(4)
x = 0

while True:
if sw():
x = min(255, x+1)
else:
x = max(0,x-1)
led.intensity(x)
pyb.delay(30)

Press the USR switch and take a look what's going on? ^_^ Interesting, isn't it?

2. Log of Accelerometer's Readings

Let's try out MicroPython's Example Code : Accelerometer Log with trivial modification.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# log the accelerometer values to a .csv-file on the SD-card

import pyb

accel = pyb.Accel() # create object of accelerometer
blue = pyb.LED(4) # create object of blue LED

log = open('.log.csv', 'w') # open file to write data - /sd/ is the SD-card, /flash/ the internal memory
blue.on() # turn on blue LED

for i in range(100): # do 100 times (if the board is connected via USB, you can't write longer because the PC tries to open the filesystem which messes up your file.)
t = pyb.millis() # get time since reset
x, y, z = accel.filtered_xyz() # get acceleration data
log.write('{},{},{},{}\n'.format(t,x,y,z)) # write data to file

log.close() # close file
blue.off() # turn off LED

Just press the RST switch, the above piece of code will automatically run once, and the onboard accelerator's reading will be logged in file log.csv. In my test, 100 readings are logged as:

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
156,-10,-14,13
157,-20,-28,26
158,-30,-42,39
159,-40,-56,52
161,-40,-56,52
162,-40,-56,52
163,-40,-56,52
164,-40,-56,52
165,-40,-56,52
166,-40,-56,52
167,-40,-56,52
169,-39,-56,53
170,-38,-56,54
171,-37,-56,55
172,-36,-56,56
173,-36,-56,56
174,-36,-56,56
176,-36,-56,56
177,-36,-56,56
178,-36,-56,56
179,-36,-56,56
180,-36,-56,56
181,-36,-56,56
183,-36,-56,56
184,-36,-55,57
185,-36,-54,58
186,-36,-53,59
187,-36,-52,60
188,-36,-52,60
189,-36,-52,60
191,-36,-52,60
192,-36,-52,60
193,-36,-52,60
194,-36,-52,60
195,-36,-52,60
322,-30,-58,58
324,-24,-64,56
325,-18,-70,54
326,-12,-76,52
327,-12,-76,52
328,-12,-76,52
329,-12,-76,52
331,-12,-76,52
332,-12,-76,52
333,-12,-76,52
334,-14,-73,55
335,-16,-70,58
336,-18,-67,61
338,-20,-64,64
339,-20,-64,64
340,-20,-64,64
341,-20,-64,64
342,-20,-64,64
343,-20,-64,64
345,-20,-64,64
346,-20,-64,64
347,-20,-64,64
348,-20,-64,64
349,-18,-67,63
350,-16,-70,62
352,-14,-73,61
353,-12,-76,60
354,-12,-76,60
355,-12,-76,60
356,-12,-76,60
357,-12,-76,60
359,-12,-76,60
360,-12,-76,60
361,-12,-76,60
488,-19,-68,58
489,-26,-60,56
490,-33,-52,54
491,-40,-44,52
492,-40,-44,52
493,-40,-44,52
495,-40,-44,52
496,-40,-44,52
497,-40,-44,52
498,-41,-45,55
499,-42,-46,58
500,-43,-47,61
502,-44,-48,64
503,-44,-48,64
504,-44,-48,64
505,-44,-48,64
506,-44,-48,64
507,-44,-48,64
509,-44,-48,64
510,-44,-48,64
511,-44,-48,64
512,-44,-48,64
513,-43,-47,65
516,-30,-52,59
517,-17,-57,53
518,-2,-64,47
519,12,-72,40
520,14,-74,40
521,16,-76,40
523,16,-76,40
524,16,-76,40

Flash Micropython Onto Pyboard

1. Checkout Micropython Source Code

Let's FIRST download the NEWEST micropython release. In my case, the MOST up-to-date release is 1.11. (Do NOT** use the git version** from https://github.com/micropython/micropython.git ).

2. Build Micropython For PYBV11

We'll strictly follow ports/stm32/README.md to build Micropython.

1
2
3
4
5
6
7
8
9
➜  micropython-1.11 make -C mpy-cross
make: Entering directory '....../micropython-1.11/mpy-cross'
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build/genhdr/mpversion.h
CC main.c
LINK mpy-cross
text data bss dec hex filename
322105 24864 864 347833 54eb9 mpy-cross
make: Leaving directory '....../micropython-1.11/mpy-cross'

Then we enter subfolder ports/stm32. for further building.

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
➜  micropython-1.11 cd ports/stm32 
➜ stm32 make BOARD=PYBV11 deploy
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
mkdir -p build-PYBV11/genhdr
GEN build-PYBV11/genhdr/pins.h
GEN stmconst build-PYBV11/modstm_qstr.h
GEN build-PYBV11/genhdr/mpversion.h
GEN build-PYBV11/genhdr/moduledefs.h
GEN build-PYBV11/genhdr/pybcdc.inf
GEN build-PYBV11/genhdr/pybcdc_inf.h
GEN build-PYBV11/genhdr/pllfreqtable.h
GEN build-PYBV11/genhdr/qstr.i.last
GEN build-PYBV11/genhdr/qstr.split
GEN build-PYBV11/genhdr/qstrdefs.collected.h
QSTR updated
GEN build-PYBV11/genhdr/qstrdefs.generated.h
mkdir -p build-PYBV11/boards/
mkdir -p build-PYBV11/build-PYBV11/
mkdir -p build-PYBV11/drivers/bus/
mkdir -p build-PYBV11/drivers/dht/
mkdir -p build-PYBV11/drivers/memory/
mkdir -p build-PYBV11/extmod/
mkdir -p build-PYBV11/lib/embed/
mkdir -p build-PYBV11/lib/libc/
mkdir -p build-PYBV11/lib/libm/
mkdir -p build-PYBV11/lib/mp-readline/
mkdir -p build-PYBV11/lib/netutils/
mkdir -p build-PYBV11/lib/oofatfs/
mkdir -p build-PYBV11/lib/stm32lib/STM32F4xx_HAL_Driver/Src/
mkdir -p build-PYBV11/lib/timeutils/
mkdir -p build-PYBV11/lib/utils/
mkdir -p build-PYBV11/py/
mkdir -p build-PYBV11/usbdev/class/src/
mkdir -p build-PYBV11/usbdev/core/src/
CC ../../py/mpstate.c
CC ../../py/nlr.c
CC ../../py/nlrx86.c
CC ../../py/nlrx64.c
CC ../../py/nlrthumb.c
CC ../../py/nlrxtensa.c
CC ../../py/nlrsetjmp.c
CC ../../py/malloc.c
CC ../../py/gc.c
CC ../../py/pystack.c
CC ../../py/qstr.c
CC ../../py/vstr.c
CC ../../py/mpprint.c
CC ../../py/unicode.c
...
CC lcd.c
CC accel.c
CC servo.c
CC dac.c
CC adc.c
AS boards/startup_stm32f4.s
CC system_stm32.c
AS resethandler.s
AS ../../lib/utils/gchelper_m3.s
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc_ex.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fmc.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_mmc.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sdram.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dcmi.c
CC ../../lib/stm32lib/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c
CC usbdev/core/src/usbd_core.c
CC usbdev/core/src/usbd_ctlreq.c
CC usbdev/core/src/usbd_ioreq.c
CC usbdev/class/src/usbd_cdc_msc_hid.c
CC usbdev/class/src/usbd_msc_bot.c
CC usbdev/class/src/usbd_msc_scsi.c
CC usbdev/class/src/usbd_msc_data.c
CC build-PYBV11/pins_PYBV11.c
LINK build-PYBV11/firmware.elf
text data bss dec hex filename
332432 32 27876 360340 57f94 build-PYBV11/firmware.elf
GEN build-PYBV11/firmware.dfu
Writing build-PYBV11/firmware.dfu to the board
Traceback (most recent call last):
File "../../tools/pydfu.py", line 586, in <module>
main()
File "../../tools/pydfu.py", line 566, in main
init()
File "../../tools/pydfu.py", line 97, in init
raise ValueError('No DFU device found')
ValueError: No DFU device found
make: *** [Makefile:442: deploy] Error 1
➜ stm32

3. Load MicroPython on a Microcontroller Board

The above ERROR message is telling that our board is NOT in the DFU mode yet. Therefore, according to the blog How to Load MicroPython on a Microcontroller Board, we need to make sure P1 (DFU) and 3V3 pin are connected together before flashing.

Note: Before connecting P1 (DFU) and 3V3 pin, make sure power is disconnected from the pyboard.

Now, let's try it again:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
➜  stm32 make BOARD=PYBV11 deploy
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Writing build-PYBV11/firmware.dfu to the board
File: build-PYBV11/firmware.dfu
b'DfuSe' v1, image size: 332773, targets: 1
b'Target' 0, alt setting: 0, name: "ST...", size: 332488, elements: 2
0, address: 0x08000000, size: 14824
1, address: 0x08020000, size: 317648
usb: 0483:df11, device: 0x0000, dfu: 0x011a, b'UFD', 16, 0x60c9ebae
Writing memory...
0x08000000 14824 [=========================] 100%
0x08020000 317648 [=========================] 100%
Exiting DFU...
➜ stm32

Let's try picocom connection again:

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
➜  stm32 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.11 on 2019-07-13; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>>
Terminating...
Thanks for using picocom
➜ stm32

4. Optional: dfu-util

Due to the Pyboard Firmware Update Wiki, we may also use dfu-util to flash the board.

1
2
3
4
5
6
7
8
➜  ~ sudo dfu-util -l
[sudo] password for lvision:
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Raining today...

Skill 1 - How to apply color for words in Markdown?

Solution

Please refer to https://stackoverflow.com/questions/35465557/how-to-apply-color-in-markdown.

1
Some Markdown text with <span style="color:blue">some *blue* text</span>.

Test

Please refer to the following line in our yesterday's blog NVidia Jetson Nano - 1. The code is as follows:

1
<span style="color:red">**Now, Jetson Nano is wired connected onto the Internet.**</span>

Skill 2 - Multirow/multicolumn cell in markdown table

Solution

Try: https://github.com/markdown-it/markdown-it/issues/406

Test

Collumns
First Second Third
| First 1 |

Second 2

Second 2 |

Third 1

Third 2

Third 3 | | * List 1 element |

*List 2 elements (1)

  • List 2 elements (2) |

    • List 3 elements (1)

      *List 3 elements (2)

      • List 3 elements (3) |

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: * https://gnu.freemirror.org/gnu/binutils/binutils-2.32.tar.gz * https://gnu.freemirror.org/gnu//gcc/gcc-9.1.0/gcc-9.1.0.tar.gz * https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.1.12.tar.gz * https://ftp.gnu.org/glibc/glibc-2.29.tar.xz * https://ftp.gnu.org/mpfr/mpfr-4.0.2.tar.xz * https://ftp.gnu.org/gmp/gmp-6.1.2.tar.xz * https://ftp.gnu.org/mpc/mpc-1.1.0.tar.gz * ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 * ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1.tar.gz

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

According to our previous blog Install Armbian Ubuntu Desktop Nightly Built onto Orange Pi 3, Wifi module of Orange Pi 3 with Armbian nightly built for Orange Pi 3 does NOT function well. Therefore, today, we resort back to the Ubuntu Desktop distro from Orange Pi's official website.

PART A: Install Ubuntu Desktop from Official Orange Pi Website onto Orange Pi 3

1. Download Ubuntu Desktop for Orange Pi 3 from Official Orange Pi Website

We FIRST go visiting Orange Pi's official website http://www.orangepi.org/downloadresources/ and find the Ubuntu Desktop distro for Orange Pi 3.

After OrangePi_3_xenial_desktop_linux4.9_v1.3.img.tar.gz has been downloaded, we had it extracted as follows:

1
2
3
➜  orangepi tar xvf OrangePi_3_xenial_desktop_linux4.9_v1.3.img.tar.gz 
OrangePi_3_xenial_desktop_linux4.9_v1.3.img
OrangePi_3_xenial_desktop_linux4.9_v1.3.img.md5sum

2. Install Orange Pi's Official Ubuntu Desktop for Orange Pi 3

Exactly the same as in our previous blog Install Armbian Ubuntu Desktop with the Newest Supported Mainline Linux Kernel onto Orange Pi Plus 2, we have the TF card formatted and dd the system into it.

1
2
3
4
5
➜  orangepi sudo dd bs=4M if=OrangePi_3_xenial_desktop_linux4.9_v1.3.img of=/dev/mmcblk0 conv=fsync
[sudo] password for lvision:
950+0 records in
950+0 records out
3984588800 bytes (4.0 GB, 3.7 GiB) copied, 170.284 s, 23.4 MB/s

PART B: Boot Into Orange Pi 3, Enable SSH, Update & Upgrade, Locale Configuration, Network Configuration

Different from our previous blog Install Armbian Ubuntu Desktop With Kernel 5.0 onto Banana Pi M3, SSH service on Orange Pi's Official Ubuntu Desktop for Orange Pi 3 is NOT enabled by default. Therefore, we've got to enable SSH during out FIRST boot.

1. Boot into Orange Pi 3

The overview of Official Orange Pi's Ubuntu Desktop for Orange Pi 3 looks as:

Overview of Official Orange Pi's Ubuntu Desktop

2. Kernel Doublechecking

1
2
3
4
5
6
7
8
9
10
orangepi@OrangePi:~$ uname -r
4.9.118+
orangepi@OrangePi:~$ uname -a
Linux OrangePi 4.9.118+ #5 SMP PREEMPT Mon Apr 15 09:45:02 CST 2019 aarch64 aarch64 aarch64 GNU/Linux
orangepi@OrangePi:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial

3. Enable SSH

Auto Start SSH Service After Booting

After having successfully enabled SSH, you are able to login Orange Pi 3 remotely. Well, you may still need to figure out how to:

  • setup Wifi for Orange Pi 3, which is pretty simple with Ubuntu Desktop GUI
  • further setup static IP addresses in your router for both Wifi and Wired connections

4. Update & Upgrade

1
2
3
4
5
6
7
8
9
10
11
orangepi@OrangePi:~$ sudo apt update
[sudo] password for orangepi:
Hit:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports xenial InRelease
Hit:2 http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports xenial-updates InRelease
Hit:3 http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports xenial-backports InRelease
Hit:4 http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports xenial-security InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
root@orangepi3:~#

Since I've already updated/upgraded all packages, it'll tell you from terminal that All packages are up to date.. BTW, it seems Orange Pi is a team from TsingHua Universiity?

5. Locale Configuration

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
orangepi@OrangePi:~$ sudo dpkg-reconfigure tzdata
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_PAPER = "en",
LC_ADDRESS = "en",
LC_MONETARY = "en",
LC_NUMERIC = "en",
LC_TELEPHONE = "en",
LC_IDENTIFICATION = "en",
LC_MEASUREMENT = "en",
LC_CTYPE = "en_CA.UTF-8",
LC_TIME = "en",
LC_NAME = "en",
LANG = "en_CA.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory

Current default time zone: 'America/Vancouver'
Local time is now: Wed Jun 5 09:43:12 PDT 2019.
Universal Time is now: Wed Jun 5 16:43:12 UTC 2019.

During the above process, you'll set the following 2 pages correspondingly:

System Locale America
System Locale Vancouver

By using the command date, we can see the timezone has been successfully reset.

1
2
orangepi@OrangePi:~# date
Wed Jun 5 12:05:40 PDT 2019

6. Network Configuration

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
orangepi@OrangePi:~$ 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 36:c9:e3:f1:b8:05 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.78/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 2001:569:7e6d:1b00:4cbf:8fff:88e0:e68c/64 scope global temporary dynamic
valid_lft 7488sec preferred_lft 7188sec
inet6 2001:569:7e6d:1b00:c145:4c18:8c39:e90a/64 scope global mngtmpaddr noprefixroute dynamic
valid_lft 7488sec preferred_lft 7188sec
inet6 fe80::5ca:d7da:797:33af/64 scope link
valid_lft forever preferred_lft forever
3: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
link/ipip 0.0.0.0 brd 0.0.0.0
4: gre0@NONE: <NOARP> mtu 1476 qdisc noop state DOWN group default qlen 1
link/gre 0.0.0.0 brd 0.0.0.0
5: gretap0@NONE: <BROADCAST,MULTICAST> mtu 1462 qdisc noop state DOWN group default qlen 1000
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
6: ip_vti0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
link/ipip 0.0.0.0 brd 0.0.0.0
7: ip6_vti0@NONE: <NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1
link/tunnel6 :: brd ::
8: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
link/sit 0.0.0.0 brd 0.0.0.0
9: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN group default qlen 1
link/tunnel6 :: brd ::
10: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 6c:21:a2:14:cc:ce brd ff:ff:ff:ff:ff:ff
inet 192.168.1.79/24 brd 192.168.1.255 scope global dynamic wlan0
valid_lft 86384sec preferred_lft 86384sec
inet6 2001:569:7e6d:1b00:9055:86f5:5b5:82ae/64 scope global temporary dynamic
valid_lft 7488sec preferred_lft 7188sec
inet6 2001:569:7e6d:1b00:a76:2b2e:4c08:f7cd/64 scope global mngtmpaddr noprefixroute dynamic
valid_lft 7488sec preferred_lft 7188sec
inet6 fe80::200d:cbb5:fc23:f6e4/64 scope link
valid_lft forever preferred_lft forever

As you can see, I set up static IP address as follows:

  • eth0: 192.168.1.78
  • wlan0: 192.168.1.79