problem when build LKM - HTC Sensation XL

Here is a loadable kernel module for HTC Sensation XL (runnymede-crc-2.6.35).
/*
* mydebug.c
* System Call sys_open dubugging
*/
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/module.h> /* Needed by all modules */
#include <linux/init.h> /* Needed for macros */
#include <asm/unistd.h>
#include <linux/linkage.h>
#include <generated/autoconf.h>
#include <linux/in.h>
#include <linux/init_task.h>
#include <linux/ip.h>
#include <linux/kernel.h>
#include <linux/kmod.h>
#include <linux/mm.h>
#include <linux/skbuff.h>
#include <linux/workqueue.h>
#include <linux/sched.h>
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/syscalls.h>
#include <linux/tcp.h>
#include <linux/types.h>
#include <linux/version.h>
asmlinkage ssize_t (*orig_open)(const char *pathname, int flags);
asmlinkage ssize_t hooked_open(const char *pathname, int flags)
{
printk(KERN_INFO "SYS_OPEN: %s\n", pathname);
return orig_open(pathname, flags);
}
static int __init root_start(void)
{
unsigned long sys_addr = 0xc003b104; /* System.map */
unsigned long *sys_call_table= (unsigned long *)sys_addr;
orig_open = sys_call_table[__NR_open];
sys_call_table[__NR_open] = hooked_open;
return 0;
}
static void __exit root_stop(void)
{
unsigned long sys_addr = 0xc003b104;
unsigned long *sys_call_table= (unsigned long *)sys_addr;
sys_call_table[__NR_open] = &orig_open;
}
module_init(root_start);
module_exit(root_stop);
-------
When I buid it, the error shows below,
make -C /home/scott/runnymede-crc-2.6.35/ M=`pwd` ARCH=arm CROSS_COMPILE=~/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- modules
make[1]: Entering directory `<home>/runnymede-crc-2.6.35'
CC [M] /<home>/workspace/debugkit/mydebug.o
cc1: warnings being treated as errors
/<home>/workspace/debugkit/mydebug.c: In function 'root_start':
/<home>/workspace/debugkit/mydebug.c:44: error: assignment makes pointer from integer without a cast
/<home>/workspace/debugkit/mydebug.c:45: error: assignment makes integer from pointer without a cast
/<home>/workspace/debugkit/mydebug.c: In function 'root_stop':
/<home>/workspace/debugkit/mydebug.c:55: error: assignment makes integer from pointer without a cast
make[2]: *** [/<home>/workspace/debugkit/mydebug.o] Error 1
make[1]: *** [_module_/<home>/workspace/debugkit] Error 2
make[1]: Leaving directory `/home/scott/runnymede-crc-2.6.35'
make: *** [default] Error 2
Anyone can give me a help for it?

2 things...
you should change in the menu : warnings being treated as errors...this will stop building the kernel also if its only a warning
also you can have probs with the toolchain...you can try this:
http://forum.xda-developers.com/showpost.php?p=23367049&postcount=112
with kind regards

Related

[INFO] Details on boot logo format

Hi,
I had posted this in the Q&A thread, thought I would post it here as well.
Glossary:
boot logo: the static image you see when you turn on the phone.
boot animation: a series of pics in a zip file that are displayed after the boot logo.
Hi,
If you want to change the boot logo, you just fastboot flash logo logo.bin. It's mmcblk0p8.
The format is a constant string, 4 bytes, "SOL:" followed by 4 zero bytes, followed by 4 bytes for the width, 540, 4 bytes for the height 960, and the raw data of the image. Each pixel is 2 bytes, it's 565 format.
save a png as 540x960 called logo.png
$ convert -depth 8 logo.png rgb:logo.raw
$ ./rgb2565 < logo.raw > temp.bin
$ cat logo-heaader.bin temp.bin > logo.bin
$ sudo ./moto-fastboot flash logo logo.bin
Here is the source to rgb2565:
Code:
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define to565(r,g,b) \
((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3))
#define from565_r(x) ((((x) >> 11) & 0x1f) * 255 / 31)
#define from565_g(x) ((((x) >> 5) & 0x3f) * 255 / 63)
#define from565_b(x) (((x) & 0x1f) * 255 / 31)
void to_565_raw(void)
{
unsigned char in[3];
unsigned short out;
while(read(0, in, 3) == 3) {
out = to565(in[0],in[1],in[2]);
write(1, &out, 2);
}
return;
}
void to_565_raw_dither(int width)
{
unsigned char in[3];
unsigned short out;
int i = 0;
int e;
int* error = malloc((width+2) * 3 * sizeof(int));
int* next_error = malloc((width+2) * 3 * sizeof(int));
memset(error, 0, (width+2) * 3 * sizeof(int));
memset(next_error, 0, (width+2) * 3 * sizeof(int));
error += 3; // array goes from [-3..((width+1)*3+2)]
next_error += 3;
while(read(0, in, 3) == 3) {
int r = in[0] + error[i*3+0];
int rb = (r < 0) ? 0 : ((r > 255) ? 255 : r);
int g = in[1] + error[i*3+1];
int gb = (g < 0) ? 0 : ((g > 255) ? 255 : g);
int b = in[2] + error[i*3+2];
int bb = (b < 0) ? 0 : ((b > 255) ? 255 : b);
out = to565(rb, gb, bb);
write(1, &out, 2);
#define apply_error(ch) { \
next_error[(i-1)*3+ch] += e * 3 / 16; \
next_error[(i)*3+ch] += e * 5 / 16; \
next_error[(i+1)*3+ch] += e * 1 / 16; \
error[(i+1)*3+ch] += e - ((e*1/16) + (e*3/16) + (e*5/16)); \
}
e = r - from565_r(out);
apply_error(0);
e = g - from565_g(out);
apply_error(1);
e = b - from565_b(out);
apply_error(2);
#undef apply_error
++i;
if (i == width) {
// error <- next_error; next_error <- 0
int* temp = error; error = next_error; next_error = temp;
memset(next_error, 0, (width+1) * 3 * sizeof(int));
i = 0;
}
}
free(error-3);
free(next_error-3);
return;
}
void to_565_rle(void)
{
unsigned char in[3];
unsigned short last, color, count;
unsigned total = 0;
count = 0;
while(read(0, in, 3) == 3) {
color = to565(in[0],in[1],in[2]);
if (count) {
if ((color == last) && (count != 65535)) {
count++;
continue;
} else {
write(1, &count, 2);
write(1, &last, 2);
total += count;
}
}
last = color;
count = 1;
}
if (count) {
write(1, &count, 2);
write(1, &last, 2);
total += count;
}
fprintf(stderr,"%d pixels\n",total);
}
int main(int argc, char **argv)
{
if ((argc == 2) && (!strcmp(argv[1],"-rle"))) {
to_565_rle();
} else {
if (argc > 2 && (!strcmp(argv[1], "-w"))) {
to_565_raw_dither(atoi(argv[2]));
} else {
to_565_raw();
}
}
return 0;
}
See example logo.bin attached.
Cheers!​
dumb question, had u tried this?
luismanson said:
dumb question, had u tried this?
Click to expand...
Click to collapse
Hi,
If you want an example, try my zoomquilt2 bootanimation.
[BOOTANIMATION] HD bootanimation zoom quilt 1 & 2
Only downside is that things like "unlocked" show up on top of the logo, so design with a back background to avoid that.
Cheers!
NFHimself said:
Hi,
If you want an example, try my zoomquilt2 bootanimation.
[BOOTANIMATION] HD bootanimation zoom quilt 1 & 2
Only downside is that things like "unlocked" show up on top of the logo, so design with a back background to avoid that.
Cheers!
Click to expand...
Click to collapse
I believe this post refers to the initial boot logo, not the boot animation that follows.
yeah, the OP got confused... now i dont know if i should try this
Guys, if you read the zoomquilt thread, it replaces the logo.bin and boot animation. OP didn't confuse himself.
Is there a maximum size to the bootlogo file, I have a spica as well and many people have bricked there spica if they flash a bootlogo bigger than 192 kb as it results in overwriting the Bootloader or something like that.
PS:- The bricks are hard bricks.
munchy_cool said:
Is there a maximum size to the bootlogo file, I have a spica as well and many people have bricked there spica if they flash a bootlogo bigger than 192 kb as it results in overwriting the Bootloader or something like that.
PS:- The bricks are hard bricks.
Click to expand...
Click to collapse
Hi,
If you create the file correctly, if will always be the same size (1036820), it's not like other android logos (initlogo.rle) that are rle compressed. there is the header and a raw 565 format image, that's it.
For an initlogo.rle you would use ./rgb2565 -rle < logo.raw > temp.bin.
Cheers!
^^ thanks a lot.
thanks 4 this, finally got it!!!
OSNPA said:
Guys, if you read the zoomquilt thread, it replaces the logo.bin and boot animation. OP didn't confuse himself.
Click to expand...
Click to collapse
My bad.
Didn't catch that part in the zoomquilt thread.
Edit:
This worked like a charm too!
Something I threw together as a test.
Left a black strip up top so I could see boot messages.
The preview below looks like garbage compared to how it looks on the phone.

Java maze solver HELP

I've been working on trying to create a maze solver method using an enum, but it has not been going so well.
This is the enum class:
Code:
public enum Direction {
N, NE, E, SE, S, SW, W, NW, HERE;
/**
* Returns the X/column change on the screen that is associated with
* this direction: -1 for W, 0 for N/S, and +1 for E.
*/
public int getColModifier() {
int mod;
switch (this) {
case NW:
case W:
case SW:
mod = -1;
break;
case NE:
case E:
case SE:
mod = +1;
break;
default:
mod = 0;
break;
}
return mod;
}
/**
* Returns the Y/row change on the screen that is associated with
* this direction: -1 for N, 0 for E/W, and +1 for south.
*/
public int getRowModifier() {
int mod;
switch (this) {
case N:
case NE:
case NW:
mod = -1;
break;
case S:
case SE:
case SW:
mod = +1;
break;
default:
mod = 0;
break;
}
return mod;
}
/** As {@link #getColModifier()} */
public int getXModifier() {
return this.getColModifier();
}
/** As {@link #getRowModifier()} */
public int getYModifier() {
return this.getRowModifier();
}
/**
* Returns the direction that is the opposite of this one.
* For example, <code>Direction.NE.reverse() == Direction.SW</code>.
* (The opposite of HERE is still HERE though.)
*/
public Direction reverse() {
if (this == HERE) {
return this;
}else {
int reversed = (this.ordinal() + 4) % 8;
Direction[] dirs = Direction.values();
return dirs[reversed];
}
}
}
and this is the method that I have been trying to write:
Code:
public java.util.ArrayList<Direction> getPathToExit(){
for (int x=0; x<map.length; x++){
for (int y=0; y<map[x].length; y++){
if (map[x][y]=='S'){
this.startRow=x;
this.startCol=y;
}
}
}
System.out.println("start "+startRow+", "+startCol);
return getPathToExit(this.startRow, this.startCol);
}
private java.util.ArrayList<Direction> getPathToExit(int row, int col){
Direction [] dirs = Direction.values();
ArrayList<Direction> path = new ArrayList<Direction>();
getPathToExit(row, col);
if (row < 0 || col < 0 || row > map.length || col > map[row].length){
return path;
}
else if (map[row][col] != ' '){
return path;
}
else if (map[row][col] == 'E'){
path.add(Direction.HERE);
return path;
}
else {
for (int x=0; x<dirs.length-1; x++){
map[row][col]='x';
int nextRow = row + dirs[x].getRowModifier();
int nextCol = col + dirs[x].getColModifier();
path = getPathToExit(nextRow, nextCol);
}
}
return path;
}
The problem I am having is that I keep getting stackoverflowerrors or the piece does not move (tested this by printing what row/col it is on), it would stay on the same tile then crash.
Thanks in advance.

Extracting boot.img and recovery.img

Hello,
I was hoping I could help port a custom recovery to the x86 platform, but I ran into a problem pretty early...:
I have extracted the boot and recovery partitionen images like this:
Code:
# cat /proc/partitions
major minor #blocks name alias
179 0 7766016 mmcblk0 (null)
179 1 11264 mmcblk0p1 bos
179 2 11264 mmcblk0p2 bosbackup
179 3 1024 mmcblk0p3 ulogo
179 4 1024 mmcblk0p4 logo
179 5 11264 mmcblk0p5 boot
179 6 11264 mmcblk0p6 recovery
179 7 128 mmcblk0p7 cid
179 8 2048 mmcblk0p8 sp
179 9 8192 mmcblk0p9 panic
179 10 512 mmcblk0p10 devtree
179 11 512 mmcblk0p11 devtreeBackup
259 0 8192 mmcblk0p12 pds
259 1 512 mmcblk0p13 misc
259 2 655360 mmcblk0p14 cache
259 3 153600 mmcblk0p15 cdrom
259 4 1253376 mmcblk0p16 system
259 5 5599471 mmcblk0p17 userdata
179 12 3872256 mmcblk1 (null)
179 13 2840820 mmcblk1p1
179 14 1000000 mmcblk1p2
179 15 31435 mmcblk1p3
# cat /dev/block/mmcblk0p6 > /external1/recovery.img
# cat /dev/block/mmcblk0p5 > /external1/boot.img
But I get the following message when I try to extract the recovery's ramdisk:
Code:
$ ./split_bootimg.pl recovery.img
Android Magic not found in recovery.img. Giving up.
I haven't had this problem before. Is it happening because the differences between the x86 and ARM images is too different?
Thanks!
EDIT:
I have extracted the kernel and ramdisk from the recovery.img using a Hex Editor. You'll find a link to the files below:
dl.dropbox.com/u/19117372/recovery_files.zip
That's what the theory is. Its stopping us from using the kernel source and making a custom recovery because we cannot unpack or pack them.
Sent from my XT890 using Tapatalk 2
mattlgroff said:
That's what the theory is. Its stopping us from using the kernel source and making a custom recovery because we cannot unpack or pack them.
Sent from my XT890 using Tapatalk 2
Click to expand...
Click to collapse
Apparently the script I used looks for this string: "ANDROID!" in the beginning of the binary file. But this image starts with "init=/init". Is there any other Android devices that does this?
I've downloaded the Android x86 ics source code from Intel and they use the standard:
Code:
#define BOOT_MAGIC "ANDROID!"
When packing the img.
V-g- said:
Apparently the script I used looks for this string: "ANDROID!" in the beginning of the binary file. But this image starts with "init=/init". Is there any other Android devices that does this?
I've downloaded the Android x86 ics source code from Intel and they use the standard:
Code:
#define BOOT_MAGIC "ANDROID!"
When packing the img.
Click to expand...
Click to collapse
It would be better to look at the other Intel Android Devices like the Orange San Diego and see what their images are. The Android x86 project doesn't even pack the boot.img from when I used it, but maybe I'm remembering wrong.
Sent from my XT890 using Tapatalk 2
mattlgroff said:
That's what the theory is. Its stopping us from using the kernel source and making a custom recovery because we cannot unpack or pack them.
Sent from my XT890 using Tapatalk 2
Click to expand...
Click to collapse
I've been able to unpack and repack the boot.img using a hex editor (same way we got insecure boot in the first place) and am able to manipulate the contents of the ramdisk, but have not been able to compile a recovery for Intel. As for the standard tools/scripts, I don't think they're capable of dealing with the second stage which is optional in the img format but used by the Razr i (http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack%2C_Edit%2C_and_Re-Pack_Boot_Images).
dew.man said:
I've been able to unpack and repack the boot.img using a hex editor (same way we got insecure boot in the first place) and am able to manipulate the contents of the ramdisk, but have not been able to compile a recovery for Intel. As for the standard tools/scripts, I don't think they're capable of dealing with the second stage which is optional in the img format but used by the Razr i (http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack%2C_Edit%2C_and_Re-Pack_Boot_Images).
Click to expand...
Click to collapse
I think our best bet right now is to hope Motorola can give us documentation on this when the new MotoDev.com comes on November 1st. No device has really been in this position before, so the current tools and documentation aren't helpful. I appreciate you taking a look.
---------- Post added at 03:28 PM ---------- Previous post was at 03:19 PM ----------
Found this in the sourceforge under system_core.tar.gz:
Maybe helpful...maybe not. The tools could be in the sourceforge.
Android.mk
Code:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := mkbootimg.c
LOCAL_STATIC_LIBRARIES := libmincrypt
LOCAL_MODULE := mkbootimg
include $(BUILD_HOST_EXECUTABLE)
$(call dist-for-goals,dist_files,$(LOCAL_BUILT_MODULE))
mkbootimg.c
Code:
/* tools/mkbootimg/mkbootimg.c
**
** Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "mincrypt/sha.h"
#include "bootimg.h"
static void *load_file(const char *fn, unsigned *_sz)
{
char *data;
int sz;
int fd;
data = 0;
fd = open(fn, O_RDONLY);
if(fd < 0) return 0;
sz = lseek(fd, 0, SEEK_END);
if(sz < 0) goto oops;
if(lseek(fd, 0, SEEK_SET) != 0) goto oops;
data = (char*) malloc(sz);
if(data == 0) goto oops;
if(read(fd, data, sz) != sz) goto oops;
close(fd);
if(_sz) *_sz = sz;
return data;
oops:
close(fd);
if(data != 0) free(data);
return 0;
}
int usage(void)
{
fprintf(stderr,"usage: mkbootimg\n"
" --kernel <filename>\n"
" --ramdisk <filename>\n"
" [ --second <2ndbootloader-filename> ]\n"
" [ --cmdline <kernel-commandline> ]\n"
" [ --board <boardname> ]\n"
" [ --base <address> ]\n"
" [ --pagesize <pagesize> ]\n"
" -o|--output <filename>\n"
);
return 1;
}
static unsigned char padding[4096] = { 0, };
int write_padding(int fd, unsigned pagesize, unsigned itemsize)
{
unsigned pagemask = pagesize - 1;
unsigned count;
if((itemsize & pagemask) == 0) {
return 0;
}
count = pagesize - (itemsize & pagemask);
if(write(fd, padding, count) != count) {
return -1;
} else {
return 0;
}
}
int main(int argc, char **argv)
{
boot_img_hdr hdr;
char *kernel_fn = 0;
void *kernel_data = 0;
char *ramdisk_fn = 0;
void *ramdisk_data = 0;
char *second_fn = 0;
void *second_data = 0;
char *cmdline = "";
char *bootimg = 0;
char *board = "";
unsigned pagesize = 2048;
int fd;
SHA_CTX ctx;
uint8_t* sha;
argc--;
argv++;
memset(&hdr, 0, sizeof(hdr));
/* default load addresses */
hdr.kernel_addr = 0x10008000;
hdr.ramdisk_addr = 0x11000000;
hdr.second_addr = 0x10F00000;
hdr.tags_addr = 0x10000100;
while(argc > 0){
char *arg = argv[0];
char *val = argv[1];
if(argc < 2) {
return usage();
}
argc -= 2;
argv += 2;
if(!strcmp(arg, "--output") || !strcmp(arg, "-o")) {
bootimg = val;
} else if(!strcmp(arg, "--kernel")) {
kernel_fn = val;
} else if(!strcmp(arg, "--ramdisk")) {
ramdisk_fn = val;
} else if(!strcmp(arg, "--second")) {
second_fn = val;
} else if(!strcmp(arg, "--cmdline")) {
cmdline = val;
} else if(!strcmp(arg, "--base")) {
unsigned base = strtoul(val, 0, 16);
hdr.kernel_addr = base + 0x00008000;
hdr.ramdisk_addr = base + 0x01000000;
hdr.second_addr = base + 0x00F00000;
hdr.tags_addr = base + 0x00000100;
} else if(!strcmp(arg, "--board")) {
board = val;
} else if(!strcmp(arg,"--pagesize")) {
pagesize = strtoul(val, 0, 10);
if ((pagesize != 2048) && (pagesize != 4096)) {
fprintf(stderr,"error: unsupported page size %d\n", pagesize);
return -1;
}
} else {
return usage();
}
}
hdr.page_size = pagesize;
if(bootimg == 0) {
fprintf(stderr,"error: no output filename specified\n");
return usage();
}
if(kernel_fn == 0) {
fprintf(stderr,"error: no kernel image specified\n");
return usage();
}
if(ramdisk_fn == 0) {
fprintf(stderr,"error: no ramdisk image specified\n");
return usage();
}
if(strlen(board) >= BOOT_NAME_SIZE) {
fprintf(stderr,"error: board name too large\n");
return usage();
}
strcpy(hdr.name, board);
memcpy(hdr.magic, BOOT_MAGIC, BOOT_MAGIC_SIZE);
if(strlen(cmdline) > (BOOT_ARGS_SIZE - 1)) {
fprintf(stderr,"error: kernel commandline too large\n");
return 1;
}
strcpy((char*)hdr.cmdline, cmdline);
kernel_data = load_file(kernel_fn, &hdr.kernel_size);
if(kernel_data == 0) {
fprintf(stderr,"error: could not load kernel '%s'\n", kernel_fn);
return 1;
}
if(!strcmp(ramdisk_fn,"NONE")) {
ramdisk_data = 0;
hdr.ramdisk_size = 0;
} else {
ramdisk_data = load_file(ramdisk_fn, &hdr.ramdisk_size);
if(ramdisk_data == 0) {
fprintf(stderr,"error: could not load ramdisk '%s'\n", ramdisk_fn);
return 1;
}
}
if(second_fn) {
second_data = load_file(second_fn, &hdr.second_size);
if(second_data == 0) {
fprintf(stderr,"error: could not load secondstage '%s'\n", second_fn);
return 1;
}
}
/* put a hash of the contents in the header so boot images can be
* differentiated based on their first 2k.
*/
SHA_init(&ctx);
SHA_update(&ctx, kernel_data, hdr.kernel_size);
SHA_update(&ctx, &hdr.kernel_size, sizeof(hdr.kernel_size));
SHA_update(&ctx, ramdisk_data, hdr.ramdisk_size);
SHA_update(&ctx, &hdr.ramdisk_size, sizeof(hdr.ramdisk_size));
SHA_update(&ctx, second_data, hdr.second_size);
SHA_update(&ctx, &hdr.second_size, sizeof(hdr.second_size));
sha = SHA_final(&ctx);
memcpy(hdr.id, sha,
SHA_DIGEST_SIZE > sizeof(hdr.id) ? sizeof(hdr.id) : SHA_DIGEST_SIZE);
fd = open(bootimg, O_CREAT | O_TRUNC | O_WRONLY, 0644);
if(fd < 0) {
fprintf(stderr,"error: could not create '%s'\n", bootimg);
return 1;
}
if(write(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) goto fail;
if(write_padding(fd, pagesize, sizeof(hdr))) goto fail;
if(write(fd, kernel_data, hdr.kernel_size) != hdr.kernel_size) goto fail;
if(write_padding(fd, pagesize, hdr.kernel_size)) goto fail;
if(write(fd, ramdisk_data, hdr.ramdisk_size) != hdr.ramdisk_size) goto fail;
if(write_padding(fd, pagesize, hdr.ramdisk_size)) goto fail;
if(second_data) {
if(write(fd, second_data, hdr.second_size) != hdr.second_size) goto fail;
if(write_padding(fd, pagesize, hdr.ramdisk_size)) goto fail;
}
return 0;
fail:
unlink(bootimg);
close(fd);
fprintf(stderr,"error: failed writing '%s': %s\n", bootimg,
strerror(errno));
return 1;
}
bootimg.h
Code:
/* tools/mkbootimg/bootimg.h
**
** Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
#ifndef _BOOT_IMAGE_H_
#define _BOOT_IMAGE_H_
typedef struct boot_img_hdr boot_img_hdr;
#define BOOT_MAGIC "ANDROID!"
#define BOOT_MAGIC_SIZE 8
#define BOOT_NAME_SIZE 16
#define BOOT_ARGS_SIZE 512
struct boot_img_hdr
{
unsigned char magic[BOOT_MAGIC_SIZE];
unsigned kernel_size; /* size in bytes */
unsigned kernel_addr; /* physical load addr */
unsigned ramdisk_size; /* size in bytes */
unsigned ramdisk_addr; /* physical load addr */
unsigned second_size; /* size in bytes */
unsigned second_addr; /* physical load addr */
unsigned tags_addr; /* physical addr for kernel tags */
unsigned page_size; /* flash page size we assume */
unsigned unused[2]; /* future expansion: should be 0 */
unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */
unsigned char cmdline[BOOT_ARGS_SIZE];
unsigned id[8]; /* timestamp / checksum / sha1 / etc */
};
/*
** +-----------------+
** | boot header | 1 page
** +-----------------+
** | kernel | n pages
** +-----------------+
** | ramdisk | m pages
** +-----------------+
** | second stage | o pages
** +-----------------+
**
** n = (kernel_size + page_size - 1) / page_size
** m = (ramdisk_size + page_size - 1) / page_size
** o = (second_size + page_size - 1) / page_size
**
** 0. all entities are page_size aligned in flash
** 1. kernel and ramdisk are required (size != 0)
** 2. second is optional (second_size == 0 -> no second)
** 3. load each element (kernel, ramdisk, second) at
** the specified physical address (kernel_addr, etc)
** 4. prepare tags at tag_addr. kernel_args[] is
** appended to the kernel commandline in the tags.
** 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
** 6. if second_size != 0: jump to second_addr
** else: jump to kernel_addr
*/
#if 0
typedef struct ptentry ptentry;
struct ptentry {
char name[16]; /* asciiz partition name */
unsigned start; /* starting block number */
unsigned length; /* length in blocks */
unsigned flags; /* set to zero */
};
/* MSM Partition Table ATAG
**
** length: 2 + 7 * n
** atag: 0x4d534d70
** <ptentry> x n
*/
#endif
#endif
http://www.sourceforge.net/motorola/razr-i/
dew.man said:
I've been able to unpack and repack the boot.img using a hex editor (same way we got insecure boot in the first place) and am able to manipulate the contents of the ramdisk, but have not been able to compile a recovery for Intel. As for the standard tools/scripts, I don't think they're capable of dealing with the second stage which is optional in the img format but used by the Razr i.
Click to expand...
Click to collapse
Great! - Would you mind sharing how you did it?
V-g- said:
Great! - Would you mind sharing how you did it?
Click to expand...
Click to collapse
http://forum.xda-developers.com/showpost.php?p=32406634&postcount=120
Hey guys currently trying it too, because i realy need my lovely cwm
when i open the boot.img i see this:
androidboot.bootmedia=sdcard
so if i theoretically would change that to external1
would it boot from my sdcard?!

[Q] Kernel LED Brightness - mA Table

I am struggling a bit with the LED brightness.
in
Code:
drivers/leds/leds-bd2802.c
i have the following code
Code:
#define BD2802_CURRENT_WHITE_PEAK 0x5 /* 18mA */
#define BD2802_CURRENT_WHITE_MAX 0x01c /* 5.6mA */
#define BD2802_CURRENT_BLUE_MAX 0x01c /* 5.6mA */
#define BD2802_CURRENT_WHITE_MIN 0x03 /* 0.6mA */
#define BD2802_CURRENT_BLUE_MIN 0x03 /* 0.6mA */
#define BD2802_CURRENT_000 0x00 /* 0.0mA */
What i would like to know, how do i know, which hex value equals which mA value?
i tried googling but didnt find anything.
is there any chart / table to calculate between the hex and mA value?
Thank you

Android Don't execute anything until location variable exists

Goodmorning, I've tried to implement the method that request permission first and than execute something but without success ...
Here is my MainActivity code:
Code:
public class MainActivity extends AppCompatActivity {
public static String latitudineCorrente = ""; //current Latitude
public static String longitudineCorrente = ""; //current Longitude
private SharedPreferences sharedPreferences; //shared preferences
private SharedPreferences.Editor mEditor; // shared preferences editor
/* Variable for getting location */
private FusedLocationProviderClient fusedLocationProviderClient;
private LocationRequest locationRequest;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String appLanguage = "ita";
LanguageUtil.setAppLanguage(getApplicationContext(), appLanguage);
/* .... other code.... */
sharedPreferences = this.getSharedPreferences("appname", MODE_PRIVATE);
mEditor = sharedPreferences.edit(); // set edit sharedpreferences
richiamaPermessi(); //permission request
requestLocationUpdates(); // function requestlocationupdates();
CaricamentoInizialeApplicazione(); // function for presetting configurations
}
private void CaricamentoInizialeApplicazione() {
boolean configIniziale = sharedPreferences.getBoolean("configurazioneinizialeok", false);
if(!configIniziale)
{
/* can't execute this because Double.parseDouble(this.latitudineCorrente), Double.parseDouble(this.longitudineCorrente) */
ApiMarkers.getMarkers(MainActivity.this, 0, 400,
Double.parseDouble(this.latitudineCorrente), Double.parseDouble(this.longitudineCorrente),
0, 0,0,1, 0,0,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
/* response elaborations */
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
dialog.dismiss();
Toast.makeText(MainActivity.this, "" + error.getMessage(), Toast.LENGTH_LONG).show();
error.printStackTrace();
}
});
mEditor.putBoolean("configurazioneinizialeok", true);
mEditor.commit();
}
}
/* Function for requist location updates */
public void requestLocationUpdates() {
if(ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) ==
PermissionChecker.PERMISSION_GRANTED && ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) ==
PermissionChecker.PERMISSION_GRANTED) {
fusedLocationProviderClient = new FusedLocationProviderClient(this);
locationRequest = new LocationRequest();
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
locationRequest.setFastestInterval(1500);
locationRequest.setInterval(3000);
fusedLocationProviderClient.requestLocationUpdates(locationRequest, new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
super.onLocationResult(locationResult);
mEditor = sharedPreferences.edit();
mEditor.putString("latitudine", String.valueOf(locationResult.getLastLocation().getLatitude()));
mEditor.putString("longitudine", String.valueOf(locationResult.getLastLocation().getLongitude()));
MainActivity.latitudineCorrente = String.valueOf(locationResult.getLastLocation().getLatitude());
MainActivity.longitudineCorrente = String.valueOf(locationResult.getLastLocation().getLongitude());
Log.d("coordinate", "MAIN ACTIVITY: Latitudine: " + MainActivity.latitudineCorrente + "/"
+ "Longitudine: " + MainActivity.longitudineCorrente);
}
}, getMainLooper());
} else richiamaPermessi();
}
/* Function for requesting access */
public void richiamaPermessi()
{
Permissions.check(this, new String[] { Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION},
"Permessi di locazione obbligatori per determinare la propria posizione!",
new Permissions.Options().setSettingsDialogTitle("Avviso").setRationaleDialogTitle("Permessi locazione"),
new PermissionHandler() {
@Override
public void onGranted() {
requestLocationUpdates();
}
@Override
public void onDenied(Context context, ArrayList<String> deniedPermissions) {
super.onDenied(context, deniedPermissions);
richiamaPermessi();
}
});
}
}
The problem is executing function ApiMarkers.getMarkers(.... with latitude and longitude filled ...) but can't execute because latitude and longitude are not loaded... I spent two nights without solution Thanks for any help! Cristian
Up! I tried to follow this video on youtube youtube.com/watch?v=gEcFf2Mv4L0 and in any case I could not understand where or when I can call the method "CaricamentoInizialeApplicazione ()" in order to call a method that uses the location coordinates! What I want is to make sure that I don't call the method already said until the location coordinates are loaded into the variables indicated in the code! Is it possible that someone is not able to solve the problem? Thank you
Oh thanks for any help!

Categories

Resources