Merge pull request #15481 from s-hadinger/berry_crc32

Berry use crc32 code from esp rom
This commit is contained in:
s-hadinger 2022-04-29 10:43:10 +02:00 committed by GitHub
commit 77d94c429f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1494 additions and 1773 deletions

View File

@ -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 */

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
#include "be_constobj.h"
static be_define_const_map_slots(m_libcrc_map) {
{ be_const_key(crc32, 1), be_const_ctype_func(c_crc32) },
{ be_const_key(crc8, 2), be_const_ctype_func(c_crc8) },
{ be_const_key(crc16, -1), be_const_ctype_func(c_crc16) },
};
static be_define_const_map(
m_libcrc_map,
3
);
static be_define_const_module(
m_libcrc,
"crc"
);
BE_EXPORT_VARIABLE be_define_const_native_module(crc);

View File

@ -0,0 +1,88 @@
/********************************************************************
* Berry module `webserver`
*
* To use: `import webserver`
*
* Allows to respond to HTTP request
*******************************************************************/
#include "be_constobj.h"
#include "be_mapping.h"
#include "rom/crc.h"
uint32_t c_crc32(uint32_t crc, const uint8_t* buf, size_t size) {
return crc32_le(crc, buf, size);
}
BE_FUNC_CTYPE_DECLARE(c_crc32, "i", "i(bytes)~")
uint32_t c_crc16(uint32_t crc, const uint8_t* buf, size_t size) {
return crc16_le(crc, buf, size);
}
BE_FUNC_CTYPE_DECLARE(c_crc16, "i", "i(bytes)~")
uint32_t c_crc8(uint32_t crc, const uint8_t* buf, size_t size) {
return crc8_le(crc, buf, size);
}
BE_FUNC_CTYPE_DECLARE(c_crc8, "i", "i(bytes)~")
// const uint32_t crc32_tab[] = {
// 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
// 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
// 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
// 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
// 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
// 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
// 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
// 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
// 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
// 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
// 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
// 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
// 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
// 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
// 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
// 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
// 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
// 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
// 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
// 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
// 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
// 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
// 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
// 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
// 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
// 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
// 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
// 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
// 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
// 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
// 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
// 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
// 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
// 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
// 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
// 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
// 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
// 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
// 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
// 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
// 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
// 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
// 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
// };
// uint32_t c_crc32(uint32_t crc, const uint8_t *p, size_t size) {
// crc ^= ~0U;
// while (size--)
// crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8);
// return crc ^ ~0U;
// }
/* @const_object_info_begin
module crc (scope: global) {
crc32, ctype_func(c_crc32)
crc16, ctype_func(c_crc16)
crc8, ctype_func(c_crc8)
}
@const_object_info_end */
#include "be_fixed_crc.h"

View File

@ -8,73 +8,39 @@
#include "be_constobj.h"
/********************************************************************
** Solidified function: init
** Solidified function: tostring
********************************************************************/
be_local_closure(Partition_otadata_init, /* name */
be_local_closure(Partition_otadata_tostring, /* name */
be_nested_proto(
5, /* nstack */
3, /* argc */
9, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 6]) { /* constants */
/* K0 */ be_nested_str(maxota),
/* K1 */ be_const_int(1),
/* K2 */ be_nested_str(offset),
( &(const bvalue[ 7]) { /* constants */
/* K0 */ be_nested_str(string),
/* K1 */ be_nested_str(format),
/* K2 */ be_nested_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),
/* K3 */ be_nested_str(active_otadata),
/* K4 */ be_const_int(0),
/* K5 */ be_nested_str(load),
/* K4 */ be_nested_str(seq0),
/* K5 */ be_nested_str(seq1),
/* K6 */ be_nested_str(maxota),
}),
&be_const_str_init,
&be_const_str_tostring,
&be_const_str_solidified,
( &(const binstruction[17]) { /* code */
0x90020001, // 0000 SETMBR R0 K0 R1
0x880C0100, // 0001 GETMBR R3 R0 K0
0x4C100000, // 0002 LDNIL R4
0x1C0C0604, // 0003 EQ R3 R3 R4
0x780E0000, // 0004 JMPF R3 #0006
0x90020101, // 0005 SETMBR R0 K0 K1
0x90020402, // 0006 SETMBR R0 K2 R2
0x880C0102, // 0007 GETMBR R3 R0 K2
0x4C100000, // 0008 LDNIL R4
0x1C0C0604, // 0009 EQ R3 R3 R4
0x780E0001, // 000A JMPF R3 #000D
0x540EDFFF, // 000B LDINT R3 57344
0x90020403, // 000C SETMBR R0 K2 R3
0x90020704, // 000D SETMBR R0 K3 K4
0x8C0C0105, // 000E GETMET R3 R0 K5
0x7C0C0200, // 000F CALL R3 1
0x80000000, // 0010 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: set_ota_max
********************************************************************/
be_local_closure(Partition_otadata_set_ota_max, /* name */
be_nested_proto(
2, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str(maxota),
}),
&be_const_str_set_ota_max,
&be_const_str_solidified,
( &(const binstruction[ 2]) { /* code */
0x90020001, // 0000 SETMBR R0 K0 R1
0x80000000, // 0001 RET 0
( &(const binstruction[ 9]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0x8C080301, // 0001 GETMET R2 R1 K1
0x58100002, // 0002 LDCONST R4 K2
0x88140103, // 0003 GETMBR R5 R0 K3
0x88180104, // 0004 GETMBR R6 R0 K4
0x881C0105, // 0005 GETMBR R7 R0 K5
0x88200106, // 0006 GETMBR R8 R0 K6
0x7C080C00, // 0007 CALL R2 6
0x80040400, // 0008 RET 1 R2
})
)
);
@ -159,149 +125,6 @@ be_local_closure(Partition_otadata_load, /* name */
/*******************************************************************/
/********************************************************************
** Solidified function: crc32_update
********************************************************************/
be_local_closure(Partition_otadata_crc32_update, /* name */
be_nested_proto(
8, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 7]) { /* constants */
/* K0 */ be_nested_str(partition),
/* K1 */ be_nested_str(Partition_otadata),
/* K2 */ be_nested_str(crc32_table),
/* K3 */ be_const_int(0),
/* K4 */ be_const_int(1),
/* K5 */ be_const_int(16777215),
/* K6 */ be_nested_str(stop_iteration),
}),
&be_const_str_crc32_update,
&be_const_str_solidified,
( &(const binstruction[32]) { /* code */
0x5409FFFE, // 0000 LDINT R2 -1
0x34040202, // 0001 XOR R1 R1 R2
0xB80A0000, // 0002 GETNGBL R2 K0
0x88080501, // 0003 GETMBR R2 R2 K1
0x88080502, // 0004 GETMBR R2 R2 K2
0x600C0010, // 0005 GETGBL R3 G16
0x6010000C, // 0006 GETGBL R4 G12
0x5C140000, // 0007 MOVE R5 R0
0x7C100200, // 0008 CALL R4 1
0x04100904, // 0009 SUB R4 R4 K4
0x40120604, // 000A CONNECT R4 K3 R4
0x7C0C0200, // 000B CALL R3 1
0xA802000C, // 000C EXBLK 0 #001A
0x5C100600, // 000D MOVE R4 R3
0x7C100000, // 000E CALL R4 0
0x54160007, // 000F LDINT R5 8
0x3C140205, // 0010 SHR R5 R1 R5
0x2C140B05, // 0011 AND R5 R5 K5
0x541A00FE, // 0012 LDINT R6 255
0x2C180206, // 0013 AND R6 R1 R6
0x941C0004, // 0014 GETIDX R7 R0 R4
0x34180C07, // 0015 XOR R6 R6 R7
0x94180406, // 0016 GETIDX R6 R2 R6
0x34140A06, // 0017 XOR R5 R5 R6
0x5C040A00, // 0018 MOVE R1 R5
0x7001FFF2, // 0019 JMP #000D
0x580C0006, // 001A LDCONST R3 K6
0xAC0C0200, // 001B CATCH R3 1 0
0xB0080000, // 001C RAISE 2 R0 R0
0x540DFFFE, // 001D LDINT R3 -1
0x340C0203, // 001E XOR R3 R1 R3
0x80040600, // 001F RET 1 R3
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: crc32_ota_seq
********************************************************************/
be_local_closure(Partition_otadata_crc32_ota_seq, /* name */
be_nested_proto(
7, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 4]) { /* constants */
/* K0 */ be_nested_str(partition),
/* K1 */ be_nested_str(Partition_otadata),
/* K2 */ be_nested_str(crc32_update),
/* K3 */ be_nested_str(add),
}),
&be_const_str_crc32_ota_seq,
&be_const_str_solidified,
( &(const binstruction[12]) { /* code */
0xB8060000, // 0000 GETNGBL R1 K0
0x88040301, // 0001 GETMBR R1 R1 K1
0x8C040302, // 0002 GETMET R1 R1 K2
0x600C0015, // 0003 GETGBL R3 G21
0x7C0C0000, // 0004 CALL R3 0
0x8C0C0703, // 0005 GETMET R3 R3 K3
0x5C140000, // 0006 MOVE R5 R0
0x541A0003, // 0007 LDINT R6 4
0x7C0C0600, // 0008 CALL R3 3
0x5411FFFE, // 0009 LDINT R4 -1
0x7C040600, // 000A CALL R1 3
0x80040200, // 000B RET 1 R1
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: tostring
********************************************************************/
be_local_closure(Partition_otadata_tostring, /* name */
be_nested_proto(
9, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 7]) { /* constants */
/* K0 */ be_nested_str(string),
/* K1 */ be_nested_str(format),
/* K2 */ be_nested_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),
/* K3 */ be_nested_str(active_otadata),
/* K4 */ be_nested_str(seq0),
/* K5 */ be_nested_str(seq1),
/* K6 */ be_nested_str(maxota),
}),
&be_const_str_tostring,
&be_const_str_solidified,
( &(const binstruction[ 9]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0x8C080301, // 0001 GETMET R2 R1 K1
0x58100002, // 0002 LDCONST R4 K2
0x88140103, // 0003 GETMBR R5 R0 K3
0x88180104, // 0004 GETMBR R6 R0 K4
0x881C0105, // 0005 GETMBR R7 R0 K5
0x88200106, // 0006 GETMBR R8 R0 K6
0x7C080C00, // 0007 CALL R2 6
0x80040400, // 0008 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: save
********************************************************************/
@ -390,6 +213,53 @@ be_local_closure(Partition_otadata_save, /* name */
/*******************************************************************/
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Partition_otadata_init, /* name */
be_nested_proto(
5, /* nstack */
3, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 6]) { /* constants */
/* K0 */ be_nested_str(maxota),
/* K1 */ be_const_int(1),
/* K2 */ be_nested_str(offset),
/* K3 */ be_nested_str(active_otadata),
/* K4 */ be_const_int(0),
/* K5 */ be_nested_str(load),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[17]) { /* code */
0x90020001, // 0000 SETMBR R0 K0 R1
0x880C0100, // 0001 GETMBR R3 R0 K0
0x4C100000, // 0002 LDNIL R4
0x1C0C0604, // 0003 EQ R3 R3 R4
0x780E0000, // 0004 JMPF R3 #0006
0x90020101, // 0005 SETMBR R0 K0 K1
0x90020402, // 0006 SETMBR R0 K2 R2
0x880C0102, // 0007 GETMBR R3 R0 K2
0x4C100000, // 0008 LDNIL R4
0x1C0C0604, // 0009 EQ R3 R3 R4
0x780E0001, // 000A JMPF R3 #000D
0x540EDFFF, // 000B LDINT R3 57344
0x90020403, // 000C SETMBR R0 K2 R3
0x90020704, // 000D SETMBR R0 K3 K4
0x8C0C0105, // 000E GETMET R3 R0 K5
0x7C0C0200, // 000F CALL R3 1
0x80000000, // 0010 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: set_active
********************************************************************/
@ -461,6 +331,71 @@ be_local_closure(Partition_otadata_set_active, /* name */
/*******************************************************************/
/********************************************************************
** Solidified function: set_ota_max
********************************************************************/
be_local_closure(Partition_otadata_set_ota_max, /* name */
be_nested_proto(
2, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str(maxota),
}),
&be_const_str_set_ota_max,
&be_const_str_solidified,
( &(const binstruction[ 2]) { /* code */
0x90020001, // 0000 SETMBR R0 K0 R1
0x80000000, // 0001 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: crc32_ota_seq
********************************************************************/
be_local_closure(Partition_otadata_crc32_ota_seq, /* name */
be_nested_proto(
9, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 3]) { /* constants */
/* K0 */ be_nested_str(crc),
/* K1 */ be_nested_str(crc32),
/* K2 */ be_nested_str(add),
}),
&be_const_str_crc32_ota_seq,
&be_const_str_solidified,
( &(const binstruction[11]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0x8C080301, // 0001 GETMET R2 R1 K1
0x5411FFFE, // 0002 LDINT R4 -1
0x60140015, // 0003 GETGBL R5 G21
0x7C140000, // 0004 CALL R5 0
0x8C140B02, // 0005 GETMET R5 R5 K2
0x5C1C0000, // 0006 MOVE R7 R0
0x54220003, // 0007 LDINT R8 4
0x7C140600, // 0008 CALL R5 3
0x7C080600, // 0009 CALL R2 3
0x80040400, // 000A RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: _validate
********************************************************************/
@ -527,282 +462,21 @@ be_local_closure(Partition_otadata__validate, /* name */
be_local_class(Partition_otadata,
5,
NULL,
be_nested_map(15,
be_nested_map(13,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(init, 5), be_const_closure(Partition_otadata_init_closure) },
{ be_const_key(seq0, 14), be_const_var(3) },
{ be_const_key(set_ota_max, -1), be_const_closure(Partition_otadata_set_ota_max_closure) },
{ be_const_key(offset, -1), be_const_var(1) },
{ be_const_key(load, -1), be_const_closure(Partition_otadata_load_closure) },
{ be_const_key(seq1, -1), be_const_var(4) },
{ be_const_key(active_otadata, -1), be_const_var(2) },
{ be_const_key(crc32_ota_seq, -1), be_const_static_closure(Partition_otadata_crc32_ota_seq_closure) },
{ be_const_key(tostring, -1), be_const_closure(Partition_otadata_tostring_closure) },
{ be_const_key(set_active, 11), be_const_closure(Partition_otadata_set_active_closure) },
{ be_const_key(maxota, 8), be_const_var(0) },
{ be_const_key(save, -1), be_const_closure(Partition_otadata_save_closure) },
{ be_const_key(crc32_update, 9), be_const_static_closure(Partition_otadata_crc32_update_closure) },
{ be_const_key(tostring, 1), be_const_closure(Partition_otadata_tostring_closure) },
{ be_const_key(_validate, -1), be_const_closure(Partition_otadata__validate_closure) },
{ be_const_key(crc32_table, -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, {
be_const_list( * be_nested_list(256,
( (struct bvalue*) &(const bvalue[]) {
be_const_int(0),
be_const_int(1996959894),
be_const_int(-301047508),
be_const_int(-1727442502),
be_const_int(124634137),
be_const_int(1886057615),
be_const_int(-379345611),
be_const_int(-1637575261),
be_const_int(249268274),
be_const_int(2044508324),
be_const_int(-522852066),
be_const_int(-1747789432),
be_const_int(162941995),
be_const_int(2125561021),
be_const_int(-407360249),
be_const_int(-1866523247),
be_const_int(498536548),
be_const_int(1789927666),
be_const_int(-205950648),
be_const_int(-2067906082),
be_const_int(450548861),
be_const_int(1843258603),
be_const_int(-187386543),
be_const_int(-2083289657),
be_const_int(325883990),
be_const_int(1684777152),
be_const_int(-43845254),
be_const_int(-1973040660),
be_const_int(335633487),
be_const_int(1661365465),
be_const_int(-99664541),
be_const_int(-1928851979),
be_const_int(997073096),
be_const_int(1281953886),
be_const_int(-715111964),
be_const_int(-1570279054),
be_const_int(1006888145),
be_const_int(1258607687),
be_const_int(-770865667),
be_const_int(-1526024853),
be_const_int(901097722),
be_const_int(1119000684),
be_const_int(-608450090),
be_const_int(-1396901568),
be_const_int(853044451),
be_const_int(1172266101),
be_const_int(-589951537),
be_const_int(-1412350631),
be_const_int(651767980),
be_const_int(1373503546),
be_const_int(-925412992),
be_const_int(-1076862698),
be_const_int(565507253),
be_const_int(1454621731),
be_const_int(-809855591),
be_const_int(-1195530993),
be_const_int(671266974),
be_const_int(1594198024),
be_const_int(-972236366),
be_const_int(-1324619484),
be_const_int(795835527),
be_const_int(1483230225),
be_const_int(-1050600021),
be_const_int(-1234817731),
be_const_int(1994146192),
be_const_int(31158534),
be_const_int(-1731059524),
be_const_int(-271249366),
be_const_int(1907459465),
be_const_int(112637215),
be_const_int(-1614814043),
be_const_int(-390540237),
be_const_int(2013776290),
be_const_int(251722036),
be_const_int(-1777751922),
be_const_int(-519137256),
be_const_int(2137656763),
be_const_int(141376813),
be_const_int(-1855689577),
be_const_int(-429695999),
be_const_int(1802195444),
be_const_int(476864866),
be_const_int(-2056965928),
be_const_int(-228458418),
be_const_int(1812370925),
be_const_int(453092731),
be_const_int(-2113342271),
be_const_int(-183516073),
be_const_int(1706088902),
be_const_int(314042704),
be_const_int(-1950435094),
be_const_int(-54949764),
be_const_int(1658658271),
be_const_int(366619977),
be_const_int(-1932296973),
be_const_int(-69972891),
be_const_int(1303535960),
be_const_int(984961486),
be_const_int(-1547960204),
be_const_int(-725929758),
be_const_int(1256170817),
be_const_int(1037604311),
be_const_int(-1529756563),
be_const_int(-740887301),
be_const_int(1131014506),
be_const_int(879679996),
be_const_int(-1385723834),
be_const_int(-631195440),
be_const_int(1141124467),
be_const_int(855842277),
be_const_int(-1442165665),
be_const_int(-586318647),
be_const_int(1342533948),
be_const_int(654459306),
be_const_int(-1106571248),
be_const_int(-921952122),
be_const_int(1466479909),
be_const_int(544179635),
be_const_int(-1184443383),
be_const_int(-832445281),
be_const_int(1591671054),
be_const_int(702138776),
be_const_int(-1328506846),
be_const_int(-942167884),
be_const_int(1504918807),
be_const_int(783551873),
be_const_int(-1212326853),
be_const_int(-1061524307),
be_const_int(-306674912),
be_const_int(-1698712650),
be_const_int(62317068),
be_const_int(1957810842),
be_const_int(-355121351),
be_const_int(-1647151185),
be_const_int(81470997),
be_const_int(1943803523),
be_const_int(-480048366),
be_const_int(-1805370492),
be_const_int(225274430),
be_const_int(2053790376),
be_const_int(-468791541),
be_const_int(-1828061283),
be_const_int(167816743),
be_const_int(2097651377),
be_const_int(-267414716),
be_const_int(-2029476910),
be_const_int(503444072),
be_const_int(1762050814),
be_const_int(-144550051),
be_const_int(-2140837941),
be_const_int(426522225),
be_const_int(1852507879),
be_const_int(-19653770),
be_const_int(-1982649376),
be_const_int(282753626),
be_const_int(1742555852),
be_const_int(-105259153),
be_const_int(-1900089351),
be_const_int(397917763),
be_const_int(1622183637),
be_const_int(-690576408),
be_const_int(-1580100738),
be_const_int(953729732),
be_const_int(1340076626),
be_const_int(-776247311),
be_const_int(-1497606297),
be_const_int(1068828381),
be_const_int(1219638859),
be_const_int(-670225446),
be_const_int(-1358292148),
be_const_int(906185462),
be_const_int(1090812512),
be_const_int(-547295293),
be_const_int(-1469587627),
be_const_int(829329135),
be_const_int(1181335161),
be_const_int(-882789492),
be_const_int(-1134132454),
be_const_int(628085408),
be_const_int(1382605366),
be_const_int(-871598187),
be_const_int(-1156888829),
be_const_int(570562233),
be_const_int(1426400815),
be_const_int(-977650754),
be_const_int(-1296233688),
be_const_int(733239954),
be_const_int(1555261956),
be_const_int(-1026031705),
be_const_int(-1244606671),
be_const_int(752459403),
be_const_int(1541320221),
be_const_int(-1687895376),
be_const_int(-328994266),
be_const_int(1969922972),
be_const_int(40735498),
be_const_int(-1677130071),
be_const_int(-351390145),
be_const_int(1913087877),
be_const_int(83908371),
be_const_int(-1782625662),
be_const_int(-491226604),
be_const_int(2075208622),
be_const_int(213261112),
be_const_int(-1831694693),
be_const_int(-438977011),
be_const_int(2094854071),
be_const_int(198958881),
be_const_int(-2032938284),
be_const_int(-237706686),
be_const_int(1759359992),
be_const_int(534414190),
be_const_int(-2118248755),
be_const_int(-155638181),
be_const_int(1873836001),
be_const_int(414664567),
be_const_int(-2012718362),
be_const_int(-15766928),
be_const_int(1711684554),
be_const_int(285281116),
be_const_int(-1889165569),
be_const_int(-127750551),
be_const_int(1634467795),
be_const_int(376229701),
be_const_int(-1609899400),
be_const_int(-686959890),
be_const_int(1308918612),
be_const_int(956543938),
be_const_int(-1486412191),
be_const_int(-799009033),
be_const_int(1231636301),
be_const_int(1047427035),
be_const_int(-1362007478),
be_const_int(-640263460),
be_const_int(1088359270),
be_const_int(936918000),
be_const_int(-1447252397),
be_const_int(-558129467),
be_const_int(1202900863),
be_const_int(817233897),
be_const_int(-1111625188),
be_const_int(-893730166),
be_const_int(1404277552),
be_const_int(615818150),
be_const_int(-1160759803),
be_const_int(-841546093),
be_const_int(1423857449),
be_const_int(601450431),
be_const_int(-1285129682),
be_const_int(-1000256840),
be_const_int(1567103746),
be_const_int(711928724),
be_const_int(-1274298825),
be_const_int(-1022587231),
be_const_int(1510334235),
be_const_int(755167117),
})) ) } )) },
{ be_const_key(crc32_ota_seq, 12), be_const_static_closure(Partition_otadata_crc32_ota_seq_closure) },
{ be_const_key(active_otadata, -1), be_const_var(2) },
{ be_const_key(save, 8), be_const_closure(Partition_otadata_save_closure) },
{ be_const_key(seq1, -1), be_const_var(4) },
{ be_const_key(init, 7), be_const_closure(Partition_otadata_init_closure) },
{ be_const_key(set_ota_max, -1), be_const_closure(Partition_otadata_set_ota_max_closure) },
{ be_const_key(seq0, 10), be_const_var(3) },
{ be_const_key(set_active, -1), be_const_closure(Partition_otadata_set_active_closure) },
{ be_const_key(offset, -1), be_const_var(1) },
{ be_const_key(load, 2), be_const_closure(Partition_otadata_load_closure) },
{ be_const_key(maxota, -1), be_const_var(0) },
})),
(bstring*) &be_const_str_Partition_otadata
);

View File

@ -224,77 +224,10 @@ class Partition_otadata
var seq0 #- ota_seq of first block -#
var seq1 #- ota_seq of second block -#
# the following is not included in the solidified version
#-------------------------------------------------------------
- Simple CRC32 imple
-
- adapted from Python https://rosettacode.org/wiki/CRC-32#Python
-------------------------------------------------------------#
# static def crc32_create_table()
# var a = []
# for i:0..255
# var k = i
# for j:0..7
# if k & 1
# k = (k >> 1) & 0x7FFFFFFF
# k ^= 0xedb88320
# else
# k = (k >> 1) & 0x7FFFFFFF
# end
# end
# a.push(k)
# end
# return a
# end
# static crc32_table = Partition_otadata.crc32_create_table()
# comptued in advanced
static crc32_table = [
0, 1996959894, -301047508, -1727442502, 124634137, 1886057615, -379345611, -1637575261,
249268274, 2044508324, -522852066, -1747789432, 162941995, 2125561021, -407360249, -1866523247,
498536548, 1789927666, -205950648, -2067906082, 450548861, 1843258603, -187386543, -2083289657,
325883990, 1684777152, -43845254, -1973040660, 335633487, 1661365465, -99664541, -1928851979,
997073096, 1281953886, -715111964, -1570279054, 1006888145, 1258607687, -770865667, -1526024853,
901097722, 1119000684, -608450090, -1396901568, 853044451, 1172266101, -589951537, -1412350631,
651767980, 1373503546, -925412992, -1076862698, 565507253, 1454621731, -809855591, -1195530993,
671266974, 1594198024, -972236366, -1324619484, 795835527, 1483230225, -1050600021, -1234817731,
1994146192, 31158534, -1731059524, -271249366, 1907459465, 112637215, -1614814043, -390540237,
2013776290, 251722036, -1777751922, -519137256, 2137656763, 141376813, -1855689577, -429695999,
1802195444, 476864866, -2056965928, -228458418, 1812370925, 453092731, -2113342271, -183516073,
1706088902, 314042704, -1950435094, -54949764, 1658658271, 366619977, -1932296973, -69972891,
1303535960, 984961486, -1547960204, -725929758, 1256170817, 1037604311, -1529756563, -740887301,
1131014506, 879679996, -1385723834, -631195440, 1141124467, 855842277, -1442165665, -586318647,
1342533948, 654459306, -1106571248, -921952122, 1466479909, 544179635, -1184443383, -832445281,
1591671054, 702138776, -1328506846, -942167884, 1504918807, 783551873, -1212326853, -1061524307,
-306674912, -1698712650, 62317068, 1957810842, -355121351, -1647151185, 81470997, 1943803523,
-480048366, -1805370492, 225274430, 2053790376, -468791541, -1828061283, 167816743, 2097651377,
-267414716, -2029476910, 503444072, 1762050814, -144550051, -2140837941, 426522225, 1852507879,
-19653770, -1982649376, 282753626, 1742555852, -105259153, -1900089351, 397917763, 1622183637,
-690576408, -1580100738, 953729732, 1340076626, -776247311, -1497606297, 1068828381, 1219638859,
-670225446, -1358292148, 906185462, 1090812512, -547295293, -1469587627, 829329135, 1181335161,
-882789492, -1134132454, 628085408, 1382605366, -871598187, -1156888829, 570562233, 1426400815,
-977650754, -1296233688, 733239954, 1555261956, -1026031705, -1244606671, 752459403, 1541320221,
-1687895376, -328994266, 1969922972, 40735498, -1677130071, -351390145, 1913087877, 83908371,
-1782625662, -491226604, 2075208622, 213261112, -1831694693, -438977011, 2094854071, 198958881,
-2032938284, -237706686, 1759359992, 534414190, -2118248755, -155638181, 1873836001, 414664567,
-2012718362, -15766928, 1711684554, 285281116, -1889165569, -127750551, 1634467795, 376229701,
-1609899400, -686959890, 1308918612, 956543938, -1486412191, -799009033, 1231636301, 1047427035,
-1362007478, -640263460, 1088359270, 936918000, -1447252397, -558129467, 1202900863, 817233897,
-1111625188, -893730166, 1404277552, 615818150, -1160759803, -841546093, 1423857449, 601450431,
-1285129682, -1000256840, 1567103746, 711928724, -1274298825, -1022587231, 1510334235, 755167117]
static def crc32_update(buf, crc)
crc ^= 0xffffffff
var crc32_table = partition.Partition_otadata.crc32_table
for k:0..size(buf)-1
crc = (crc >> 8 & 0x00FFFFFF) ^ crc32_table[(crc & 0xff) ^ buf[k]]
end
return crc ^ 0xffffffff
end
#- crc32 for ota_seq as 32 bits unsigned, with init vector -1 -#
static def crc32_ota_seq(seq)
return partition.Partition_otadata.crc32_update(bytes().add(seq, 4), 0xFFFFFFFF)
import crc
return crc.crc32(0xFFFFFFFF, bytes().add(seq, 4))
end
#---------------------------------------------------------------------#