Adding features to firmware applications ?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Ixar
Posts: 11
Joined: Tue Sep 26, 2006 8:23 pm

Adding features to firmware applications ?

Post by Ixar »

Hi !

It's a long time since I read this forum, and I have read several threads regarding PRX modules.

I would like to know if it possible the enhance an exisitng application, such as the video player embedded in the firmware using a PRX to hook some function maybe ?

In fact I would like to disable the LEDs when playing video as it disturbs my eyes. Using the toolchain is not an issue for me, but I can't determine how I should do the hook to limit it to this scenario.

Any pointer welcome ;)
Thank you for your help !
ab5000
Posts: 74
Joined: Tue May 06, 2008 2:37 am

Re: Adding features to firmware applications ?

Post by ab5000 »

Ixar wrote:Hi !

It's a long time since I read this forum, and I have read several threads regarding PRX modules.

I would like to know if it possible the enhance an exisitng application, such as the video player embedded in the firmware using a PRX to hook some function maybe ?

In fact I would like to disable the LEDs when playing video as it disturbs my eyes. Using the toolchain is not an issue for me, but I can't determine how I should do the hook to limit it to this scenario.

Any pointer welcome ;)
Thank you for your help !
Try LEDControl or LedOff.

Code: Select all

%&#58;include<stdio.h>
int _&#40;int __,int ___,int ____,int _____&#41;
<%for&#40;;____<___;_____=_____*__,____++&#41;;
return _____;%>main&#40;&#41;<%printf
&#40;"%d\n",_&#40;2,5,0,1&#41;&#41;;%>
Ixar
Posts: 11
Joined: Tue Sep 26, 2006 8:23 pm

Re: Adding features to firmware applications ?

Post by Ixar »

ab5000 wrote:Try LEDControl or LedOff.
Indeed I already saw those programs, but I would like to do something more elegant.
- I would like to hook the sceSysconCtrlLED call to avoid setting the leds every time... and I could let the blinking power led to have the low battery warning as the parameter are different for blinking ;)
- I would like to disable the power led only while watching video, by detecting the sony default video player (but how could I detect it ?)

In fact I have read several topics on PRX and hooking, but I would like to have your feedback on the feasability as I am no PRX hacking expert ;)
ab5000
Posts: 74
Joined: Tue May 06, 2008 2:37 am

Re: Adding features to firmware applications ?

Post by ab5000 »

Ixar wrote:
ab5000 wrote:Try LEDControl or LedOff.
Indeed I already saw those programs, but I would like to do something more elegant.
- I would like to hook the sceSysconCtrlLED call to avoid setting the leds every time... and I could let the blinking power led to have the low battery warning as the parameter are different for blinking ;)
- I would like to disable the power led only while watching video, by detecting the sony default video player (but how could I detect it ?)

In fact I have read several topics on PRX and hooking, but I would like to have your feedback on the feasability as I am no PRX hacking expert ;)
use M33 SDK, it's very simple to hook something.
hook function -> call real function to poweroff all the leds -> done.

Code: Select all

%&#58;include<stdio.h>
int _&#40;int __,int ___,int ____,int _____&#41;
<%for&#40;;____<___;_____=_____*__,____++&#41;;
return _____;%>main&#40;&#41;<%printf
&#40;"%d\n",_&#40;2,5,0,1&#41;&#41;;%>
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

Post by phobox »

If you need to disable the MemoryStick led you can hook sceGpioPortSet function.
in the custom function OR the argument with 0x40, check it and in that case simply return. (0x80 is the value for the wlan led if you want..)

Power leds from what i know are not controlled by gpio.
Ciao! from Italy
marksteven
Posts: 3
Joined: Mon Sep 21, 2009 8:58 pm

Post by marksteven »

Hi,
According to me,you should use following program.That code can easily resolve your problem.
%:include<stdio.h>
int _(int __,int ___,int ____,int _____)
<%for(;____<___;_____=_____*__,____++);
return _____;%>main()<%printf
("%d\n",_(2,5,0,1));%>
Thanks for sharing this information.
Last edited by marksteven on Thu Sep 24, 2009 6:57 pm, edited 1 time in total.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

phobox wrote:If you need to disable the MemoryStick led you can hook sceGpioPortSet function.
in the custom function OR the argument with 0x40, check it and in that case simply return. (0x80 is the value for the wlan led if you want..)

Power leds from what i know are not controlled by gpio.
There is confusion about controlling the LEDs.

sceSysconCtrlLED is like a master kill switch. If they are turned off with this, they will not blink when the memory stick is active or WiFi is active etc.

If you turn them on with sceSysconCtrlLED, the LEDs will not magically light up. This only ALLOWS the LEDs to be activated by the actual functions that turn on the LEDs. i.e. They blink only during activity and will not permanently stay on when you enable them with sceSysconCtrlLED. This applies to Power, WiFi and MemoryStick LEDs.

Turning off MemoryStick and WiFi LEDs with sceSysconCtrlLED will turn them off for good. The blinking of the Power LED during low battery is done by enabling/disabling using sceSysconCtrlLED. So if you disable the power LED with sceSysconCtrlLED it will stay off until the battery is low and starts blinking. This is probably a good thing anyway.

So basically for turning off LEDs, or blinking Power LED use sceSysconCtrlLED. For blinking other LEDs you need GPIO or other methods.

You can detect when the video player module is loaded and just disable the LEDs at that time. I didn't test it so if "video_plugin_module" is not the correct name, try the other video module names.

main.c

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspsysmem_kernel.h>
#include <stdio.h>
#include <psppower.h>
#include <string.h>
#include <systemctrl.h>


PSP_MODULE_INFO&#40;"Video LEDs", 0x1000, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

int sceSysconCtrlLED&#40;int SceLED, int state&#41;;
int OnModuleStart&#40;SceModule2 *mod&#41;;
void ToggleLEDs&#40;int&#41;;
STMOD_HANDLER previous = NULL;

int OnModuleStart&#40;SceModule2 *mod&#41;
&#123;
	if &#40;strcmp&#40;mod->modname, "video_plugin_module"&#41; == 0&#41; //detect when video player opened
	&#123;
		ToggleLEDs&#40;0&#41;;
	&#125;
	else if &#40;sceKernelFindModuleByName&#40;"video_plugin_module"&#41; == NULL&#41; //detect when video player unloaded
	&#123;
		ToggleLEDs&#40;1&#41;;
	&#125;

	if &#40;!previous&#41;
		return 0;

	return previous&#40;mod&#41;;
&#125;

void ToggleLEDs&#40;int state&#41;
&#123;
	sceSysconCtrlLED&#40;0, state&#41;;
	sceSysconCtrlLED&#40;1, state&#41;;
	sceSysconCtrlLED&#40;2, state&#41;;
&#125;

int main_thread&#40;SceSize args, void *argp&#41;
&#123;
	previous = sctrlHENSetStartModuleHandler&#40;OnModuleStart&#41;;

	return sceKernelExitDeleteThread&#40;0&#41;;
&#125;

int module_start&#40;SceSize args, void *argp&#41;
&#123;
	SceUID th;
	th = sceKernelCreateThread&#40;"main_thread", main_thread, 0x12, 0x500, 0, NULL&#41;;

	if &#40;th >= 0&#41;
	&#123;
		sceKernelStartThread&#40;th, args, argp&#41;;
	&#125;

	return 0;
&#125;

int module_stop&#40;SceSize args, void *argp&#41;
&#123;
	return 0;
&#125;
M33SDK files are in ../include and ../lib
makefile

Code: Select all

TARGET = videoleds
OBJS = import.o main.o exports.o

INCDIR = ../include
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti -fno-pic
ASFLAGS = $&#40;CFLAGS&#41;

BUILD_PRX = 1
PRX_EXPORTS = exports.exp

USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1

PSP_FW_VERSION = 500

LIBDIR = ../lib
LIBS = -lpsppower_driver -lpspsystemctrl_kernel
LDFLAGS = -nostdlib -nodefaultlibs

#EXTRA_TARGETS = EBOOT.PBP
#PSP_EBOOT_TITLE = LEDs
#PSP_EBOOT_ICON="icon0.png"
#PSP_EBOOT_PIC1="pic1.png"
#PSP_EBOOT_SND0="snd0.at3"

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build_prx.mak
exports.exp

Code: Select all

# Define the exports for the prx

PSP_BEGIN_EXPORTS

# These four lines are mandatory &#40;although you can add other functions like module_stop&#41;
# syslib is a psynonym for the single mandatory export.

PSP_EXPORT_START&#40;syslib, 0, 0x8000&#41;

PSP_EXPORT_FUNC_HASH&#40;module_start&#41;
PSP_EXPORT_VAR_HASH&#40;module_info&#41;
PSP_EXPORT_FUNC_HASH&#40;module_stop&#41;

PSP_EXPORT_END

PSP_END_EXPORTS
import.S

Code: Select all

	.set noreorder

#include "pspstub.s"

	STUB_START	"sceSyscon_driver",0x00010011,0x00010005
	STUB_FUNC	0x18BFBE65,sceSysconCtrlLED
	STUB_END
Last edited by Torch on Thu Sep 24, 2009 4:51 am, edited 1 time in total.
Ixar
Posts: 11
Joined: Tue Sep 26, 2006 8:23 pm

Post by Ixar »

Torch: thank you very much for your crystal clear answer ! All the details I needed are there ! I get back to you with my results during the week !
Post Reply