maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   GUIDE: Maemo on SD card (https://talk.maemo.org/showthread.php?t=83719)

peterbjornx 2012-04-17 22:03

GUIDE: Maemo on SD card
 
Maemo on SD card

DISCLAIMER: THIS GUIDE CAN POTENTIALLY BRICK YOUR PHONE, THE AUTHOR IS NOT RESPONSIBLE FOR ANY DAMAGE TO YOUR PHONE

Introduction:
In this guide i will explain how to move Maemo from the internal flash to the SD card, this guide is based on what i did to unbrick my phone so it might not be 100% accurate as my success in it was mostly trial-on-error, however , the steps in this guide ARE correct, of that i am sure, it might just be that i forgot something,

Benefits:
  • More rootfs space
  • (If using U-Boot)No need for flasher anymore
  • Unbricking USB-less phones or preventing irreversable bricks on such devices
  • rootfs free for alternative OS/storage/whatever you might want to use it for

Requirements:
  • Ability to build your own (N900) kernel.
  • (Recommended) U-Boot
  • Linux PC with working UBI and nandsim (If you don't have this, the SDK VM will do fine.)
  • MicroSD card ( 1GB or larger )
  • U-Boot mkimage (uboot-mkimage package in SDK VM)

Steps:

Step 0 - Clean eMMC:
If the N900 /home partition contains optified apps/Maemo programs, you will need to format/reflash eMMC, this can be done through flashing a new eMMC image or through the devices x-terminal.
If you dont do this, the phone might get stuck at the bootscreen!

Step 1 - Partitioning SD card:
If using U-Boot, you need to create a small (a couple of MB's) FAT16 (msdos) partition before the main partition
Either way, you now need to format the main partition ext3 and mount it somewhere on your development machine

Step 2 - Mounting root filesystem:
Either enter these commands one by one or make it a script:
Code:

modprobe mtdblock
modprobe ubi
modprobe nandsim first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte=0x15
#I reccommend testing if nandsim works by catting /proc/mtd, that should yield:
#dev:    size  erasesize  name
#mtd0: 10000000 00020000 "NAND simulator partition 0"
#
#MAKE SURE THE NUMBER AFTER mtd MATCHES THE ONES IN
#THE NEXT COMMANDS OR YOU WILL NUKE A REAL FLASH
#CHIP IN YOUR DEVELOPMENT BOX
 
dd if=rootfs.jffs2 of=/dev/mtdblock0 bs=2048
ubiattach /dev/ubi_ctrl -m 0
mount -t ubifs ubi0_0 <PREFERRED MOUNT POINT>

Step 3 - Transferring rootfs:
Use the following command for this, -r will make cp recurse into directories, -p will make it preserve ownership and access masks.
Code:

cp -r -p <ROOTFS MOUNTPOINT>/* <SDCARD PART2 MOUNTPOINT>
Step 4 - Configuring your kernel:
Use your preferred ARM (GNU EABI) toolchain for this, or use scratchbox, you need to use the default config for the N900 (rx51_defconfig), and make the following changes:
  • Built in ext3 filesystem
  • Built in MMC subsystem
  • Built in OMAP MMC host driver (The one already set to module)
  • Command line: "/dev/mmcblk0p<PARTITION> rootwait rw init=/sbin/preinit" (Partition is 1 for flasher boot and 2 for U-Boot users)
  • Disable cpufreq or build as module. (WORKAROUND for kernel panic when combining mmc and cpufreq)
  • (Only for extra debugging) Framebuffer console built in
Now build the kernel and modules, install modules to the sdcard's /lib/modules/<KERNEL_NAME>'

Step 5 (U-Boot) - Configuring U-Boot
First you need to turn your kernel into an U-Boot kernel image:
Code:

mkimage  -A arm -O linux -T kernel -C none -a 80008000 -e 80008000 -n MaemoSD -d <PATH TO zImage> <SD BOOT PART MOUNTPT>/lmaemosd
Next you need to create a file containing the following code:
Code:

mmc init
echo "Booting Maemo from SD card"
fatload mmc 0:1 ${loadaddr} maemosd
setenv atags ${nolo_atagaddr}
bootm ${loadaddr}

which you need to turn into a U-Boot script with:
Code:

mkimage  -A arm -O linux -T script -C none -a 0 -e 0 -n MaemoLoader -d <PATH TO SCRIPT SOURCE> <SD BOOT PART MOUNTPT>/boot.scr
Step 5(Flasher) - Flashing your new kernel
Put your N900 into flashing mode and run:
Code:

flasher-3.5 -k <PATH TO zImage> -f -R
Step 6 - Testing
Unmount all SD card partitions and put it in your phone, it should boot into Maemo, to verify that it has worked, open xterm and enter df -h, it should show a significantly larger rootfs!

Credits:
x86 - rootfs mount guide
DocScrutinizer and other people from #maemo - Helping me fix some problems with this

ammyt 2012-04-17 22:08

Re: GUIDE: Maemo on SD card
 
It took 2 years for such a guide to arrive, however, it did.
This could be life-saving you know...

peterbjornx 2012-04-17 22:14

Re: GUIDE: Maemo on SD card
 
The only real down side (for now, i am not really into linux kernel development but maybe someone finds the bug) is the kernel panic when somehow the MMC driver forces cpufreq to switch clock speed, and it panics in set_frequency or something, so i had to disable cpufreq , which means battery life sucks and no overclocking either

ammyt 2012-04-17 22:16

Re: GUIDE: Maemo on SD card
 
Quote:

Originally Posted by peterbjornx (Post 1193536)
The only real down side (for now, i am not really into linux kernel development but maybe someone finds the bug) is the kernel panic when somehow the MMC driver forces cpufreq to switch clock speed, and it panics in set_frequency or something, so i had to disable cpufreq , which means battery life sucks and no overclocking either

At what speed does the CPU set to? Max?

peterbjornx 2012-04-17 22:19

Re: GUIDE: Maemo on SD card
 
As far as i know, it doesnt set it at all if you disable cpufreq, and judging from the speed of my phone , NOLO/U-Boot sets it to 600MHz

peterbjornx 2012-04-17 22:21

Re: GUIDE: Maemo on SD card
 
I have yet to try compiling cpufreq as module and loading it after boot,might do that tomorrow, my N900's battery is charging at the moment (external charger), also im sure this isnt a hardware bug as meego-qemu did exactly the same

MINKIN2 2012-04-17 22:21

Re: GUIDE: Maemo on SD card
 
A very impressive first post. Welcome to the forums! ...Although I am sure you have been viewing us for some time already :)

Would I be right in believing that should one were to have 2 maemo devices, then we could swap the SD cards between them and transfer all installed data too?

peterbjornx 2012-04-17 22:26

Re: GUIDE: Maemo on SD card
 
Not with the steps described in this guide, this still relies on the eMMC for data and application storage, the SD card only replaces the rootfs,
the eMMC location is hardcoded into quite a lot of scripts and configuration files, moving it to a sd card would be a lot of work

ammyt 2012-04-17 22:33

Re: GUIDE: Maemo on SD card
 
Quote:

Originally Posted by peterbjornx (Post 1193547)
Not with the steps described in this guide, this still relies on the eMMC for data and application storage, the SD card only replaces the rootfs,
the eMMC location is hardcoded into quite a lot of scripts and configuration files, moving it to a sd card would be a lot of work

The rootFS is a very fast memory chip, so how's the performance, speed? How well would Maemo 5 run on a class 10 memory card?

peterbjornx 2012-04-17 22:38

Re: GUIDE: Maemo on SD card
 
Only boot and application speeds are affected, as the rootfs is not used for any "normal" storage, tmp is on a ramdisk and /home and /opt are on eMMC, im using a 2GB microSD without any class advertised on it and it runs fine, no real lag only slightly slower boot


All times are GMT. The time now is 23:23.

vBulletin® Version 3.8.8