Skip to content

Conversation

@hlyi
Copy link

@hlyi hlyi commented Jul 21, 2023

This request to add the following features and board:

  • Add "Jeff Probe" board.
  • Add "BOOT_LOAD_PIN".
    • The code was based upon SAM-BA. when boots, pulling BOOT_LOAD_PIN low would enter bootloader mode.
    • The define can be set in board_config.h
    • This feature costs about ~36 Bytes.
  • Add ability to update bootloader in UF2 mode without touching application flash
    • The feature can be enable by adding "USE_SRAM_BL_FLASH = 1" in "board.mk" file.
    • To enable this feature for the first time, add "CONV_SRAM_BL=1" option to make command. The "update-bootloader-.uf2" will still overwrite application flash
    • For subsequent updates, do not use "CONV_SRAM_BL=1" option, the "update-bootloader-.uf2" will run from SRAM, and will not overwrite application flash.
    • This feature costs about ~108 Bytes.

…h bootloader from SRAM which does not touch application code
Copy link

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor format cleanups: I'd like to be consistent about code formatting style.

These commits are several months old; I was confused, but I think you're just pushing them now?

Have you built and tested this code base on some standard board (say an Adafruit one) without the new options being enabled? Thanks.

} else {
// logval("write block at", bl->targetAddr);
#ifdef SRAM_BL_SIZE
if ( use_flash) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( use_flash) {
if (use_flash) {

if ( use_flash) {
flash_write_row((void *)bl->targetAddr, (void *)bl->data);
*DBL_TAP_PTR = 0;
}else{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}else{
} else {

uint32_t addr_limit = boot_sram ? SRAM_BASE_ADDR+SRAM_BL_SIZE : FLASH_SIZE;

app_start_address = *(uint32_t *)( base_addr + 4 );
if ( app_start_address < base_addr || app_start_address > addr_limit ){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( app_start_address < base_addr || app_start_address > addr_limit ){
if (app_start_address < base_addr || app_start_address > addr_limit) {

*DBL_TAP_PTR = 0;
}else{
memcpy((void*)bl->targetAddr, (void*)bl->data, FLASH_ROW_SIZE);
if ( bl->targetAddr == SRAM_BASE_ADDR ){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( bl->targetAddr == SRAM_BASE_ADDR ){
if (bl->targetAddr == SRAM_BASE_ADDR) {

memcpy((void*)bl->targetAddr, (void*)bl->data, FLASH_ROW_SIZE);
if ( bl->targetAddr == SRAM_BASE_ADDR ){
uint32_t bootAddr = bl->data[4] | (bl->data[5]<<8) | (bl->data[6]<<16) | (bl->data[7]<<24);
if( bootAddr > SRAM_BASE_ADDR && bootAddr < (SRAM_BASE_ADDR + SRAM_BL_SIZE) ){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if( bootAddr > SRAM_BASE_ADDR && bootAddr < (SRAM_BASE_ADDR + SRAM_BL_SIZE) ){
if (bootAddr > SRAM_BASE_ADDR && bootAddr < (SRAM_BASE_ADDR + SRAM_BL_SIZE)) {

*DBL_TAP_PTR = 0;
}
#ifdef SRAM_BL_SIZE
else if ( *DBL_TAP_PTR == DBL_TAP_MAGIC_SRAM_BL ) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
else if ( *DBL_TAP_PTR == DBL_TAP_MAGIC_SRAM_BL ) {
else if (*DBL_TAP_PTR == DBL_TAP_MAGIC_SRAM_BL) {

// bootloader doesn't run us a second time. We don't need to erase to write
// zeros. The remainder of the write unit will be set to 1s which should
// preserve the existing values but its not critical.
#if ( (! defined(SRAM_BL_SIZE)) || defined(USE_STD_FLASH_BL) )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if ( (! defined(SRAM_BL_SIZE)) || defined(USE_STD_FLASH_BL) )
#if ((!defined(SRAM_BL_SIZE)) || defined(USE_STD_FLASH_BL))

// reset without waiting for double tap (only works for one reset)
RGBLED_set_color(COLOR_LEAVE);
#ifdef SRAM_BL_SIZE
if ( *DBL_TAP_PTR != DBL_TAP_MAGIC_SRAM_BL)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( *DBL_TAP_PTR != DBL_TAP_MAGIC_SRAM_BL)
if (*DBL_TAP_PTR != DBL_TAP_MAGIC_SRAM_BL)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants