ADD library update-client
This commit is contained in:
		
							
								
								
									
										2
									
								
								mbed-os-bootloader/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								mbed-os-bootloader/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -5,4 +5,4 @@ projectfiles | ||||
| mbed-os | ||||
| BUILD | ||||
| !BUILD/DISCO_H747I/GCC_ARM/mbed-os-bootloader.bin | ||||
|  | ||||
| update-client | ||||
|   | ||||
| @@ -1,8 +1,10 @@ | ||||
| #include "mbed.h" | ||||
| #include "FlashIAPBlockDevice.h" | ||||
| #include "update-client/block_device_application.hpp" | ||||
|  | ||||
| #include "mbed_trace.h" | ||||
| #if MBED_CONF_MBED_TRACE_ENABLE | ||||
| #define TRACE_GROUP "bootloader" | ||||
| #define TRACE_GROUP "BOOTLOADER" | ||||
| #endif // MBED_CONF_MBED_TRACE_ENABLE | ||||
|  | ||||
| #if MBED_CONF_MBED_TRACE_ENABLE | ||||
| @@ -22,14 +24,30 @@ int main() { | ||||
|     mbed_trace_print_function_set(boot_debug); | ||||
| #endif // MBED_CONF_MBED_TRACE_ENABLE | ||||
|  | ||||
|     tr_debug("BikeComputer bootloader\r\n"); | ||||
|     tr_debug("BikeComputer bootloader\r"); | ||||
|  | ||||
|     // at this stage we directly branch to the main application | ||||
|     void *sp = *((void **) POST_APPLICATION_ADDR + 0);  // NOLINT(readability/casting) | ||||
|     void *pc = *((void **) POST_APPLICATION_ADDR + 1);  // NOLINT(readability/casting) | ||||
|     tr_debug("Starting application at address 0x%08x (sp 0x%08x, pc 0x%08x)\r\n", POST_APPLICATION_ADDR, (uint32_t) sp, (uint32_t) pc); | ||||
|     FlashIAPBlockDevice flashIAPBlockDevice(MBED_ROM_START, MBED_ROM_SIZE); | ||||
|     int ret = flashIAPBlockDevice.init(); | ||||
|     if(ret == 0) { | ||||
|         update_client::BlockDeviceApplication app(flashIAPBlockDevice, HEADER_ADDR - MBED_ROM_START, POST_APPLICATION_ADDR - MBED_ROM_START); //MBED_CONF_UPDATE_CLIENT_STORAGE_ADDRESS);// | ||||
|         tr_debug("Checking active application\n"); | ||||
|  | ||||
|     mbed_start_application(POST_APPLICATION_ADDR); | ||||
|         tr_debug("MBED_ROM_START : 0x%08x", MBED_ROM_START); | ||||
|         tr_debug("MBED_ROM_SIZE : 0x%08x", MBED_ROM_SIZE); | ||||
|         tr_debug("HEADER_ADDR : 0x%08x", HEADER_ADDR); | ||||
|         tr_debug("APPLICATION_ADDR : 0x%08x", APPLICATION_ADDR); | ||||
|         tr_debug("POST_APPLICATION_ADDR : 0x%08x\n", POST_APPLICATION_ADDR); | ||||
|  | ||||
|     return 0; | ||||
|         update_client::UCErrorCode ret = app.checkApplication(); | ||||
|         if(ret == update_client::UCErrorCode::UC_ERR_NONE) { | ||||
|             tr_debug("Application is valid"); | ||||
|             void *sp = *((void **) POST_APPLICATION_ADDR + 0);  // NOLINT(readability/casting) | ||||
|             void *pc = *((void **) POST_APPLICATION_ADDR + 1);  // NOLINT(readability/casting) | ||||
|             tr_debug("Starting application at address 0x%08x (sp 0x%08x, pc 0x%08x)", POST_APPLICATION_ADDR, (uint32_t) sp, (uint32_t) pc); | ||||
|             mbed_start_application(POST_APPLICATION_ADDR); | ||||
|         } | ||||
|         tr_error("Error on check of the application"); | ||||
|     } | ||||
| 	tr_error("Error on init flash IAP block device"); | ||||
|     return -1; | ||||
| } | ||||
| @@ -1,6 +1,7 @@ | ||||
| { | ||||
|     "macros": [ | ||||
|       "MBED_CONF_MBED_TRACE_FEA_IPV6=0" | ||||
|       "MBED_CONF_MBED_TRACE_FEA_IPV6=0", | ||||
|       "MBED_BOOTLOADER_FLASH_BANK_SIZE=MBED_ROM_SIZE/2" | ||||
|     ], | ||||
|     "config": { | ||||
|       "main-stack-size": { | ||||
| @@ -17,7 +18,10 @@ | ||||
|         "platform.all-stats-enabled": true, | ||||
|         "target.printf_lib":"minimal-printf", | ||||
|         "platform.minimal-printf-enable-floating-point": true, | ||||
|         "platform.minimal-printf-set-floating-point-max-decimals": 2 | ||||
|         "platform.minimal-printf-set-floating-point-max-decimals": 2, | ||||
|         "update-client.storage-address": "(MBED_BOOTLOADER_FLASH_BANK_SIZE)", | ||||
|         "update-client.storage-size": "(MBED_BOOTLOADER_FLASH_BANK_SIZE)", | ||||
|         "update-client.storage-locations": 2 | ||||
|       }, | ||||
|       "DISCO_H747I": { | ||||
|         "target.restrict_size": "0x20000", | ||||
|   | ||||
							
								
								
									
										22
									
								
								mbed-os-bootloader/mbed_lib.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								mbed-os-bootloader/mbed_lib.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| { | ||||
|   "name": "bootloader", | ||||
|   "target_overrides": { | ||||
|     "*": { | ||||
|       "target.header_format": [ | ||||
|         ["magic", "const", "32be", "0x5a51b3d4"], | ||||
|         ["version", "const", "32be", "2"], | ||||
|         ["firmwareVersion", "timestamp", "64be", null], | ||||
|         ["firmwareSize", "size", "64be", ["application"]], | ||||
|         ["firmwareHash", "digest", "SHA256", "application"], | ||||
|         ["hashpad", "const", "64be", "0"], | ||||
|         ["hashpad", "const", "64be", "0"], | ||||
|         ["hashpad", "const", "64be", "0"], | ||||
|         ["hashpad", "const", "64be", "0"], | ||||
|         ["campaign", "const", "64be", "0"], | ||||
|         ["campaign", "const", "64be", "0"], | ||||
|         ["firmwareSignatureSize", "const", "32be", "0"], | ||||
|         ["headerCRC", "digest", "CRCITT32be", "header"] | ||||
|       ] | ||||
|     } | ||||
|   } | ||||
| } | ||||
							
								
								
									
										1
									
								
								mbed-os-bootloader/update-client.lib
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								mbed-os-bootloader/update-client.lib
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| https://github.com/SergeAyer/update-client#82fe2add70c714d9ce943f1a7dc5fda7dba75dba | ||||
		Reference in New Issue
	
	Block a user