Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Lawrie Griffiths
    @lawrie
    With those in place, the lcc-complied assembler seems to produce the same output as the gcc-compiled one.
    root@buildroot:~# as -o as.o as.s
    Assembling module 'as.s'...
    root@buildroot:~# ./a.out -o as1.o as.s
    Assembling module 'as.s'...
    root@buildroot:~# diff as.o as1.o
    Lawrie Griffiths
    @lawrie
    And the lcc-compiled one is faster:
    root@buildroot:~# time ./lccas -o as1.o as.s
    Assembling module 'as.s'...
    real    0m 2.28s
    user    0m 2.11s
    sys    0m 0.17s
    root@buildroot:~# time as -o as1.o as.s
    Assembling module 'as.s'...
    real    0m 3.01s
    user    0m 2.80s
    sys    0m 0.17s
    emard
    @emard
    https://github.com/emard/tetris4terminals HI I found some low level tetris and lcc compiles it but to be playable it needs non-blocking getchar and putchar. Can LCC do it - if not dont make too much development prilority for this, its just a ugly game
    Paul Ruiz
    @pnru_gitlab

    @lawrie: that is a great result! What was the issue with the fail on fputc? In any case, as is a non-trivial 3,000 line C program. That it compiles and works correctly gives a lot of confidence in what we have now. Maybe the gcc version will be faster if compiled with -O2.

    @emard: I think the game code needs raw input as well as non-blocking. What the current LCC lib offers is ioctl() and you can use it to achieve both, I think.

    drr
    @danrr_au_twitter

    interesting ISSI vs. winbond flash differences in this chat, I'd like to confirm that my stuff (doesn't) work on the ISSI but I only have a blue winbond board here

    @emard do you know if the ISSI parts on the ULX are preconfigured to have the QE enabled by default, if that's possible? I know for the winbond ones you can order them that way but otherwise the QE configuration must be done before trying quad cmds

    emard
    @emard
    @pnru_gitlab yes yes code has some size and everything works the same as compiled on gcc/PC :) so it's a proof lcc is doing very well. Instead of non-blocking probably also interrupt on incoming char or timer will make it. OK I can try few simple tricks on PC first and then the same on LCC
    emard
    @emard
    @danrr_au_twitter flash is nasty because it has memory that will never forget unless explicitely erased :). All of them were bought the same from Mouser, no factory preload of course. Quad can be enabled in the bitstream. FPGA first starts loading it in 1-bit mode slow and then depending on bitstream, switches to Quad and clocks faster. I have used many of them but usually only passthru and selftest and I avoid enabling Quad because then re-flashing from jtag becomes difficult. This flash is never used directly, but thru FPGA with either JTAG-SPI module or USRMCLK module
    I wouldn't say flash has entered quad mode because after failing saxonsoc bitstream, I upload passthru over jtag and from ecp5.py I can continue to talk to flash in 1-bit mode
    Lawrie Griffiths
    @lawrie
    @pnru_gitlab I don't know exactly what was causing the fputc crash. fputc was working on the other two files. When I commented it out for the output file, I got crashes in other uses of the output files. I thought it might be something to do with lseek and fixing lseek fixed it.
    emard
    @emard
    @danrr_au_twitter how do I compile on ulx3s (or can you just provide flash image for 85F+32MB SDRAM)
    make ulx3s_prog
    Makefile:176: icestation-32/software/common/core.mk: No such file or directory
    make: *** No rule to make target 'icestation-32/software/common/core.mk'.  Stop.
    emard
    @emard
    @pnru_gitlab is select() and termios available?
    drr
    @danrr_au_twitter

    @emard Need the submodule cloned to get that file:

    git submodule update --init --recursive
    make ulx3s_prog

    this works for me on a fresh clone, otherwise please share the error and I can make the bit / flash

    emard
    @emard
    OK that countinued but complained on make: riscv-none-embed-cpp: but I have riscv64-linux-gnu-gcc so I will try to fix it later it will probably work
    not, now 28 | # error "rv32i-based targets are not supported"
    better the bitstream if we just need to check flash
    drr
    @danrr_au_twitter
    fujprog -j flash -f 0x200000 prog.bin
    fujprog ulx3s.svf
    @emard This works on my 85F + WInbond. SDRAM is not used.
    emard
    @emard
    Small detail - I dont have DVI monitor here. If I plug 3.5mm earphones should I hear music?
    or some LEDs blinking
    Lawrie Griffiths
    @lawrie
    @emard No I have not implemented the select system call and termios is not implemented.
    emard
    @emard
    currently all LEDs off
    @lawrie OK... I will first try on gcc to at least make it work to know its good then we can try to find replacement on lcc
    drr
    @danrr_au_twitter
    no music on that one @emard as flash image is quite big, when the bitstream starts, you should hear sound effects after waiting maybe 10 seconds. don't need to press any buttons.
    if it is mute then it's definitely not working
    emard
    @emard
    @danrr_au_twitter flashed but no leds, no sound.. :) could be ISSI issue :)
    I hear some tiny noise in earphones, seems as PWM tone generator is running or initialized but no sound effects definitely
    drr
    @danrr_au_twitter

    yeah probably is, thanks for confirming. the sound effects are pretty loud when just plugging in headphones so it is noticable

    My plan is to use the standard JEDEC ID cmd in the boot code and do any vendor specific stuff when I know which vendor flash is on board, should be no problem

    emard
    @emard
    Yes, as little SPI commands to flash as possible, that is better. 0x3 or 0xB for reading must always work. Initialization maybe 0xAB and thats all. FPGA will anyway talk to flash at power up and already read it
    Lawrie Griffiths
    @lawrie
    @emard I think you need to buildroot version of the gcc riscv cross-compiler to compile things that run on SaxonSoc Linux. Other versions of riscv32 or riscv64 are likely to have a c library that is not compatible. That was the only compiler that worked for me.
    @pnru_gitlab @emard I did some tests of ioctl:
    emard
    @emard
    Yes, thats on my todo-install to sandbox virtual somehow
    Lawrie Griffiths
    @lawrie
    #include <stdio.h>
    #include <unistd.h>
    #include <errno.h>
    
    #define KDGETMODE        0x4B3B
    #define KDSETMODE        0x4B3A 
    #define FIONBIO      21537
    
    int main() {
      int r;
      int mode;
      char buf[2];
    
      buf[1] = 0;
    
      mode = 0;
      r = ioctl(0, FIONBIO, &mode);
    
      printf("Result: %d\n", r);
      printf("errno: %d\n", errno);
    
      do {
        r = read(0, buf, 1);
        if (r > 0)  printf("key is %d\n", buf[0]);
      } while (r <= 0);
    
      printf("r is %d\n", r);
    
      mode = 0;
      r = ioctl(0, FIONBIO, &mode);
    
      return 0;
    }
    emard
    @emard
    tetris needs to read keyboard and timeout if no key to redraw screen. It could be blocking.
    So the select call is kinda ideal but I can take yours example and try what can be done
    Lawrie Griffiths
    @lawrie
    That sets it to no-blocking but the terminal still buffers characters. You can't use KDSETMODE as that gives #define ENOTTY 25 /* Not a typewriter */.
    KDSETMODE to RAW would return key scan codes if we were using a real console and keyboard, but does not work on the uart console.
    emard
    @emard
    Buffering is desireable
    Lawrie Griffiths
    @lawrie
    It makes it harder to use arrow keys and you have to press enter after every key.
    emard
    @emard
    :) arrows are replaced by jkl single chars. I can update gcc repository
    gcc at least is working now (select termios). Edit source for NONBLOCKING 0 that will replace just sleep(1) instead of getchar to preview that game logic works but no keys then
    Lawrie Griffiths
    @lawrie
    My examples program can be used after setting stty raw and then ascii keys are sent without having to press enter.
    emard
    @emard
    that should be good workaround. And is there some timeout that is for example 1 second if no key pressed, but immediately aborts timeout on first pressed key. Thats how tetris must work
    Or maybe not really always but thats the first approximation :)
    anways I can later take your example and try to fit :)
    Paul Ruiz
    @pnru_gitlab

    Are you sure that Saxon Linux says that serial is not a TTY? That would be odd in a historical context, where all TTY's were connected via a serial line...

    To set a TTY to raw input mode with ioctl() see this page that explains it in great detail (but is a quick and pleasant read). The call tcgetattr(fd, &termcfg) can be replaced by ioctl(fd, TCGETS, &termcfg) (or TCSETSW for tcsetattr).
    The definitions for termios are e.g. here:
    https://code.woboq.org/gcc/include/bits/termios.h.html
    The Tetris source code has something similar to this in the vt100_initialize subroutine.

    Lawrie Griffiths
    @lawrie
    include <stdio.h>
    #include <unistd.h>
    #include <errno.h>
    
    #define KDGETMODE        0x4B3B
    #define KDSETMODE        0x4B3A 
    
    int main() {
      int r;
      int mode;
    
      r = ioctl(0, KDGETMODE, &mode);
    
      printf("Result: %d\n", r);
      printf("errno: %d\n", errno);
    
      return 0;
    }
    root@buildroot:~# ./a.out
    Result: -1
    errno: 25