Raspberry Pi: Dart Hello BC2835

  • Ubuntu 16.04 LTS
  • arm-linux-gnueabihf (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  • Dart SDK, master 511963d71509de50ac577ac22f3bac8d33c17e34
  • Raspberry Pi 3 model B
Install ARM toolchain

See Raspberry Pi: C++ cross-compiling

Build and install Dart SDK for ARM

See Dart: build Dart SDK for x86 and ARM

Optionally, copy dart-api.h to /usr/local/include:

$ cd dart-sdk/sdk/out
$ find . -name dart_sdk.h
$ cp ./ReleaseXARM/dart-sdk/include/dart_api.h /usr/local/include
Build and install libbcm2835.so

See Raspberry Pi: cross-compile bcm2835 library

Build  missing Dart SDK ARM libraries
# libunsafe_extension.git
$ git clone https://github.com/mezoni/unsafe_extension.git
$ cd unsafe_extension/lib/src/
$ arm-linux-gnueabihf-gcc -shared -fPIC -I/home/username/tools/sdk-dart/sdk/out/ReleaseXARM/dart-sdk/include unsafe_extension.cc -o libunsafe_extension.cc
$ scp libunsafe_extension.so pi@192.168.0.xxx:~
# libffi6_extension.so
$ git clone https://github.com/mezoni/libffi6_extension.git
$ cd libffi6_extension/lib/src/
$ arm-linux-gnueabihf-gcc -shared -fPIC -I/home/username/tools/sdk-dart/sdk/out/ReleaseXARM/dart-sdk/include ffi6_extension.cc -o libffi6_extension.so
$ scp libffi6_extension.so pi@192.168.0.xxx:~
Install the libraries on Raspberry Pi
# On Raspberry Pi
$ sudo mv libbcm2835.so /usr/lib
$ sudo mv libunsafe_extension.so /usr/lib
$ sudo mv libffi6_extension.so /usr/lib
$ sudo ldconfig
Dart Hello BCM2835 project
# On Raspberry Pi
$ git clone https://github.com/yolkhovyy/dart-hello-bcm2835.git
$ cd dart-hello-bcm2835
$ pub get
Resolving dependencies... (1.6s)
Got dependencies!
$ dart bin/main.dart
Hello bcm2835!
Unhandled exception:
Bad state: File not found: bcm2835.lib.h
#0      Declarations.Declarations (package:binary_declarations/src/binary_declarations/declarations.dart:25:7)
#1      _Declarations.declare (package:binary_types/src/declarations.dart:37:28)
#2      BinaryTypeHelper.declare (package:binary_types/src/type_helper.dart:143:24)
#3      Bcm2835Lib.Bcm2835Lib (package:bcm2835_bindings/src/bcm2835_bindings/bcm2835.lib.dart:17:14)
#4      loadBcm2835Library (package:bcm2835_bindings/src/bcm2835_bindings/bcm2835_lib_loader.dart:23:14)
#5      main (file:///home/pi/projects/spikes/bcm2835/dart/bin/main.dart:13:27)
#6      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:263)
#7      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:151)

TODO: figure out why bcm2835.lib.h is missing.

Update: bcm2835_bindings is not maintained anymore – dead end?

Raspberry Pi: C++ cross-compiling in Eclipse

Based on this GuruCoding page.

  • Ubuntu 16.04 LTS
  • Eclipse Neon.3 Release 4.6.3
  • arm-linux-gnueabihf (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  • Raspberry Pi 3 Model B
ARM toolchain

See Raspberry Pi: cross-compiling blog.

Upgrade libstdc++ to 6.0.21 on Raspberry Pi

See Raspberry Pi: how to solve the “version `GLIBCXX_6.0.21′ not found” problem.

Install Eclipse IDE for C/C++ developers

Download, unpack from here.

Eclipse plugins


  • Help > Install new software > Work with: –All Available Sites–
  • Check “Mobile and Device Development”
  • Next > Accept the terms of the license agreement” > Finish
  • Restart Eclipse
Create project

In Eclipse:

  • File > New > C++ Project
  • C++ Project
    • Project name: helloworld
    • Project type: Hello World C++ Project
    • Toolchains: Cross GCC
    • Next
  • Basic Settings
    • Hello world greeting: Hello world!
    • Next
  • Select Configurations
    • Next
  • Cross GCC Command
    • Cross compiler prefix: arm-linux-gnueabihf-
    • Cross compiler path: /usr/bin
    • Finish
  • Project > Properties > C/C++ Build > Settings
    • Tool Settings > Cross Settings
      • Prefix: arm-linux-gnueabihf-
      • Path: /usr/bin
Enable C++ 11
  • Project > Properties > C/C++ Build > Settings
    • Configuration: Debug/Release
    • Tool Settings > Cross G++ Compiler > Dialect: ISO C+11 (-std=c++0x)
  • Project > Build All

Raspberry Pi: debugging with gdb, command line


This post is about how to debug Raspberry Pi software with gdb, command line. For gdb debugging in Eclipse see Raspberry Pi: gdb debugging in Eclipse.

In case you are interested how to debug Dart command line applications in IntelliJ – see Raspberry Pi: How to remote debug Dart command line applications in IntelliJ.


  • Ubuntu 16.04 LTS
  • arm-linux-gnueabihf (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  • Raspberry Pi 3 Model B

Prepare/compile helloworld

See here.

Install gdb-multiarch on host

$ sudo apt-get install gdb-multiarch

Install gdbserver on Raspberry Pi

$ sudo apt-get install gdbserver


# On target, - debug host's ip address
$ gdbserver --multi
Listening on port 2345

# On host, - target ip address
$ gdb-multiarch
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target extended-remote
Remote debugging using
(gdb) set remote exec-file /home/pi/path/helloworld
(gdb) file /home/uname/path/helloworld
Reading symbols from /home/uname/path/helloworld...done.
(gdb) start
Temporary breakpoint 1 at 0x105f4: file src/helloworld.cpp, line 12.
Starting program: /home/uname/path/helloworld 
Temporary breakpoint 1, main () at src/helloworld.cpp:12
12    int main() {
(gdb) next
13        std::cout << "Hello World!" << std::endl;
(gdb) next
12    int main() {
(gdb) next
13        std::cout << "Hello World!" << std::endl;
(gdb) next
12    int main() {
(gdb) next
13        std::cout << "Hello World!" << std::endl;
(gdb) next
15    }

# On target
Remote debugging from host
Process /home/pi/path/helloworld created; pid = 2267
Hello World!


Raspberry Pi: C++ cross-compiling

  • Ubuntu 16.04 LTS
  • arm-linux-gnueabihf (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  • Raspberry Pi 3 Model B
Install build tools

Check/install build-essential:

# Check if build-essential is installed
$ dpkg -s build-essntial
# Install build-essential if needed
$ sudo apt-get install build-essential
Install ARM toolchain
# ARM build tools
$ sudo apt-get install g++-arm-linux-gnueabihf
# Check installation
$ arm-linux-gnueabihf-g++ -v
Upgrade libstdc++ to 6.0.21 on Raspberry Pi

See Raspberry Pi: how to solve the “version `GLIBCXX_6.0.21′ not found” problem.

Create helloworld.cpp
#include <iostream>

int main() {
    std::cout << "Hello World!" << std::endl;
    return 0;
$ arm-linux-gnueabihf-g++ -O3 -g3 -Wall -fPIC -c -o helloworld.o helloworld.cpp
$ arm-linux-gnueabihf-g++ -o helloworld helloworld.o
Copy helloworld to Raspberry Pi
$ scp ./helloworld pi@192.168.0.xxx:/home/pi/path
Login into Raspberry Pi and run helloworld
$ ssh pi@192.168.0.xxx
# On Raspberry Pi
$ cd path
$ ./helloworld
Hello World!
g++-arm-linux-gnueabihf pakage detais
$ dpkg -s g++-arm-linux-gnueabihf
Package: g++-arm-linux-gnueabihf
Status: install ok installed
Priority: optional
Section: devel
Installed-Size: 11
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Source: gcc-defaults (1.150ubuntu1)
Version: 4:5.3.1-1ubuntu1
Depends: cpp-arm-linux-gnueabihf (>= 4:5.3.1-1ubuntu1), gcc-arm-linux-gnueabihf (>= 4:5.3.1-1ubuntu1), g++-5-arm-linux-gnueabihf (>= 5.3.1-3~)
Description: GNU C++ compiler for the armhf architecture
 This is the GNU C++ compiler, a fairly portable optimizing compiler for C++.
 This is a dependency package providing the default GNU C++ cross-compiler
 for the armhf architecture.
Original-Maintainer: Debian GCC Maintainers <debian-gcc@lists.debian.org>

Fuchsia OS: download, build and run


Supported build platforms

At the moment of writing two build platforms seems to be supported – Ubuntu and Mac OSx. This article focuses on Ubuntu.

Getting the source

How to install version control tools and checkout Fuchsia OS repositories is described on the Fuchsia Manifest page:

# Install tools
sudo apt-get install golang git-all build-essential curl
# Install jiri scripts
curl -s https://raw.githubusercontent.com/fuchsia-mirror/jiri/master/scripts/bootstrap_jiri | bash -s fuchsia
# Export path to jiri
cd fuchsia
export PATH=`pwd`/.jiri_root/bin:$PATH
# Import/update Fuchsia code
jiri import fuchsia https://fuchsia.googlesource.com/manifest
jiri update

Building Fuchsia

Build instructions can be found in the Fuchsia Repository:

# Setup build environment, amr64
source scripts/env.sh && envprompt && fset arm64
# Build

Built sysroot will be in:


and the boot image in:



cd fuchsia
git clone https://fuchsia.googlesource.com/third_party/qemu
cd qemu
./configure --target-list=arm-softmmu,aarch64-softmmu,x86_64-softmmu
make -j32
sudo make install

Run Fuchsia OS in QEMU

cd fuchsia/magenta
# Run aarch64 (optionally, with graphical consol - add -g)
./scripts/run-magenta-arm64 -x ../out/debug-aarch64/user.bootfs -m 2048 [-g]

Magenta on Raspberry PI

See Magenta on Raspberry Pi and Raspberry Pi: compile and run Magenta pages.