aschulm / battor Goto Github PK
View Code? Open in Web Editor NEWBattOr - Power monitor for smartphones and tablets
License: Apache License 2.0
BattOr - Power monitor for smartphones and tablets
License: Apache License 2.0
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.
This seems like a OSX driver bug. I was able to unstick the BattOr by unloading and reloading the OSX kext (driver) for the FTDI serial device.
sudo kextunload -b com.apple.driver.AppleUSBFTDI
sudo kextload -b com.apple.driver.AppleUSBFTDI
CC @testaco
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.
The fix for this is to use the error code on halt() and say that the reason for halt was just finished downloading samples, so it should go into idle mode after that.
Flow control stops the UART from sending while it waits for the receiver's buffer to clear. This makes it so in the BattOr's init freezes when in debug printing mode.
With digipots sharing SRAM once SRAM writes start digipot writes do not work anymore.
The current measurement resistor, voltage offset, and both voltage measurement divider resistors need to have calibration values stored in the EEPROM.
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).
Add support to the battor cli so that way it honors the passed in tty parameter.
I left a BattOr running all night on a phone with a full battery, and in the morning I could not run a SD card store on the BattOr. It went into a reset loop with an SD_OPEN halt each time it rebooted.
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.
Run the INIT several times and it will return a EEPROM read failure and the yellow LED will be stuck on.
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.
The isolation of the mux is not high enough to calibrate at the higher gain. It's roughly only 0.001, with 100x gain, that's still quite a bit of leakage.
When folks start deploying the BattOr in infrastructure, they will not want to unplug it every time there is an error.
LEDs should blink in a special way to notify that the SD card has failed. Right now if the card can not be read from the driver just halts.
BattOr should reset when it sees a new init in the middle of a run
Need some way for the BattOr reader to determine an error code from a hault. Possibly the hault should just go into a loop where it only responds to the error code request, or a reset request.
If protocol-level changes are made, this will catch errors due to fw/sw mismatch.
EOM
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.
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
It was expecting frame 65535 and got something else. I get the sense that it was not really expecting frame 65535 though.
RESET should be right next to INIT so it never changes with changes in the command set.
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.
There is no logic yet to reformat the SD card when it fills up.
The firmware expects acks or it resets. Sometimes if the PC app stops those acks don't hit the firmware, but the firmware doesn't reset.
I think it's only after an SD card insert/remove cycle but then when 'battor -b -r 10000' is run the BattOr resets but doesn't start the download.
This will allow us to track a problematic device by its serial number.
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.
When a UART TX pause flow control interrupt occurs, it can cause a firmware freeze.
It appears that this happens when the flow control pause changes the trigger when the SPI device is
using the DMA channel.
If other people are going to use the BattOr, they need to know what the LED modes are.
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
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.
The startblock should remember the gain and sample rate of the format.
Need an option to sample at a much lower rate -- very hard to download/work with 10KHz data if your run is an hour or longer.
In many cases 1Hz is sufficient for what I do, but 5 or 10 is typical.
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.
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.
Chris Cameron mentioned that he would like to see this feature because it's easy to glance at these averages and try different programs.
We need to figure out how to reduce the search time to ideally less than a second if there are this many files on the card.
filesystem dump of card with over 4000 files attached fsdump_fullsd.txt
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
Start a battor stream then Ctrl+C then immediately start one again, the BattOr will not respond to any commands.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.