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
#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;
}
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.
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
#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;
}
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
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:~#
@pnru_gitlab How do you think we should implement sleep in the lcc library?
See here for some ideas. Untested 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