From fd3bce508c3f24fec0d2f8c9847b1f7f8203a24a Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Fri, 29 Apr 2022 10:19:47 +0200 Subject: [PATCH] Berry use crc32 code from esp rom --- lib/libesp32/berry/default/be_modtab.c | 2 + lib/libesp32/berry/generate/be_const_strtab.h | 6 +- .../berry/generate/be_const_strtab_def.h | 2461 +++++++++-------- lib/libesp32/berry/generate/be_fixed_crc.h | 19 + .../berry_tasmota/src/be_crc32_module.c | 88 + .../berry_tasmota/src/be_partition_module.c | 620 +---- .../src/embedded/partition_embedded.be | 71 +- 7 files changed, 1494 insertions(+), 1773 deletions(-) create mode 100644 lib/libesp32/berry/generate/be_fixed_crc.h create mode 100644 lib/libesp32/berry_tasmota/src/be_crc32_module.c diff --git a/lib/libesp32/berry/default/be_modtab.c b/lib/libesp32/berry/default/be_modtab.c index 3c8560ce8..61da1f3e3 100644 --- a/lib/libesp32/berry/default/be_modtab.c +++ b/lib/libesp32/berry/default/be_modtab.c @@ -47,6 +47,7 @@ be_extern_native_module(hue_bridge); be_extern_native_module(uuid); be_extern_native_module(animate); be_extern_native_module(partition); +be_extern_native_module(crc); #ifdef USE_LVGL be_extern_native_module(lv); be_extern_native_module(lv_extra); @@ -148,6 +149,7 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = { #endif // USE_WEBSERVER &be_native_module(flash), &be_native_module(partition), + &be_native_module(crc), /* user-defined modules register end */ NULL /* do not remove */ diff --git a/lib/libesp32/berry/generate/be_const_strtab.h b/lib/libesp32/berry/generate/be_const_strtab.h index 332f57979..69f2b5ccf 100644 --- a/lib/libesp32/berry/generate/be_const_strtab.h +++ b/lib/libesp32/berry/generate/be_const_strtab.h @@ -382,9 +382,11 @@ extern const bcstring be_const_str_cosh; extern const bcstring be_const_str_couldn_X27t_X20not_X20initialize_X20noepixelbus; extern const bcstring be_const_str_count; extern const bcstring be_const_str_counters; +extern const bcstring be_const_str_crc; +extern const bcstring be_const_str_crc16; +extern const bcstring be_const_str_crc32; extern const bcstring be_const_str_crc32_ota_seq; -extern const bcstring be_const_str_crc32_table; -extern const bcstring be_const_str_crc32_update; +extern const bcstring be_const_str_crc8; extern const bcstring be_const_str_create_custom_widget; extern const bcstring be_const_str_create_matrix; extern const bcstring be_const_str_create_segment; diff --git a/lib/libesp32/berry/generate/be_const_strtab_def.h b/lib/libesp32/berry/generate/be_const_strtab_def.h index 5d31477c0..584754438 100644 --- a/lib/libesp32/berry/generate/be_const_strtab_def.h +++ b/lib/libesp32/berry/generate/be_const_strtab_def.h @@ -1,898 +1,900 @@ -be_define_const_str(, "", 2166136261u, 0, 0, &be_const_str_serial); -be_define_const_str(_X0A, "\n", 252472541u, 0, 1, &be_const_str_POST); -be_define_const_str(_X0A_X29_X3E, "\n)>", 804061574u, 0, 3, &be_const_str_scr_act); -be_define_const_str(_X20, " ", 621580159u, 0, 1, &be_const_str_obj_class_create_obj); -be_define_const_str(_X20_X20, " ", 2982523533u, 0, 2, &be_const_str_is_ota); -be_define_const_str(_X20_X28, " (", 2848302581u, 0, 2, &be_const_str_tasmota); -be_define_const_str(_X21_X3D, "!=", 2428715011u, 0, 2, &be_const_str_I2C_Driver); -be_define_const_str(_X21_X3D_X3D, "!==", 559817114u, 0, 3, &be_const_str_valuer_error); -be_define_const_str(_X22, "\"", 655135397u, 0, 1, &be_const_str_SERIAL_7O2); -be_define_const_str(_X22_X3A, "\":", 399167565u, 0, 2, &be_const_str__X2Esize); -be_define_const_str(_X23, "#", 638357778u, 0, 1, &be_const_str_SERIAL_7O1); -be_define_const_str(_X23autoexec_X2Ebat, "#autoexec.bat", 3382890497u, 0, 13, &be_const_str_SERIAL_5N1); -be_define_const_str(_X23autoexec_X2Ebe, "#autoexec.be", 1181757091u, 0, 12, &be_const_str_AXP192); -be_define_const_str(_X23display_X2Eini, "#display.ini", 182218220u, 0, 12, NULL); -be_define_const_str(_X23init_X2Ebat, "#init.bat", 3297595077u, 0, 9, &be_const_str_constructor_cb); -be_define_const_str(_X23preinit_X2Ebe, "#preinit.be", 687035716u, 0, 11, &be_const_str_add_anim); -be_define_const_str(_X25, "%", 537692064u, 0, 1, &be_const_str__timers); -be_define_const_str(_X2502d_X25s_X2502d, "%02d%s%02d", 1587999717u, 0, 10, &be_const_str_autoexec); -be_define_const_str(_X2504d_X2D_X2502d_X2D_X2502dT_X2502d_X3A_X2502d_X3A_X2502d, "%04d-%02d-%02dT%02d:%02d:%02d", 3425528601u, 0, 29, &be_const_str_arg_X20must_X20be_X20a_X20subclass_X20of_X20lv_obj); -be_define_const_str(_X2508x_X2D_X2504x_X2D_X2504x_X2D_X2504x_X2D_X2504x_X2508x, "%08x-%04x-%04x-%04x-%04x%08x", 1670063141u, 0, 28, &be_const_str_CFG_X3A_X20removing_X20first_X20time_X20marker); -be_define_const_str(_X25s_X2Eautoconf, "%s.autoconf", 3560383524u, 0, 11, &be_const_str_get_image_size); -be_define_const_str(_X26lt_X3BError_X3A_X20apply_X20new_X20or_X20remove_X26gt_X3B, "<Error: apply new or remove>", 2855507949u, 0, 34, &be_const_str_get_height); -be_define_const_str(_X26lt_X3BNone_X26gt_X3B, "<None>", 2602165498u, 0, 12, &be_const_str_engine); -be_define_const_str(_X27_X20_X2D_X20, "' - ", 3420378487u, 0, 4, &be_const_str_copy); -be_define_const_str(_X28_X29, "()", 685372826u, 0, 2, &be_const_str_onsubmit_X3D_X27return_X20confirm_X28_X22This_X20will_X20change_X20the_X20current_X20configuration_X20and_X20cause_X20a_X20restart_X2E_X22_X29_X3B_X27_X3E); -be_define_const_str(_X29, ")", 739023492u, 0, 1, &be_const_str_SERIAL_8E2); -be_define_const_str(_X2A, "*", 789356349u, 0, 1, &be_const_str_file_X20extension_X20is_X20not_X20_X27_X2Ebe_X27_X20or_X20_X27_X2Ebec_X27); -be_define_const_str(_X2B, "+", 772578730u, 0, 1, &be_const_str_nan); -be_define_const_str(_X2C, ",", 688690635u, 0, 1, &be_const_str_SERIAL_8E1); -be_define_const_str(_X2C_X22AXP192_X22_X3A_X7B_X22VBusVoltage_X22_X3A_X25_X2E3f_X2C_X22VBusCurrent_X22_X3A_X25_X2E1f_X2C_X22BattVoltage_X22_X3A_X25_X2E3f_X2C_X22BattCurrent_X22_X3A_X25_X2E1f_X2C_X22Temperature_X22_X3A_X25_X2E1f_X7D, ",\"AXP192\":{\"VBusVoltage\":%.3f,\"VBusCurrent\":%.1f,\"BattVoltage\":%.3f,\"BattCurrent\":%.1f,\"Temperature\":%.1f}", 2598755376u, 0, 106, NULL); -be_define_const_str(_X2D, "-", 671913016u, 0, 1, &be_const_str_get_option); -be_define_const_str(_X2D_X2A, "-*", 499980374u, 0, 2, NULL); -be_define_const_str(_X2D_X2D_X3A_X2D_X2D, "--:--", 1370615441u, 0, 5, NULL); -be_define_const_str(_X2E, ".", 722245873u, 0, 1, &be_const_str_can_show); -be_define_const_str(_X2E_X2E, "..", 2748622605u, 0, 2, &be_const_str_set_channels); -be_define_const_str(_X2Eautoconf, ".autoconf", 2524679088u, 0, 9, &be_const_str_Partition_otadata); -be_define_const_str(_X2Ebe, ".be", 1325797348u, 0, 3, &be_const_str_getfloat); -be_define_const_str(_X2Ebec, ".bec", 3985273221u, 0, 4, &be_const_str_SERIAL_6E2); -be_define_const_str(_X2Elen, ".len", 850842136u, 0, 4, &be_const_str_cb_do_nothing); -be_define_const_str(_X2Ep, ".p", 1171526419u, 0, 2, NULL); -be_define_const_str(_X2Ep1, ".p1", 249175686u, 0, 3, NULL); -be_define_const_str(_X2Ep2, ".p2", 232398067u, 0, 3, NULL); -be_define_const_str(_X2Esize, ".size", 1965188224u, 0, 5, &be_const_str_lights); -be_define_const_str(_X2Etapp, ".tapp", 1363391594u, 0, 5, &be_const_str__ptr); -be_define_const_str(_X2Ew, ".w", 1255414514u, 0, 2, &be_const_str_phy); -be_define_const_str(_X2F, "/", 705468254u, 0, 1, &be_const_str_MI32); -be_define_const_str(_X2F_X2Eautoconf, "/.autoconf", 2212074393u, 0, 10, &be_const_str_fromptr); -be_define_const_str(_X2F_X3Frst_X3D, "/?rst=", 580074707u, 0, 6, &be_const_str_lv_event); -be_define_const_str(_X2Fac, "/ac", 3904651978u, 0, 3, &be_const_str_CFG_X3A_X20could_X20not_X20run_X20_X25s_X20_X28_X25s_X20_X2D_X20_X25s_X29); -be_define_const_str(_X2Flights_X2F, "/lights/", 2370247908u, 0, 8, &be_const_str_json_fdump); -be_define_const_str(_X2Fstate_X2F, "/state/", 4226179876u, 0, 7, &be_const_str_argument_X20must_X20be_X20a_X20function); -be_define_const_str(00, "00", 569209421u, 0, 2, &be_const_str__X3D_X3D); -be_define_const_str(_X3A, ":", 1057798253u, 0, 1, &be_const_str_every_250ms); -be_define_const_str(_X3C, "<", 957132539u, 0, 1, &be_const_str_font_embedded); -be_define_const_str(_X3C_X2Fform_X3E_X3C_X2Fp_X3E, "

", 3546571739u, 0, 11, &be_const_str_load_templates); -be_define_const_str(_X3C_X2Fselect_X3E_X3Cp_X3E_X3C_X2Fp_X3E, "

", 1863865923u, 0, 16, &be_const_str_check_not_method); -be_define_const_str(_X3C_X3D, "<=", 2499223986u, 0, 2, &be_const_str_set_pwm); -be_define_const_str(_X3Cbutton_X20name_X3D_X27reapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3ERe_X2Dapply_X20current_X20configuration_X3C_X2Fbutton_X3E, "", 3147934216u, 0, 82, &be_const_str_SERIAL_6O1); -be_define_const_str(_X3Cbutton_X20name_X3D_X27zipapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3EApply_X20configuration_X3C_X2Fbutton_X3E, "", 1205771629u, 0, 72, &be_const_str__persist_X2Ejson); -be_define_const_str(_X3Cfieldset_X3E_X3Cstyle_X3E_X2Ebdis_X7Bbackground_X3A_X23888_X3B_X7D_X2Ebdis_X3Ahover_X7Bbackground_X3A_X23888_X3B_X7D_X3C_X2Fstyle_X3E, "
", 842307168u, 0, 77, &be_const_str_eth); -be_define_const_str(_X3Cinstance_X3A_X20_X25s_X28_X25s_X2C_X20_X25s_X2C_X20_X25s_X29, "", 2342198361u, 0, 61, &be_const_str_members); -be_define_const_str(_X3Cinstance_X3A_X20Partition_otadata_X28ota_active_X3A_X25d_X2C_X20ota_seq_X3D_X5B_X25d_X2C_X25d_X5D_X2C_X20ota_max_X3D_X25d_X29_X3E, "", 666780908u, 0, 73, &be_const_str_connect); -be_define_const_str(_X3Clabel_X3EChoose_X20a_X20device_X20configuration_X3A_X3C_X2Flabel_X3E_X3Cbr_X3E, "
", 1336654704u, 0, 49, &be_const_str_SERIAL_7E2); -be_define_const_str(_X3Clambda_X3E, "", 607256038u, 0, 8, &be_const_str__available); -be_define_const_str(_X3Clegend_X3E_X3Cb_X20title_X3D_X27Autoconfiguration_X27_X3E_X26nbsp_X3BCurrent_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E, " Current auto-configuration", 4212500780u, 0, 82, &be_const_str_del); -be_define_const_str(_X3Clegend_X3E_X3Cb_X20title_X3D_X27New_X20autoconf_X27_X3E_X26nbsp_X3BSelect_X20new_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E, " Select new auto-configuration", 1926223891u, 0, 80, &be_const_str_autorun); -be_define_const_str(_X3Coption_X20value_X3D_X27_X25s_X27_X3E_X25s_X3C_X2Foption_X3E, "", 510303524u, 0, 30, &be_const_str_event_send); -be_define_const_str(_X3Coption_X20value_X3D_X27reset_X27_X3E_X26lt_X3BRemove_X20autoconf_X26gt_X3B_X3C_X2Foption_X3E, "", 3994619755u, 0, 54, &be_const_str_AudioFileSourceFS); -be_define_const_str(_X3Cp_X20style_X3D_X27width_X3A340px_X3B_X27_X3E_X3Cb_X3EException_X3A_X3C_X2Fb_X3E_X3Cbr_X3E_X27_X25s_X27_X3Cbr_X3E_X25s_X3C_X2Fp_X3E, "

Exception:
'%s'
%s

", 4252565082u, 0, 59, NULL); -be_define_const_str(_X3Cp_X3E_X3C_X2Fp_X3E_X3C_X2Ffieldset_X3E_X3Cp_X3E_X3C_X2Fp_X3E, "

", 2052843416u, 0, 25, NULL); -be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dac_X20action_X3D_X27ac_X27_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20method_X3D_X27get_X27_X3E_X3Cbutton_X3EAuto_X2Dconfiguration_X3C_X2Fbutton_X3E_X3C_X2Fform_X3E_X3C_X2Fp_X3E, "

", 2058443583u, 0, 110, &be_const_str_classof); -be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dreapply_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20action_X3D_X27_X2Fac_X27_X20method_X3D_X27post_X27_X20, "

 (This feature requires an internet connection)

", 2719266486u, 0, 74, &be_const_str_json); -be_define_const_str(_X3Cp_X3ECurrent_X20configuration_X3A_X20_X3C_X2Fp_X3E_X3Cp_X3E_X3Cb_X3E_X25s_X3C_X2Fb_X3E_X3C_X2Fp_X3E, "

Current configuration:

%s

", 4115655761u, 0, 46, &be_const_str_animate); -be_define_const_str(_X3Cselect_X20name_X3D_X27zip_X27_X3E, "

", 1863865923u, 0, 16, NULL); +be_define_const_str(_X3C_X3D, "<=", 2499223986u, 0, 2, &be_const_str_SERIAL_5E2); +be_define_const_str(_X3Cbutton_X20name_X3D_X27reapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3ERe_X2Dapply_X20current_X20configuration_X3C_X2Fbutton_X3E, "", 3147934216u, 0, 82, &be_const_str_couldn_X27t_X20not_X20initialize_X20noepixelbus); +be_define_const_str(_X3Cbutton_X20name_X3D_X27zipapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3EApply_X20configuration_X3C_X2Fbutton_X3E, "", 1205771629u, 0, 72, &be_const_str_json_fdump_list); +be_define_const_str(_X3Cfieldset_X3E_X3Cstyle_X3E_X2Ebdis_X7Bbackground_X3A_X23888_X3B_X7D_X2Ebdis_X3Ahover_X7Bbackground_X3A_X23888_X3B_X7D_X3C_X2Fstyle_X3E, "
", 842307168u, 0, 77, &be_const_str_save_before_restart); +be_define_const_str(_X3Cinstance_X3A_X20_X25s_X28_X25s_X2C_X20_X25s_X2C_X20_X25s_X29, "", 2342198361u, 0, 61, &be_const_str_input); +be_define_const_str(_X3Cinstance_X3A_X20Partition_otadata_X28ota_active_X3A_X25d_X2C_X20ota_seq_X3D_X5B_X25d_X2C_X25d_X5D_X2C_X20ota_max_X3D_X25d_X29_X3E, "", 666780908u, 0, 73, &be_const_str_fast_loop); +be_define_const_str(_X3Clabel_X3EChoose_X20a_X20device_X20configuration_X3A_X3C_X2Flabel_X3E_X3Cbr_X3E, "
", 1336654704u, 0, 49, &be_const_str_adv_watch); +be_define_const_str(_X3Clambda_X3E, "", 607256038u, 0, 8, &be_const_str_SERIAL_5O2); +be_define_const_str(_X3Clegend_X3E_X3Cb_X20title_X3D_X27Autoconfiguration_X27_X3E_X26nbsp_X3BCurrent_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E, " Current auto-configuration", 4212500780u, 0, 82, &be_const_str_codedump); +be_define_const_str(_X3Clegend_X3E_X3Cb_X20title_X3D_X27New_X20autoconf_X27_X3E_X26nbsp_X3BSelect_X20new_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E, " Select new auto-configuration", 1926223891u, 0, 80, &be_const_str_point); +be_define_const_str(_X3Coption_X20value_X3D_X27_X25s_X27_X3E_X25s_X3C_X2Foption_X3E, "", 510303524u, 0, 30, &be_const_str_nvskeys); +be_define_const_str(_X3Coption_X20value_X3D_X27reset_X27_X3E_X26lt_X3BRemove_X20autoconf_X26gt_X3B_X3C_X2Foption_X3E, "", 3994619755u, 0, 54, &be_const_str_None); +be_define_const_str(_X3Cp_X20style_X3D_X27width_X3A340px_X3B_X27_X3E_X3Cb_X3EException_X3A_X3C_X2Fb_X3E_X3Cbr_X3E_X27_X25s_X27_X3Cbr_X3E_X25s_X3C_X2Fp_X3E, "

Exception:
'%s'
%s

", 4252565082u, 0, 59, &be_const_str_type_error); +be_define_const_str(_X3Cp_X3E_X3C_X2Fp_X3E_X3C_X2Ffieldset_X3E_X3Cp_X3E_X3C_X2Fp_X3E, "

", 2052843416u, 0, 25, &be_const_str_continue); +be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dac_X20action_X3D_X27ac_X27_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20method_X3D_X27get_X27_X3E_X3Cbutton_X3EAuto_X2Dconfiguration_X3C_X2Fbutton_X3E_X3C_X2Fform_X3E_X3C_X2Fp_X3E, "

", 2058443583u, 0, 110, &be_const_str_get_power); +be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dreapply_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20action_X3D_X27_X2Fac_X27_X20method_X3D_X27post_X27_X20, "

 (This feature requires an internet connection)

", 2719266486u, 0, 74, &be_const_str_CFG_X3A_X20loaded_X20_X20); +be_define_const_str(_X3Cp_X3ECurrent_X20configuration_X3A_X20_X3C_X2Fp_X3E_X3Cp_X3E_X3Cb_X3E_X25s_X3C_X2Fb_X3E_X3C_X2Fp_X3E, "

Current configuration:

%s

", 4115655761u, 0, 46, &be_const_str_clock); +be_define_const_str(_X3Cselect_X20name_X3D_X27zip_X27_X3E, "