Skip to content

Commit bd74041

Browse files
Bootloader stable version 0x02
1 parent 4974295 commit bd74041

18 files changed

Lines changed: 8286 additions & 7630 deletions
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
2F62501ED4689FB349E356AB974DBE57=6FB3D03341C5D261A9EE9841C66A6A20
1+
2F62501ED4689FB349E356AB974DBE57=FB342634F37698A5AC3944ABCC196355
22
635E684B79701B039C64EA45C3F84D30=E893F68E978C440B1208EDC95C425A4A
33
66BE74F758C12D739921AEA421D593D3=0
4-
8DF89ED150041C4CBC7CB9A9CAA90856=6FB3D03341C5D261A9EE9841C66A6A20
4+
8DF89ED150041C4CBC7CB9A9CAA90856=FB342634F37698A5AC3944ABCC196355
55
DC22A860405A8BF2F2C095E5B6529F12=5E54281DC75B4DE702FD7B851B2C5A22
66
eclipse.preferences.version=1

Core/App/Bootloader.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ void bootloader_start(){
6565
}
6666

6767
void const __b_get_version(fdcan_packet_t* packet){
68-
__b_clean_fdcan_packet_all(packet);
69-
7068
__b_send_ack(packet);
7169

7270
packet->data[0] = BOOTLOADER_VERSION;
@@ -133,8 +131,19 @@ void const __b_write_memory(fdcan_packet_t* packet){
133131
__b_send_nack(packet);
134132
return;
135133
}
136-
__b_data_copy_to_packet(packet, ((uint8_t*)&(buffer[i])));
134+
135+
if (packet->identifier != WRITE_MEMORY_ORDER) {
136+
packet->identifier = WRITE_MEMORY_ORDER;
137+
__b_send_nack(packet);
138+
return;
139+
}
140+
141+
__b_data_copy_from_packet(packet, ((uint8_t*)&(buffer[i])));
137142
}
143+
144+
flash_write(address, buffer, SECTOR_SIZE_IN_32BITS_WORDS);
145+
146+
__b_send_ack(packet);
138147
}
139148

140149
void const __b_erase_memory(fdcan_packet_t* packet){
@@ -169,6 +178,15 @@ void const __b_data_copy_to_packet(fdcan_packet_t* packet, uint8_t* data){
169178
}
170179
}
171180

181+
void const __b_data_copy_from_packet(fdcan_packet_t* packet, uint8_t* data){
182+
uint8_t i;
183+
184+
for (i = 0; i < 64; ++i) {
185+
data[i] = packet->data[i];
186+
}
187+
}
188+
189+
172190
void const __b_send_ack(fdcan_packet_t* packet){
173191
__b_clean_fdcan_packet_data(packet);
174192
packet->data[0] = BOOTLOADER_ACK;

Core/App/Bootloader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "Flash.h"
1313
#include "FDCAN.h"
1414

15-
#define BOOTLOADER_VERSION (0x01)
15+
#define BOOTLOADER_VERSION (0x02)
1616

1717
/****************************************************************************************
1818
* Type definitions

Core/App/Flash.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ flash_error const flash_write(uint32_t dest_addr, uint32_t* data, uint32_t numbe
5353
return FLASH_PROTECTED_MEM;
5454
}
5555

56-
data[index] = index;
5756
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, start_sector_addr, (uint32_t)&data[index]) == HAL_OK) {
5857
start_sector_addr += FLASH_WORD_SIZE;
5958
index += FLASH_WORD_SIZE / FLASH_32BITS_WORLD;

Core/Src/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ int main(void)
9393
HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0);
9494

9595
bootloader_start();
96-
//flash_test();
9796
/* USER CODE END 2 */
9897

9998
/* Infinite loop */

Debug/Core/App/Bootloader.o

1.24 KB
Binary file not shown.

Debug/Core/App/Bootloader.su

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
../Core/App/Bootloader.c:33:6:bootloader_start 80 static
2-
../Core/App/Bootloader.c:66:12:__b_get_version 16 static
3-
../Core/App/Bootloader.c:80:12:__b_read_memory 131104 static
4-
../Core/App/Bootloader.c:113:12:__b_write_memory 16 static
5-
../Core/App/Bootloader.c:115:12:__b_erase_memory 24 static
6-
../Core/App/Bootloader.c:135:12:__b_go 16 static
7-
../Core/App/Bootloader.c:137:12:__b_data_copy_to_packet 24 static
8-
../Core/App/Bootloader.c:145:12:__b_send_ack 16 static
9-
../Core/App/Bootloader.c:151:12:__b_send_nack 16 static
10-
../Core/App/Bootloader.c:157:16:__b_get_addr_from_data 24 static
11-
../Core/App/Bootloader.c:163:12:__b_clean_fdcan_packet_data 24 static
12-
../Core/App/Bootloader.c:171:12:__b_clean_fdcan_packet_all 24 static
13-
../Core/App/Bootloader.c:182:12:__b_wait_until_fdcan_message_received 8 static
1+
../Core/App/Bootloader.c:34:6:bootloader_start 80 static
2+
../Core/App/Bootloader.c:67:12:__b_get_version 16 static
3+
../Core/App/Bootloader.c:79:12:__b_read_memory 131104 static
4+
../Core/App/Bootloader.c:112:12:__b_write_memory 131104 static
5+
../Core/App/Bootloader.c:149:12:__b_erase_memory 24 static
6+
../Core/App/Bootloader.c:169:12:__b_go 16 static
7+
../Core/App/Bootloader.c:173:12:__b_data_copy_to_packet 24 static
8+
../Core/App/Bootloader.c:181:12:__b_data_copy_from_packet 24 static
9+
../Core/App/Bootloader.c:190:12:__b_send_ack 16 static
10+
../Core/App/Bootloader.c:196:12:__b_send_nack 16 static
11+
../Core/App/Bootloader.c:202:16:__b_get_addr_from_data 24 static
12+
../Core/App/Bootloader.c:208:12:__b_clean_fdcan_packet_data 24 static
13+
../Core/App/Bootloader.c:216:12:__b_clean_fdcan_packet_all 24 static
14+
../Core/App/Bootloader.c:227:12:__b_wait_until_fdcan_message_received 8 static

Debug/Core/App/Flash.o

-20 Bytes
Binary file not shown.

Debug/Core/App/Flash.su

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
../Core/App/Flash.c:16:19:flash_read 32 static
22
../Core/App/Flash.c:33:19:flash_write 48 static
3-
../Core/App/Flash.c:70:19:flash_erase 24 static
4-
../Core/App/Flash.c:98:16:__flash_get_sector 24 static
5-
../Core/App/Flash.c:138:16:flash_get_sector_starting_address 24 static
3+
../Core/App/Flash.c:69:19:flash_erase 24 static
4+
../Core/App/Flash.c:97:16:__flash_get_sector 24 static
5+
../Core/App/Flash.c:137:16:flash_get_sector_starting_address 24 static

Debug/Core/Src/main.o

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)