Skip to content

Commit e91cbe8

Browse files
committed
Bootloader: add 3 LED blinks on boot
Replaces #12
1 parent 66fda83 commit e91cbe8

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

bootloaders/atmega4809_uart_bl.hex

+18-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
:10000000112480911F138B3E09F05FC08FEF809306
2-
:100010001F1393E08DE984BF90930010809102102C
3-
:1000200081FDFCCF80EC80930608A09123110A2E5D
4-
:10003000000CBB0BBC5F2CE530E00E946C00DC01C7
5-
:10004000CB019E5FAF4FBF4F2AE0B595A79597951F
6-
:1000500087952A95D1F78093080890930908809195
7-
:10006000E20581608093E205049A669AE0E0F2E49A
8-
:100070002DE933E040E41EC08091040887FFFCCFE7
9-
:1000800080910008E11552E4F50711F4882391F0FE
10-
:10009000809302088193CF018F779927892B51F4A0
11-
:1000A00024BF309300108091021080FDFCCF8DB1F1
12-
:1000B00084278DB9CF0190548115904CE8F291E0DE
13-
:1000C00088ED84BF9093410007C082E080930110C7
14-
:1000D000E0E0F1E00995A6CF0E947300B7FF089514
15-
:1000E000821B930B0895A29FB001B39FC001A39FF1
16-
:1000F000700D811D1124911DB29F700D811D112461
17-
:04010000911D0895B0
1+
:100000001124669A26E030E408C000000197E9F761
2+
:100010008DB183278DB9215019F081E091E7F6CF9A
3+
:1000200080911F138B3E69F48FEF80931F138DE92E
4+
:1000300093E084BF909300108091021081FDFCCF6B
5+
:1000400006C082E080930110E0E0F1E0099580ECC9
6+
:1000500080930608A09123110A2E000CBB0BBC5FF5
7+
:100060002CE530E00E9476007E5F8F4F9F4F2AE0A4
8+
:1000700095958795779567952A95D1F760930808A8
9+
:10008000709309088091E20581608093E205049AEB
10+
:10009000E0E0F2E42DE933E040E41EC08091040882
11+
:1000A00087FFFCCF80910008E11552E4F50711F4B9
12+
:1000B000882391F0809302088193CF018F7799274D
13+
:1000C000892B51F424BF309300108091021080FDE1
14+
:1000D000FCCF8DB184278DB9CF0190548115904C00
15+
:1000E000E8F288ED91E084BF909341000E947D008A
16+
:1000F000B7FF0895821B930B0895A29FB001B39F91
17+
:10010000C001A39F700D811D1124911DB29F700D20
18+
:08011000811D1124911D0895C9
1819
:02000004008278
1920
:00000001FF

bootloaders/boot.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static inline uint8_t uart_receive(void);
7777
static inline void uart_send(uint8_t byte);
7878
static inline void init_status_led(void);
7979
static inline void toggle_status_led(void);
80+
static inline void wait_50_ms(void);
8081

8182
/*
8283
* Main boot function
@@ -88,6 +89,13 @@ __attribute__((naked)) __attribute__((section(".ctors"))) void boot(void)
8889
/* Initialize system for AVR GCC support, expects r1 = 0 */
8990
asm volatile("clr r1");
9091

92+
/* 3 very fast blinks (to match optiboot behaviour) */
93+
init_status_led();
94+
for (uint8_t i = 0; i < 6; i++) {
95+
wait_50_ms();
96+
toggle_status_led();
97+
}
98+
9199
/* Check if entering application or continuing to bootloader */
92100
if(!is_bootloader_requested()) {
93101
/* Enable Boot Section Lock */
@@ -100,7 +108,6 @@ __attribute__((naked)) __attribute__((section(".ctors"))) void boot(void)
100108

101109
/* Initialize communication interface */
102110
init_uart();
103-
init_status_led();
104111

105112
/*
106113
* Start programming at start for application section
@@ -199,3 +206,10 @@ static inline void toggle_status_led(void)
199206
/* Toggle LED0 (PD6) */
200207
VPORTD.OUT ^= PIN6_bm;
201208
}
209+
210+
static inline void wait_50_ms(void)
211+
{
212+
for (uint16_t i = 160000; i--; i != 0) {
213+
asm volatile ("nop");
214+
}
215+
}

bootloaders/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ ${AVR_GCC_PATH}/avr-objcopy -O ihex -R .fuses boot.elf boot.hex
1515
echo Moving hex
1616
mv boot.hex atmega4809_uart_bl.hex
1717

18-
${AVR_GCC_PATH}/../avrdude/6.3.0-arduino14/bin/avrdude -C${AVR_GCC_PATH}/../avrdude/6.3.0-arduino14/etc/avrdude.conf -v -patmega4809 -cxplainedmini_updi -Pusb -Ufuses:w:boot.fuses:r -Uflash:w:boot.bin:r
18+
#${AVR_GCC_PATH}/../avrdude/6.3.0-arduino14/bin/avrdude -C${AVR_GCC_PATH}/../avrdude/6.3.0-arduino14/etc/avrdude.conf -v -patmega4809 -cxplainedmini_updi -Pusb -Ufuses:w:boot.fuses:r -Uflash:w:boot.bin:r

0 commit comments

Comments
 (0)