Page 1 of 1

ChibiOS Posix-GCC emulation

Posted: Sun Aug 12, 2012 3:53 pm
by kflee2000
Hi,

Just download ChibiOS and compile the demos/Posix-GCC files under Linuxmint and it compiled without error on first run, impressed. I set myself a project to learn ChibiOS by using the linux-emulator came in Posix-GCC directory.

Now that I can get the 'linux-emulator' compilied and when run the executable program 'ch' and it shown SD1 on port 29001 and SD2 on port 29002. Since my serial port in Linux is an USB converted, so I changed the SD1 value in file os/hal/platforms/Posix/serial_lld.h to the port in Linux which is /dev/ttyUSB5. When recompiled and run the SD1 became a value of 10931. These value and notation does not came close to the familiar com port in window or Linux.

In Linux, the USB serial device used cp210x converter and is attached to ttyUSB5. This work fine as I do have normal Linux program that can open the port and read it ok.

Can someone give me some guide as where to look and modify the serial port device?

rgds, kflee.

Re: ChibiOS Posix-GCC emulation

Posted: Sun Aug 12, 2012 4:15 pm
by Giovanni
Hi,

That value in serial_lld.h is a TCP/IP port number, you cannot change it to a device driver name. You could do that by writing some kind of virtual device driver that would route the TCP/IP port to a /dev/something but I never did that.
Alternatively you may rewrite serial_lld.c and serial_lld.h to use different communication mechanisms for the emulation of the serial port.

Anyway, let me suggest to get some cheap board like an STM32xx-Discovery and learn ChibiOS in its real environment: bare hardware :)

Giovanni

Re: ChibiOS Posix-GCC emulation

Posted: Mon Aug 13, 2012 3:44 am
by kflee2000
Hi,

Thanks for the advice. I am reading ChibiOS source code, a hard task even for an experienced programmer.

I would like to test on both solutions and will also document how I do it for the benefit of myself and maybe also for myself.

1) Write a serial driver to replace serial_lld.c : On this I would need to know how the upper layer requires the lld to supply.
Is there a document to explain the requirement for the lld?

2) Write a tcp socket to serial driver. Can I assume that SD1 would be listen to 29001 port continuously, so Iwhat I
need to write is a driver that read serial port and then pass the data to the 29001 port. This would
obviously a much neater solution than a replacement driver for serila_lld. At least it would not messed up the core
of ChibiOS.

3) Let say, I would like ChibiOS to detect the insertion of an USB disk or the removal of it, how should I do?

4) If my understanding (only start to the know the system in 2days) is correct, SD2 could be hooked with for example,
an Bluetooth device since again it is just tcp socket and we just need to supply the hook just like serial port. Am I right
to think this way?

5) I would certainly to get some real device to test. However I think, everybody has a PC and lot of them using Linux
so, if I can get the PC acting like embed-device via the drivers that already come with Linux, then people would
learn the system much easier and quicker.

rgds,
kfl.

Re: ChibiOS Posix-GCC emulation

Posted: Thu Sep 13, 2012 6:10 pm
by mobyfab
By the way Giovanni, you should add -m32 in the makefile for 64bits Linux, else it won't work.

ie:

Code: Select all

  
# Linux, or other
  CPFLAGS += -m32 -Wa,-alms=$(<:.c=.lst)
  LDFLAGS += -m32 -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR)

Re: ChibiOS Posix-GCC emulation

Posted: Thu Sep 13, 2012 6:23 pm
by Giovanni
I forgot to answer to this... well I was more focused on vacations in August :)

kflee2000 wrote:1) Write a serial driver to replace serial_lld.c : On this I would need to know how the upper layer requires the lld to supply.
Is there a document to explain the requirement for the lld?


There are no special requirements, you have to follow the templates.

kflee2000 wrote:3) Let say, I would like ChibiOS to detect the insertion of an USB disk or the removal of it, how should I do?


ChibiOS is not a replacement for the host operating system, such things are out of scope even something could be hacked.

kflee2000 wrote:4) If my understanding (only start to the know the system in 2days) is correct, SD2 could be hooked with for example,
an Bluetooth device since again it is just tcp socket and we just need to supply the hook just like serial port. Am I right
to think this way?


You can emulate a serial port in many ways.

kflee2000 wrote:5) I would certainly to get some real device to test. However I think, everybody has a PC and lot of them using Linux
so, if I can get the PC acting like embed-device via the drivers that already come with Linux, then people would
learn the system much easier and quicker.


Sorry, there is no replacement for real HW :) you need to dirty your hands.

mobyfab wrote:By the way Giovanni, you should add -m32 in the makefile for 64bits Linux, else it won't work.


Thanks, will do.

Giovanni