Commands are now executed after decoding, so there is no need to
track any state other than complete.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
All commands are now framed, where the payload must
always be included within a frame. A 16-bit CRC is postfixed
to each frame for validation. The protocol is now as follows:
<16-bit header><8-bit command><8-bit payload length in words><payload><16-bit trailer><16-bit CRC>
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The latest Klipper main Makefile has bugfixes for proper rebuilding on
a change during "make menuconfig".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's a good idea to reset the cpu before starting the main application
code. However it is difficult to reliably reset the cpu in software.
This changes the software to actually do a cpu hardware reset prior to
launching the main application - after each bootup the code checks to
see if the application should be started before entering the main
bootloader code. This helps ensure the application code is started in
a "pristine" cpu state.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The bootloader is only called after a reset - it doesn't need to worry
about another bootloader launching it. This reduces the code size by
a small amount.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Build size is likely more important than CPU performance for a
bootloader. So, instruct gcc to optimize for size by default.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use Klipper's nodeid to canbus_id scheme (canbus_id = nodeid * 2 +
0x100). Instead, use a nodeid offset of 128 to avoid collisions with
Klipper.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It is possible that a user will flash the bootloader before
ever having flashed Klipper. In this case they would be
unable to supply a UUID.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This broadcasts a command to clear the id for all nodes running
the bootloader, which should prevent ID collisions.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This is just to avoid confusion between RX_EOF and the command trailer.
Having both as 0x03 could potential lead to issues.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This method isn't necessary as the bootloader shouldnt need to discover
multiple node ids. Change the decoded node ID offset to 0x200 in an
effort to avoid collisions with nodes assigned by Klipper.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>