Skip to content
SaeHie Park edited this page Feb 7, 2022 · 44 revisions

Flash img to SD card

sudo dd if=what_ever.img of=/dev/sdj status=progress bs=4M

Setup with Ubuntu 18.04 LTS

Ubuntu Server aarch64 now available

raspi-config

Download from https://archive.raspberrypi.org/debian/pool/main/r/raspi-config/

Follow https://askubuntu.com/questions/1130052/enable-i2c-on-raspberry-pi-ubuntu

Setup with Ubuntu Mate 16.04 LTS

Packages

sudo apt-get install vim dnsutils build-essential cmake nfs-common libunwind8-dev

Cross build tools

sudo apt-get install gcc make binutils-arm-linux-gnueabi
sudo apt-get install gcc-arm-linux-gnueabihf  g++-arm-linux-gnueabihf

DNS

Need to set DNS nameserver IP at /etc/resolv.conf file if DHCP is updating to a wrong server

nameserver (some server)
nameserver (more server)
nameserver 8.8.8.8

Partition with Swap...

Command (m for help): p
Disk /dev/mmcblk0: 29.7 GiB, 31914983424 bytes, 62333952 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
Disklabel type: dos
Disk identifier: 0x580a66ff

Device         Boot    Start      End  Sectors  Size Id Type
/dev/mmcblk0p1 *        2048   133119   131072   64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2        133120 54132735 53999616 25.8G 83 Linux
/dev/mmcblk0p4      54132736 62333951  8201216  3.9G 82 Linux swap / Solaris

Mount USB memory stick

/etc/fstab

/dev/sda1    /home/maxwell/u    ext4    defaults    0    1

Mount SSD and replace work, var

attach, edit /etc/fstab

UUID=whatever /ssd ext4 defaults 0 2

reboot and rsync var

sudo rsync -aqxP /var /ssd

change /var in /etc/fstab

/ssd/ssd /home/ubuntu/ssd none bind
/ssd/var /var none bind

Tools and libraries

mkdir -p $HOME/w/github/rpi && cd $HOME/w/github/rpi
git clone https://github.com/raspberrypi/firmware

cd /opt
sudo mv vc vc.old
sudo cp -Rv $HOME/w/github/rpi/firmware/hardfp/opt/vc .

Information

Useful Links

View running frequency (http://raspberrypi.stackexchange.com/questions/1219/how-do-i-determine-the-current-mhz)

sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

edit /etc/apt/apt.conf.d/10periodic and change to

APT::Periodic::Update-Package-Lists "0";

Running Status

Temperature

/opt/vc/bin/vcgencmd measure_temp
#!/bin/bash

cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "$((cpu/1000)) c"

clock=$(</sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
echo "$((clock/1000)) MHz"

Remote debug with gdb

Better to install this

sudo apt-get install libc6-dbg

RPi should be also connected to network with IP address

run gdb server in RPi

gdbserver :1234 someprogram

where 1234 is listening port

run gdb in develop host(where source code exist)

run gdb

arm-none-eabi-gdb

in gdb,

symbol-file <target binary>
target remote <RPi IP:1234>

where <target binary> is which you are running in RPi

SysGCC

Good link: http://wiki.igrebot.fr/index.php?title=Raspi_Cross_Toolchain

Uses Eclipse as IDE

With Visual Studio 2015

  1. Start a Makefile Project
  • File > New > Project
  • VisualC++ > General > Makefile Project
    • Build command line: build.bat
    • Clean commands: clean.bat
    • Clear Output edit box
  1. Project properties
  • clean all VC++ Directories
  • NMake
    • delete Preprocessor Definitions
    • add to includes
      • D:\SysGCC\Raspberry\arm-linux-gnueabihf\include\c++\4.9
      • D:\SysGCC\Raspberry\lib\gcc\arm-linux-gnueabihf\4.9\include
      • D:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\include\arm-linux-gnueabihf
      • D:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\include
  1. Add Source
  • Project right click > Add > New Item > C++ File(.cpp)
  • Main.cpp
#include <stdio.h>

int main()
{
  printf("Hello Pi from windows.\n");
  return(0);
}
  1. Add batch files
  • build.bat
set sources=*.cpp
set executable=Main
set pscp_exe="(path of pscp.exe from putty)"
set putty_key="(file path of private key generated with puttygen)"

PATH=D:\SysGCC\Raspberry\arm-linux-gnueabihf\bin:$PATH
PATH=D:\SysGCC\Raspberry\bin:$PATH

D:\SysGCC\Raspberry\bin\arm-linux-gnueabihf-gcc-4.9.exe -Wall -O3 %sources% -o %executable%

%pscp_exe% -i %putty_key% %executable% pi@(raspberry pi address):/home/pi/VS/.
  • need to save public key to ~/.ssh/authorized_keys file
  1. save as project template ...

DNS update fix

http://askubuntu.com/questions/690511/how-to-change-dns-in-ubuntu-15-10

Enable i2c

/boot/config.txt

# i2c on
dtparam=i2c_arm=on

# i2s on
dtparam=spi=on

Moving mysql data to another drive

Follow https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04

# stop
sudo service mysql stop
sudo service mysql status

# move
sudo rsync -av /var/lib/mysql /var/hdd/mysqldb

# change cfg
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
# change to new location
datadir=/var/hdd/mysqldb/mysql
# and maybe for the log

# update AppArmor
sudo vi /etc/apparmor.d/tunables/alias
# add locations
alias /var/lib/mysql/ -> /var/hdd/mysqldb/mysql/,
alias /var/log/mysql/ -> /var/hdd/log/mysql/,

# restart AppArmor
sudo service apparmor restart

# fake mysql starter
sudo mkdir /var/lib/mysql/mysql -p

# start mysqld
sudo service mysql start

# check 
mysql -u root -p
# where?
select @@datadir;

For Raspbian

GCC-4.8

Visit gcc-4-8-on-raspberry-pi-wheezy to install GCC-4.8 from jessie.

Packages

  • dnsutils is missing for raspbian jessie 2015-11 version

Ubuntu Mate

SSH

# Enable by default
sudo update-rc.d ssh defaults

--> USE raspi-config !!!

Boot logo

# disable boot logo
sudo apt-get remove plymouth

# reinstall
sudo apt-get install lightdm plymouth plymouth-label plymouth-theme-ubuntu-mate-logo

--> USE raspi-config ALSO !!!

CPU clock?

$ lscpu
Architecture:          armv7l
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    4
Socket(s):             1
Model name:            ARMv7 Processor rev 4 (v7l)
CPU max MHz:           1200.0000
CPU min MHz:           600.0000

Clone this wiki locally