The Following User Says Thank You to Mentalist Traceur For This Useful Post: | ||
![]() |
2013-11-06
, 09:28
|
Posts: 2,225 |
Thanked: 3,822 times |
Joined on Jun 2010
@ Florida
|
#42
|
![]() |
2013-11-06
, 10:08
|
Posts: 1,163 |
Thanked: 1,873 times |
Joined on Feb 2011
@ The Netherlands
|
#43
|
Edit: P.S. reinob, etc, anyone still left with an N900 that hasn't been R&D mode turned-on, ever?
The Following 2 Users Say Thank You to mr_pingu For This Useful Post: | ||
![]() |
2013-11-06
, 10:14
|
Posts: 1,808 |
Thanked: 4,272 times |
Joined on Feb 2011
@ Germany
|
#44
|
prepare_start_udev /sbin/udevd --daemon
echo -n "Mounting a tmpfs over /dev..." mount -n -o size=$tmpfs_size,mode=0755,noatime -t tmpfs none /dev
The Following 4 Users Say Thank You to reinob For This Useful Post: | ||
![]() |
2013-11-06
, 13:11
|
Posts: 1,808 |
Thanked: 4,272 times |
Joined on Feb 2011
@ Germany
|
#45
|
The Following 4 Users Say Thank You to reinob For This Useful Post: | ||
![]() |
2013-11-06
, 13:41
|
Posts: 3,074 |
Thanked: 12,964 times |
Joined on Mar 2010
@ Sofia,Bulgaria
|
#46
|
Hi again,
I have just had a look at @freemangordon's implementation of libcal, and it's a bit weird.
First of all: cal_read_block() and cal_write_block() do *internally* cal_init_ and cal_finish_ (which do the actual set-up and free()ing of the buffers).
So from the point of view of a user application you do not need to call cal_init() or cal_finish(), as they are nops.
But cal_write_block_() has a problem when len = 0, because it does malloc(len), which when len is zero may return NULL or a pointer. If NULL however, the function exits with an error (CAL_ERROR). This is something for @freemangordon to fix, unless it is required that when writing len > 0, meaning there should be another function to erase a CAL block.
The Following 4 Users Say Thank You to freemangordon For This Useful Post: | ||
![]() |
2013-11-06
, 14:09
|
Posts: 1,808 |
Thanked: 4,272 times |
Joined on Feb 2011
@ Germany
|
#47
|
It is not "my implementation" but a RE, so whathever weirdness you found, most probably it is Nokia legacy. I even fixed some obvious bugs, but not all of them.
I disagree, those are part of the API and the implementation may change in the future versions.
Correct. And this comes from the Nokia (I'll double-check with IDA again). I think libcal was never meant to be used for block erasure, that is why len == 0 is not checked for. On the other hand it is possible that malloc in our glibc to return non-NULL for zero-sized allocation, so there is no (real)problem. However, len == 0 case should be processed correctly(it is going in my todo list, along with packaging).
The Following 2 Users Say Thank You to reinob For This Useful Post: | ||
![]() |
2013-11-06
, 20:31
|
Posts: 1,808 |
Thanked: 4,272 times |
Joined on Feb 2011
@ Germany
|
#48
|
CAL DEBUG: found block 'part_table' at config1 vaddr 00000000 (ver 0, len 96) CAL DEBUG: found block 'bme' at config1 vaddr 00000800 (ver 0, len 1536) CAL DEBUG: found block 'phone-info' at config1 vaddr 00001000 (ver 0, len 42) CAL DEBUG: found block 'phone-info' at config1 vaddr 00001800 (ver 1, len 42) CAL DEBUG: found block 'phone-info' at config1 vaddr 00002000 (ver 2, len 42) CAL DEBUG: found block 'phone-info' at config1 vaddr 00002800 (ver 3, len 42) CAL DEBUG: found block 'phone-info' at config1 vaddr 00003000 (ver 4, len 42) CAL DEBUG: found block 'wlan-tx-cost3_0' at config1 vaddr 00003800 (ver 0, len 756) CAL DEBUG: found block 'bme' at config1 vaddr 00004000 (ver 1, len 1536) CAL DEBUG: found block 'bme' at config1 vaddr 00004800 (ver 2, len 1536) CAL DEBUG: found block 'bme' at config1 vaddr 00005000 (ver 3, len 1536) CAL DEBUG: found block 'bme' at config1 vaddr 00005800 (ver 4, len 1536) CAL DEBUG: found block 'bme' at config1 vaddr 00006000 (ver 5, len 1536) CAL DEBUG: found block 'bme' at config1 vaddr 00006800 (ver 6, len 1536) CAL DEBUG: found block 'fmtx_pwl' at config1 vaddr 00007000 (ver 0, len 36) CAL DEBUG: found block 'fmtx_pwl' at config1 vaddr 00007800 (ver 1, len 36) CAL DEBUG: found block 'fmtx_pwl' at config1 vaddr 00008000 (ver 2, len 36) CAL DEBUG: found block 'phone-info' at config1 vaddr 00008800 (ver 5, len 42) CAL DEBUG: found block 'als_calib' at config1 vaddr 00009000 (ver 0, len 8) CAL DEBUG: found block 'cert-npc' at config1 vaddr 00009800 (ver 0, len 448) CAL DEBUG: found block 'cert-ccc' at config1 vaddr 0000a000 (ver 0, len 448) CAL DEBUG: found block 'cert-hwc' at config1 vaddr 0000a800 (ver 0, len 256) CAL DEBUG: found block 'phone-info' at config1 vaddr 0000b000 (ver 6, len 42) CAL DEBUG: found block 'nolo-ver' at user vaddr 00000000 (ver 0, len 17) CAL DEBUG: found block 'kernel-ver' at user vaddr 00000800 (ver 0, len 23) CAL DEBUG: found block 'sw-release-ver' at user vaddr 00001000 (ver 0, len 33) CAL DEBUG: found block 'lock_code' at user vaddr 00001800 (ver 0, len 16) CAL DEBUG: found block 'nolo-ver' at user vaddr 00002000 (ver 1, len 12) CAL DEBUG: found block 'kernel-ver' at user vaddr 00002800 (ver 1, len 21) CAL DEBUG: found block 'sw-release-ver' at user vaddr 00003000 (ver 1, len 31) CAL DEBUG: found block 'content-ver' at user vaddr 00003800 (ver 0, len 29) CAL DEBUG: found block 'sw-release-ver' at user vaddr 00004000 (ver 2, len 32) CAL DEBUG: found block 'lock_enable' at user vaddr 00004800 (ver 0, len 4) CAL DEBUG: found block 'lock_period' at user vaddr 00005000 (ver 0, len 4) CAL DEBUG: found block 'lock_code' at user vaddr 00005800 (ver 1, len 40) CAL DEBUG: found block 'sw-release-ver' at user vaddr 00006000 (ver 3, len 32) CAL DEBUG: found block 'r&d_mode' at user vaddr 00006800 (ver 0, len 7) CAL DEBUG: found block 'r&d_mode' at user vaddr 00007000 (ver 1, len 63) CAL DEBUG: found block 'r&d_mode' at user vaddr 00007800 (ver 2, len 78) CAL DEBUG: found block 'r&d_mode' at user vaddr 00008000 (ver 3, len 63) CAL DEBUG: found block 'r&d_mode' at user vaddr 00008800 (ver 4, len 78) CAL DEBUG: found block 'r&d_mode' at user vaddr 00009000 (ver 5, len 63) CAL DEBUG: trying to find user block 'r&d_mode' CAL DEBUG: checking block 'nolo-ver' CAL DEBUG: checking block 'kernel-ver' CAL DEBUG: checking block 'content-ver' CAL DEBUG: checking block 'lock_enable' CAL DEBUG: checking block 'lock_period' CAL DEBUG: checking block 'lock_code' CAL DEBUG: checking block 'sw-release-ver' CAL DEBUG: checking block 'r&d_mode'
The Following 2 Users Say Thank You to reinob For This Useful Post: | ||
![]() |
2013-11-07
, 08:47
|
Posts: 2,225 |
Thanked: 3,822 times |
Joined on Jun 2010
@ Florida
|
#49
|
I believe my 1st N900 never been in R&D-mode, but I am not sure. But hey, it's worth the try right?
@Mentalist Traceur,
/dev is actually not stored in the filesystem, but also a tmpfs.
Going back to /etc/init.d/rcS (I have to someday post details about the whole /etc/init.d in the Maemo5 boot process thread, which only dealt with the upstart part).
IN SHORT:
if you run your program during your early boot console, rcS has not run yet, so udev is not running yet and /dev is merely a directory of your rootfs, where you can store your p0rn if wanted (and your semaphores
Once rcS runs whatever you had under /dev is not visible anymore.
[EDIT] so yes, feel free to mkdir -p /dev/shm before rcS runs, this way nothing should segfault
[EDIT**2] I just modified /etc/udev/udev.conf and changed the size to "512k". Maemo booted fine (this is my "production" N900). Obviously I cannot tell if less actual RAM is being used or not, but I internally feel better knowing that less RAM-management is taking place
Hi again,
I have just had a look at @freemangordon's implementation of libcal, and it's a bit weird.
First of all: cal_read_block() and cal_write_block() do *internally* cal_init_ and cal_finish_ (which do the actual set-up and free()ing of the buffers).
So from the point of view of a user application you do not need to call cal_init() or cal_finish(), as they are nops.
The first thing your program does is to read the r&d_mode block. After the call to call_read_block the only thing that is valid is tmp_ptr and len, i.e. cal_s has been freed.
So towards the end of the program, when you actually call cal_write_block (if the mode string is different), cal_s is undefined, but it's OK because it will be cal_init_()'ed again.
If I read correctly, when you want to clear r&d_mode (*rd_mode_string == '\0')) you use sizeof(rd_mode_string) as the length. However the length should be zero. sizeof() gives the actual size of rd_mode_string, which is the same as sizeof(char *) which is namely 4 (for a 32-bit computer). You actually want a zero in there.
Basically you want to drop the "if(*rd_mode_string == '\0') and just use the normal path, where you use strlen(rd_mode_string) (which will be zero when rd_mode_string is empty anyway), however you need to get rid of the "+1" (why is it there anyway?, that's going to cause random segmentation faults).
But cal_write_block_() has a problem when len = 0, because it does malloc(len), which when len is zero may return NULL or a pointer. If NULL however, the function exits with an error (CAL_ERROR). This is something for @freemangordon to fix, unless it is required that when writing len > 0, meaning there should be another function to erase a CAL block.
I've printed cal.c and will read it when I'm on the train. Maybe I spot something.
Correct. And this comes from the Nokia (I'll double-check with IDA again). I think libcal was never meant to be used for block erasure, that is why len == 0 is not checked for. On the other hand it is possible that malloc in our glibc to return non-NULL for zero-sized allocation, so there is no (real)problem. However, len == 0 case should be processed correctly(it is going in my todo list, along with packaging).
Thanks. By the way, I just verified (on a N900 having R&D previously set) that setting and clearing a flag using Mentalist Traceur's program (I used serial-console as example) works fine. Double-checked with cal-tool and everything looks OK.
The Following 3 Users Say Thank You to Mentalist Traceur For This Useful Post: | ||
![]() |
2013-11-07
, 09:13
|
Community Council |
Posts: 4,920 |
Thanked: 12,867 times |
Joined on May 2012
@ Southerrn Finland
|
#50
|
Now that libcal is open I may well just write a program to simply allow perusing the data and viewing the data of each block. Unless someone's already done it.
The Following 3 Users Say Thank You to juiceme For This Useful Post: | ||
![]() |
Tags |
command line, on device, r&d mode |
Thread Tools | |
|
So there is still more work do be done, I am missing something somewhere. But for now, I am out. Sleep. Needs to happen. Besides that, I updated the source once again in case the above post didn't make that obvious. I cleaned up the code that handles the R&D-virgin N900s correctly (there was a cal_finish() call left in one of those code paths from years ago, and I fixed the messages it provided to be more meaningful thanks to me getting new understanding of what they mean myself, and made it actually properly distinguish between the 'R&D virgin' error and the other errors that might be returned - I also made it use the cal.h defined macros for the return values of cal_read_block instead of just going by the numerical value as the old code did..
Edit: P.S. reinob, etc, anyone still left with an N900 that hasn't been R&D mode turned-on, ever?
If you want to donate in support of anything that I do, you can do so with either of these options:
PayPal | Bitcoin: 1J4XG2z97iFEKNZXThHdFHq6AeyWEHs8BJ | [Will add other donation options eventually]