Added cache support

This commit is contained in:
Benjamin Vedder 2024-03-10 12:56:27 +01:00
parent b544785ffb
commit 341a7e67b1
8 changed files with 45 additions and 5 deletions

View File

@ -286,6 +286,8 @@ void commands_process_packet(unsigned char *data, unsigned int len,
strcpy((char*)(send_buffer + ind), FW_NAME);
ind += strlen(FW_NAME) + 1;
buffer_append_uint32(send_buffer, main_calc_hw_crc(), &ind);
fw_version_sent_cnt++;
reply_func(send_buffer, ind);

View File

@ -66,6 +66,14 @@ int conf_custom_cfg_num(void) {
return res;
}
int conf_custom_get_cfg_xml(int conf_ind, uint8_t **data) {
if (conf_ind != 0 || m_get_cfg_xml == 0) {
return 0;
}
return m_get_cfg_xml(data);
}
void conf_custom_process_cmd(unsigned char *data, unsigned int len,
void(*reply_func)(unsigned char *data, unsigned int len)) {
COMM_PACKET_ID packet_id;

View File

@ -30,6 +30,7 @@ void conf_custom_add_config(
int (*get_cfg_xml)(uint8_t **data));
void conf_custom_clear_configs(void);
int conf_custom_cfg_num(void);
int conf_custom_get_cfg_xml(int conf_ind, uint8_t **data);
void conf_custom_process_cmd(unsigned char *data, unsigned int len,
void(*reply_func)(unsigned char *data, unsigned int len));

View File

@ -24,7 +24,7 @@
#define FW_VERSION_MAJOR 6
#define FW_VERSION_MINOR 05
// Set to 0 for building a release and iterate during beta test builds
#define FW_TEST_VERSION_NUMBER 27
#define FW_TEST_VERSION_NUMBER 28
#include "datatypes.h"

31
main.c
View File

@ -47,6 +47,10 @@
#include "timer.h"
#include "imu.h"
#include "flash_helper.h"
#include "conf_custom.h"
#include "crc.h"
#include "qmlui.h"
#if HAS_BLACKMAGIC
#include "bm_if.h"
#endif
@ -54,9 +58,9 @@
#include "mempools.h"
#include "events.h"
#include "main.h"
#ifdef CAN_ENABLE
#include "comm_can.h"
#define CAN_FRAME_MAX_PL_SIZE 8
#endif
@ -215,6 +219,31 @@ bool main_init_done(void) {
return m_init_done;
}
uint32_t main_calc_hw_crc(void) {
uint32_t crc = 0;
#ifdef QMLUI_SOURCE_HW
crc = crc32_with_init(data_qml_hw, DATA_QML_HW_SIZE, crc);
#endif
for (int i = 0;i < conf_custom_cfg_num();i++) {
uint8_t *data = 0;
int len = conf_custom_get_cfg_xml(i, &data);
if (len > 0) {
crc = crc32_with_init(data, len, crc);
}
}
if (flash_helper_code_size(CODE_IND_QML) > 0) {
crc = crc32_with_init(
flash_helper_code_data(CODE_IND_QML),
flash_helper_code_size(CODE_IND_QML),
crc);
}
return crc;
}
int main(void) {
halInit();
chSysInit();

1
main.h
View File

@ -21,5 +21,6 @@
#define MAIN_H_
bool main_init_done(void);
uint32_t main_calc_hw_crc(void);
#endif /* MAIN_H_ */

View File

@ -89,7 +89,7 @@ void crc32_reset(void) {
CRC->CR |= CRC_CR_RESET;
}
uint32_t crc32_with_init(uint8_t *buf, uint32_t len, uint32_t cksum) {
uint32_t crc32_with_init(const uint8_t *buf, uint32_t len, uint32_t cksum) {
cksum = ~cksum;
while (len--) {
@ -99,7 +99,6 @@ uint32_t crc32_with_init(uint8_t *buf, uint32_t len, uint32_t cksum) {
uint32_t mask = -(cksum & 1);
cksum = (cksum >> 1) ^ (0xEDB88320 & mask);
}
}
return ~cksum;

View File

@ -28,6 +28,6 @@
unsigned short crc16(unsigned char *buf, unsigned int len);
uint32_t crc32(uint32_t *buf, uint32_t len);
void crc32_reset(void);
uint32_t crc32_with_init(uint8_t *buf, uint32_t len, uint32_t cksum);
uint32_t crc32_with_init(const uint8_t *buf, uint32_t len, uint32_t cksum);
#endif /* CRC_H_ */