@@ -785,9 +785,18 @@ int ai_matmul_q16_16(const q16_16_t* a, const q16_16_t* b, q16_16_t* c, uint32_t
785785}
786786
787787void ai_model_init (void ) {
788+ serial_write_string ("DEBUG: ai_model_init starting...\n" );
788789 uint32_t phys_start = (uint32_t )& _ai_model_start ;
789790 uint32_t phys_end = (uint32_t )& _ai_model_end ;
791+
792+ serial_write_string ("DEBUG: AI Model range: " );
793+ serial_write_hex32 (phys_start );
794+ serial_write_string (" - " );
795+ serial_write_hex32 (phys_end );
796+ serial_write_string ("\n" );
797+
790798 if (phys_end <= phys_start ) {
799+ serial_write_string ("DEBUG: AI Model not found (size 0)\n" );
791800 ai_mapped_base = 0 ;
792801 ai_mapped_size = 0 ;
793802 return ;
@@ -797,20 +806,30 @@ void ai_model_init(void) {
797806 uint32_t offset = phys_start - aligned_phys ;
798807 uint32_t total = offset + size ;
799808 uint32_t page_count = (total + 0x3FFFFF ) >> 22 ;
809+
810+ serial_write_string ("DEBUG: Mapping AI Model pages: " );
811+ serial_write_hex32 (page_count );
812+ serial_write_string ("\n" );
813+
800814 for (uint32_t i = 0 ; i < page_count ; ++ i ) {
815+ if ((i % 10 ) == 0 ) serial_write_string ("." );
801816 map_page_4mb (AI_MODEL_VIRT_BASE + (i << 22 ), aligned_phys + (i << 22 ), 0x3 );
802817 }
818+ serial_write_string ("\nDEBUG: AI Model pages mapped\n" );
819+
803820 ai_mapped_base = (uint8_t * )(AI_MODEL_VIRT_BASE + offset );
804821 ai_mapped_size = size ;
805822
823+ serial_write_string ("DEBUG: Reading GGUF header...\n" );
806824 gguf_header_t header ;
807825 if (gguf_read_header (ai_mapped_base , & header )) {
808- serial_write ( " GGUF OK\n" );
826+ serial_write_string ( "DEBUG: GGUF OK\n" );
809827 diag_log (DIAG_INFO , "gguf header ok" );
810828 } else {
811- serial_write ( " GGUF BAD\n" );
829+ serial_write_string ( "DEBUG: GGUF BAD\n" );
812830 diag_log (DIAG_ERROR , "gguf header invalid" );
813831 }
832+ serial_write_string ("DEBUG: ai_model_init finished\n" );
814833}
815834
816835static int contains_word (const char * text , const char * word ) {
0 commit comments