Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

picocom for elks? #1968

Open
RNRetailer opened this issue Aug 20, 2024 · 3 comments
Open

picocom for elks? #1968

RNRetailer opened this issue Aug 20, 2024 · 3 comments

Comments

@RNRetailer
Copy link

Hi,

Has anyone made picocom for elks?

I tried to port it but the compilation step is failing.

Here is my repo:
https://github.com/RNRetailer/picocom-elks/

Thanks!

@ghaerr
Copy link
Owner

ghaerr commented Sep 3, 2024

Sorry for my late response @RNRetailer, I missed this issue and it must have gotten lost in the shuffle.

Have you tried running miniterm, this is very similar and currently running on ELKS.

I tried to port it but the compilation step is failing.

Please post your compilation output so that we can help, otherwise we'd just be guessing as to a problem.

Thank you!

@RNRetailer
Copy link
Author

ELKS miniterm didn't seem to have a good way to transfer files to and from the remote server.
I only saw options to log into a serial console.

I disabled linenoise support and tried to compile picocom.

Here is the resulting output:

make --always-make
Makefile:117: warning: overriding recipe for target '.c.o'
Makefile:54: warning: ignoring old recipe for target '.c.o'
../prefix/bin/ia16-elf-gcc -ffreestanding -fno-inline -mtune=i8086 -mno-segment-relocation-stuff -mcmodel=small -I/include -I/libc/include -I/elks/include -I../prefix/include -D__LIBC__ -Wall -Os  -Wall -g -DVERSION_STR=\"3.1\" -DTTY_Q_SZ=0 -DHIGH_BAUD -DUSE_FLOCK -o picocom.o -c picocom.c
cc1: warning: target system does not support debug output
picocom.c: In function ‘cleanup’:
picocom.c:741:13: warning: implicit declaration of function ‘flock’ [-Wimplicit-function-declaration]
             flock(tty_fd, LOCK_UN);
             ^~~~~
picocom.c:743:13: warning: implicit declaration of function ‘close’ [-Wimplicit-function-declaration]
             close(tty_fd);
             ^~~~~
picocom.c: In function ‘establish_child_signal_handlers’:
picocom.c:1128:44: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     dfl_action._signal_handlers.sa_handler = SIG_DFL;
                                            ^
picocom.c:1129:5: warning: implicit declaration of function ‘sigemptyset’ [-Wimplicit-function-declaration]
     sigemptyset (&dfl_action.sa_mask);
     ^~~~~~~~~~~
picocom.c:1132:5: warning: implicit declaration of function ‘sigaction’ [-Wimplicit-function-declaration]
     sigaction (SIGINT, &dfl_action, NULL);
     ^~~~~~~~~
picocom.c: In function ‘run_cmd’:
picocom.c:1150:5: warning: implicit declaration of function ‘sigaddset’ [-Wimplicit-function-declaration]
     sigaddset(&sigm, SIGTERM);
     ^~~~~~~~~
picocom.c:1152:5: warning: implicit declaration of function ‘sigprocmask’ [-Wimplicit-function-declaration]
     sigprocmask(SIG_BLOCK, &sigm, &sigm_old);
     ^~~~~~~~~~~
picocom.c:1154:11: warning: implicit declaration of function ‘fork’ [-Wimplicit-function-declaration]
     pid = fork();
           ^~~~
In file included from picocom.c:39:0:
../prefix/include/sys/wait.h:57:28: warning: implicit declaration of function ‘__WIFEXITED’ [-Wimplicit-function-declaration]
 # define WIFEXITED(status) __WIFEXITED (status)
                            ^
picocom.c:1174:14: note: in expansion of macro ‘WIFEXITED’
         if ( WIFEXITED(status) ) {
              ^~~~~~~~~
../prefix/include/sys/wait.h:54:30: warning: implicit declaration of function ‘__WEXITSTATUS’ [-Wimplicit-function-declaration]
 # define WEXITSTATUS(status) __WEXITSTATUS (status)
                              ^
picocom.c:1176:23: note: in expansion of macro ‘WEXITSTATUS’
                       WEXITSTATUS(status));
                       ^~~~~~~~~~~
../prefix/include/sys/wait.h:58:30: warning: implicit declaration of function ‘__WIFSIGNALED’ [-Wimplicit-function-declaration]
 # define WIFSIGNALED(status) __WIFSIGNALED (status)
                              ^
picocom.c:1178:21: note: in expansion of macro ‘WIFSIGNALED’
         } else if ( WIFSIGNALED(status) ) {
                     ^~~~~~~~~~~
../prefix/include/sys/wait.h:55:27: warning: implicit declaration of function ‘__WTERMSIG’ [-Wimplicit-function-declaration]
 # define WTERMSIG(status) __WTERMSIG (status)
                           ^
picocom.c:1180:23: note: in expansion of macro ‘WTERMSIG’
                       WTERMSIG(status));
                       ^~~~~~~~
picocom.c:1199:14: warning: implicit declaration of function ‘fcntl’ [-Wimplicit-function-declaration]
         fl = fcntl(fd, F_GETFL);
              ^~~~~
picocom.c:1205:9: warning: implicit declaration of function ‘dup2’ [-Wimplicit-function-declaration]
         dup2(fd, STI);
         ^~~~
picocom.c:1230:9: warning: implicit declaration of function ‘execvp’ [-Wimplicit-function-declaration]
         execvp(argv[0], argv);
         ^~~~~~
picocom.c: In function ‘loop’:
picocom.c:1518:21: warning: implicit declaration of function ‘read’ [-Wimplicit-function-declaration]
                 n = read(STI, buff_rd, sizeof(buff_rd));
                     ^~~~
picocom.c:1600:21: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
                 n = write(tty_fd, tty_q.buff, sz);
                     ^~~~~
picocom.c: In function ‘deadly_handler’:
picocom.c:1621:9: warning: implicit declaration of function ‘kill’ [-Wimplicit-function-declaration]
         kill(0, SIGTERM);
         ^~~~
picocom.c: In function ‘main’:
picocom.c:2120:18: warning: implicit declaration of function ‘open’ [-Wimplicit-function-declaration]
         log_fd = open(opts.log_filename,
                  ^~~~
picocom.c:2178:14: warning: implicit declaration of function ‘isatty’ [-Wimplicit-function-declaration]
         if ( isatty(STI) ) {
              ^~~~~~
../prefix/bin/ia16-elf-gcc -ffreestanding -fno-inline -mtune=i8086 -mno-segment-relocation-stuff -mcmodel=small -I/include -I/libc/include -I/elks/include -I../prefix/include -D__LIBC__ -Wall -Os  -Wall -g -DVERSION_STR=\"3.1\" -DTTY_Q_SZ=0 -DHIGH_BAUD -DUSE_FLOCK -o term.o -c term.c
cc1: warning: target system does not support debug output
term.c:205:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 115200, B115200 },
       ^~~~~~
term.c:208:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 230400, B230400 },
       ^~~~~~
term.c:211:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 460800, B460800 },
       ^~~~~~
term.c:214:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 500000, B500000 },
       ^~~~~~
term.c:217:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 576000, B576000 },
       ^~~~~~
term.c:220:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 921600, B921600 },
       ^~~~~~
term.c:223:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 1000000, B1000000 },
       ^~~~~~~
term.c:226:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 1152000, B1152000 },
       ^~~~~~~
term.c:229:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 1500000, B1500000 },
       ^~~~~~~
term.c:232:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 2000000, B2000000 },
       ^~~~~~~
term.c:235:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 2500000, B2500000 },
       ^~~~~~~
term.c:238:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 3000000, B3000000 },
       ^~~~~~~
term.c:241:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 3500000, B3500000 },
       ^~~~~~~
term.c:244:7: warning: overflow in implicit constant conversion [-Woverflow]
     { 4000000, B4000000 },
       ^~~~~~~
term.c: In function ‘term_exitfunc’:
term.c:403:13: warning: implicit declaration of function ‘tcflush’ [-Wimplicit-function-declaration]
             tcflush(term.fd[i], TCIFLUSH);
             ^~~~~~~
term.c:405:21: warning: implicit declaration of function ‘tcsetattr’ [-Wimplicit-function-declaration]
                 r = tcsetattr(term.fd[i], TCSANOW, &term.origtermios[i]);
                     ^~~~~~~~~
term.c:410:25: warning: implicit declaration of function ‘ttyname’ [-Wimplicit-function-declaration]
                 tname = ttyname(term.fd[i]);
                         ^~~~~~~
term.c:410:23: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
                 tname = ttyname(term.fd[i]);
                       ^
term.c:424:13: warning: implicit declaration of function ‘flock’ [-Wimplicit-function-declaration]
             flock(term.fd[i], LOCK_UN);
             ^~~~~
term.c:426:13: warning: implicit declaration of function ‘close’ [-Wimplicit-function-declaration]
             close(term.fd[i]);
             ^~~~~
term.c: In function ‘term_lib_init’:
term.c:454:27: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
                     tname = ttyname(term.fd[i]);
                           ^
term.c: In function ‘term_add’:
term.c:495:16: warning: implicit declaration of function ‘isatty’ [-Wimplicit-function-declaration]
         if ( ! isatty(fd) ) {
                ^~~~~~
term.c:507:13: warning: implicit declaration of function ‘tcgetattr’ [-Wimplicit-function-declaration]
         r = tcgetattr(fd, &term.origtermios[i]);
             ^~~~~~~~~
term.c: In function ‘term_set_raw’:
term.c:781:9: warning: implicit declaration of function ‘cfmakeraw’ [-Wimplicit-function-declaration]
         cfmakeraw(&term.nexttermios[i]);
         ^~~~~~~~~
term.c: In function ‘term_set_baudrate’:
term.c:813:17: warning: implicit declaration of function ‘cfsetospeed’ [-Wimplicit-function-declaration]
             r = cfsetospeed(&tio, spd);
                 ^~~~~~~~~~~
term.c:820:13: warning: implicit declaration of function ‘cfsetispeed’ [-Wimplicit-function-declaration]
             cfsetispeed(&tio, B0);
             ^~~~~~~~~~~
term.c: In function ‘term_get_baudrate’:
term.c:860:20: warning: implicit declaration of function ‘cfgetispeed’ [-Wimplicit-function-declaration]
             code = cfgetispeed(&term.currtermios[i]);
                    ^~~~~~~~~~~
term.c:868:16: warning: implicit declaration of function ‘cfgetospeed’ [-Wimplicit-function-declaration]
         code = cfgetospeed(&term.currtermios[i]);
                ^~~~~~~~~~~
term.c: In function ‘term_pulse_dtr’:
term.c:1377:13: warning: implicit declaration of function ‘sleep’ [-Wimplicit-function-declaration]
             sleep(1);
             ^~~~~
term.c: In function ‘term_drain’:
term.c:1606:17: warning: implicit declaration of function ‘tcdrain’ [-Wimplicit-function-declaration]
             r = tcdrain(fd);
                 ^~~~~~~
term.c:1619:28: warning: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration]
         if ( DRAIN_DELAY ) usleep(DRAIN_DELAY);
                            ^~~~~~
term.c: In function ‘term_break’:
term.c:1729:13: warning: implicit declaration of function ‘tcsendbreak’ [-Wimplicit-function-declaration]
         r = tcsendbreak(fd, 0);
             ^~~~~~~~~~~
../prefix/bin/ia16-elf-gcc -ffreestanding -fno-inline -mtune=i8086 -mno-segment-relocation-stuff -mcmodel=small -I/include -I/libc/include -I/elks/include -I../prefix/include -D__LIBC__ -Wall -Os  -Wall -g -DVERSION_STR=\"3.1\" -DTTY_Q_SZ=0 -DHIGH_BAUD -DUSE_FLOCK -o fdio.o -c fdio.c
cc1: warning: target system does not support debug output
fdio.c: In function ‘writen_ni’:
fdio.c:48:18: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
             nw = write(fd, p, nl);
                  ^~~~~
fdio.c: In function ‘fd_readline’:
fdio.c:128:13: warning: implicit declaration of function ‘read’ [-Wimplicit-function-declaration]
         r = read(fdi, &c, 1);
             ^~~~
../prefix/bin/ia16-elf-gcc -ffreestanding -fno-inline -mtune=i8086 -mno-segment-relocation-stuff -mcmodel=small -I/include -I/libc/include -I/elks/include -I../prefix/include -D__LIBC__ -Wall -Os  -Wall -g -DVERSION_STR=\"3.1\" -DTTY_Q_SZ=0 -DHIGH_BAUD -DUSE_FLOCK -o split.o -c split.c
cc1: warning: target system does not support debug output
../prefix/bin/ia16-elf-gcc -ffreestanding -fno-inline -mtune=i8086 -mno-segment-relocation-stuff -mcmodel=small -I/include -I/libc/include -I/elks/include -I../prefix/include -D__LIBC__ -Wall -Os  -Wall -g -DVERSION_STR=\"3.1\" -DTTY_Q_SZ=0 -DHIGH_BAUD -DUSE_FLOCK -o termios2.o -c termios2.c
cc1: warning: target system does not support debug output
../prefix/bin/ia16-elf-gcc -ffreestanding -fno-inline -mtune=i8086 -mno-segment-relocation-stuff -mcmodel=small -I/include -I/libc/include -I/elks/include -I../prefix/include -D__LIBC__ -Wall -Os  -Wall -g -DVERSION_STR=\"3.1\" -DTTY_Q_SZ=0 -DHIGH_BAUD -DUSE_FLOCK -o custbaud_bsd.o -c custbaud_bsd.c
cc1: warning: target system does not support debug output
../prefix/bin/ia16-elf-gcc -mtune=i8086 -o picocom picocom.o term.o fdio.o split.o termios2.o custbaud_bsd.o 
/home/RNRetailer/Music/elks/picocomgithub/picocom-elks-http/prefix/bin/../lib/gcc/ia16-elf/6.3.0/../../../../ia16-elf/bin/ld: cannot find -l:crtbegin.o: No such file or directory
/home/RNRetailer/Music/elks/picocomgithub/picocom-elks-http/prefix/bin/../lib/gcc/ia16-elf/6.3.0/../../../../ia16-elf/bin/ld: cannot find -l:crtend.o: No such file or directory
/home/RNRetailer/Music/elks/picocomgithub/picocom-elks-http/prefix/bin/../lib/gcc/ia16-elf/6.3.0/../../../../ia16-elf/bin/ld: cannot find -l:dos-t-c0.o: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:107: picocom] Error 1

@ghaerr
Copy link
Owner

ghaerr commented Sep 4, 2024

Most of the compilation warnings can be readily fixed by including various required header files, like <unistd.h>, <sys/wait.h>, etc. The functions can be grepped for in libc/include/{,/*.h}.

ELKS doesn't support sigaction so those routines must be rewritten using the only signal, which usually isn't a big deal if the signal is just trying to be caught or ignored.

The termios functions tcflush, cfsetospeed, cfmakeraw etc are wrapper functions that are not (yet) implemented in ELKS, but a direct ioctl using the appropriate sub function will work - see elkscmd/misc_utils/miniterm.c for examples.

Looking at the baud rate value overflows it is evident that picocom.c thinks it should be compiled in 32-bit, there may be other non-portable to 16-bit portions of the program, so its guaranteed it will actually run until the source is more closely looked at. I would think it could be ported though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants