[yocto] Eclipse configuration : Battery Charger : Cross compilation on imx28evk

pierre jozwicki pierre.jozwicki at hotmail.fr
Fri Feb 27 05:33:32 PST 2015


Hi,
First of all, thank you very much if you can take the time to read my email and give me some answers to my questions.I'm sorry for this mail beeing quite long but I'm trying to give you the necessary details so you would have more chances to help me out ;)
I am pretty new to cross compilation methods and a big newbie in Linux architecture, user's and kernel space.I'm working on an imx28evk board, linux kernel 2.6.35 and to start with this board I'm trying to write a simple code for Battery Monitoring.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
In this document (Using the PMU + Battery Charger) : http://cache.freescale.com/files/32bit/doc/app_note/AN4199.pdfand making a ctlf +f with keyword "modif", shows that (Kernel side):
1/- in file /linux-2.6.35.3/arch/arm/mach-mx28/bus_freq.c : VDDIO can be modified- in file /linux-2.6.35.3/arch/arm/mach-mx28/device.c : the values of u16ChargingCurrent,  u16ChargingThresholdCurrent can be modified.
2/In power_prep.c the brownout level can be modified according to the battery reference voltage.
Correct me if I'm wrong but for me the changes made to the files described in 1/ and 2/ have to be done on the git downloaded archive and prior to bitbaking an image. Then the image obtained contains the battery charger configured in the way we specified it in those files.Is this correct ?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
But now what to do if I want to for example write a C code with Eclipse configured using autotools to monitor the Battery Charger ?
To configure eclipse, I followed the steps in section 4.2.2 of : http://www.yoctoproject.org/docs/1.7.1/dev-manual/dev-manual.html#modifying-temporary-source-code
As the image I bitbaked is a core-image-sato-sdk I have a rootfs directory inside the core-image-sato-sdk directory and I don't know if this is the one to use or to use the sysroot directory in /fsl-community/build/tmp/sysroots.
Toolchain root location: /home/pjo/fsl-community/buildSysroot Location : /home/pjo/fsl-community/build/tmp/work/imx28evk-poky-linux-gnueabi/core-image-sato-sdk/1.0-ro/rootfsTarget architecture : armv5te-poky-linux-gnueabi
The Hello World project is working well when exported on the target.

But now when I try to add to the Hello World project some headers like for example : #include"ddi_bc_hw.h" or "ddi_bc_internal.h", I  created an environment variable called INCLUDES = -I/home/pjo/fsl-community-bsp/build/tmp/sysroots/imx28evk/usr/src/kernel/drivers/power/mxs -I/home/pjo/fsl-community-bsp/build/tmp/sysroots/imx28evk/usr/src/kernel/arch/arm/plat-mxs/include/mach
The headers are now recognized. But when I try to access the function ddi_bc_hwGetBatteryVoltage() : 
voltage = ddi_bc_hwGetBatteryVoltage();printf("Voltage = %u \n", voltage);
There is an undefined reference to this function (defined in ddi_bc_hw.h)


In this document chapter 27 the functions for Battery Charger are described: http://www.element14.com/community/servlet/JiveServlet/download/56891-1-44201/Freescale-i.MX28-MCIMX281AVM4B-Gallery%20MCU-Reference%20Manuals-Freescale.Reference_Maunal_1.pdf
So now my question is the following: Is it possible to use those headers when programming ? or are they in kernel space and not accessible by the application developper ? If not : Will the battery charger behaviour be the same all the time after the image is copied on a SD card ?If yes : How to get rid of the undefined reference ?
I tried to use readelf to find the libs that match the headers. But it was unsuccessfull. So I added to several environment variables in Eclipse all the folders named "include" so Eclipse ca n find the libs in the correct paths. I tried to get some documentation on how to add packages to the build, or modules. I've read some documentation on ioctl's but according to the reference manual above ioctl's are only for frame buffer driver, pixel pipeline etc ... (but not battery charger ?)
All I found is a file : /home/pjo/fsl-community-bsp/build/tmp/work/imx28evk-poky-linux-gnueabi/core-image-sato-sdk/1.0-r0/rootfs/usr/lib/matchbox-panel/libbattery.so
But it seems like this is not the correct lib to add and it gererates many errors during build : all of this type : /home/pjo/fsl-community-bsp/build/tmp/sysroots/imx28evk/usr/include/gtk/gtk.h:32:21: fatal error: gdk/gdk.h: No such file or directorySo i create the symbolic links so the files are found but I don't think it's the correct way.

All I can do right now is a program like this :  (which is capable of retrieving the voltage in user space)
int main(void) {        puts("Hello World");        char voltage_from_file[12] = "";        FILE* fd = NULL;        fd = fopen("/sys/class/power_supply/battery/voltage_now", "r");
        if (fd != NULL)        {            fgets(voltage_from_file, 12, fd);            printf("Voltage : %s", voltage_from_file);            fclose(fd);        }        return 0;}
But if I want to use this value to set the charging current using uint16_t u16ChargingCurrent;
uint16_t u16ChargingThresholdCurrent; or cut the battery or anything else I'm stuck....
If think that my problem is global understanding of the Linux architecture and Kernel space, and linking libraries to the makefile... 
But I would be really grateful if you could help me out, answer my previous questions or at least tell me what is the correct way to develop this simple application. Maybe what I'm trying to do, and on which I'm stuck for more than 2 weeks now is simply not possible, but I'd like to be sure about it ^^
Thank you in advance for your help, and sorry for this long email.
Kind regards,
Pierre Jozwicki





 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20150227/d98d5d14/attachment.html>


More information about the yocto mailing list