We are evaluating if we can migrate our devices from raspbian to resinOS.
We got resinOS running on our CM3 based device, the last open task is porting our kernel module.
The problem is that it needs to replace /dev/ttyAMA0 (uart-pl011 driver) because we need to access this UART directly and uart-pl011 is not a module but built-in.
We have 2 different ways to map the UART I/O addresses into kernel space.
Method 1:
This method re-uses the existing ioremap() from the uart-pl011 driver
(which is the original /dev/ttyAMA0 driver after reboot).
Method 2:
This method creates its own ioremap() from the uart-pl011 driver and then removes the ioremap() from the uart-pl011 driver by unbinding the driver
In both methods shall /dev/ttyAMA0 not be removed, but shall instead renamed to e.g. /dev/NO-ttyAMA0. This is to prevent accidental use of /dev/ttyAMA0.
Method 1:
- rename /dev/ttyAMA0 to /dev/NO-ttyAMA0.
- determine the virtual address, say VIRT_ADDR, of the existing mapping by analyzing /proc/vmallocinfo.
- insmod the elmos.ko module with module parameter membase="$VIRT_ADDR"
Method 2:
- rename /dev/ttyAMA0 to /dev/NO-ttyAMA0.
- insmod the elmos.ko module without module parameter membase. The module
parameter membase can still be given but will have no effect since it is
being overridden in the code line below. - unbind the uart-pl011 driver (which removes the ioremap() installed by it.
It is important to unbind the driver AFTER the elmos.ko has installed its
own ioremap().
How can this be done in resionOS.