- Ubuntu 20.04 LTS image for Rasperry Pi4(64bit/32bit), Pi3(64bit/32bit), Pi2(32bit)
Recommendation: 32bit image (Why? There are way more resources (toutorials, documentation) on the internet for 32bit issues. ) - BaleanaEtcher
- SD-Card less than 32GB (-> FAT)
- Start Etcher
- Choose image file
- Choose SD card
- Flash SD Card
After the SD-Card flashing, edith the networkconfiguration.
Note: This is only needed, if your router does not support static DHCP leases for specific MAC addresses.
Example: A device with the Mac address of "dc:a6:32:18:xx:xx" will allways be assigned to the IP address of "192.168.1.200"
- Edith the network-config file in the system-boot section of the SD-Card.
- Connect the ethernet cable (if configured with ethernet); if WiFi was configured ignore this step
- Connect the Power
- Raspberry starts
Access your Pi with ssh. The commands are the same on Windows 10 and Linux
Default user: ubuntu Default password: ubuntu
ssh ubuntu@<ip-of-raspberry-pi>
Example: ssh [email protected]
Install the GNU Compiler Collection && Debugger
sudo apt install gcc gdb
Check if it's installed.
which gcc
If it's installed something like /usr/bin/gcc is shown. \
Check if ARM toolchain is installed
arm-none-eabi-gcc
If something like the below message is shown the toolchain is installed:
** arm-none-eabi-gcc: fatal error: no input files compilation terminated. **
Install the ARM embedded toolchain
sudo apt install gcc-arm-none-eabi
Check if python3 is installed.
which python3
If no output is shown install it.
sudo apt install python3
\
\
Check if pip3 is installed.
which pip3
If no output is shown install it.
sudo apt install python3-pip
\
Check if VIM is installed.
which vim
If no output is shown install it.
sudo apt install vim
\
Show current folder
pwd
Change to the home folder of the ubuntu user and create a projects directory
cd
mkdir projects
Show content of the current folder. Verify that the folder projects was created.
ls -la
Example: drwxrwxr-x 2 ubuntu ubuntu 4096 Aug 28 09:23 projects
sudo apt install python3-gpiozero
Check if module was installed corretly
pip3 freeze | grep RPi
# folder /home/ubuntu/projects
vim ledon.py
- Type: "i" for entering the VIM insert mode
- Copy/Pastefollowing code
#!/usr/bin/env python3
from gpiozero import LED
from time import sleep
# Number of the GPIO PIN not the physical pin
# GPIOPin 24 -> physical pin 18
# GPIOPin 21 -> physical pin 40
gpioPin = 40
led = LED(gpioPin)
print("Using GIPOPin %d" % gpioPin)
print("-----------------")
while True:
print("LED On")
led.on()
sleep(1)
print("LED Off")
led.off()
sleep(1)
- hit ESC and type
- :wq which means write and quit
Make file executable for current user
chmod u+x ledon.py
Execute python code
./ledon.py
Result: An output shold be generated an the LED should turn on and off.
Create folder
# folder /home/ubuntu/projects/test_asm1
mkdir test_asm1 && cd test_asm1
Create assembly file by pasting the contents of the file asmtest2.s
vim asmtest2.s
# hit i -> for insert mode
# copy paste content from file
# hit ESC
# hit :wq
Create "makefile" file by pasting the contents of the file makefile
vim makefile
# hit i -> for insert mode
# copy paste content from file
# hit ESC
# hit :wq
Manually:
as -o asmtest2.o asmtest2.s
ld -o asmtest2 asmtest2.o
Automatically:
make
# in the projecet folder /home/ubuntu/projects/test_asm1
./asmest2 ; echo $?
Output should be 65
The gcc-arm-none-eabi consists of the following min binaries:
- C Compiler (gcc): arm-none-eabi-ld
- C++ Compiler (gcc): arm-none-eabi-g++
- Assembler: arm-none-eabi-as
- Object copy: arm-none-eabi-objcopy
- Object dump: arm-none-eabi-objdump
List all "arm-*" binaries.
ls /usr/bin/ | grep arm-none-*
@Todo needs to be tested first Combile Manually for (cortex-a72 - Raspberry Pi 4)
arm-none-eabi-gcc -c -mcpu=cortex-a72 asmtest2.s -o asmtest2.o
# link the object file using our linking script
$ arm-none-eabi-ld asmtest2.o -o asmtest2 -T asmtest2.ld
# we need pure binary code, not an ELF file, so strip the ELF header
$ arm-none-eabi-objcopy asmtest2 -O binary kernel.img
Combile Manually for (cortex-a53 - Raspberry Pi 3B)
arm-none-eabi-gcc -c -mcpu=cortex-a72 asmtest2.s -o asmtest2.o
# link the object file using our linking script
$ arm-none-eabi-ld asmtest2.o -o asmtest2 -T asmtest2.ld
# we need pure binary code, not an ELF file, so strip the ELF header
$ arm-none-eabi-objcopy asmtest2 -O binary kernel.img
For when to use which tool, consult page 36 of this PDF from the university of Michigan.
Assembly files (.s) => (assembler Tool:*-as ) => Object files (.o) => (linker Tool: *-ld)