Build system improvements and bug fixes (#1129)
* Assets: recompile * Makefile: add debug_other to main makefile * Github: stop compilation if compiled assets not in sync with assets sources * Assets: recompile * Makefile: correct debug_other rule. Bt: prevent on system start hook from waiting for bt service * Power, FuriHal: gauge self check report * Loader: move on system start hook call to the beginning
This commit is contained in:
		
							parent
							
								
									703844dd69
								
							
						
					
					
						commit
						1623134a82
					
				
							
								
								
									
										1
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							| @ -78,6 +78,7 @@ jobs: | |||||||
|             set -e |             set -e | ||||||
|             make -C assets clean |             make -C assets clean | ||||||
|             make -C assets |             make -C assets | ||||||
|  |             git diff --quiet || ( echo "Assets recompilation required."; exit 255 ) | ||||||
| 
 | 
 | ||||||
|       - name: 'Build the firmware in docker' |       - name: 'Build the firmware in docker' | ||||||
|         uses: ./.github/actions/docker |         uses: ./.github/actions/docker | ||||||
|  | |||||||
							
								
								
									
										4
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Makefile
									
									
									
									
									
								
							| @ -51,6 +51,10 @@ flash: firmware_flash | |||||||
| debug: | debug: | ||||||
| 	@$(MAKE) -C firmware -j$(NPROCS) debug | 	@$(MAKE) -C firmware -j$(NPROCS) debug | ||||||
| 
 | 
 | ||||||
|  | .PHONY: debug_other | ||||||
|  | debug_other: | ||||||
|  | 	@$(MAKE) -C firmware -j$(NPROCS) debug_other | ||||||
|  | 
 | ||||||
| .PHONY: blackmagic | .PHONY: blackmagic | ||||||
| blackmagic: | blackmagic: | ||||||
| 	@$(MAKE) -C firmware -j$(NPROCS) blackmagic | 	@$(MAKE) -C firmware -j$(NPROCS) blackmagic | ||||||
|  | |||||||
| @ -189,6 +189,8 @@ static void bt_cli_print_usage() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void bt_cli(Cli* cli, string_t args, void* context) { | static void bt_cli(Cli* cli, string_t args, void* context) { | ||||||
|  |     furi_record_open("bt"); | ||||||
|  | 
 | ||||||
|     string_t cmd; |     string_t cmd; | ||||||
|     string_init(cmd); |     string_init(cmd); | ||||||
|     BtSettings bt_settings; |     BtSettings bt_settings; | ||||||
| @ -235,14 +237,13 @@ static void bt_cli(Cli* cli, string_t args, void* context) { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     string_clear(cmd); |     string_clear(cmd); | ||||||
|  |     furi_record_close("bt"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void bt_on_system_start() { | void bt_on_system_start() { | ||||||
| #ifdef SRV_CLI | #ifdef SRV_CLI | ||||||
|     Cli* cli = furi_record_open("cli"); |     Cli* cli = furi_record_open("cli"); | ||||||
|     furi_record_open("bt"); |  | ||||||
|     cli_add_command(cli, "bt", CliCommandFlagDefault, bt_cli, NULL); |     cli_add_command(cli, "bt", CliCommandFlagDefault, bt_cli, NULL); | ||||||
|     furi_record_close("bt"); |  | ||||||
|     furi_record_close("cli"); |     furi_record_close("cli"); | ||||||
| #else | #else | ||||||
|     UNUSED(bt_cli); |     UNUSED(bt_cli); | ||||||
|  | |||||||
| @ -455,18 +455,17 @@ void loader_update_menu() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int32_t loader_srv(void* p) { | int32_t loader_srv(void* p) { | ||||||
|     FURI_LOG_I(TAG, "Starting"); |     FURI_LOG_I(TAG, "Executing system start hooks"); | ||||||
|  |     for(size_t i = 0; i < FLIPPER_ON_SYSTEM_START_COUNT; i++) { | ||||||
|  |         FLIPPER_ON_SYSTEM_START[i](); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|  |     FURI_LOG_I(TAG, "Starting"); | ||||||
|     loader_instance = loader_alloc(); |     loader_instance = loader_alloc(); | ||||||
| 
 | 
 | ||||||
|     loader_build_menu(); |     loader_build_menu(); | ||||||
|     loader_build_submenu(); |     loader_build_submenu(); | ||||||
| 
 | 
 | ||||||
|     // Call on start hooks
 |  | ||||||
|     for(size_t i = 0; i < FLIPPER_ON_SYSTEM_START_COUNT; i++) { |  | ||||||
|         FLIPPER_ON_SYSTEM_START[i](); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     FURI_LOG_I(TAG, "Started"); |     FURI_LOG_I(TAG, "Started"); | ||||||
| 
 | 
 | ||||||
|     furi_record_create("loader", loader_instance); |     furi_record_create("loader", loader_instance); | ||||||
|  | |||||||
							
								
								
									
										10
									
								
								applications/power/power_service/power.c
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										10
									
								
								applications/power/power_service/power.c
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							| @ -12,6 +12,8 @@ void power_draw_battery_callback(Canvas* canvas, void* context) { | |||||||
|     furi_assert(context); |     furi_assert(context); | ||||||
|     Power* power = context; |     Power* power = context; | ||||||
|     canvas_draw_icon(canvas, 0, 1, &I_Battery_26x8); |     canvas_draw_icon(canvas, 0, 1, &I_Battery_26x8); | ||||||
|  | 
 | ||||||
|  |     if(power->info.gauge_is_ok) { | ||||||
|         canvas_draw_box(canvas, 2, 3, (power->info.charge + 4) / 5, 4); |         canvas_draw_box(canvas, 2, 3, (power->info.charge + 4) / 5, 4); | ||||||
|         if(power->state == PowerStateCharging) { |         if(power->state == PowerStateCharging) { | ||||||
|             canvas_set_bitmap_mode(canvas, 1); |             canvas_set_bitmap_mode(canvas, 1); | ||||||
| @ -21,6 +23,9 @@ void power_draw_battery_callback(Canvas* canvas, void* context) { | |||||||
|             canvas_draw_icon(canvas, 8, 0, &I_Charging_lightning_9x10); |             canvas_draw_icon(canvas, 8, 0, &I_Charging_lightning_9x10); | ||||||
|             canvas_set_bitmap_mode(canvas, 0); |             canvas_set_bitmap_mode(canvas, 0); | ||||||
|         } |         } | ||||||
|  |     } else { | ||||||
|  |         canvas_draw_box(canvas, 8, 4, 8, 2); | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static ViewPort* power_battery_view_port_alloc(Power* power) { | static ViewPort* power_battery_view_port_alloc(Power* power) { | ||||||
| @ -119,6 +124,7 @@ static void power_check_charging_state(Power* power) { | |||||||
| static bool power_update_info(Power* power) { | static bool power_update_info(Power* power) { | ||||||
|     PowerInfo info; |     PowerInfo info; | ||||||
| 
 | 
 | ||||||
|  |     info.gauge_is_ok = furi_hal_power_gauge_is_ok(); | ||||||
|     info.charge = furi_hal_power_get_pct(); |     info.charge = furi_hal_power_get_pct(); | ||||||
|     info.health = furi_hal_power_get_bat_health_pct(); |     info.health = furi_hal_power_get_bat_health_pct(); | ||||||
|     info.capacity_remaining = furi_hal_power_get_battery_remaining_capacity(); |     info.capacity_remaining = furi_hal_power_get_battery_remaining_capacity(); | ||||||
| @ -140,6 +146,10 @@ static bool power_update_info(Power* power) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void power_check_low_battery(Power* power) { | static void power_check_low_battery(Power* power) { | ||||||
|  |     if(!power->info.gauge_is_ok) { | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     // Check battery charge and vbus voltage
 |     // Check battery charge and vbus voltage
 | ||||||
|     if((power->info.charge == 0) && (power->info.voltage_vbus < 4.0f) && |     if((power->info.charge == 0) && (power->info.voltage_vbus < 4.0f) && | ||||||
|        power->show_low_bat_level_message) { |        power->show_low_bat_level_message) { | ||||||
|  | |||||||
| @ -29,6 +29,8 @@ typedef struct { | |||||||
| } PowerEvent; | } PowerEvent; | ||||||
| 
 | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|  |     bool gauge_is_ok; | ||||||
|  | 
 | ||||||
|     float current_charger; |     float current_charger; | ||||||
|     float current_gauge; |     float current_gauge; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,3 +1,3 @@ | |||||||
| #pragma once | #pragma once | ||||||
| #define PROTOBUF_MAJOR_VERSION 0 | #define PROTOBUF_MAJOR_VERSION 0 | ||||||
| #define PROTOBUF_MINOR_VERSION 5 | #define PROTOBUF_MINOR_VERSION 6 | ||||||
|  | |||||||
| @ -21,6 +21,9 @@ typedef struct { | |||||||
|     volatile uint8_t insomnia; |     volatile uint8_t insomnia; | ||||||
|     volatile uint8_t deep_insomnia; |     volatile uint8_t deep_insomnia; | ||||||
|     volatile uint8_t suppress_charge; |     volatile uint8_t suppress_charge; | ||||||
|  | 
 | ||||||
|  |     uint8_t gauge_initialized; | ||||||
|  |     uint8_t charger_initialized; | ||||||
| } FuriHalPower; | } FuriHalPower; | ||||||
| 
 | 
 | ||||||
| static volatile FuriHalPower furi_hal_power = { | static volatile FuriHalPower furi_hal_power = { | ||||||
| @ -84,6 +87,29 @@ void furi_hal_power_init() { | |||||||
|     FURI_LOG_I(TAG, "Init OK"); |     FURI_LOG_I(TAG, "Init OK"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | bool furi_hal_power_gauge_is_ok() { | ||||||
|  |     bool ret = true; | ||||||
|  | 
 | ||||||
|  |     BatteryStatus battery_status; | ||||||
|  |     OperationStatus operation_status; | ||||||
|  | 
 | ||||||
|  |     furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); | ||||||
|  | 
 | ||||||
|  |     if(bq27220_get_battery_status(&furi_hal_i2c_handle_power, &battery_status) == BQ27220_ERROR || | ||||||
|  |        bq27220_get_operation_status(&furi_hal_i2c_handle_power, &operation_status) == | ||||||
|  |            BQ27220_ERROR) { | ||||||
|  |         ret = false; | ||||||
|  |     } else { | ||||||
|  |         ret &= battery_status.BATTPRES; | ||||||
|  |         ret &= operation_status.INITCOMP; | ||||||
|  |         ret &= (cedv.design_cap == bq27220_get_design_capacity(&furi_hal_i2c_handle_power)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     furi_hal_i2c_release(&furi_hal_i2c_handle_power); | ||||||
|  | 
 | ||||||
|  |     return ret; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| uint16_t furi_hal_power_insomnia_level() { | uint16_t furi_hal_power_insomnia_level() { | ||||||
|     return furi_hal_power.insomnia; |     return furi_hal_power.insomnia; | ||||||
| } | } | ||||||
| @ -315,10 +341,9 @@ void furi_hal_power_dump_state() { | |||||||
|     } else { |     } else { | ||||||
|         // Operation status register
 |         // Operation status register
 | ||||||
|         printf( |         printf( | ||||||
|             "bq27220: CALMD: %d, SEC0: %d, SEC1: %d, EDV2: %d, VDQ: %d, INITCOMP: %d, SMTH: %d, BTPINT: %d, CFGUPDATE: %d\r\n", |             "bq27220: CALMD: %d, SEC: %d, EDV2: %d, VDQ: %d, INITCOMP: %d, SMTH: %d, BTPINT: %d, CFGUPDATE: %d\r\n", | ||||||
|             operation_status.CALMD, |             operation_status.CALMD, | ||||||
|             operation_status.SEC0, |             operation_status.SEC, | ||||||
|             operation_status.SEC1, |  | ||||||
|             operation_status.EDV2, |             operation_status.EDV2, | ||||||
|             operation_status.VDQ, |             operation_status.VDQ, | ||||||
|             operation_status.INITCOMP, |             operation_status.INITCOMP, | ||||||
|  | |||||||
| @ -19,10 +19,20 @@ typedef enum { | |||||||
|     FuriHalPowerICFuelGauge, |     FuriHalPowerICFuelGauge, | ||||||
| } FuriHalPowerIC; | } FuriHalPowerIC; | ||||||
| 
 | 
 | ||||||
| /** Initialize drivers
 | /** Initialize drivers */ | ||||||
|  */ |  | ||||||
| void furi_hal_power_init(); | void furi_hal_power_init(); | ||||||
| 
 | 
 | ||||||
|  | /** Check if gauge is ok
 | ||||||
|  |  *  | ||||||
|  |  * Verifies that: | ||||||
|  |  * - gauge is alive | ||||||
|  |  * - correct profile loaded | ||||||
|  |  * - self diagnostic status is good | ||||||
|  |  *  | ||||||
|  |  * @return true if gauge is ok | ||||||
|  |  */ | ||||||
|  | bool furi_hal_power_gauge_is_ok(); | ||||||
|  | 
 | ||||||
| /** Get current insomnia level
 | /** Get current insomnia level
 | ||||||
|  * |  * | ||||||
|  * @return     insomnia level: 0 - no insomnia, >0 - insomnia, bearer count. |  * @return     insomnia level: 0 - no insomnia, >0 - insomnia, bearer count. | ||||||
|  | |||||||
| @ -28,22 +28,25 @@ typedef struct { | |||||||
|     bool FD : 1; // Full-discharge is detected
 |     bool FD : 1; // Full-discharge is detected
 | ||||||
| } BatteryStatus; | } BatteryStatus; | ||||||
| 
 | 
 | ||||||
|  | _Static_assert(sizeof(BatteryStatus) == 2, "Incorrect structure size"); | ||||||
|  | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     // Low byte, Low bit first
 |     // Low byte, Low bit first
 | ||||||
|     bool CALMD : 1; |     bool CALMD : 1; /**< Calibration mode enabled */ | ||||||
|     bool SEC0 : 1; |     uint8_t SEC : 2; /**< Current security access */ | ||||||
|     bool SEC1 : 1; |     bool EDV2 : 1; /**< EDV2 threshold exceeded */ | ||||||
|     bool EDV2 : 1; |     bool VDQ : 1; /**< Indicates if Current discharge cycle is NOT qualified or qualified for an FCC updated */ | ||||||
|     bool VDQ : 1; |     bool INITCOMP : 1; /**< gauge initialization is complete */ | ||||||
|     bool INITCOMP : 1; |     bool SMTH : 1; /**< RemainingCapacity is scaled by smooth engine */ | ||||||
|     bool SMTH : 1; |     bool BTPINT : 1; /**< BTP threshold has been crossed */ | ||||||
|     bool BTPINT : 1; |  | ||||||
|     // High byte, Low bit first
 |     // High byte, Low bit first
 | ||||||
|     uint8_t RSVD1 : 2; |     uint8_t RSVD1 : 2; | ||||||
|     bool CFGUPDATE : 1; |     bool CFGUPDATE : 1; /**< Gauge is in CONFIG UPDATE mode */ | ||||||
|     uint8_t RSVD0 : 5; |     uint8_t RSVD0 : 5; | ||||||
| } OperationStatus; | } OperationStatus; | ||||||
| 
 | 
 | ||||||
|  | _Static_assert(sizeof(OperationStatus) == 2, "Incorrect structure size"); | ||||||
|  | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     // Low byte, Low bit first
 |     // Low byte, Low bit first
 | ||||||
|     bool CCT : 1; |     bool CCT : 1; | ||||||
| @ -62,6 +65,8 @@ typedef struct { | |||||||
|     uint8_t RSVD3 : 3; |     uint8_t RSVD3 : 3; | ||||||
| } GaugingConfig; | } GaugingConfig; | ||||||
| 
 | 
 | ||||||
|  | _Static_assert(sizeof(GaugingConfig) == 2, "Incorrect structure size"); | ||||||
|  | 
 | ||||||
| typedef struct { | typedef struct { | ||||||
|     union { |     union { | ||||||
|         GaugingConfig gauge_conf; |         GaugingConfig gauge_conf; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 あく
						あく