s-macke / jor1k

Online OR1K Emulator running Linux
http://jor1k.com
BSD 2-Clause "Simplified" License
1.73k stars 193 forks source link

new jor1k and cs-education boot bug #131

Open remisharrock opened 6 years ago

remisharrock commented 6 years ago

Hi, could you help me, I tried to use the newest version of jor1k with a modified version of cs-education and the bootup of jor1k is freezing until I hit multiple times 'ENTER' in the terminal.

Here is a video to show the freeze and how I have to type ENTER multiple times to finish the bootup.

https://youtu.be/_rgFVUmC-Hk

Here is the source code:

https://github.com/remisharrock/sysbuild/tree/newjor1kfromcseducation

and the readme to run the code:

https://github.com/remisharrock/sysbuild/blob/newjor1kfromcseducation/README.md

Thank you!

remisharrock commented 6 years ago

Thanks Lawrence Angrave for your reply, here is your guess that you mentioned in your email (my answer below):

The frontend code setup wait logic can be found in sys-runtime.js. I'd guess it is this logic that will need to be tweaked. In your fork I'd start with this file- https://github.com/remisharrock/sysbuild/blob/master/webapp/src/app/sys-runtime.js

e.g. I see the 'wait requirements' here, which waits for the prompt to appear. this.sendKeys('tty0', '', '~ $', onTTY0Login);

this.sendKeys('tty1', '', '~ #', onTTY1Login);

Notice it waits for TWO terminals to be ready. Perhaps the new default jor1k instance only starts one, or maybe the settings use to initialize the terminal, stty -clocal crtscts -ixoff echo boot2ready-$?

are no longer valid with the newer jor1k build and returning stty is non-zero value.

Also the frontend code waits for the ready string "boot2ready-0" to be printed by both terminals before continuing.

Notice the communication with the kernel is actually through a simple narrow interface - just a serial tty. You may wish to instrument the initialization steps in sys-runtime.js using console.log messages to understand the setup process and find out why the extra returns are required. :-)

Hopefully this is enough to help debug the problem.

I tried to do an almost empty sys-runtime.js that is available here https://github.com/remisharrock/sysbuild/blob/63dbfc7baa1d34289977e2d54bac142d8cdb2a3f/webapp/src/app/sys-runtime.js

As you can see, everything is commented except the this.jor1kgui = new Jor1k(jor1kparameters); and the jor1kparameters definition.

I still have the same issue that you can see here https://youtu.be/J_TxJck0kkw

In the video, you can see that error looping in the terminal.

ata1: lost interrupt (Status 0x58)
ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
ata1.00: failed command: READ SECTOR(S)
ata1.00: cmd 20/00:10:00:00:00/00:00:00:00:00/e0 tag 0 pio 8192 in
res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x4 (timeout)
ata1.00: status: { DRDY }
ata1: soft resetting link
ata1.00: configured for PIO
ata1.00: device reported invalid CHS sector 0
ata1: EH complete

To stop the loop, I have to press ENTER exactly 5 times, then the boot continues and finishes correctly:

sda: detected capacity change from 0 to 65536
sd 0:0:0:0: [sda] Attached SCSI disk
VFS: Mounted root (9p filesystem) readonly on device 0:12.
devtmpfs: mounted
Freeing unused kernel memory: 136K (c054e000 - c0570000)
sda: detected capacity change from 0 to 65536
-login[50]: root login on 'ttyS1'

I'm cross-referencing the bug here https://github.com/cs-education/sysbuild/issues/175 Narrowing the problem, hope I can get it fixed !

s-macke commented 6 years ago

I cannot start the server to reproduce the problem. I get

 #  gulp serve
[22:42:27] Requiring external module babel-register
/var/www/vhosts/jor1k.com/httpdocs/sysbuild/webapp/gulpfile.babel.js:1
(function (exports, require, module, __filename, __dirname) { import fs from 'fs';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:152:10)
    at Module._compile (module.js:605:28)
    at loader (/var/www/vhosts/jor1k.com/httpdocs/sysbuild/webapp/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/var/www/vhosts/jor1k.com/httpdocs/sysbuild/webapp/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)
    at Function.Module._load (module.js:495:3)
    at Module.require (module.js:585:17)
    at require (internal/module.js:11:18)
s-macke commented 6 years ago

Can you try to comment following lines in jor1k-worker-min.js please

   7441             if (doze) { // doze
   7442                 doze = 0x0;
   7443                 if ((raise_interrupt|0) == 0)
   7444                 if (!(TTMR & (1 << 28))) {
   7445                     return steps|0;
   7446                 }
s-macke commented 6 years ago

or try the gh-pages branch please. I guess it has to do with timing changes and the idle mode of jor1k.

remisharrock commented 6 years ago

I cannot start the server to reproduce the problem.

@s-macke Did you npm install before gulp serve ?

@s-macke try the gh-pages branch : IT WORKED IT WORKED !! So happy! So it is the difference between gh-pages and the master branch (maybe the code you found in fastcpu.js right ? - have to do some testing if you want more detailed feedback) Anyway the problem is gone with the gh-pages branch !!

remisharrock commented 6 years ago

@s-macke It looks like if I use the master branch, even if I comment

   7441             if (doze) { // doze
   7442                 doze = 0x0;
   7443                 if ((raise_interrupt|0) == 0)
   7444                 if (!(TTMR & (1 << 28))) {
   7445                     return steps|0;
   7446                 }

it does not work. But if I use gh-pages, it works !

s-macke commented 6 years ago

I have reverted the patch and also updated some libs. I hope to get gdb running soon.