Page 1 of 1

Simulate a cold boot on the Electron

Posted: Sat Aug 15, 2020 8:46 am
by roland
How can I simulate a cold start of the Electron? I can do a JMP (&FFFC) to enter the reset routine. Can I force it to simulate a cold start? A hard break might also be usable. I am aware that this won't be a real reset because the hardware is not reset this way. The main goal is to initialize the operating system.

Re: Simulate a cold boot on the Electron

Posted: Sat Aug 15, 2020 9:23 am
by hoglet
roland wrote:
Sat Aug 15, 2020 8:46 am
How can I simulate a cold start of the Electron? I can do a JMP (&FFFC) to enter the reset routine. Can I force it to simulate a cold start? A hard break might also be usable. I am aware that this won't be a real reset because the hardware is not reset this way. The main goal is to initialize the operating system.
Here's the start of the reset code:

Code: Select all

.LD8D2
LDA #&40:STA &0D00    :\ Put RTI in NMI code space
SEI:CLD               :\ Disable IRQs, put in Decimal mode
LDX #&FF:TXS          :\ Reset stack
INX                   :\ X=&00
STX &FE00             :\ 
STX &028D             :\ Set Last Break Type to &00=SoftBreak
LDA #&F8:STA LFE05    :\
LDA LFE00:AND #&02    :\ Read PowerOn flag from ULA    <<<<<<<<<
EOR #&02:PHA          :\ Save PowerOn flag
BEQ LD8FB             :\ If PowerOn, jump to clear memory
The test for the PowerOn flag is marked.

As far as I know, there is no way to set bit 1 of &FE00 in the ULA again, so the only answer is to replicate the code before this in your application, then JMP into the reset code i.e.

Code: Select all

.power_up_reset
LDA #&40
STA &0D00
SEI
CLD
LDX #&FF
TXS
INX
STX &FE00
STX &028D
LDA #&F8
STA &FE05
LDA #&02
JMP &D8EB 
Dave

Re: Simulate a cold boot on the Electron

Posted: Sat Aug 15, 2020 9:41 am
by Rich Talbot-Watkins
There's always the cheesy option:

Code: Select all

PRINT"Please press CTRL"
REPEAT UNTIL INKEY-2
CALL !-4

Re: Simulate a cold boot on the Electron

Posted: Sat Aug 15, 2020 9:44 am
by Rich Talbot-Watkins
Does *FX 200,2 work on an Electron to clear memory and force a harder reset? Because, if so... that!

Re: Simulate a cold boot on the Electron

Posted: Sat Aug 15, 2020 11:08 am
by jgharston
roland wrote:
Sat Aug 15, 2020 8:46 am
How can I simulate a cold start of the Electron? I can do a JMP (&FFFC) to enter the reset routine. Can I force it to simulate a cold start? A hard break might also be usable. I am aware that this won't be a real reset because the hardware is not reset this way. The main goal is to initialize the operating system.
Posted some time ago. As the Electron doesn't have a hardware VIA, you can't set the VIA's reset bit, you have to bypass the startup code. See link.

Code: Select all

    .ResetElk
    CLC
    LDA &FFFC:ADC #25:STA addr+0   :\ Find RESET+25
    LDA &FFFD:ADC #0:STA addr+1
    :
    \ The following is a copy of the first 22 bytes of the Electron RESET code
    LDA #&40:STA &0D00             :\ Set null NMI routine
    SEI:CLD:LDX #&FF:TXS           :\ Disable IRQs, set to Binary, clear the stack
    INX:STX &FE00:STX &028D        :\ Reset the ULA, set ResetType=PowerOn
    LDA #&F8:STA LFE05             :\ Set up the ULA
    :
    \ Now fake that the ULA is in power-on state
    LDA #2:JMP (addr)              :\ A='ULA power on', jump into startup code

Re: Simulate a cold boot on the Electron

Posted: Sat Aug 15, 2020 11:29 am
by 0xC0DE
Can confirm. I use this code all the time. Combine with *FX 200,2 or *FX 200,3 (clear memory on BREAK) and your own BREAK intercept handler to have a really hard reset on pressing BREAK. I add this to all my demo effects (that take over the entire Elk) to properly reset the machine on BREAK. I remember that the BREAK intercept handler needs to live in low RAM (<&400) if you intend to combine this with *FX200,3 (clear RAM). I usually put the handler at the bottom of the stack (&100).

Re: Simulate a cold boot on the Electron

Posted: Sun Aug 16, 2020 1:06 pm
by roland
Thanks for those answers. I used these and it worked. The Electron WiFi software has now an *UPDATE command to check if there are updates of the ROM. If so, the user is prompted if these update must be installed. If the users chooses to update the ROM then the new version is downloaded from my web server and flashed into the EEPROM. Before flashing there is a CRC16 check to verify the download. In case of an CRC error the update will be aborted. After the update is applied the Electron gets a forced hard reset with your code.