Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
-
Upload
eneasoftware -
Category
Software
-
view
159 -
download
2
Transcript of Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
Open Enea Linux
BeagleBone Black
Hands-on workshop
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)?
Did you know that...
Enea is the only Linux
Foundation authorized
training parter in Europe?
What we do...
Software Products
Linux
RTOS
Embedded Mgmt and HA
Embedded data bases
Software services
Training
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
Linux Kernel
Package Package
Tools
Linux Kernel
Package Package
Package Package
Package
Linux Kernel
Package Package
Package Package
Package Package
Package Package
Tools
Linux Kernel
Package Manager
Open Source
Tools
Package
Package
Package
Package Package
Package
Package
Package
*Embedded Market Forecasters’ surveys
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
Workshop fundamentals
Workshop material
64b Linux Machine
BeagleBone Black
4/8GB microSD card
+ adapter
USB to TTL cable
Mini USB cable
Hardware Accessories
USB stick
Workshop Part 1
9:30 to 10:30
Bulk binaries to computer
Prepare SD card
Serial Connection
Boot OEL
Configure Package ManagerSERIAL
Step 1 – Bulk binaries
Copy binaries locally
- OEL Images- SDK/Toolchain- Enea Linux Eclipse
$ cd
$ mkdir OEL
$ cd OEL
$ cp -r -v /media/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 might find ENEAUSB under /media/<user>/ENEAUSB
*You can now remove the USB stick safely
Step 2 – Connect microSD cardConnect 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:
Alternatively, you can also list your existing devices this way:
$ ls /dev/mmc*
$ ls /dev/sd*
$ 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.
/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,…)
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 actiona 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
*Note that you need to replace /dev/<device_name> with your actual device name
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)
Step 3 – Partition microSD card
Partition 1From beginningTo 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 2From sectr 4095
To end
*If you make a mistake, you can always initialize the partition table by selecting o, and start from scratch
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 1From beginningTo sector 4095
Partition 2From sectr 4095
To end
*You might get a warning after this, but do not worry.
Step 3 – Partition microSD card
Partition 1vfat
Partition 2ext4
Format partition 1 as FAT:
$ sudo mkfs.vfat /dev/<partition1>
… and partition 2 as ext4:
$ sudo mkfs.ext4 /dev/<partition2>
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
<device_name>
<partition1>
<partition2>
*Remember that our device name is mmcblk0 because we are using the SD adapter
Step 4 – Populate microSD card
Partition 1MLO, 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
Now synchronize and unmount:
$ sync
$ sudo umount -v /mnt/partition1
$ sudo umount -v /mnt/partition2
$ 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/
Populate both partitions:
Partition 2Filesystem,OEL images
*Replace <partition1> and <partition2> with the devices found in the previous step
*Takes a while…
Step 5 – Serial Connection
We will use minicom to talk to our BeagleBone Black. Install it first:
SERIALPOWER
*Minicom is a text-based serial port communications program
*Alternatively you can install it via the Synaptic Package Manager
$ 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
1
Pin connection:
- Pin1 (black): Ground
- Pin4 (green): Receive
- Pin5 (white): Transmit
Step 5 – Serial Connection
We need to find out the name of the port that minicom will listen to:
SERIALPOWER$ dmesg | grep tty
...
[110831.397736] usb 3-2: pl2303 converter now attached to ttyUSB0
Now, let’s configure minicom:
*Note that our serial port is ttyUSB0, yours might be different
$ sudo minicom -s
Step 5 – Serial Connection
Select Serial port set up and configure:
- Serial Device
- Bps/Par/Bits
- Hardware Flow Control
- Software Flow ControlSERIALPOWER
+-----[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? |
+------------------------------------------------------------+
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:
SERIALPOWER
+-----[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
Step 6 - Erase eMMC flash
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
*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
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 512USER/BOOT
BUTTON
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
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
Step 8 – Configure Package Manager
Let’s configure the package manager. Execute script and select option 1:
20.000 packagesfor the beagle
And update the package manager metadata:
# smart update
Check internet conection and make sure you have been given an ip address:
# ifconfig eth0
# 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
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 install openssh
You can now test an ssh connection from the host:
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?
$ ssh root@<board_ip>
# smart search ssh
You will find openssh. Go ahead and install it:
*You might need to reboot the BeagleBone so that the ssh client starts up
REBOOT
BUTTON
Break 10:30 – 11:00
Join Open Enea Linux mailing list today and win a BeagleBone Black
Workshop Part 2
11:00 to 12:00
Toolchain/SDKEclipse
SSH
ping.c
Install Toolchain
Install Eclipse
Create a remote connection
Create an ADT project
Remote Debugging with ping
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
Step 11 – Install Eclipse
$ cd ~/OEL/tools
$ tar –xvzf Enea-Linux-Eclipse_4.0.tar.gz
$ cd eclipse
$ ./eclipse &
Let’s extract the Enea Linux Eclipse toolsuite:
And start it in the background:
Select your workspace folder: /home/<user>/workspace
Click OK and close welcome tab
/home/<user>/workspace
Step 12 – Remote ConnectionNow 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 Explorer2. File → New → Other → Remote System Explorer
→ Connection
Step 12 – Remote Connection
4. Enter Host name (IP address of the beagle) and
Connection Name (bbb) → Finish3. Select SSH Only
bbb
Enter IP address here
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.
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/
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
*Default location should be /home/<user>/workspace/ping
ping
/home/<user>/workspace/ping
Step 14 – Create ADT Project
3. Fill in Author → Finish 4. Open C/C++ perspective
Step 14 – Create ADT Project
$ cp ~/OEL/tools/ping.c ~/workspace/ping/src/ping.c5. 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
Step 15 – Cross Compile
Right click on project name (ping in our case) → Reconfigure Project
Check for “Operation Successful” in Eclipse Configure Console window.
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
Step 16 – Remote Debugging1. Run → Debug Configurations → Expand C/C++ Remote Application
and select Ping_gdb_arm-oel-linux-gnueabi
3. Type “/home/root/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
src/ping
ping
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
Step 16 – Remote Debugging
7. This should launch a debug session and break your program at the entry into the main function
Step 16 – Remote Debugging8. To run a simple test, set a breakpoint at line 688 (Shortcut to find line: CTRL + L)
*Repeat this step a few times, and see
that it breaks at every reply
9. Then go to Run → Resume (Shortcut for resume: F8)
Ping.c
PingPing
*Double-click here
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
More About Tools
- support for debugging shared objects
- support for debugging multicore applications
- attach to applications at runtime
- debug large scale projects with separate build systems
More advanced User space debugging
Tools Overview
Tools Overview
Thanks
Join Open Enea Linux mailing list today and win a BeagleBone Black