============================= Embedded Systems II Quick Reference ============================= Hochschule Augsburg H. Högl 2023 ------------- URL: Hints: 1) \ means line continuation +========+ | ESTOOL | +========+ = https://gitlab.informatik.hs-augsburg.de Souce code (Python 3) /hhoegl/estool Documentation /es2/estool/estool.html Configuration .estool/estool.ini Get help with "estool -h" Installation Clone repository and install with pip: cd estool sudo python -m pip install --upgrade . +=====+ | GDB | +=====+ Commands --------- q(uit) quit continue continue program C-L refresh C-c interrupt program load load prog to FLASH or SRAM b ARG set breakpoint. ARG is fct or linenum info b info about bkpts del N delete bktp N list S list source code info reg list registers p $rN print reg, N=0..12 p $sp stack ptr (r13) p $lr link register (r14) p $pc program cntr (r15) p VAR print VAR help p show details of p x MEM dump memory help x show details of x n next line (step over) s next line (step into) ni next instruction si step instruction finish run until fct ret disas disassemble where where is program | help x | less Pager Monitor (send to OpenOCD) ------------------------- moni Send an OpenOCD telnet cmd to GDB moni reset halt moni reset run Windows ------- C-x a toggle tui window C-x A C-x C-a (hint: C-x a means press keys "Control" and "x", release both and press "a". C-x C-a means press "Control", press "x", release "x", press "a", release "a", release "Control") C-x 1 tui with 1 win C-x 2 toggle win layouts C-x o other window C-x s toggle SingleKey Various important things ------------------------ Executable for ARM arm-none-eabi-gdb arm-none-eabi-gdb-py Nice options --tui text user interface -silent -iex "set auto-load \ safe-path /" --configuration check e.g. Python support target remote localhost:3333 connect to OpenOCD Init files 1) /.estool/gdbinit 2) ~/.gdbinit 3) /etc/gdb/gdbinit Python 3 ... (gdb) python >import sys >print(sys.version_info) >end 3.8.11 (default, Jul 20 2022, 16:45:24) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] (gdb) ... or no Python: "Scripting in the 'Python' \ language is not supported \ in this copy of GDB." Documentation apt install gdb-doc info gdb More info http://www.dirac.org/\ linux/gdb/ https://beej.us/guide/\ bggdb http://www.unknownroad.com\ /rtfm/gdbtut/ +======+ | GCC | +======+ GNU Compiler Collection Preferred locations: 1) Debian packages gcc-arm-none-eabi gdb-arm-none-eabi (= gdb-multiarch) Installed in /usr/bin/ 2) https://developer.arm.com/\ Tools%20and%20Software/GNU%20Toolchain Program names arm-none-eabi-gcc arm-none-eabi-as arm-none-eabi-ld arm-none-eabi-objcopy arm-none-eabi-objdump arm-none-eabi-nm arm-none-eabi-readelf GCC Options -v report version -mcpu=cortex-m3 -mcpu=cortex-m4 -mthumb -Wall -pedantic -std=c99 (c11, gnu11) -g -g3 -O0 (-Og) -O3 -Os -c -o -I. -Dmacro=value -M dependencies Output ASM LISTING -Wa,-ahls asm lst >stdout -Wa,-ahls=main.lst asm lst to file objdump -S main.elf asm lst to file Output LINKER MAP file -Wl,-Map,main.map Documentation apt install gcc-doc apt install binutils-doc info gcc info ld info as info objdump ... +================+ | LINKER SCRIPTS | +================+ Configuration for STM32F100 ENTRY(RESET_Handler) MEMORY { sram (rwx) : # 8K from \ # 0x20000000 flash (rx) : # 128K from # 0x08000000 } _end_stack = 0x20002000; SECTIONS { . = ORIGIN(flash); vectors : { *(.vectors) } >flash .text : { *(.text) *(.rodata) *(.rodata*) _end_text = .; } >flash .data : { _start_data = .; *(.data) _end_data = .; } >sram AT >flash . = ALIGN(4); .bss : { _start_bss = .; *(.bss) _end_bss = .; } >sram . = ALIGN(4); _start_stack = .; } _end = .; PROVIDE(end = .); Lit.: apt install binutils-doc info ld (chapter "Linker Scripts") +======+ | TMUX | +======+ Prefix C-z (C-b) Init file ~/.tmux.conf See sample file in estool/etc/_tmux.conf tmux -V report version tmux -2 256 colours C-z select window C-z c create window C-z & kill window C-z | split vertical C-z - split horizontal C-z x kill pane C-z q window info C-z i pane info C-z Z toggle zoom C-z [ copy mode Space start selection (vi keys move around) Enter copy selection C-z ] paste selection tmux show-buffer tmux save-buffer file C-z d detach tmux tmux attach attach tmux C-z : tmux prompt tmux kill-session C-z s select session C-z ? help tmux ls list sessions tmux choose-session tmux kill-session tmux kill-server Documentation man tmux +======+ | VIM | +======+ vim -p *.c *.h open all .c and .h files in tabs :e file edit file :w write file :ls list buffers :q quit gt go to next tab gT go to prev tab Ngt go to tab N :tabnew open new tab :tabc close tab :make run make :cn next error :cfirst first error :clast last error ctags (use exuberant ctags \ "ctags *.c *.h") C-] jump to tag C-t jump back from tag :cs add cscope.out :cs show :cstag main vim -d file1 file2 compare two files Lit.: * Swaroop, A Byte of Vim http://www.swaroopch.com/\ notes/vim/ * Steve Oualline, The Vim Book, 2007 http://www.oualline.com/\ vim-book.html * http://www.vim.org * vimtutor +=========+ | OpenOCD | +=========+ Init file: openocd.cfg Options -v report version -h print help -c "cmd" execute cmd -d N debug level N=0..3 telnet localhost 4444 > help ... > exit # quit telnet Flash a program: > reset halt > flash probe 0 > flash write_image erase \ main.bin 0x08000000 > reset run Homepage https://openocd.org +==========+ | STLINK | +==========+ Homepage https://github.com/stlink-org/stlink Flashing the STM32 st-flash write /dev/sg0 \ main.bin 0x08000000 +==========+ | PICOCOM | +==========+ udev rules /etc/udev/\ rules.d/\ 81-usb-to-serial.rules picocom -b 9600 /dev/ttyUSB0 picocom -b 9600 /dev/stm32lab_uart Exit with C-a C-x +=========+ | MAKE | +=========+ Makefile Makefile contains sequence of target: dependency action is a hard tab character ---Makefile--- all: main main.o: main.c gcc -c main.c main: main.o gcc -o main main.o clean: rm -f main main.o ---End of Makefile--- Run make: make run first target make main.o run target main.o make clean run target clean Documentation apt install make-doc info make +==========+ | PYTHON | +==========+ (use Python 3) python setup.py --help python setup.py \ --help-commands python setup.py \ --help install python setup.py build sudo python setup.py \ install sudo python -m pip \ uninstall estool cd estool sudo python -m pip \ install --upgrade . https://packaging.python.org === END ===