User:Illen/HaRET
![]() HaRET running on Lark FreeBird 43.1 | |
Name | HaRET |
---|---|
1st stage |
Unavailable |
2nd stage |
Unavailable |
Resources | source |
HaRET is a Linux bootloader that is executed from ARM Windows CE environment. It is mostly hardware agnostic, often making it the only choice to boot Linux on a Windows CE ARM device. It does NOT support other CPUs than ARM though.
Requirements
- ARMv4 or newer CPU
- Any ARM version of Windows CE (2.1 and later, including derivatives such as PocketPC or Windows Mobile)
Building HaRET
- Download MinGW32CE
- Extract it somewhere
- Git clone HaRET
- Set this value to the path of MinGW32CE
- Enter the path of your local HaRET repository in terminal and run
make
- The output executable should be
out/haret.exe
, meant to run on Windows CE ARM environment.
Porting HaRET to the new device
This is optional, but recommended and simple, specifically on supported SoCs. HaRET will perform some initial hardware setup before jumping to the Linux kernel, and will automatically set some variables such as machine type (required for non-DT machines) or starting address of memory.
Obtaining OEM info and platform type
HaRET needs OEM info and platform type to determine the type of the device it runs on. To extract these values, you can run unmodified HaRET with empty earlyharetlog.txt
alongside its executable. HaRET will then write a new file haretlog.txt
which has these values logged:
Trying to detect machine (Plat='SmartPhone' OEM='SGH-i600')
Defining a new device in HaRET
In include/machine-type.h
:
- Define a new machine type, preferably use a number higher than highest on this list to avoid conflicts.
#define MACH_TYPE_SGH_I600 5160
- And then at the end of file, just right before the comment:
#ifdef CONFIG_MACH_SGH_I600
# ifdef machine_arch_type
# undef machine_arch_type
# define machine_arch_type __machine_arch_type
# else
# define machine_arch_type MACH_TYPE_SGH_I600
# endif
# define machine_is_sgh_i600() (machine_arch_type == MACH_TYPE_SGH_I600)
#else
# define machine_is_sgh_i600() (0)
#endif
In src/mach/machlist.txt
- Add an entry for the new device:
# classname, archtype, oeminfos, machtype, [script commands...]
[...]
PLATFORM=SmartPhone
Tornado, OMAP850 ,Vodafone v1240, OMAP_TORNADO
Libra, MSM7500 ,LIBR100
SGH_i600, OMAP850 ,SGH-i600, SGH_I600 set ramsize 64*1024*1024
- classname can be anything, preferably something related to the device
- archtype should be the closest SoC to the one that device uses
- oeminfos should exactly match the
OEM=
value from the HaRET log. Use quotation marks if there are spaces - machtype should match the value defined in
include/machine-type.h
- script commands can be used to define a size of system memory
- The new entry should be added below appropriate
PLATFORM
section, the section should match thePlat=
value from HaRET log. - If there is no appropriate
PLATFORM
section in machlist.txt file already, you can define new one and add the new entry underneath:
PLATFORM=LD2416
lark_430, S3c2416 ,"lark_freebird_430 ", LD2416
If HaRET does not support the SoC in your device, you can either add a new SoC based on already supported one, or resort to the generic ARM machine support. Some examples
Booting Linux with HaRET
You can create a small boot partition (32 MB should be more than enough) formatted with FAT filesystem so Windows CE can read it, and another partition for Linux rootfs.
Create a script default.txt
and put it alongside HaRET's executable.
log haret.txt # Useful for logging the boot process
# set RAMADDR 0x10000000 # Starting address of device's memory, required if device is not defined in machlist.txt
# set RAMSIZE 0x04000000 # Size of device's memory in bytes, required if not defined in machlist.txt
# set MTYPE 5160 # Machine type that Linux is supposed to run on, required if the device is not defined in machlist.txt. Has no effect if using a kernel with appended device tree, without any non-DT platforms enabled.
set FBDURINGBOOT 1 # Enables logging on device's framebuffer after HaRET overtakes the CPU control and stops logging to file.
set KERNEL zImage # File name of kernel image
set INITRD initramfs # File name of initial ramdisk
set cmdline "console=tty0 panic=20 root=/dev/mmcblk0p2 init=/usr/bin/init" # Kernel cmdline in ATAGs
boot # Boots the kernel