U-Boot porting
It is possible to port u-boot on your phone, even if there is no SOC support in uboot tree (because stock bootloader initialized hardware for us). First thing to focus on should be getting u-boot shell prompt.
Preparation
- Find uboot code
- Before starting uboot porting, you should get access to the stock bootloader uart port. Make sure you can see stock bootloader logs.
- Search uboot code for a uart driver, compatible with your SOC. It is good, if it support debug(i.e. include debug_uart.h)
Create basic configuration and build
TODO: add more specific info |
Add simple board, see examples.
TODO: Create template |
Examples
Getting uart debug output
TODO: add raw c and assemble examples. Also config options for debug_uart.h What init code to comment out |
You can get debug output from particular *.c file by adding
#define DEBUG
at the top of file, and calling
debug("debug output");
where you need.
Finding base address
TODO: How to dump PC register on ARM, to know RAM range to dump |
You should tell u-boot base address, i.e. address in RAM, where stock bootloader load u-boot. Do it with CONFIG_SYS_TEXT_BASE option. Without that knowledge u-boot will fail on `/common/board_f.c` file in function `init_sequence_f`. This function contains list of initcall addresses, and if CONFIG_SYS_TEXT_BASE does not match with address u-boot resides, you CPU will jump in wrong address and execute irrelevant code, leaving you with unpredictable uart output and results.
To find u-boot base address, you should dump RAM, where u-boot presumably resides, and find, at what address uboot image starts. Result should be placed in CONFIG_SYS_TEXT_BASE
Ram dump code example:
char *val; val = 0x40001000; debug("0x40001000 - 0x40101000 \n"); for(int i=0 ; i < 0x100000; i++) { if ((i & 0xf) == 0) { debug("\n%.8x: ", val + i); // new line every 16 symbols } debug("%.2x ", *(val + i)); } debug("\n");
Creating basic device tree
TODO: Add Template and examples |