Skip to content

Add FEL support for Allwinner SoC A733 - #223

Open
dlan17 wants to merge 4 commits into
linux-sunxi:masterfrom
dlan17:A733
Open

dlan17 wants to merge 4 commits into
linux-sunxi:masterfrom
dlan17:A733

Conversation

@dlan17

@dlan17 dlan17 commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

the PR tries to add FEL support for A733, tested on Radxa Cubie A7A board
it's capable of booting uboot spl image..

still need some help to check if the commit message is accurate..

the spl_address is coded to 0x52000, as in my case I've tried, the <0x51000 isn't working..

@Icenowy

Icenowy commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

Is the WIP U-Boot port available anywhere?

@Icenowy

Icenowy commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

And is there any BROM dump of this SoC?

@dlan17

dlan17 commented Aug 14, 2025

Copy link
Copy Markdown
Contributor Author

Is the WIP U-Boot port available anywhere?

have a local repo, but not sorted out yet,
the main challenge is to bring up DDR..

@dlan17

dlan17 commented Aug 14, 2025

Copy link
Copy Markdown
Contributor Author

And is there any BROM dump of this SoC?

no idea of what's the aim to do the dump, not really needed of this from my side..

@apritzel apritzel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for posting this. I guess we need to adjust some addresses, to be able to later load the same mainline SPL as used on an SD card.

Comment thread soc_info.c Outdated
};

sram_swap_buffers a733_sram_swap_buffers[] = {
{ .buf1 = 0x48800, .buf2 = 0x72000, .size = 0x0400 },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you double check that the area at 0x72000 is not used by the BROM?
Try to write something to that area, using "sunxi-fel write", then try to read it back (using the "read") command. This should work without using the swap buffers, and this way you can check if the BROM uses that area. Feel free to poke around nearby, it would be good if you could actually find something that the BROM changes, and the confirm that it's NOT between 0x72000 and 0x72400.
Another way would be to dump the BootROM, then check the disassembly for addresses used for buffers and stack.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you double check that the area at 0x72000 is not used by the BROM? Try to write something to that area, using "sunxi-fel write", then try to read it back (using the "read") command. This should work without using the swap buffers, and this way you can check if the BROM uses that area. Feel free to poke around nearby, it would be good if you could actually find something that the BROM changes, and the confirm that it's NOT between 0x72000 and 0x72400. Another way would be to dump the BootROM, then check the disassembly for addresses used for buffers and stack.

I've done a "write then read back" test with sunxi-fel, and found 0x46E00 - 0x48C00 is the space that we can't write (touched it will corrupt FEL) and should be preserved, so I will use it as swap_buffer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (the space that we can't write) is the space that needs to be backed up (buf1 here) instead of the used swap buffer (buf2).

If any higher SRAM is available, then buf2 should be as high as possible.

Comment thread soc_info.c Outdated
},{
.soc_id = 0x1903, /* Allwinner A733 */
.name = "A733",
.spl_addr = 0x52000,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this should be 0x47000, to match the load address used by the BROM when loading from SD cards (and other boot media). Making this the same is crucial to be able to use the same SPL binary for FEL and boot media, since we need a fixed link address for the SPL (since we cannot use PIE).
And we should double check that it's really 0x47000, and not 0x44000. Again the BROM disassembly would help.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this should be 0x47000, to match the load address used by the BROM when loading from SD cards (and other boot media). Making this the same is crucial to be able to use the same SPL binary for FEL and boot media, since we need a fixed link address for the SPL (since we cannot use PIE). And we should double check that it's really 0x47000, and not 0x44000. Again the BROM disassembly would help.

agree, I will use 0x47000

in my test, both 0x44000 and 0x47000 works fine, address 0x44000 will give more space, but downside is that we have to maintain two different value for FEL and booting from SD, so will leave it for now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, most addresses will work in FEL, but please note that SD card compatibility is a hard requirement, not a "nice to have": we will only support one image, for FEL, SD card, eMMC and SPI booting.
And the "more space" is quite theoretical, we will probably not need more than say 64KB. For the A523, we are at 37KB at the moment, which leaves us quite some room, even for the probably higher DRAM setup demand of the A733.
So, what is your CONFIG_SUNXI_SRAM_ADDRESS in U-Boot, and does that work from an SD card? Just use the working version of this address.

@dlan17 dlan17 Aug 27, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, what is your CONFIG_SUNXI_SRAM_ADDRESS in U-Boot, and does that work from an SD card? Just use the working version of this address.

Currently it's CONFIG_SUNXI_SRAM_ADDRESS=0, but while checking the code, it should be CONFIG_SUNXI_SRAM_ADDRESS=0x47000 for case A733?

for FEL mode, it seems doesn't matter of what the CONFIG_SUNXI_SRAM_ADDRESS is, or guess I'm only booting directly from ram.. but SD boot case, due to lacking of DDR initialization, I'm not able to fully test the SD boot procedure.. only got this log

U-Boot SPL 2025.10-rc1-00134-gc107a6ec79aa (Aug 27 2025 - 10:53:03 +0000)
DRAM: 1024 MiB

then stuck, due to even in SPL stage it will utilize DDR memory space..

Comment thread soc_info.c Outdated
.soc_id = 0x1903, /* Allwinner A733 */
.name = "A733",
.spl_addr = 0x52000,
.scratch_addr = 0x54000,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I guess we should adjust this as well, to be 4096 bytes after the spl address.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I guess we should adjust this as well, to be 4096 bytes after the spl address.

for spl_addr = 0x47000, then scratch_addr is 0x48000, which < 0x48C00, so it doesn't work..

I would pick 0x71000 if no objection, since it's a temp address for running code

@apritzel

Copy link
Copy Markdown
Contributor

A BootROM dump would indeed be very helpful to confirm the various addresses used, for instance the SD card load address, the stack locations, and where any BROM buffers are. You can try to submit them to https://github.com/smaeul/sunxi-blobs, so that we have them on record for the future

Comment thread uart0-helloworld-sdboot.c Outdated
set_wbit(soc->ccu_base + 0x90c,
int reg_ofs;

reg_ofs = (soc->soc_id == 0x1903) ? 0xe00 : 0x90c;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a new flag for the clock, like FLAG_A733_CLOCK. You can combine this with the other new flag to FLAG_NCAT3 or so.

Comment thread uart0-helloworld-sdboot.c Outdated
int reg_ofs;

reg_ofs = (soc->soc_id == 0x1903) ? 0xe00 : 0x90c;
set_wbit(soc->ccu_base + reg_ofs,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that each UART has its own BGR register now. So I suggest something like:

if (soc->flags & FLAG_NCAT3_CLOCK) {
    set_wbit(soc->ccu_base + 0xe000 + uart_index * 4, 0x10001);
} else if (soc->flags ^ FLAG_NCAT2_CLOCK) {
....

Comment thread uart0-helloworld-sdboot.c Outdated
pio_dat_off = 0x10;
pio_pull_off = 0x24;
} else if (soc->flags & FLAG_A733_GPIO) {
pio_bank_size = 0x80;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need an offset value, as you figured below, as on the A733, the bank A registers start at 0x80, not 0x0 as before. Either you add a new pio_bank_a_offset variable, and set this 0x80 here, or you adjust pio_base in here, directly.

Comment thread uart0-helloworld-sdboot.c Outdated
* Adjust pio_base offset by shift size 0x80, as
* PB bank start at 0x100 with the bank size 0x80
*/
if (soc->soc_id == 0x1903)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no SoC specific hacks, we now have the flags to take of this properly, so that it can be reused later on. I guess this won't be the last SoC using this pinctrl layout. See above for a better solution.

@dlan17

dlan17 commented Aug 25, 2025

Copy link
Copy Markdown
Contributor Author

A BootROM dump would indeed be very helpful to confirm the various addresses used, for instance the SD card load address, the stack locations, and where any BROM buffers are. You can try to submit them to https://github.com/smaeul/sunxi-blobs, so that we have them on record for the future

I'm not familiar with this, I'd appreciate if someone else would do this..

@Icenowy

Icenowy commented Aug 25, 2025 •

Copy link
Copy Markdown
Contributor

At least N-BROM should be easy to dump -- just use sunxi-fel read functionality to dump the memory zone of BROM according to the manual.

@Icenowy

Icenowy commented Aug 25, 2025

Copy link
Copy Markdown
Contributor

Looks like the branch is still quite broken -- sunxi-fel read on BROM does not work at all (while sunxi-fel readl can read individual words from BROM)

@dlan17

dlan17 commented Aug 25, 2025

Copy link
Copy Markdown
Contributor Author

Looks like the branch is still quite broken -- sunxi-fel read on BROM does not work at all (while sunxi-fel readl can read individual words from BROM)

$ ./sunxi-fel read 0x17000 0x200 dump.bin
usb_bulk_recv() ERROR -7: Operation timed out

it seems these address space aren't readable? I have no idea why..

@Icenowy

Icenowy commented Aug 25, 2025 •

Copy link
Copy Markdown
Contributor

smaeul/sunxi-blobs#5

BROM dumps here (HS-BROM seems to be not available now).

Maybe I should try to do some trick like what @apritzel does on A523, on my Teclast tablet, to retrieve the secure part.

@apritzel

Copy link
Copy Markdown
Contributor

Thanks @Icenowy for the BROM dump! That looks like the usual BootROM setup procedure, with all the hotplug checks, and including setting the ACTLR.SMP bit that isn't there anymore on the A55. Oh well ....
Normal stack is at 0xf3400 (towards the end of the NPU SRAM aka "SHARED_SRAM), IRQ stack is at 0x48c00.

0x46E00 - 0x48C00 is the space that we can't write

Are you sure it's that large? Typically the IRQ stack usage is pretty small, like at most 1KB (0x400), which would mean we just need to save/restore from 0x48800-0x48c00.
I wonder if we can use the area before the SPL load address for thunk and scratch? So 0x44000 and 0x45000 or so?
I will continue wading through the BROM disassembly, to see if I can find some buffer addresses somewhere, or if it touches more in the lower SRAM area.

@dlan17

dlan17 commented Aug 30, 2025

Copy link
Copy Markdown
Contributor Author

Are you sure it's that large? Typically the IRQ stack usage is pretty small, like at most 1KB (0x400), which would mean we just need to save/restore from 0x48800-0x48c00.

Yes, it's my actual test result, just boot straight into FEL mode (without SD or eMMC), then I did something like this a) "fel write 512bytes" b) "fel read back 512bytes" c) do m5sum to compare

for 0x46e00, it's fail at stage a - fel write

for the large buffer, is the space used by anything else than IRQ stack, like FEL/usb buffer? or maybe simply access forbidden?

I wonder if we can use the area before the SPL load address for thunk and scratch? So 0x44000 and 0x45000 or so?

I think it's possible, but haven't tested, I will try it some day and will let you know..

@Icenowy Icenowy mentioned this pull request Dec 26, 2025
@dlan17

dlan17 commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor Author

I wonder if we can use the area before the SPL load address for thunk and scratch? So 0x44000 and 0x45000 or so?

I think it's possible, but haven't tested, I will try it some day and will let you know..

Yes, it's possible, I can move all buffer used to address before 0x47000, so the diff is something like:

+/*
+ * Please note memory from 0x46E00 - 0x46FFF is also used by BROM or FEL
+ * but since we won't touch this range, so no save/restore it
+ */
 sram_swap_buffers a733_sram_swap_buffers[] = {
-       { .buf1 = 0x47000, .buf2 = 0x72400, .size = 0x1C00 },
+       { .buf1 = 0x47000, .buf2 = 0x44000, .size = 0x1C00 },
        { .size = 0 }  /* End of the table */
 };

@@ -756,8 +760,8 @@ soc_info_t soc_info_table[] = {
                .soc_id       = 0x1903, /* Allwinner A733 */
                .name         = "A733",
                .spl_addr     = 0x47000,
-               .scratch_addr = 0x71000,
-               .thunk_addr   = 0x72000, .thunk_size = 0x200,
+               .scratch_addr = 0x46000,
+               .thunk_addr   = 0x45E00, .thunk_size = 0x200,

@deece

deece commented Oct 6, 2026

Copy link
Copy Markdown

Hi @dlan17, @apritzel, @Icenowy,

We tracked down the cause of the usb_bulk_recv() ERROR -7 / ERROR -8 timeouts that were blocking sunxi-fel read on the A733: on high-speed USB 2.0/3.0 controllers, receiving transfers shorter than 512 bytes directly into smaller buffers triggers packet overflow/truncation issues with the A733 BROM.

We have submitted two pull requests:

  1. fel_lib: Handle USB bulk transfers smaller than 512 bytes safely #257 fixes the <512-byte bulk receive issue in fel_lib.c (unblocking sunxi-fel read on A733).
  2. Add support for Allwinner A733 (sun60iw2) SoC #258 supersedes this PR with verified SRAM swap buffers (0x47000 <-> 0x87200, size 0x3000), upper scratch/thunk addresses (0xEE800/0xEEA00), and full 320 KB SRAM mapping, tested on physical hardware with native U-Boot SPL and LPDDR5 DRAM initialization, while carrying forward the uart0-helloworld definitions from here with co-attribution.

@deece deece mentioned this pull request Oct 7, 2026
@apritzel

apritzel commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Looks like the branch is still quite broken -- sunxi-fel read on BROM does not work at all (while sunxi-fel readl can read individual words from BROM)

$ ./sunxi-fel read 0x17000 0x200 dump.bin usb_bulk_recv() ERROR -7: Operation timed out

it seems these address space aren't readable? I have no idea why..

@Icenowy @dlan17:
So for the records: as @jameshilliard figured out, the BROM FEL code denies access to some areas, namely the BootROM itself. It does so by sending an 8-byte error report instead of the data, which confuses our USB routines and leads to the timeout error. See #259 for a proposed fix.
And please note that this is only possible with the read command, which directly translates into a FEL primitive. So only then the BROM sees the address. readl on the other hand works by sunxi-fel uploading code and executing it, so the BROM does not get to see any addresses, and so cannot intervene.
That also means that the soc_info changes here are actually fine, as the bug is elsewhere.

@dlan17
dlan17 force-pushed the A733 branch 2 times, most recently from 0b9b0b1 to 56706a2 Compare October 23, 2026 03:10
@VinicKMx

Copy link
Copy Markdown

Hi Yixun, Andre,

I've been loading my own SPL over FEL (Radxa Cubie A7Z, A733,
1 GiB) with an earlier copy of this soc_info entry, so I ran the
current head (56706a2) from cold FEL, no SD card.

sunxi-fel spl with that SPL and a FIT gets to the U-Boot prompt,
3 times in a row. version, readl, read, write and reset64
also worked. I ran those in a separate late-FEL session, after boot0.

uart0-helloworld built from this head prints and returns to FEL (3 times
in a row), but spl then fails with SPL: failure code '\xff\xff\xff\xff\xff\xff\xff\xff'.

I think it's the swap. On A733 the swap buffer starts at spl_addr
(0x47000), and the thunk swaps back before returning, so the header
is at 0x72404 when fel.c reads 0x47004. After the return I see 0xff at
0x47004 and eGON.FEL at 0x72404. A733 is the only entry in soc_info.c
with buf1 == spl_addr.

Reading the signature from the buf2 side when spl_addr + 4 is inside
a swapped range should fix it, but I haven't tried. A U-Boot SPL that
returns to FEL (sunxi-fel uboot) should hit the same thing. Not
tested either.

Thanks,
Vinicius

@dlan17

dlan17 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Hi Yixun, Andre,

I've been loading my own SPL over FEL (Radxa Cubie A7Z, A733, 1 GiB) with an earlier copy of this soc_info entry, so I ran the current head (56706a2) from cold FEL, no SD card.

sunxi-fel spl with that SPL and a FIT gets to the U-Boot prompt, 3 times in a row. version, readl, read, write and reset64 also worked. I ran those in a separate late-FEL session, after boot0.

uart0-helloworld built from this head prints and returns to FEL (3 times in a row), but spl then fails with SPL: failure code '\xff\xff\xff\xff\xff\xff\xff\xff'.

I think it's the swap. On A733 the swap buffer starts at spl_addr (0x47000), and the thunk swaps back before returning, so the header is at 0x72404 when fel.c reads 0x47004. After the return I see 0xff at 0x47004 and eGON.FEL at 0x72404. A733 is the only entry in soc_info.c with buf1 == spl_addr.

Reading the signature from the buf2 side when spl_addr + 4 is inside a swapped range should fix it, but I haven't tried. A U-Boot SPL that returns to FEL (sunxi-fel uboot) should hit the same thing. Not tested either.

Thanks, Vinicius

Hi Yixun, Andre,

I've been loading my own SPL over FEL (Radxa Cubie A7Z, A733, 1 GiB) with an earlier copy of this soc_info entry, so I ran the current head (56706a2) from cold FEL, no SD card.

sunxi-fel spl with that SPL and a FIT gets to the U-Boot prompt, 3 times in a row. version, readl, read, write and reset64 also worked. I ran those in a separate late-FEL session, after boot0.

uart0-helloworld built from this head prints and returns to FEL (3 times in a row), but spl then fails with SPL: failure code '\xff\xff\xff\xff\xff\xff\xff\xff'.

I think it's the swap. On A733 the swap buffer starts at spl_addr (0x47000), and the thunk swaps back before returning, so the header is at 0x72404 when fel.c reads 0x47004. After the return I see 0xff at 0x47004 and eGON.FEL at 0x72404. A733 is the only entry in soc_info.c with buf1 == spl_addr.

Reading the signature from the buf2 side when spl_addr + 4 is inside a swapped range should fix it, but I haven't tried. A U-Boot SPL that returns to FEL (sunxi-fel uboot) should hit the same thing. Not tested either.

Yes, we've found this issue while implementing support for T153 SoC.. I've pushed a fix along here, please try to test this updated PR..

@VinicKMx

VinicKMx commented Nov 5, 2026

Copy link
Copy Markdown

Yes, we've found this issue while implementing support for T153 SoC.. I've pushed a fix along here, please try to test this updated PR..

Thanks, I tested fa9705b on my board (Radxa Cubie A7Z - A733).

The original FEL issue is fixed. From cold FEL with no SD card, uart0-helloworld loaded with sunxi-fel spl prints, returns to FEL, and the command now exits 0 (3/3 tries). The previous head (56706a2) still fails with the same binary. My SPL + FIT (BL31 + U-Boot) also still reaches the U-Boot prompt (3/3 tries).

I found one more issue while testing uart0-helloworld from SD. With the image at sector 16, it prints "Returning back to FEL." instead of detecting MMC0 (2/2 tries). After it returned to FEL, I checked memory and found the eGON.BT0 header at 0x47000, with the boot media byte at offset 0x28 set to 0x00 (MMC0). The A733 entry in bare-metal.c uses SRAM at 0x20000, so get_boot_device() looks at the wrong address:

.sram = { SRAM_A1_ADDR_20000 },

Changing the A733 .sram entry to 0x47000 fixes this on my board: SD boot now prints "Booted from MMC0, entering an infinite loop.", and the cold FEL path still works.

I also noticed a small ordering issue in 2feeaa1: swap_buffers[i].buf1 is overwritten with spl_addr before the size adjustment, so the subtraction is always zero:

sunxi-tools/fel.c

Lines 893 to 894 in fa9705b

swap_buffers[i].buf1 = soc_info->spl_addr;
swap_buffers[i].size -= (soc_info->spl_addr - swap_buffers[i].buf1);

The same block in the T153 PR (#252) has the two statements in the right order. It doesn't affect the A733 because its buf1 already equals spl_addr.

The A523 entry may have the same SRAM issue (spl_addr 0x44000, .sram 0x20000), judging from the code, but I haven't tested it on hardware. I also haven't tested sunxi-fel uboot with an SPL that returns to FEL.

Thanks,
Vinicius

The Allwinner A733 is built on a 12nm process and features a dual-core
ARM Cortex-A76 combined with a hexa-core ARM Cortex-A55 using the
big.LITTLE architecture.

The chip has 16K + 192K of SRAM-A2, with first 16K used only by CPUS
domain, later it follows by 512K of SHARED-SRAM with no gaps.

 SRAM_A2       0x40000 - 0x73FFF
 SHARED_SRAM   0x74000 - 0xF3FFF

The BootROM SRAM usage is similar to other SoCs: there is the IRQ stack
growing down from around 34K offset in SRAM-A2, and probably some
buffers located towards the end of the SRAM. In this setup, we've only
tried to use the 192K block of SRAM-A2, which should be enough for SPL
setup. It's possible to use more SRAM, for example, the SHARED-SRAM,
but we leave it for now.

This setup is known to boot the WIP mainline U-Boot setup, including
some placeholder TF-A port for now. SPL execution, including returning
back to the BROM, works, also the 64-bit switch, as well as the SID
dump.

Signed-off-by: Yixun Lan <dlan@gentoo.org>
Enable UART's pinctrl and clock settings.

Signed-off-by: Yixun Lan <dlan@gentoo.org>
Yixun Lan added 2 commits November 6, 2026 13:16
Need to take special care when SPL address sit in range of swap_buffers.buf1
ram space. Adjust and rewrite the swap_buffers.buf1 to exclude the header
part which wont't be touched in SPL download phase.

Example of the dram space used as below:

swap_buffers(buf1):     >  |-------------|
SPL address             >     |-----------...---|
new swap_buffers(buf1): >     |----------|

Signed-off-by: Yixun Lan <dlan@kernel.org>
---
 This is a prerequisite patch for handling FEL signature check, to make
sure SPL header always saved in buf2 when there is dram space overlap.

 Another idea if want to drop this patch, that is always making sure
swap_buffers.buf1 >= spl address when implementing in the C code level.
The actualy SPL payload will be put into swap_buffers.buf2 when there
is overlap between SPL address and swap_buffers.buf1.

Signed-off-by: Yixun Lan <dlan@kernel.org>
@deece

deece commented Nov 7, 2026 •

Copy link
Copy Markdown

Hi @dlan17,

Thanks for continuing the work on A733 support!

Disclaimer: We haven't booted this exact PR branch on target hardware yet, but I reviewed the code and memory layout against our tested implementation from #258 and our mainline U-Boot requirements.

There is one critical blocker regarding the SRAM layout and SPL size ceiling:

SPL Size Limit (spl_len_limit) and LPDDR5 SPLs

In fel.c, the maximum SPL size is bounded by:

spl_len_limit = swap_buffers[i].buf2 - soc_info->spl_addr;

With the current values:

  • spl_addr = 0x47000
  • buf2 = 0x72400
  • spl_len_limit = 0x72400 - 0x47000 = 0x2B400 (~173 KiB)

Furthermore, scratch_addr = 0x71000 and thunk_addr = 0x72000 will be overwritten during FEL load if an SPL exceeds ~168 KiB (0x71000 - 0x47000).

In mainline U-Boot, an SPL compiled with in-tree C LPDDR5 PHY & PMU training firmware is currently ~172 KiB uncompressed. With any debugging symbols or minor additions enabled, sunxi-fel spl aborts with SPL image is too large.

Proposed Memory Layout (from #258)

On A733, SRAM A2 (0x40000–0x73FFF, 208 KiB) and SHARED-SRAM (0x74000–0xF3FFF, 512 KiB) form a contiguous 720 KiB address space:

  • sram_size: 320 * 1024 (covers through 0x90000).
  • buf2: 0x87200 -> spl_len_limit = 0x87200 - 0x47000 = 0x40200 (~256.5 KiB).
  • scratch_addr / thunk_addr: 0xEE800 / 0xEEA00 (located in upper SRAM, where BROM USB scratch resides, well clear of SPL code and stack top 0xF3400).
  • swap_buffers.size: 0x1C00 (matches the BROM IRQ stack boundary 0x48C00 - 0x47000, as you have in PR Add FEL support for Allwinner SoC A733 #223).

I have pushed a clean commit with these layout updates rebased on top of your PR head for easy cherry-picking:
deece@f179dd2
(Branch: https://github.com/deece/sunxi-tools/tree/a733-lpddr5-layout)

@VinicKMx

VinicKMx commented Nov 9, 2026

Copy link
Copy Markdown

Disclaimer: We haven't booted this exact PR branch on target hardware yet, but I reviewed the code and memory layout against our tested implementation from #258 and our mainline U-Boot requirements.

@deece @dlan17 I tested deece/sunxi-tools@f179dd2 on my hardware, from cold FEL and after watchdog resets. The new layout works here.

  • uart0-helloworld (8 KiB) runs and returns to FEL, 3/3. The eGON.FEL signature is read from the new buf2 (0x87204).
  • A 200 KiB image, crossing 0x74000, runs and returns, 3/3. Reading back from 0x48C00 to the end of the image matches the file byte for byte.
  • An image of exactly 0x40200 bytes runs, 2/2, with the same readback check. 0x40204 is refused (need 262660, have 262656).
  • For comparison, 6362299 refuses the 200 KiB image with have 176128, so the old limit was 0x2B000 (thunk at 0x72000), a bit below the 0x2B400 from buf2.

FWIW the BROM itself reports scratchpad=000ee800 in sunxi-fel version, so the new scratch_addr matches it.

One thing that might be worth a line in the commit message: anything preloaded into SHARED-SRAM before sunxi-fel spl has to stay out of 0x87200-0x88E00 (swap) and 0xEE800 and up (scratch/thunk). My SPL loads a FIT that I stage at 0x80000, and with f179dd2 it failed the FIT CRC check. Moving only the FIT to 0x89000 booted to U-Boot again.

I also tested the sunxi-fel uboot loading and handoff path with the 8 KiB and 200 KiB returning test SPLs (one cold run each). After the SPL returns to FEL, the tool loads the FIT image and the RMR code at 0xEE800 requests an AArch64 warm reset. The payload was a small AArch64 program that prints on UART (it did, both runs), rather than U-Boot itself. My normal SPL does not return to FEL, so I used the test SPLs for this check.

I can't run an LPDDR5 SPL here.

Tested on: Radxa Cubie A7Z (A733, 1 GiB LPDDR4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants