yashsingh1/xdaforums huggingface dataset:
[HD Mini Android Development] -r0bin-:
those who are expert in IDA pro, can you please help on this:

I have dissassembled a function that appears to be the one that access SMEM in photon.

unfortunately, it seems IDA pro cannot get the address value:

BatteryPDDGetStatus
STMFD SP!, {R4-R6,LR}
MOV R6, R1
MOV R5, R0
LDR R4, =unk_1000C228
MOV R1, 0x1388 ; dwMilliseconds
LDR R0, [R4] ; hHandle
BL WaitForSingleObject
CMP R0, #0
BLNE GetLastError
[B]LDR R0, =unk_1000C384[/B]
LDR R2, [R0]
LDR R3, [R2]
STR R3, [R5]
LDR R3, [R2,#4]
STR R3, [R5,#4]
LDR R3, [R2,#8]

You see this line: LDR R0, =unk_1000C384

how can you tell IDA pro to look for it?
[HD Mini Android Development] -r0bin-:
for this to work, you need to activate this option in kernel:

CONFIG_DEVMEM = y

(in photon default src it is desactivated)
[HD Mini Android Development] -r0bin-:
exactly, thats equal to 0

that should not!

i'll see if i can get help of XDA guys that knows IDA Pro...

yes that's correct! and i dont know the batt id, but you can get other batt values using this app: http://www.codeproject.com/KB/windows/WiMoPower1.aspx

And i wonder if my smem dump is good, can you make one on your side and publish here to compare?
[HD Mini Android Development] -r0bin-:
attached the files i modified to get raphael smem battery algorithm.

feel free to use, but they dont work right now:

smem values are wrong, and you get a weird computation of the final battery value.

GPIO for cable is correct however, thus when you plug your USB cable the charge start.

/!\ don't charge if your battery is 100% under winmo, you could destroy your battery: charge wont stop because battery percent is wrong

note: also attached a patch to enable kernel frame buffer console at startup. not very useful as long as android boot ok :)
[HD Mini Android Development] schlund:
please share your dump :)
[HD Mini Android Development] schlund:
..because of my fix which also uses second memory bank :)

i only want you to share SMEM :) i am not interested in the rest
[HD Mini Android Development] -r0bin-:
guys i think i understood the smem batt mystery, will post more later...

edit:

ok so I have a good news and a bad news.

good news is: we have the smem offset for photon battery, as well as smem value.

all we need is here:

bad news is: we must decode the values. meaning that, we must build our own ds2746 decoder that analyses the measurements and provide a correct battery value to android. which can be risky if we use a wrong algorithm.

we can get help on the existing code of raphael / topaz / rhodium / kovsky (see code i shared with you previously, htc_battery_smem.c) but the values seems to be more or less unique for each architecture (yet to be defined). thus, we must analyse the battdrvr.dll asm.

guys, let's get trained on IDA pro ;-)
[HD Mini Android Development] shah-ilya:
Hi guys! Not sure what you are handy, but still ... Do not judge strictly. :)

This is some info from IDA
[HD Mini Android Development] -r0bin-:
code I released is only a port of raphael algorithm, to enable you must select "CONFIG_MSM_SMEM_BATTCHG" in your kernel config, but it still needs to be adapted to photon.

im workin on it, i might have a working battery indicator soon...
[HD Mini Android Development] -r0bin-:
hurray, i got DEX working!

I can command the ARM9 to update the battery values in SMEM

Battery algorithm seems to work too, but it needs a little fine tuning, there are so many parameters.

+ i still need GPIO number triggered to enable FAST charge, if you have it...

i will post the kernel in a separate post, for those who wants to test.

edit: see here:

http://xdaforums.com/showthread.php?p=12928141#post12928141
[HD Mini Android Development] -r0bin-:
src for battery enclosed, if some wants to have a look at it.

it's not optimal yet, feel free to improve the code if you have good ideas ;)

changes in:

- board-photon.c/.h

- Kconfig

- Makefile

new files:

+ htc_battery_smem.c

+ include/mach/htc_battery_smem.h

+ include/mach/htc_battery_smem_def.h

the rest of modified files are not useful (related to fb_console) but here in case of i forgot something

Note:

to build this driver, you must disable the previous HTC battery driver and enable CONFIG_MSM_SMEM_BATTCHG
[HD Mini Android Development] schlund:
Great job!

i think you forgot about the proc_comm_wince files :)

as far as i can see, battery starts at 100%, but after a few minutes, the values fit very good..

i also had the problem with sleep.. atm i dont know what is happening there..
[HD Mini Android Development] -r0bin-:
yes, batt values need some time to initialize correctly, this is normal.

but final percent value still need fine tuning, you cant imagine how complex they made the battery gauge

also, i dont have the feeling that my mobile is charging when connected to PC.

android says "charging" but i did not noticed my battery capacity was increasing...
[HD Mini Android Development] pietje63:
When connected to the PC the charging is less fast than normal (on WinMo). In case you use the phone, I think it is hardly charging at all, so it may just look like it is not charging.

I just started testing Android on my mini yesterday and should say THANK to all developing and testing. Good work. It looks like most things are pretty close to working (except the mic maybe, but that shouldn't be the hardest part, and except for data (GPRS/3G) which will proably be harder). The only thing is that for a starter it is confusing that many kernels are downloadable at the same time and you do not know which one to use, and for which one a fix is intended. I understand the background (different developers, different goals). Keep on the good work!
[HD Mini Android Development] schlund:
hey,

in fact, we are working very close, but on different issues. thats the reason we have little differentences on kernels. only if a fix works very well it will be added to our "master" release by cardsharing, which is http://gitorious.org/kernel-htc-hd-mini

battery for example is close but not finished, yet.

Also we are not able to make a full package for every little thing we change, only to get nondevelopers running the latest release.
[HD Mini Android Development] schlund:
this should be Battery discharge
[HD Mini Android Development] -r0bin-:
based on this line:

0x040c is batt temperature (°C)

0x0106 is batt ID (dont know what is the use of this, it is not a constant value)

0x0001 is batt charge (mA)

0x0b0a is batt voltage (V)

0x0194 is batt discharge (mA)

if "batt charge" is 0, it means phone run on battery, and discharge value is given by "batt discharge".

the difficulty is those values are encoded by a "special" algorithm, the main line is given by Raphael algorithm.

i did a fast adaptation, based on few values observed on Winmo, and I was able to say this algorithm works for a few values.

but i want to have a safe and accurate algorithm, it needs to be enhanced with a complete analysys:

i'm currently building a program for winmo to populate a database with Windows computed values VS raw smem values, in order to generate a better algorithm.

so, 1st step is to decode the volt/temp/charge/discharge values

2nd step is to compute/calculate the battery % with those values

algorithm is explained in htc_battery_smem.h
[HD Mini Android Development] -r0bin-:
just to share my thougths regarding mic issue not functionning:

this is a bit tricky because it also impact the Android library...

kernel code is located in mach-msm/qdsp5-comp/snd.c

look at the ioctl func, SND_SET_DEVICE:

case SND_SET_DEVICE:
if (copy_from_user(&dev, (void *) arg, sizeof(dev))) {
rc = -EFAULT;
break;
}

dmsg.args.device = cpu_to_be32(dev.device);
dmsg.args.ear_mute = cpu_to_be32(dev.ear_mute);
dmsg.args.mic_mute = cpu_to_be32(dev.mic_mute);
dmsg.args.cb_func = cpu_to_be32(0x11111111);
dmsg.args.client_data = cpu_to_be32(0x11223344);

pr_info("snd_set_device %d %d %d\n", dev.device,
dev.ear_mute, dev.mic_mute);

msm_rpc_setup_req(&dmsg.hdr, RPC_SND_PROG, RPC_SND_VERS,
SND_SET_DEVICE_PROC);

rc = msm_rpc_write(snd->ept, &dmsg, sizeof(dmsg));
htc_pwrsink_audio_path_set(dmsg.args.device);
break;

this function is responsible to enable/disable mic, speakers, and route audio to wired headset, handset or bluetooth headset.

when you look at the traces for a voice call, here is what you got:

at boot time:

[ 15.982338] snd_set_device 1 1 1 => device 1, all mute

calling a number / in call

[ 124.485518] snd_set_device 0 0 1 => device 0, mic mute

in call, using wired headset

[ 133.450378] snd_set_device 2 0 1 => device 2, mic mute

[ 135.862563] snd_set_device 0 0 1 => device 0, mic mute

[ 135.890294] snd_set_device 2 0 1 => device 2, mic mute

in call, removing wired headset

[ 143.167984] snd_set_device 0 0 1 => device 0, mic mute

end call

[ 146.779543] snd_set_device 0 1 1 => device 0, all mute

Observations:

- device 0 is handset, device 2 is wired headset, device 1 is speaker

- "mute" setting is always on

- "mute" setting comes from Android library, which is called "libAudio.so"

src here: https://gitorious.org/replicant/msm7k/trees/master/libaudio

don't know who is responsible of this

- despite the "mute always on", the wired headset mic is enabled

i suspect a bad init setting, now need to investigate where are defined the device configurations.

if you guys have any idea please share ;)
[HD Mini Android Development] schlund:
this is nearly the same that i got, atm i am trying to get this working by kernel, kind of "hardenable" :D
[HD Mini Android Development] mqd:
i have try a call and mic wont work but i can hear my voice in the hd mini

if this can help
[HD Mini Android Development] wismar:
A Russian developer said that it can help in porting android

htc-linux.org/wiki/index.php?title=LK_Bootloader
[HD Mini Android Development] 15131331231:
Good job,cardsharing!waiting for the latest news about android on mini is the most important thing in my daily life!:-
[HD Mini Android Development] ttcome:
Throughout the android system, with the relevant part of the headset are:

Linux driver: insert the headset key to complete the test, hook key test, which included press and key hook

And the press.

headset in the frameworks of the observation file (HeadsetObserver.java), the document was seized

Measuring the headphones are inserted, and the name and the relevant content out through the Intent broadcasts.

associated with the audio, change the audio output of the path (here comes to play music and phone part).

associated with the handling of events, this part of the hook function is mainly reflected mainly receive calls, hang up the phone.

Event processing and event processing into linux and android on the event handling.
[HD Mini Android Development] schlund:
i was successfully adding that before, if you want i can show you the difference or, what i would prefer, you could explain me how to add this to git (i am interested in that :) )
[HD Mini Android Development] derefas:
i think test snd from touch pro2?

https://gitorious.org/linux-on-qual.../htc-msm-2.6.27/arch/arm/mach-msm/qdsp5/snd.c

diff

https://gitorious.org/linux-on-qual...mmit/43f0a9681d0557cb0e38a533b3a9ae8d75346af6
[HD Mini Android Development] -r0bin-:
dont worry, the only values we need are good:

GET_ADC_VREF and GET_ADC_0_5_VREF

the rest is here for when raphael/topaz users need to know if the PCB is different or not, and if the battery capacity differs.

photon uses only one battery capacity today (1200mAh) so we dont need to detect it...
[HD Mini Android Development] -r0bin-:
yes i saw this, thanks for sharing.

unfortunately this code requires definition and use of var "snd_state" that doesnt exists on photon's code: the diff is bigger than you think
[HD Mini Android Development] -r0bin-:
yes, battery charging is not working

this battery code needs improvements, but at least you can use your phone (without charging) and have a battery indicator more or less accurate.

im working on it ;-)
[HD Mini Android Development] codiak:
Lower Backpart of the phone gets hot after a while.

Are you aware of this?

I dont think its the battery itself...
[HD Mini Android Development] -r0bin-:
thanks for feedback

is it hot when connected with cable, or hot without cable (=running on batteries)?

did you noticed this behavior with WinMo as well?

are you sure the temperature is caused by the battery, and not something else inside the device? (try removing battery to test)

as far as I know, the battery can get hot only when charging, and there is usually an integrated circuit to switch off charging automatically if it gets too hot (>80°C).

if bottom of handset gets hot too much when running on batteries, there is probably a component that is always powered but should not.

mic? 3G? sensor?
[HD Mini Android Development] codiak:
It gets "very warm". hot is not the right word, i think.

That happens only when running android. While charging and on batt.

I think its a component near the SIM card slot.

I cannot say if that happend in cotullas version too for sure. I hoped that it could be fixed with the battery driver. Seems not :)
[HD Mini Android Development] codiak:
Investigated this a bit. It seems to be near the microSD card slot, and not SIM.

This was also reported by other users.
[HD Mini Android Development] -r0bin-:
if you try to match the heat spot on the motherboard pictures that were provided previously in this thread, what chip do you think it could be?

Seems it matches with the PM7540 chipset, or the other component below, which is (i dont know)
[HD Mini Android Development] derefas:
i have problem with compilation last kernel

this error i see often

i deleted QDSP_QUEUE_MAX compiling

next error

sorry guys i make some mistakes with .config :D
[HD Mini Android Development] schlund:
as compiler says: you are using undeclared identifiers,

try to set the compiler not to treat warnings as errors
[HD Mini Android Development] codiak:
I am sorry. I cant find it on the pictures provided by gabbana :/
[HD Mini Android Development] derefas:
I did not right .config out msm_defconfig and had to make photon_defconfig

PS: i think to fix mic we need make sound routing in kernel or edit libaudio.so in android image...
[HD Mini Android Development] codiak:
Some thoughts about the camera issue.

As it worked on cotullas release, isnt it possible to simply adapt his changes?
[HD Mini Android Development] 15131331231:
cardsharing,according to the feedbacks from xda-China,we got this:with the new zimage released at 27 April,I found somewhere was very warm,and even over 80℃ sometimes around the sim card,but now i am sure that it is around the IF.the way to resolve this is flashing the original rom.after that,it just looks like running in windows mobile.i hope this would help.thanks,and sorry for my bad English.⊙.⊙
[HD Mini Android Development] nnkjsc:
Thank you.
[HD Mini Android Development] lucaogame:
Please, don't give up all your work now! You are in a very good point of this porting. This phone is not so common, people who has this phone hopes in people like you. we are not developers, i think, but we are here, supporting you. I check this thread every single day waiting for new updates, and i think that other people do the same. I can try to help you, but the only thing that i know is c language. I studied it at school (i'm already studying java) last year. I'm not expert but i can try to help you. Please, don't give up :(
[HD Mini Android Development] lucaogame:
Ok. But before i want you to leave all your thought and data about battery and things you were studying. And i would want other developers explain me how android works, and how can i help with c language. Maybe in chat?
[HD Mini Android Development] RoSo:
here you can use IRC to chat with developers. ;)

http://htc-linux.org/wiki/index.php?title=IRC
[HD Mini Android Development] lucaogame:
Can you explain me why we cannot use this code or others code for battery usage? Why doesn't it work on our device?

P.S: I saw the code. It's very hard, i've problem to understand it. Anyway, Why the kernel you uploaded, the wifi doesn't work?
[HD Mini Android Development] MobileMini:
Hey, it would be really sad if you stopped with the project :(. I think this project can really be accomplished. I can understand your decision, its really hard to do this project with only a few dedicated people who are not 100% into developing. And don't get me wrong I really think you all do a great job, a lot of respect for all of you dev guys! Maybe focusing on being one team and handle one problem at a time can bring back momentum? I don't know, but abandoning Android, with so much time and effort invested, would be really sad...
[HD Mini Android Development] fernando2610:
Hey pals, it's so sad that you leave this mission!!! All you devs can do it, the mic isn't working, you made work battery, wifi, ... you can do it, dont stop PLEASE!!
[HD Mini Android Development] fernando2610:
I want to help to develop mic, what programs can i use to?

Hi guys i want to help to develop but i dont know what programas to use!! please someone can explain me?? thanks:)
[HD Mini Android Development] jarugut:
Hi cardsharing,

I'm don't know if you have received help from other developers, but you are making a good job.

If that information help you there are other forum in xda-developers where the battery works with some issue, wifi works ok with this change.

The Forum is http://xdaforums.com/showthread.php?t=1002178
[HD Mini Android Development] pierpaolo789:
I'll add you many have done an excellent job here is really quite unfortunate stop almost at the end. Xche x me just adjust the microphone then the rest has little:):(
[HD Mini Android Development] -r0bin-:
hey dude don't give up, we're close to the end and we all need you.

but just to clarify: you cannot expect anyone to answer 100% of your questions on a defined timescale.

I know many photon users are waiting for a working android version and it's taking lot of time, but we all have obligations (job, work, study, girlfriend, family, friends, vacations, hobbies) and devs cannot be full time 24/7 porting android on photon or looking at xda forum.

this being said, it doesnt mean devs gave up or that devs are not work together.

We are working on it, we will make it but it will take some time.

if you want us (the devs) to help you on uploading sources to GIT repository, then just tell us and give us the rights to do it.

if you want to discuss with me any topic, you already have my contact, you

know what to do :cool:
[HD Mini Android Development] utsavkoju:
I checked your log and everythings are just flying all above my mind. :-0

Have learned C, C++ and Java as core programing language but can't find the place i can start from ;-).

I am having my exam and after i finished it this afternoon i will try to learn more about the programming in mobile device and Android kernels.

BTW thank you Cardsharing for not giving up, your good work mean a lot to us. Thanks to r0bin, schlund and other developers as well.

Guys i want help you people but don't find from where should i start and from where i can learn about android basic.

Please HELP!!!
[HD Mini Android Development] djfastest:
please give a link to the android 2.3 I will try to help in the testing
[HD Mini Android Development] -r0bin-:
last time i sent you a diff you asked me full src, i dont understand :confused:

when you asked me explanations on how to enable batt fix, i answered you on the forum too :confused:

its taking lot of time for me to do a diff, its more easy for you to do it since you have the latest GIT src version already. and since i want to progress on this code too, i prefer spending time on improving the driver.

you have the smem address in my previous posts.

formula is complex, inside the src file. there is like three formula applied to the raw values before getting the batt percentage.

seriously you must jump into the code to understand, its less difficult that it seems.

try the one of cotulla:

// Cotulla: vibro test
//*(volatile unsigned int*)(MSM_GPIO1_BASE + 0x808) |= 0x1000000;
//*(volatile unsigned int*)(MSM_GPIO1_BASE + 0x808) |= 0x1000000;

or, take my battery fix, and use the DEX command for this:

msm_proc_comm_wince_vibrate(...)

i saw this, this is good job, but i cant help right now: i focus on batt and mic on current android version
[HD Mini Android Development] -r0bin-:
thanks, but there is no hurry: if you wait a little more i will upload better battery driver.

dont worry, the smem error is not really an error, it is just different method i tried to get battery values.

as of now, the battery driver i released is good, it can read smem successfully.

i only need to fine tune the formula to get more accurate value, and enable charger. I will clean the output messages as well.

i did a little investigation on mic:

on winmo, when mic is enabled, a DEX command is sent

here is code i created, based on raphael src, not working for the moment:

void dex_enable_mic(int mic_on)
{
struct msm_dex_command dex;
dex.cmd = PCOM_UPDATE_AUDIO;
printk("snd r0bin, dex enable mic=%d",mic_on);
//dex.data=0x10;
dex.data=mic_on;
dex.has_data=1;
//*(unsigned *)(MSM_SHARED_RAM_BASE+mic_offset)=0xffff0080 | (on?0x100:0);
msm_proc_comm_wince( &dex, 0 );
}

but when I use this code, I can hear my voice in the speaker.

we're getting closer...
[HD Mini Android Development] lucaogame:
I would notice you that video cannot be played in Android. I think is kernel-inside problem..
[HD Mini Android Development] sahari308:
thanks -Please continue to give the microphone to solve
[HD Mini Android Development] pwel:
maybe you can solve the mic issue yourself? You asking this question will annoy the devs, be patient and follow the thread and stop asking these stupid questions!!! The devs determine their own pace to solve the mic issue.
[HD Mini Android Development] lucaogame:
I don't remember. I tried to play a video in the last kernel you released. Give me the link of the previous kernel you mean, i can't find it, and i will test it.
[HD Mini Android Development] lucaogame:
i said just kernel but i installed all :) Anyway, i tried with 06.04.2011. With you tube, when i select i video, i can hear only audio, and can't stop the video, can't exit, but the audio still play. With the browser, video are showed WITHOUT HQ. In HQ video are slow. I'm trying with players. Can you fix it in new kernel?
[HD Mini Android Development] lucaogame:
No, in 29.04 video doesn't work.
[HD Mini Android Development] Twean:
Hi devs,

dont know if its common problem or just mine, but when my phone (running android) goes to standby (lock phone) then nearly all time a cant unlock it. Its still locked, screen is off and phone not respond on presing power button. In WIN its normal, this problem is just when running android.

Im running 29.4.2011 version.

Posting just to imforming you. If you already know this issue and its on the list....then Im sorry for spaming.
[HD Mini Android Development] pwel:
I do have that sometimes but not often. Maybe move this item to http://xdaforums.com/showthread.php?t=1002178 ?
[HD Mini Android Development] codiak:
I also have this issue every time the phone locks.
[HD Mini Android Development] ttcome:
you can use volume up then power ,it is ok
[HD Mini Android Development] Gipsy_Mickey:
sometimes vol_up + vol_down + power helps better to awake your phone.
[HD Mini Android Development] -r0bin-:
guys, great news: i got incall mic working :-)

seems we must send DEX + RPC pm_en_mic

only issue is, now speaker dont work, but wait a little more...
[HD Mini Android Development] codiak:
Good news! Keep on rocking! ;)
[HD Mini Android Development] tzacapaca:
yupiiiiiiiiiiiiiiiiiiiiiiii

greatttttttttttttttttttttttttttt r00000000000000000binnnnnnnnnnnnnnnnn :D:D:D

you da man;)
[HD Mini Android Development] ttcome:
its Exciting news ，，Come on！！~~~~加油!

All the people of MINI in the waiting~~
[HD Mini Android Development] -r0bin-:
almost fixed:

now i have mic working + headset speaker working, only issue is, i hear my voice also in my hear when i speak.

just a little fine tuning...
[HD Mini Android Development] silb:
you are great man! thanks a lot! woop woop \o/