I reconstructed the Openwrt sdcard image using your patched bl2. Did a power cycle (seems like bl2 is only used for cold boot), and while I do get to userspace I’m still seeing 4gb memory. Any way to debug this without UART (I have not got one yet)?
I checked Openwrt main branch and it seems they have upgraded to uboot 2025.01, which contains mediatek-openwrt/arm-trusted-firmware@e0907706 where DDR4_4BG_MODE defaults to 1. Your other commit to add AVAIL_DRAM_SIZE := 1024 2048 4096 however doesn’t yet exist.
I’ll hold onto the patch until we figure out why the bl2 I got from your repo still doesn’t detect 8gb RAM.
tested image with default ram-setting: 4GB shown but working so far
flashed 8gb variant from my repo, still 4GB
noticed that i had 2 dram-settings set (DRAM_USE_COMB=1 DDR4_4BG_MODE=1) and dropped the USE_COMB=1, but then i see this:
NOTICE: EMI: DDR4 4BG mode
NOTICE: EMI: Using DDR3 settings
NOTICE: EMI: Detected DRAM size: 0 MB
@tombpi@drozdi70@wwwing any idea? possibly my mtk-atf version is too old, i see some changes in mtk-original atf, tried using latest atf but failed due to missing files
make: *** No rule to make target 'plat/mediatek/common/drivers/efuse/mtk_efuse.c', needed by '/media/data_ext/git/uboot/u-boot/build/mt7988/release/bl2/mtk_efuse.o'. Stop.
same for plat/mediatek/common/drivers/mmc/mtk-sd.c, plat/mediatek/common/drivers/spi/mtk_spi.c, plat/mediatek/mt7988/drivers/wdt/mtk_wdt.c
last one has multiple conflicts when i try to cherry-pick from my old tree
Unfortunately, I also wasn’t able to get my BPi-R4 to recognize the full 8GB of RAM using the 8GB variant from your repo.
Now, I must say I have far less experience than you when it comes to using OpenWrt with BPi, so what I’m going to share below might be obvious to you, but I’m posting it anyway in case it helps someone who just received their new board.
My goal was to run OpenWrt from the eMMC. From my testing, the only way I managed to get all 8GB recognized was:
The fastest and most straightforward method is using the official image from the BPi documentation specifically made for the R4-8GB:
The advantage is that you can be up and running with full RAM support within minutes. The downside is that the image is based on a relatively old version of OpenWrt (I believe it’s 21.02) and it’s a snapshot, which makes updating packages via opkg a bit tricky.
The second option works with any OpenWrt version and allows to use the full 8GB:
I used the official OpenWrt Firmware Selector and picked the latest stable release, 24.10. After selecting the packages I needed, I wrote the image to an SD card and used it to install OpenWrt to the NAND using U-Boot, and from NAND to eMMC.
This results in OpenWrt 24.10 being installed to eMMC (also on SD and Nand) but initially, only 4GB of RAM is detected.
To fix that, I booted OpenWrt again from NAND and re-flashed the BL2 partition of the eMMC using the bl2_emmc_8g.img file (same one included in the snapshot 21.02 files I mentioned above).
After rebooting from eMMC, the system properly detected the full 8GB while still running the stable OpenWrt 24.10.
That’s how I got it working using prebuilt images. It would definitely be ideal to learn how to build them properly and update your repo to support the R4-8GB variant out of the box.
Besides @tombpi@drozdi70@wwwing I believe @meehien might also be able to help, since they mentioned in the thread below that they managed to build the BL2 image themselves:
old versions but still working for my board.
I noticed that recently arm-trusted-firmware-mediatek package has some issues and not compiling well bl2 files. Now my board is in pieces and Im focused on some other projects. I will check out that later
!!!
Just one thing… I heard that changes in arm-trusted-firmware-mediatek package as above could impact that image you compile could not work for users with 4GB board. Please validate it…
Yes i did crosscompile on amd64 host,but it seemed my old atf code missed something (got only 4gb recognized).with new atf code i needed to remove build dir to no get build errors,but then 8gb are detected
I managed to get 8GB to show up. Should we figure out how/what to upstream to OpenWrt next? What was the missing piece of the puzzle compared to your earlier release/
To be honest i do not undestand why such big script is needed when using my binaries (looks like you disassemble full image instead of replacing the bl2 only)…it should be a simple dd replacing openwrt bl2 with mine. Hardcoded offsets and overwriting something in the bl2.img looks somehow strange. Maybe you can comment why it is needed from your PoV?
Imho it does not make sense to create 8gb images where only bl2 differs. As 4gb works on both boards it would be enough if openwrt releases 8gb bl2 for all boot devices and tutorial to replace the 4gb bl2 in image and system.
Exactly i prefer to stay with 4gb images to create/compile and change later bl2 if needed for sd or emmc
Eric i dont know what happen on my aarch64 - maybe os or some libraries differ but this year i was not successful to compile bl2 on my standard dev env orangepi5+. I did IT on my laptop. Copy 1:1.
You’re absolutely right. I disassembled the sdcard image and replaced all 3 bl2 sections of the image. The hardcoded offsets are in the OpenWrt image building makefile.
I do this because that is the most surefire way to make sure a person who’s new to the device will get a working device to spec. This prevents:
following the OpenWrt instructions and getting a different RAM capacity than expected
picking the wrong bl2 to flash (there are 9 on your uboot release page)
wondering why booting from each boot source gives a different amount of detected ram (because it was not obvious to me each source had a different bl2)
and as a corollary, the method for flashing nand using the bootloader involves copying the bl2 from an unloaded bl2 of the sdcard
None of these are necessary – and you could say that it’s all rookie mistakes – but reduces the amount of problems a new user who wants to get up and running quickly would encounter. The tradeoff would be needing a different sdcard image.
I think it’s worth it, especially since in my case I have had to get documentation from this forum, OpenWrt docs, and the OpenWrt forum to assemble a set of instructions that can work. This would also hopefully reduce the number of times experienced folk have to answer repeated questions (on all the different sources of information).
But ultimately at the end of the day it’s for you and the other maintainers who should make a call on what’s desirable – few people would have the deep and intimate knowledge of the hardware as you would.
by the way - my offer of trying to get this upstreamed to OpenWrt still stands. I would want a smooth user experience for users of this hardware. I’ll start with the commits I can identify from your uboot repository which affects bl2 and 8G RAM; may need you to chime in later on (or with @\dangowrt) if the OpenWrt maintainers have questions