Open the usb device with the O_NOCTTY flag. This prevents
a SIGHUP signal from killing the flashtool process if the
bootloader request results in a hangup event.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Handle exceptions if the conversion from USB serial number
to uuid fails for can bridge devices. Abort detection as the
can bridge device cannot be flashed in one step.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Raise a FlashError if Katapult's MCU does not match the
MCU detected in klipper.bin. If a user wants to flash a binary
built for a different they can rename klipper.bin, which will
bypass detection.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
The previous UUID verification step introduce a delay that allowed
nodes time to reboot before a node ID was assigned. Reintroduce a
1 second delay.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
When multiple nodes are on the network the UUID query
can result in transmit errors, as multiple nodes with the
same ID will attempt to respond.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Don't requre exactly 8 bytes in a response, as its possible
that some apps may not return a full 8 bytes.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Don't log read exceptions for each iteration, only log when the
exception differs. Log timeout exceptions separately.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Support building a "flashing application" that one may run from an
existing bootloader. This flashing application will then flash the
main CanBoot binary to the start of flash.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The lpc176x internal rom checks that the first 8 words of the flash
sum to zero. Many flash writing tools for the lpc176x will
automatically add the appropriate checksum. However, it can be useful
to build the checksum locally so that the image supports direct flash
writing.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Allow the application start address to be configurable from "make
menuconfig".
Add a build check to verify the final binary can fit within the
configured size.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some boards require an initial gpio state in order to start USB. Port
the initial_pins capability from Klipper to provide that support.
This also synchronizes scripts/buildcommands.py with the latest code
from Klipper.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add the sched.c code and associated DECL_INIT(), DECL_TASK() macros so
that it is easier to import low-level Klipper code into the CanBoot
repo.
These additional code wrappers do not increase the overall binary size
as gcc does a good job of inlining the wrappers and removing unused
code during the compile process.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
There is a severe corner case where two mcus could potentially be
assigned the same canbus_id and thus flash commands could go to the
wrong mcu. Add a get_canbus_id command to attempt to prevent this.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>