Jump to content


Photo

Modifying initial ramdisk


  • Please log in to reply
20 replies to this topic

#1 bayger

bayger

    Member

  • Jr. Member
  • PipPip
  • 20 posts
  • LocationWarsaw, Poland

Posted 19 September 2012 - 03:59 AM

Hi guys,
I am trying to bake a custom ROM from ainol sources. Just to see how it works and learn how to do it properly and in the future try to help community developing custom ROMs for Fire (JB is the target for me). I came to the point where I need to modify init.rc script which resides on the initial ram disk. I know that this stuff is inside boot.img. The question is how to modify that file? I know that the file is in uImage format and it contains the kernel and initramfs, but I don't know how to unpack it and later prepare modified boot.img. I tried some Perl script called unpack-bootimg.pl, but it says that it is not a complete image. I also tried two scripts from Pat's mediafire account called repack.sh and unpack.sh - the device is not bootable after flashing that modified boot.img.

Any idea how to do it properly?

I will be very grateful for any help. :)
Cheers!

UPDATE: [Problem SOLVED]
So basically remove gzip part from repack.sh script and it works just fine. Just remember that this method doesn't allow bigger ramdisks than original.

Edited by bayger, 19 September 2012 - 04:22 PM.


#2 fards

fards

    Advanced Member

  • FW Developer
  • PipPipPip
  • 1,014 posts

Posted 19 September 2012 - 10:32 AM

I prefer building the uImage from kernel source rather than an extracted zImage & initramfs.

which is what you will need to do anyway to get JB running properly.

this is a good set of scripts (the unpack works very well) the repack I'm not convinced by.

http://www.slatedroi...051#entry382051

extract the initramfs and stick it in a folder in the kernel source called out/

to build the kernel
make -f kernel.mk TARGET=g06refe4 INSTALL_ROOT=out/initramfs_<VERSION>/ CROSS_COMPILE=/<DIRECT_PATH_TO>/<TOOLCHAIN>/bin/arm-eabi-


you end up with a uImage and uImage_recovery... rename the uImage_recovery to boot.img and flash with an update.zip

or flash it directly by copying it to the device and flash with
flash_image boot <PATH_TO>uImage_recovery
(or whatever you renamed it).


(not tried the fire yet, but the elfII needed Code Sourcery 0950, Code Sourcery 2010q1 toolchains btw , I've been patching the source to work with later linaro 4.7.2)

see my github for examples of that, I'm waiting to see what the TS fix is before I start messing with the fire source.

Edited by fards, 19 September 2012 - 10:41 AM.

  • Pat Moss likes this
GIthub for source codes.

My github collection

If you feel like donating, then Thank You! but don't stress either way.

#3 bayger

bayger

    Member

  • Jr. Member
  • PipPip
  • 20 posts
  • LocationWarsaw, Poland

Posted 19 September 2012 - 01:35 PM

fards, thank you very much for detailed instructions! Compiling the kernel is the next step on my list. Now I just wanted to see the device booting.

Which is what I finally achieved today. :D I figured out what was wrong with the repack script. It uses gzip to compress cpio'd ramdisk. It is not supported by the bootloader or whatever uses that ramdisk. It must be plain cpio file to boot properly. So finally my Fire is booting JB. Of course there is no wifi, no camera, even no sdcards. I had numerous problems with wrong orientation of display and wrong mapping of touchscreen which was funny. So basically I am learning.

Cheers!

#4 fards

fards

    Advanced Member

  • FW Developer
  • PipPipPip
  • 1,014 posts

Posted 19 September 2012 - 02:00 PM

Lol we're all learning...
The entire uimage uboot is new to me so I'm learning as i go!

my way may not be the best way but its working on the elf ii so far :)

of course any better ways of doing this are much appreciated.



if you have none of those then id say you're init.rc is a bit messed up :)
GIthub for source codes.

My github collection

If you feel like donating, then Thank You! but don't stress either way.

#5 bayger

bayger

    Member

  • Jr. Member
  • PipPip
  • 20 posts
  • LocationWarsaw, Poland

Posted 19 September 2012 - 04:30 PM

Could you share your JB init.rc from Elf2? I believe that it's basically the same hardware except the screen. You said also that there is a need to recompile kernel to work properly with JB. Do you remember what problems did you have with it in JB?

#6 fards

fards

    Advanced Member

  • FW Developer
  • PipPipPip
  • 1,014 posts

Posted 19 September 2012 - 04:53 PM

Could you share your JB init.rc from Elf2? I believe that it's basically the same hardware except the screen. You said also that there is a need to recompile kernel to work properly with JB. Do you remember what problems did you have with it in JB?


I'm not building jb yet,
I'm still working on getting the kernel working with the later Gcc and fixing issues :D

there's the initramfs from Christians CM 10 build (in effect JB ) here>

https://github.com/f...tree/master/out

in terms of what needs changing I haven't looked fully, but from what I've seen jb needs a few tweaks to audio and framebuffer to comply.

I really must sit down soon and start work on whats needed, when I get time.
GIthub for source codes.

My github collection

If you feel like donating, then Thank You! but don't stress either way.

#7 Crihz

Crihz

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 75 posts

Posted 19 September 2012 - 04:57 PM

You guys are getting me motivated to give it a go myself.
Except for one thing...there's a pretty good chance to brick your fire doing this right?

Do you guys simulate a boot after compiling?
"We can all have fun with this device. It is cheap and awesome." - Pat Moss

#8 bayger

bayger

    Member

  • Jr. Member
  • PipPip
  • 20 posts
  • LocationWarsaw, Poland

Posted 20 September 2012 - 02:29 AM

I am willing to sacrifice my Fire for science. ;)

Anyway, there is an unbrick tool for Fire, but it is probably needed only if you damage somehow the recovery. I did tens of flashes without any problem so far. Also I have not experienced touchscreen problems other than wrong mapping touch->screen.

#9 fards

fards

    Advanced Member

  • FW Developer
  • PipPipPip
  • 1,014 posts

Posted 20 September 2012 - 04:17 AM

you'd have to flash a recovery to the nand to mess up the in built recovery I think.

experimenting by booting from the sdcard should prevent that from happening (but does cause unexpected issues such as clockrate getting limited)
GIthub for source codes.

My github collection

If you feel like donating, then Thank You! but don't stress either way.

#10 Steve8x8

Steve8x8

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 260 posts

Posted 20 September 2012 - 05:17 AM

Is there any way to watch the device booting? I mean, via a "serial console" or the like?
I have found this page which seems to refer to the A10 - would such a beast work with one of the M6 devices as well?

#11 fards

fards

    Advanced Member

  • FW Developer
  • PipPipPip
  • 1,014 posts

Posted 20 September 2012 - 11:30 AM

there was some discussion on jtags for the elf ii I think.

http://www.slatedroi...post__p__416742

btw to build the full thing

. /build/envsetup.sh && lunch full_g06refe4-user && make -j4


should do it, but I haven't tried yet :D

Edited by fards, 20 September 2012 - 11:36 AM.

GIthub for source codes.

My github collection

If you feel like donating, then Thank You! but don't stress either way.

#12 Steve8x8

Steve8x8

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 260 posts

Posted 05 February 2013 - 07:06 AM

Filipp,
you're talking about unpack and repack? (They both have a subtle bug, they only work for 90% of the kernels out there.)

#13 Frizzy

Frizzy

    Newbie

  • Jr. Member
  • Pip
  • 5 posts

Posted 07 February 2013 - 04:29 AM

Oh, thanks, I will keep it in mind.

One more question: I make linux kernel from ainol source by command
make -f kernel.mk TARGET=g06_e4_ainol INSTALL_ROOT=./ramdisk/initramfs_CWM_My/ CROSS_COMPILE=./arm-2010q1/bin/arm-none-linux-gnueabi- CONFIG_DEBUG_SECTION_MISMATCH=y
.
Build successful, but uImage or uImage_recovery also can not loading both burning into boot or recovery partitions and just from sdcard in recovery mood (volume- down + power).
Maybe needed some special config file or make changes original config? And also where i can select specifications of display (tm or qm)?

I'm wait usb-to-uart adapter from Chine now, so I shell try to get u-boot console when it comes.

Best regards, Filipp Frizzy

#14 Steve8x8

Steve8x8

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 260 posts

Posted 12 February 2013 - 02:53 AM

Ainol sources: you're talking about the outdated ones from August 12, or do you have access to an updated version? The old ones don't even know about TM screens, let alone the new accel sensor.

AFAIK there are very few people around who can build working kernels - most boot images are created by taking an existing kernel and replacing the ramdisk only (which is limited in size because it's "inside" the image).

#15 Frizzy

Frizzy

    Newbie

  • Jr. Member
  • Pip
  • 5 posts

Posted 12 February 2013 - 10:22 AM

Yes, i'm toking about old kernel source like a fards kernel source at https://github.com/f...nol_fire_kernel, but from ainol package.
So, so bad...
Thanks for answers, i shell wait usb to uart and try to look at u-boot console...

#16 mario44

mario44

    Member

  • Jr. Member
  • PipPip
  • 18 posts

Posted 13 February 2013 - 07:02 AM

Is there any way to replace aml_logo.img?
I would like exchange for attached aml_logo.bmp

Attached Files



#17 Steve8x8

Steve8x8

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 260 posts

Posted 13 February 2013 - 09:28 AM

According to my records, the aml logo is in mtd partition 2 (device mtd2) - certainly you can read it out from there; it'll be padded at the end as the image itself is only 4096056 bytes (1280*800 x 32bit + header) while the partition is 8M.

(Fire, 0815qm firmware, YMMV.)

I do NOT recommend writing to the mtd partition.

#18 mario44

mario44

    Member

  • Jr. Member
  • PipPip
  • 18 posts

Posted 13 February 2013 - 02:38 PM

According to my records, the aml logo is in mtd partition 2 (device mtd2) - certainly you can read it out from there; it'll be padded at the end as the image itself is only 4096056 bytes (1280*800 x 32bit + header) while the partition is 8M.

(Fire, 0815qm firmware, YMMV.)

I do NOT recommend writing to the mtd partition.


@Steve8x8
Thank for your info.
Can you explain me, why you don't recommend writing to the mtd partition.
Can you tell me why I can't write aml logo using:
write_raw_image(package_extract_file("aml_logo.img"), "aml_logo");
How can I find partition 2 (mtd2) ? What a tools use?
Thanks for your help.

#19 fuser-invent

fuser-invent

    Advanced Member

  • FW Developer
  • PipPipPip
  • 1,830 posts

Posted 19 February 2013 - 01:11 PM

UPDATE: [Problem SOLVED]
So basically remove gzip part from repack.sh script and it works just fine. Just remember that this method doesn't allow bigger ramdisks than original.


Could you post a code snippet of the line you changed and how you modified it?
If I've helped you set-up your new tablet, unbrick your device or if you use and enjoy my Amlogic AML8726-M Series ROM's
please consider a donation.
My ROMS - *Crystal Clear (Ainol Crystal) *Anti-Hero (Ainol Hero) *Elenari (Ainol Elf2) *Astronautica (Ainol Aurora2) *Karbonn Custom (Karbonn SmartTab ST8 & ST10)
My DEVICES - *HP Touchpad *Ainol Crystal *Ainol Hero *Ainol Fire *Cube U30GT Mini-S *Nexus 7 (2013)
I don't respond to most PM's just because of the amount I get. If you have a question the best way to get an answer is to post in one of my threads.


My Ainol Crystal "Get Started" Guide. ----- My "How To Unbrick Your Amlogic AML8726-MX Series Tablet" Guide. ----- Go check out my music - It's all free!!!

#20 Marqui

Marqui

    Advanced Member

  • Jr. Member
  • PipPipPip
  • 55 posts
  • LocationLondon, UK.

Posted 21 February 2013 - 12:50 PM

Is there any way to watch the device booting? I mean, via a "serial console" or the like?
I have found this page which seems to refer to the A10 - would such a beast work with one of the M6 devices as well?

There is a serial port accessible via pads on the main board. It is on the underside of the board. There are 4 gold circular pads. I can't remember the order. You can buzz out the ground. Then you have TX RX and I think reset. I used a USB serial port converter (ttl level) and just tried the RX input on each of the two pads next to the ground. The speed is 115200 baud.

Attached is a sample printout. This is from my first Fire which has a problem that as soon as the AXP driver initialises the chip the device switches off! (I think the driver has somehow set an invalid value into one of the registers, which isn't cleared on reset - I haven't found any way to clear it yet.)

Attached Files