Skip to content

Commit

Permalink
uncommenting some parts doesn't flash but also doesn't break dfu
Browse files Browse the repository at this point in the history
  • Loading branch information
vk2seb committed Sep 2, 2023
1 parent 510d3bb commit e9d469b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion bootloader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ TINYUSB_OBJ := $(notdir $(TINYUSB_SRC:.c=.o))
CFLAGS += -I$(TINYUSB_DIR)/src \
-DCFG_TUSB_MCU=OPT_MCU_LUNA_EPTRI \
-fdata-sections -ffunction-sections -fsingle-precision-constant -fno-strict-aliasing \
-DCFG_TUSB_DEBUG=3
-DCFG_TUSB_DEBUG=0

vpath %.c $(dir $(TINYUSB_SRC)) $(FW_DIRECTORY) $(FW_DIRECTORY)/luna/eptri
vpath %.S $(FW_DIRECTORY)

OBJECTS = crt0.o \
main.o \
sleep.o \
flash.o \
dcd_eptri.o \
usb_descriptors.o

Expand Down
22 changes: 12 additions & 10 deletions bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ typedef struct
} memory_offest;

memory_offest const alt_offsets[] = {
{.address = 0x200000, .length = 0x600000}, /* Main Gateware */
{.address = 0x800000, .length = 0x400000}, /* Main Firmawre */
{.address = 0x100000, .length = 0x100000}, /* Main Gateware */
{.address = 0x1E0000, .length = 0x010000}, /* Main Firmawre */
{.address = 0xC00000, .length = 0x400000}, /* Extra */
{.address = 0x000000, .length = 0x200000} /* Bootloader */
{.address = 0x000000, .length = 0x100000} /* Bootloader */
};

static int complete_timeout;
Expand Down Expand Up @@ -217,6 +217,7 @@ int main(int i, char **c)
{
button_count = board_millis();
}
#endif

if (bus_reset_received)
{
Expand All @@ -226,24 +227,27 @@ int main(int i, char **c)
break;
}
}
#endif
}
}

/* Reboot to our user bitstream */
irq_setie(0);
usb_device_controller_connect_write(0);

/*
if (spiflash_protection_read() == false)
{
spiflash_protection_write(true);
}
*/

msleep(50);


printf("RESET - pull down PROGRAMN");

while (1)
{
reset_out_write(1);
programn_out_write(1);
}

return 0;
Expand Down Expand Up @@ -326,7 +330,6 @@ void tud_dfu_download_cb(uint8_t alt, uint16_t block_num, uint8_t const *data, u

uint32_t flash_address = alt_offsets[alt].address + block_num * CFG_TUD_DFU_XFER_BUFSIZE;

#if 0
/* First block in 64K erase block */
if ((flash_address & (FLASH_64K_BLOCK_ERASE_SIZE - 1)) == 0)
{
Expand All @@ -337,11 +340,11 @@ void tud_dfu_download_cb(uint8_t alt, uint16_t block_num, uint8_t const *data, u
/* While FLASH erase is in progress update LEDs */
while (spiflash_read_status_register() & 1)
{
led_blinking_task();
//led_blinking_task();
};
}

//printf("tud_dfu_download_cb(), alt=%u, block=%u, flash_address=%08x\n", alt, block_num, flash_address);
printf("tud_dfu_download_cb(), alt=%u, block=%u, flash_address=%08x\n", alt, block_num, flash_address);

for (int i = 0; i < CFG_TUD_DFU_XFER_BUFSIZE / 256; i++)
{
Expand All @@ -357,7 +360,6 @@ void tud_dfu_download_cb(uint8_t alt, uint16_t block_num, uint8_t const *data, u
//led_blinking_task();
};
}
#endif

// flashing op for download complete without error
tud_dfu_finish_flashing(DFU_STATUS_OK);
Expand Down

0 comments on commit e9d469b

Please sign in to comment.