Simulate a cold boot on the Electron

bbc/electron apps, languages, utils, educational progs, demos + more
Post Reply
User avatar
roland
Posts: 4042
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Simulate a cold boot on the Electron

Post by roland » 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.
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:

User avatar
hoglet
Posts: 9438
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: Simulate a cold boot on the Electron

Post by hoglet » Sat Aug 15, 2020 9:23 am

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

User avatar
Rich Talbot-Watkins
Posts: 1662
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: Simulate a cold boot on the Electron

Post by Rich Talbot-Watkins » Sat Aug 15, 2020 9:41 am

There's always the cheesy option:

Code: Select all

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

User avatar
Rich Talbot-Watkins
Posts: 1662
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: Simulate a cold boot on the Electron

Post by Rich Talbot-Watkins » Sat Aug 15, 2020 9:44 am

Does *FX 200,2 work on an Electron to clear memory and force a harder reset? Because, if so... that!

User avatar
jgharston
Posts: 4118
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Simulate a cold boot on the Electron

Post by jgharston » Sat Aug 15, 2020 11:08 am

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

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

User avatar
0xC0DE
Posts: 732
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: Simulate a cold boot on the Electron

Post by 0xC0DE » Sat Aug 15, 2020 11:29 am

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).
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my demos for Acorn Electron and BBC Micro

User avatar
roland
Posts: 4042
Joined: Thu Aug 29, 2013 9:29 pm
Location: Born (NL)
Contact:

Re: Simulate a cold boot on the Electron

Post by roland » Sun Aug 16, 2020 1:06 pm

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.
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:

Post Reply

Return to “8-bit acorn software: other”