How do I cause the P2 to reboot programmatically? I'm working on code to boot a large program from flash and I'd like to force a reboot after writing the flash. What's the best way to cause the P2 to reboot?
And another related question: Can someone remind me of the magic incantation to relaunch the monitor? Obviously, it's a coginit instruction but what is the base address of the monitor in ROM?
And another related question: Can someone remind me of the magic incantation to relaunch the monitor? Obviously, it's a coginit instruction but what is the base address of the monitor in ROM?
Attempting to answer my own question, is this the code I need to relaunch the current COG with Chip's monitor program? I stole this from the ROM loader.
CON
SERIAL_TX = 90 ' serial pins
SERIAL_RX = 91
DAT
coginit monitor_pgm, monitor_ptr 'relaunch cog0 with monitor
monitor_pgm long $55C+$1B4 'monitor program address
monitor_ptr long SERIAL_TX<<9 + SERIAL_RX 'monitor parameter (conveys pins)
When a COG is started, $1F8 contiguous longs are read from HUB memory and written to COG registers
$000..$1F7. The COG will then begin execution at $000. This process takes 1,016 clocks.
Example:
COGID COGNUM 'what COG am I?
SETCOG COGNUM 'set my COG number
COGINIT COGPGM,COGPTR 'restart me with the ROM Monitor
COGPGM LONG $0070C 'address of the ROM Monitor
COGPTR LONG 90<<9 + 91 'tx = P90, rx = P91
COGNUM RES 1
'If you want to inspect hub memory after your program has run,
' just put the following code at the end of your program:
Code:
coginit monitor_pgm,monitor_ptr 'relaunch cog0 with monitor
monitor_pgm long $70C 'monitor program address
monitor_ptr long 90<<9 + 91 'monitor parameter (conveys tx/rx pins)
'This will launch the ROM Monitor and let you view what your program did to hub memory.
' The monitor only affects the hub memory when you give it a command to do so. So, when
' the monitor starts up, hub memory is just as your program left it, ready to be inspected.
When a COG is started, $1F8 contiguous longs are read from HUB memory and written to COG registers
$000..$1F7. The COG will then begin execution at $000. This process takes 1,016 clocks.
Example:
COGID COGNUM 'what COG am I?
SETCOG COGNUM 'set my COG number
COGINIT COGPGM,COGPTR 'restart me with the ROM Monitor
COGPGM LONG $0070C 'address of the ROM Monitor
COGPTR LONG 90<<9 + 91 'tx = P90, rx = P91
COGNUM RES 1
'If you want to inspect hub memory after your program has run,
' just put the following code at the end of your program:
Code:
coginit monitor_pgm,monitor_ptr 'relaunch cog0 with monitor
monitor_pgm long $70C 'monitor program address
monitor_ptr long 90<<9 + 91 'monitor parameter (conveys tx/rx pins)
'This will launch the ROM Monitor and let you view what your program did to hub memory.
' The monitor only affects the hub memory when you give it a command to do so. So, when
' the monitor starts up, hub memory is just as your program left it, ready to be inspected.
Thanks! It's odd that your address for the monitor is $70C but the one in Chip's boot ROM listing is $55C+$1B4=$710. Any idea why there is a difference? Yours works though and the one I got from Chip's listing doesn't although I'm sure it is due to my own misunderstanding what Chip's code does. Anyway, thanks for your help!!
Thanks! It's odd that your address for the monitor is $70C but the one in Chip's boot ROM listing is $55C+$1B4=$710. Any idea why there is a difference? Yours works though and the one I got from Chip's listing doesn't although I'm sure it is due to my own misunderstanding what Chip's code does. Anyway, thanks for your help!!
_________
CLKSET D
---------
CLKSET writes the lower 9 bits of D to the HUB clock register:
%R_MMMM_XX_SS
R = 1 for hardware reset, 0 for continued operation
MMMM = PLL multiplying factor for XI pin input:
% 0000 for PLL disabled
% 0001..% 1111 for 2..16 multiply (XX must be set for XI input or XI/XO crystal oscillator)
MMMM = PLL mode:
% 0000 for disabled, else XX must be set for XI input or XI/XO crystal oscillator
% 0001 for multiply XI by 2
% 0010 for multiply XI by 3
% 0011 for multiply XI by 4
% 0100 for multiply XI by 5
% 0101 for multiply XI by 6
% 0110 for multiply XI by 7
% 0111 for multiply XI by 8
% 1000 for multiply XI by 9
% 1001 for multiply XI by 10
% 1010 for multiply XI by 11
% 1011 for multiply XI by 12
% 1100 for multiply XI by 13
% 1101 for multiply XI by 14
% 1110 for multiply XI by 15
% 1111 for multiply XI by 16
XX = XI/XO pin mode:
00 for XI reads low, XO floats
01 for XI input, XO floats
10 for XI/XO crystal oscillator with 15pF internal loading and 1M-ohm feedback
11 for XI/XO crystal oscillator with 30pF internal loading and 1M-ohm feedback
SS = Clock selector:
00 for RCFAST (~20MHz)
01 for RCSLOW (~20KHz)
10 for XTAL (10MHz-20MHz)
11 for PLL
_________
CLKSET D
---------
CLKSET writes the lower 9 bits of D to the HUB clock register:
%R_MMMM_XX_SS
R = 1 for hardware reset, 0 for continued operation
MMMM = PLL multiplying factor for XI pin input:
% 0000 for PLL disabled
% 0001..% 1111 for 2..16 multiply (XX must be set for XI input or XI/XO crystal oscillator)
MMMM = PLL mode:
% 0000 for disabled, else XX must be set for XI input or XI/XO crystal oscillator
% 0001 for multiply XI by 2
% 0010 for multiply XI by 3
% 0011 for multiply XI by 4
% 0100 for multiply XI by 5
% 0101 for multiply XI by 6
% 0110 for multiply XI by 7
% 0111 for multiply XI by 8
% 1000 for multiply XI by 9
% 1001 for multiply XI by 10
% 1010 for multiply XI by 11
% 1011 for multiply XI by 12
% 1100 for multiply XI by 13
% 1101 for multiply XI by 14
% 1110 for multiply XI by 15
% 1111 for multiply XI by 16
XX = XI/XO pin mode:
00 for XI reads low, XO floats
01 for XI input, XO floats
10 for XI/XO crystal oscillator with 15pF internal loading and 1M-ohm feedback
11 for XI/XO crystal oscillator with 30pF internal loading and 1M-ohm feedback
SS = Clock selector:
00 for RCFAST (~20MHz)
01 for RCSLOW (~20KHz)
10 for XTAL (10MHz-20MHz)
11 for PLL
Thanks again! I guess I wouldn't have thought of using CLKSET to do a reset. From what you list it sounds like this will reset the P2:
In Yours example You will reset it to
>
Because the the clock register is cleared to %0_0000_00_00 on reset, the chip starts up in RCFAST mode
with both the crystal oscillator and the PLL disabled.
You need in same time set other value3s to what You want.
Thanks to the help I got in this thread, I got the flash loader working. I'm now able to write a C program to flash so it will boot on reset. I've got a few problems to iron out and I'll push the changes. Anyway, thanks Sapieha for your help!
Thanks to the help I got in this thread, I got the flash loader working. I'm now able to write a C program to flash so it will boot on reset. I've got a few problems to iron out and I'll push the changes. Anyway, thanks Sapieha for your help!
I've pushed the propeller-load changes. You can now use the propeller-load -e option to write a program to the flash and have it boot on reset. We still don't have support for XMM mode yet though so you're limited to COG, LMM, or CMM programs at the moment. However, your LMM or CMM program can use all of the 126k of hub memory.
Comments
That example come from Chip.
In dump that address starts with Long - 0
But I have not looked yet why Chip starts at this point.
Thanks again! I guess I wouldn't have thought of using CLKSET to do a reset. From what you list it sounds like this will reset the P2: Does that sound right?
Sorry, I guess it has to be this:
Anyway, CLKSET works fine and so does my flash loader test! Thanks!!
In Yours example You will reset it to
>
Because the the clock register is cleared to % 0_0000_00_00 on reset, the chip starts up in RCFAST mode
with both the crystal oscillator and the PLL disabled.
You need in same time set other value3s to what You want.
I've pushed the propeller-load changes. You can now use the propeller-load -e option to write a program to the flash and have it boot on reset. We still don't have support for XMM mode yet though so you're limited to COG, LMM, or CMM programs at the moment. However, your LMM or CMM program can use all of the 126k of hub memory.