U-Boot porting: Difference between revisions
Dsankouski (talk | contribs) u-boot porting guide initial page |
Dsankouski (talk | contribs) |
||
Line 8: | Line 8: | ||
== Create basic configuration and build == | == Create basic configuration and build == | ||
=== Add board files === | |||
{{todo|add more specific info}} | {{todo|add more specific info}} | ||
Add simple board, see examples. | Add simple board, see examples. | ||
{{todo|Create template}} | {{todo|Create template}} | ||
=== Examples === | ==== Examples ==== | ||
# Add [https://gitlab.denx.de/u-boot/u-boot/-/commit/6c15a2a996214574e8145bff69d110a302edf277 exynos7420 espresso board] | # Add [https://gitlab.denx.de/u-boot/u-boot/-/commit/6c15a2a996214574e8145bff69d110a302edf277 exynos7420 espresso board] | ||
# Add [https://gitlab.denx.de/u-boot/u-boot/-/commit/e39448e8be8389f5ddeabae0ec9c6a3b7b8a2ca6 exynos7420 SOC support] | # Add [https://gitlab.denx.de/u-boot/u-boot/-/commit/e39448e8be8389f5ddeabae0ec9c6a3b7b8a2ca6 exynos7420 SOC support] | ||
=== Building === | |||
Install arm cross compiler | |||
Build: | |||
export CROSS_COMPILE=aarch64-linux-gnu- | |||
make <$board_name>_defconfig | |||
make | |||
{{todo| How to assemble android boot image }} | |||
== Getting uart debug output == | == Getting uart debug output == | ||
{{todo|add raw c and assemble examples. Also config options for debug_uart.h What init code to comment out}} | {{todo|add raw c and assemble examples. Also config options for debug_uart.h What init code to comment out}} |
Revision as of 18:32, 7 October 2020
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
Add board files
TODO: add more specific info |
Add simple board, see examples.
TODO: Create template |
Examples
Building
Install arm cross compiler Build:
export CROSS_COMPILE=aarch64-linux-gnu- make <$board_name>_defconfig make
TODO: How to assemble android boot image |
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 |