Example #1
0
void OpenIBootStart() {
	setup_openiboot();
	pmu_charge_settings(TRUE, FALSE, FALSE);

#ifdef OPENIBOOT_INSTALLER
	framebuffer_setdisplaytext(FALSE);
	framebuffer_clear();

	{
		int w, h;
		uint32_t *bgImg = framebuffer_load_image(datainstallerLogoPNG, sizeof(datainstallerLogoPNG), &w, &h, TRUE);
		if(bgImg)
		{
			int x = (framebuffer_width() - w)/2;
			int y = (framebuffer_height() - h)/3;

			framebuffer_draw_image(bgImg, x, y, w, h);
		}
		else
		{
			framebuffer_setdisplaytext(TRUE);
			bufferPrintf("Failed to load image...\n");
		}
	}

#else
	framebuffer_setdisplaytext(TRUE);
	framebuffer_clear();
	bufferPrintf("Loading openiBoot...");
#ifndef SMALL
#ifndef NO_STBIMAGE
	int defaultOS = 0;
	int tempOS = 0;
	const char* hideMenu = nvram_getvar("opib-hide-menu");
	const char* sDefaultOS = nvram_getvar("opib-default-os");
	const char* sTempOS = nvram_getvar("opib-temp-os");
	if(sDefaultOS)
		defaultOS = parseNumber(sDefaultOS);
	if(sTempOS)
		tempOS = parseNumber(sTempOS);
	if(tempOS!=defaultOS) {
				
		switch (tempOS) {
			case 0:
				framebuffer_clear();
				bufferPrintf("Loading iOS...");
				reset_tempos(sDefaultOS);
				Image* image = images_get(fourcc("ibox"));
				if(image == NULL)
					image = images_get(fourcc("ibot"));
				void* imageData;
				images_read(image, &imageData);
				chainload((uint32_t)imageData);
				break;
			
			case 1:
				framebuffer_clear();
				bufferPrintf("Loading iDroid...");
				reset_tempos(sDefaultOS);
#ifndef NO_HFS
#ifndef CONFIG_IPOD
				radio_setup();
#endif
				nand_setup();
				fs_setup();
				if(globalFtlHasBeenRestored) {
					if(ftl_sync()) {
						bufferPrintf("ftl synced successfully");
					} else {
						bufferPrintf("error syncing ftl");
					}
				}	
				pmu_set_iboot_stage(0);
				startScripting("linux"); //start script mode if there is a script file
				boot_linux_from_files();
#endif
				break;
				
			case 2:
				framebuffer_clear();
				bufferPrintf("Loading Console...");
				reset_tempos(sDefaultOS);
				hideMenu = "1";
				break;
		}
		
	} else if(hideMenu && (strcmp(hideMenu, "1") == 0 || strcmp(hideMenu, "true") == 0)) {
		bufferPrintf("Boot menu hidden. Use 'setenv opib-hide-menu false' and then 'saveenv' to unhide.\r\n");
	} else {
        	framebuffer_setdisplaytext(FALSE);
        	isMultitouchLoaded = load_multitouch_images();
		framebuffer_clear();
		const char* sMenuTimeout = nvram_getvar("opib-menu-timeout");
		int menuTimeout = -1;
		if(sMenuTimeout)
			menuTimeout = parseNumber(sMenuTimeout);
		menu_setup(menuTimeout, defaultOS);
	}
#endif
#endif
#endif //OPENIBOOT_INSTALLER

	startUSB();

#ifndef CONFIG_IPOD
	camera_setup();
	radio_setup();
#endif
	sdio_setup();
	wlan_setup();
	accel_setup();
#ifndef CONFIG_IPOD
	als_setup();
#endif

	nand_setup();
#ifndef NO_HFS
	fs_setup();
#endif

	pmu_set_iboot_stage(0);
	startScripting("openiboot"); //start script mode if there is a file
	bufferPrintf("version: %s\r\n", OPENIBOOT_VERSION_STR);
	bufferPrintf("-----------------------------------------------\r\n");
	bufferPrintf("              WELCOME TO OPENIBOOT\r\n");
	bufferPrintf("-----------------------------------------------\r\n");
	DebugPrintf("                    DEBUG MODE\r\n");

	audiohw_postinit();

	setReady(TRUE);

	// Process command queue
	while(TRUE) {
		char* command = NULL;
		CommandQueue* cur;
		EnterCriticalSection();
		if(commandQueue != NULL) {
			cur = commandQueue;
			command = cur->command;
			commandQueue = commandQueue->next;
			free(cur);
		}
		LeaveCriticalSection();

		if(command) {
			setReady(FALSE);
			processCommand(command);
			setReady(TRUE);
			free(command);
		}
	}
	// should not reach here

}
Example #2
0
void OpenIBootStart() {
	setup_openiboot();
	pmu_charge_settings(TRUE, FALSE, FALSE);

	framebuffer_setdisplaytext(TRUE);
	framebuffer_clear();

#ifndef SMALL
#ifndef NO_STBIMAGE
	const char* hideMenu = nvram_getvar("opib-hide-menu");
	if(hideMenu && (strcmp(hideMenu, "1") == 0 || strcmp(hideMenu, "true") == 0)) {
		bufferPrintf("Boot menu hidden. Use 'setenv opib-hide-menu false' and then 'saveenv' to unhide.\r\n");
	} else {
		framebuffer_setdisplaytext(FALSE);
		const char* sMenuTimeout = nvram_getvar("opib-menu-timeout");
		int menuTimeout = -1;
		if(sMenuTimeout)
			menuTimeout = parseNumber(sMenuTimeout);

		menu_setup(menuTimeout);
	}
#endif
#endif

	startUSB();

	radio_setup();
	sdio_setup();
	wlan_setup();
	accel_setup();
	als_setup();

	nand_setup();
#ifndef NO_HFS
	fs_setup();
#endif

	pmu_set_iboot_stage(0);
	startScripting("openiboot"); //start script mode if there is a file
	bufferPrintf("-----------------------------------------------\r\n");
	bufferPrintf("              WELCOME TO OPENIBOOT\r\n");
	bufferPrintf("-----------------------------------------------\r\n");
	DebugPrintf("                    DEBUG MODE\r\n");

	audiohw_postinit();

	// Process command queue
	while(TRUE) {
		char* command = NULL;
		CommandQueue* cur;
		EnterCriticalSection();
		if(commandQueue != NULL) {
			cur = commandQueue;
			command = cur->command;
			commandQueue = commandQueue->next;
			free(cur);
		}
		LeaveCriticalSection();

		if(command) {
			processCommand(command);
			free(command);
		}
	}
	// should not reach here

}
Example #3
0
int main(void)
{
    bool init_status;
    int retValue;
	int i = defaultPerso.fall_detection_window;

    // initialize LEDs
    nrf_gpio_cfg_output(LED_RESETTING);
    nrf_gpio_cfg_output(LED_NO_FALL);
    nrf_gpio_cfg_output(LED_FALL_DETECTED);
		nrf_gpio_cfg_output(LED_OTHER);
		
		welcomeLEDs();

    // Initialize
    timers_init();
    ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();
    sec_params_init();
    twi_master_init();
		
#ifdef TEST_ACTIVITY_LOG		
		testActivityLog();
#endif
		
		initActivityLog();
		initSnapshotBuffer();
		initCoefficients();

    // initialize values
    retValue = 0;

    init_status = mpu6050_init(MPU6050_DEVICE_ADDR);
    if ( false == init_status )
    {
        init_status = mpu6050_init(MPU6050_DEVICE_ADDR+1);
        if ( false == init_status )
        {   
            retValue = -1;
						errorLEDs();
					sd_nvic_SystemReset();
        }
    }
    if ( 0 == retValue )
    {    
      init_status = false;

			
			i = 0;
        while ( false == init_status )
        {
          if (i == 6) 
					{
						errorLEDs();
						sd_nvic_SystemReset();
					}
					
					init_status = accel_setup();
					i++;
					
				}
    }
		
		
    if (0 == retValue) {
			 
			char outbuf[20];
			
			// Start execution - write a log entry with zero steps to indicate startup
				
//				writeLogEntry(999);
        advertising_start();
				setup_wdt();
        timers_start(); // start sampliing
        
        while(1)
        {
					if (ReadSnapshots == 1)
					{

						FullSnapshotEntry* entry = (FullSnapshotEntry*)(SNAPSHOT_DATA_ADDRESS_START) ;
						
						SnapshotHeader *h;
						Sensor_Reading *r;

            sprintf (outbuf, "ID: %s                                   ", getPerso()->uname);    
						ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
                

                for(int i=0;i < getActivityLogSize(); i++)
                {
                  h = &entry->hdr;
									
									sprintf (outbuf, ": SNAPSHOT # %d  \n                           ",(i));
									ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 16);
									
									sprintf (outbuf, "Version: 2 \n");//
									ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 12);
									
									sprintf (outbuf, "t:%d n:%d last:%d",h->data.time, h->data.num_of_data_points, h->data.latest_data_point_index);
									ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
//									ptr++;
								
									r = entry->r;
										
									for (int j = 0; j < NUMBER_OF_ENTRIES; j++)
									{
										#define FLASH_READ_DELAY 40
										nrf_gpio_pin_set(LED_RESETTING); 
		
										sprintf (outbuf, "i: %d T: %04x           ",j,r[j].val.temp);
										ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
										
										nrf_delay_ms(FLASH_READ_DELAY);

										sprintf (outbuf, "A: x%04xy%04xz%04x",r[j].val.x_ac,r[j].val.y_ac,r[j].val.z_ac);
										ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
										
										nrf_delay_ms(FLASH_READ_DELAY);
								
										sprintf (outbuf, "G: x%04xy%04xz%04x",r[j].val.x_gy,r[j].val.y_gy,r[j].val.z_gy);
										ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
										
										nrf_delay_ms(FLASH_READ_DELAY);
										
										nrf_gpio_pin_clear(LED_RESETTING);
										
										nrf_delay_ms(FLASH_READ_DELAY);
										
										//ptr += sizeof(Sensor_Reading);
										

									}
									entry++;
                    
									
                    
                }  	
						
						
						ReadSnapshots = 0;
					}

					if (ReadSnapshotsPartial == 1)
					{
						
						PartialSnapTotal = ((PartialSnap1-('0'))*10)+(PartialSnap2-('0'));
						
						FullSnapshotEntry* entry = (FullSnapshotEntry*)(SNAPSHOT_DATA_ADDRESS_START+(((PartialSnapTotal*sizeof(FullSnapshotEntry)*10))/4)) ;
						
						SnapshotHeader *h;
						Sensor_Reading *r;

            sprintf (outbuf, "ID: %s                                   ", getPerso()->uname);    
						ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
                

                for(int i=0;i < 10; i++)
                {
                  h = &entry->hdr;
									
									sprintf (outbuf, ": SNAPSHOT # %d  \n                           ",(i+(PartialSnapTotal*10)));
									ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 16);
									
									sprintf (outbuf, "Version: 2 \n");//
									ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 12);
									
									sprintf (outbuf, "t:%d n:%d last:%d",h->data.time, h->data.num_of_data_points, h->data.latest_data_point_index);
									ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
//									ptr++;
								
									r = entry->r;
										
									for (int j = 0; j < NUMBER_OF_ENTRIES; j++)
									{
										#define FLASH_READ_DELAY 40
										nrf_gpio_pin_set(LED_RESETTING); 
		
										sprintf (outbuf, "i: %d T: %04x           ",j,r[j].val.temp);
										ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
										
										nrf_delay_ms(FLASH_READ_DELAY);

										sprintf (outbuf, "A: x%04xy%04xz%04x",r[j].val.x_ac,r[j].val.y_ac,r[j].val.z_ac);
										ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
										
										nrf_delay_ms(FLASH_READ_DELAY);
								
										sprintf (outbuf, "G: x%04xy%04xz%04x",r[j].val.x_gy,r[j].val.y_gy,r[j].val.z_gy);
										ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
										
										nrf_delay_ms(FLASH_READ_DELAY);
										
										nrf_gpio_pin_clear(LED_RESETTING);
										
										nrf_delay_ms(FLASH_READ_DELAY);
										
										//ptr += sizeof(Sensor_Reading);
										

									}
									entry++;
                    
									
                    
                }  	
						
						
						ReadSnapshotsPartial = 0;
					}
					
					if (ReadDataBuffer == 1)
					{
						LogEntry *addr;
 
			
						sprintf (outbuf, "ID: %s                                   ", getPerso()->uname);
							ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
							
						addr = (LogEntry *)(STEP_DATA_ADDRESS_START);
							for(int i=0;i < getActivityLogSize(); i++)
							{
								nrf_gpio_pin_set(LED_RESETTING); 
								nrf_delay_ms(20);
								nrf_gpio_pin_clear(LED_RESETTING);
								nrf_delay_ms(20);  
								
									
					//			sprintf ( outbuf, ": h:%d s:%d a:%04f                                   ",addr->item.hour, addr->item.sec, addr->item.activity_level);
								sprintf ( outbuf, "%d:%d - %03f                                   ",addr->item.hour, (addr->item.sec)/60, addr->item.activity_level);
									ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
									//nrf_delay_ms(1);
								addr++;
									
							}  
							ReadDataBuffer = 0;
					}

					if (ReadDataBufferPartial == 1)
					{
						LogEntry *addr;
 
			
						sprintf (outbuf, "ID: %s                                   ", getPerso()->uname);
							ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
						
						PartialCountTotal = ((PartialCount1-('0'))*10)+(PartialCount2-('0'));							
						
						addr = (LogEntry *)(STEP_DATA_ADDRESS_START+(2*(PartialCountTotal*1000)));

							for(int i=0;i < 1000; i++)
							{
								nrf_gpio_pin_set(LED_RESETTING); 
								nrf_delay_ms(20);
								nrf_gpio_pin_clear(LED_RESETTING);
								nrf_delay_ms(20);  
								
									
					//			sprintf ( outbuf, ": h:%d s:%d a:%04f                                   ",addr->item.hour, addr->item.sec, addr->item.activity_level);
								sprintf ( outbuf, "%d:%d - %03f                                   ",addr->item.hour, (addr->item.sec)/60, addr->item.activity_level);
									ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
									//nrf_delay_ms(1);
								addr++;
									
							}  
							ReadDataBufferPartial = 0;
					}
				 
					if (Dumper == 1)
					{
						
						sprintf (outbuf, "Log: %d                                   ",getActivityLogSize());
							ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);   

							Dumper = 0;
					}
					
					if (ReadBigSnapshot == 1)
					{	
						SnapshotHeader *h = getSnapshotHeader();
						
						sprintf (outbuf, "t:%d n:%d last:%d",h->data.time, h->data.num_of_data_points, h->data.latest_data_point_index);
						ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
						
						for (i = 0; i < NUMBER_OF_ENTRIES; i++) //i <= h->data.latest_data_point_index; i++)
						{      
							#define RAM_READ_DELAY 15
							
							sprintf (outbuf, "i: %d T: %04x           ",i,raw_data[i].val.temp);
							ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
							nrf_delay_ms(RAM_READ_DELAY);

							sprintf (outbuf, "A: x%04xy%04xz%04x",raw_data[i].val.x_ac,raw_data[i].val.y_ac,raw_data[i].val.z_ac);
							ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
							nrf_delay_ms(RAM_READ_DELAY);

							sprintf (outbuf, "G: x%04xy%04xz%04x",raw_data[i].val.x_gy,raw_data[i].val.y_gy,raw_data[i].val.z_gy);
							ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
							nrf_delay_ms(RAM_READ_DELAY);
							
							
						}
						
						ReadBigSnapshot = 0;
						
					}
												
					if (do_post_processing == true)
					{
						do_post_processing = false;
						
						if (emergencyCall == 1) 
							{
								makeTheCall();
								emergencyCall = 0;
							}
						
						post_comm_processing();
						
					}
				
        // Power Method 1
				//		nrf_gpio_pin_write(LED_OTHER,1);
           // power_manage();
				//		nrf_gpio_pin_write(LED_OTHER,0);
        }
    }
    return retValue;

		
}
Example #4
0
void OpenIBootStart() {
	setup_openiboot();

	framebuffer_hook();
	framebuffer_setdisplaytext(TRUE);

#ifndef CONFIG_IPHONE_4
	pmu_charge_settings(TRUE, FALSE, FALSE);

	framebuffer_setdisplaytext(TRUE);
	framebuffer_clear();
	bufferPrintf("Loading openiBoot...");
#ifndef SMALL
#ifndef NO_STBIMAGE
	int defaultOS = 0;
	int tempOS = 0;
	const char* hideMenu = nvram_getvar("opib-hide-menu");
	const char* sDefaultOS = nvram_getvar("opib-default-os");
	const char* sTempOS = nvram_getvar("opib-temp-os");
	if(sDefaultOS)
		defaultOS = parseNumber(sDefaultOS);
	if(sTempOS)
		tempOS = parseNumber(sTempOS);
	if(tempOS!=defaultOS) {
				
		switch (tempOS) {
			case 0:
				framebuffer_clear();
				bufferPrintf("Loading iOS...");
				reset_tempos(sDefaultOS);
				Image* image = images_get(fourcc("ibox"));
				if(image == NULL)
					image = images_get(fourcc("ibot"));
				void* imageData;
				images_read(image, &imageData);
				chainload((uint32_t)imageData);
				break;
			
			case 1:
				framebuffer_clear();
				bufferPrintf("Loading iDroid...");
				reset_tempos(sDefaultOS);
#ifndef NO_HFS
#ifndef CONFIG_IPOD
				radio_setup();
#endif
				nand_setup();
				fs_setup();
				if(globalFtlHasBeenRestored) {
					if(ftl_sync()) {
						bufferPrintf("ftl synced successfully");
					} else {
						bufferPrintf("error syncing ftl");
					}
				}	
				pmu_set_iboot_stage(0);
				startScripting("linux"); //start script mode if there is a script file
				boot_linux_from_files();
#endif
				break;
				
			case 2:
				framebuffer_clear();
				bufferPrintf("Loading Console...");
				reset_tempos(sDefaultOS);
				hideMenu = "1";
				break;
		}
		
	} else if(hideMenu && (strcmp(hideMenu, "1") == 0 || strcmp(hideMenu, "true") == 0)) {
		bufferPrintf("Boot menu hidden. Use 'setenv opib-hide-menu false' and then 'saveenv' to unhide.\r\n");
	} else {
        	framebuffer_setdisplaytext(FALSE);
        	isMultitouchLoaded = load_multitouch_images();
		framebuffer_clear();
		const char* sMenuTimeout = nvram_getvar("opib-menu-timeout");
		int menuTimeout = -1;
		if(sMenuTimeout)
			menuTimeout = parseNumber(sMenuTimeout);
		menu_setup(menuTimeout, defaultOS);
	}
#endif
#endif

#endif
#ifndef CONFIG_IPAD
	startUSB();
#endif
#ifndef CONFIG_IPHONE_4
#ifndef CONFIG_IPOD
	camera_setup();
	radio_setup();
#endif
	sdio_setup();
	wlan_setup();
	accel_setup();
#ifndef CONFIG_IPOD
	als_setup();
#endif
	nand_setup();
#ifndef NO_HFS
	fs_setup();
#endif

	pmu_set_iboot_stage(0);
	startScripting("openiboot"); //start script mode if there is a file
#endif
	bufferPrintf("  ___                   _ ____              _   \r\n");
	bufferPrintf(" / _ \\ _ __   ___ _ __ (_) __ )  ___   ___ | |_ \r\n");
	bufferPrintf("| | | | '_ \\ / _ \\ '_ \\| |  _ \\ / _ \\ / _ \\| __|\r\n");
	bufferPrintf("| |_| | |_) |  __/ | | | | |_) | (_) | (_) | |_ \r\n");
	bufferPrintf(" \\___/| .__/ \\___|_| |_|_|____/ \\___/ \\___/ \\__|\r\n");
	bufferPrintf("      |_|                                       \r\n");
	bufferPrintf("\r\n");
	bufferPrintf("version: %s\r\n", OPENIBOOT_VERSION_STR);
	DebugPrintf("                    DEBUG MODE\r\n");

#ifndef CONFIG_IPHONE_4
	audiohw_postinit();
#endif

	// Process command queue
	while(TRUE) {
		char* command = NULL;
		CommandQueue* cur;
		EnterCriticalSection();
		if(commandQueue != NULL) {
			cur = commandQueue;
			command = cur->command;
			commandQueue = commandQueue->next;
			free(cur);
		}
		LeaveCriticalSection();

		if(command) {
			processCommand(command);
			free(command);
		}
	}
	// should not reach here

}
Example #5
0
void OpenIBootStart() {
	setup_openiboot();
	pmu_charge_settings(TRUE, FALSE, FALSE);

	framebuffer_setdisplaytext(TRUE);
	framebuffer_clear();
    //enable multitouch before displaying menu, only 3g first
    framebuffer_setdisplaytext(FALSE);
    nand_setup();
    fs_setup();
    int size;
    size = fs_extract(1, "/firmware/zephyr2.bin", (void*) 0x09000000);
    if(size < 0)
    {
        bufferPrintf("Cannot find zephyr bin.\r\n");
        return;
    }
    
    multitouch_setup((uint8_t*) 0x09000000, size);
    
#ifndef SMALL
#ifndef NO_STBIMAGE
	const char* hideMenu = nvram_getvar("opib-hide-menu");
	if(hideMenu && (strcmp(hideMenu, "1") == 0 || strcmp(hideMenu, "true") == 0)) {
		bufferPrintf("Boot menu hidden. Use 'setenv opib-hide-menu false' and then 'saveenv' to unhide.\r\n");
	} else {
		framebuffer_setdisplaytext(FALSE);
		const char* sMenuTimeout = nvram_getvar("opib-menu-timeout");
		int menuTimeout = -1;
		if(sMenuTimeout)
			menuTimeout = parseNumber(sMenuTimeout);

		menu_setup(menuTimeout);
	}
#endif
#endif

	startUSB();

#ifndef CONFIG_IPOD
	camera_setup();
	radio_setup();
#endif
	sdio_setup();
	wlan_setup();
	accel_setup();
#ifndef CONFIG_IPOD
	als_setup();
#endif

	nand_setup();
#ifndef NO_HFS
	fs_setup();
#endif

	pmu_set_iboot_stage(0);
	startScripting("openiboot"); //start script mode if there is a file
	bufferPrintf("version: %s\r\n", OPENIBOOT_VERSION_STR);
	bufferPrintf("-----------------------------------------------\r\n");
	bufferPrintf("              WELCOME TO OPENIBOOT\r\n");
	bufferPrintf("-----------------------------------------------\r\n");
	DebugPrintf("                    DEBUG MODE\r\n");

	audiohw_postinit();

	// Process command queue
	while(TRUE) {
		char* command = NULL;
		CommandQueue* cur;
		EnterCriticalSection();
		if(commandQueue != NULL) {
			cur = commandQueue;
			command = cur->command;
			commandQueue = commandQueue->next;
			free(cur);
		}
		LeaveCriticalSection();

		if(command) {
			processCommand(command);
			free(command);
		}
	}
	// should not reach here

}