28typedef enum : uint32_t {
205 uint64_t font_bytes = 0U;
216 priv_mkfontimg_diag(
"mkfontimg: font changed, is invalid, or could not be copied exactly: ");
252 if ((argc >= 2) && (
strcmp(argv[1],
"--blank") == 0)) {
259 if (argc < 3 || argc > 4) {
263 const char* card_name = (argc == 4) ? argv[3] :
"FONT.OTF";
@ k_block_size
Bytes per image sector.
mkfontimg_constant_t
FAT16 geometry, BPB fields, and accepted font limits.
@ k_bpb_numfats
FAT copy count.
@ k_byte_lo_mask
Low-byte mask.
@ k_bpb_fatsz16
Sectors per FAT.
@ k_bpb_sig_b
Signature high byte.
@ k_bpb_sig_off_b
Signature high offset.
@ k_bpb_off_bytspersec
BPB bytes/sector offset.
@ k_bpb_off_secfat
BPB FAT-size offset.
@ k_bpb_rootentcnt
Fixed root entries.
@ k_bpb_sig_a
Signature low byte.
@ k_bpb_sig_off_a
Signature low offset.
@ k_bpb_secperclus
Sectors per cluster.
@ k_font_min_bytes
Minimum accepted font bytes.
@ k_bpb_off_secperclus
BPB sectors/cluster offset.
@ k_bpb_rsvdseccnt
Reserved sectors.
@ k_bpb_off_rootentcnt
BPB root-entry offset.
@ k_bpb_off_numfats
BPB FAT-count offset.
@ k_bpb_off_rsvdseccnt
BPB reserved-sector offset.
@ k_font_cap
Maximum accepted font bytes.
@ k_blocks_fat16
Sectors in the image.
int main(int argc, char **argv)
Parse CLI mode and delegate to blank or font image generation.
static int internal_run_font(const char *font_in, const char *image_out, const char *card_name)
Generate a FAT16 image containing one verified streamed font.
static int internal_run_blank(const char *image_out)
Generate and publish a formatted empty FAT16 image.
static void internal_put16(uint8_t *sector, uint32_t offset, uint16_t value)
Store one little-endian 16-bit BPB field.
static void internal_build_fat16(uint8_t sector[k_block_size])
Build the legacy-compatible minimal FAT16 boot sector.
static bool internal_finish_image(mkfontimg_host_t *host, ra8_fs_mount_t *mount)
Finish filesystem state and publish the image atomically.
static bool internal_mount_image(const char *image_out, mkfontimg_host_t *host, ra8_fs_mount_t **mount)
Create, seed, and mount one unpublished FAT16 image.
Module-private bounded host-storage composition for mkfontimg.
void priv_mkfontimg_diag(const char *text)
Write one complete best-effort diagnostic fragment to standard error.
bool priv_mkfontimg_host_seed(mkfontimg_host_t *host, const uint8_t *bytes, uint32_t length)
Seed exact bytes at the beginning of the temporary image.
bool priv_mkfontimg_host_begin(const char *final_path, uint64_t block_count, uint32_t block_size, mkfontimg_host_t *host)
Create, size, and bind one private sibling-temporary image.
bool priv_mkfontimg_host_commit(mkfontimg_host_t *host)
Sync and atomically publish a complete temporary image.
void priv_mkfontimg_diag_u64(uint64_t value)
Write one unsigned decimal value to standard error without stdio.
void priv_mkfontimg_host_abort(mkfontimg_host_t *host)
Close and unlink an unpublished temporary image.
bool priv_mkfontimg_host_copy(const mkfontimg_host_t *host, ra8_fs_mount_t *mount, const char *input_path, const char *card_name, uint64_t minimum_bytes, uint64_t maximum_bytes, uint64_t *out_bytes)
Stream one stable host input into a card file and verify it by reread.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
int strcmp(const char *s1, const char *s2)
Compare two null-terminated strings.
Minimal FAT12/FAT16/FAT32 filesystem adapter (read + write).
ra8_err_t ra8_fs_mount(const ra8_fs_backend_t *backend, ra8_fs_mount_t **out_handle)
Mount a FAT volume from a block-device backend, auto-selecting the first partition.
ra8_err_t ra8_fs_unmount(ra8_fs_mount_t *handle)
Unmount a previously mounted volume and release its slot.
bool io_failed
Sticky positioned-I/O failure.
Caller-owned sibling-temporary and block-backend binding.
ra8_fs_backend_t backend
Portable FS facade.
mkfontimg_disk_t disk
Bound block state.
Cached parse of one mounted FAT volume.
@ k_byte_shift
Bits per byte for LE packing.
@ k_bpb_off_totsec16
Total sectors (16-bit).