!From some experiments by DK

A software initiated Cybiko Reboot

There is (as far as we know) no documented way to have the SDK perform a software reset of the Cybiko.

There are many potential uses of such a facility. One being a surefire way to recover from 'memory leaks'. Of course, when the Cybiko reboots, there is a bundle of debug info pushed to the serial port. This might cause issues to any connected micro.

Now that we know how to plant assembler into the C file, this seems to be the way to go.

I looked at the Boot ROM H8 code. There are two versions of this Version 1.1.2 (used in the original Classic unit, the one with the black slide power on/off switch) and Version 1.1.7 - (used in the second edition of the Cybiko Classic which uses the 'Esc' key to turn power on and off).

N.B. if you aren't using either of these versions of the boot loader, the addresses will likely not work. Note that this bootstrap code is located in the ROM of the H8 chip. Unlike CyOS (which resides in flash), it isn't upgradeable.

Locations 0 .. 1e6 hold the vectors for the H8 reset.

 BootLoaderV1.1.7.rom:     file format binary

 Disassembly of section .data:

 00000000 <.data>:

 Start vector 0 					- 00 00 0d be
       0:	00 00       	00 00             nop
       2:	0d be       	0d be             mov.w	e3,e6
 Manual reset vector 1 - 00 00 00 00
 Reserved vectors 2, 3, 4, 5, 6 		- 00 00 00 00
 NMI vector 7 					- 00 00 10 b8
      1c:	00 00       	00 00             nop
      1e:	10 b8       	10 b8        .word	H'10,H'b8

This is 00 00 0D 6A (decimal 3434) for the older Classic unit and is 00 00 0D BE (or decimal 3518) for the newer Classic units.

The function 'get_hardware_version()' returns 0 on the original Classic, 2 on the new Classic and 150 on the Xtreme. So, the following code sets the stack up & then forces transfer of control to the appropriate location.

 void classic_reset_original()
 {
     //hard reset the unit
     set_critical_mode( TRUE );
     asm(".even");
     asm("load.l 3434"); //the cybiko boot ROM entry point
     asm("push"); //LSW onto the stack
     asm("load.l 0");
     asm("push"); //MSW
     asm("load.l 0");
     asm("push"); //filler
     asm("load.l 0");
     asm("push"); //filler
     asm("retf");
     //don't need anything else ... we are now resetting!
 }
 
 
 void classic_reset_new()
 {
     //hard reset the unit
     set_critical_mode( TRUE );
     asm(".even");
 
     asm("load.l 3518"); //the cybiko boot ROM entry point
     asm("push"); //LSW onto the stack
 
     asm("load.l 0");
     asm("push"); //MSW
 
     asm("load.l 0");
     asm("push"); //filler
 
     asm("load.l 0");
     asm("push"); //filler
 
     asm("retf");
 
     //don't need anything else ... we are now resetting!
 }
 
 switch(get_hardware_version()) {
    case 0: classic_reset_original(); break;
    case 2: clasic_reset_new(); break;
   default: ; ///What should the default be?/
 }

Interesting to note that the 'retf' bytecode instruction seems to consume two longwords from the stack. We assume that 'push' pushes a word. Hence the need for the extra two pushes.

Calling this has worked for me in two test apps.

Another point of interest. on the newer Classic, if the address 3518, above, is replaced with the number '3213', the unit will print 'INVALID! system halted :-(' to the console and then hang in an infinite loop. This might be fun to use if we detect unwanted activity!