public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* RE: [ECOS] Nano using PDCurses for eCos
@ 2009-04-17  3:06 Steven Clugston
  2009-04-17 12:59 ` Sergei Gavrikov
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Clugston @ 2009-04-17  3:06 UTC (permalink / raw)
  To: eCos discuss list

[-- Attachment #1: Type: text/plain, Size: 3352 bytes --]

> If you just want to edit config files, it's better to implement own
> editor, call it `femto' then :-)
> http://en.wikipedia.org/wiki/SI_prefix
> It seems for me that nano is enough bloat stuff for eCos targets.

Nano does far more than I realised and I agree that most of it is bloat for what I need like calls to external programs for spell checking and wide character and NLS support etc, but it's a choice between writing an editor from scratch or hacking nano to work by disabling the bloat using its existing config mechanism. I think the latter should take less time/effort. It's a shame there's not a #define NANO_FEMTO mode to strip off even more than NANY_TINY does.

> Yesterday evening I did grab the latest stable nano sources (2.0.9)
> from here http://www.nano-editor.org, and tried to  > build it. After
> configure and some tweaks I got The GNU nano editor for the eCos
> i386linux target just in 110K using those PDCurses package and dummy
> driver.

> I should not have told about until a try. Steven, I have to finalize
> and test the build (at the least using eCos
> FS_RAM), I have to add the real terminal driver to PDCurses. I do hope this will occur the next weekend and then I will
> share a full story somewere on the web (some guys are nervious if they cannot read here only a digest about eCos kernel
> gears and cpu parts :-) There are a few hints the below

I know this is bordering on another general programming discussion, but its because of the issues which ecos throws up that I'm discussing it and it just might interest some other ecos user out there one day.

> I configured the nano as: --enable-tiny --disable-nls --disable-utf8;
> I have a bit tweaked config.h to point on that
> which things are absent in eCos, made a peace with Linux/GNU (pwd, mkstemp, signals, getopt) and I got the executable.
> There is alone rule in my eCos Makefile

>    ACTUAL_CFLAGS := $(subst , -DHAVE_CONFIG_H=1,$(ACTUAL_CFLAGS))

I've actually got nano 2.0.7 to compile to a binary with modifying any of the actual nano source. It seems to run on my PowerPC board now. I can't tell if it works yet as it doesn't accept any input, but the main screen fires up. For some reason my raw binary is around 413Kb which seems quite big, but I probably could have disabled more stuff in CDL like unneeded hardware packages.

Here's what I did:

I just ran configure on the source in Linux to get the basic config.h file and then modified that to disable most headers and things that are not present in ecos and enabled NANO_TINY as well.

To get the termios stuff and unix signals to compile I had to use the POSIX compatibility layer package and enable POSIX signals and disable the ISO C signals infrastructure.

I made a compat.h and compat.c to replace the missing function calls with dummy ones like you did with your TCL experiment.

I also 'borrowed' the GNU/Linux versions of strnlen.c and getopt.c for now. There's a CDL option to supply comandline args to main{}, so maybe an ecos implementation of getopt() might be useful to have in a compatability package or something.

No doubt that it will come off the rails as soon as it hits one of the dummy calls, but hopefully with some more work it will be able to load a file off a jffs2 partition, edit it, and save it back.

Steven


[-- Attachment #2: compat.c --]
[-- Type: text/plain, Size: 880 bytes --]

#include <errno.h>
#include "compat.h"

int lstat(const char* f,struct stat* b){return stat(f,b);}
mode_t umask(mode_t mask){errno=ENOTSUP;return(-1);}
int execvp(){errno=ENOTSUP;return(-1);}
int execlp(const char *file, const char *arg, ...){errno=ENOTSUP;return(-1);}
pid_t fork(){errno=ENOTSUP;return(-1);}
//kill(){errno=ENOTSUP;return(-1);}
pid_t wait(int status){CYG_UNUSED_PARAM(int,status);errno=ENOTSUP;return(-1);}
int pipe(int pipefd[2]){errno=ENOTSUP;return(-1);}
char *mktemp(char *template){errno=ENOTSUP;return(0);}
int mkstemp(char *template){errno=ENOTSUP;return(0);}
struct passwd *getpwnam(){errno=ENOTSUP;return(0);}
struct passwd *getpwent(void){errno=ENOTSUP;return(0);}
struct passwd *getpwuid(uid_t uid){CYG_UNUSED_PARAM(uid_t,uid);errno=ENOTSUP; return(0);}
pid_t waitpid(pid_t pid, int *status, int options){errno=ENOTSUP;return(-1);};
void endpwent(){}

[-- Attachment #3: compat.h --]
[-- Type: text/plain, Size: 1223 bytes --]

#ifndef CYGONCE_NANO_COMPAT_H
#define CYGONCE_NANO_COMPAT_H
//#include <errno.h>
//#include <unistd.h>
#include <sys/stat.h>
struct passwd
{
};

#define P_tmpdir "/tmp"
#define   SIGCONT         18      /* Continue (POSIX).  */
#define SIGSTOP         19      /* Stop, unblockable (POSIX).  */
#define   SIGTSTP         20      /* Keyboard stop (POSIX).  */

int getopt(int argc, char * const argv[], const char *optstring);
size_t strnlen(const char *s, size_t maxlen);
extern char *optarg;
extern int optind, opterr, optopt;

//isascii(c){return((unsigned)(c)<=0200);}
int lstat(const char* f,struct stat* b);
mode_t umask(mode_t mask);

//readlink(p,b,s){int 
//n,f;if(f=open(p,1)==-1)return(-1);n=read(f,b,s);close(f);return(n);}
//char *mktemp(char *template);
int mkstemp(char *template);
//struct passwd *getpwnam(const char *name);
struct passwd *getpwent(void);
void endpwent(void);
struct passwd *getpwuid(uid_t uid);
//int execvp(const char *file, char *const argv[]);
int execlp(const char *file, const char *arg, ...);
pid_t fork(void);
//kill(){errno=ENOTSUP;return(-1);}
//pid_t wait(int *status);
pid_t waitpid(pid_t pid, int *status, int options);
//int pipe(int pipefd[2]);
#endif //CYGONCE_NANO_COMPAT_H

[-- Attachment #4: Type: text/plain, Size: 148 bytes --]

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [ECOS] TUI: PDCurses for eCOS
@ 2009-03-24 21:16 Sergei Gavrikov
  2009-04-15 10:48 ` [ECOS] Nano using PDCurses for eCos Steven Clugston
  0 siblings, 1 reply; 5+ messages in thread
From: Sergei Gavrikov @ 2009-03-24 21:16 UTC (permalink / raw)
  To: Steven Clugston; +Cc: eCos discuss list

Steven Clugston wrote:
> I've been wanting to do a port of a minimal console text editor
> something like nano or pico to eCos to do on board editing of
> configuration files to be storred in flash. I've not had time to look
> into it yet, but as nano (as far as I remember) uses ncurses, this
> might be just the thing to get the ball rolling.

I brief check the latest nano sources at the least they have

~/repo/nano$ grep -li pdcurses *
BUGS
ChangeLog.pre-2.1
NEWS

~/repo/nano/src$ grep -i pdcurses *
winio.c:#ifdef PDCURSES

Sergei

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-04-17 12:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-17  3:06 [ECOS] Nano using PDCurses for eCos Steven Clugston
2009-04-17 12:59 ` Sergei Gavrikov
  -- strict thread matches above, loose matches on Subject: below --
2009-03-24 21:16 [ECOS] TUI: PDCurses for eCOS Sergei Gavrikov
2009-04-15 10:48 ` [ECOS] Nano using PDCurses for eCos Steven Clugston
2009-04-15 11:26   ` Sergei Gavrikov
2009-04-16 10:34     ` Sergei Gavrikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).