radio_tool 0.2.1
Loading...
Searching...
No Matches
cs_fw.hpp
1
21#pragma once
22
23#include <radio_tool/fw/fw.hpp>
24
25#include <memory>
26
27namespace radio_tool::fw
28{
29 typedef struct
30 {
31 uint32_t baseaddr_offset; // 0x00 - 0x08000000 + this (0x20000 or 0x10000 usually), 0 if spi flash data
32 uint32_t unkaddr1; // 0x04 - 0
33 uint32_t unkaddr2; // 0x08 - 0
34 uint32_t rsrc_size; // 0x0C - 0 if image bin, size if spi flash data (ex. 0x00069010 for RCDB)
35 uint32_t unksize1; // 0x10 - 0
36 uint32_t imagesize; // 0x14 - total image data size is this + imageHeaderSize
37 uint8_t padding1[0x24]; // 0x18
38 uint32_t rsrcHeaderSize; // 0x3C - 0x80 if spi data, 0 if image data
39 uint32_t unkHeaderSize; // 0x40 - 0
40 uint32_t imageHeaderSize; // 0x44 - 0x80
41 uint8_t padding2[0x24]; // 0x48
42 uint32_t version; // 0x6C - 0x00000001 usually
43 uint8_t resv[0x10]; // 0x70
44 } CS800D_header; // total size 0x80
45 static_assert(sizeof(CS800D_header) == 0x80);
46
47 class CSFW : public FirmwareSupport
48 {
49 public:
50 auto Read(const std::string &fw) -> void override;
51 auto Write(const std::string &fw) -> void override;
52 auto ToString() const -> std::string override;
53 auto GetRadioModel() const -> const std::string override;
54 auto SetRadioModel(const std::string&) -> void override;
55 auto Decrypt() -> void override;
56 auto Encrypt() -> void override;
57 auto IsCompatible(const FirmwareSupport* Other) const -> bool override;
58
62 static auto SupportsFirmwareFile(const std::string &file) -> bool;
63
64 static auto SupportsRadioModel(const std::string &model) -> bool;
65
69 static auto Create() -> std::unique_ptr<FirmwareSupport>
70 {
71 return std::make_unique<CSFW>();
72 }
73 private:
74 CS800D_header header;
75 uint16_t checksum;
76
77 auto MakeChecksum() const -> uint16_t;
78 auto MakeFiledata() const -> std::vector<uint8_t>;
79 auto UpdateHeader() -> void;
80 };
81} // namespace radio_tool::fw
auto Read(const std::string &fw) -> void override
Definition: cs_fw.cpp:33
static auto Create() -> std::unique_ptr< FirmwareSupport >
Definition: cs_fw.hpp:69
auto Encrypt() -> void override
Definition: cs_fw.cpp:155
auto IsCompatible(const FirmwareSupport *Other) const -> bool override
Definition: cs_fw.cpp:222
auto Write(const std::string &fw) -> void override
Definition: cs_fw.cpp:94
auto GetRadioModel() const -> const std::string override
Definition: cs_fw.cpp:138
static auto SupportsFirmwareFile(const std::string &file) -> bool
Definition: cs_fw.cpp:161
auto SetRadioModel(const std::string &) -> void override
Definition: cs_fw.cpp:144
auto ToString() const -> std::string override
Definition: cs_fw.cpp:117
auto Decrypt() -> void override
Definition: cs_fw.cpp:149