diff --git a/avr/bootloader/bootloader.c b/avr/bootloader/bootloader.c index b09a1f6..874e184 100644 --- a/avr/bootloader/bootloader.c +++ b/avr/bootloader/bootloader.c @@ -33,6 +33,10 @@ #include "config.h" #include "usbdrv/usbdrv.c" + + + + /* * USBasp requests, taken from the original USBasp sourcecode */ @@ -74,6 +78,10 @@ (LED_DIR ^= (1 << LED_PIN)));} +#define AVR_BTLDR_EN_PORT PORTC +#define AVR_BTLDR_EN_DIR DDRC +#define AVR_BTLDR_EN_PIN PC1 +#define AVR_BTLDR_EN_IN PINC /* @@ -449,6 +457,18 @@ int __attribute__ ((noreturn, OS_main)) main(void) uint16_t delay = 0; timeout = TIMEOUT; + DDRC &= ~(1 << AVR_BTLDR_EN_PIN); + PORTC &= ~(1 << AVR_BTLDR_EN_PIN); + + if ((AVR_BTLDR_EN_IN & ( 1 << AVR_BTLDR_EN_PIN)) == 0){ + banner(); + uart_puts("Bootloader flashing is disabled\n\r"); + MCUSR = 0; + leave_bootloader(); + + } + + /* * if power-on reset, quit bootloader via watchdog reset diff --git a/avr/usbload/testing.c b/avr/usbload/testing.c index 9657d67..38054d5 100644 --- a/avr/usbload/testing.c +++ b/avr/usbload/testing.c @@ -31,6 +31,7 @@ #include "debug.h" #include "crc.h" #include "info.h" +#include "dump.h" void test_read_write() { @@ -92,6 +93,30 @@ void test_non_zero_memory(uint32_t bottom_addr, uint32_t top_addr) } +void test_memory_pattern(uint32_t bottom_addr, uint32_t top_addr, uint32_t bank_size) +{ + uint32_t addr = 0; + uint8_t pattern = 0x55; + info_P(PSTR("test_memory_pattern: bottom_addr=0x%08lx top_addr=0x%08lx\n"), bottom_addr, top_addr); + sram_bulk_write_start(bottom_addr); + for (addr = bottom_addr; addr < top_addr; addr++) { + if (addr % bank_size == 0){ + pattern++; + info_P(PSTR("test_memory_pattern: write addr=0x%08lx pattern=0x%08lx\n"), addr, pattern); + } + sram_bulk_write(pattern); + } + sram_bulk_write_end(); + + + for (addr = bottom_addr; addr < top_addr; addr+=bank_size) { + info_P(PSTR("test_memory_pattern: dump bottom_addr=0x%08lx top_addr=0x%08lx\n"), addr, addr + bank_size); + dump_memory(addr, addr + bank_size ); + info_P(PSTR("----------------------------------------------------------------\n")); + } + + crc_check_bulk_memory((uint32_t)bottom_addr,top_addr, bank_size); +} void test_crc() {