Using upstream u-boot 2021.01

Talking about OS and emulation core development
Post Reply
royger
Posts: 18
Joined: Fri Jan 08, 2021 2:22 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Using upstream u-boot 2021.01

Post by royger »

Hello,

It seems like there's support for the Odroid Go2 in upstream u-boot, but I'm not sure how to properly install it. I've build 2021.01 with the odroid-go2_defconfig and flashed the resulting u-boot.bin to the sd card based on the official Odroid v2.1 image by Hardkernel using:

dd if=u-boot.bin of=/dev/disk2 conv=notrunc bs=512 seek=1

But that doesn't seem to change the u-boot version used at boot, as I still see:

Code: Select all

U-Boot 201709-g4102e41302-dirty (Dec 03 2020 - 18:45:15 +0900)

Model: Rockchip RK3326 ODROID-GO Advanced
PreSerial: 2
DRAM:  992 MiB
Sysmem: init
Relocation Offset is: 3dabc000
Using default environment

adc0 (hw rev) 82
dwmmc@ff370000: 1
sfc nor id: b 40 18
GUID Partition Table Header signature is wrong: 0xFFFFFFFFFFFFFFFF != 0x5452415020494645
Repair the backup gpt table OK!
Bootdev(atags): spinor 1
PartType: EFI
init_resource_list: failed to get resource part, ret=-1
RKPARM: Invalid parameter part table
dtb in resource read fail, try dtb in spi flash

Device 1: Vendor: 0x0308 Rev: V100 Prod: rkflash-SpiNor
            Type: Hard Disk
            Capacity: 160 MB = 00 GB (32768 x 512)
 is now current device

spinor read: device 1 block # 12392, count 200  200 blocks read: OK
I2c speed: 400000Hz
PMIC:  RK8170 (on=0x80, off=0x80)
vdd_logic 1100000 uV
vdd_arm 1100000 uV
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Model: ODROID-GO3 for linux based on Rockchip rk3326
download key pressed entering recovery mode!
boot mode: recovery (key)
CLK: (sync kernel arm: enter 600000 KHz, init 600000 KHz, kernel 600000 KHz)
  apll 600000 KHz
  dpll 664000 KHz
  cpll 24000 KHz
  npll 1188000 KHz
  gpll 1200000 KHz
  aclk_bus 200000 KHz
  hclk_bus 150000 KHz
  pclk_bus 100000 KHz
  aclk_peri 200000 KHz
  hclk_peri 150000 KHz
  pclk_pmu 100000 KHz
Rockchip UBOOT DRM driver version: v101
Using display timing dts
Detailed mode clock 27500 kHz, flags[a]
    H: 0480 0490 0500 0505
    V: 0854 0866 0868 0928
bus_format: 100e
final DSI-Link bandwidth: 366 Mbps x 2
** Unable to read file logobmp **
logobmp file not found! filesize = 0

spinor read: device 1 block # 12592, count 400  400 blocks read: OK
Uncompressed size: 1229814 = 0x12C3F6
switch to partitions #0, OK
mmc1 is current device
Net:   Net Initialization Skipped
No ethernet found
Hit key to stop autoboot('CTRL+C'):  0
switch to partitions #0, OK
mmc1 is current device
reading bootini
1150 bytes read in 5 ms (2246 KiB/s)
## Executing script at 00800800
reading Image
14972936 bytes read in 1011 ms (141 MiB/s)
reading uInitrd
9351243 bytes read in 633 ms (141 MiB/s)
reading rk3326-odroidgo3-linuxdtb
89198 bytes read in 11 ms (77 MiB/s)
## Loading init Ramdisk from Legacy Image at 01100000
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    9351179 Bytes = 89 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum  OK
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
  'reserved-memory' region@110000: addr=110000 size=f0000
   Loading Ramdisk to 313c4000, end 31caf00b  OK
   Loading Device Tree to 00000000313ab000, end 00000000313c3c6d  OK
reserve drm-loader-logo offset = 58604
reserve drm-logo mem = 000000003de00000, size = 3736832
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x0a200000 - 0x40000000 (size: 0x35e00000)
Total: 471830 ms

Starting kernel
It still seems to be booting using 201709. Any pointers about how to correctly flash the new u-boot are appreciated.

Thanks!

notime2d8
Posts: 350
Joined: Thu Dec 11, 2014 4:40 am
languages_spoken: english
Has thanked: 106 times
Been thanked: 158 times
Contact:

Re: Using upstream u-boot 2021.01

Post by notime2d8 »

There's a few post on here from @macc24 & @macromorgan that talk about it. But you need to hit the reset button to get it to bypass the SPI chip and use the mmc u-boot. To get it to work the way you want though, I believe you need to use the rockchip trust.img.

Have you looked at the hard kernel u-boot and script that it uses to see what it flashes to the sd card?

royger
Posts: 18
Joined: Fri Jan 08, 2021 2:22 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: Using upstream u-boot 2021.01

Post by royger »

Thanks for the reply! I was attempting to follow the wiki page at:

https://wiki.odroid.com/odroid_go_advance/build_uboot

But using upstream u-boot instead of the Hardkernel fork. The wiki doesn't mention anything about pressing the reset button in order to use the u-boot on the sd instead of the SPI one, so didn't know anything about that. I'm also using Odroid Go Super instead of Advance, but I'm no sure this matters much.

Is there a more up to date documentation, or could the existing one be fixed?

notime2d8
Posts: 350
Joined: Thu Dec 11, 2014 4:40 am
languages_spoken: english
Has thanked: 106 times
Been thanked: 158 times
Contact:

Re: Using upstream u-boot 2021.01

Post by notime2d8 »

royger wrote:
Mon Feb 08, 2021 7:19 am
Thanks for the reply! I was attempting to follow the wiki page at:

https://wiki.odroid.com/odroid_go_advance/build_uboot

But using upstream u-boot instead of the Hardkernel fork. The wiki doesn't mention anything about pressing the reset button in order to use the u-boot on the sd instead of the SPI one, so didn't know anything about that. I'm also using Odroid Go Super instead of Advance, but I'm no sure this matters much.

Is there a more up to date documentation, or could the existing one be fixed?
If you build the Hardkernel U-Boot it has the Rockchip miniloader and trust image included so it boots as desired. If you build mainline u-boot, it does not have those files and defaults to using the u-boot in SPI flash. You can hold the reset button to either do recovery on the SPI flash or force load the U-boot on the SD card.

royger
Posts: 18
Joined: Fri Jan 08, 2021 2:22 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: Using upstream u-boot 2021.01

Post by royger »

So I'm trying the plain image from Hardkernel v2.1 from:

https://wiki.odroid.com/odroid_go_advance/make_sd_card

Without any kind of modifications, just used the balenaEtcher stuff to flash it into an SD card. And I get the following output from the serial header:

Code: Select all

U-Boot 2017.09-00038-ge9d7bedabe (Jan 10 2021 - 19:49:14 -0300)

Model: Rockchip RK3326 ODROID-GO Advanced
PreSerial: 2
DRAM:  992 MiB
Sysmem: init
Relocation Offset is: 3dabb000
Using default environment

adc0 (hw rev) 82
no mmc device at slot 1
RKPARM: Invalid parameter part table
Found IDB in SDcard
dwmmc@ff370000: 1 (SD)
Bootdev(atags): mmc 1
MMC1: Legacy, 50Mhz
PartType: DOS
init_resource_list: failed to get resource part, ret=-1
dtb in resource read fail, try dtb in spi flash
sfc nor id: b 40 18

Device 1: GUID Partition Table Header signature is wrong: 0xFFFFFFFFFFFFFFFF != 0x5452415020494645
Repair the backup gpt table OK!
Vendor: 0x0308 Rev: V1.00 Prod: rkflash-SpiNor
            Type: Hard Disk
            Capacity: 16.0 MB = 0.0 GB (32768 x 512)
... is now current device

spinor read: device 1 block # 12392, count 200 ... 200 blocks read: OK
I2c speed: 400000Hz
PMIC:  RK8170 (on=0x80, off=0x80)
vdd_logic 1100000 uV
vdd_arm 1100000 uV
 Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Model: ODROID-GO3 for linux based on Rockchip rk3326
download key pressed... entering recovery mode!
boot mode: recovery (key)
CLK: (sync kernel. arm: enter 600000 KHz, init 600000 KHz, kernel 600000 KHz)
  apll 600000 KHz
  dpll 664000 KHz
  cpll 24000 KHz
  npll 1188000 KHz
  gpll 1200000 KHz
  aclk_bus 200000 KHz
  hclk_bus 150000 KHz
  pclk_bus 100000 KHz
  aclk_peri 200000 KHz
  hclk_peri 150000 KHz
  pclk_pmu 100000 KHz
Rockchip UBOOT DRM driver version: v1.0.1
Using display timing dts
Detailed mode clock 27500 kHz, flags[a]
    H: 0480 0490 0500 0505
    V: 0854 0866 0868 0928
bus_format: 100e
final DSI-Link bandwidth: 366 Mbps x 2
 Unable to read file logo.bmp
logo.bmp file not found! filesize = 0

spinor read: device 1 block # 12592, count 400 ... 400 blocks read: OK
Uncompressed size: 1229814 = 0x12C3F6
switch to partitions #0, OK
mmc1 is current device
Net:   Net Initialization Skipped
No ethernet found.
Hit key to stop autoboot('CTRL+C'):  0
switch to partitions #0, OK
mmc1 is current device
reading boot.ini
1150 bytes read in 3 ms (374 KiB/s)
## Executing script at 00800800
reading Image
14972936 bytes read in 655 ms (21.8 MiB/s)
reading uInitrd
9221723 bytes read in 405 ms (21.7 MiB/s)
reading rk3326-odroidgo3-linux.dtb
89198 bytes read in 7 ms (12.2 MiB/s)
## Loading init Ramdisk from Legacy Image at 01100000 ...
   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (uncompressed)
   Data Size:    9221659 Bytes = 8.8 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
  'reserved-memory' region@110000: addr=110000 size=f0000
   Loading Ramdisk to 313e3000, end 31cae61b ... OK
   Loading Device Tree to 00000000313ca000, end 00000000313e2c6d ... OK
reserve drm-loader-logo offset = 58604
reserve drm-logo mem = 000000003de00000, size = 3736832
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x0a200000 - 0x40000000 (size: 0x35e00000)
Total: 4157.1 ms

Starting kernel ...
Note the "dtb in resource read fail, try dtb in spi flash" message, which makes me wonder if even the SD image provided by Hardkernel has u-boot properly setup on the image, as it seems to use the one from the SPI recovery flash instead of the SD one?

Maybe I'm just confused because I'm not really familiar with all the Arm u-boot stuff.

Thanks.

User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

Re: Using upstream u-boot 2021.01

Post by odroid »

It should boot out of the box.
Can you check the md5sum value of the downloaded file?
3f7126d705c339f16b88aa2d6ce01a8a ubuntu-18.04-4.4-es-odroid-goS-20201218.img.xz
Don't extract the xz file if you use Etcher.

BTW, do you use a UHS-1 compatible microSD card?

macromorgan
Posts: 117
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 47 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macromorgan »

For upstream uboot, master builds fine but there are a few gotchas.

First, if you want to go FULLY upstream you’ll need to build ARM trusted firmware and copy the resultant bl31.elf into the uboot source root directory. When you build you’ll have to edit the config for the SPL stage where it reads the u-boot off of the MMC. By default it is set to 0x200, but it should read uboot from 0x4000. Once it’s done compiling, flash it to your SD card by “dd if=u-boot-rockchip.bin of=/dev/mmcblkX bs=512 seek=64”. The u-boot-rockchip.bin has the tpl, SPL, and uboot stages at the right offsets (uboot is at 0x4000 so you had to change it). Make sure when you create your filesystem you don’t put anything in the first 16MB.

As for using miniloader, you can follow the rockchip instructions from their website for building upstream. Note for using miniloader you will have to create a memory hole for Optee, otherwise the system will crash the instant Linux tries to use the RAM.

In both cases you will have to hold the reset button while pressing the power button, otherwise it will boot from the internal flash chip. If you erase the internal flash chip you can always boot from SD without having to push reset. Let me know if I can help you in any way.
These users thanked the author macromorgan for the post:
notime2d8 (Tue Feb 09, 2021 3:20 pm)

royger
Posts: 18
Joined: Fri Jan 08, 2021 2:22 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: Using upstream u-boot 2021.01

Post by royger »

odroid wrote:
Tue Feb 09, 2021 12:12 pm
It should boot out of the box.
Can you check the md5sum value of the downloaded file?
3f7126d705c339f16b88aa2d6ce01a8a ubuntu-18.04-4.4-es-odroid-goS-20201218.img.xz
Don't extract the xz file if you use Etcher.

BTW, do you use a UHS-1 compatible microSD card?
I'm using 20210120, which has the following checksum:

d86d70e14e444f0b57ce9ab4f9ba516d ubuntu-18.04-4.4-es-odroid-goS-20210120.img.xz

Yes, the SD card is a Lexar UHS-1.

If I instead press the back reset button while powering up like @macromorgan suggested it does use the u-boot from the SD I think, see slightly different output in that case:

Code: Select all

U-Boot 201709-00038-ge9d7bedabe (Jan 10 2021 - 19:49:14 -0300)

Model: Rockchip RK3326 ODROID-GO Advanced
DRAM:  992 MiB
Sysmem: init
Relocation Offset is: 3dabb000
Using default environment

adc0 (hw rev) 82
dwmmc@ff370000: 1
## Error: "rkimg_bootdev" not defined
Bootdev: mmc 0
rockchip_get_bootdev: Can't find dev_desc!
init_resource_list: dev_desc is NULL!
RKPARM: Invalid parameter part table
dtb in resource read fail, try dtb in spi flash
sfc nor id: 0 0 0
ret -1

Device 1: sfc nor id: 0 0 0
ret -1

spinor read: device 1 block # 12392, count 200  sfc nor id: 0 0 0
ret -1
-1 blocks read: ERROR
dtb in spi flash fail, try dtb in fat
reading rk3326-odroidgo3-linuxdtb
89198 bytes read in 8 ms (106 MiB/s)
I2c speed: 400000Hz
PMIC:  RK8170 (on=0x80, off=0x08)
vdd_logic 1100000 uV
vdd_arm 1100000 uV
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Model: Hardkernel ODROID-GO3
rockchip_get_bootdev: Can't find dev_desc!
[Vendor ERROR]:Invalid boot device type(0)
rockchip_get_bootdev: Can't find dev_desc!
[Vendor ERROR]:Invalid boot device type(0)
download key pressed entering recovery mode!
boot mode: recovery (key)
CLK: (sync kernel arm: enter 600000 KHz, init 600000 KHz, kernel 600000 KHz)
  apll 600000 KHz
  dpll 664000 KHz
  cpll 24000 KHz
  npll 1188000 KHz
  gpll 1200000 KHz
  aclk_bus 200000 KHz
  hclk_bus 150000 KHz
  pclk_bus 100000 KHz
  aclk_peri 200000 KHz
  hclk_peri 150000 KHz
  pclk_pmu 100000 KHz
Rockchip UBOOT DRM driver version: v101
Using display timing dts
Detailed mode clock 27500 kHz, flags[a]
    H: 0480 0482 0492 0494
    V: 0854 0866 0868 0928
bus_format: 100e
final DSI-Link bandwidth: 366 Mbps x 2
** Unable to read file logobmp **
logobmp file not found! filesize = 0

spinor read: device 1 block # 12592, count 400  sfc nor id: ff ff ff
ret -1
-1 blocks read: ERROR
cat not find bmp file
show_bmp : failed to decode bmp at 0x000000003df90500
switch to partitions #0, OK
mmc1 is current device
Net:   Net Initialization Skipped
No ethernet found
Hit key to stop autoboot('CTRL+C'):  0
switch to partitions #0, OK
mmc1 is current device
reading bootini
1150 bytes read in 4 ms (2803 KiB/s)
## Executing script at 00800800
reading Image
14972936 bytes read in 660 ms (216 MiB/s)
reading uInitrd
9351226 bytes read in 417 ms (214 MiB/s)
reading rk3326-odroidgo3-linuxdtb
89198 bytes read in 8 ms (106 MiB/s)
## Loading init Ramdisk from Legacy Image at 01100000
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    9351162 Bytes = 89 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum  OK
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
  'reserved-memory' region@110000: addr=110000 size=f0000
   Loading Ramdisk to 313c3000, end 31cadffa  OK
   Loading Device Tree to 00000000313aa000, end 00000000313c2c6d  OK
cat not find bmp file
show_bmp : failed to decode bmp at 0x000000003df90500
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x0a200000 - 0x40000000 (size: 0x35e00000)
Total: 373258 ms

Starting kernel
I assume the above output is from the u-boot in the SD card instead of the SPI one. Is it really intended to use the u-boot from SPI instead of the SD card by default? It doesn't seem to be documented anywhere, and renders the whole point of updating u-boot on the SD card pointless, as I don't plan to go around with a toothpick to press the reset button every time I boot.

@odroid is there anyway to change the default to pick u-boot from the SD instead of SPI?

User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

Re: Using upstream u-boot 2021.01

Post by odroid »

That image is the latest correct one. Sorry for the confusion caused.

As far as I remember, the u-boot in the SD card must be loaded instead of the SPI flash.
I hope @joy will confirm and help you early next week after Lunar new year holidays.

Meanwhile, can you please reflash the SPI image pre-built v1.4 to narrow down root causes?
https://wiki.odroid.com/odroid_go_advan ... ery_spirom
Attachments
ss_go3clear1_SPI.jpg
ss_go3clear1_SPI.jpg (45.9 KiB) Viewed 7943 times

royger
Posts: 18
Joined: Fri Jan 08, 2021 2:22 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: Using upstream u-boot 2021.01

Post by royger »

Thanks for the detailed information! I will reply inline as I think it will make it easier to see the right context. I've also asked on the U-Boot mailing list, so part of my reply below is based on that:

https://lists.denx.de/pipermail/u-boot/ ... 40591.html
macromorgan wrote:
Tue Feb 09, 2021 2:49 pm
For upstream uboot, master builds fine but there are a few gotchas.

First, if you want to go FULLY upstream you’ll need to build ARM trusted firmware and copy the resultant bl31.elf into the uboot source root directory.
OK, so far I've tried using the bl31.elf from RockChip:

https://github.com/rockchip-linux/rkbin ... _v1.21.elf

I've looked at the Arm trusted firmware software, but it doesn't seem to support rk3326?

https://github.com/ARM-software/arm-tru ... t/rockchip
macromorgan wrote:
Tue Feb 09, 2021 2:49 pm
When you build you’ll have to edit the config for the SPL stage where it reads the u-boot off of the MMC. By default it is set to 0x200, but it should read uboot from 0x4000.
Sorry, I'm afraid I'm lost here. Is this a file in the u-boot source code that I need to modify, or something else? Would you mind pointing out where it is exactly?
macromorgan wrote:
Tue Feb 09, 2021 2:49 pm
Once it’s done compiling, flash it to your SD card by “dd if=u-boot-rockchip.bin of=/dev/mmcblkX bs=512 seek=64”. The u-boot-rockchip.bin has the tpl, SPL, and uboot stages at the right offsets (uboot is at 0x4000 so you had to change it). Make sure when you create your filesystem you don’t put anything in the first 16MB.
So following the guidelines from upstream I originally did:

dd if=idbloader.img of=/dev/foo conv=fsync bs=512 seek=64
dd if=u-boot.itb of=/dev/foo conv=fsync bs=512 seek=16384

Is this equivalent to flashing u-boot-rockchip.bin?
macromorgan wrote:
Tue Feb 09, 2021 2:49 pm
As for using miniloader, you can follow the rockchip instructions from their website for building upstream. Note for using miniloader you will have to create a memory hole for Optee, otherwise the system will crash the instant Linux tries to use the RAM.
I think I will stick with idbloader right now, as that seems to be easier to build. Is there any benefit of using miniloader instead?
macromorgan wrote:
Tue Feb 09, 2021 2:49 pm
In both cases you will have to hold the reset button while pressing the power button, otherwise it will boot from the internal flash chip.
So when dd'ing idbloader.img and u-boot.itb separately I just get the following output when booting with the reset button pressed:

Code: Select all

U-Boot TPL board init
DDR3, 333MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS=1 Die BW=16 Size=1024MB
out
No serial driver found
resetting ...
Doesn't seem to be picking u-boot from the SD at all. While if I boot from the SD flashed with u-boot-rockchip.bin I do seem to get a bit further:

Code: Select all

U-Boot TPL board init
DDR3, 333MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS=1 Die BW=16 Size=1024MB
out

U-Boot SPL 2021.01 (Feb 08 2021 - 16:33:03 +0100)
Trying to boot from MMC1
mmc_load_image_raw_sector: mmc block read error
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
I don't even have a partition table on that SD, so I guess that's where U-Boot is complaining with the "mmc block read error"? Or maybe that's because I haven't adjusted SPL to load from 0x4000 as you said above?
macromorgan wrote:
Tue Feb 09, 2021 2:49 pm
If you erase the internal flash chip you can always boot from SD without having to push reset. Let me know if I can help you in any way.
Thanks very much for all the help, I think I did manage to make some progress! Are there instructions about how to wipe the internal flash chip? Is there any tradeoff/risk from wiping it?

royger
Posts: 18
Joined: Fri Jan 08, 2021 2:22 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: Using upstream u-boot 2021.01

Post by royger »

odroid wrote:
Tue Feb 09, 2021 5:50 pm
That image is the latest correct one. Sorry for the confusion caused.

As far as I remember, the u-boot in the SD card must be loaded instead of the SPI flash.
I hope @joy will confirm and help you early next week after Lunar new year holidays.

Meanwhile, can you please reflash the SPI image pre-built v1.4 to narrow down root causes?
https://wiki.odroid.com/odroid_go_advan ... ery_spirom
So I've flashed v1.4 SPI image, and now I'm seeing a different behaviour, it does seem to pick up the U-Boot version from the SD card when using v2.1 Ubuntu image I do see:

Code: Select all

U-Boot 2017.09-00038-ge9d7bedabe (Jan 10 2021 - 19:49:14 -0300)

Model: Rockchip RK3326 ODROID-GO Advanced
PreSerial: 2
DRAM:  992 MiB
Sysmem: init
Relocation Offset is: 3dabb000
Using default environment

adc0 (hw rev) 82
no mmc device at slot 1
RKPARM: Invalid parameter part table
Found IDB in SDcard
dwmmc@ff370000: 1 (SD)
Bootdev(atags): mmc 1
MMC1: Legacy, 50Mhz
PartType: DOS
init_resource_list: failed to get resource part, ret=-1
dtb in resource read fail, try dtb in spi flash
sfc nor id: b 40 18

Device 1: GUID Partition Table Header signature is wrong: 0xFFFFFFFFFFFFFFFF != 0x5452415020494645
Repair the backup gpt table OK!
Vendor: 0x0308 Rev: V1.00 Prod: rkflash-SpiNor
            Type: Hard Disk
            Capacity: 16.0 MB = 0.0 GB (32768 x 512)
... is now current device

spinor read: device 1 block # 12392, count 200 ... 200 blocks read: OK
I2c speed: 400000Hz
PMIC:  RK8170 (on=0x80, off=0x04)
vdd_logic 1100000 uV
vdd_arm 1100000 uV
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Model: ODROID-GO3 for linux based on Rockchip rk3326
download key pressed... entering recovery mode!
boot mode: recovery (key)
CLK: (sync kernel. arm: enter 600000 KHz, init 600000 KHz, kernel 600000 KHz)
  apll 600000 KHz
  dpll 664000 KHz
  cpll 24000 KHz
  npll 1188000 KHz
  gpll 1200000 KHz
  aclk_bus 200000 KHz
  hclk_bus 150000 KHz
  pclk_bus 100000 KHz
  aclk_peri 200000 KHz
  hclk_peri 150000 KHz
  pclk_pmu 100000 KHz
Rockchip UBOOT DRM driver version: v1.0.1
Using display timing dts
Detailed mode clock 27500 kHz, flags[a]
    H: 0480 0490 0500 0505
    V: 0854 0866 0868 0928
bus_format: 100e
final DSI-Link bandwidth: 366 Mbps x 2
** Unable to read file logo.bmp **
logo.bmp file not found! filesize = 0

spinor read: device 1 block # 12592, count 400 ... 400 blocks read: OK
Uncompressed size: 1229814 = 0x12C3F6
switch to partitions #0, OK
mmc1 is current device
Net:   Net Initialization Skipped
No ethernet found.
Hit key to stop autoboot('CTRL+C'):  0
switch to partitions #0, OK
mmc1 is current device
reading boot.ini
1150 bytes read in 4 ms (280.3 KiB/s)
## Executing script at 00800800
reading Image
14972936 bytes read in 660 ms (21.6 MiB/s)
reading uInitrd
9351226 bytes read in 417 ms (21.4 MiB/s)
reading rk3326-odroidgo3-linux.dtb
89198 bytes read in 8 ms (10.6 MiB/s)
## Loading init Ramdisk from Legacy Image at 01100000 ...
   Image Name:   uInitrd
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    9351162 Bytes = 8.9 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
  'reserved-memory' region@110000: addr=110000 size=f0000
   Loading Ramdisk to 313c3000, end 31cadffa ... OK
   Loading Device Tree to 00000000313aa000, end 00000000313c2c6d ... OK
reserve drm-loader-logo offset = 58604
reserve drm-logo mem = 000000003de00000, size = 3736832
Adding bank: 0x00200000 - 0x08400000 (size: 0x08200000)
Adding bank: 0x0a200000 - 0x40000000 (size: 0x35e00000)
Total: 4182.249 ms

Starting kernel ...
Which does seem to point out that the U-Boot on the SD card is used instead of the SPI one, even without pressing the disable SPI button on the back.

The weird part of this is that while U-Boot from the minimal Ubuntu image seems to be used I cannot still boot upstream U-Boot without pressing the disable SPI button. If I don't press the button I just get garbage on the serial console. If I press the disable SPI button I get some output from the SD U-Boot:

Code: Select all

U-Boot TPL board init
DDR3, 333MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS=1 Die BW=16 Size=1024MB
out

U-Boot SPL 2021.01 (Feb 08 2021 - 16:33:03 +0100)
Trying to boot from MMC1
mmc_load_image_raw_sector: mmc block read error
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
Is there anything I'm missing for using upstream U-Boot without having to press the SPI disable button?

Thanks!

User avatar
odroid
Site Admin
Posts: 41084
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 3194 times
Been thanked: 1753 times
Contact:

Re: Using upstream u-boot 2021.01

Post by odroid »

Good to hear that you have a small progress at least.

A stock miniloader in the SPI flash seems not to be compatible with your upstream u-boot blobs probably.
But, since we've not used any upstream u-boot, I have no idea what is really wrong.

royger
Posts: 18
Joined: Fri Jan 08, 2021 2:22 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: Using upstream u-boot 2021.01

Post by royger »

odroid wrote:
Tue Feb 09, 2021 7:14 pm
Good to hear that you have a small progress at least.

A stock miniloader in the SPI flash seems not to be compatible with your upstream u-boot blobs probably.
But, since we've not used any upstream u-boot, I have no idea what is really wrong.
Thanks! So the boot process when not pressing the SPI button involves using miniloader from SPI and then chainloading U-Boot from the SD card?

Is miniloader something that can be built to support newer U-Boot versions if that's what's missing?

What version of miniloader is packed with the SPI recovery image?

Or maybe there's a way to force the disable SPI mode as default? Ie: would be nice if it could be inverted so that the default is to boot from the SD, and when pressing the reset button boot is attempted from the SPI instead.

Thanks.

macromorgan
Posts: 117
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 47 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macromorgan »

Sorry for last night's terse response, I was on my phone and not quite as able to be detailed. The bootflow for this device is that there is an on chip BROM that goes down a full list of things and boots whatever is available first. The SPI chip is given a higher priority than the SD card, so as long as there is something valid on the SPI chip it will always boot off of that first. The miniloader from Rockchip appears to want to boot off of SD if there is a valid image though, so (I'm guessing here) the stock bootflow is basically 1) BROM, 2) Miniloader in the SPI, 3) if trust.img in the SD then A-TF and Op-Tee from the SD else from the SPI, 4) if Uboot in SD then boot from SD otherwise Uboot from SPI, 5) Linux. When you push the reset button you basically drive the CS pin of the SPI chip so that the chip is not seen by the BROM, forcing it to skip the SPI chip and move down to the SD card.

As for building a completely upstream U-Boot, you can do the following:
First, you need to check out the Arm Trusted Firmware repository to build an upstream A-TF.

Code: Select all

git clone https://github.com/ARM-software/arm-trusted-firmware.git
Go into the A-TF directory that you just checked out and make for the PX30 (the RK3326 is literally just a PX30 without the "little" end of the video output processor).

Code: Select all

make CROSS_COMPILE=aarch64-linux-gnu- PLAT=px30 bl31
Assuming everything went smoothly, you should now have a valid A-TF image at ./build/px30/release/bl31/bl31.elf. You can either copy this elf file to the root of your u-boot tree or export the absolute path to it by doing

Code: Select all

export BL31=$(pwd)/bl31.elf
Note that you'll have to be in the same directory as the elf file to use that specific command, but you get the gist. If you need to rebuild the A-TF for any reason you'll need to unset BL31 as an environment variable and clean your build tree with a make distclean.

Now it's time for u-boot. Clone the upstream sources if you have not done so already (kind of hard to copy the elf file if the tree isn't already there...)

Code: Select all

git clone https://github.com/u-boot/u-boot.git
Start with a make odroid-go2_defconfig to pull in the stock config.

Code: Select all

make odroid-go2_defconfig
At this point you can edit the config if you want or start building it as-is. Note that you MUST change the CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR option from the default value of 0x200 to 0x4000. U-boot is supposed to be loaded from the SD card at the 8MB mark, but for some reason by default this is set to 0x200. Setting it to 0x4000 should fix it.

Do your full u-boot build now and wait for it to complete. Look for any errors in the output; if there is a problem with your bl31.elf U-boot won't fail but it will warn you that your image isn't bootable.

Code: Select all

make CROSS_COMPILE=aarch64-linux-gnu-
If everything was good you should have a series of outputs in your build directory. The one you are most interested in is the u-boot-rockchip.bin file. This file has the TPL, SPL U-Boot, and all the other images all at the correct offsets and bundled the correct way. All you need to do is flash it to a blank SD card by doing the following (note the seek offset, it's supposed to start at exactly sector 64 where the BROM expects to find the TPL stage).

Code: Select all

dd if=u-boot-rockchip.bin of=/dev/foo bs=512 seek=64
If all goes well you should be able to boot up the device by holding down the reset button and pressing power into a fully upstream u-boot. Please note that upstream u-boot doesn't use the boot.ini file format, you must make boot.scr files for it to read and load.

Bonus: This doesn't apply to the OGS since it has a different GPIO structure on the 10 pin header, but you can change the u-boot console to UART1 if you do the following:
Change the CONFIG_DEBUG_UART_CHANNEL to 0 and the CONFIG_DEBUG_UART_BASE to 0xFF158000 in the u-boot config file.
Change the stdout-path line in the arch/arm/dts/rk3326-odroid-go2.dts file to read stdout-path = "serial1:115200n8"; (note the change from serial 2 to serial 1).

This way you can debug without having to use the debug port.
These users thanked the author macromorgan for the post:
royger (Mon Feb 22, 2021 9:22 pm)

macromorgan
Posts: 117
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 47 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macromorgan »

As for building with the miniloader, here's how you do it.

Check out the rockchip rkbin sources.

Code: Select all

git clone https://github.com/rockchip-linux/rkbin.git
Go into the rockchip rkbin directory and build the miniloader. Note you can skip this step if you use the miniloader present in the sd_fuse directory of the Hardkernel u-boot sources.

Code: Select all

tools/mkimage -n px30 -T rksd -d bin/rk33/rk3326_ddr_333MHz_v1.15.bin idbloader.img
cat bin/rk33/rk3326_miniloader_v1.20.bin >> idbloader.img
Now build the trust.img from the rkbin directory. Note you can also skip this step if you want to use the trust.img present in the sd_fuse directory of the Hardkernel u-boot sources.

Code: Select all

tools/trust_merger RKTRUST/RK3326TRUST.ini
If you followed these steps you will have both a trust.img and a idbloader.img file in your rkbin folder. You will need these images later.

After this, build u-boot as indicated in my other post. Ignore all the parts about bl31.elf, it doesn't matter. Likewise if you get any warnings about bl31.elf, it doesn't matter. Once building is complete, copy the u-boot-dtb.bin from your source u-boot directory into the rkbin directory. Then, pack the u-boot image using the loaderimage tool.

Code: Select all

tools/loaderimage --pack --uboot u-boot-dtb.bin u-boot-dtb.img 0x00200000
At this point you will have your u-boot-dtb.img, your idbloader.img, and your trust.img in your rkbin folder. Flash these images to the SD card.

Code: Select all

dd if=idbloader.img of=/dev/foo bs=512 seek=64
dd if=u-boot-dtb.img of=/dev/foo bs=512 seek=16384
dd if=trust.img of=/dev/foo bs=512 seek=24576
For some reason I could never get this to boot without also holding the reset button, but your mileage may vary. Please note that this method creates secure memory for Op-Tee that Linux won't be aware of. If you don't create a memory hole in Linux you will get exception errors and crashes. Put something like this in your devicetree to create a hole at the addresses Op-Tee is using.

Code: Select all

        reserved-memory {
                #address-cells = <1>;
                #size-cells = <1>;
                ranges;
                
                optee_reserved: external-abort@8400000 {
                        reg = <0 0x8400000 0 0x1e00000>;
                        no-map;
                };
        };
Again, if you have any questions let me know. I'm still figuring this stuff out as I go along, but I've made some progress. The main/last piece I want to accomplish is reading the SPI flash chip in U-boot. I can't use the native SFC driver in either Linux or U-boot, but I can at least bit-bang it in Linux (not working in U-boot currently).
These users thanked the author macromorgan for the post:
royger (Mon Feb 22, 2021 9:22 pm)

macromorgan
Posts: 117
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 47 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macromorgan »

royger wrote:
Tue Feb 09, 2021 6:17 pm
Thanks very much for all the help, I think I did manage to make some progress! Are there instructions about how to wipe the internal flash chip? Is there any tradeoff/risk from wiping it?
Not sure of any risk, but for what it's worth I do dev work on my older Odroid Go Advance (original model) and I have wiped the SPI flash rom so I can boot exclusively off of upstream U-boot. I did so by booting an upstream kernel with the following in devicetree (so I can bitbang the SPI flash chip, note that the SFC driver isn't available upstream yet).

Code: Select all

        spi_gpio: spi {
                compatible = "spi-gpio";
                #address-cells = <0x1>;
                #size-cells = <0x0>;
                sck-gpios = <&gpio1 RK_PB1 0>;
                miso-gpios = <&gpio1 RK_PA1 0>;
                mosi-gpios = <&gpio1 RK_PA0 0>;
                cs-gpios = <&gpio1 RK_PA4 0>;
                num-chipselects = <1>;

                flash: XT25F128B@0 {
                        #address-cells = <1>;
                        #size-cells = <1>;
                        compatible = "XT25F128B","jedec,spi-nor";
                        reg = <0>;
                        spi-max-frequency = <500000>;
                };
        };
You'll need to make sure the CONFIG_SPI_GPIO is selected in your kernel as well. Once done, you should see a /dev/mtd0 on your device. I just wrote zeroes to the first part of it to wipe out the part read by the BROM.

Code: Select all

dd if=/dev/zero of=/dev/mtd0 bs=1M count=1
royger wrote:
Tue Feb 09, 2021 7:55 pm
Or maybe there's a way to force the disable SPI mode as default? Ie: would be nice if it could be inverted so that the default is to boot from the SD, and when pressing the reset button boot is attempted from the SPI instead.
I'm afraid that's not possible, the behavior is encoded in ROM. If there were a way to change the push button from being default open until pushed to default closed until pushed would be the only way, and I'm not sure how you'd accomplish that. The button is connected directly to the CS line of the SPI flash chip and basically makes the flash chip reset itself as long as you hold it down. Doing so during bootup hides the chip from the BROM.
These users thanked the author macromorgan for the post:
royger (Mon Feb 22, 2021 9:22 pm)

macc24
Posts: 58
Joined: Sun Sep 20, 2020 11:31 pm
languages_spoken: english polish
ODROIDs: Basically quit doing ARM handheld stuff.
Has thanked: 6 times
Been thanked: 24 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macc24 »

macromorgan wrote:
Wed Feb 10, 2021 1:28 am
I'm afraid that's not possible, the behavior is encoded in ROM. If there were a way to change the push button from being default open until pushed to default closed until pushed would be the only way, and I'm not sure how you'd accomplish that. The button is connected directly to the CS line of the SPI flash chip and basically makes the flash chip reset itself as long as you hold it down. Doing so during bootup hides the chip from the BROM.
With enough care, the pushbutton can be manually shorted using soldering iron, but wiping spi flash is much better idea

royger
Posts: 18
Joined: Fri Jan 08, 2021 2:22 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: Using upstream u-boot 2021.01

Post by royger »

Thanks much for the detailed input. I've managed to get upstream u-boot working and sent some minor fixes upstream, like the CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR stuff.

It would be nice to have a branch with the Hardkernel u-boot patches on top of the main u-boot repository, as that would help figure out what's needed to upstream into mainline. I think there are a bunch of pieces missing in mainline u-boot (like screen support?)

royger
Posts: 18
Joined: Fri Jan 08, 2021 2:22 am
languages_spoken: english
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: Using upstream u-boot 2021.01

Post by royger »

macromorgan wrote:
Wed Feb 10, 2021 1:28 am
Not sure of any risk, but for what it's worth I do dev work on my older Odroid Go Advance (original model) and I have wiped the SPI flash rom so I can boot exclusively off of upstream U-boot. I did so by booting an upstream kernel with the following in devicetree (so I can bitbang the SPI flash chip, note that the SFC driver isn't available upstream yet).

Code: Select all

        spi_gpio: spi {
                compatible = "spi-gpio";
                #address-cells = <0x1>;
                #size-cells = <0x0>;
                sck-gpios = <&gpio1 RK_PB1 0>;
                miso-gpios = <&gpio1 RK_PA1 0>;
                mosi-gpios = <&gpio1 RK_PA0 0>;
                cs-gpios = <&gpio1 RK_PA4 0>;
                num-chipselects = <1>;

                flash: XT25F128B@0 {
                        #address-cells = <1>;
                        #size-cells = <1>;
                        compatible = "XT25F128B","jedec,spi-nor";
                        reg = <0>;
                        spi-max-frequency = <500000>;
                };
        };
You'll need to make sure the CONFIG_SPI_GPIO is selected in your kernel as well. Once done, you should see a /dev/mtd0 on your device. I just wrote zeroes to the first part of it to wipe out the part read by the BROM.

Code: Select all

dd if=/dev/zero of=/dev/mtd0 bs=1M count=1
I guess it's always possible to restore the contents of the SPI by flashing the recovery image? (the ones from https://wiki.odroid.com/odroid_go_advan ... ery_spirom)

macromorgan
Posts: 117
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 47 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macromorgan »

royger wrote:
Mon Feb 22, 2021 9:25 pm
Thanks much for the detailed input. I've managed to get upstream u-boot working and sent some minor fixes upstream, like the CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR stuff.

It would be nice to have a branch with the Hardkernel u-boot patches on top of the main u-boot repository, as that would help figure out what's needed to upstream into mainline. I think there are a bunch of pieces missing in mainline u-boot (like screen support?)
Screen and SFC are the main pieces I think that are missing. Screen should be straightforward enough (famous last words) but I'm still struggling with the SFC bit. For now I'm able to bitbang the SPI chip, albeit very very slowly (40KB/s).

macc24
Posts: 58
Joined: Sun Sep 20, 2020 11:31 pm
languages_spoken: english polish
ODROIDs: Basically quit doing ARM handheld stuff.
Has thanked: 6 times
Been thanked: 24 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macc24 »

macromorgan wrote:
Tue Feb 23, 2021 2:41 am
Screen and SFC are the main pieces I think that are missing. Screen should be straightforward enough (famous last words) but I'm still struggling with the SFC bit. For now I'm able to bitbang the SPI chip, albeit very very slowly (40KB/s).
Screen isn't as hard as it looks to be, as afaik px30 uses a dw mipi-dsi controller and u-boot supports them, what would be needed is just panel driver + px30 specific stuff and maybe phy for mipi-dsi.
But if u-boot can load kernel fast enough so user doesn't notice anything(keyword: falcon) there isn't really a reason to have screen since letting linux do everything would make sense in this usecase

macromorgan
Posts: 117
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 47 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macromorgan »

Three fucking months later...

Code: Select all

U-Boot TPL board init
DDR3, 333MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS=1 Die BW=16 Size=1024MB
out

U-Boot SPL 2021.07-rc2+ (May 12 2021 - 14:12:13 -0500)
Trying to boot from SPI
NOTICE:  BL31: v2.4(debug):v2.5-rc1
NOTICE:  BL31: Built : 14:11:42, May 12 2021
INFO:    ARM GICv2 driver initialized
INFO:    plat_rockchip_pmu_init: pd status d00e
INFO:    BL31: Initializing runtime services
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000
INFO:    SPSR = 0x3c9


U-Boot 2021.07-rc2+ (May 12 2021 - 14:12:13 -0500)

Model: ODROID-GO Advance
DRAM:  1022 MiB
PMIC:  RK8170 (on=0x80, off=0x80)
MMC:   dwmmc@ff370000: 0
Loading Environment from FAT... OK
In:    serial@ff160000
Out:   serial@ff160000
Err:   serial@ff160000
Model: ODROID-GO Advance
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
1201 bytes read in 3 ms (390.6 KiB/s)
## Executing script at 00500000
43930 bytes read in 6 ms (7 MiB/s)
8 bytes filled with random data
13333927 bytes read in 562 ms (22.6 MiB/s)
   Uncompressing Kernel Image
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 000000003df1b000, end 000000003df28fff ... OK

Starting kernel ...
Please note that while U-boot does appear to start Linux it doesn't seem to start A-TF correctly (and no amount of debugging options on the A-TF or U-boot firmware will tell me why, but CPUs 1 through 3 fail to come online and Linux halts halfway through the boot process). So while yes, I can boot a fully open stack from the BROM all the way to the kernel now it's still pretty broken. I'm working with the MTD guys to see if we can figure out why, but this one is a noodle scratcher. Identical binaries produce different results depending upon where they are loaded from which is really strange. Booting works normally and as expected when booting from SD, but doing so from the SPI/SFC fails.

I'll post patches later, but for now the main things I did are 1) update the devicetrees in U-boot to support booting from SPI, 2) update the clock driver in U-boot to support turning on the SFC clock, 3) update the cru driver in U-boot to support setting the correct pin configuration for the SFC, 4) copying the U-boot SFC driver from Rockchip's branch, and 5) recognizing that you need to shift the trb bits 8 places to the left when you update the address (as the last two bytes are unused).
These users thanked the author macromorgan for the post:
notime2d8 (Fri May 14, 2021 1:13 am)

notime2d8
Posts: 350
Joined: Thu Dec 11, 2014 4:40 am
languages_spoken: english
Has thanked: 106 times
Been thanked: 158 times
Contact:

Re: Using upstream u-boot 2021.01

Post by notime2d8 »

macromorgan wrote:
Thu May 13, 2021 11:36 pm
Three fucking months later...

Code: Select all

U-Boot TPL board init
DDR3, 333MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS=1 Die BW=16 Size=1024MB
out

U-Boot SPL 2021.07-rc2+ (May 12 2021 - 14:12:13 -0500)
Trying to boot from SPI
NOTICE:  BL31: v2.4(debug):v2.5-rc1
NOTICE:  BL31: Built : 14:11:42, May 12 2021
INFO:    ARM GICv2 driver initialized
INFO:    plat_rockchip_pmu_init: pd status d00e
INFO:    BL31: Initializing runtime services
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000
INFO:    SPSR = 0x3c9


U-Boot 2021.07-rc2+ (May 12 2021 - 14:12:13 -0500)

Model: ODROID-GO Advance
DRAM:  1022 MiB
PMIC:  RK8170 (on=0x80, off=0x80)
MMC:   dwmmc@ff370000: 0
Loading Environment from FAT... OK
In:    serial@ff160000
Out:   serial@ff160000
Err:   serial@ff160000
Model: ODROID-GO Advance
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
1201 bytes read in 3 ms (390.6 KiB/s)
## Executing script at 00500000
43930 bytes read in 6 ms (7 MiB/s)
8 bytes filled with random data
13333927 bytes read in 562 ms (22.6 MiB/s)
   Uncompressing Kernel Image
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 000000003df1b000, end 000000003df28fff ... OK

Starting kernel ...
Please note that while U-boot does appear to start Linux it doesn't seem to start A-TF correctly (and no amount of debugging options on the A-TF or U-boot firmware will tell me why, but CPUs 1 through 3 fail to come online and Linux halts halfway through the boot process). So while yes, I can boot a fully open stack from the BROM all the way to the kernel now it's still pretty broken. I'm working with the MTD guys to see if we can figure out why, but this one is a noodle scratcher. Identical binaries produce different results depending upon where they are loaded from which is really strange. Booting works normally and as expected when booting from SD, but doing so from the SPI/SFC fails.

I'll post patches later, but for now the main things I did are 1) update the devicetrees in U-boot to support booting from SPI, 2) update the clock driver in U-boot to support turning on the SFC clock, 3) update the cru driver in U-boot to support setting the correct pin configuration for the SFC, 4) copying the U-boot SFC driver from Rockchip's branch, and 5) recognizing that you need to shift the trb bits 8 places to the left when you update the address (as the last two bytes are unused).
Awesome job as always. This could potentially allow USB booting with some tweaks? Without needing a SD card. 🤔 Is there any remaining space for a initrd?

macromorgan
Posts: 117
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 47 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macromorgan »

notime2d8 wrote:
Fri May 14, 2021 1:33 am
macromorgan wrote:
Thu May 13, 2021 11:36 pm
Three fucking months later...

Code: Select all

U-Boot TPL board init
DDR3, 333MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS=1 Die BW=16 Size=1024MB
out

U-Boot SPL 2021.07-rc2+ (May 12 2021 - 14:12:13 -0500)
Trying to boot from SPI
NOTICE:  BL31: v2.4(debug):v2.5-rc1
NOTICE:  BL31: Built : 14:11:42, May 12 2021
INFO:    ARM GICv2 driver initialized
INFO:    plat_rockchip_pmu_init: pd status d00e
INFO:    BL31: Initializing runtime services
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x200000
INFO:    SPSR = 0x3c9


U-Boot 2021.07-rc2+ (May 12 2021 - 14:12:13 -0500)

Model: ODROID-GO Advance
DRAM:  1022 MiB
PMIC:  RK8170 (on=0x80, off=0x80)
MMC:   dwmmc@ff370000: 0
Loading Environment from FAT... OK
In:    serial@ff160000
Out:   serial@ff160000
Err:   serial@ff160000
Model: ODROID-GO Advance
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
1201 bytes read in 3 ms (390.6 KiB/s)
## Executing script at 00500000
43930 bytes read in 6 ms (7 MiB/s)
8 bytes filled with random data
13333927 bytes read in 562 ms (22.6 MiB/s)
   Uncompressing Kernel Image
## Flattened Device Tree blob at 01f00000
   Booting using the fdt blob at 0x1f00000
   Loading Device Tree to 000000003df1b000, end 000000003df28fff ... OK

Starting kernel ...
Please note that while U-boot does appear to start Linux it doesn't seem to start A-TF correctly (and no amount of debugging options on the A-TF or U-boot firmware will tell me why, but CPUs 1 through 3 fail to come online and Linux halts halfway through the boot process). So while yes, I can boot a fully open stack from the BROM all the way to the kernel now it's still pretty broken. I'm working with the MTD guys to see if we can figure out why, but this one is a noodle scratcher. Identical binaries produce different results depending upon where they are loaded from which is really strange. Booting works normally and as expected when booting from SD, but doing so from the SPI/SFC fails.

I'll post patches later, but for now the main things I did are 1) update the devicetrees in U-boot to support booting from SPI, 2) update the clock driver in U-boot to support turning on the SFC clock, 3) update the cru driver in U-boot to support setting the correct pin configuration for the SFC, 4) copying the U-boot SFC driver from Rockchip's branch, and 5) recognizing that you need to shift the trb bits 8 places to the left when you update the address (as the last two bytes are unused).
Awesome job as always. This could potentially allow USB booting with some tweaks? Without needing a SD card. 🤔 Is there any remaining space for a initrd?
~14MB enough? TPL/SPL comes in at 128k roughly, and U-Boot proper plus A-TF takes another meg or so at most (and can be located just about anywhere on the flash).

Also, I figured out the bug that was causing A-TF to fail; turns out A-TF doesn't like DMA early in the boot process. I disabled DMA in the SFC driver I'm working on and now it's working just fine.

USB booting is definitely doable, all you have to do is make sure the drivers are in place and make sure it's set up in host mode (I think by default it actually gets set in device/gadget mode).

macromorgan
Posts: 117
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 47 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macromorgan »

As promised: https://gist.github.com/macromorgan/868 ... 458dc99cd1

Note that I'm not distributing this as a fork but rather a patch, my overriding goal is to get this mainlined. Before that can happen I need to do a lot of testing and cleaning up of the SFC driver itself though.

edit: build this as detailed in my other posts about building mainline u-boot (make sure to build A-TF or it won't boot Linux!). As configured, write the idbloader.img to 0x10000 and the u-boot.itb to 0x200000 of the flash chip.
These users thanked the author macromorgan for the post:
odroid (Fri May 14, 2021 12:13 pm)

macromorgan
Posts: 117
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 47 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macromorgan »

macromorgan wrote:
Fri May 14, 2021 11:46 am
As promised: https://gist.github.com/macromorgan/868 ... 458dc99cd1

Note that I'm not distributing this as a fork but rather a patch, my overriding goal is to get this mainlined. Before that can happen I need to do a lot of testing and cleaning up of the SFC driver itself though.

edit: build this as detailed in my other posts about building mainline u-boot (make sure to build A-TF or it won't boot Linux!). As configured, write the idbloader.img to 0x10000 and the u-boot.itb to 0x200000 of the flash chip.
Upstreaming efforts for Linux: https://patchwork.ozlabs.org/project/li ... gmail.com/
I think this one is a few touch-ups away from prime-time.

Upstreaming efforts for U-boot: http://patchwork.ozlabs.org/project/ubo ... gmail.com/
Note that all things being equal, I plan on changing the clock names in U-boot to match the Linux driver. I'll also see if I can get dual mode working, as it takes flash read from 3.8MB/s to 5.7MB/s in Linux (though that's with DMA enabled, it must be disabled in SPL mode for U-boot). Lots to fix in this driver though.

macromorgan
Posts: 117
Joined: Mon Dec 30, 2019 10:35 am
languages_spoken: english
ODROIDs: Odroid-GO
Has thanked: 6 times
Been thanked: 47 times
Contact:

Re: Using upstream u-boot 2021.01

Post by macromorgan »

macromorgan wrote:
Thu May 27, 2021 4:45 am
macromorgan wrote:
Fri May 14, 2021 11:46 am
As promised: https://gist.github.com/macromorgan/868 ... 458dc99cd1

Note that I'm not distributing this as a fork but rather a patch, my overriding goal is to get this mainlined. Before that can happen I need to do a lot of testing and cleaning up of the SFC driver itself though.

edit: build this as detailed in my other posts about building mainline u-boot (make sure to build A-TF or it won't boot Linux!). As configured, write the idbloader.img to 0x10000 and the u-boot.itb to 0x200000 of the flash chip.
Upstreaming efforts for Linux: https://patchwork.ozlabs.org/project/li ... gmail.com/
I think this one is a few touch-ups away from prime-time.

Upstreaming efforts for U-boot: http://patchwork.ozlabs.org/project/ubo ... gmail.com/
Note that all things being equal, I plan on changing the clock names in U-boot to match the Linux driver. I'll also see if I can get dual mode working, as it takes flash read from 3.8MB/s to 5.7MB/s in Linux (though that's with DMA enabled, it must be disabled in SPL mode for U-boot). Lots to fix in this driver though.
The final pieces required to get mainline U-Boot to work (the SFC drivers and flash chip drivers) have been added to mainline.

https://source.denx.de/u-boot/u-boot/-/ ... 344d40fba4
https://source.denx.de/u-boot/u-boot/-/ ... 5172bfee0c

Please note there is a bug though that prevents booting from any medium on mainline U-boot, I wrote these patches to fix it and am awaiting their review.
https://patchwork.ozlabs.org/project/ub ... gmail.com/
These users thanked the author macromorgan for the post:
odroid (Tue Aug 17, 2021 9:33 am)

FergusL
Posts: 2
Joined: Tue Apr 04, 2023 6:36 pm
languages_spoken: french, english
ODROIDs: C2, RG351M (oga2 clone)
Has thanked: 2 times
Been thanked: 0
Contact:

Re: Using upstream u-boot 2021.01

Post by FergusL »

Hi and thanks a lot for the work here! FWIW, most of the information here is available here as well: https://github.com/u-boot/u-boot/blob/m ... miniloader

Also a quick look at current u-boot code confirms the above changes were finally mainlined! Thank you @macromorgan
Worth noting as well that many rk3326 devices are now mainlined in the kernel as well, including dtbs for many of the Odroid Go flavours, and that's also thanks to @macromorgan and @macc24!
Has anyone tried to bundle a new base image from a recent rootfs along with u-boot and kernel?

I am curious though about the section here; https://github.com/u-boot/u-boot/blob/m ... st#sd-card it's different from the link above and sounds "new", but does that mean that it's all that should be needed to do? (no trust, no 3-step-flashing, no nothing)?

Post Reply

Return to “Platform development”

Who is online

Users browsing this forum: No registered users and 1 guest