Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish release with idb_finish.img binary? #3

Closed
dmikushin opened this issue Mar 6, 2023 · 9 comments
Closed

Publish release with idb_finish.img binary? #3

dmikushin opened this issue Mar 6, 2023 · 9 comments

Comments

@dmikushin
Copy link
Contributor

Hi @MarcinWad,

Would you like to publish your own version of idb_finish.img as a project Release, so that we could verify our work using yours as a reference?

@MarcinWad
Copy link
Owner

Of course.
Will do that.

@MarcinWad
Copy link
Owner

Done

@dmikushin
Copy link
Contributor Author

Thank you 🙏

@dmikushin
Copy link
Contributor Author

dmikushin commented Mar 7, 2023

I flashed image to the SD card only, not yet to the SPI. Somehow I could get a U-boot command prompt only for the very first time, and I typed "reset". Now I try to boot again and again, but U-boot just displays an error and does not give "=>" to let me enter into interactive mode. What am I doing wrong?

Welcome to minicom 2.8

OPTIONS: I18n                                               
Port /dev/ttyUSB0, 22:07:30                                 
                                                            
Press CTRL-A Z for help on special keys                     
                                                            
                                                            
U-Boot TPL 2023.01-rc4 (Jan 03 2023 - 11:10:10)             
DDR4, 333MHz                                                
BW=32 Col=10 Bk=4 BG=2 CS0 Row=16 CS=1 Die BW=16 Size=2048MB
Trying to boot from BOOTROM                                 
Returning to boot ROM...                                    
Running in level: 3                                         
                                                            
U-Boot SPL 2023.01-rc4 (Jan 03 2023 - 11:10:10 +0100)       
rockchip_spi_of_to_plat: base=ff190000, max-frequency=50000000, deactivate_delay=0
rockchip_spi_probe: probe                                   
rockchip_spi_probe: rate = 750000                           
Trying to boot from MMC1
spl: mmc init failed with error: -110
Trying to boot from SPI
Trying to boot from MMC1
spl: mmc init failed with error: -110
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
```

@dmikushin
Copy link
Contributor Author

dmikushin commented Mar 7, 2023

Strange, maybe my SD card is bad? I flashed another one and got everything working:

Welcome to minicom 2.8

OPTIONS: I18n                                               
Port /dev/ttyUSB0, 23:04:40                                 
                                                            
Press CTRL-A Z for help on special keys                     
                                                  
U-Boot TPL 2023.01-rc4 (Jan 03 2023 - 11:10:10)             
DDR4, 333MHz                                                
BW=32 Col=10 Bk=4 BG=2 CS0 Row=16 CS=1 Die BW=16 Size=2048MB
Trying to boot from BOOTROM                                 
Returning to boot ROM...                                    
Running in level: 3                                         
                                                            
U-Boot SPL 2023.01-rc4 (Jan 03 2023 - 11:10:10 +0100)       
rockchip_spi_of_to_plat: base=ff190000, max-frequency=50000000, deactivate_delay=0
rockchip_spi_probe: probe                                   
rockchip_spi_probe: rate = 750000                           
Trying to boot from MMC1
NOTICE:  BL31: v2.3():v2.3-dirty
NOTICE:  BL31: Built : 11:04:37, Jan  3 2023
NOTICE:  BL31:Rockchip release version: v1.2
ns16550_serial serial@ff130000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19


U-Boot 2023.01-rc4 (Jan 03 2023 - 11:10:12 +0100)

Model: FriendlyElec NanoPi R2S
DRAM:  2 GiB
PMIC:  RK8050 (on=0x40, off=0x00)
Core:  235 devices, 25 uclasses, devicetree: separate
MMC:   mmc@ff500000: 1
Loading Environment from SPIFlash... rockchip_spi_of_to_plat: base=ff190000, max-frequency=50000000, deactivate_delay=0
rockchip_spi_probe: probe
rockchip_spi_probe: rate = 750000
SF: Detected w25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

In:    serial@ff130000
Out:   serial@ff130000
Err:   serial@ff130000
Model: FriendlyElec NanoPi R2S
EFUSE
Net:   eth0: ethernet@ff540000
Hit any key to stop autoboot:  0 
=> sf erase 0x0 0x200000
No SPI flash selected. Please run `sf probe'
=> sf probe
SF: Detected w25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
=> sf erase 0x0 0x200000
SF: 2097152 bytes @ 0x0 Erased: OK
=> mmc dev 1
switch to partitions #0, OK
mmc1 is current device
=> mmc read 0x300000 0x0 0x1000

MMC read: dev # 1, block # 0, count 4096 ... 4096 blocks read: OK
=> sf write 0x300000 0x0 0x200000 
device 0 offset 0x0, size 0x200000
SF: 2097152 bytes @ 0x0 Written: OK

@MarcinWad
Copy link
Owner

MarcinWad commented Mar 8, 2023 via email

@dmikushin
Copy link
Contributor Author

Did you solder flash bigger than 16Mbyes?

No, it is exactly 16 MBytes.

@dmikushin
Copy link
Contributor Author

dmikushin commented Mar 14, 2023

OK, I've figured out the following:

  1. Our installation procedure is two-fold: we install the same firmware first on the SD card, and then to SPI Flash chip. But image for SD card and SPI chip cannot be the same, as explained below.
  2. When booting from an SD card, the "main" u-boot.itb is searched for at block 16384. With SD card block sector implied to be 512 bytes by default, this means a u-boot image must be presented at ~8MBytes offset. I don't know how to alter this setting.
  3. In case of our 1-MByte idb_finish.img image, the u-boot is therefore will be searched in the SD card region, which is not written by us:
  • In case you are using a new clean SD card, you will get a SPL: failed to boot from all boot devices error as shown above.
  • In case you are using an un-erased SD card from some previous installation of embedded Linux, the U-boot from that installation will be taken. It might happen to have SPI and SPI chip support enabled, so the rest of steps in our guide might succeed by coincidence.
  1. In order to really support both SD card and SPI in a single image, our idb_finish.img should be changed to have u-boot.itb written twice at 0x40000 and at sector 16384, which can be done this way:
  • Extract u-boot.itb from released idb_finish.img at 0x40000:
dd if=idb_finish.img of=u-boot.itb bs=1 skip=262144
  • Write a copy of u-boot.itb at sector 16384 of idb_finish.img:
dd if=u-boot.itb of=idb_finish.img bs=512 seek=16384

Is there a way to make SD card to use the same offset 0x40000?

@dmikushin
Copy link
Contributor Author

Is there a way to make SD card to use the same offset 0x40000?

Maybe Jagan @openedev has a clue?

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

No branches or pull requests

2 participants