From 07c77d0e0bd8fc15d9e4d3394abba9f67e8d25f1 Mon Sep 17 00:00:00 2001 From: Jeffrey Lee <jlee@gitlab.riscosopen.org> Date: Mon, 21 May 2012 00:37:01 +0000 Subject: [PATCH] Miscellaneous fixes and improvements Detail: Resources/UK/Desc - Changed handling of icon 17 (SCSI drive number) so that it gets restored properly when saved choices are reloaded Resources/UK/Templates,fec - Added scroll bars, resize icon, etc. to main window to make it usable on low-res displays Resources/UK/!Help - Add linebreaks to wrap text to 80 columns. Required for it to display properly in FrontEnd's help viewer. Updated changelog. bas/SDCreate: - Tidied up formatting a bit and added LOCAL's to procedures/functions to make it clearer which vars are local and which are global. - PROCdismount now dismounts the drive under both Fat32Fs and SCSIFS instead of just SCSIFS. - Added PROCCheckDisc to handle warning the user about potential data loss when writing an image to card/disc, and to provide an additional warning if the target disc holds !Boot or is the configured boot drive. Admin: Tested in a few situations to ensure Fat32Fs dismounting and !Boot drive/boot drive detection works OK Version 1.25. Tagged as 'SDCreate-1_25' --- Resources/UK/!Help | 220 +++++++++++++++++++++++++++---------- Resources/UK/Desc | 2 +- Resources/UK/Templates,fec | Bin 3458 -> 3458 bytes VersionNum | 20 ++-- bas/SDCreate | 91 ++++++++++++--- 5 files changed, 252 insertions(+), 81 deletions(-) diff --git a/Resources/UK/!Help b/Resources/UK/!Help index 7f1ed6f..c0cacae 100644 --- a/Resources/UK/!Help +++ b/Resources/UK/!Help @@ -5,38 +5,65 @@ SDCreate Introduction ------------ -SDCreate is a utility designed to help people with the task of installing RISC OS ROM images onto SD cards, for use with the OMAP3 and OMAP4 ports of RISC OS. If you attempt to create an SD card manually then there are many places where things can go wrong, either due to user error or operating system quirks. But if you use SDCreate to create the image for you then you can (almost) guarantee that it will boot without any trouble. +SDCreate is a utility designed to help people with the task of installing +RISC OS ROM images onto SD cards, for use with the OMAP3 and OMAP4 ports of +RISC OS. If you attempt to create an SD card manually then there are many +places where things can go wrong, either due to user error or operating system +quirks. But if you use SDCreate to create the image for you then you can +(almost) guarantee that it will boot without any trouble. Requirements ------------ -Images can be created on almost any RISC OS computer with >32MB of spare disc space. You will need at least version 1.28 of the FrontEnd module and version 1.52 of DDEUtils. RISC OS 5 users can find up-to-date versions of these modules in the HardDisc4 image available in the downloads section of the RISC OS Open website. Users of 26bit machines can find the modules in the "System resources" download. +Images can be created on almost any RISC OS computer with >32MB of spare disc +space. You will need at least version 1.28 of the FrontEnd module and version +1.52 of DDEUtils. RISC OS 5 users can find up-to-date versions of these modules +in the HardDisc4 image available in the downloads section of the RISC OS Open +website. Users of 26bit machines can find the modules in the "System resources" +download. http://www.riscosopen.org/content/downloads/other-zipfiles -If you want to use SDCreate to write the image to an SD card, then you'll need to be using a RISC OS 5 machine with a USB card reader and the USB mass storage drivers (SCSISoftUSB). +If you want to use SDCreate to write the image to an SD card, then you'll need +to be using a RISC OS 5 machine with a USB card reader and the USB mass storage +drivers (SCSISoftUSB). -Alternatively, you can copy the SD card image to a Windows/Linux/Mac/etc. PC and write the image to an SD card using any number of the free utilities that are available for those platforms (see the 'Utilities for other platforms' section, below) +Alternatively, you can copy the SD card image to a Windows/Linux/Mac/etc. PC +and write the image to an SD card using any number of the free utilities that +are available for those platforms (see the 'Utilities for other platforms' +section, below) -Before you use SDCreate to create an SD card image, you may need to track down some extra files/software: +Before you use SDCreate to create an SD card image, you may need to track down +some extra files/software: -* BeagleBoard-xM users will need suitable copies of x-loader and U-Boot. You will find suitable versions on the Linux SD card that came with your board; the 'mlo' file is x-loader, and the 'u-boot/bin' file is u-boot. Alternatively, you can extract them from the demo images available to download from the CircuitCo website: +* BeagleBoard-xM users will need suitable copies of x-loader and U-Boot. You + will find suitable versions on the Linux SD card that came with your board; + the 'mlo' file is x-loader, and the 'u-boot/bin' file is u-boot. + Alternatively, you can extract them from the demo images available to + download from the CircuitCo website: http://circuitco.com/support/index.php?title=Circuitco_Support_Wiki -* TouchBook users will need suitable copies of x-loader and U-Boot as well. You can either copy these off of the Linux SD card that came with the machine, or download new versions from the Always Innovating website. +* TouchBook users will need suitable copies of x-loader and U-Boot as well. You + can either copy these off of the Linux SD card that came with the machine, or + download new versions from the Always Innovating website. -* TouchBook users will also need to install the RISC OS port of mkimage, available from riscos.info: +* TouchBook users will also need to install the RISC OS port of mkimage, + available from riscos.info: http://www.riscos.info/packages/CommandDetails.html#Mkimage Usage ----- -The SDCreate main window is split into two sections - 'Create image' and 'Write image'. Depending on which options are selected the 'Run' button at the bottom may or may not be greyed out. +The SDCreate main window is split into two sections - 'Create image' and 'Write +image'. Depending on which options are selected the 'Run' button at the bottom +may or may not be greyed out. ******** WARNING ******* -The code which writes images to SD cards hasn't received thorough testing, and doesn't ask for confirmation before beginning the write operation. So if you've selected the wrong drive you will lose all your data on that drive, and if you try interacting with the drive while the write is occuring then it will likely result in a corrupt image. +The code which writes images to SD cards hasn't received thorough testing. In +particular, if you try interacting with the drive while the write is occuring +then it will likely result in a corrupt image. ******** WARNING ******* @@ -47,7 +74,8 @@ If you want to create an image, and save it as a file: * Deselect 'Write image' * Select the right machine type * Drag the RISC OS ROM image to the 'ROM image' box -* Drag the x-loader and U-Boot binaries into the x-loader and U-Boot boxes, if necessary +* Drag the x-loader and U-Boot binaries into the x-loader and U-Boot boxes, if + necessary * Drag your desired CMOS file into the 'CMOS file' box, if necessary * Click 'Run' @@ -56,7 +84,8 @@ If you want to create an image, and write it straight out to a card: * Select both 'Create image' and 'Write image' * Select the right machine type * Drag the RISC OS ROM image to the 'ROM image' box -* Drag the x-loader and U-Boot binaries into the x-loader and U-Boot boxes, if necessary +* Drag the x-loader and U-Boot binaries into the x-loader and U-Boot boxes, if + necessary * Select the SCSI drive number which your SD card reader has appeared under * Drag your desired CMOS file into the 'CMOS file' box, if necessary * Click 'Run' @@ -71,55 +100,93 @@ If you want to write an existing SD image to an SD card: * Click 'Run' -That's it! If it all went well, you should now have a working SD card/image for use with your OMAP machine. +That's it! If it all went well, you should now have a working SD card/image for +use with your OMAP machine. CMOS files ---------- -RISC OS stores a number of non volatile settings in what is often referred to as CMOS memory. Most notably, these are all the configuration settings such as the keyboard repeat rate and the drive to boot from. - -From RISC OS 5.18 onwards the OMAP3 HAL will try to find CMOS memory mounted on a carrier board plugged into the otherwise unused 14 pin JTAG connector. -If that is not found to be present then an attempt will be made to find a valid CMOS image loaded into volatile memory by the boot process, though any settings will be forgotten when powered down - it is recommended to obtain a CMOS carrier board from your supplier for full read/write capability. -If that is also not found to be present (or is corrupt) the defaults in the kernel will be used instead, so the machine will still boot whether the hardware is present or not and whether a CMOS file is present or not. - -The default filename is simply 'cmos' but can be changed to anything you desire as long as the corresponding boot script is ammended (see 'The Techie Bit' +RISC OS stores a number of non volatile settings in what is often referred to +as CMOS memory. Most notably, these are all the configuration settings such as +the keyboard repeat rate and the drive to boot from. + +From RISC OS 5.18 onwards the OMAP3 HAL will try to find CMOS memory mounted on +a carrier board plugged into the otherwise unused 14 pin JTAG connector. +If that is not found to be present then an attempt will be made to find a valid +CMOS image loaded into volatile memory by the boot process, though any settings +will be forgotten when powered down - it is recommended to obtain a CMOS +carrier board from your supplier for full read/write capability. +If that is also not found to be present (or is corrupt) the defaults in the +kernel will be used instead, so the machine will still boot whether the +hardware is present or not and whether a CMOS file is present or not. + +The default filename is simply 'cmos' but can be changed to anything you desire +as long as the corresponding boot script is ammended (see 'The Techie Bit' later). The behaviour of SDCreate with regards to CMOS files is as follows: -* When creating an image (i.e. the 'Create image' box is ticked), you can place a copy of a specific CMOS file into the image by entering the filename in the 'CMOS file' box. +* When creating an image (i.e. the 'Create image' box is ticked), you can place + a copy of a specific CMOS file into the image by entering the filename in the + 'CMOS file' box, or by dragging the file into the box. * If you don't specify a file, a blank CMOS file will be placed in the image. -* If you're writing an existing image to a card (i.e. 'Create image' isn't ticked), then by default the CMOS file held in the image will be used. -* However you can override this behaviour by entering a filename in the 'CMOS file' box. This CMOS file will then be used instead of the one held in the image. +* If you're writing an existing image to a card (i.e. 'Create image' isn't + ticked), then by default the CMOS file held in the image will be used. +* However you can override this behaviour by entering a filename in the 'CMOS + file' box. This CMOS file will then be used instead of the one held in the + image. -The format of CMOS file used is compatible with that used by the *LoadCMOS/*SaveCMOS commands, or the load/save CMOS option available within Configure. Note that you should obviously only use CMOS files that have been saved by an OMAP3 machine; a file from a RiscPC, Iyonix, etc. isn't guaranteed to work correctly. +The format of CMOS file used is compatible with that used by the +*LoadCMOS/*SaveCMOS commands, or the load/save CMOS option available within +Configure. Note that you should obviously only use CMOS files that have been +saved by an OMAP3 machine; a file from a RiscPC, Iyonix, etc. isn't guaranteed +to work correctly. Additional usage notes ---------------------- -Owners of old BeagleBoards, with version of U-Boot before 2009.01, may find that the 'BeagleBoard' option produces an SD card that won't boot on their machine. This can be solved in one of three ways: - -* Edit the !SDCreate.Desc file so that the boot script is named 'RESET/SCR' instead of 'BOOT/SCR'. You need to change the "icn 8 maps_to ..." line (line 31) -* Reflash your NAND with the latest x-loader & U-Boot. See the beagleboard.org website for details. -* Use the BeagleBoard-xM machine type (with either the BeagleBoard or BeagleBoard-xM x-loader & U-Boot; both should be compatible with the non-xM boards). - * Note however that this may introduce an additional problem, where the machine hangs on boot, due to an old, incompatible version of x-loader in NAND being used with the new version of U-Boot on the SD card. To fix this you can find an older version of U-Boot that works, or reflash your board, or always boot while holding down the User button. +Owners of old BeagleBoards, with version of U-Boot before 2009.01, may find +that the 'BeagleBoard' option produces an SD card that won't boot on their +machine. This can be solved in one of three ways: + +* Edit the !SDCreate.Desc file so that the boot script is named 'RESET/SCR' + instead of 'BOOT/SCR'. You need to change the "icn 8 maps_to ..." line + (line 31) +* Reflash your NAND with the latest x-loader & U-Boot. See the beagleboard.org + website for details. +* Use the BeagleBoard-xM machine type (with either the BeagleBoard or + BeagleBoard-xM x-loader & U-Boot; both should be compatible with the non-xM + boards). + * Note however that this may introduce an additional problem, where the + machine hangs on boot, due to an old, incompatible version of x-loader in + NAND being used with the new version of U-Boot on the SD card. To fix this + you can find an older version of U-Boot that works, or reflash your board, + or always boot while holding down the User button. Utilities for other platforms ----------------------------- -If you don't own a working RISC OS machine and therefore can't use SDCreate to create an SD card image, then 'The techie bit' section below has information as to what files SDCreate places into the images. This should allow you to create a working card manually. +If you don't own a working RISC OS machine and therefore can't use SDCreate to +create an SD card image, then 'The techie bit' section below has information as +to what files SDCreate places into the images. This should allow you to create +a working card manually. -If you've created an image file using SDCreate, but can't use SDCreate itself to write the image to a card, then you can use one of the following Windows/Linux/Mac utilities to write the image for you: +If you've created an image file using SDCreate, but can't use SDCreate itself +to write the image to a card, then you can use one of the following +Windows/Linux/Mac utilities to write the image for you: * Windows - Win32DiskImager - https://wiki.ubuntu.com/Win32DiskImager - Just make sure the file has a .img extension for Win32DiskImager to find it * Linux - UNetbootin - http://unetbootin.sourceforge.net/ - Or if you're feeling adventurous, just use 'dd' * Mac - http://meego.com/devices/netbook/installing-meego-your-netbook - - I'm not aware of any user-friendly utilities to do this on a Mac OS X machine, but the above instructions for writing a MeeGo Linux disc image onto a USB drive can easily be adapted for writing the SD card images created by SDCreate. + - I'm not aware of any user-friendly utilities to do this on a Mac OS X + machine, but the above instructions for writing a MeeGo Linux disc image + onto a USB drive can easily be adapted for writing the SD card images + created by SDCreate. The techie bit @@ -127,10 +194,16 @@ The techie bit SDCreate creates SD card images in the following manner: -* The file !SDCreate.blank is a blank, 32MB FAT16 disc image created under Windows and then copied off of the SD card using 'dd' under Linux +* The file !SDCreate.blank is a blank, 32MB FAT16 disc image created under + Windows and then copied off of the SD card using 'dd' under Linux * This file was then squashed using !Squash to cut down the size of the program. -* So one of the first things SDCreate does is to unsquash the image. If the image is being written straight out to the SD card then it will be unsquashed directly to the card using the SCSIFS_DiscOp SWIs. Otherwise, it will be unsquashed to a file. This file will then have its filetype set to 'DOSDisc', allowing the FAT image to be used as an image file with DOSFS. -* SDCreate then copies a series of files into the image. The exact files copied will depend upon which machine type you are using: +* So one of the first things SDCreate does is to unsquash the image. If the + image is being written straight out to the SD card then it will be unsquashed + directly to the card using the SCSIFS_DiscOp SWIs. Otherwise, it will be + unsquashed to a file. This file will then have its filetype set to 'DOSDisc', + allowing the FAT image to be used as an image file with DOSFS. +* SDCreate then copies a series of files into the image. The exact files copied + will depend upon which machine type you are using: BeagleBoard (non-xM): BOOT/SCR <- The BeagleBoard boot script from !SDCreate.scripts @@ -174,55 +247,91 @@ SDCreate creates SD card images in the following manner: RISCOS <- Your RISC OS ROM image CMOS <- Your CMOS settings -* The rules for which files get used on which machine type are in the FrontEnd description file (!SDCreate.Desc). I wouldn't advise trying to decipher it, though! -* If you want to examine the contents of an image file, just set its filetype to 'DOSDisc' and double-click. (The files get typed to Data since the FrontEnd module doesn't consider image files to be valid tool output!) +* The rules for which files get used on which machine type are in the FrontEnd + description file (!SDCreate.Desc). I wouldn't advise trying to decipher it, + though! +* If you want to examine the contents of an image file, just set its filetype + to 'DOSDisc' and double-click. (The files get typed to Data since the FrontEnd + module doesn't consider image files to be valid tool output!) * The Touch Book uImage file is created using the following command: - mkimage -A arm -O linux -T kernel -C none -a 0x81000000 -e 0x81000064 -n "RISC OS" -d <infile> <outfile> + mkimage -A arm -O linux -T kernel -C none -a 0x81000000 -e 0x81000064 + -n "RISC OS" -d <infile> <outfile> The even more techie bit ------------------------ -The human-readable source to the boot scripts is available in !SDCreate.scripts.source. You will also find there the 'convert' script script, which uses mkimage to convert the scripts to the binary format used by U-Boot. +The human-readable source to the boot scripts is available in !SDCreate.scripts. +source. You will also find there the 'convert' script script, which uses +mkimage to convert the scripts to the binary format used by U-Boot. -Each boot script will enter the ROM image at a different address; this is how RISC OS works out what machine type it's running on. The full list of (current) ROM image entry points is given below: +Each boot script will enter the ROM image at a different address; this is how +RISC OS works out what machine type it's running on. The full list of (current) +ROM image entry points is given below: -BeagleBoard ROM start + &00000000 -DevKit8000 ROM start + &00000004 -IGEPv2 ROM start + &00000008 -Pandora ROM start + &0000000C -Touch Book ROM start + &00000010 +BeagleBoard ROM start + &00000000 +DevKit8000 ROM start + &00000004 +IGEPv2 ROM start + &00000008 +Pandora ROM start + &0000000C +Touch Book ROM start + &00000010 -PandaBoard ROM start + &00000000 +PandaBoard ROM start + &00000000 -There is also an extra entry point at offset &00000064, which should be used when the ROM image is packed as a uImage. This entry point allows RISC OS to detect the machine type automatically, via the machine ID number that is passed to it by U-Boot. The uImage format also has a few other advantages (checksums, argument strings), so in the future it may be adopted for all machine types instead of just the Touch Book (and the only reason it's used on the Touch Book is because the default Touch Book version of U-Boot doesn't seem to look for boot scripts). +There is also an extra entry point at offset &00000064, which should be used +when the ROM image is packed as a uImage. This entry point allows RISC OS to +detect the machine type automatically, via the machine ID number that is passed +to it by U-Boot. The uImage format also has a few other advantages (checksums, +argument strings), so in the future it may be adopted for all machine types +instead of just the Touch Book (and the only reason it's used on the Touch Book +is because the default Touch Book version of U-Boot doesn't seem to look for +boot scripts). -The U-Boot environment file (uenv.txt) is a file that new versions of U-Boot use to get their environment variables. Although it's supposedly an optional thing, the BeagleBoard-xM demo images have had their default environments changed such that the regular boot.scr is no longer used, and uenv.txt is the only (easy) method to boot RISC OS. +The U-Boot environment file (uenv.txt) is a file that new versions of U-Boot +use to get their environment variables. Although it's supposedly an optional +thing, the BeagleBoard-xM demo images have had their default environments +changed such that the regular boot.scr is no longer used, and uenv.txt is the +only (easy) method to boot RISC OS. History ------- +V1.25 - 2012/5/21 + * Fixed bug that prevented the SCSI drive number from being saved properly by + the "Save options" iconbar option + * Added confirmation popup before writing an image to a card, and an extra + popup if the destination card/drive looks like the boot drive + * Reformatted this help file so it displays properly when viewed via the "Help" + iconbar option + * Added scrollbars to main window to allow SDCreate to be used on low-res + screens + * If Fat32Fs is loaded, SDCreate now makes sure Fat32Fs dismounts the drive + before writing the image V1.23 - 2012/2/22 * Relicenced as BSD and imported into RISC OS Open's CVS server * ROOL CVS is now the main source repository for SDCreate * No functional changes V1.21 - 2012/2/22 - * Fixed "No such function/procedure" error when attempting to write pre-prepared images to a card + * Fixed "No such function/procedure" error when attempting to write + pre-prepared images to a card V1.20 - 2012/2/12 * Added PandaBoard support [Willi Theiss] * Fix interactive help text - * Relaxed ROM size constraints and changed to using a 32MB FAT16 partition, to allow for both bigger ROMs and compressed ROMs - * Change 'x-loader' to 'x-loader/MLO' in the templates file to help make it clear what's required + * Relaxed ROM size constraints and changed to using a 32MB FAT16 partition, to + allow for both bigger ROMs and compressed ROMs + * Change 'x-loader' to 'x-loader/MLO' in the templates file to help make it + clear what's required V1.16 - 2012/1/7 * Scripts adjusted to load the CMOS file with 'fatload' [Rob Sprowson] V1.15 - 2011/5/25 - * Added a uenv.txt file to provide compatability with the latest BeagleBoard/BeagleBoard-xM versions of U-Boot + * Added a uenv.txt file to provide compatability with the latest + BeagleBoard/BeagleBoard-xM versions of U-Boot V1.10 - 2011/1/22 * Added support for adding CMOS files to images V1.02b - 2010/11/14 - * Changed !Run file to RMEnsure FrontEnd 1.28 after receiving reports of 1.16 not working + * Changed !Run file to RMEnsure FrontEnd 1.28 after receiving reports of 1.16 + not working V1.02 - 2010/10/17 * Fixed a bug with the step that checks for successful uImage creation * Corrected all filenames to be in caps, so TouchBook/xM cards actually boot! @@ -260,5 +369,6 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -SDCreate was created by Jeffrey Lee, me@phlamethrower.co.uk. SDCreate icon created by Chris Wraight. +SDCreate was created by Jeffrey Lee, me@phlamethrower.co.uk. SDCreate icon +created by Chris Wraight. diff --git a/Resources/UK/Desc b/Resources/UK/Desc index 6b04bed..3c0c610 100644 --- a/Resources/UK/Desc +++ b/Resources/UK/Desc @@ -40,7 +40,7 @@ dbox_start icn 14 maps_to ""; icn 15 maps_to ""; icn 16 on maps_to "disc " followed_by icn 17 produces_no_output; - icn 17 on maps_to ""; + icn 17 maps_to string; icn 18 decreases icn 17 min 0; icn 19 increases icn 17 max 7; diff --git a/Resources/UK/Templates,fec b/Resources/UK/Templates,fec index 2f8dcee28da20ff59edee97c3100c12ab087a94d..5d3f6bbb1c5946610b7c8719fca1a24dc9cb1389 100644 GIT binary patch delta 45 scmZpYZj#<`heg4Ug@IuOBLf2;2Lr<eRt7lu4+KICEdMwEVQJ$40PoNYBLDyZ delta 45 scmZpYZj#<`heg4Tg@IuWBLl-fb_RwktPF7Q9|(jPSlT!LVQJ$400z4Zk^lez diff --git a/VersionNum b/VersionNum index 9b099cc..8119014 100644 --- a/VersionNum +++ b/VersionNum @@ -1,23 +1,23 @@ -/* (1.24) +/* (1.25) * * This file is automatically maintained by srccommit, do not edit manually. * Last processed by srccommit version: 1.1. * */ -#define Module_MajorVersion_CMHG 1.24 +#define Module_MajorVersion_CMHG 1.25 #define Module_MinorVersion_CMHG -#define Module_Date_CMHG 25 Mar 2012 +#define Module_Date_CMHG 21 May 2012 -#define Module_MajorVersion "1.24" -#define Module_Version 124 +#define Module_MajorVersion "1.25" +#define Module_Version 125 #define Module_MinorVersion "" -#define Module_Date "25 Mar 2012" +#define Module_Date "21 May 2012" -#define Module_ApplicationDate "25-Mar-12" +#define Module_ApplicationDate "21-May-12" #define Module_ComponentName "SDCreate" #define Module_ComponentPath "bsd/RiscOS/Sources/Utilities/SDCreate" -#define Module_FullVersion "1.24" -#define Module_HelpVersion "1.24 (25 Mar 2012)" -#define Module_LibraryVersionInfo "1:24" +#define Module_FullVersion "1.25" +#define Module_HelpVersion "1.25 (21 May 2012)" +#define Module_LibraryVersionInfo "1:25" diff --git a/bas/SDCreate b/bas/SDCreate index ad807fb..e7160b6 100644 --- a/bas/SDCreate +++ b/bas/SDCreate @@ -26,17 +26,23 @@ REM ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE REM POSSIBILITY OF SUCH DAMAGE. REM ON ERROR PRINT REPORT$;" at ";ERL : END + REM Create blank CMOS file + DIM cmos% 2052 FOR a%=0 TO 2044 STEP 4 : cmos%!a%=0 : NEXT a% cmos%!2048 = 510 : REM Current Boot$OSVersion, just in case something cares about it in the future loadedcmos%=FALSE + REM Grab command line from DDEUtils + SYS "DDEUtils_GetCLSize" TO clsize% DIM cl% clsize% SYS "DDEUtils_GetCl",cl% clpos%=0 + REM Find output type, name + type$=FNgetarg IF type$="CMOS" THEN loadedcmos%=TRUE : PROCloadCMOS(FNgetarg) : type$=FNgetarg IF type$="disc" THEN disc%=TRUE ELSE IF type$="file" THEN disc%=FALSE ELSE PRINT "Unknown output type '"+type$+"'" @@ -44,11 +50,14 @@ IF disc%=TRUE THEN discno%=VAL(FNgetarg) IF discno%<0 OR discno%>7 THEN PRINT "Bad SCSI drive number" sdimage$="SCSI::"+STR$(discno%)+".$" + PROCCheckDisc ELSE sdimage$=FNgetarg IF sdimage$="" THEN PRINT "No output filename given" ENDIF + REM Validate the other command line args + pos%=clpos% outfile$=FNgetarg IF outfile$="image" THEN @@ -64,7 +73,9 @@ WHILE outfile$<>"" PROCCheckFile(outfile$,infile$) outfile$=FNgetarg ENDWHILE -REM Now do it for real + +REM Now do it for real + clpos%=pos% PROCdecompress("<SDCreate$Dir>.blank") REM Process other command line args @@ -100,26 +111,28 @@ PRINT "Done" END DEF FNgetarg -arg$="" -WHILE clpos%<clsize% AND cl%?clpos%=32 - clpos%+=1 -ENDWHILE -WHILE clpos%<clsize% AND cl%?clpos%>32 - arg$=arg$+CHR$(cl%?clpos%) - clpos%+=1 -ENDWHILE + LOCAL arg$ + arg$="" + WHILE clpos%<clsize% AND cl%?clpos%=32 + clpos%+=1 + ENDWHILE + WHILE clpos%<clsize% AND cl%?clpos%>32 + arg$=arg$+CHR$(cl%?clpos%) + clpos%+=1 + ENDWHILE =arg$ DEF PROCdecompress(infile$) + LOCAL F%,size%,sqsh%,buf%,worksize%,work%,flags%,in%,in_remain%,discaddr%,O%,stat%,out_end%,unwritten% F%=OPENIN(infile$) size%=EXT#F% - DIM sqsh% size% + DIM sqsh% LOCAL size% SYS "OS_GBPB",4,F%,sqsh%,size% CLOSE#F% IF sqsh%!0<>&48535153 THEN PRINT "Compressed file corrupt?" : END - DIM buf% 128*1024 + DIM buf% LOCAL 128*1024 SYS "Squash_Decompress",8,-1 TO worksize% - DIM work% worksize% + DIM work% LOCAL worksize% REM Decompress to temp buffer & write out flags%=0 @@ -147,6 +160,7 @@ DEF PROCdecompress(infile$) ENDPROC DEF PROCCheckFile(outfile$,infile$) + LOCAL F%,L% IF infile$="" THEN PRINT "Bad command line parameters" : END F%=OPENIN(infile$) IF F%=0 THEN PRINT "File '"+infile$+"' not found" : END @@ -163,10 +177,11 @@ DEF PROCCheckFile(outfile$,infile$) ENDPROC DEF PROCwrite(infile$) + LOCAL F%,size%,discaddr%,read%,buf%,unread% PROCdismount F%=OPENIN(infile$) size%=EXT#F% - DIM buf% 128*1024 + DIM buf% LOCAL 128*1024 discaddr%=0 PRINT "Writing image..."; REPEAT @@ -184,6 +199,7 @@ DEF PROCwrite(infile$) ENDPROC DEF PROCloadCMOS(infile$) + LOCAL F%,L%,pos% IF infile$="" THEN PRINT "Bad command line parameters" : END F%=OPENIN(infile$) IF F%=0 THEN PRINT "File '"+infile$+"' not found" : END @@ -206,8 +222,53 @@ DEF PROCwriteCMOS ENDPROC DEF PROCdismount + LOCAL A$ IF disc%=FALSE THEN ENDPROC + REM Fat32Fs may be loaded, make sure that dismounts the drive as well + A$="-Fat32Fs-%dismount :"+STR$ discno% + SYS "XOS_CLI",A$ + SYS "XOS_CLI",A$ REM Dismount twice to ensure FileCore forgets the disc - OSCLI("-SCSI-%dismount :"+STR$ discno%) - OSCLI("-SCSI-%dismount :"+STR$ discno%) + A$="-SCSI-%dismount :"+STR$ discno% + OSCLI(A$) + OSCLI(A$) +ENDPROC + +DEF PROCCheckDisc + LOCAL buf1%,buf2%,flags%,pos%,bad%,fs%,default%,result% + bad%=FALSE + DIM buf1% LOCAL 4096 + DIM buf2% LOCAL 4096 + REM Pop up a generic confirmation message + buf1%!0 = 0 + $(buf1%+4) = "All existing data on drive "+sdimage$+" will be lost. Proceed?"+CHR$(0) + SYS "Wimp_ReportError",buf1%,&517,"SDCreate","!sdcreate" TO ,result% + IF result%<>1 THEN PRINT "User cancelled operation" : END + REM Check that the selected disc (discno%, sdimage$) is safe to write to + REM i.e. doesn't look like the boot drive! + SYS "XOS_FSControl",37,"<Boot$Dir>",buf1%,,,4096 TO ;flags% + IF (flags% AND 1) = 0 THEN + SYS "XOS_FSControl",37,sdimage$,buf2%,,,4096 TO ;flags% + IF (flags% AND 1) = 0 THEN + pos%=0 + WHILE (buf1%?pos% = buf2%?pos%) AND (buf2%?pos%<>ASC("$")) + pos%=pos%+1 + ENDWHILE + IF (buf1%?pos%=ASC("$")) AND (buf2%?pos%=ASC("$")) THEN bad%=TRUE + ENDIF + ENDIF + REM Also check configured boot drive? + IF bad%=FALSE THEN + SYS "OS_Byte",161,5 TO ,,fs% + IF fs%=26 THEN + SYS "SCSIFS_Drives" TO default% + IF default%=discno% THEN bad%=TRUE + ENDIF + ENDIF + IF bad%=TRUE THEN + buf1%!0 = 0 + $(buf1%+4) = sdimage$+" appears to be the boot drive. Are you sure you want to proceed? All existing data will be lost"+CHR$(0) + SYS "Wimp_ReportError",buf1%,&517,"SDCreate","!sdcreate" TO ,result% + IF result%<>1 THEN PRINT "User cancelled operation" : END + ENDIF ENDPROC -- GitLab