Tags:
create new tag
view all tags

Preparing Ubuntu on the PC for Raspberry Pi development

Exercises:

Create your own user and add him to the sudo group (usermod -a -G sudo yourUserName).
Go through the exercises of the first student session and try everything. If something does not work (e.g. the tree command does not work or the some environment variables are not set, then mark these down and solve the problems by adding the corresponding commands with apt install or by adding the corresponding environment variables in ~/.bash_profile or ~/.bashrc.

Adding additional commands

I personally prefer to use emacs, which is not installed by default on Ubuntu. Please install it if it is not there. Are there other commands you are missing? Install them. If you want to use an IDE (Integrated Development Environment) then eclipse is a good candidate.

You may also want to install Qt5 and qtcreator. This however is only useful if you cross compile at least the base Qt5 system (all the necessary libraries) for the raspberry Pi. https://wiki.qt.io/RaspberryPi2EGLFS explains how to do this. Don't be mistaken however: this is not for the faint hearted and it will take some 2-3 h for the compilation to terminate if everything goes well.

gnuplot is not installed but needed in the next session on programming. Install it. Create a text file with some data and test gnuplot by plotting them.

The problem is that my PC is now fully configured including everything that is needed for cross compilation, which is not the case if you only just installed the base OS.
Make sure the file system looks similar to mine:
I have: /opt/ucc as base directory for everything concerning the course. In /opt/ucc I have

  • include
  • lib
  • lectures
  • micros
  • projects

Under lectures create subdirectories

  • Lectures-2017
    • exercises
      • problems
      • solutions
    • images
    • slides

Cross Compilation tools

Install the cross compilation tools for the Raspberry Pi:

  • arm-linux-gnueabihf-gcc
  • arm-linux-gnueabihf-g++

These go to /opt/ucc/micros/raspberry/tools. Use git clone https://github.com/raspberrypi/tools to get the compilers. Set up the CROSS_COMPILE environment variable to contain arm-linux-gnueabihf-
Try to compile a hello world program with the gcc compiler on the PC as well as using the cross tools you just copied. Create Makefiles to do the compilation. Make sure these are easily accessible by adding their binary directory to the execution path in your .bash_profile.
Install qemu-arm and try the ARM emulator to run your cross compiled program on the PC. If you statically link your arm program the emulator should be able to run it straight away. If you dynamically link, then you will probably miss the shared library ld-linux.so.3. This can be solved by copying part of the Raspberry Pi root file system to the PC. I put these into /opt/ucc/micros/raspberry/sysroot. You will need

  • /lib
  • /usr/lib
  • /usr/include
  • /opt/vc

Now try to find ld-linux.so.3 and set up the environment variable QEMU_LD_PREFIX correspondingly. If this is correct you should be able to run also dynamically linked ARM binaries on your PC.

-- Uli Raich - 2017-09-04

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatodt tutor_1.odt r1 manage 21.1 K 2017-09-11 - 11:06 UnknownUser  
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2017-09-11 - uli
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback