Commit Graph

48 Commits

Author SHA1 Message Date
Olaf Rempel 559a403836 Do not reply with NAK on last byte
At least the bcm2835 (Raspberry Pi 3) I2C/SMBus master has problems
when replying with a NAK to the last byte written to a slave device.

Fix this by replying with NAK one byte later.
2021-02-20 22:12:01 +01:00
Olaf Rempel baf5a895b5 Update README 2020-10-26 19:53:43 +01:00
Olaf Rempel f4952aaa63 Implement a virtual bootloader section
- patch reset vector while programming flash page0
  Let the reset vector always point to the twiboot start.
- Use another (must be unused!) ISR vector to store the original
  reset vector as jump to the application.
- Cache the values for the verification read
- currently works only for devices < 8kB flash (2 byte vector entries)
- using a attiny85 as target

This change is heavily based on the optiboot bootloader.
2020-10-26 18:54:00 +01:00
Olaf Rempel 9f3781a3eb Implement USI peripheral slave statemachine
- Implement a TWI slave using the USI peripheral found in AVR tiny MCUs
- using attiny85 as target (has no bootloader section!)
- USI peripheral in general needs clock stretching support from the
  master since the whole statemachine is software based.
  For now the actual writing to flash/eeprom is also done during
  clock stretching (like original twiboot implementation).
  This might be changed later.
- ACK/NAK handling is different:
  For TWI peripheral the ACK/NAK of the *next* byte has to be returned
  by TWI_data_write(). For USI peripheral the ACK/NAK of the *current*
  byte needs to be returned. For now the TWI version remains in the
  code and might be changed later.
2020-10-26 13:51:07 +01:00
Olaf Rempel df56c54697 Align identation and some cleanup 2020-10-24 22:09:34 +02:00
Olaf Rempel c5f5a74783 Increment major version
Make a major version bump since the clockstretching changes require
retries/polling and might break current master implementations.
2020-02-02 00:08:13 +01:00
Olaf Rempel 964c933bf3 Do not rely on Clockstretching for writes 2020-02-02 00:03:09 +01:00
Olaf Rempel 5bdbb430e7 Fix NACK handling for flash write 2020-02-01 23:59:15 +01:00
Olaf Rempel 0416a2f536 Cleanup and reduce size 2020-02-01 23:58:50 +01:00
Olaf Rempel cde9bf0a5b Cleanup command names 2020-02-01 22:50:47 +01:00
Olaf Rempel 05a4533cd2 Do not repeat check for every chip type 2020-02-01 22:50:22 +01:00
Olaf Rempel 7e7e50ad84 Calculate timer values 2020-02-01 22:49:51 +01:00
Olaf Rempel 1ff13ca69e
Fix markdown table on github 2019-11-06 13:24:46 +01:00
Olaf Rempel fc61d39288 Do not use IRQs and remove vector table
Do not use ISRs and poll for interrupt flags in the main loop.
No need for moving vector table into bootloader and back.

Remove vector table by adding LDFLAGS = -nostartfiles.
Manually add some code which is now removed, but still needed by C
runtime:
- make sure that r1 is 0x00 (zero register).
- on some MCUs the stack pointer is not initialized correctly after
reset.
- main() need to be placed in special section .init9 to be called at all.

Not sure why the BSS and DATA segment are still initialized.

This change is heavily based on the optiboot bootloader.
2019-11-06 13:18:53 +01:00
Olaf Rempel b60a0fe735 Simplify ACK handling
TWEA bit in TWCR register needs to be cleared to send NACK.
Clear it when too many bytes were received, re-enable it after
when going idle.

Add missing state for prev. send NACK.
Catch all invalid states and reset bus.

TWINT bit needs to be set every time in ISR.
2019-11-06 13:18:53 +01:00
Olaf Rempel eee017dedf Split TWI handling into read/write functions 2019-11-06 13:18:53 +01:00
Olaf Rempel 1418971648 Remove MCU type from version string 2019-11-06 13:18:53 +01:00
Olaf Rempel 5ba6367a37 Get signature bytes from system headers 2019-11-06 13:18:53 +01:00
Olaf Rempel f4ef7a7b1e Update code style
Update indention to spaces
Fix comments
Add README.md and GPL-2 LICENSE files
2019-11-06 13:18:53 +01:00
Olaf Rempel dd4ca2cb33 Merge pull request #2 from jlefley/atmega328p
fix comment to reflect changes in fuses
2015-03-25 09:48:04 +01:00
Jason Lefley f58adea5d6 fix comment to reflect changes in fuses 2015-03-24 11:13:57 -07:00
Olaf Rempel bc5d45359a Fix sizeof(VERSION_STRING)
- sizeof(info) should not be increased (16->18) since the size is never
  exchanged with the I2C master. Also using a non 2^x size will result
  in bigger code since the compiler can no longer use a simple AND to
  implement the bcnt %= sizeof(info).

- when using a info[16] the firmware is small enough to fit in a 512
  word bootloader again :)
2015-03-21 09:15:43 +01:00
Olaf Rempel 31d65c76d7 Merge pull request #1 from jlefley/atmega328p
Add support for atmega328p
2015-03-21 09:11:27 +01:00
Jason Lefley 89b3251dde add support for atmega328p 2015-03-18 15:28:12 -07:00
Olaf Rempel df9fb6c077 move linux tool to own repository 2014-12-26 11:37:34 +01:00
Olaf Rempel 5e4b562608 update Makefile 2014-10-05 14:32:07 +02:00
Olaf Rempel ca2a0a99ae replace linux application 2012-02-11 12:44:02 +01:00
Olaf Rempel 9424e20ea7 add LED macros, bump version 2011-02-20 14:40:42 +01:00
Olaf Rempel d281696895 add progressbar for dumb terminals 2011-02-20 14:40:13 +01:00
Olaf Rempel 9da00855c1 some cleanup 2010-12-25 13:08:02 +01:00
Olaf Rempel 7aa4456607 wait 100ms after application switch 2010-12-25 12:50:23 +01:00
Olaf Rempel 3acd88c11c add small timeout after exit 2010-10-17 18:24:12 +02:00
Olaf Rempel b16b660495 fix mega8 interrupt vector switch 2010-10-17 18:23:41 +02:00
Olaf Rempel a857b3906e fix verify in linux tool 2010-10-17 18:22:38 +02:00
Olaf Rempel 6244c44e65 add linux tool 2010-10-16 19:29:15 +02:00
Olaf Rempel 8a98e09c46 corrections 2010-10-16 19:28:05 +02:00
Olaf Rempel b2c6dc35ce flag eeprom support 2010-08-15 17:01:06 +02:00
Olaf Rempel 525c2e3701 Merge branch 'mega88' 2010-08-15 16:47:01 +02:00
Olaf Rempel f73b52bc3c multicpu support 2010-08-15 16:44:54 +02:00
Olaf Rempel e013aea33c new protocol 2010-07-11 16:51:50 +02:00
Olaf Rempel b39087eb8e change programmer 2009-01-24 16:52:22 +01:00
Olaf Rempel a2becf91ad reduce codesize 2008-06-23 13:51:08 +02:00
Olaf Rempel 997af25bee disable watchdog after reset, reduce size 2008-06-21 15:40:44 +02:00
Olaf Rempel dbef89dc6e mega88 version 2008-06-17 18:02:07 +02:00
Olaf Rempel 96a79d970d fixed eeprom handling 2008-02-17 23:04:52 +01:00
Olaf Rempel b9595cca59 cleanups 2007-10-05 23:16:44 +02:00
Olaf Rempel 164ef6fefa secure writing with cookie 2007-09-24 10:32:51 +02:00
Olaf Rempel 914150f707 initial commit 2007-09-21 21:39:09 +02:00