Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    drr
    @danrr_au_twitter
    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
    Paul Ruiz
    @pnru_gitlab
    Ah, I read up on KDGET/SETMODE and it is for the console only. It uses ENOTTY to signal that the device is not a console TTY.
    Lawrie Griffiths
    @lawrie
    This works quite well:
    #include <stdio.h>
    #include <unistd.h>
    #include <errno.h>
    
    #define FIONBIO      0x5421
    
    #define TCGETS           0x5401
    #define TCSETS           0x5402
    
    #define ECHO             0000010
    #define ICANON           0000002
    
    typedef unsigned char    cc_t;
    typedef unsigned int     speed_t;
    typedef unsigned int     tcflag_t;
    
    #define NCCS             32
    
    struct termios {
        tcflag_t c_iflag;                /* input mode flags */
        tcflag_t c_oflag;                /* output mode flags */
        tcflag_t c_cflag;                /* control mode flags */
        tcflag_t c_lflag;                /* local mode flags */
        cc_t c_line;                     /* line discipline */
        cc_t c_cc[NCCS];                 /* control characters */
        speed_t c_ispeed;                /* input speed */
        speed_t c_ospeed;                /* output speed */
    #define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
    #define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
      };
    
    int main() {
      int r;
      int mode;
      char buf[2];
      struct termios raw, orig;
    
      buf[1] = 0;
    
      r = ioctl(0, TCGETS, &orig);
      raw = orig;
    
      raw.c_lflag &= ~(ECHO | ICANON);
    
      r = ioctl(0, TCSETS, &raw);
    
      mode = 1;
      r = ioctl(0, FIONBIO, &mode);
    
      do {
        r = read(0, buf, 1);
        if (r > 0)  {
          printf("key is %d\n", buf[0]);
          if (buf[0] == 'q') break;
        } else write(1,"!",1);
      } while (1);
    
      mode = 0;
      r = ioctl(0, FIONBIO, &mode);
    
      r = ioctl(0, TCSETS, &orig);
    
      return 0;
    }
    Dolu1990
    @Dolu1990
    Got I2C on linux using the i2c-gpio driver to work
    I mean, i can the the frame XD
    didn't test with real slave
    Lawrie Griffiths
    @lawrie
    What pins are you using it on? To access the RTC, we will need to make the RTC pins gpioA pins in the lpf file.
    LOCATE COMP "system_hdmiPhy_gpdi_sda" SITE "B19"; # I2C shared with RTC
    LOCATE COMP "system_hdmiPhy_gpdi_scl" SITE "E12"; # I2C shared with RTC C12->E12
    Dolu1990
    @Dolu1990
    I was currently testing on arty A7, i'm now porting it to Ulx3s on those pins
    on ulx
    Lawrie Griffiths
    @lawrie
    @pnru_gitlab How do you think we should implement sleep in the lcc library?
    Dolu1990
    @Dolu1990
    For the RTC, is there anything special to configure on the board to get it alive on I2C ?
    should work without battery i guess
    emard
    @emard
    No board immediately has i2c to RTC. It is called in my constraints gpdi_sda, gpdi_scl. Its not only gpdi but it is shared bus with GPDI and RTC. Maybe I could just have called it i2c_sda i2c_scl :)
    Dolu1990
    @Dolu1990
    Rawrrr
    root@buildroot:~# i2cdetect -y 0
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 6f 
    70: -- -- -- -- -- -- -- --                         
    root@buildroot:~#
    emard
    @emard
    RTC completey works without battery but of course wont keep time after power off
    Yes 0x6F is RTCs address :)
    This is very promising for RTC and shutdown/wakeup capability :)
    Paul Ruiz
    @pnru_gitlab

    @pnru_gitlab How do you think we should implement sleep in the lcc library?

    See here for some ideas. Untested code.

    Dolu1990
    @Dolu1990
    apparently there is a driver in linux for that rtc (rtc-ds1307.c)
    emard
    @emard
    :) maybe a compatible enough one, as we have MCP7940N (microchip). Most of them RTC are very similar and have important time registers with equal meaning
    our RTC has to be initialized to start ticking. Power on default without battery is to "boot" as stopped.
    Dolu1990
    @Dolu1990
    got the rtc to start counting seconds and read it via :
    i2cset -y 0 0x6F 0x00 0x80
    sleep 4
    i2cget -y 0 0x6F 0x00
    emard
    @emard
    eheheheee it is great, it works!
    Uninitialized RTC outputs 32768Hz to boards internal wakeup pin. In this state board cant shutdown. RTC has to be initialized as alarm in future and its flag cleared, then it is possible that board sleeps in power off until alarm triggers
    Lawrie Griffiths
    @lawrie
    @pnru_gitlab Here is a test of your sleep code:
    #include <stdio.h>
    
    extern int sleep(int sec);
    extern int usleep(int usec);
    
    int main() {
      printf("Sleep for 2 seconds\n");
      sleep(2);
      printf("Sleep for 1M microseconds\n");
      usleep(1000000);
    
      return 0;
    }
    
    root@buildroot:~# time ./a.out
    Sleep for 2 seconds
    Sleep for 1M microseconds
    real    0m 3.02s
    user    0m 0.00s
    sys    0m 0.01s