Running !Squeak and !Scratch
Doug Webb (190) 1180 posts |
Hi, After a lot of head scratching I’ve managed to get the latest versions of !Squeak and !Scratch running on a Raspberry Pi but only by running High Vector versions of the ROM. RC14 and RC15 both give abort errors pointing to an offset in the Utlity module, according to the Where command. I’m assuming that the abort handler and zero page handling in the HV ROMS is doing a better job of covering up memory issues than the Low Vector ones in this case as I think it is the first time I have had to have a HV ROM running to get something to work! The reason I’m trying to get the two programmes working is to use them as part of the RISCOS coding workshop at Recursion 18 so if anyone has any other way of getting them working then I’d like to know as if not I’ll have to put some notes out about updating the RISCOS Roms to the beta ones as part of the coding workshop. |
Chris Hall (132) 3554 posts |
Try removing the ZPP support modules that are only needed for the high vector rom? |
Doug Webb (190) 1180 posts |
Chris, Yes done that and get the same error with LV ROMS. So it seems at this stage running HV ROMS and Zeropain are actually helping unless there is a fix post RC15 that has been introduced that is the real reason they work. I suppose I could try a home brew LV ROM build from the latest sources if I can remember how to do it and get some time to do so! |
Rick Murray (539) 13840 posts |
Um, doesn’t it sound to you like something is broken in the application, not the OS? Is there any ZeroPain logfile that might indicate what is going on? At a random guess, I’d wonder if it isn’t passing a NULL pointer to some OS SWI, which under HV/ZPP may be a true zero if read, but on an LV system is one of the processor vectors, so will look like some big number (remember the oflaoflaofla errors!). |
Doug Webb (190) 1180 posts |
Rick You may be right but I was just trying to eliminate other things with out being in pointy finger mode at the application or support modules as it is too easy to assume things. !Scratch and !Squeak run on an Iyonix 5.22 LV so it may be Pi specific. Attached is a sample of the Zeropain log from a Pi running the latest Beta HV ROM. I have sent the logs to Tim Rowledge but he does not have a Pi or access to a newer DDE. Time: Tue Nov 28 13:24:31 2017 R0 = 0004d194 R1 = 4b735000 R2 = 00000000 R3 = 00000000 0002588c : 75746553 : LDRVCB R6,[R4,#-1363]! R15 = 000258d4 = +1d8d4 in application memory = SetupPixelTranslationTable +28 USR stack: |
Rick Murray (539) 13840 posts |
Hi, Finally found some source for these functions at http://www.squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/platforms/RiscOS/vm/sqRPCWindows.c?revision=2700&view=markup but I must confess, I’m worried that the code was last modified “4 years, 8 months ago”. I gave up working out how to download an archive of the files to attempt to build it, but then it would probably expect GCC and not Norcroft. ;-) As far as this particular problem goes, it is totally a null pointer bug in Squeak.
Without a debugger or trace instructions (I note plenty of PRINTFs in the source), I can’t tell exactly where this is failing, but the code shown above is loading R2 from the address in R0, plus 40. R0 is then stuffed into R5. The stack is then fiddled with. And now for our faulty instruction. It is loading a word into R0 from the address in R2 plus 40. Unfortunately R2 is zero, so we are trying to load a word from address &28. Now the faulty function is SetupPixelTranslationTable. The BPP of the Pi in 16M colours is 5, so the second block of code is executed (not the “fudge the pixel table” part).
The result is… zero! ColourTrans is telling us we do not need a translation table if the source and destination are the same. Just guesswork, mostly, but that’s where I’d be looking. It’s definitely a null pointer problem and the code I’ve located does appear to suffer the potential to create a null pointer situation; though I guess it may behave differently on other machines or else it’d be crashy on everything…?
If it builds with the DDE (and not GCC), I’ll be happy to try building it on a Pi if somebody can get me an archive of the sources.
Oh, I like that! ☺ |
Doug Webb (190) 1180 posts |
HI Rick Excellent stuff. I’ve emailed Tim and said you would be willing to recomplile if we can get a archive of the sources and pointed him here. |
Tim Rowledge (1742) 170 posts |
OK, Hi guys. I’m a bit limited by lack of a recent RISC OS and DDE, so this may be a bit more complicated than we’d like. FIrst off, Rick can breath easier since I don’t use gcc on RISC OS. I don’t even like it on linux… but that’s another issue. The last time I did any development work on the RISC OS Squeak vm was at the beginning of 2013 when I started the RPF work to improve Scratch. The fact that the sqRPCWindows.c file hasn’t been touched since forever is a good sign because it means nothing appeared to be broken. Evidently something isn’t quite right though, so let’s see what we can winkle out of the debug trace. These days the VM sources are available on github (yes, I hate it too) at https://github.com/OpenSmalltalk/opensmalltalk-vm – so the relevant file is https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/platforms/RiscOS/vm/sqRPCWindows.c – and I see some kind person added a new api in 2016 to keep it up to date. No idea who krono is. We’re looking at line 712 & 725. I see what Rick means about the tableSize thing; it never occured to me that you’d get a 0 back for that. I was naive enough to think that one might get sometihng like, y’know, an actual error in case of strangeness. Silly me! Not to mention I have trouble imagining how the following call to actually generate the table doesn’t error out. So, questions - |
Steve Pampling (1551) 8170 posts |
Impossible to fulfill both of those mutually exclusive requests. |
Jeffrey Lee (213) 6048 posts |
If assuming makes an ass out of you and me, what does guessing do? R15 = 000258d4 = +1d8d4 in application memory = SetupPixelTranslationTable +28 The crash occurred at an offset of &28 into SetupPixelTranslationTable. Sometimes compilers can rearrange things and make offsets like this meaningless, but if you look at the disassembly (* and you know what to look for) it’s clear that the crash has occurred very early on. Far too early for it to have called ColourTrans, called realloc, and then called ColourTrans again (and if the crash was in ColourTrans or the C library then the callstack would have been quite different). 0002588c : 75746553 : LDRVCB R6,[R4,#-1363]! ; This bit's the embedded function name, you can ignore that 00025890 : 78695070 : STMVCDA R9!,{R4-R6,R12,R14}^ ; 00025894 : 72546c65 : SUBVCS R6,R4,#&6500 ; 00025898 : 6c736e61 : LDCVSL CP14,C6,[R3],#-388 ; 0002589c : 6f697461 : SWIVS &697461 ; 000258a0 : 6261546e : RSBVS R5,R1,#&6E000000 ; 000258a4 : 0000656c : ANDEQ R6,R0,R12,ROR #10 ; 000258a8 : ff00001c : Undefined instruction ; 000258ac : e1a0c00d : MOV R12,R13 ; APCS function prologue. Push stack frame, check if stack extension is needed. 000258b0 : e92ddbe1 : STMDB R13!,{R0,R5-R9,R11,R12,R14,PC} ; 000258b4 : e24cb004 : SUB R11,R12,#4 ; 000258b8 : e15d000a : CMP R13,R10 ; 000258bc : 4b000c65 : BLMI &00028A58 ; 000258c0 : e5902028 : LDR R2,[R0,#40] ; Function body starts here 000258c4 : e1a05000 : MOV R5,R0 ; 000258c8 : e24dd00c : SUB R13,R13,#&0C ; 000258cc * e5920028 * LDR R0,[R2,#40] ; 000258d0 : e1a0300d : MOV R3,R13 ; 000258d4 : e28d2004 : ADD R2,R13,#4 ; 000258d8 : e3a01009 : MOV R1,#9 ; You’ll note that it crashes on the second load instruction of the function. The very first line of code in SetupPixelTranslationTable is this: if ( ( e = xos_read_mode_variable( thisWindow->displaySprite->mode, os_MODEVAR_LOG2_BPP, &log2bpp, &junk)) != NULL) { Load thisWindow→displaySprite (
Returning R4=0 is ColourTrans’ way of telling you that you don’t need a table. “ColourTrans, how much memory do I need to allocate for a translation table?” “Zero.”
Yes; if you don’t need a translation table then you should just pass a null pointer into OS_SpriteOp. (But just because the colour depths or pixel formats match doesn’t meant that you don’t need a table – e.g. 8bpp)
I don’t know – what problem is it working around? The way you’re using ColourTrans looks a bit unusual to me, but I don’t think there’s anything wrong with it. Possibly the funny behaviour you saw was a result of the null pointer. |
Tim Rowledge (1742) 170 posts |
Blech. If thisWindow→displaySprite is 0 then at some point the creation of the Sprite or possibly the selection of it with xosspriteop_select_sprite() failed…. or wait a minute… If that is actually the sequence (and I haven’t had to do anything with this code since about 2004 so it’s a while since I thought about it) then it could only ever work properly on the second and subsequent times the sprite gets (re)created. Which would be so damn wrong… As for the fudge and some problem with generate table, your guess may be as good as mine. It dates back to at least 2004 and probably something read on one or other of the contemporary net resources for RISC OS. Google is not my friend on this. |
Rick Murray (539) 13840 posts |
Makes an ass out of just me? It’s not bad. Together we’ve identified two sources of potential null pointer problems. ;-) |
Tim Rowledge (1742) 170 posts |
perhaps the smart start is for Rick to send a skype request to me – timrowledge – and we’ll see if we can work out how to get a compile going |
Rick Murray (539) 13840 posts |
…uh… I’ve not touched Skype since Microsoft embraced it and subsequently broke it. Never used it much anyway. Logging into Arcade BBS and sending me a message (I’m user #427) is more my speed. ;-) |
Tim Rowledge (1742) 170 posts |
Guys, you’re not exactly making it easy for me to try to help here. I persuaded my ancient Pi 1 with broken SD card holder and old SD with RISC OS to boot. So in theory I might be able to build a new VM with the old whatevers are on the original NutPi/DDE stuff. |
Rob Andrews (112) 164 posts |
I have a Pi going if you need it but sending it from Aus will cost more than buying a new one is there any one in the uk that can borrow/give you a Pi so that you can do the work?? |
Steve Pampling (1551) 8170 posts |
Ah, so your DDE copy is relatively new. I was thinking it was a pre-Pi revision. In general I see no major obstacle to you doing a recompile. Just a suggestion, but perhaps you could put up a copy of the source in a zip at the same location as the zip archives with the binaries as I think Ricks main issue was pulling a full source copy. Bear in mind he has RO machines and an elderly XP machine only. |
Tim Rowledge (1742) 170 posts |
Rob, that’s a very kind offer but rest assured that I have many, many, Pis. I do only have a single original Pi 1 that still works though, and that is what is needed since all my RISC OS work is on a full size SD card. Steve, yes I guess that might be part of a path for Rick. The bigger part of the job is making sure I remember everything needed to be able to build; OSLib, rink, various modules, the path setup etc. The last build I see on my machine is March 2013, so anything that has changed since then that could affect the process will be an issue to work around. |
Tim Rowledge (1742) 170 posts |
So, at last I have a Pi 2 running ROS and connected to my net. I have no idea why it would connect at first, nor second, nor third etc but something unknown made it suddenly decide to do the dhcp dance. I transferred everything I could from the old Pi1. Trying to compile anything results in a whine about ’this program can only be run on a raspberry Pi. It is on a Raspberry Pi. |
Steve Fryatt (216) 2105 posts |
NutPi is tied to the Pi hardware, and IIRC there was an upgrade (or second edition) which recognised the Pi 2. It might be a choice of update your version, or stick to the Pi 1. |
Tim Rowledge (1742) 170 posts |
I can’t stick to the Pi 1 because it is becoming unreliable – a combination of a broken card holder and a dying SD card. |
Doug Webb (190) 1180 posts |
Hi Tim Thanks for sticking with this. Firstly how did you set up the NutPi DDE on your new Pi2/SDCard. Did you use the !PiCopy utlility found in the DDE24 zip file on the NutPi SD or just copy some things over as the routines does set things up. Secondly someone on here posted that the DDE on the origonally NutPi did load on a Pi2 but that may have may been the origonal Pi2 with the older processor. Finally one of the ROOL news announcements mentioned that those who had a NutPi DDE could upgrade it for a small fee so it may that is an option as per below:
If not come back to us and we will see what other help we can give. |
Doug Webb (190) 1180 posts |
Tim Another thought did you do the following once you copied over the DDE contents?
|
Tim Rowledge (1742) 170 posts |
Sadly, it made no differnce |
Doug Webb (190) 1180 posts |
Ok, sounds like you have a Pi2 B v1.2 with the new processor which is a A57 variant. The DDE must check it is running on a Pi by looking at the system and hence the older NutPi version can’t run as it does not have the newer v1.2 processor/system it it’s code. You could try updating the DDE as per the news arcticle I quoted or see if you have a older v1.1 Pi2 B with a BCM2836 SOC or better still a Pi1 B+ which has a Micro Sd slot in your collection. |