Commit 4d969764 changed the "eof" command to return the number of
blocks instead of the number of pages written. Report the number of
pages written again.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't gather "blocks" into flash pages. Instead, write each "block"
to flash on each flash_write_block() request.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Avoid read-modify-write operations on the FLASH->CR register. Write
out the desired valid explicitly.
Use writew() and writel() to write the flash bytes out to avoid gcc
reordering the memory write relative to the flash register writes.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move application_check_valid() in bootentry.c to armcm_boot.c and make
the check specific to the ARM cortex-m. On these ARM machines it is
easier to validate the application stack address.
Also rename jump_to_application() to application_jump().
Also rename flash_read_block() to application_read_flash() and move to
armcm_boot.c .
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>
Create a board specific timer_setup() function and call it at the
start of sched_main().
Move udelay() from board code to sched.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Introduce the Klipper command_encode() and command_dispatch() style
functions. This makes it easier to import additional Klipper
low-level message handling code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move command handlers from canboot_main.c to flashcmd.c. Move startup
code to sched.c. Rename remaining bootloader entry code to new
bootentry.c file.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Convert the "complete" command to use a regular task instead of custom
code in enter_bootloader().
Perform the reboot based on a timer so that it is not necessary to
query the low-level code for ack transmission status.
Use jump_to_application() instead of canbus_reboot() to start the user
code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
There is no need for a custom check_blink_time() function as this can
be done from a new led_blink_task().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Move the low-level command parsing and encoding code from
canboot_main.c to a new command.c file.
Standardize the parameters and naming for command handlers. Rename
send_ack() to console_send_ack() and rework parameters to be similar
to command handlers.
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>
Wrap defines with expressions in parenthesis.
MAX_OBUF_SIZE is in bytes - divide by 4 for number of words.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>