Giter Site home page Giter Site logo

aschulm / battor Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 7.0 958 KB

BattOr - Power monitor for smartphones and tablets

License: Apache License 2.0

Python 0.32% C 79.42% C++ 0.86% Shell 17.76% Makefile 1.49% M4 0.17%
chrome energy-monitor systrace

battor's People

Contributors

aschulm avatar testac974 avatar testaco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

battor's Issues

BattOr halts after 6 seconds of recording samples

When the device is buffering, any incoming bytes will interrupt the processor and take up precious CPU cycles that are needed for handling the incoming stream of samples. This could lead to various halt conditions.

The problem is we want the client to be able to send a clock sync whenever it likes, not knowing what the BattOr is doing, and the client wants the BattOr to respond as quickly as possible. This means there will always be a chance that a clock sync message DOSes the BattOr.

Pulling the plug on the BattOr can kill the program stored in onboard flash

The BattOr was running and I pulled the 3-pin plug and put it back in and the BattOr came back online and was stuck in an infinite loop in the bootloader.

This could be because the voltage watchdog on the Atmel chip is not set properly in the fuses so we are running it at too low voltage during the unplug transition. It also could be because we are not protecting the onboard flash memory addresses so they can be overwritten by the program itself. Maybe we can set a fuse to prevent this too.

Need to store calibration values

The current measurement resistor, voltage offset, and both voltage measurement divider resistors need to have calibration values stored in the EEPROM.

POTs fail to initalize

In some operating conditions, for example when connected to the Saleae, or for the new v3.3 BattOrs, the digipots fail to initialize. The reason seems to be that the clock frequency of 400 kHz is too fast given that the SDO needs a pullup resistor on it. It is possible that this only works reliably when the BattOr is fed from a laptop power supply (for an unknown reason).

Start/Stop button should start and stop captures

In v3.3 we added a button to start and stop tracing. This button should start and stop tracing, but we also need some UI elements and changes to the download in order for this to be useful to users. The recording LED should blink in a pattern to indicate which file is being written. Also, the download should not just download the last file, it should download whichever file the user requests.

BattOr reader sometimes hangs on startup

This bug has shown up on older versions of the firmware, but still seems to be hanging around. I need to determine where it is hanging, but it's probably waiting for the ACK after the stream start command.

SRAM fails write and read in self test

After slowing down the clock of the POTS in Issue #40, the SRAM self test started failing. The saleae revealed that there were 0x00 sent over the MOSI for the first SRAM messages. It seems that the reason for this issue is that the clock is operating so slowly during the POT write that the SRAM write is started in the middle of the clock tick after last tick of the POT clock.

make install hangs on battor -k

I've been running an old version of the BattOr firmware - 3c437f6

I recently tried to update the BattOr firmware to master since I noticed that there were some possibly important commits that I was missing such as 667213f. This failed with an error stating that /dev/ttyUSB0 could not be found. Thus, I tried to dig into this to identify the commit that changed the Makefile in some way. During git bisect, while I was compiling and flashing the firmware present in different commits, one of the commits caused the BattOr to stop responding. I'm not sure which commit this was.

Currently, This is what I get:

avrdude -e -p x192a3u -c avr109 -b 115200 -P /dev/ttyUSB0 -U flash:w:main.hex
avrdude: butterfly_recv(): programmer is not responding

Enabling verbose output, I get:

avrdude -e -p x192a3u -c avr109 -b 115200 -P /dev/ttyUSB0 -U flash:w:main.hex -v -v -v -v -v
avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/home/guru/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB0
         Using Programmer              : avr109
         Overriding Baud Rate          : 115200
         AVR Part                      : ATxmega192A3U
         Chip Erase delay              : 0 us
         PAGEL                         : P00
         BS2                           : P00
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 0
         StabDelay                     : 0
         CmdexeDelay                   : 0
         SyncLoops                     : 0
         ByteDelay                     : 0
         PollIndex                     : 0
         PollValue                     : 0x00
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           prodsig        0     0     0    0 no         50   50      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           fuse1          0     0     0    0 no          1    0      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           fuse2          0     0     0    0 no          1    0      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           fuse4          0     0     0    0 no          1    0      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           fuse5          0     0     0    0 no          1    0      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           data           0     0     0    0 no          0    0      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom         0     0     0    0 no       2048   32      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           application    0     0     0    0 no     196608  512      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           apptable       0     0     0    0 no       8192  512      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           boot           0     0     0    0 no       8192  512      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash          0     0     0    0 no     204800  512      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           usersig        0     0     0    0 no        512  512      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           fuse0          0     0     0    0 no          1    0      0     0     0 0x00 0x00
             Memory Ops:
               Oeration     Inst Bit  Bit Type  Bitno  Value
               -----------  --------  --------  -----  -----

         Programmer Type : butterfly
         Description     : Atmel AppNote AVR109 Boot Loader

Connecting to programmer: .avrdude: Send: . [1b] 
avrdude: Send: S [53] 
avrdude: ser_recv(): programmer is not responding
avrdude: butterfly_recv(): programmer is not responding

Battor should report real timestamps, not starting from 0

It's pretty painful to manually record when I start the run, then later align the data to wall time / other logs -- requires post-processing scripts, usually several attempts to get the alignment right, etc.

Suggestion: a command-line option that can be sent along with '-b', that pushes the host's current time to the battor, then the timestamps start from that time.

Or, always push the host timestamp, then it could be an option to the download command to apply the offset. Might be nice to have that timestamp handy all the time in case there is confusion about where your data came from.

INIT should send an ACK after its reset.

If an INIT is called and it leads to a reset because the BattOr was already INIT then the BattOr should reply with an INIT reply after the reset has completed. The reason why this is important is otherwise the INIT has to be sent multiple times just in case it caused a reset which violates the basic protocol of if the BattOr gets an INIT then it should send an ACK.

Multiple ./battor runs can lead to sequence number errors.

error: expected sample frame seqnum 5 got seqnum 4
error: expected sample frame seqnum 5 got seqnum 4
error: expected sample frame seqnum 5 got seqnum 4
error: expected sample frame seqnum 5 got seqnum 4
error: expected sample frame seqnum 5 got seqnum 4
error: expected sample frame seqnum 5 got seqnum 4
error: expected sample frame seqnum 5 got seqnum 4
error: expected sample frame seqnum 5 got seqnum 4
error: expected sample frame seqnum 5 got seqnum 4
error: expected sample frame seqnum 5 got seqnum 4

Firmware UART TX doesn't pause when flow control occurs before TX starts

It is possible for for a UART flow control interrupt to come in right before a UART TX starts. The UART TX will then cancel the UART flow control pause, even though the UART TX should just start paused. The result is lost UART TX data, which leads to partial frame transmissions and thus missing sequence number warnings. This bug has a low probability of occurring when downloading short traces, but is very likely to happen when traces are longer than a few minutes.

/cc @peastham @CharlieA

SD card download can be sped up

Currently the SD card download builds the UART frames as they are being downloaded, this makes the download very slow. Alternatively, we could build the UART frames while the samples are being collected because we have lots of space CPU cycles.

Auto-calibration needs to be performed over more samples

Currently auto calibration only happens over the first 50 samples of the trace, in order to hit < 1mA accuracy we need to calibrate over a longer period of time. Somebody needs to download traces and take a look to see how long is necessary for the auto calibration.

The goal here should be to have very consistent auto calibration data for the same run in the same environment.

Slight mods needed to get it to work with OS X El Capitan

Using the built-in AppleUSBFTDI driver, I had to modify the tty name in battor.c to "/dev/cu.usbserial-482351150012".

Not sure what that number is, and I don't see a better auto-symlink to use.

Other than that, it seems to be working fine!

macos 10.11.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.