Custom image that defaults to LIME2 as the fallback board config

Started by kimfaint, May 18, 2022, 08:59:01 AM

Previous topic - Next topic

kimfaint

Using an A20 LIME2 board which is connected to a daughter board via the GPIO-1 header.  When to boots, if there is an error reading the EEPROM we get:
U-Boot SPL 2021.04+olimex-1-20220413.080758 (Apr 13 2022 - 08:09:11 +0000)
DRAM: 1024 MiB
CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
Loading configuration from EEPROM: Error
Loading configuration from MMC: OK
Verifying data: Error
Error

WARNING: The board cannot be detected!
Please run:
        'olinuxino config list' - Select your board
        'olinuxino config write' - Store the board configuration
        'reset' - Reset the board and load the configuration

Using 'A20-OLinuXino-LIME' as fallback configuration.

Trying to boot from MMC1


U-Boot 2021.04+olimex-1-20220413.080758 (Apr 13 2022 - 08:09:11 +0000) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
ID:    A20-OLinuXino-LIME Rev.A
SN:    00000000
MAC:   FF:FF:FF:FF:FF:FF
I2C:   ready
DRAM:  1 GiB
MMC:   mmc@1c0f000: 0
Loading Environment from EXT4... OK

As a result the ethernet doesn't work, because it is Using 'A20-OLinuXino-LIME' as fallback configuration.

How can I modify or create an OS image which uses A20-OLinuXino-LIME2 as the fallback configuration?  Or how can I modify the image so that it explicitly boots as a LIME2?

LubOlimex

I am not sure about how to change the default in the sources but if this happens you can recover by either fixing what is written in the EEPROM. Follow the description here:

https://github.com/OLIMEX/OLINUXINO/tree/master/SOFTWARE/A20/A20-eeprom-contents

or manually set the proper board in u-boot you can use what the help says:

'olinuxino config list' - Select your board
'olinuxino config write' - Store the board configuration
'saveenv'
'reset' - Reset the board and load the configuration

Refer to chapter "7.1 U-boot tools" in this document:

https://github.com/OLIMEX/OLINUXINO/blob/master/DOCUMENTS/OLIMAGE/Olimage-guide.pdf
Technical support and documentation manager at Olimex

kimfaint

Unfortunately, we cannot access the EEPROM at all because there is something else connected to GPIO-1 PB18.  So we need a method to force u-boot to select a different default board.

As has been mentioned by others the `olinuxino config write` command doesn't allow saving to MMC when the EEPROM fails:
=>           olinuxino config write 8340 e
Erasing EEPROM configuration...
ERROR: Failed to init eeprom!
Erasing MMC configuration...
Writting EEPROM configuration...
ERROR: Failed to init eeprom!
Writting MMC configuration...

LubOlimex

I think it can be changed here:

https://github.com/OLIMEX/u-boot-olinuxino/blob/release-20220413/board/olimex/a20_olinuxino/board.c

around line 66:

eeprom->header = OLINUXINO_EEPROM_MAGIC;
eeprom->id = 7739;
eeprom->revision.major = 'A';
eeprom->revision.minor = 0;
eeprom->serial = 0;
memset(eeprom->mac, 0xFF, 12);

and then rebuild the u-boot and overwrite the u-boot of the card that you use.

Rebuilding u-boot is described at the end of the olimage guide.
Technical support and documentation manager at Olimex

kimfaint

The end of the olimage guide only has instructions for rebuilding DTS and kernel.

However I found some instructions for rebuilding u-boot here: https://www.olimex.com/wiki/ArmbianHowTo#Building_u-boot

I have changed the board/olimex/a20_olinuxino/board.c file:
$ git diff
diff --git a/board/olimex/a20_olinuxino/board.c b/board/olimex/a20_olinuxino/board.c
index 19cc35ff27..f33f8fa27b 100644
--- a/board/olimex/a20_olinuxino/board.c
+++ b/board/olimex/a20_olinuxino/board.c
@@ -61,11 +61,11 @@ void spl_board_init(void)
        printf("\t\'olinuxino config list\' - Select your board\n");
        printf("\t\'olinuxino config write\' - Store the board configuration\n");
        printf("\t\'reset\' - Reset the board and load the configuration\n");
-      printf("\nUsing \'A20-OLinuXino-LIME\' as fallback configuration.\n\n");
+      printf("\nUsing \'A20-OLinuXino-LIME2\' as fallback configuration.\n\n");

        eeprom->header = OLINUXINO_EEPROM_MAGIC;
-      eeprom->id = 7739;
-      eeprom->revision.major = 'A';
+      eeprom->id = 8340;
+      eeprom->revision.major = 'E';
        eeprom->revision.minor = 0;
        eeprom->serial = 0;
        memset(eeprom->mac, 0xFF, 12);

and now successfully rebuilt the u-boot binary, which was essentially as easy as:
$ sudo apt install bison flex swig gcc-arm-linux-gnueabihf
$ make A20-OLinuXino_defconfig
$ make CROSS_COMPILE=arm-linux-gnueabihf-

Tomorrow I will try the Updating via USB part.

Though I am hoping I can just update the .img file with something like:
dd if=u-boot-sunxi-with-spl.bin of=A20-OLinuXino-bullseye-minimal-20220518-101434.img bs=1024 seek=8 conv=notrunc

JohnS

Just a nudge: you may need SKIP instead of SEEK.

(Either way, I'd read what's there before replacing it.)

John

kimfaint

Got back to looking into this today.

Regarding seek vs skip `man dd` says:
      seek=N skip N obs-sized blocks at start of output

      skip=N skip N ibs-sized blocks at start of input

So I think definately wan't to skip at the output file.  Hence using seek is correct.

The command I ended up using was:
dd if=u-boot-sunxi-with-spl.bin of=A20-OLinuXino-bullseye-minimal-20220518-101434.img bs=1024 seek=8 conv=notrunc

I was then able to boot my hardware and when the EEPROM error occurred, it fell back to a LIME2, and the network interface worked and all was good.
U-Boot SPL 2021.04-00022-gb39c5a7c93-dirty (May 19 2022 - 15:16:42 +1000)
DRAM: 1024 MiB
CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
Loading configuration from EEPROM: Error
Loading configuration from MMC: OK
Verifying data: Error
Error

WARNING: The board cannot be detected!
Please run:
        'olinuxino config list' - Select your board
        'olinuxino config write' - Store the board configuration
        'reset' - Reset the board and load the configuration

Using 'A20-OLinuXino-LIME2' as fallback configuration.

Trying to boot from MMC1


U-Boot 2021.04-00022-gb39c5a7c93-dirty (May 19 2022 - 15:16:42 +1000) Allwinner Technology

CPU:  Allwinner A20 (SUN7I)
ID:    A20-OLinuXino-LIME2-e4GB Rev.E
SN:    00000000
MAC:  FF:FF:FF:FF:FF:FF
I2C:  ready
DRAM:  1 GiB
MMC:  mmc@1c0f000: 0, mmc@1c11000: 1
Loading Environment from EXT4... *** Warning - bad CRC, using default environment

Loading Environment from FAT... ** No device specified **

Happy days ;D

JohnS

I'm glad it's working!

Sorry for the SKIP/SEEK confusion.

John

megamax

Hi,
I have the same problem because the my daughter board was designed before the introduction of eeprom in SOM boards.. there is another solution: if you see the the boot output it try to read configuration in the mmc but (for me) fails the verification. I read the uboot code and in effect it there are all functions to read and write the configuration in the sector 15 of the mmc, but I think there's something broken in the code.
So, here what I did:
* Put the SOM in EVB to get i2c work
* Read the content of the eeprom whith cmd "i2cdump 1 0x50"
* Copy the content readed from the eeprom in the mmc with "hexedit" starting from "1E00" position.

It works for me and now uboot reads configuration from MMC, here's my boot:


U-Boot SPL 2021.04+olimex-1-20220413.080758 (Apr 13 2022 - 08:09:11 +0000)
DRAM: 1024 MiB
CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
Loading configuration from EEPROM: Error
Loading configuration from MMC: OK
Verifying data: OK
Trying to boot from MMC1


U-Boot 2021.04+olimex-1-20220413.080758 (Apr 13 2022 - 08:09:11 +0000) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
ID:    T2-SOM-IND Rev.E2
SN:    000236A8
MAC:   FF:FF:FF:FF:FF:FF
I2C:   ready

@LubOlimex can be uboot fixed? It might be useful for older boards