Skip to content

Commit 77b194e

Browse files
all working πŸ’ͺ
1 parent 7914813 commit 77b194e

10 files changed

Lines changed: 8777 additions & 8691 deletions

β€ŽCore/App/Bootloader.cβ€Ž

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void const __b_write_memory(fdcan_packet_t* packet){
133133
uint32_t buffer[SECTOR_SIZE_IN_32BITS_WORDS];
134134
sector_t sector;
135135
uint32_t address;
136-
uint16_t i;
136+
uint16_t i, counter = 1;
137137

138138
sector = packet->data[0];
139139
address = flash_get_sector_starting_address(sector);
@@ -145,6 +145,11 @@ void const __b_write_memory(fdcan_packet_t* packet){
145145

146146
__b_send_ack(packet);
147147

148+
if (__b_wait_for_ack(packet->identifier) != BOOTLOADER_OK) {
149+
__b_send_nack(packet);
150+
return;
151+
}
152+
148153
for (i = 0; i < SECTOR_SIZE_IN_32BITS_WORDS; i +=16) {
149154
__b_wait_until_fdcan_message_received();
150155
if (fdcan_read(packet) != FDCAN_OK) {
@@ -159,6 +164,18 @@ void const __b_write_memory(fdcan_packet_t* packet){
159164
}
160165

161166
__b_data_copy_from_packet(packet, ((uint8_t*)&(buffer[i])));
167+
168+
if (counter >= BOOTLOADER_BLOCK_SIZE) {
169+
__b_send_ack(packet);
170+
if (__b_wait_for_ack(packet->identifier) != BOOTLOADER_OK) {
171+
__b_send_nack(packet);
172+
return;
173+
}
174+
counter = 1;
175+
}else{
176+
counter++;
177+
}
178+
162179
}
163180

164181
flash_write(address, buffer, SECTOR_SIZE_IN_32BITS_WORDS);

β€ŽCore/App/Bootloader.hβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#define BOOTLOADER_BLOCK_SIZE ((uint8_t)8U)
1818

19-
#define BOOTLOADER_MAX_TIMEOUT ((uint32_t) 1000)
19+
#define BOOTLOADER_MAX_TIMEOUT ((uint32_t) 2000)
2020

2121

2222
/****************************************************************************************

β€ŽDebug/Core/App/Bootloader.oβ€Ž

316 Bytes
Binary file not shown.

β€ŽDebug/Core/App/Bootloader.suβ€Ž

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
../Core/App/Bootloader.c:73:12:__b_get_version 16 static
33
../Core/App/Bootloader.c:85:12:__b_read_memory 131104 static
44
../Core/App/Bootloader.c:132:12:__b_write_memory 131104 static
5-
../Core/App/Bootloader.c:169:12:__b_erase_memory 24 static
6-
../Core/App/Bootloader.c:189:12:__b_go 16 static
7-
../Core/App/Bootloader.c:193:12:__b_data_copy_to_packet 24 static
8-
../Core/App/Bootloader.c:201:12:__b_data_copy_from_packet 24 static
9-
../Core/App/Bootloader.c:209:26:__b_wait_for_ack 88 static
10-
../Core/App/Bootloader.c:227:12:__b_send_ack 16 static
11-
../Core/App/Bootloader.c:233:12:__b_send_nack 16 static
12-
../Core/App/Bootloader.c:239:16:__b_get_addr_from_data 24 static
13-
../Core/App/Bootloader.c:245:12:__b_clean_fdcan_packet_data 24 static
14-
../Core/App/Bootloader.c:253:12:__b_clean_fdcan_packet_all 24 static
15-
../Core/App/Bootloader.c:264:26:__b_wait_until_fdcan_message_received 8 static
5+
../Core/App/Bootloader.c:186:12:__b_erase_memory 24 static
6+
../Core/App/Bootloader.c:206:12:__b_go 16 static
7+
../Core/App/Bootloader.c:210:12:__b_data_copy_to_packet 24 static
8+
../Core/App/Bootloader.c:218:12:__b_data_copy_from_packet 24 static
9+
../Core/App/Bootloader.c:226:26:__b_wait_for_ack 88 static
10+
../Core/App/Bootloader.c:244:12:__b_send_ack 16 static
11+
../Core/App/Bootloader.c:250:12:__b_send_nack 16 static
12+
../Core/App/Bootloader.c:256:16:__b_get_addr_from_data 24 static
13+
../Core/App/Bootloader.c:262:12:__b_clean_fdcan_packet_data 24 static
14+
../Core/App/Bootloader.c:270:12:__b_clean_fdcan_packet_all 24 static
15+
../Core/App/Bootloader.c:281:26:__b_wait_until_fdcan_message_received 8 static

β€ŽDebug/Core/Src/main.oβ€Ž

0 Bytes
Binary file not shown.

β€ŽDebug/HUPV-Bootloader.binβ€Ž

136 Bytes
Binary file not shown.

β€ŽDebug/HUPV-Bootloader.elfβ€Ž

132 Bytes
Binary file not shown.

0 commit comments

Comments
Β (0)