|
| 1 | +# SH1106 OLED demo (navigation menu for a motor controller) |
| 2 | + |
| 3 | +See detailed description of the emulated system here https://github.com/jpcornil-git/Cone2Hank |
| 4 | + |
| 5 | +- Use arrows to navigate menu |
| 6 | +- \<enter\> to select |
| 7 | +- \<space\> to start,pause or stop (long press) motor |
| 8 | +- 'v' to start/stop VCD traces |
| 9 | +- 'q' or ESC to quit |
| 10 | + |
| 11 | +**NOTE**: Emulation may be slightly slower than realtime and a keypress has to be long enough to cope with that. |
| 12 | + |
| 13 | +## Usage |
| 14 | +Command line options: |
| 15 | +``` |
| 16 | +$ sh1106demo.elf --help |
| 17 | +Usage: sh1106demo.elf [...] <firmware> |
| 18 | + [--help|-h|-?] Display this usage message and exit |
| 19 | + [--list-cores] List all supported AVR cores and exit |
| 20 | + [-v] Raise verbosity level |
| 21 | + (can be passed more than once) |
| 22 | + [--freq|-f <freq>] Sets the frequency for an .hex firmware |
| 23 | + [--mcu|-m <device>] Sets the MCU type for an .hex firmware |
| 24 | + [--gdb|-g [<port>]] Listen for gdb connection on <port> (default 1234) |
| 25 | + [--output|-o <file>] VCD file to save signal traces (default gtkwave_trace.vcd) |
| 26 | + [--start-vcd|-s Start VCD output from reset |
| 27 | + [--pc-trace|-p Add PC to VCD traces |
| 28 | + [--add-trace|-at <name=[portpin|irq|trace]@addr/mask or [sram8|sram16]@addr>] |
| 29 | + Add signal to be included in VCD output |
| 30 | + <firmware> An ELF file (can include debugging syms) |
| 31 | +``` |
| 32 | +## Examples |
| 33 | +### Execute firmware.elf (with no .mmcu section -> -m and -f required) on system |
| 34 | +``` |
| 35 | +$ sh1106demo.elf -m atmega32u4 -f 16000000 firmware_no_mmcu.elf |
| 36 | +``` |
| 37 | + |
| 38 | +### Start system and wait for gdb to connect, load firmware, ... |
| 39 | +``` |
| 40 | +$ sh1106demo.elf -m atmega32u4 -f 16000000 -g |
| 41 | +``` |
| 42 | + |
| 43 | +### Execute firmware.elf on system and trace signals in a VCD file |
| 44 | +- .mmcu section of the firmware includes something like: |
| 45 | + ``` |
| 46 | + #include "avr_mcu_section.h" |
| 47 | + |
| 48 | + extern void *__brkval; |
| 49 | + |
| 50 | + AVR_MCU (F_CPU, "atmega32u4" ); |
| 51 | + AVR_MCU_VOLTAGES(3300, 3300, 3300); |
| 52 | + AVR_MCU_VCD_FILE("simavr.vcd", 10000000); |
| 53 | + |
| 54 | + const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ = { |
| 55 | + { AVR_MCU_VCD_SYMBOL("Encoder"), .what = (void*) &PIND, .mask=(1<<PIND2), }, |
| 56 | + { AVR_MCU_VCD_SRAM_16("Heap"), .what = (void*)(&__brkval), }, |
| 57 | + }; |
| 58 | + ``` |
| 59 | +- Options from the command line: |
| 60 | + - Add a 16 bits trace for Stack Pointer (SPL/SPH) (could also be in the section above) |
| 61 | + - Add a (16 bits) trace for Program Counter (PC) |
| 62 | + - Start VCD dump (set to "simavr.vcd" in the .mmcu section) from reset |
| 63 | +``` |
| 64 | +$ sh1106demo.elf --add-trace Stack=sram16@0x5d -p -s firmware_mmcu.elf |
| 65 | +``` |
| 66 | + GTKWave ouput |
| 67 | + |
| 68 | + |
0 commit comments