FreeDOS support

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
pohmelie
Posts: 55
Joined: Mon Nov 23, 2015 6:31 pm

Re: FreeDOS support

Post by pohmelie » Mon Dec 07, 2015 12:25 pm

dhylands
Since freedos build based on djgpp, and in the last version of https://github.com/pohmelie/micropython-freedos I had reduce env variables count to one. Just DJGPP=/path/to/djgpp-folder. So maybe use this env variable (DJGPP) as condition for branching in makefile?

User avatar
dhylands
Posts: 3463
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: FreeDOS support

Post by dhylands » Mon Dec 07, 2015 3:49 pm

Personally I think using the DJGPP env var seems awkward, and makes it a lot more difficult lt to switch back and forth between unix and freedoms builds.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: FreeDOS support

Post by pfalcon » Mon Dec 07, 2015 4:53 pm

pohmelie wrote: How about block copy for "physical" and "virtual"?
For "virtual", block copy uses standard Python syntax of array slice assignment:

Code: Select all

# mem1 & mem2 is bytearray captured e.g. by uctypes.bytearray_at()
mem1[0:10] = mem2[100:110]
pohmelie wrote: Cause djgpp "physical" memory access is expensive.
It's the same on probably any virtual-memory system. That's why there's no block copy support for that in uPy - a typical usecase for accessing physical memory is doing IOMEM access, and that's usually done single data unit at time anyway. If you really need it, doing your adhoc solution makes sense.

pohmelie wrote: Also, can't find some common machine module description in /py. Does it have standard/template?
It's in review state currently: https://github.com/micropython/micropyt ... rdware-API
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pohmelie
Posts: 55
Joined: Mon Nov 23, 2015 6:31 pm

Re: FreeDOS support

Post by pohmelie » Mon Dec 07, 2015 5:12 pm

dhylands wrote:Personally I think using the DJGPP env var seems awkward, and makes it a lot more difficult lt to switch back and forth between unix and freedoms builds.
Agree.
pfalcon wrote:It's in review state currently: https://github.com/micropython/micropyt ... rdware-API
Great! I forgot about wiki :D

pohmelie
Posts: 55
Joined: Mon Nov 23, 2015 6:31 pm

Re: FreeDOS support

Post by pohmelie » Tue Dec 08, 2015 7:30 am

I need to disable "MICROPY_STREAMS_NON_BLOCK", it is defined in "mpconfigport.h". How to do that? Cause in "mpconfigport.h" there is no check about it is already defined.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: FreeDOS support

Post by pfalcon » Tue Dec 08, 2015 11:28 pm

So, it's probably fair to assume that FreeDOS port will need its own mpconfigport.h. So, if you still follow "try to host djgpp port within unix/" approach (as recommended), feel free to create mpconfigport_freedos.h file, and then a target to Makefile similar to existing "minimal" or "fast". Again, that's minimal set of changes, and good approach to start with. It may be the case that it will be worth the port is worth it's own subdir, but starting with minimal-changes approach is always good.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pohmelie
Posts: 55
Joined: Mon Nov 23, 2015 6:31 pm

Re: FreeDOS support

Post by pohmelie » Wed Dec 09, 2015 8:37 am

Trying to build termios module. And have some issues:

Code: Select all

CC modtermios.c
modtermios.c: In function 'mod_termios_tcgetattr':
modtermios.c:63:45: error: passing argument 1 of 'mp_obj_new_bytes' from incompatible pointer type [-Werror=incompatible-pointer-types]
             cc->items[i] = mp_obj_new_bytes(&term.c_cc[i], 1);
                                             ^
In file included from ../py/mpstate.h:34:0,
                 from ../py/nlr.h:68,
                 from modtermios.c:32:
../py/obj.h:603:10: note: expected 'const byte * {aka const unsigned char *}' but argument is of type 'cc_t * {aka unsigned int *}'
 mp_obj_t mp_obj_new_bytes(const byte* data, mp_uint_t len);
          ^
In file included from ../py/mpstate.h:34:0,
                 from ../py/nlr.h:68,
                 from modtermios.c:32:
modtermios.c: At top level:
modtermios.c:139:7: error: 'B57600' undeclared here (not in a function)
     C(B57600),
       ^
../py/obj.h:84:66: note: in definition of macro 'MP_OBJ_NEW_SMALL_INT'
 #define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_int_t)(small_int)) << 1) | 1))
                                                                  ^
modtermios.c:135:50: note: in expansion of macro 'MP_ROM_INT'
 #define C(name) { MP_ROM_QSTR(MP_QSTR_ ## name), MP_ROM_INT(name) }
                                                  ^
modtermios.c:139:5: note: in expansion of macro 'C'
     C(B57600),
     ^
modtermios.c:140:7: error: 'B115200' undeclared here (not in a function)
     C(B115200),
       ^
../py/obj.h:84:66: note: in definition of macro 'MP_OBJ_NEW_SMALL_INT'
 #define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_int_t)(small_int)) << 1) | 1))
                                                                  ^
modtermios.c:135:50: note: in expansion of macro 'MP_ROM_INT'
 #define C(name) { MP_ROM_QSTR(MP_QSTR_ ## name), MP_ROM_INT(name) }
                                                  ^
modtermios.c:140:5: note: in expansion of macro 'C'
     C(B115200),
     ^
cc1: all warnings being treated as errors
make[1]: *** [build-freedos/modtermios.o] Error 1
make[1]: Leaving directory `/home/broomrider/tmp/micropython/unix'
make: *** [freedos] Error 2
First one is just cast error, cause djgpp termios.h said

Code: Select all

typedef unsigned cc_t;
typedef unsigned speed_t;
typedef unsigned tcflag_t;

struct termios {
  cc_t		c_cc[NCCS];
  tcflag_t	c_cflag;
  tcflag_t	c_iflag;
  tcflag_t	c_lflag;
  tcflag_t	c_oflag;
  speed_t	c_ispeed;
  speed_t	c_ospeed;
};
this can be solved, by add (unsigned char *)&... to modtermios.c. But should this be done? And how, if so?

Rest of errors are macros based. If I comment

Code: Select all

// C(B57600),
// C(B115200),
in modtermios.c, then module compiles ok. But I don't understand why "C(B9600)" is not error, but "C(B57600)" is :?

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: FreeDOS support

Post by pfalcon » Wed Dec 09, 2015 7:52 pm

in modtermios.c, then module compiles ok. But I don't understand why "C(B9600)" is not error, but "C(B57600)" is
Because 35 years ago SystemV/BSD didn't have speeds beyond 38400 or so, and any higher value is "non-standard". Should be fixed in https://github.com/micropython/micropyt ... b7b28a64b9 . (And right, these issues are exactly the kind of changes I'm looking for to support DJGPP - they should be largely small and localized).
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: FreeDOS support

Post by pfalcon » Wed Dec 09, 2015 8:06 pm

pohmelie wrote: this can be solved, by add (unsigned char *)&... to modtermios.c. But should this be done? And how, if so?
Yep, if we want to build it, apparently it should be done. And it seems that DJGPP tries to be smart and support control chars to be unicode chars ;-). Well, that's still not supported on uPy side (because hardly anybody need that), so just a minimal workaround applied indeed: https://github.com/micropython/micropyt ... dc9136baa2
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pohmelie
Posts: 55
Joined: Mon Nov 23, 2015 6:31 pm

Re: FreeDOS support

Post by pohmelie » Wed Dec 09, 2015 8:41 pm

pfalcon wrote:Because 35 years ago SystemV/BSD didn't have speeds beyond 38400 or so
Yep, you are right (http://www.delorie.com/djgpp/doc/incs/termios.h) 38400 is high bound.

Post Reply