Open Enea Linux (http://www.openenealinux.org) is a binary distribution based on the poky example distro from the Yocto Project. The concept is to make embedded devices easy to use, adapt and extend with a simple flick of the package-manager.
At ECS we held a workshop on BeagleBone Black demonstrating the ease of customizing the distro, installing a toolchain and doing remote debugging.
2. About us...
Founded in 1968, Stockholm
World’s third largest player in real-time
operating systems
Broad ecosystem of partners
ARM, Texas Instruments, Freescale,...
Broad ecosystem of customers
Ericsson, Nokia, Electrolux, ...
Did you know that...
Sweden’s first e-mail is
sent over the internet to
Enea (April 7, 1983)?
What we do...
Software Products
Software services
Training
Did you know that...
Linux
RTOS
Embedded Mgmt and HA
Embedded data bases
Enea is the only Linux
Foundation authorized
training parter in Europe?
3. Embedded Linux
Main factors when choosing an OS for embedded systems:
Acquisition cost
Source code availability
Linux is the most widely used OS in embedded devices
World of embedded Linux is very fragmented
Over 200 distros
Different kernel versions, packages, build systems, tools
Tools
Package Package
Linux Kernel
Package
Package Package
Package Package
Linux Kernel
Tools
Package Package
Package Package
Package Package
Package Package
Linux Kernel
Open Source
Tools
Package Manager
Package Package
Linux Kernel
Package
Package
Package
Package
Package
Package
*Embedded Market Forecasters’ surveys
4. What’s Open Enea Linux
Yocto compatible embedded Linux distribution
All prebuilt binaries available
- Linux images
- Toolchain/SDK
Package repository infrastructure
Exclusively open source tools
Instructions and video tutorials
Community
- Interact with Eneans an other community members
6. Workshop material
64b Linux Machine
BeagleBone Black
4/8GB microSD card
+ adapter
USB to TTL cable
Mini USB cable
Hardware Accessories
USB stick
7. Workshop Part 1
9:30 to 10:30
Bulk binaries to computer
Prepare SD card
Serial Connection
Boot OEL
SERIAL Configure Package Manager
8. Step 1 – Bulk binaries
Copy binaries locally
- OEL Images
- SDK/Toolchain
- Enea Linux Eclipse
$ cd
$ mkdir OEL
$ cd OEL
$ cp -r -v /media/ENEAUSB/* .
*You might find ENEAUSB under /media/<user>/ENEAUSB
Browse directory
$ ls –la
drwx------ 2 user user 4096 Oct 24 16:19 boot
drwx------ 2 user user 4096 Oct 24 16:20 partition1
drwx------ 2 user user 4096 Oct 24 16:20 partition2
drwx------ 2 user user 4096 Oct 30 14:12 scripts
drwx------ 2 user user 4096 Oct 24 16:20 toolchain
drwx------ 2 user user 4096 Oct 24 16:19 tools
*You can now remove the USB stick safely
9. Step 2 – Connect microSD card
Connect your microSD card to your computer using an SD adapter or a memory card
reader. Observe which device it registers as by checking your dmesg log:
$ dmesg | tail
[17622.977436] mmc0: new SDHC card at address aaaa
[17622.977810] mmcblk0: mmc0:aaaa SL32G 29.7 GiB
[17622.989858] mmcblk0: p1 p2
[17623.410434] EXT4-fs (mmcblk0p2): recovery complete
[17623.414702] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
*Note that this MicroSD card contains 2 partitions in /dev/mmcblk0
Your SD card might have only one or no partition at all.
Alternatively, you can also list your existing devices this way:
$ ls /dev/mmc*
$ ls /dev/sd*
/dev/mmcblk0p1
/dev/mmcblk0p2
*If you are using an SD car adapter
*If you are using an SD car reader
(might be called something like sdf, sdb,…)
10. Step 3 – Partition microSD card
Unmount existing partitions (if applicable)
$ sudo umount /dev/<device_name>*
Begin partitioning the microSD card
$ sudo fdisk /dev/<device_name>
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
*Note that you need to replace /dev/<device_name> with your actual device name
11. Step 3 – Partition microSD card
Partition 1
From beginning
To sector 4095
Initialize a new partition table by selecting o, then verify the partition
table is empty by selecting p
Partition 1: Create a boot partition by selecting n for ‘new’, then p for
‘primary’, and 1 to specify the first partition. Press enter to accept the
default first sector and specify 4095 for the last sector
Change the partition type to FAT16 by selecting t for ‘type’ and e for
‘W95 FAT16 (LBA)’
Set the partition bootable by selecting a then 1
Partition 2: Create the data partition for the root file system by
selecting n for ‘new’, then p for ‘primary’, and 2 to specify the second
partition. Accept the default values for the first and last sectors by
pressing enter twice
Partition 2
From sectr 4095
To end
*If you make a mistake, you can always initialize the partition table by selecting o, and start from scratch
12. Step 3 – Partition microSD card
Press p to ‘print’ the partition table. It should look similar to the
one below:
Disk /dev/sdb: 7948 MB, 7948206080 bytes
255 heads, 63 sectors/track, 966 cylinders, total 15523840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xafb3f87b
Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 4095 1024 e W95 FAT16 (LBA)
/dev/sdb2 * 4096 15523839 7759872 83 Linux
Now you can commit the changes by selecting w to ‘write’ the
partition table and exit fdisk
Partition 1
From beginning
To sector 4095
Partition 2
From sectr 4095
To end
*You might get a warning after this, but do not worry.
13. Step 3 – Partition microSD card
Partition 1
vfat
Partition 2
ext4
Check your partition names:
$ ls -l /dev/<device_name>*
brw-rw---- 1 root disk 179, 0 Oct 30 14:28 /dev/mmcblk0
brw-rw---- 1 root disk 179, 1 Oct 30 14:28 /dev/mmcblk0p1
brw-rw---- 1 root disk 179, 2 Oct 30 14:28 /dev/mmcblk0p2
Format partition 1 as FAT:
$ sudo mkfs.vfat /dev/<partition1>
… and partition 2 as ext4:
$ sudo mkfs.ext4 /dev/<partition2>
<device_name>
<partition1>
<partition2>
*Remember that our device name is mmcblk0 because we are using the SD adapter
14. Step 4 – Populate microSD card
Partition 1
MLO, u-boot,
uEnv.txt
Mount both partitions:
$ sudo mkdir /mnt/partition1
$ sudo mkdir /mnt/partition2
$ sudo mount -t vfat -v /dev/<partition1> /mnt/partition1
$ sudo mount -t ext4 -v /dev/<partition2> /mnt/partition2
Populate both partitions:
$ cd ~/OEL/
$ sudo cp -r partition1/* /mnt/partition1/
$ cd partition2
$ sudo tar -xvjf core-image-minimal-rpm-beaglebone.tar.bz2 -C /mnt/partition2
$ sudo cp -r -v ../boot/* /mnt/partition2/boot/
$ sudo cp -r -v ../scripts/* /mnt/partition2/home/root/
Now synchronize and unmount:
$ sync
$ sudo umount -v /mnt/partition1
$ sudo umount -v /mnt/partition2
Partition 2
Filesystem,
OEL images
*Replace <partition1> and <partition2> with the devices found in the previous step
*Takes a while…
15. Step 5 – Serial Connection
We will use minicom to talk to our BeagleBone Black. Install it first:
POWER SERIAL
$ sudo apt-get install minicom
Now, insert the micro SD card in the BeagleBone Black board …
.. and connect it to the host using a USB TTL serial cable as explained in
the next slide
*Minicom is a text-based serial port communications program
*Alternatively you can install it via the Synaptic Package Manager
1
17. Step 5 – Serial Connection
We need to find out the name of the port that minicom will listen to:
POWER SERIAL
$ dmesg | grep tty
...
[110831.397736] usb 3-2: pl2303 converter now attached to ttyUSB0
*Note that our serial port is ttyUSB0, yours might be different
Now, let’s configure minicom:
$ sudo minicom -s
18. Step 5 – Serial Connection
Select Serial port set up and configure:
- Serial Device
- Bps/Par/Bits
- Hardware Flow Control
- Software Flow Control
POWER SERIAL
+-----[configuration]------+
| Filenames and paths |
| File transfer protocols |
| Serial port setup |
| Modem and dialing |
| Screen and keyboard |
| Save setup as dfl |
| Save setup as.. |
| Exit |
| Exit from Minicom |
+---------------------------+
+------------------------------------------------------------+
| A - Serial Device : /dev/<serial_port> |
| B - Lockfile Location : /var/lock |
| C - Callin Program : |
| D - Callout Program : |
| E - Bps/Par/Bits : 115200 8N1 |
| F - Hardware Flow Control : No |
| G - Software Flow Control : No |
| |
| Change which setting? |
+------------------------------------------------------------+
19. Step 5 – Serial Connection
Save set up as default (dfl) so that you can start listening to the serial
connection at a later point in time:
POWER SERIAL
+-----[configuration]------+
| Filenames and paths |
| File transfer protocols |
| Serial port setup |
| Modem and dialing |
| Screen and keyboard |
| Save setup as dfl |
| Save setup as.. |
| Exit |
| Exit from Minicom |
+---------------------------+
Then “exit from minicom”, and start serial connection:
$ sudo minicom
20. Step 6 - Erase eMMC flash
Pressing the USER/BOOT button when powering on will temporarily change the boot order, But for the sake of
simplicity, you might want to erase the eMMC on the Black, so that it boots off automatically from the SD card
Power on board by connecting the USB to miniUSB cable and see the console
prompt in minicom. Get to u-boot command prompt by interrupting the initial boot
process (follow verbose instructions) and erase the eMMC:
ERASE
U-Boot 2014.07 (Jul 18 2014 - 14:49:15)
I2C: ready
DRAM: 512 MiB
MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Net: not set. Validating first E-fuse MAC
cpsw, usb_ether Hit any key to stop autoboot:
U-boot# mmc dev 1
U-boot# mmc erase 0 512 USER/BOOT
BUTTON
*We are using BBB revision C, we have experienced boot issues with previous revisions
*Some of you might already have it deleted since we have been testing some of the boards
21. Step 7 – Boot OEL
Connect the board to the network and reboot:
U-boot# reset
OEL should boot automatically. Log in as root and do not forget to
change your password:
...
Starting syslogd/klogd: done
Stopping Bootlog daemon: bootlogd.
Starting tcf-agent: OK
Open Enea Linux 2014-01-01 beaglebone /dev/ttyO0
beaglebone login: root
root@beaglebone:~# passwd
*Make sure you set a password, otherwise Eclipse will complain later when creating a remote ssh connection
22. Step 8 – Configure Package Manager
Check internet conection and make sure you have been given an ip address:
# ifconfig eth0
Let’s configure the package manager. Execute script and select option 1:
20.000 packages
for the beagle
# chmod 700 smart_config.sh
# ./smart_config.sh
Open Enea Linux script:
Smart package manager configurator
1) Configure Smart 3) Show Configuration
2) Reset Configuration 4) Quit
Please enter your choice: 1
*You can also show or reset the configuration in case you need to do some trouble-shooting
And update the package manager metadata:
# smart update
23. Step 9 – Customize your distro
openssh
It is time you start customizing your OEL distro... Search for any
package you like. Let’s say you need to ssh your board:
# smart search ssh
You will find openssh. Go ahead and install it:
# smart install openssh
You can now test an ssh connection from the host:
$ ssh root@<board_ip>
*You might need to reboot the BeagleBone so that the ssh client starts up
You done?
Try and install some packages that you are familiar with...
For instance, an alternative to vi editor. Can you find and install
nano editor?
REBOOT
BUTTON
24. Break 10:30 – 11:00
Join Open Enea Linux mailing list today and
win a BeagleBone Black
25. Workshop Part 2
11:00 to 12:00
Toolchain/SDK
Eclipse
SSH
ping.c
Install Toolchain
Install Eclipse
Create a remote connection
Create an ADT project
Remote Debugging with ping
26. Step 10 – Install Toolchain
First of all, we need to install the toolchain. Type this on the host.
Note that we are chosing opt/oel-beagle/ as target directory, which is relative:
$ cd ~/OEL/toolchain/
$ sudo chmod 775 oel-eglibc-x86_64-core-image-minimal-cortexa8hf-vfp-neon-toolchain-2014-01-01.sh
$ ./oel-eglibc-x86_64-core-image-minimal-cortexa8hf-vfp-neon-toolchain-2014-01-01.sh
Enter target directory for SDK (default: /opt/oel/2014-01-01): opt/oel-beagle/
You are about to install the SDK to "/home/<user>/OEL/toolchain/opt/oel-beagle". Proceed[Y/n]?Y
Extracting SDK...done
Setting it up...done
SDK has been successfully set up and is ready to be used.
*Note that opt/oel-beagle is a relative directory, the toolchain is actually installed here:
/home/<user>/OEL/toolchain/opt/oel-beagle
27. Step 11 – Install Eclipse
Let’s extract the Enea Linux Eclipse toolsuite:
$ cd ~/OEL/tools
$ tar –xvzf Enea-Linux-Eclipse_4.0.tar.gz
And start it in the background:
$ cd eclipse
$ ./eclipse &
Select your workspace folder: /home/<user>/workspace
Click OK and close welcome tab
/home/<user>/workspace
28. Step 12 – Remote Connection
Now we are going to connect Eclipse to our target.
Eclipse supports several types of remote connections: in Open Enea Linux, SSH connection is used.
This type of connection requires that a corresponding service (openssh) is enabled and running on the target.
1. Window → Open Perspective →
Other → Remote System Explorer
2. File → New → Other → Remote System Explorer
→ Connection
29. Step 12 – Remote Connection
4. Enter Host name (IP address of the beagle) and
Connection Name (bbb) → Finish
3. Select SSH Only
Enter IP address here
bbb
30. Step 12 – Remote Connection
5. To verify the remote connection, go to the Remote
Systems window tab and expand your connection.
Expand
6. It may ask for login information for the
initial ssh connection. Enter user and passwd.
Now your bbb Root file system should have
expanded completely and you should be able
to browse it.
31. Step 13 – Tools Set up
Set up general cross compiler preferences. Go to:
Window → Preferences → Yocto Project ADT
→ Cross Compiler Options:
- 1. Select Standalone pre-built toolchain and configure the following:
- 2. Toolchain Root Location: /home/<user>/OEL/toolchain/opt/oel-beagle
- 3. Sysroot Location: /home/<user>/OEL/toolchain/opt/oel-beagle/sysroots/
- 4. Target Architecture: “cortexa8hf-vfp-neon-oel-linux-gnueabi”
- 5. Click OK
.../opt/oel-beagle/
.../opt/oel-beagle/sysroots/
32. Step 14 – Create ADT Project
1. File → New → Project:
Expand C/C++ Project and select C Project
2. Expand Yocto Project ADT Autotools Project and
select Hello World ANSI C Autotools Project
Project name: “ping”
Use default location
Click Next
ping
/home/<user>/workspace/ping
*Default location should be /home/<user>/workspace/ping
33. Step 14 – Create ADT Project
3. Fill in Author → Finish 4. Open C/C++ perspective
34. Step 14 – Create ADT Project
$ cp ~/OEL/tools/ping.c ~/workspace/ping/src/ping.c
5. Now we need to replace the generated
file with our own ping file. Type on host:
6. And double check that the file has been replaced in Eclipse:
Double click ping.c
ping.c
35. Step 15 – Cross Compile
Right click on project name (ping in our case) → Reconfigure Project
Check for “Operation Successful” in Eclipse Configure Console window.
36. Step 15 – Cross Compile
Right click on project name (ping) → Build Project
Verify logs in CDT Build Console to ensure it has built, and see resulting binaries in Project Explorer window
*You can select the various Eclipse consoles
by clicking the dropdown console button
37. Step 16 – Remote Debugging
1. Run → Debug Configurations → Expand C/C++ Remote Application
and select Ping_gdb_arm-oel-linux-gnueabi
3. Type “/home/root/ping”
ping
src/ping
*This tells Eclipse to deploy the ping binary in the root home folder of the target
2. Select connection: bbb
4. Do not click on Debug yet…
/home/root/ping
38. Step 16 – Remote Debugging
5. Arguments Tab → Add 127.0.0.1 to ping to ourselves.
6. Click Debug and open debug perspective
127.0.0.1
39. Step 16 – Remote Debugging
7. This should launch a debug session and break your program at the entry into the main function
40. Step 16 – Remote Debugging
8. To run a simple test, set a breakpoint at line 688 (Shortcut to find line: CTRL + L)
9. Then go to Run → Resume (Shortcut for resume: F8)
*Repeat this step a few times, and see
that it breaks at every reply
Ping.c
Ping
Ping
*Double-click here
41. More About Tools
More advanced User space debugging
Kernel Debugging (KDBG)
- shares serial connection
- needs kernel sources and vmlinux file – kernel debug image
- uses SysRq magic commands to put the kernel into debugging mode
- rest is normal GDB debugging
- scheduling/execution control are still sensitive areas
- possible to debug kernel modules
- need to provide GDB with module mapping data
- needs special kernel configs:
CONFIG_KGDB=y
CONFIG_KGDB_SERIAL_CONSOLE=y
CONFIG_DEBUG_INFO=y
- support for debugging shared objects
- support for debugging multicore applications
- attach to applications at runtime
- debug large scale projects with separate build systems