reprap: Some more updates, also a Marlin binary to test
Added a marlin binary that works, to help repsnapper's
Signed-off-by: Michel Pollet <buserror@gmail.com>
stepper: Keep position in step numbers, not mm
More precise, also use a cycle timer to send status positions in mm
Signed-off-by: Michel Pollet <buserror@gmail.com>
reprap: Added a 'relief' sleep
Tweaked Marlin to do a spurious write to GPIOR0 so allow
the simulator to get some usleep() and not use 100% cpu
Signed-off-by: Michel Pollet <buserror@gmail.com>
uart_pty: Check value of environment variable
Can set it to 0 to disable the xterm
Signed-off-by: Michel Pollet <buserror@gmail.com>
run_avr: Use the new read_ihex_chunks
Still doesn't solve the problem of the avr assembler ihex being sparse,
but at least the problem is no longer int he ihex code.
Signed-off-by: Michel Pollet <buserror@gmail.com>
ihex: Made read_ihexq_chunks allocare the table
The table is allocared and returned as the result
Signed-off-by: Michel Pollet <buserror@gmail.com>
reprap: Progress
Now the reprap board has fake stepper motors that know their position,
with endstops (they work with Marlin) also there is a way to use
arduidiot pins numbers and remap them to AVR pins..
There is a prototype "heatpot" part that will be used to collect
source and drain of heat and calculafe a temperature.
Also added mongoose embedable web server. The current plan is to
use WebGL to render the graphics of the 3D printer... altho it's
not entirely sure as yet.
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: Ensure we can run in >64K flash
From an original patch from alex Bondarenko <alexian79@gmail.com>
Reworked to add a new type for flash addresses.
Signed-off-by: Michel Pollet <buserror@gmail.com>
misc: Cleanup & typos
No functional changes
Signed-off-by: Michel Pollet <buserror@gmail.com>
mega1280: Made PORTK work
This was triggering a limit in the AVR core IO table
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: Increased the number of possible IOs
Also added a sanity check
Signed-off-by: Michel Pollet <buserror@gmail.com>
i2ctest: Collapsed both i2ctests into one
Just need one of these
Signed-off-by: Michel Pollet <buserror@gmail.com>
i2ctest: Added a mega1280 version
Probably will lose either this one, or the older version as they
are exactly the same
Signed-off-by: Michel Pollet <buserror@gmail.com>
i2ctest: Moved files to shared
Put the atmel i2c example to a shared directory
Signed-off-by: Michel Pollet <buserror@gmail.com>
cores: Added mega1280
Very little testing was done. ADC was fixed, but still misses the higher
differential channels
Signed-off-by: Michel Pollet <buserror@gmail.com>
ADC: Grown to 64 possible mux values
Needs a bigger ADC, the mega1280 uses 6 bits.
Signed-off-by: Michel Pollet <buserror@gmail.com>
timer: Reconfigure the timer in fast pwm mode
If OCR* changes, the timer still needs to be reconfigured in fast PWM mode.
Signed-off-by: Michel Pollet <buserror@gmail.com>
UART: Added a trace macro
Replaces the comments
Signed-off-by: Michel Pollet <buserror@gmail.com>
thermistor: Now works
Return millivolts, not ADC values
Signed-off-by: Michel Pollet <buserror@gmail.com>
New example board: reprap
Proto shell for a reprap emulator. Currently can run Marlin, up to a point
There are lots of stuff to add, but with a bit of luck we could use the
"pins.h" of the firmware itseld to configure the simavr board, and
have it "adapt" to various hardware boards.
Currently the fake thermistor has been moderately tested, and seems to work.
It needs more work, like linear extrapolation, target temps etc.
elf: Do not set values that weren't present
Some ELF binaries without a simavr section can now be loaded
Signed-off-by: Michel Pollet <buserror@gmail.com>
uart: Trace the use of the x2 flag
No functional change
Signed-off-by: Michel Pollet <buserror@gmail.com>
timer: Added phase correct mode, possibly works
Not tested..
Signed-off-by: Michel Pollet <buserror@gmail.com>
uart_pty: Added a debug terminal
You can now launch an xterm with picocom by setting environment
SIMAVR_UART_XTERM. This could (will) be improved.
Also, the uart_pty symlinks the pty pathname to /tmp/simavr-uart-X
so you can rely on a constant pathname.
Signed-off-by: Michel Pollet <buserror@gmail.com>
uart_udp: Updated, obsolete
Will probably remive this part in the future
Signed-off-by: Michel Pollet <buserror@gmail.com>
simduino: Updated, uses uart_pty
Now works properly again, and uses the new pty part.
Also removed mmap and uses a read/write instead for the flash file,
Signed-off-by: Michel Pollet <buserror@gmail.com>
uart_pty: New part
This one replaces uart_udp, that was really a toy. This new part simulates
a proper serial port (almost) on the host, and allow connection with minicom
or anything you like.
Properly implemented flow control too, do it's safe at any speed.
Signed-off-by: Michel Pollet <buserror@gmail.com>
irq: Added an INIT flag
'filtered' interrupts didn't work if the initial value was the same as the
one used to raise the irq. Now it works properly, can could also be used
to track IRQs in the pool by usage.
Signed-off-by: Michel Pollet <buserror@gmail.com>
uart: Finaly fixed the xon/xoff
Now works as intended
Signed-off-by: Michel Pollet <buserror@gmail.com>
interrupts: Delivery fix
Polled interrupts as for the UART were borken. Now fixed.
Signed-off-by: Michel Pollet <buserror@gmail.com>
fifo: Small update
Expose the size specified as a constant
Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr: Now use the generated config files
Removed the statis tables, use the generated config
Also updated .gitignore
Signed-off-by: Michel Pollet <buserror@gmail.com>
Makefile: Generate config files
The Makefile now tries to detect the cores that can
be built using the current avr-gcc install. This allows
simavr to be built with older toolchain that don't have
the latest cores. Like arduidiot.
It also allows generation of an automated core list for
simavr so the run_avr and others don't have to have an
explicit list of cores. They are now autodetected.
Signed-off-by: Michel Pollet <buserror@gmail.com>
Makefile: OSX Update
Only add the MacPort dir if it's there. This
removes a warning when linking
Signed-off-by: Michel Pollet <buserror@gmail.com>
examples: Exclude USB on non-linux
Skip USB example and parts on OSX
Signed-off-by: Michel Pollet <buserror@gmail.com>
examples: Updated LCD part for OSX
Uses the proper include file on OSX
Signed-off-by: Michel Pollet <buserror@gmail.com>
misc: Updated .gitignore
Added OSX turd files
Signed-off-by: Michel Pollet <buserror@gmail.com>
misc: Explicitely link libelf
Some linker don't understand inherited links
Signed-off-by: Michel Pollet <buserror@gmail.com>
examples: New board_usb
Automaticaly tries to build the vhci libraries
TODO: Make the whole simavr build work even if the vhci
compile fails, or is not linux
By: Torbjorn Tyridal <ttyridal@gmail.com>
Signed-off-by: Michel Pollet <buserror@gmail.com>
parts: New vhci usb device bridge
By Torbjorn Tyridal <ttyridal@gmail.com>
Signed-off-by: Michel Pollet <buserror@gmail.com>
cores: Added at90usb162
Straight from Torbjorn Tyridal <ttyridal@gmail.com>
Signed-off-by: Michel Pollet <buserror@gmail.com>
simavr: Added usb slave emulation module
Straight from Torbjorn Tyridal <ttyridal@gmail.com> with
just a bit of source code remangling
Signed-off-by: Michel Pollet <buserror@gmail.com>
examples: Link against .so
If .so is present, link against that, not the static lib
Signed-off-by: Michel Pollet <buserror@gmail.com>
vhci: Fix Makefile PWD
Somehow PWD is wrong, it's the shell's one not the make one
Signed-off-by: Michel Pollet <buserror@gmail.com>
Makefiles: general update
+ Now uses the shared library if present, and added some
logic to find where it was built.
+ Added an "official" version number
+ Added a "make install DESTDIR=..." target
+ Added a "simavr.pc" pkg-config file
all: Added -Wall to the build
And fixed the warnings that poped out
Signed-off-by: Michel Pollet <buserror@gmail.com>
cycle_timers: Fix a delivery problem
If the timer was deleting/inserting timers, it wouldn't
be rescheduled properly.
Signed-off-by: Michel Pollet <buserror@gmail.com>
vhci: Added a gitignore
Ignore generated files in there
Signed-off-by: Michel Pollet <buserror@gmail.com>
interrupts: Isolated runtime data
Split the runtime data related to interrupts into it's own
struct, and updated anyone using it directly.
Ultimately it would be the goal not to have to pass an avr_t
around to all the functions.
Signed-off-by: Michel Pollet <buserror@gmail.com>
regbits: Moved the struct declaration
Moved the data type to sim_avr_types.h, so it doesn't
need the full avr_t type to be used.
Signed-off-by: Michel Pollet <buserror@gmail.com>
style: Updated to 2012
Changed prototypes, updared copyright etc
Signed-off-by: Michel Pollet <buserror@gmail.com>
vhci: build kernel module & library
This makefile downloads the vhci bits, hack the a little
and compile them in place.
One done it's left as an excercise to the reader to install
the module where they want.
Example board can then link/compile by adding -I../vhci/include and
-L../vhci/lib to their makefile
Signed-off-by: Michel Pollet <buserror@gmail.com>
cycle_timers: Big rework
Removed the old bitfield, implemented a sorted list. Timers
get added to the list by (reverse) order of execution do acts
as a stack of timers to run and pop out.
This considerably simplifies the code, and also makes the code
that test for the next timer to run very small and efficient.
This should make cycle_timers a lot more scalable, since they are
used for many more uses than they were originaly designed for.
Signed-off-by: Michel Pollet <buserror@gmail.com>
general: Introduce two new headers
Split the cycle/usec conversion code from the cycle_timer
heacers into it's new sim_time.h
Also removed the simple types out of sim_avr.h to create
new header sim_avr_types.h
Adapted other modules to use avr_time.h
Signed-off-by: Michel Pollet <buserror@gmail.com>
timer: Fix a problem on unconfigured comparators
Was trying to calculated and setup comparators that
didn't exists on some cores... confusion ensued.
This fixes the "64 led timer" example.
Signed-off-by: Michel Pollet <buserror@gmail.com>
interrupts: Rewrote interrupt delivery
Now uses a fifo, removed the bitfield.
This allows multiple interrupt "sources" per vector,
and should make delivery a bit quicker too.
Signed-off-by: Michel Pollet <buserror@gmail.com>
i2ctest: Make example exit properly
Demo was trying to exit, but the harness wasn't
Signed-off-by: Michel Pollet <buserror@gmail.com>
tests: Cleanup the test harnesses
Removed extra scripts, etc
Signed-off-by: Michel Pollet <buserror@gmail.com>
adc: Fix for non updating ADC values
Patch from Peter Ross pross@xvid.org
Signed-off-by: Michel Pollet <buserror@gmail.com>
makefile: Make -j works
Was lacking dependencies
Signed-off-by: Michel Pollet <buserror@gmail.com>
makefile: Don't track system headers
Otherwise incremental make fails after system updates
Signed-off-by: Michel Pollet <buserror@gmail.com>
tests: Revert a uart patch
We do need the translation, as it's not one, but generation of \n\r
Signed-off-by: Michel Pollet <buserror@gmail.com>
cores: Added mega16m1
Could work for megaXm1 ?
Signed-off-by: Markus Lampert <mlampert@telus.net>
Signed-off-by: Michel Pollet <buserror@gmail.com>
lin: Added module
- added core module for atmega16m1,
standard peripherals and LIN-in-UART mode
Signed-off-by: Markus Lampert <mlampert@telus.net>
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: Added a log level
added log_level to avr_t to control the output of the
simavr library (minimal usage)
Signed-off-by: Markus Lampert <mlampert@telus.net>
Signed-off-by: Michel Pollet <buserror@gmail.com>
uart: Do not assume all interupt vectors are available, etc
LIN uart doesn't have them (?)
- fixed uart code to only trigger rxt if more pending
characters are in the input buffer
- fixed uart-echo test code to not get stuck in
endless loop upon receiving '\r'
Signed-off-by: Markus Lampert <mlampert@telus.net>
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: added new states
States cpu_Done and cpu_Crashed allow graceful exit
and cleanup of simavr applications.
Signed-off-by: Markus Lampert <mlampert@telus.net>
Signed-off-by: Michel Pollet <buserror@gmail.com>
core: Fixed opcode printing on access violation
No functional change
Signed-off-by: Markus Lampert <mlampert@telus.net>
Signed-off-by: Michel Pollet <buserror@gmail.com>
adc: Added VCC/4 reading
For mega16m1
Signed-off-by: Markus Lampert <mlampert@telus.net>
Signed-off-by: Michel Pollet <buserror@gmail.com>
misc: formatting, typos
Also removed test case that doesn't actualy test anything
Signed-off-by: Michel Pollet <buserror@gmail.com>
ioport: Added avr_iopin_t
Descriptor for pin name/pin number
Signed-off-by: Michel Pollet <buserror@gmail.com>
vcd: change VCD time base to 1 ns to handle higher AVR speeds (e.g. 20 MHz / max. frequency: 1000 MHz)
- increase VCD log size to 5kB
Signed-off-by: Stephan Veigl <veigl@gmx.net>
Signed-off-by: Michel Pollet <buserror@gmail.com>
irq: add avr_unconnect_irq() and avr_irq_unregister_notify()
Signed-off-by: Stephan Veigl <veigl@gmx.net>
bitbang: add new bitbang sub-module
Signed-off-by: Stephan Veigl <veigl@gmx.net>
test: fix test cases and add new test function
- add tests_assert_uart_receive_avr() function (called by tests_assert_uart_receive() and test cases)
- fix DDR settings
Signed-off-by: Stephan Veigl <veigl@gmx.net>
Update .gitignore.
Signed-off-by: Sami Liedes <sliedes@cc.hut.fi>
Signed-off-by: Michel Pollet <buserror@gmail.com>
vcd: change VCD time base to 1 ns to handle higher AVR speeds (e.g. 20 MHz / max. frequency: 1000 MHz)
- increase VCD log size to 5kB
- add test files
Signed-off-by: Stephan Veigl <veigl@gmx.net>
simavr: change hard-coded value to define: AVR_IOPORT_OUTPUT
Signed-off-by: Stephan Veigl <veigl@gmx.net>
output: add NO_COLOR define to disable / enable color output for simavr core messages and UART
Signed-off-by: Stephan Veigl <veigl@gmx.net>
doc: add doxygen file
Signed-off-by: Stephan Veigl <veigl@gmx.net>
cores: Add mega1281
Signed-off-by: HATATANI Shinta <gamaguchi@gmail.com>
Signed-off-by: Michel Pollet <buserror@gmail.com>
cores: Added mega8, old generation
Possibly would work with mega16, 32 ?
Signed-off-by: Michel Pollet <buserror@gmail.com>
examples: Working i2c master test board
Write a few bytes to an i2c eeprom, read them back...
Signed-off-by: Michel Pollet <buserror@gmail.com>
parts: Adds generic i2c eeprom slave
This part simulates an i2c eeprom, it handles most modes, including
"multiple addresses" ones, and ones with multiple byte offset bytes.
Signed-off-by: Michel Pollet <buserror@gmail.com>
twi: Fully functional master
Now works properly, tested against Atmel's code. See
examples/board_i2ctest for a demo
Signed-off-by: Michel Pollet <buserror@gmail.com>
examples: Fix firmware pathnames
Twas borken since I changed the build system. Now works
Signed-off-by: Michel Pollet <buserror@gmail.com>
example: Added i2ctest
This example need some polish. It simulates an AVR with an
i2c eeprom of 1024 bytes. The eeprom is "generic" an will go to the
parts/ directory when this is fully working.
Right now write the eeprom works, but there is a stray byte somewhere;
the bug /could/ be in the atmel code tho, wich I had to fix and tweak.
Signed-off-by: Michel Pollet <buserror@gmail.com>
twi: Update, 95% functional master code
Still need a bit of polish, but the logic works. Works with the
interupt based Atmel application note code.
Signed-off-by: Michel Pollet <buserror@gmail.com>
run_avr: Added a signal handler
Catches control-C to make sure any VCD file is flushed
Signed-off-by: Michel Pollet <buserror@gmail.com>
cores: Fix TWI interupt flag
This flag was using the wrong register
Signed-off-by: Michel Pollet <buserror@gmail.com>
test: Updated uart_echo
Now set a baud rate, to excersize the new logic in the uart
simulator.
Also added a VCD file
Signed-off-by: Michel Pollet <buserror@gmail.com>
cores: Added UART bit rate flags
Updated the cores that have UART(s) with extra flags.
Signed-off-by: Michel Pollet <buserror@gmail.com>
uart: Added logic to regulate data rate
Now uses a data rate thst is proportional to speed.
Could be made a bit better by using the cycle clock count directly,
but this method is a bit clearer
Signed-off-by: Michel Pollet <buserror@gmail.com>
misc: Fixes various typos
Author: Sami Liedes <sliedes@cc.hut.fi>
Signed-off-by: Michel Pollet <buserror@gmail.com>
Fix interupt -> interrupt typo, including in some function names.
Signed-off-by: Sami Liedes <sliedes@cc.hut.fi>
Do not let code clear the UDRE flag in USART.
It's a read only location and clearing it may break software that
assumes it cannot be cleared.
Signed-off-by: Sami Liedes <sliedes@cc.hut.fi>
Merge remote-tracking branch 'sliedes/to-upstream' into dev-home
Tweak struct avr_t to always include a pointer to trace data structure.
Previously the size of struct avr_t was dependent on whether the
preprocessor macro CONFIG_SIMAVR_TRACE was defined. This was problematic
since it meant that applications that link to simavr need to define it
the same way as it is defined in simavr Makefiles.
Change it to a single pointer to a struct, which is allocated iff
tracing is compiled in and a NULL pointer otherwise.
Signed-off-by: Sami Liedes <sliedes@cc.hut.fi>
Automate test cases.
This patch implements a framework for test cases. Each test case is
compiled into an individual executable. All test cases can be run by
invoking the command `make run_tests', which runs the shell script
run_tests.
Signed-off-by: Sami Liedes <sliedes@cc.hut.fi>
Include sim_gdb.h from sim_gdb.c. Also fix prototype in .h.
sim_gdb.c did not include sim_gdb.h. Also there was a slight
difference in the prototype in the header and the implementation in
the .c, causing a warning.
Signed-off-by: Sami Liedes <sliedes@cc.hut.fi>