misc: Traces updates
Applies naming convention to globals, types etc.
twi: Added first bit of slave support
Need the slave support for TWI, will add bits as I go along
Signed-off-by: Michel Pollet <buserror@gmail.com>
megax8: Added a couple of timer modes
Pretty obvious timer modes were missing...
Signed-off-by: Michel Pollet <buserror@gmail.com>
Merge pull request #21 from bsekisser/sim_core_eicall_eijmp_bugfix
sim_core.c: extended data type to 32 bits for eicall/eijmp instruction.
sim_core.c: extended data type to 32 bits for eicall/eijmp instruction.
modified: simavr/sim/sim_core.c
core: Add an overridable logging function
AVR_LOG() now uses a logging function which can be overridden as
necessary. By default, it logs to stdout/stderr.
Fixed-up-by: schuay <jakob.gruber@gmail.com>
Merge pull request #12 from ponty/logger2
new global_logger, used in AVR_LOG(), default is stdout/stderr
io,elf: pass the trace section name to getirq
avr_iomem_getirq() now takes a 'name' for the IRQs. The elf loader now
passes down the trace name so the irq gets named properly.
Signed-off-by: Michel Pollet <buserror@gmail.com>
irq: Add a warning if the name is NULL
Names are not getting important, for the scripting project
Signed-off-by: Michel Pollet <buserror@gmail.com>
vcd: Initializes IRQs when needed only
Also manufacture an IRQ name with the one passed in add_signal
Signed-off-by: Michel Pollet <buserror@gmail.com>
io: Create irq names for io addresses
Set names for the io address IRQ when they are created
Signed-off-by: Michel Pollet <buserror@gmail.com>
ioport: Tweak IRQ names
Names should include the size in bits, if not 1
Signed-off-by: Michel Pollet <buserror@gmail.com>
Makefile: Removed uname -o
This break on BSDs (aka OSX), this commit will break windows build, it
will need a proper fix
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: larger data type to store extended z-pointer value
misc: Add a Contributing section to README.md
misc: Add a Documentation section to README.md
misc: Remove outdated README
There's no point in keeping two similar README's around, and README.md
is better maintained.
new global_logger, used in AVR_LOG(), default is stdout/stderr
Merge pull request #10 from the-real-orca/mingw
MinGW merge, thanks!
mingw: make simavr compilable with MinGW
- patch makefiles to work with MinGW
- compile to run_avr.exe on windows, otherwise run_avr cannot be started from the normal windows command prompt
- add sim_network.h to encapsulate the network functions of different platforms
(use winsock2 for Windows network functions)
- make network helper functions static
- force open() to use binary mode (on Windows default is text mode)
- do not change stderr on Windows
- exclude simduino example on Windows
- add MinGW README
Signed-off-by: Stephan Veigl <veigl@gmx.net>
uart: default to 8-bit word length on reset
megax4/uart: implement u2x (double uart transmission speed)
cores: No standard include paths
There are problems with standard includes since the paths are ambiguous
between host and AVR. Using absolute includes does not work for multi-platform
projects.
The solution is to remove all standard includes of the host system for the
core files since there is no reason why a core definition should require
standard includes from the host system. User interaction (status messages)
is the job of the simulator and not the core definitions.
- add CORE_CFLAGS (-nostdinc) to Makefile.common
- remove <stdio.h> from core definition files
- move init message from core definition files to avr_init() in sim_avr.c
Signed-off-by: Stephan Veigl <veigl@gmx.net>
watchdog: Fix register naming
MCUSR is called MCUCSR in atmega128
Signed-off-by: Stephan Veigl <veigl@gmx.net>
tests: Remove vcd files on clean
Remove the vcd files generated by test cases on: make clean
Signed-off-by: Stephan Veigl <veigl@gmx.net>
tests: Fix number of successful tests calculation
Signed-off-by: Stephan Veigl <veigl@gmx.net>
misc: Update NO_COLOR define switch
The NO_COLOR define switch is a preparation for the Windows version.
Since the standard Windows command prompt is not able to display
ANSI color statements correctly. With this define switch it is
possible to remove any coloring of the output. This will be set
automatically in the MinGW patch.
The color definitions are moved from sim_core.c to sim_core.h since
they are used in other macros as well.
Signed-off-by: Stephan Veigl <veigl@gmx.net>
Merge pull request #7 from mali/working
Makefile : fix cleaning rules
Makefile : fix cleaning rules
in order to leave the src tree as clean as before a build
+ add rm -f of autogenerated sim_core_config.h & sim_core_decl.h
in simavr/Makefile
+ add rm *.hex in example/board_*/Makefile
Makefile: Fix git tag issues
+ Pick the correct tag for the version number
+ Do not fail if git is not there
+ Add the version to the config file
Signed-off-by: Michel Pollet <buserror@gmail.com>
Makefile: Introduce a release build
make RELEASE=1 will use rpath-link to link the executable,
preventing simavr build path to be referenced. This requires
that simavr gets installed for it to work
Signed-off-by: Michel Pollet <buserror@gmail.com>
usb: Made the usb example optional
Downloading extra sources is against debian policy and was
a blocker to get simavr in debian. Made the board_usb example
optional, it will require an explicit make.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Makefiles: Add manual and a global doc target
Manual generation is now included in the doc/Makefile. Additionally,
a doc target has been added to the global Makefile.
doc: Add simavr manual
This is an excerpt of the bachelor's thesis "qsimavr: Graphical
Simulation of an AVR Processor and Periphery" by Jakob Gruber. The full
thesis is available at https://github.com/schuay/bachelors_thesis.
misc: Point to correct simavr include dirs
misc: Move avr_mcu_section.h to sim/avr
Since sim_elf.h includes avr_mcu_section.h, it needs to reference
a path which works both during simavr builds, and compilation of
external programs including sim_elf.h. Adding the avr/ subdirectory
to pkg-config cflags is not desired, to make sure it's clear that header
is shared between the sim and the firmware.
Makefiles: Remove executable bit from headers
Makefiles: Separate simavr.pc and simavr-avr.pc
According to http://people.freedesktop.org/~dbn/pkg-config-guide.html,
"each pkg-config file is best used to describe a single library, so each
package should have at least as many pkg-config files as they do
installed libraries."
Makefiles: Use PREFIX instead of DESTDIR in simavr.pc
This is needed when DESTDIR does not equal the actual intended
destination (this usually occurs when building packages for
distribution).
An example make invocation:
make DESTDIR=pkg/usr PREFIX=/usr install
core: Deinitialize GDB in avr_terminate()
This is relevant when running multiple simavr sessions in a single
program.
cores: Use correct extint control register
The atmega1280/atmega1281/atmega128/90usb162
have two external interrupt control registers;
EICRA for ISC[0-3]x, and EICRB for ISC[4-7]x.
vcd: Made the trace buffer dynamic
Made the trade buffer growable, to accomadate busy tracers
Also converted the traces to AVR_LOG in that bit.
Signed-off-by: Michel Pollet <buserror@gmail.com>
ioport: Restore PIN to PORT values when DDR is set to output
ioport: Use IRQ_FLAG_FILTERED instead of manual filtering
Manual filtering could cause us to miss pin changes when data
is written to PINs while the port is set to input mode (and thus
the PORT register is not updated).
vcd_file: Update comment to reflect correct time units
timer: Avoid infinite cycle timer on TCNT write
In some situations, it was possible to enter an infinite cycle timer
loop. In avr_timer_tcnt_write, the tov cycle timer registration is not
protected and can register a timer with p->tov_cycles == 0.
The following atmega1280 program demonstrates this issue:
int main() {
TCCR1A = 0;
TCCR1B = (1<<WGM12) | (1<<ICES1);
OCR1B = OCR1A = 960;
/* Start */
TCNT1 = 0;
TCCR1B |= (1<<CS11);
/* Stop */
TCCR1B &= ~(1<<CS11);
TIFR1 |= (1<<OCF1A) | (1<<OCF1B);
/* Start */
TCNT1 = 0; /**< Registers timer with tov_cycles == 0. */
TCCR1B |= (1<<CS11);
while (1) ;
return 0;
}
io: Convert logging to AVR_LOG()
interrupts: Convert logging to AVR_LOG()
gdb: Convert logging to AVR_LOG()
elf: Convert logging to AVR_LOG()
cycle_timers: Convert logging to AVR_LOG()
core: Convert logging to AVR_LOG()
watchdog: Convert logging to AVR_LOG()
usb: Convert logging to AVR_LOG()
A couple of these functions did not have references to avr_t, so this is
incomplete.
uart: Convert logging to AVR_LOG()
UART stdout output was left as is.
lin: Convert logging to AVR_LOG()
flash: Convert logging to AVR_LOG()
eeprom: Convert logging to AVR_LOG()
bitbang: Convert logging to AVR_LOG()
adc: Convert logging to AVR_LOG()
timer: Remove trace_flags
All uses have been converted to AVR_LOG().
timer: Convert to logging to AVR_LOG()
core: Introduce a logging macro AVR_LOG()
This works in conjunction with avr->log to tune out messages we are not
interested in. LOG_ERROR is the default level.
run_avr: Add -v argument to raise verbosity level
Pass it more than once to raise it further. This works better with the
standard conventions, which would allow passing -vvv (instead of -v -v
-v). Unfortunately, this does not work here.
The type of avr->log has been altered to accomodate values up to 3.
cores: Move static to front of declaration
This fixes the two -Wold-style-declaration warnings reported by gcc with
-Wextra.
mega1280: Initialize UART 2 and 3
These definitions already existed but were not initialized.
mega1280: Add missing timers 4 and 5
These are 16-bit timers similar to Timer1 and Timer3.
core: Increase MAX_IOs for atmega1280
The atmega1280 uses IO registers up to an address of 0x136.
Set MAX_IOs to (0x136 - 0x20 + 0x01) = 279.
core: Don't sleep with pending interrupts
This avoids an issue in which we would incorrectly enter a state in
which the CPU was sleeping and interrupts were disabled. It occurred
when an interrupt was raised and a SLEEP instruction processed before
the interrupt could be serviced (due to pending wait).
There are several disadvantages: if somebody adds new code which
switches the CPU to sleeping, there's a good chance of them forgetting
to add this check. Preventing sleep even if the interrupt is masked is
probably harmless but incorrect. Finally, on a real AVR it _is_ possible
to trigger an interrupt and then go to sleep in the next instruction
before the interrupt is serviced.
I'd actually prefer fixing this by moving the CPU interrupt wakeup from
avr_raise_interrupt() to avr_service_interrupts(), but that requires
further changes to avoid sleeping during avr->run() while an interrupt
is about to be serviced.
cores: Set raise_sticky in TWI interrupt vectors
interrupts: Introduce raise_sticky flag
If set, the raise bit is not cleared in avr_clear_interrupt. This
corresponds to the hardware not clearing the interrupt flag when
executing the interrupt routine.
The only known example of this is the TWI Interrupt Flag TWINT.
interrupts: Do not clear raised bit twice
avr_regbit_clear is already called in avr_clear_interrupt.
twi: Correct swapped twi irq names
interrupts: Typo correction (pooling -> polling)
misc: Consistent include guards in headers
Changed all include guard defines to a consistent form and added them if
missing.
misc: Add extern "C" blocks to headers
Most headers already had these. This commit adds them where they weren't
included yet.
simavr: Do not call avr_terminate in run callbacks
Neither run_avr nor the examples expect avr_terminate to be called by
simavr itself.
This also caused issues for cleanup code (such as IRQ disconnections)
that did not know if avr_terminate had already been called or not.
irq: Print errors to stderr
Trying to (dis)connect an invalid IRQ is an error. Note that the
incorrect function name printed in avr_unconnect_irq has been corrected.
twi: Move avr_twi_irq_msg to avr_twi.c
This fixes inclusion of avr_twi.h into C++ files.
interrupts: Don't wake up if not sleeping
This caused the CPU to wake up even if it was explicitly set to
cpu_Stopped.
Makefile: Create .deb files using fpm
Handy way of creating debian packages quickly
Signed-off-by: Michel Pollet <buserror@gmail.com>
examples: Correct instructions for timer_64led example
run_avr: Abort if firmware could not be read
Otherwise, simavr continues and tries to process whichever random memory
content is located in the flash memory section even when the file could
not be read.
examples: hd44780 responds on falling edge of E pin
The example itself works both ways, but the actual HD44780 chip
processes data on the falling edge - see the data sheet.
examples: Fix frequency of ac_input signal
The comment in ac_input.h specifies 50 Hz, but it was actually 500 Hz.
This off-by-one-zero error probably went unnoticed because of inaccurate
sleep handling (which was fixed in the previous commit).
simavr: Improved accuracy of sleep durations
This commit solves (or at least improves) an issue that occurs when
short sleep times are requested in avr_callback_sleep_*. The operating
system cannot accurately handle short sleep requests, and sending many
short requests takes significantly longer than requesting the equivalent
time in longer bursts. This can be observed by running the board_hd77480
example - the counter is much slower when vcd recording is turned on
(= short sleep requests) than when it is turned off (= long sleep
requests).
We improve this situation by accumulating sleep requests until a certain
minimum count of pending usecs is reached which can be handled somewhat
accurately (200 microseconds worked well for me).
gdb: Read/write SREG values correctly
Accessing SREG through gdb seems to have been broken since SREG is no
longer synthesized at each instruction (
2f67001d). As a quick fix, make
SREG accessors public and use them in sim_gdb.
Note that invalid avr->sreg values no longer trigger the CRASH macro.
tests: Correct expected output of atmega88_uart_echo
Carriage return generation was added back to the file handler in
a26a2e43fc4b547090f3069e121713702593261d. Since the string is actually
passed through uart_putchar twice, the received string has a duplicate
'\r' character.
Merge pull request #4 from schuay/markdown_syntax
Markdown syntax
misc: Update repository URL in README
misc: Fix broken links in README.md
misc: Github markdown uses indentation to mark code blocks
misc: Minor wording changes in README.md
misc: Github markdown uses underscores to italicize words
Merge pull request #2 from schuay/watchpoints
Watchpoints
Merge pull request #3 from schuay/not_known
misc: Fix confusing typo in error message
misc: Fix confusing typo in error message