Allow flash_write_block() to write to arbitrary addresses as long as
the flash address starts at a 256 byte boundary.
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>
Rename the existing armcm_boot.c file to armcm_canboot.c . This makes
it easier to track changes between CanBoot and Klipper as the CanBoot
entry code is notably different from the Klipper entry code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Arm GCC 11.2 generates an array bounds warning when
dereferencing a 64-bit pointer. Selectively disable the
warning when handling the bootup code.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This moves the stack so that it is located in an area of SRAM
not modified by the system boot rom.
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
Avoid wrapping the sector index, as that could potentially result in
erasing the booloader itself.
Also, move the stm32f4_sector_index() inline into erase_page().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
There was a Klipper bugfix for STM32F401 clock init.
There was a Klipper build bugfix when building with gcc hardfloat flags.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
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>