fix iar build

This commit is contained in:
hathach
2025-10-03 11:26:14 +07:00
parent e2dbf2bdd1
commit 3b007249cf
3 changed files with 8 additions and 7 deletions

View File

@ -111,8 +111,8 @@ static fs_file_t fs_objects[FS_MAX_FILE_COUNT] = {
.image_bit_depth = 0,
.parent = 0,
.association_type = MTP_ASSOCIATION_UNDEFINED,
.size = sizeof(README_TXT_CONTENT)-1,
.data = (uint8_t*) (uintptr_t) README_TXT_CONTENT,
.size = sizeof(README_TXT_CONTENT)-1
},
{
.name = { 't', 'i', 'n', 'y', 'u', 's', 'b', '.', 'p', 'n', 'g', 0 }, // "tinyusb.png"
@ -123,8 +123,8 @@ static fs_file_t fs_objects[FS_MAX_FILE_COUNT] = {
.image_bit_depth = 32,
.parent = 0,
.association_type = MTP_ASSOCIATION_UNDEFINED,
.data = (uint8_t*) (uintptr_t) logo_bin,
.size = logo_len,
.size = LOGO_LEN,
.data = (uint8_t*) (uintptr_t) logo_bin
}
};
@ -391,7 +391,7 @@ static int32_t fs_get_storage_info(tud_mtp_cb_data_t* cb_data) {
const uint32_t storage_id = command->params[0];
TU_VERIFY(SUPPORTED_STORAGE_ID == storage_id, -1);
// update storage info with current free space
storage_info.max_capacity_in_bytes = sizeof(README_TXT_CONTENT) + logo_len + FS_MAX_CAPACITY_BYTES;
storage_info.max_capacity_in_bytes = sizeof(README_TXT_CONTENT) + LOGO_LEN + FS_MAX_CAPACITY_BYTES;
storage_info.free_space_in_objects = FS_MAX_FILE_COUNT - fs_get_file_count();
storage_info.free_space_in_bytes = storage_info.free_space_in_objects ? FS_MAX_CAPACITY_BYTES : 0;
mtp_container_add_raw(io_container, &storage_info, sizeof(storage_info));

View File

@ -1,6 +1,6 @@
// convert using tools/file2carray.py
const size_t logo_len = 2733;
const uint8_t logo_bin[] __attribute__((aligned(16))) = {
enum { LOGO_LEN = 2733 };
static const uint8_t logo_bin[] __attribute__((aligned(16))) = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x08, 0x06, 0x00, 0x00, 0x00, 0xd2, 0xd6, 0x7f,
0x7f, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,

View File

@ -35,7 +35,8 @@ def main():
fout_name = fin_name + '.h'
with open(fout_name, 'w') as fout:
print(f"Converting {fin_name} to {fout_name}")
fout.write(f'const size_t bindata_len = {len(contents)};\n')
fout.write(f'enum {{ BINDATA_LEN = {len(contents)} }};\n')
fout.write(f'const size_t bindata_len = BINDATA_LEN;\n')
fout.write(f'const uint8_t bindata[] __attribute__((aligned(16))) = {{')
print_carray(fout, contents)
fout.write('};\n')