[defcon russia #29] Борис Савков - bare-metal programming на примере raspberry...
TRANSCRIPT
Bare-metal programming на примере Raspberry Pi
10/03/2017DCG #7812
г. Санкт-Петербург
Defcon Russia (DCG #7812) 2
Who am iРанее: • DC4919; • Bushwhackers; • BalalaikaCr3w.Сейчас: • Evil Dwarfs; • Безопасность АСУ ТП; • OWASP Russia; • jbfc;• It sec pro course;• ASP Labs.
ONE MORE SECURITY RESEARCHER
Defcon Russia (DCG #7812) 3
Bare-metal
• Обучениеhttp://www.cl.cam.ac.uk/freshers/raspberrypi/tutorials/ http://wiki.osdev.org/Raspberry_Pi_Bare_Bones
• Производительность• For fun!
Defcon Russia (DCG #7812) 4
Raspberry pi
Defcon Russia (DCG #7812) 5
Why raspberry pi • дёшево• много материалов (-RP 3)
Defcon Russia (DCG #7812) 6
CPU
RPi:• ARM1176GTZFRPi 2:• Cortex A7RPi 3:• Cortex A53(Aarch-64)
Defcon Russia (DCG #7812) 7
CPURPi:• arm-none-eabi-gcc -O2 -mfpu=vfp -mfloat-abi=hard
-march=armv6zk -mtune=arm1176jzf-s arm-test.cRPi 2:• arm-none-eabi-gcc -O2 -mfpu=vfp -mfloat-abi=hard
-march=armv7-a -mtune=cortex-a7 arm-test.cRPi 3:• aarch64-elf-gcc (linaro cross gcc)
(https://releases.linaro.org/components/toolchain/binaries/6.1-2016.08/aarch64-elf/ )
*arm-none-eabi-objcopy kernel.elf -O binary kernel.img
Defcon Russia (DCG #7812) 8
Cortex A53
Defcon Russia (DCG #7812) 9
How it worksRAM 0
X00000000-------------------
IO0x3f0000000
or0x20000000
-------------------GPIO
0x3f0200000 or
0x20200000-------------------
...
GPU
CPU
Defcon Russia (DCG #7812) 10
Steps
1. Start GPU– Read SD
2. CPU – bootload.bin, start.elf, config
3. Start CPU cores– Run Kernel.img
Defcon Russia (DCG #7812) 11
Files
1. bootloader.binзагружает start.elf
2. start.elfпрошивка GPU которая стартует CPU
3. config.txtконфигурация
4. kernel.img OS или ваша программа
Defcon Russia (DCG #7812) 12
config.txtExamples:
arm_control=0x200 (запуск в x64)kernel_old=1 (загрузка с 0)disable_commandline_tags=1
kernel_old=1disable_commandline_tags=1
kernel_address=0x06000000
Defcon Russia (DCG #7812) 13
Other files
https://github.com/raspberrypi/firmware
Defcon Russia (DCG #7812) 14
GPIOhttps://rawgit.com/msperl/rpi-registers/master/rpi-registers.html
Defcon Russia (DCG #7812) 15
UART
Examples:https://github.com/gingold-adacore/rpi3-fosdem17
Defcon Russia (DCG #7812) 16
Blink
Examples:http://www.valvers.com/open-software/raspberry-pi/step01-bare-metal-programming-in-cpt1/ (RPI, RPI 2)
https://github.com/dwelch67/raspberrypi
Defcon Russia (DCG #7812) 17
Wanna more
Examples:https://github.com/PeterLemon/RaspberryPi
https://www.raspberrypi.org/forums/viewtopic.php?t=72260
Defcon Russia (DCG #7812) 18
USB
Examples:https://github.com/rsta2/uspi
Defcon Russia (DCG #7812) 19
Free SCADA
Defcon Russia (DCG #7812) 20
Q?