# Altimeter thingo ## Getting Started ### Submoule checkout This repo uses the [Unity](http://www.throwtheswitch.org/unity) unit testing library, as well as Bosch's BMP3 Sensor API, which are included as submodules. You must therefore do a recursive clone when cloning this repo initially, e.g.: git clone --recursive https://git.nah.nz/altimeter/ or later come along and check out the submodules if you didn't perform a recursive clone initially: git submodule init && git submodule update ### Dependencies Bare minimum, you will need: * make * avr-gcc * avr-libc If you want to flash to a real board, you will need: * avrdude If you want to simulate a mock/fake version of the software on a virtual AVR before flashing, you will need: * qemu-avr ### Test In order to build and run the unit tests without building ELFs or HEXs: $ make test Otherwise, unit tests are always run as the final part of the `make all` recipe below and will fail the build if they do not pass. ### Build $ make all ... $ file build/altimeter*.elf build/altimeter.elf: ELF 32-bit LSB executable, Atmel AVR 8-bit, version 1 (SYSV), statically linked, with debug_info, not stripped build/altimeter_sim.elf: ELF 32-bit LSB executable, Atmel AVR 8-bit, version 1 (SYSV), statically linked, with debug_info, not stripped ### Run mock/sim build of software in QEMU The sim build of the software has peripherals mocked out so that the software can run in QEMU, where the only peripherals available on the AVR are timers and the USART controller. Thus, the sim build isn't very useful for hacking on I/O driver code, but is perfectly fine for higher level logic, such as UI and business logic. A simulated barometer is provided, which cycles through some preset pressure values each time it is asked for pressure. The HD44780 LCD is replaced with a thin UART driver instead, which QEMU puts on stdout. $ make emu and from a separate terminal, attach GDB. Optionally set breakpoints before unpausing qemu: $ make gdb (gdb) cont You should see some activity in the emulated serial output back on the first terminal. Use GDB as normal to play/pause/debug the software. Ctrl+C and k to end QEMU. Now that you have some serial output, try the `ui_remote.py` script. It will turn some keypresses into UI events on the QEMU target with GDB. The latency noticeable, but it's an okay tool to hack around with. ### Flash good software to chip With the board reset into programming mode, run avrdude through the makefile recipe: $ make flash PORT=/dev/ttyACMx ...replacing `/dev/ttyACMx` with the right tty device that shows up when you put your microcontroller into programming mode.